This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit fd6dc624be1eaf447569df270eb0d8ac5e3d7518 Author: Jun Zhao <[email protected]> AuthorDate: Fri Aug 28 07:44:27 2026 +0800 Commit: Jun Zhao <[email protected]> CommitDate: Tue Sep 8 05:00:37 2026 +0000 avformat: Restore the container channel layout after a failed decoder open avformat_find_stream_info() copies codec parameters from the decoder context after probing, including when avcodec_open2() has already failed. A failed avcodec_open2() zeroes the context channel layout via ff_codec_close() -> av_opt_free(), because ch_layout is an AV_OPT_TYPE_CHLAYOUT option. That empty layout is then written back onto codecpar and replaces the value the demuxer had already set from the container. This is reachable for codecs such as adpcm_psx that have no parser and do not set AVSTREAM_PARSE_*: the only source of the channel count is the demuxer header. It differs from codecs like mp3, where the decoder is expected to fill the layout. Restore the container channel layout when it was specified and the decoder result is unspecified, matching the existing restore of color metadata in parameters_from_context(). See also: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-November/335598.html Fixes: #24290 Fixes: https://issues.oss-fuzz.com/issues/42536474 Reported-by: DarĂo Clavijo Found-by: OSS-Fuzz Signed-off-by: Jun Zhao <[email protected]> --- libavformat/demux.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavformat/demux.c b/libavformat/demux.c index da0f5853cc..97eaa5f9bc 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -2596,6 +2596,16 @@ static int parameters_from_context(AVFormatContext *ic, AVCodecParameters *par, if (par_tmp->chroma_location != AVCHROMA_LOC_UNSPECIFIED) par->chroma_location = par_tmp->chroma_location; + /* A failed avcodec_open2() zeroes ch_layout through + * ff_codec_close() -> av_opt_free(); do not copy that empty layout + * over a container-signaled one. Other AVOption types used here are + * integers and are not cleared. */ + if (par_tmp->ch_layout.nb_channels > 0 && !par->ch_layout.nb_channels) { + ret = av_channel_layout_copy(&par->ch_layout, &par_tmp->ch_layout); + if (ret < 0) + goto fail; + } + ret = 0; fail: avcodec_parameters_free(&par_tmp); -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
