]> granicus.if.org Git - libvpx/commitdiff
Fixed rate histogram calculation
authorTero Rintaluoma <teror@google.com>
Fri, 15 Jul 2011 11:47:44 +0000 (14:47 +0300)
committerTero Rintaluoma <teror@google.com>
Mon, 18 Jul 2011 07:35:05 +0000 (10:35 +0300)
Using small values for --buf-sz= in command line causes
floating point exception due to division by zero.

Change-Id: Ibfe2d44db922993a78ebc9a4a1087d9625de48ae

vpxenc.c

index 042f07b81344993867598ace09dcfa0ba2c3c427..b765201531d5d41d6b7252ae4dcfb7bbf7361b3a 100644 (file)
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -1312,6 +1312,11 @@ static void init_rate_histogram(struct rate_hist          *hist,
      * adjustment (5/4) to account for alt-refs
      */
     hist->samples = cfg->rc_buf_sz * 5 / 4 * fps->num / fps->den / 1000;
+
+    // prevent division by zero
+    if (hist->samples == 0)
+      hist->samples=1;
+
     hist->pts = calloc(hist->samples, sizeof(*hist->pts));
     hist->sz = calloc(hist->samples, sizeof(*hist->sz));
     for(i=0; i<RATE_BINS; i++)