shithub: libvpx

Download patch

ref: ebcc6605c1bd224fcb26494d74a1db81e981f3ab
parent: b70f23caec2b06fc7e71b124e0fe8802d1c19ba7
author: Yaowu Xu <yaowu@google.com>
date: Wed Dec 7 15:08:31 EST 2011

fixed a crash caused invalid Q choice

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

--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -4180,6 +4180,9 @@
     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;
 
--- a/vp8/encoder/quantize.c
+++ b/vp8/encoder/quantize.c
@@ -965,18 +965,17 @@
     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;
--