summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorPaul Wilkins <paulwilkins@google.com>2013-02-21 10:00:36 +0000
committerPaul Wilkins <paulwilkins@google.com>2013-02-22 14:00:51 +0000
commitdbf49420461de4030fdf79ae74fc30e5ce513639 (patch)
tree93d1b703727da5688055af813d8a93172c986b7f /vp9
parentef01b956d88e68a4cb66b94d6a99a46c6909fa1a (diff)
downloadlibvpx-dbf49420461de4030fdf79ae74fc30e5ce513639.tar
libvpx-dbf49420461de4030fdf79ae74fc30e5ce513639.tar.gz
libvpx-dbf49420461de4030fdf79ae74fc30e5ce513639.tar.bz2
libvpx-dbf49420461de4030fdf79ae74fc30e5ce513639.zip
Experimental removal of over quant code
The over quant code was added in VP8 post bitstream freeze to allow compression to lower data rates In VP9 the real qualtizer range has been greatly extended anyway. Change-Id: I5d384fa5e9a83ef75a3df34ee30627bd21901526
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_onyx_if.c66
-rw-r--r--vp9/encoder/vp9_onyx_int.h2
-rw-r--r--vp9/encoder/vp9_quantize.c12
-rw-r--r--vp9/encoder/vp9_ratectrl.c60
-rw-r--r--vp9/encoder/vp9_rdopt.c10
5 files changed, 8 insertions, 142 deletions
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 4c73cb5c8..5b1ad2b6d 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -2562,8 +2562,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
int q_low;
int q_high;
- int zbin_oq_high;
- int zbin_oq_low = 0;
int top_index;
int bottom_index;
@@ -2576,11 +2574,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
#if RESET_FOREACH_FILTER
int q_low0;
int q_high0;
- int zbin_oq_high0;
- int zbin_oq_low0 = 0;
int Q0;
- int last_zbin_oq;
- int last_zbin_oq0;
int active_best_quality0;
int active_worst_quality0;
double rate_correction_factor0;
@@ -2614,7 +2608,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
}
// Clear zbin over-quant value and mode boost values.
- cpi->zbin_over_quant = 0;
cpi->zbin_mode_boost = 0;
// Enable or disable mode based tweaking of the zbin
@@ -2804,18 +2797,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// Determine initial Q to try
Q = vp9_regulate_q(cpi, cpi->this_frame_target);
}
-#if RESET_FOREACH_FILTER
- last_zbin_oq = cpi->zbin_over_quant;
-#endif
-
- // Set highest allowed value for Zbin over quant
- if (cm->frame_type == KEY_FRAME)
- zbin_oq_high = 0; // ZBIN_OQ_MAX/16
- else if (cpi->refresh_alt_ref_frame
- || (cpi->refresh_golden_frame && !cpi->source_alt_ref_active))
- zbin_oq_high = 16;
- else
- zbin_oq_high = ZBIN_OQ_MAX;
vp9_compute_frame_size_bounds(cpi, &frame_under_shoot_limit,
&frame_over_shoot_limit);
@@ -2898,9 +2879,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
q_low0 = q_low;
q_high0 = q_high;
Q0 = Q;
- zbin_oq_low0 = zbin_oq_low;
- zbin_oq_high0 = zbin_oq_high;
- last_zbin_oq0 = last_zbin_oq;
rate_correction_factor0 = cpi->rate_correction_factor;
gf_rate_correction_factor0 = cpi->gf_rate_correction_factor;
active_best_quality0 = cpi->active_best_quality;
@@ -3059,23 +3037,12 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
if (cpi->projected_frame_size > cpi->this_frame_target) {
q_low = (Q < q_high) ? (Q + 1) : q_high; // Raise Qlow as to at least the current value
- if (cpi->zbin_over_quant > 0) // If we are using over quant do the same for zbin_oq_low
- zbin_oq_low = (cpi->zbin_over_quant < zbin_oq_high) ? (cpi->zbin_over_quant + 1) : zbin_oq_high;
-
if (undershoot_seen || (loop_count > 1)) {
// Update rate_correction_factor unless cpi->active_worst_quality has changed.
if (!active_worst_qchanged)
vp9_update_rate_correction_factors(cpi, 1);
Q = (q_high + q_low + 1) / 2;
-
- // Adjust cpi->zbin_over_quant (only allowed when Q is max)
- if (Q < MAXQ)
- cpi->zbin_over_quant = 0;
- else {
- zbin_oq_low = (cpi->zbin_over_quant < zbin_oq_high) ? (cpi->zbin_over_quant + 1) : zbin_oq_high;
- cpi->zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
- }
} else {
// Update rate_correction_factor unless cpi->active_worst_quality has changed.
if (!active_worst_qchanged)
@@ -3083,7 +3050,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
Q = vp9_regulate_q(cpi, cpi->this_frame_target);
- while (((Q < q_low) || (cpi->zbin_over_quant < zbin_oq_low)) && (Retries < 10)) {
+ while ((Q < q_low) && (Retries < 10)) {
vp9_update_rate_correction_factors(cpi, 0);
Q = vp9_regulate_q(cpi, cpi->this_frame_target);
Retries++;
@@ -3094,10 +3061,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
}
// Frame is too small
else {
- if (cpi->zbin_over_quant == 0)
- q_high = (Q > q_low) ? (Q - 1) : q_low; // Lower q_high if not using over quant
- else // else lower zbin_oq_high
- zbin_oq_high = (cpi->zbin_over_quant > zbin_oq_low) ? (cpi->zbin_over_quant - 1) : zbin_oq_low;
+ q_high = (Q > q_low) ? (Q - 1) : q_low;
if (overshoot_seen || (loop_count > 1)) {
// Update rate_correction_factor unless cpi->active_worst_quality has changed.
@@ -3105,12 +3069,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
vp9_update_rate_correction_factors(cpi, 1);
Q = (q_high + q_low) / 2;
-
- // Adjust cpi->zbin_over_quant (only allowed when Q is max)
- if (Q < MAXQ)
- cpi->zbin_over_quant = 0;
- else
- cpi->zbin_over_quant = (zbin_oq_high + zbin_oq_low) / 2;
} else {
// Update rate_correction_factor unless cpi->active_worst_quality has changed.
if (!active_worst_qchanged)
@@ -3127,7 +3085,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
q_low = Q;
}
- while (((Q > q_high) || (cpi->zbin_over_quant > zbin_oq_high)) && (Retries < 10)) {
+ while ((Q > q_high) && (Retries < 10)) {
vp9_update_rate_correction_factors(cpi, 0);
Q = vp9_regulate_q(cpi, cpi->this_frame_target);
Retries++;
@@ -3143,16 +3101,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
else if (Q < q_low)
Q = q_low;
- // Clamp cpi->zbin_over_quant
- cpi->zbin_over_quant = (cpi->zbin_over_quant < zbin_oq_low) ?
- zbin_oq_low : (cpi->zbin_over_quant > zbin_oq_high) ?
- zbin_oq_high : cpi->zbin_over_quant;
-
- // Loop = ((Q != last_q) || (last_zbin_oq != cpi->zbin_over_quant)) ? TRUE : FALSE;
Loop = ((Q != last_q)) ? TRUE : FALSE;
-#if RESET_FOREACH_FILTER
- last_zbin_oq = cpi->zbin_over_quant;
-#endif
} else
Loop = FALSE;
@@ -3196,12 +3145,9 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
if (Loop == TRUE) {
overshoot_seen = FALSE;
undershoot_seen = FALSE;
- zbin_oq_low = zbin_oq_low0;
- zbin_oq_high = zbin_oq_high0;
q_low = q_low0;
q_high = q_high0;
Q = Q0;
- cpi->zbin_over_quant = last_zbin_oq = last_zbin_oq0;
cpi->rate_correction_factor = rate_correction_factor0;
cpi->gf_rate_correction_factor = gf_rate_correction_factor0;
cpi->active_best_quality = active_best_quality0;
@@ -3450,8 +3396,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->avg_q,
vp9_convert_qindex_to_q(cpi->ni_av_qi),
vp9_convert_qindex_to_q(cpi->cq_target_quality),
- cpi->zbin_over_quant,
- // cpi->avg_frame_qindex, cpi->zbin_over_quant,
cpi->refresh_golden_frame, cpi->refresh_alt_ref_frame,
cm->frame_type, cpi->gfu_boost,
cpi->twopass.est_max_qcorrection_factor,
@@ -3464,7 +3408,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
else
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
"%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
- "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
+ "%5d %5d %8d %8.2f %10d %10.3f"
"%8d %10d %10d %10d\n",
cpi->common.current_video_frame,
cpi->this_frame_target, cpi->projected_frame_size,
@@ -3480,8 +3424,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->avg_q,
vp9_convert_qindex_to_q(cpi->ni_av_qi),
vp9_convert_qindex_to_q(cpi->cq_target_quality),
- cpi->zbin_over_quant,
- // cpi->avg_frame_qindex, cpi->zbin_over_quant,
cpi->refresh_golden_frame, cpi->refresh_alt_ref_frame,
cm->frame_type, cpi->gfu_boost,
cpi->twopass.est_max_qcorrection_factor,
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index 813003388..cfd761aa9 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -53,7 +53,6 @@
#define GF_ZEROMV_ZBIN_BOOST 12
#define LF_ZEROMV_ZBIN_BOOST 6
#define MV_ZBIN_BOOST 4
-#define ZBIN_OQ_MAX 192
#define VP9_TEMPORAL_ALT_REF 1
@@ -421,7 +420,6 @@ typedef struct VP9_COMP {
double tot_q;
double avg_q;
- int zbin_over_quant;
int zbin_mode_boost;
int zbin_mode_boost_enabled;
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index aed379a5b..8ae53e60e 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -484,8 +484,7 @@ void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) {
// Y
zbin_extra = (cpi->common.Y1dequant[QIndex][1] *
- (cpi->zbin_over_quant +
- cpi->zbin_mode_boost +
+ (cpi->zbin_mode_boost +
x->act_zbin_adj)) >> 7;
for (i = 0; i < 16; i++) {
@@ -504,8 +503,7 @@ void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) {
// UV
zbin_extra = (cpi->common.UVdequant[QIndex][1] *
- (cpi->zbin_over_quant +
- cpi->zbin_mode_boost +
+ (cpi->zbin_mode_boost +
x->act_zbin_adj)) >> 7;
for (i = 16; i < 24; i++) {
@@ -533,8 +531,7 @@ void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) {
// Y
zbin_extra = (cpi->common.Y1dequant[QIndex][1] *
- (cpi->zbin_over_quant +
- cpi->zbin_mode_boost +
+ (cpi->zbin_mode_boost +
x->act_zbin_adj)) >> 7;
for (i = 0; i < 16; i++) {
x->block[i].zbin_extra = (int16_t)zbin_extra;
@@ -542,8 +539,7 @@ void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) {
// UV
zbin_extra = (cpi->common.UVdequant[QIndex][1] *
- (cpi->zbin_over_quant +
- cpi->zbin_mode_boost +
+ (cpi->zbin_mode_boost +
x->act_zbin_adj)) >> 7;
for (i = 16; i < 24; i++) {
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index bb608ab37..0f4371cd1 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -410,23 +410,6 @@ void vp9_update_rate_correction_factors(VP9_COMP *cpi, int damp_var) {
vp9_bits_per_mb(cpi->common.frame_type, Q)) *
cpi->common.MBs) / (1 << BPER_MB_NORMBITS));
- // Make some allowance for cpi->zbin_over_quant
- if (cpi->zbin_over_quant > 0) {
- int Z = cpi->zbin_over_quant;
- double Factor = 0.99;
- double factor_adjustment = 0.01 / 256.0; // (double)ZBIN_OQ_MAX;
-
- while (Z > 0) {
- Z--;
- projected_size_based_on_q =
- (int)(Factor * projected_size_based_on_q);
- Factor += factor_adjustment;
-
- if (Factor >= 0.999)
- Factor = 0.999;
- }
- }
-
// Work out a size correction factor.
// if ( cpi->this_frame_target > 0 )
// correction_factor = (100 * cpi->projected_frame_size) / cpi->this_frame_target;
@@ -488,9 +471,6 @@ int vp9_regulate_q(VP9_COMP *cpi, int target_bits_per_frame) {
int bits_per_mb_at_this_q;
double correction_factor;
- // Reset Zbin OQ value
- cpi->zbin_over_quant = 0;
-
// Select the appropriate correction factor based upon type of frame.
if (cpi->common.frame_type == KEY_FRAME)
correction_factor = cpi->key_frame_rate_correction_factor;
@@ -525,46 +505,6 @@ int vp9_regulate_q(VP9_COMP *cpi, int target_bits_per_frame) {
last_error = bits_per_mb_at_this_q - target_bits_per_mb;
} while (++i <= cpi->active_worst_quality);
-
- // If we are at MAXQ then enable Q over-run which seeks to claw back additional bits through things like
- // the RD multiplier and zero bin size.
- if (Q >= MAXQ) {
- int zbin_oqmax;
-
- double Factor = 0.99;
- double factor_adjustment = 0.01 / 256.0; // (double)ZBIN_OQ_MAX;
-
- if (cpi->common.frame_type == KEY_FRAME)
- zbin_oqmax = 0; // ZBIN_OQ_MAX/16
- else if (cpi->refresh_alt_ref_frame
- || (cpi->refresh_golden_frame && !cpi->source_alt_ref_active))
- zbin_oqmax = 16;
- else
- zbin_oqmax = ZBIN_OQ_MAX;
-
- // Each incrment in the zbin is assumed to have a fixed effect on bitrate. This is not of course true.
- // The effect will be highly clip dependent and may well have sudden steps.
- // The idea here is to acheive higher effective quantizers than the normal maximum by expanding the zero
- // bin and hence decreasing the number of low magnitude non zero coefficients.
- while (cpi->zbin_over_quant < zbin_oqmax) {
- cpi->zbin_over_quant++;
-
- if (cpi->zbin_over_quant > zbin_oqmax)
- cpi->zbin_over_quant = zbin_oqmax;
-
- // Adjust bits_per_mb_at_this_q estimate
- bits_per_mb_at_this_q = (int)(Factor * bits_per_mb_at_this_q);
- Factor += factor_adjustment;
-
- if (Factor >= 0.999)
- Factor = 0.999;
-
- if (bits_per_mb_at_this_q <= target_bits_per_mb) // Break out if we get down to the target rate
- break;
- }
-
- }
-
return Q;
}
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index ec157961a..c8e7468ef 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -217,16 +217,6 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int QIndex) {
cpi->RDMULT = compute_rd_mult(QIndex);
- // Extend rate multiplier along side quantizer zbin increases
- if (cpi->zbin_over_quant > 0) {
- double oq_factor;
-
- // Experimental code using the same basic equation as used for Q above
- // The units of cpi->zbin_over_quant are 1/128 of Q bin size
- oq_factor = 1.0 + ((double)0.0015625 * cpi->zbin_over_quant);
- cpi->RDMULT = (int)((double)cpi->RDMULT * oq_factor * oq_factor);
- }
-
if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME)) {
if (cpi->twopass.next_iiratio > 31)
cpi->RDMULT += (cpi->RDMULT * rd_iifactor[31]) >> 4;