[vlc-commits] demux: mp4: add chan atom

Francois Cartegnie git at videolan.org
Sat Aug 30 05:30:41 CEST 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Aug 27 20:00:09 2014 +0900| [8b2da746f8bbde25b8752130cb1201492caf6b7a] | committer: Francois Cartegnie

demux: mp4: add chan atom

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8b2da746f8bbde25b8752130cb1201492caf6b7a
---

 modules/demux/mp4/libmp4.c |   48 ++++++++++++++++++++++++++++++++++++++++++++
 modules/demux/mp4/libmp4.h |   20 ++++++++++++++++++
 2 files changed, 68 insertions(+)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 1bafd13..f51416e 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1452,6 +1452,52 @@ error:
     MP4_READBOX_EXIT( 0 );
 }
 
+static int MP4_ReadBox_stsdext_chan( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER( MP4_Box_data_chan_t );
+    MP4_Box_data_chan_t *p_chan = p_box->data.p_chan;
+
+    if ( i_read < 16 )
+        MP4_READBOX_EXIT( 0 );
+
+    MP4_GET1BYTE( p_chan->i_version );
+    MP4_GET3BYTES( p_chan->i_channels_flags );
+    MP4_GET4BYTES( p_chan->layout.i_channels_layout_tag );
+    MP4_GET4BYTES( p_chan->layout.i_channels_bitmap );
+    MP4_GET4BYTES( p_chan->layout.i_channels_description_count );
+    if ( i_read < p_chan->layout.i_channels_description_count * 24 )
+        MP4_READBOX_EXIT( 0 );
+
+    p_chan->layout.p_descriptions =
+        malloc( p_chan->layout.i_channels_description_count * 24 );
+
+    if ( !p_chan->layout.p_descriptions )
+        MP4_READBOX_EXIT( 0 );
+
+    for( uint32_t i=0; i<p_chan->layout.i_channels_description_count; i++ )
+    {
+        MP4_GET4BYTES( p_chan->layout.p_descriptions[i].i_channel_label );
+        MP4_GET4BYTES( p_chan->layout.p_descriptions[i].i_channel_flags );
+        MP4_GET4BYTES( p_chan->layout.p_descriptions[i].f_coordinates[0] );
+        MP4_GET4BYTES( p_chan->layout.p_descriptions[i].f_coordinates[1] );
+        MP4_GET4BYTES( p_chan->layout.p_descriptions[i].f_coordinates[2] );
+    }
+
+#ifdef MP4_VERBOSE
+    msg_Dbg( p_stream,
+             "read box: \"chan\" flags=0x%x tag=0x%x bitmap=0x%x descriptions=%u",
+             p_chan->i_channels_flags, p_chan->layout.i_channels_layout_tag,
+             p_chan->layout.i_channels_bitmap, p_chan->layout.i_channels_description_count );
+#endif
+    MP4_READBOX_EXIT( 1 );
+}
+
+static void MP4_FreeBox_stsdext_chan( MP4_Box_t *p_box )
+{
+    MP4_Box_data_chan_t *p_chan = p_box->data.p_chan;
+    free( p_chan->layout.p_descriptions );
+}
+
 static int MP4_ReadBox_dac3( stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_Box_data_dac3_t *p_dac3;
@@ -3371,6 +3417,8 @@ static const struct
     { ATOM_sawb,    MP4_ReadBox_sample_soun,  MP4_FreeBox_sample_soun, ATOM_stsd },
     { ATOM_OggS,    MP4_ReadBox_sample_soun,  MP4_FreeBox_sample_soun, ATOM_stsd },
     { ATOM_alac,    MP4_ReadBox_sample_soun,  MP4_FreeBox_sample_soun, ATOM_stsd },
+    /* Sound extensions */
+    { ATOM_chan,    MP4_ReadBox_stsdext_chan, MP4_FreeBox_stsdext_chan, 0 },
 
     { ATOM_drmi,    MP4_ReadBox_sample_vide,  MP4_FreeBox_sample_vide, ATOM_stsd },
     { ATOM_vide,    MP4_ReadBox_sample_vide,  MP4_FreeBox_sample_vide, ATOM_stsd },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 17fc682..1451ce9 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -140,6 +140,7 @@
 #define ATOM_enda VLC_FOURCC( 'e', 'n', 'd', 'a' )
 #define ATOM_gnre VLC_FOURCC( 'g', 'n', 'r', 'e' )
 #define ATOM_trkn VLC_FOURCC( 't', 'r', 'k', 'n' )
+#define ATOM_chan VLC_FOURCC( 'c', 'h', 'a', 'n' )
 
 #define ATOM_zlib VLC_FOURCC( 'z', 'l', 'i', 'b' )
 #define ATOM_SVQ1 VLC_FOURCC( 'S', 'V', 'Q', '1' )
@@ -1039,6 +1040,24 @@ typedef struct
 
 typedef struct
 {
+    uint8_t i_version;
+    uint32_t i_channels_flags; /* 24 bits */
+    struct
+    {
+        uint32_t i_channels_layout_tag;
+        uint32_t i_channels_bitmap;
+        uint32_t i_channels_description_count;
+        struct
+        {
+            uint32_t i_channel_label;
+            uint32_t i_channel_flags;
+            float    f_coordinates[3];
+        } *p_descriptions;
+    } layout;
+} MP4_Box_data_chan_t;
+
+typedef struct
+{
     uint8_t i_fscod;
     uint8_t i_bsid;
     uint8_t i_bsmod;
@@ -1222,6 +1241,7 @@ typedef union MP4_Box_data_s
     MP4_Box_data_avcC_t *p_avcC;
     MP4_Box_data_dac3_t *p_dac3;
     MP4_Box_data_dvc1_t *p_dvc1;
+    MP4_Box_data_chan_t *p_chan;
     MP4_Box_data_enda_t *p_enda;
     MP4_Box_data_gnre_t *p_gnre;
     MP4_Box_data_trkn_t *p_trkn;



More information about the vlc-commits mailing list