From fb5a692d27d01bd088fba0b7357c95d5165669ed Mon Sep 17 00:00:00 2001 From: Attila Nagy Date: Fri, 18 Feb 2011 10:01:49 +0200 Subject: [PATCH] Reinitialize quantizer only when any delta is changing No need to reinitialize for base Q changes. Change-Id: Ie76ec21dd3c5582d5183dbed75ed73a1eed3e291 --- vp8/encoder/onyx_if.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 6ab1b39f7..f55441ec0 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -3051,21 +3051,27 @@ 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; + int new_delta_q; cm->base_qindex = Q; + /* if any of the delta_q values are changing update flag has to be set */ + /* currently only y2dc_delta_q may change */ + cm->y1dc_delta_q = 0; - cm->y2dc_delta_q = 0; cm->y2ac_delta_q = 0; cm->uvdc_delta_q = 0; cm->uvac_delta_q = 0; - if(Q<4) + if (Q < 4) { - update |= cm->y2dc_delta_q != 4-Q; - cm->y2dc_delta_q = 4-Q; + new_delta_q = 4-Q; } + else + new_delta_q = 0; + + update |= cm->y2dc_delta_q != new_delta_q; + cm->y2dc_delta_q = new_delta_q; + // Set Segment specific quatizers mbd->segment_feature_data[MB_LVL_ALT_Q][0] = cpi->segment_feature_data[MB_LVL_ALT_Q][0]; @@ -3073,6 +3079,7 @@ static void set_quantizer(VP8_COMP *cpi, int Q) 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]; + /* quantizer has to be reinitialized for any delta_q changes */ if(update) vp8cx_init_quantizer(cpi);