From a4eb056f7ec28fa3a86038879678a283262ade3b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 25 Mar 2025 06:34:33 +0100 Subject: [PATCH 14/44] avcodec/mpeg12dec: Use ff_mpv_decode_reinit() Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg12dec.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 609af30523..9297c65029 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -944,13 +944,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) av_cmp_q(s1->save_aspect, s->avctx->sample_aspect_ratio) || (s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) || 0) { - if (s->context_initialized) - ff_mpv_common_end(s); - - ret = ff_set_dimensions(avctx, s->width, s->height); - if (ret < 0) - return ret; - if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && s1->bit_rate && (s1->bit_rate != 0x3FFFF*400)) { avctx->rc_max_rate = s1->bit_rate; @@ -958,10 +951,6 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) (s1->bit_rate != 0x3FFFF*400 || s1->vbv_delay != 0xFFFF)) { avctx->bit_rate = s1->bit_rate; } - s1->save_aspect = s->avctx->sample_aspect_ratio; - s1->save_width = s->width; - s1->save_height = s->height; - s1->save_progressive_seq = s->progressive_sequence; /* low_delay may be forced, in this case we will have B-frames * that behave like P-frames. */ @@ -989,8 +978,15 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) avctx->pix_fmt = mpeg_get_pixelformat(avctx); - if ((ret = ff_mpv_common_init(s)) < 0) + ret = ff_mpv_decode_reinit(s); + if (ret < 0) return ret; + + s1->save_aspect = s->avctx->sample_aspect_ratio; + s1->save_width = s->width; + s1->save_height = s->height; + s1->save_progressive_seq = s->progressive_sequence; + if (!s->avctx->lowres) for (int i = 0; i < s->slice_context_count; i++) ff_mpv_framesize_disable(&s->thread_context[i]->sc); @@ -1853,9 +1849,6 @@ static int vcr2_init_sequence(AVCodecContext *avctx) int i, v, ret; /* start new MPEG-1 context decoding */ - if (s->context_initialized) - ff_mpv_common_end(s); - s->width = avctx->coded_width; s->height = avctx->coded_height; avctx->has_b_frames = 0; // true? @@ -1863,7 +1856,8 @@ static int vcr2_init_sequence(AVCodecContext *avctx) avctx->pix_fmt = mpeg_get_pixelformat(avctx); - if ((ret = ff_mpv_common_init(s)) < 0) + ret = ff_mpv_decode_reinit(s); + if (ret < 0) return ret; if (!s->avctx->lowres) for (int i = 0; i < s->slice_context_count; i++) -- 2.45.2