From 944fe777023339db3ffdc813e3318a9b49160474 Mon Sep 17 00:00:00 2001 From: rigaya Date: Sat, 29 Feb 2020 17:43:41 +0900 Subject: [PATCH] =?UTF-8?q?HEVC=E3=81=A7=E3=82=82=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E3=83=93=E3=83=83=E3=83=88=E3=83=AC=E3=83=BC=E3=83=88=E4=B8=8A?= =?UTF-8?q?=E9=99=90=E3=81=AE=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E6=99=82?= =?UTF-8?q?=E3=81=ABref=E3=82=92=E5=8F=82=E7=85=A7=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VCECore/hevc_level.cpp | 14 ++++++++++++-- VCECore/hevc_level.h | 2 +- VCECore/vce_core.cpp | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) 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);