]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg12enc.c
avcodec/mpeg12enc: Move MPEG-1/2 dimension checks to mpeg12enc
[ffmpeg] / libavcodec / mpeg12enc.c
index 5676caef87bef7f282bf18ca349660395da4ab28..b7d3d1c6b02938d5fb9b487a3108da1fd33cc347 100644 (file)
@@ -144,6 +144,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
 {
     int ret;
     MpegEncContext *s = avctx->priv_data;
+    int max_size = avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ? 16383 : 4095;
+
+    if (avctx->width > max_size || avctx->height > max_size) {
+        av_log(avctx, AV_LOG_ERROR, "%s does not support resolutions above %dx%d\n",
+               CONFIG_SMALL ? avctx->codec->name : avctx->codec->long_name,
+               max_size, max_size);
+        return AVERROR(EINVAL);
+    }
 
     if ((ret = ff_mpv_encode_init(avctx)) < 0)
         return ret;