From 16581fd7fa6b45e69bb8c2d305739cb60bb798e6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 11 Jun 2025 14:52:47 +0200 Subject: [PATCH 1/2] Revert "avcodec/decode: Fix avcodec parameters when bsfs are enable by decoder" This reverts commit 1c170613975d3cbcbb5aaa469b4a3cf0df5d4c2b. The commit intended to provide certain codecs using *_mp4toannexb bitstream filters with updated (annex B) extradata (even when the user-supplied one was ISOBMFF), yet BSFs are allowed to change way more. The media100_to_mjpegb BSF used by the media100 decoder changes the codec id; the commit being reverted therefore changed AVCodecContext.codec_id which is an API violation and broke media100 decoding with the FFmpeg cli tool. This commit also made changes from the internal BSF externally visible. extradata is documented to be "owned by the codec and freed in avcodec_free_context()" which does not include replacing it with something else in avcodec_open2() and may surprise users who think that AVCodecContext.extradata is immutable before avcodec_free_context(). It also incurred a memdup which is completely unnecessary for most decoders. Therefore this commit is reverted. The problem it tried to solve will be solved differently in the next commit. Signed-off-by: Andreas Rheinhardt --- libavcodec/decode.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index ef09568381..2319e76e4b 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -202,9 +202,6 @@ static int decode_bsfs_init(AVCodecContext *avctx) goto fail; ret = av_bsf_init(avci->bsf); - if (ret < 0) - goto fail; - ret = avcodec_parameters_to_context(avctx, avci->bsf->par_out); if (ret < 0) goto fail; -- 2.45.2