diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-12-03 13:32:45 -0500 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-12-09 16:12:58 -0500 |
commit | 1fdf18f4b7e9f9983b6f07ef1033a51b289692f2 (patch) | |
tree | b309313a40bc0bfd82889fa6833fb9d51f5bc872 /libavformat/mov.c | |
parent | b2890f5ed684701ec15820b117738f6af0b7f334 (diff) | |
download | ffmpeg-1fdf18f4b7e9f9983b6f07ef1033a51b289692f2.tar.gz |
mov: add support for reading and writing the 'chan' tag
This implements reading the tag in the demuxer and adds support for writing it
in the muxer. Some example channel layout tables for muxing are included for
ac3, aac, and alac, but they are not utilized yet.
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index a0b0794592..eef53e6d66 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -37,6 +37,7 @@ #include "isom.h" #include "libavcodec/get_bits.h" #include "id3v1.h" +#include "mov_chan.h" #if CONFIG_ZLIB #include <zlib.h> @@ -554,6 +555,51 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + AVStream *st; + uint8_t version; + uint32_t flags, layout_tag, bitmap, num_descr; + + if (c->fc->nb_streams < 1) + return 0; + st = c->fc->streams[c->fc->nb_streams-1]; + + if (atom.size < 16) + return 0; + + version = avio_r8(pb); + flags = avio_rb24(pb); + + layout_tag = avio_rb32(pb); + bitmap = avio_rb32(pb); + num_descr = avio_rb32(pb); + + if (atom.size < 16ULL + num_descr * 20ULL) + return 0; + + av_dlog(c->fc, "chan: size=%ld version=%u flags=%u layout=%u bitmap=%u num_descr=%u\n", + atom.size, version, flags, layout_tag, bitmap, num_descr); + +#if 0 + /* TODO: use the channel descriptions if the layout tag is 0 */ + int i; + for (i = 0; i < num_descr; i++) { + uint32_t label, cflags; + float coords[3]; + label = avio_rb32(pb); // mChannelLabel + cflags = avio_rb32(pb); // mChannelFlags + AV_WN32(&coords[0], avio_rl32(pb)); // mCoordinates[0] + AV_WN32(&coords[1], avio_rl32(pb)); // mCoordinates[1] + AV_WN32(&coords[2], avio_rl32(pb)); // mCoordinates[2] + } +#endif + + st->codec->channel_layout = ff_mov_get_channel_layout(layout_tag, bitmap); + + return 0; +} + static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -2329,6 +2375,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('w','i','d','e'), mov_read_wide }, /* place holder */ { MKTAG('w','f','e','x'), mov_read_wfex }, { MKTAG('c','m','o','v'), mov_read_cmov }, +{ MKTAG('c','h','a','n'), mov_read_chan }, /* channel layout */ { 0, NULL } }; |