Skip to content

Commit

Permalink
HEVCでも最大ビットレート上限のチェック時にrefを参照するように。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Feb 29, 2020
1 parent cbb3634 commit 944fe77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions VCECore/hevc_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VCECore/hevc_level.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion VCECore/vce_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 944fe77

Please sign in to comment.