[vlc-commits] mp4 demux: read dec3 box
Rafaël Carré
git at videolan.org
Wed Sep 3 13:15:58 CEST 2014
vlc | branch: master | Rafaël Carré <funman at videolan.org> | Wed Sep 3 13:03:17 2014 +0200| [d4e1fc3b4f15529f80b3fea8060406f5db9b7518] | committer: Rafaël Carré
mp4 demux: read dec3 box
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d4e1fc3b4f15529f80b3fea8060406f5db9b7518
---
modules/demux/mp4/libmp4.c | 42 ++++++++++++++++++++++++++++++++++++++++++
modules/demux/mp4/libmp4.h | 18 ++++++++++++++++++
modules/demux/mp4/mp4.c | 19 ++++++++++++++-----
3 files changed, 74 insertions(+), 5 deletions(-)
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 66f5db2..f3c99cb 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1498,6 +1498,47 @@ static void MP4_FreeBox_stsdext_chan( MP4_Box_t *p_box )
free( p_chan->layout.p_descriptions );
}
+static int MP4_ReadBox_dec3( stream_t *p_stream, MP4_Box_t *p_box )
+{
+ MP4_READBOX_ENTER( MP4_Box_data_dec3_t );
+
+ MP4_Box_data_dec3_t *p_dec3 = p_box->data.p_dec3;
+
+ unsigned i_header;
+ MP4_GET2BYTES( i_header );
+
+ p_dec3->i_data_rate = i_header >> 3;
+ p_dec3->i_num_ind_sub = (i_header & 0x7) + 1;
+ for (uint8_t i = 0; i < p_dec3->i_num_ind_sub; i++) {
+ MP4_GET3BYTES( i_header );
+ p_dec3->stream[i].i_fscod = ( i_header >> 22 ) & 0x03;
+ p_dec3->stream[i].i_bsid = ( i_header >> 17 ) & 0x01f;
+ p_dec3->stream[i].i_bsmod = ( i_header >> 12 ) & 0x01f;
+ p_dec3->stream[i].i_acmod = ( i_header >> 9 ) & 0x07;
+ p_dec3->stream[i].i_lfeon = ( i_header >> 8 ) & 0x01;
+ p_dec3->stream[i].i_num_dep_sub = (i_header >> 1) & 0x0f;
+ if (p_dec3->stream[i].i_num_dep_sub) {
+ MP4_GET1BYTE( p_dec3->stream[i].i_chan_loc );
+ p_dec3->stream[i].i_chan_loc |= (i_header & 1) << 8;
+ } else
+ p_dec3->stream[i].i_chan_loc = 0;
+ }
+
+#ifdef MP4_VERBOSE
+ msg_Dbg( p_stream,
+ "read box: \"dec3\" bitrate %dkbps %d independant substreams",
+ p_dec3->i_data_rate, p_dec3->i_num_ind_sub);
+
+ for (uint8_t i = 0; i < p_dec3->i_num_ind_sub; i++)
+ msg_Dbg( p_stream,
+ "\tstream %d: bsid=0x%x bsmod=0x%x acmod=0x%x lfeon=0x%x "
+ "num dependant subs=%d chan_loc=0x%x",
+ i, p_dec3->stream[i].i_bsid, p_dec3->stream[i].i_bsmod, p_dec3->stream[i].i_acmod,
+ p_dec3->stream[i].i_lfeon, p_dec3->stream[i].i_num_dep_sub, p_dec3->stream[i].i_chan_loc );
+#endif
+ MP4_READBOX_EXIT( 1 );
+}
+
static int MP4_ReadBox_dac3( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_Box_data_dac3_t *p_dac3;
@@ -3376,6 +3417,7 @@ static const struct
{ ATOM_avcC, MP4_ReadBox_avcC, MP4_FreeBox_avcC, 0 },
{ ATOM_hvcC, MP4_ReadBox_hvcC, MP4_FreeBox_hvcC, 0 },
{ ATOM_dac3, MP4_ReadBox_dac3, MP4_FreeBox_Common, 0 },
+ { ATOM_dec3, MP4_ReadBox_dec3, MP4_FreeBox_Common, 0 },
{ ATOM_dvc1, MP4_ReadBox_dvc1, MP4_FreeBox_Common, 0 },
{ ATOM_enda, MP4_ReadBox_enda, MP4_FreeBox_Common, 0 },
{ ATOM_iods, MP4_ReadBox_iods, MP4_FreeBox_Common, 0 },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index b6c8fa4..d8ec684 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1109,6 +1109,23 @@ typedef struct
typedef struct
{
+ uint16_t i_data_rate;
+ uint8_t i_num_ind_sub;
+ struct
+ {
+ uint8_t i_fscod;
+ uint8_t i_bsid;
+ uint8_t i_bsmod;
+ uint8_t i_acmod;
+ uint8_t i_lfeon;
+ uint8_t i_num_dep_sub;
+ uint16_t i_chan_loc;
+ } stream[8];
+
+} MP4_Box_data_dec3_t;
+
+typedef struct
+{
uint8_t i_fscod;
uint8_t i_bsid;
uint8_t i_bsmod;
@@ -1291,6 +1308,7 @@ typedef union MP4_Box_data_s
MP4_Box_data_esds_t *p_esds;
MP4_Box_data_avcC_t *p_avcC;
MP4_Box_data_dac3_t *p_dac3;
+ MP4_Box_data_dec3_t *p_dec3;
MP4_Box_data_dvc1_t *p_dvc1;
MP4_Box_data_chan_t *p_chan;
MP4_Box_data_enda_t *p_enda;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index cef8be8..aad554c 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -2424,6 +2424,20 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
p_track->fmt.i_codec = VLC_CODEC_MPGA;
break;
}
+ case( VLC_FOURCC( 'e', 'c', '-', '3' ) ):
+ {
+ MP4_Box_t *p_dec3_box = MP4_BoxGet( p_sample, "dec3", 0 );
+
+ p_track->fmt.i_codec = VLC_CODEC_EAC3;
+ if( p_dec3_box )
+ {
+ MP4_Box_data_dec3_t *p_dec3 = p_dec3_box->data.p_dec3;
+ p_track->fmt.audio.i_channels = 0;
+ p_track->fmt.i_bitrate = p_dec3->i_data_rate * 1000;
+ p_track->fmt.audio.i_bitspersample = 0;
+ }
+ break;
+ }
case( VLC_FOURCC( 'a', 'c', '-', '3' ) ):
{
MP4_Box_t *p_dac3_box = MP4_BoxGet( p_sample, "dac3", 0 );
@@ -2447,11 +2461,6 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
}
break;
}
- case( VLC_FOURCC( 'e', 'c', '-', '3' ) ):
- {
- p_track->fmt.i_codec = VLC_CODEC_EAC3;
- break;
- }
case( VLC_FOURCC( 'r', 'a', 'w', ' ' ) ):
case( VLC_FOURCC( 'N', 'O', 'N', 'E' ) ):
More information about the vlc-commits
mailing list