shithub: libvpx

Download patch

ref: bb0ca87a0d7c347e924dae4b83af81fe9454dad2
parent: dc004e8c17a1f330ed46eab092ca67e6f785fee1
author: Johann <johannkoenig@google.com>
date: Wed Jun 29 10:34:25 EDT 2011

guard against space/time distortion

and divide by 0 errors

Change-Id: I8af5ca3d0913cb6f278fff754f8772bcb62e674a

--- a/vpxenc.c
+++ b/vpxenc.c
@@ -1342,6 +1342,8 @@
     if(now < cfg->rc_buf_initial_sz)
         return;
 
+    then = now;
+
     /* Sum the size over the past rc_buf_sz ms */
     for(i = hist->frames; i > 0; i--)
     {
@@ -1352,6 +1354,9 @@
             break;
         sum_sz += hist->sz[i_idx];
     }
+
+    if (now == then)
+        return;
 
     avg_bitrate = sum_sz * 8 * 1000 / (now - then);
     idx = avg_bitrate * (RATE_BINS/2) / (cfg->rc_target_bitrate * 1000);
--