libvpxenc: check for odd RC parameter combinations that could crash
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 16 Aug 2012 14:59:42 +0000 (16:59 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 16 Aug 2012 15:00:32 +0000 (17:00 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/libvpxenc.c

index 7046802..0b97907 100644 (file)
@@ -242,6 +242,13 @@ static av_cold int vp8_init(AVCodecContext *avctx)
                vpx_codec_err_to_string(res));
         return AVERROR(EINVAL);
     }
+
+    if(!avctx->bit_rate)
+        if(avctx->rc_max_rate || avctx->rc_buffer_size || avctx->rc_initial_buffer_occupancy) {
+            av_log( avctx, AV_LOG_ERROR, "Rate control parameters set without a bitrate\n");
+            return AVERROR(EINVAL);
+        }
+
     dump_enc_cfg(avctx, &enccfg);
 
     enccfg.g_w            = avctx->width;