From 5db20278314cb4abc94048c566442b11b5b99b56 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 21 May 2025 01:57:52 +0200 Subject: [PATCH 16/19] avcodec/mpegvideo: Check h263_aic, not h263_plus for allocating dc_val This means that these buffers won't be allocated any more for H.263+ with AIC disabled. Also remove setting h263_plus for the RV20 encoder, as it has only been done to force allocating dc_val. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.c | 4 +++- libavcodec/mpegvideo_enc.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 55f7178bed..f3e4d4c386 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -335,9 +335,11 @@ av_cold int ff_mpv_init_context_frame(MpegEncContext *s) s->coded_block = s->coded_block_base + s->b8_stride + 1; } - if (s->h263_pred || s->h263_plus || !s->encoding) { + if (s->h263_pred || s->h263_aic || !s->encoding) { /* dc values */ // MN: we need these for error resilience of intra-frames + // Allocating them unconditionally for decoders also means + // that we don't need to reinitialize when e.g. h263_aic changes. if (!FF_ALLOCZ_TYPED_ARRAY(s->dc_val_base, yc_size)) return AVERROR(ENOMEM); s->dc_val[0] = s->dc_val_base + s->b8_stride + 1; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 6ce741c042..e0b7ea0846 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -943,8 +943,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) avctx->delay = 0; s->c.low_delay = 1; s->c.modified_quant = 1; + // Set here to force allocation of dc_val; + // will be set later on a per-frame basis. s->c.h263_aic = 1; - s->c.h263_plus = 1; s->c.loop_filter = 1; s->c.unrestricted_mv = 0; break; -- 2.45.2