You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-06-19 19:03:00 +02:00
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 <jamrial@gmail.com>
(cherry picked from commit fd1c8fa0e6)
This commit is contained in:
+24
-13
@@ -312,16 +312,22 @@ static int mov_get_channel_layout(AVChannelLayout *ch_layout, uint32_t tag)
|
||||
/* find the channel layout for the specified layout tag */
|
||||
layout_map = find_layout_map(tag);
|
||||
if (layout_map) {
|
||||
AVChannelLayout tmp = { 0 };
|
||||
int ret;
|
||||
av_channel_layout_uninit(ch_layout);
|
||||
ret = av_channel_layout_custom_init(ch_layout, channels);
|
||||
ret = av_channel_layout_custom_init(&tmp, channels);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
for (i = 0; i < channels; i++) {
|
||||
enum AVChannel id = layout_map[i].id;
|
||||
ch_layout->u.map[i].id = (id != AV_CHAN_NONE ? id : AV_CHAN_UNKNOWN);
|
||||
tmp.u.map[i].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;
|
||||
}
|
||||
@@ -462,6 +468,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) {
|
||||
@@ -481,8 +488,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;
|
||||
|
||||
@@ -499,12 +505,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) {
|
||||
@@ -783,11 +792,10 @@ int ff_mov_read_chnl(AVFormatContext *s, AVIOContext *pb, AVStream *st)
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
@@ -808,12 +816,15 @@ int ff_mov_read_chnl(AVFormatContext *s, AVIOContext *pb, AVStream *st)
|
||||
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 = avio_rb64(pb);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user