diff mbox series

[FFmpeg-devel,11/19] avcodec/mpeg12enc: Move MPEG-1/2 dimension checks to mpeg12enc

Message ID HE1PR0301MB21544C408FB760F3434DDE828F769@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit d5c7e5cb65ee29a8e66e704ac5b7953657a6ff9c
Headers show
Series [FFmpeg-devel,1/9] avcodec/encode: Fix check for allowed LJPEG pixel formats | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 6, 2021, 9:55 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpeg12enc.c     |  8 ++++++++
 libavcodec/mpegvideo_enc.c | 14 --------------
 2 files changed, 8 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 5676caef87..b7d3d1c6b0 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -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;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 2a0fd60cbc..d1f2460409 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -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 )) {