summaryrefslogtreecommitdiff
path: root/libavformat/mov_chan.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-04-07 12:40:50 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-07-19 13:26:45 -0400
commit3bab7cd12802dc5abf2c5cc6dec49e9e249ce204 (patch)
tree5d14d61f0cbe7473b293cd4cea4a35fd1bdd17c9 /libavformat/mov_chan.c
parentc0196a14b9f0f920da30bc30a8887fae9050a4b3 (diff)
avformat: move 'chan' tag parsing to mov_chan.c to share with the CAF demuxer
Diffstat (limited to 'libavformat/mov_chan.c')
-rw-r--r--libavformat/mov_chan.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index edd5f6c4da..c0b57119d1 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -477,7 +477,7 @@ uint64_t ff_mov_get_channel_layout(uint32_t tag, uint32_t bitmap)
return layout_map[i].layout;
}
-uint32_t ff_mov_get_channel_label(uint32_t label)
+static uint32_t mov_get_channel_label(uint32_t label)
{
if (label == 0)
return 0;
@@ -542,3 +542,47 @@ uint32_t ff_mov_get_channel_layout_tag(enum CodecID codec_id,
return tag;
}
+
+int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size)
+{
+ AVIOContext *pb = s->pb;
+ uint32_t layout_tag, bitmap, num_descr, label_mask;
+ int i;
+
+ if (size < 12)
+ return AVERROR_INVALIDDATA;
+
+ layout_tag = avio_rb32(pb);
+ bitmap = avio_rb32(pb);
+ num_descr = avio_rb32(pb);
+
+ av_dlog(s, "chan: layout=%u bitmap=%u num_descr=%u\n",
+ layout_tag, bitmap, num_descr);
+
+ if (size < 12ULL + num_descr * 20ULL)
+ return 0;
+
+ label_mask = 0;
+ for (i = 0; i < num_descr; i++) {
+ uint32_t label;
+ label = avio_rb32(pb); // mChannelLabel
+ avio_rb32(pb); // mChannelFlags
+ avio_rl32(pb); // mCoordinates[0]
+ avio_rl32(pb); // mCoordinates[1]
+ avio_rl32(pb); // mCoordinates[2]
+ if (layout_tag == 0) {
+ uint32_t mask_incr = mov_get_channel_label(label);
+ if (mask_incr == 0) {
+ label_mask = 0;
+ break;
+ }
+ label_mask |= mask_incr;
+ }
+ }
+ if (layout_tag == 0)
+ st->codec->channel_layout = label_mask;
+ else
+ st->codec->channel_layout = ff_mov_get_channel_layout(layout_tag, bitmap);
+
+ return 0;
+}