summaryrefslogtreecommitdiff
path: root/vpxenc.c
diff options
context:
space:
mode:
Diffstat (limited to 'vpxenc.c')
-rw-r--r--vpxenc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/vpxenc.c b/vpxenc.c
index a3c8eadc0..d82a97fad 100644
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -1339,6 +1339,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++)