]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/mpeg12enc: Move MPEG-1/2 dimension checks to mpeg12enc
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Tue, 6 Apr 2021 13:03:19 +0000 (15:03 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Sat, 10 Apr 2021 01:53:54 +0000 (03:53 +0200)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
libavcodec/mpeg12enc.c
libavcodec/mpegvideo_enc.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;
index 8f2733091d1e2b5f9e3cf55fcfd81fe3b52e843c..0a1d0db86de953cb0067974e768d1146724aabfc 100644 (file)
@@ -534,20 +534,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
         return AVERROR(EINVAL);
     }
 
-    if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO &&
-        (avctx->width  > 4095 ||
-         avctx->height > 4095 )) {
-        av_log(avctx, AV_LOG_ERROR, "MPEG-1 does not support resolutions above 4095x4095\n");
-        return AVERROR(EINVAL);
-    }
-
-    if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
-        (avctx->width  > 16383 ||
-         avctx->height > 16383 )) {
-        av_log(avctx, AV_LOG_ERROR, "MPEG-2 does not support resolutions above 16383x16383\n");
-        return AVERROR(EINVAL);
-    }
-
     if (s->codec_id == AV_CODEC_ID_RV10 &&
         (avctx->width &15 ||
          avctx->height&15 )) {