ref: 63fc44dfa5c459c3736498f1f6e618cff3c56eeb
parent: 6bf7e2cc3777921477024bf4ed28fde28f02ca07
author: John Koleszar <jkoleszar@google.com>
date: Fri Feb 4 06:36:04 EST 2011
correct quantizer initialization The encoder was not correctly catching transitions in the quantizer deltas. If a delta_q was set, then the quantizer would be reinitialized on every frame, but if they transitioned to 0, the quantizer would not be reinitialized, leading to a encode-decode mismatch. This bug was triggered by commit 999e155, which sets a Y2 delta Q for very low base Q levels. Change-Id: Ia6733464a55ee4ff2edbb82c0873980d345446f5
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -399,13 +399,6 @@
// Clear Zbin mode boost for default case
cpi->zbin_mode_boost = 0;
- // vp8cx_init_quantizer() is first called in vp8_create_compressor(). A check is added here so that vp8cx_init_quantizer() is only called
- // when these values are not all zero.
- if (cpi->common.y1dc_delta_q | cpi->common.y2dc_delta_q | cpi->common.uvdc_delta_q | cpi->common.y2ac_delta_q | cpi->common.uvac_delta_q)
- {
- vp8cx_init_quantizer(cpi);
- }
-
// MB level quantizer setup
vp8cx_mb_init_quantizer(cpi, &cpi->mb);
}
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -3123,11 +3123,14 @@
return 1;
}
+
static void set_quantizer(VP8_COMP *cpi, int Q)
{
VP8_COMMON *cm = &cpi->common;
MACROBLOCKD *mbd = &cpi->mb.e_mbd;
+ int update = 0;
+ update |= cm->base_qindex != Q;
cm->base_qindex = Q;
cm->y1dc_delta_q = 0;
@@ -3138,13 +3141,19 @@
if(Q<4)
{
+ update |= cm->y2dc_delta_q != 4-Q;
cm->y2dc_delta_q = 4-Q;
}
+
// Set Segment specific quatizers
mbd->segment_feature_data[MB_LVL_ALT_Q][0] = cpi->segment_feature_data[MB_LVL_ALT_Q][0];
mbd->segment_feature_data[MB_LVL_ALT_Q][1] = cpi->segment_feature_data[MB_LVL_ALT_Q][1];
mbd->segment_feature_data[MB_LVL_ALT_Q][2] = cpi->segment_feature_data[MB_LVL_ALT_Q][2];
mbd->segment_feature_data[MB_LVL_ALT_Q][3] = cpi->segment_feature_data[MB_LVL_ALT_Q][3];
+
+ if(update)
+ vp8cx_init_quantizer(cpi);
+
}
static void update_alt_ref_frame_and_stats(VP8_COMP *cpi)
--
⑨