]> granicus.if.org Git - libvpx/commitdiff
fixed a crash caused invalid Q choice
authorYaowu Xu <yaowu@google.com>
Thu, 8 Dec 2011 04:08:31 +0000 (20:08 -0800)
committerYaowu Xu <yaowu@google.com>
Thu, 8 Dec 2011 15:04:23 +0000 (07:04 -0800)
The commit fixed a problem by capping cpi->active_best_quality to be
smaller than cpi->worst_quality.  Also fixed a few line of code that
was misplaced.

Change-Id: Ie908264b72140c669122a0afde5d886619c33474

vp8/encoder/onyx_if.c
vp8/encoder/quantize.c

index 0b95a02e218c56069fd695ef45ce1f8e317b1153..6d929067586967c111dfb6beb4d6de2d4aceff95 100644 (file)
@@ -4180,6 +4180,9 @@ static void encode_frame_to_data_rate
     if (cpi->active_best_quality < cpi->best_quality)
         cpi->active_best_quality = cpi->best_quality;
 
+    if (cpi->active_best_quality > cpi->worst_quality)
+        cpi->active_best_quality = cpi->worst_quality;
+
     if ( cpi->active_worst_quality < cpi->active_best_quality )
         cpi->active_worst_quality = cpi->active_best_quality;
 
index 926a1cc79818badfc5c78b76b3a8e14c9c37592a..d8a52f1ac19fda4578436c83d9ff1d4223cc7ee6 100644 (file)
@@ -965,18 +965,17 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
     int i;
     int quant_val;
     int Q;
-
-    int zbin_boost[16] = {0, 0, 8, 10, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 44, 44};
-
+    int zbin_boost[16] = { 0,  0,  8, 10, 12, 14, 16, 20,
+                          24, 28, 32, 36, 40, 44, 44, 44};
     int qrounding_factor = 48;
-#if CONFIG_EXTEND_QRANGE
-    int qzbin_factor = (vp8_dc_quant(Q,0) < 148) ? 84 : 80;
-#else
-    int qzbin_factor = (vp8_dc_quant(Q,0) < 37) ? 84: 80;
-#endif
 
     for (Q = 0; Q < QINDEX_RANGE; Q++)
     {
+#if CONFIG_EXTEND_QRANGE
+        int qzbin_factor = (vp8_dc_quant(Q,0) < 148) ? 84 : 80;
+#else
+        int qzbin_factor = (vp8_dc_quant(Q,0) < 37) ? 84: 80;
+#endif
         // dc values
         quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q);
         cpi->Y1quant_fast[Q][0] = (1 << 16) / quant_val;