Simplification of bits per macroblock estimate.
The bits per macroblock estimate based on Q had the form :-
Enumerator = X + (( X * Q) >> 12)
BitsPerMb = (Enumerator * correction_factor) / Q
Where X is a constant and Q is the quantizer (not quantizer index).
The secondary term in the calculation of Enumerator - "((X * Q) >> 12)"
has only a modest impact and is never more than a few % for any
allowed value of Q.
This patch removes this term and tweaks the baseline value of X slightly.
As well as simplifying things there are small average gains in metrics.
(Av Psnr Ov Psnr, Ssim, Psnr-hvs)
Low Res: 0.034 0.006 -0.028 0.069
UCG 360: 0.069 -0.067 0.035 0.039
Mid Res: -0.077 -0.098 -0.154 -0.062
Hd Res: -0.024 -0.076 -0.05 -0.008
STATS_CHANGED
Change-Id: I3ab4d07d2e404a9c62fb855b1128bed53268b5ae
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index bbc66f3..17cd1e4 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -173,7 +173,7 @@
const int mid = (low + high) >> 1;
const double mid_factor = calc_correction_factor(error_per_mb, mid);
const double q = av1_convert_qindex_to_q(mid, bit_depth);
- const int enumerator = 1600000 + ((int)(1600000 * q) >> 12);
+ const int enumerator = 1650000;
const int mid_bits_per_mb =
(int)((enumerator * mid_factor * group_weight_factor) / q);
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 490d9ef..de96e97 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -155,13 +155,12 @@
int av1_rc_bits_per_mb(FRAME_TYPE frame_type, int qindex,
double correction_factor, aom_bit_depth_t bit_depth) {
const double q = av1_convert_qindex_to_q(qindex, bit_depth);
- int enumerator = frame_type == KEY_FRAME ? 2000000 : 1440000;
+ int enumerator = frame_type == KEY_FRAME ? 2000000 : 1500000;
assert(correction_factor <= MAX_BPB_FACTOR &&
correction_factor >= MIN_BPB_FACTOR);
// q based adjustment to baseline enumerator
- enumerator += (int)(enumerator * q) >> 12;
return (int)(enumerator * correction_factor / q);
}
diff --git a/test/fwd_kf_test.cc b/test/fwd_kf_test.cc
index 6543d85..2a37ff1 100644
--- a/test/fwd_kf_test.cc
+++ b/test/fwd_kf_test.cc
@@ -23,7 +23,7 @@
} FwdKfTestParam;
const FwdKfTestParam kTestParams[] = {
- { 4, 34.1 }, { 6, 33.4 }, { 8, 33.0 },
+ { 4, 34.0 }, { 6, 33.3 }, { 8, 33.0 },
{ 12, 32.4 }, { 16, 32.3 }, { 18, 32.1 }
};