bug fix active_worst_quality set below active_best_quality
authorJames Berry <jamesberry@google.com>
Thu, 19 May 2011 22:02:48 +0000 (18:02 -0400)
committerJames Berry <jamesberry@google.com>
Thu, 19 May 2011 22:10:31 +0000 (18:10 -0400)
fixed a bug where active_worst_quality could be set
below active_best_quality which could result in an
infinite loop.

Change-Id: I93c229c3bc5bff2a82b4c33f41f8acf4dd194039

vp8/encoder/onyx_if.c

index 20d5539..a2fd186 100644 (file)
@@ -3427,15 +3427,15 @@ static void encode_frame_to_data_rate
                 buff_lvl_step = (cpi->oxcf.maximum_buffer_size - cpi->oxcf.optimal_buffer_level) / Adjustment;
 
                 if (buff_lvl_step)
-                {
                     Adjustment = (cpi->buffer_level - cpi->oxcf.optimal_buffer_level) / buff_lvl_step;
-                    cpi->active_worst_quality -= Adjustment;
-                }
-            }
-            else
-            {
-                cpi->active_worst_quality -= Adjustment;
+                else
+                    Adjustment = 0;
             }
+
+            cpi->active_worst_quality -= Adjustment;
+
+            if(cpi->active_worst_quality < cpi->active_best_quality)
+                cpi->active_worst_quality = cpi->active_best_quality;
         }
     }