diff --git a/VCECore/hevc_level.cpp b/VCECore/hevc_level.cpp index 80117a01..eaea15b6 100644 --- a/VCECore/hevc_level.cpp +++ b/VCECore/hevc_level.cpp @@ -76,10 +76,20 @@ static const uint32_t HEVC_LEVEL_LIMITS[_countof(HEVC_LEVEL_INDEX)+1][LEVEL_COLU }; //必要なLevelを計算する, 適合するLevelがなければ 0 を返す -int calc_hevc_auto_level(int width, int height, int fps_num, int fps_den, bool high_tier, int max_bitrate) { +int calc_hevc_auto_level(int width, int height, int ref, int fps_num, int fps_den, bool high_tier, int max_bitrate) { + int ref_mul_x3 = 3; //refのためにsample数にかけたい数を3倍したもの(あとで3で割る) + if (ref > 12) { + ref_mul_x3 = 4*3; + } else if (ref > 8) { + ref_mul_x3 = 2*3; + } else if (ref > 6) { + ref_mul_x3 = 4; + } else { + ref_mul_x3 = 3; + } uint32_t data[LEVEL_COLUMNS] = { (uint32_t)std::min((uint64_t)(width * height) * fps_num / fps_den, (uint64_t)UINT32_MAX), - (uint32_t)width * height, + (uint32_t)width * height * ref_mul_x3 / 3, (high_tier) ? 0 : (uint32_t)max_bitrate, (high_tier) ? (uint32_t)max_bitrate : 0, NULL diff --git a/VCECore/hevc_level.h b/VCECore/hevc_level.h index dfd0b73d..a0deb8cc 100644 --- a/VCECore/hevc_level.h +++ b/VCECore/hevc_level.h @@ -28,7 +28,7 @@ #ifndef __HEVC_LEVEL_H__ #define __HEVC_LEVEL_H__ -int calc_hevc_auto_level(int width, int height, int fps_num, int fps_den, bool high_tier, int max_bitrate); +int calc_hevc_auto_level(int width, int height, int ref, int fps_num, int fps_den, bool high_tier, int max_bitrate); int get_hevc_max_bitrate(int level, bool high_tier); bool is_avail_hevc_high_tier(int level); diff --git a/VCECore/vce_core.cpp b/VCECore/vce_core.cpp index 03a12864..8aa60772 100644 --- a/VCECore/vce_core.cpp +++ b/VCECore/vce_core.cpp @@ -1358,7 +1358,7 @@ RGY_ERR VCECore::initEncoder(VCEParam *prm) { } else if (prm->codec == RGY_CODEC_HEVC) { const bool high_tier = prm->codecParam[prm->codec].nTier == AMF_VIDEO_ENCODER_HEVC_TIER_HIGH; if (level == 0) { - level = calc_hevc_auto_level(m_encWidth, m_encHeight, //m_stEncConfig.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB, + level = calc_hevc_auto_level(m_encWidth, m_encHeight, prm->nRefFrames, m_encFps.n(), m_encFps.d(), high_tier, max_bitrate_kbps); } max_bitrate_kbps = get_hevc_max_bitrate(level, high_tier);