svt-av1: add patch to fix quality degradation when MaxBitRate is specified

from upstream via Brad
This commit is contained in:
sthen 2022-12-12 13:51:34 +00:00
parent dea5055fd9
commit 0c472397fb
2 changed files with 33 additions and 0 deletions

View File

@ -5,6 +5,7 @@ COMMENT= scalable AV1 encoder/decoder
VER= 1.4.0
DISTNAME= SVT-AV1-v${VER}
PKGNAME= svt-av1-${VER}
REVISION= 0
CATEGORIES= multimedia
MASTER_SITES= https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v${VER}/
EXTRACT_SUFX= .tar.bz2

View File

@ -0,0 +1,32 @@
Fix Quality Degradation When MaxBitRate Specified, Issue #2017
b4c89396fa22791570c3992f9c56a6a65bdaca48
Index: Source/Lib/Encoder/Codec/EbRateControlProcess.c
--- Source/Lib/Encoder/Codec/EbRateControlProcess.c.orig
+++ Source/Lib/Encoder/Codec/EbRateControlProcess.c
@@ -873,6 +873,11 @@ static int crf_qindex_calc(PictureControlSet *pcs, RAT
}
// Scale r0 based on the GOP structure
ppcs->r0 = ppcs->r0 / tpl_hl_islice_div_factor[scs_ptr->max_heirachical_level];
+
+ // when frames_to_key not available, i.e. in 1 pass encoding
+ rc->kf_boost = get_cqp_kf_boost_from_r0(ppcs->r0, -1, scs_ptr->input_resolution);
+ int max_boost = ppcs->used_tpl_frame_num * KB;
+ rc->kf_boost = AOMMIN(rc->kf_boost, max_boost);
} else {
if (use_qstep_based_q_calc) {
if (ppcs->tpl_ctrls.r0_adjust_factor) {
@@ -881,6 +886,13 @@ static int crf_qindex_calc(PictureControlSet *pcs, RAT
ppcs->r0 = ppcs->r0 / tpl_hl_base_frame_div_factor[scs_ptr->max_heirachical_level];
}
}
+ int num_stats_required_for_gfu_boost = ppcs->tpl_group_size + (1 << hierarchical_levels);
+ double min_boost_factor = (int32_t)1 << (hierarchical_levels >> 1);
+ if (hierarchical_levels & 1) {
+ min_boost_factor *= CONST_SQRT2;
+ }
+ rc->gfu_boost = get_gfu_boost_from_r0_lap(
+ min_boost_factor, MAX_GFUBOOST_FACTOR, ppcs->r0, num_stats_required_for_gfu_boost);
}
q = active_worst_quality;