diff mbox series

[FFmpeg-devel,4/9] avcodec/mpegvideo_enc: Remove redundant pixel format checks

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

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, 5:40 a.m. UTC
All encoders using ff_mpv_encode_init() already have pix_fmts set
so that the pixel format is already checked in ff_encode_preinit().
The one exception to this is MJPEG whose check remains.

(Btw: The AVCodec.pix_fmts check for AMV is stricter than the check
in ff_mpv_encode_init().)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c | 23 -----------------------
 1 file changed, 23 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 7c9d1bd894..0f38f63de3 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -302,16 +302,7 @@  av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     mpv_encode_defaults(s);
 
     switch (avctx->codec_id) {
-    case AV_CODEC_ID_MPEG2VIDEO:
-        if (avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
-            avctx->pix_fmt != AV_PIX_FMT_YUV422P) {
-            av_log(avctx, AV_LOG_ERROR,
-                   "only YUV420 and YUV422 are supported\n");
-            return AVERROR(EINVAL);
-        }
-        break;
     case AV_CODEC_ID_MJPEG:
-    case AV_CODEC_ID_AMV:
         format_supported = 0;
         /* JPEG color space */
         if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
@@ -334,20 +325,6 @@  av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
             return AVERROR(EINVAL);
         }
         break;
-    case AV_CODEC_ID_SPEEDHQ:
-        if (avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
-            avctx->pix_fmt != AV_PIX_FMT_YUV422P &&
-            avctx->pix_fmt != AV_PIX_FMT_YUV444P) {
-            av_log(avctx, AV_LOG_ERROR,
-                   "only YUV420/YUV422/YUV444 are supported (no alpha support yet)\n");
-            return AVERROR(EINVAL);
-        }
-        break;
-    default:
-        if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {
-            av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n");
-            return AVERROR(EINVAL);
-        }
     }
 
     switch (avctx->pix_fmt) {