Reinitialize quantizer only when any delta is changing
authorAttila Nagy <attilanagy@google.com>
Fri, 18 Feb 2011 08:01:49 +0000 (10:01 +0200)
committerAttila Nagy <attilanagy@google.com>
Fri, 18 Feb 2011 12:23:37 +0000 (14:23 +0200)
No need to reinitialize for base Q changes.

Change-Id: Ie76ec21dd3c5582d5183dbed75ed73a1eed3e291

vp8/encoder/onyx_if.c

index 6ab1b39..f55441e 100644 (file)
@@ -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);