From 339d8fb3532a9c0ddd3d4902b798cd220f616919 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 15 Jul 2014 19:12:55 +0200 Subject: [PATCH] avcodec/mpegvideo_enc: check intra dc precission Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo_enc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index e88b4f3ac8..4bb79f66ce 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -342,6 +342,17 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) } else if (s->intra_dc_precision >= 8) s->intra_dc_precision -= 8; + if (s->intra_dc_precision < 0) { + av_log(avctx, AV_LOG_ERROR, + "intra dc precision must be positive, note some applications use" + " 0 and some 8 as base meaning 8bit, the value must not be smaller than that\n"); + return AVERROR(EINVAL); + } + + if (s->intra_dc_precision > (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ? 3 : 0)) { + av_log(avctx, AV_LOG_ERROR, "intra dc precision too large\n"); + return AVERROR(EINVAL); + } s->user_specified_pts = AV_NOPTS_VALUE; if (s->gop_size <= 1) {