summaryrefslogtreecommitdiff
path: root/libavformat/mov_chan.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2017-03-31 17:14:42 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:34 -0300
commitb828c3954e61145957b60653a1e0957072221923 (patch)
tree5795738b51ae455a150eed2520549a5e2a6b6546 /libavformat/mov_chan.c
parent3654db79f4b912c1a4c3d16700c341628e40de3c (diff)
mov: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/mov_chan.c')
-rw-r--r--libavformat/mov_chan.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index 349634094c..f52239d347 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -499,7 +499,7 @@ static uint32_t mov_get_channel_label(uint32_t label)
}
uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id,
- uint64_t channel_layout,
+ const AVChannelLayout *ch_layout,
uint32_t *bitmap)
{
int i, j;
@@ -519,7 +519,7 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id,
const struct MovChannelLayoutMap *layout_map;
/* get the layout map based on the channel count */
- channels = av_get_channel_layout_nb_channels(channel_layout);
+ channels = ch_layout->nb_channels;
if (channels > 9)
channels = 0;
layout_map = mov_ch_layout_map[channels];
@@ -530,7 +530,8 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id,
continue;
for (j = 0; layout_map[j].tag != 0; j++) {
if (layout_map[j].tag == layouts[i] &&
- layout_map[j].layout == channel_layout)
+ (ch_layout->order == AV_CHANNEL_ORDER_NATIVE &&
+ layout_map[j].layout == ch_layout->u.mask))
break;
}
if (layout_map[j].tag)
@@ -540,9 +541,11 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id,
}
/* if no tag was found, use channel bitmap as a backup if possible */
- if (tag == 0 && channel_layout > 0 && channel_layout < 0x40000) {
+ if (tag == 0 && av_channel_layout_check(ch_layout) &&
+ ch_layout->order == AV_CHANNEL_ORDER_NATIVE &&
+ ch_layout->u.mask < 0x40000) {
tag = MOV_CH_LAYOUT_USE_BITMAP;
- *bitmap = (uint32_t)channel_layout;
+ *bitmap = (uint32_t)ch_layout->u.mask;
} else
*bitmap = 0;
@@ -555,6 +558,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
int64_t size)
{
uint32_t layout_tag, bitmap, num_descr, label_mask;
+ uint64_t mask = 0;
int i;
if (size < 12)
@@ -596,9 +600,14 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
}
if (layout_tag == 0) {
if (label_mask)
- st->codecpar->channel_layout = label_mask;
+ mask = label_mask;
} else
- st->codecpar->channel_layout = mov_get_channel_layout(layout_tag, bitmap);
+ mask = mov_get_channel_layout(layout_tag, bitmap);
+
+ if (mask) {
+ av_channel_layout_uninit(&st->codecpar->ch_layout);
+ av_channel_layout_from_mask(&st->codecpar->ch_layout, mask);
+ }
avio_skip(pb, size - 12);
return 0;