From d341d45fc7ebdd8cfc46d40ab1f0af4faa4e563b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Date: Wed, 9 Apr 2025 14:39:37 +0200 Subject: [PATCH 2/2] avcodec/h261dec: Set pict_type during init Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/h261dec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 840414cafc..146f979a5e 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -88,6 +88,12 @@ static av_cold int h261_decode_init(AVCodecContext *avctx) avctx->framerate = (AVRational) { 30000, 1001 }; + /* The H.261 analog of intra/key frames is setting the freeze picture release flag, + * but this does not guarantee that the frame uses intra-only encoding, + * so we still need to allocate dummy frames. So set pict_type to P here + * for all frames and override it after having decoded the frame. */ + s->pict_type = AV_PICTURE_TYPE_P; + s->private_ctx = &h->common; // set defaults ret = ff_mpv_decode_init(s, avctx); @@ -501,11 +507,6 @@ static int h261_decode_picture_header(H261DecContext *h, int *is_key) if (skip_1stop_8data_bits(&s->gb) < 0) return AVERROR_INVALIDDATA; - /* H.261 has no I-frames, but if we pass AV_PICTURE_TYPE_I for the first - * frame, the codec crashes if it does not contain all I-blocks - * (e.g. when a packet is lost). */ - s->pict_type = AV_PICTURE_TYPE_P; - h->gob_number = 0; return 0; } -- 2.45.2