ref: fd41cb849147b49466f0cb5a3efd09265c1dff20
parent: 6b6f367c3d25bdd87f80a8e5b5380963733c6f0a
author: Tero Rintaluoma <teror@google.com>
date: Fri Jul 15 10:47:44 EDT 2011
Fixed rate histogram calculation Using small values for --buf-sz= in command line causes floating point exception due to division by zero. Change-Id: Ibfe2d44db922993a78ebc9a4a1087d9625de48ae
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -1312,6 +1312,11 @@
* 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++)
--
⑨