From c79114346417fab1c09c3ca6d61fafae86aa3f0e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 25 Mar 2025 08:19:22 +0100 Subject: [PATCH 19/44] avcodec/h263dec: Use ff_mpv_decode_reinit() It allows to combine the uninitialized case (for which ff_mpv_common_init() was called) and the frame size change case. Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 189016e143..cbcd719859 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -172,7 +172,8 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) } else avctx->pix_fmt = AV_PIX_FMT_YUV420P; - if ((ret = ff_mpv_common_init(s)) < 0) + ret = ff_mpv_decode_reinit(s); + if (ret < 0) return ret; } @@ -505,12 +506,6 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, return ret; } - if (!s->context_initialized) { - avctx->pix_fmt = h263_get_format(avctx); - if ((ret = ff_mpv_common_init(s)) < 0) - return ret; - } - avctx->has_b_frames = !s->low_delay; if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) { @@ -527,24 +522,15 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, * an H263EncContext */ if (s->width != avctx->coded_width || s->height != avctx->coded_height || - s->context_reinit) { + s->context_reinit || !s->context_initialized) { /* H.263 could change picture size any time */ s->context_reinit = 0; - - ret = ff_set_dimensions(avctx, s->width, s->height); + avctx->pix_fmt = h263_get_format(avctx); + ret = ff_mpv_decode_reinit(s); if (ret < 0) return ret; ff_set_sar(avctx, avctx->sample_aspect_ratio); - - if ((ret = ff_mpv_common_frame_size_change(s))) - return ret; - - if (avctx->pix_fmt != h263_get_format(avctx)) { - av_log(avctx, AV_LOG_ERROR, "format change not supported\n"); - avctx->pix_fmt = AV_PIX_FMT_NONE; - return AVERROR_UNKNOWN; - } } if (s->codec_id == AV_CODEC_ID_H263 || -- 2.45.2