This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit fd1c8fa0e611f03681f5fce496848da7c73651a2 Author: James Almer <[email protected]> AuthorDate: Thu May 28 19:20:13 2026 -0300 Commit: James Almer <[email protected]> CommitDate: Mon Jun 1 09:53:54 2026 -0300 avformat/mov_chan: keep the layout untouched on chan/chnl box failure Needed to keep the process going if some issue was found while parsing these boxes. Signed-off-by: James Almer <[email protected]> --- libavformat/mov_chan.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c index bfe566e74e..cdf5e88ea1 100644 --- a/libavformat/mov_chan.c +++ b/libavformat/mov_chan.c @@ -381,6 +381,7 @@ static int mov_get_channel_layout(AVChannelLayout *ch_layout, uint32_t tag, uint /* find the channel layout for the specified layout tag */ layout_map = find_layout_map(tag, map); if (layout_map) { + AVChannelLayout tmp = { 0 }; int ret; int map_layout_nb_channels = tag & 0xFFFF; int nb_channels = ch_layout->nb_channels; @@ -389,19 +390,23 @@ static int mov_get_channel_layout(AVChannelLayout *ch_layout, uint32_t tag, uint if (omitted_channel_map >> map_layout_nb_channels) return AVERROR_INVALIDDATA; - av_channel_layout_uninit(ch_layout); - ret = av_channel_layout_custom_init(ch_layout, nb_channels); + ret = av_channel_layout_custom_init(&tmp, nb_channels); if (ret < 0) return ret; for (int i = 0, idx = 0; i < map_layout_nb_channels && idx < nb_channels; i++, omitted_channel_map >>= 1) { if (!(omitted_channel_map & 1)) { enum AVChannel id = layout_map[i].id; - ch_layout->u.map[idx++].id = (id != AV_CHAN_NONE ? id : AV_CHAN_UNKNOWN); + tmp.u.map[idx++].id = (id != AV_CHAN_NONE ? id : AV_CHAN_UNKNOWN); } } - return av_channel_layout_retype(ch_layout, 0, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); + ret = av_channel_layout_retype(&tmp, 0, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); + if (ret < 0) + return ret; + + av_channel_layout_uninit(ch_layout); + *ch_layout = tmp; } return 0; } @@ -562,6 +567,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, return 0; if (layout_tag == MOV_CH_LAYOUT_USE_DESCRIPTIONS) { + AVChannelLayout tmp = { 0 }; int nb_channels = ch_layout->nb_channels; if (!num_descr || num_descr < nb_channels) { @@ -581,8 +587,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, num_descr = nb_channels; } - av_channel_layout_uninit(ch_layout); - ret = av_channel_layout_custom_init(ch_layout, nb_channels); + ret = av_channel_layout_custom_init(&tmp, nb_channels); if (ret < 0) goto out; @@ -599,12 +604,15 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, avio_rl32(pb); // mCoordinates[1] avio_rl32(pb); // mCoordinates[2] size -= 20; - ch_layout->u.map[i].id = mov_get_channel_id(label); + tmp.u.map[i].id = mov_get_channel_id(label); } - ret = av_channel_layout_retype(ch_layout, 0, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); + ret = av_channel_layout_retype(&tmp, 0, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); if (ret < 0) goto out; + + av_channel_layout_uninit(ch_layout); + *ch_layout = tmp; } else if (layout_tag == MOV_CH_LAYOUT_USE_BITMAP) { if (!ch_layout->nb_channels || av_popcount(bitmap) == ch_layout->nb_channels) { if (bitmap < 0x40000) { @@ -770,7 +778,7 @@ int ff_mov_read_chnl(AVFormatContext *s, AVIOContext *pb, AVStream *st, int vers av_log(s, AV_LOG_TRACE, "'chnl' layout %d\n", layout); if (!layout) { - AVChannelLayout *ch_layout = &st->codecpar->ch_layout; + AVChannelLayout tmp = { 0 }, *ch_layout = &st->codecpar->ch_layout; int nb_channels = ch_layout->nb_channels; if (version == 1) { @@ -780,8 +788,7 @@ int ff_mov_read_chnl(AVFormatContext *s, AVIOContext *pb, AVStream *st, int vers return AVERROR_INVALIDDATA; } - av_channel_layout_uninit(ch_layout); - ret = av_channel_layout_custom_init(ch_layout, nb_channels); + ret = av_channel_layout_custom_init(&tmp, nb_channels); if (ret < 0) return ret; @@ -802,12 +809,14 @@ int ff_mov_read_chnl(AVFormatContext *s, AVIOContext *pb, AVStream *st, int vers channel = AV_CHAN_UNKNOWN; } - ch_layout->u.map[i].id = channel; + tmp.u.map[i].id = channel; } - ret = av_channel_layout_retype(ch_layout, 0, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); + ret = av_channel_layout_retype(&tmp, 0, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); if (ret < 0) return ret; + av_channel_layout_uninit(ch_layout); + *ch_layout = tmp; } else { uint64_t omitted_channel_map = 0; int omitted_channel_present = 1, channel_order_definition = 0; _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
