From fedd0ae5f88d6691a7c19b75719451961e32bdd6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 30 Apr 2025 01:45:03 +0200 Subject: [PATCH 29/44] avcodec/rv34: Defer initializing MpegEncContext Now that the RV30 and RV40 decoders use ff_mpv_decode_reinit() upon frame size changes, they need not be initialized during init; instead one can use the ordinary resizing code to also perform the initial initilization. Signed-off-by: Andreas Rheinhardt --- libavcodec/rv34.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 0545f77b44..3ebb92f563 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1520,15 +1520,8 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) avctx->has_b_frames = 1; s->low_delay = 0; - if ((ret = ff_mpv_common_init(s)) < 0) - return ret; - ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1); - ret = rv34_decoder_alloc(r); - if (ret < 0) - return ret; - ff_thread_once(&init_static_once, rv34_init_tables); return 0; @@ -1677,15 +1670,17 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, if (!s->context_initialized || s->width != si.width || s->height != si.height) { int err; - av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n", - si.width, si.height); + if (s->context_initialized) { + av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n", + si.width, si.height); - if (av_image_check_size(si.width, si.height, 0, s->avctx)) - return AVERROR_INVALIDDATA; + if (av_image_check_size(si.width, si.height, 0, s->avctx)) + return AVERROR_INVALIDDATA; - s->avctx->sample_aspect_ratio = update_sar( - s->width, s->height, s->avctx->sample_aspect_ratio, - si.width, si.height); + s->avctx->sample_aspect_ratio = update_sar( + s->width, s->height, s->avctx->sample_aspect_ratio, + si.width, si.height); + } s->width = si.width; s->height = si.height; -- 2.45.2