From 25a92b896ce6d682e4fb2fdaff8288b20ece0fb3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 30 Apr 2025 02:04:24 +0200 Subject: [PATCH 30/44] avcodec/mpegvideo: Move decoding initializing code to mpegvideo_dec.c Now that the decoders all use ff_mpv_decode_reinit(), we can move the pixel format check to it; and we can also remove the size check, as ff_mpv_decode_reinit() performs this on its own (and disallows 0x0 resolutions). Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.c | 13 +------------ libavcodec/mpegvideo_dec.c | 6 ++++++ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index de1901d53d..c804205745 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -29,9 +29,9 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" -#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/mem.h" +#include "libavutil/pixdesc.h" #include "avcodec.h" #include "blockdsp.h" @@ -41,7 +41,6 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodata.h" -#include "mpegvideo_unquantize.h" #include "libavutil/refstruct.h" @@ -393,16 +392,6 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) if (s->encoding && s->avctx->slices) nb_slices = s->avctx->slices; - if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) { - av_log(s->avctx, AV_LOG_ERROR, - "decoding to AV_PIX_FMT_NONE is not supported.\n"); - return AVERROR(EINVAL); - } - - if ((s->width || s->height) && - av_image_check_size(s->width, s->height, 0, s->avctx)) - return AVERROR(EINVAL); - dsp_init(s); /* set chroma shifts */ diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 7e300bcdc2..fe5d5bcadd 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -137,6 +137,12 @@ av_cold int ff_mpv_decode_reinit(MpegEncContext *const s) if (s->context_initialized) ff_mpv_common_end(s); + if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) { + av_log(s->avctx, AV_LOG_ERROR, + "decoding to AV_PIX_FMT_NONE is not supported.\n"); + return AVERROR(EINVAL); + } + ret = ff_set_dimensions(s->avctx, s->width, s->height); if (ret < 0) return ret; -- 2.45.2