vlc | branch: master | Jean-Baptiste Kempf <[email protected]> | Fri Apr 6 15:30:19 2012 +0200| [b4dc61ce93b6706c67139dad1259f1a3b788f18c] | committer: Jean-Baptiste Kempf
Support VC-1 in mp4, as muxed by L-Smash We will get more and more of those samples soon... > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b4dc61ce93b6706c67139dad1259f1a3b788f18c --- modules/demux/mp4/libmp4.c | 28 ++++++++++++++++++++++++++++ modules/demux/mp4/libmp4.h | 11 +++++++++++ modules/demux/mp4/mp4.c | 22 +++++++++++++++++++++- 3 files changed, 60 insertions(+), 1 deletions(-) diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c index cfd7e93..e4d1fca 100644 --- a/modules/demux/mp4/libmp4.c +++ b/modules/demux/mp4/libmp4.c @@ -1361,6 +1361,33 @@ static int MP4_ReadBox_dac3( stream_t *p_stream, MP4_Box_t *p_box ) MP4_READBOX_EXIT( 1 ); } +static int MP4_ReadBox_dvc1( stream_t *p_stream, MP4_Box_t *p_box ) +{ + MP4_Box_data_dvc1_t *p_dvc1; + + MP4_READBOX_ENTER( MP4_Box_data_dvc1_t ); + p_dvc1 = p_box->data.p_dvc1; + + MP4_GET1BYTE( p_dvc1->i_profile_level ); /* profile is on 4bits, level 3bits */ + + p_dvc1->i_vc1 = p_box->i_size - 7; /* Header + profile_level */ + + if( p_dvc1->i_vc1 > 0 ) + { + uint8_t *p = p_dvc1->p_vc1 = malloc( p_dvc1->i_vc1 ); + if( p ) + memcpy( p, p_peek, i_read ); + } + +#ifdef MP4_VERBOSE + msg_Dbg( p_stream, + "read box: \"dvc1\" profile=0x%x level=0x%x", + p_dvc1->i_profile_level & 0xf0 >> 4, p_dvc1->i_profile_level & 0xe > 1 ); +#endif + + MP4_READBOX_EXIT( 1 ); +} + static int MP4_ReadBox_enda( stream_t *p_stream, MP4_Box_t *p_box ) { MP4_Box_data_enda_t *p_enda; @@ -3063,6 +3090,7 @@ static const struct { ATOM_cmvd, MP4_ReadBox_cmvd, MP4_FreeBox_cmvd }, { ATOM_avcC, MP4_ReadBox_avcC, MP4_FreeBox_avcC }, { ATOM_dac3, MP4_ReadBox_dac3, MP4_FreeBox_Common }, + { ATOM_dvc1, MP4_ReadBox_dvc1, MP4_FreeBox_Common }, { ATOM_enda, MP4_ReadBox_enda, MP4_FreeBox_Common }, { ATOM_gnre, MP4_ReadBox_gnre, MP4_FreeBox_Common }, { ATOM_trkn, MP4_ReadBox_trkn, MP4_FreeBox_Common }, diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h index 3c5f840..25ac42c 100644 --- a/modules/demux/mp4/libmp4.h +++ b/modules/demux/mp4/libmp4.h @@ -130,6 +130,7 @@ #define ATOM_alac VLC_FOURCC( 'a', 'l', 'a', 'c' ) #define ATOM_dac3 VLC_FOURCC( 'd', 'a', 'c', '3' ) #define ATOM_dec3 VLC_FOURCC( 'd', 'e', 'c', '3' ) +#define ATOM_dvc1 VLC_FOURCC( 'd', 'v', 'c', '1' ) #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' ) @@ -1009,6 +1010,15 @@ typedef struct typedef struct { + uint8_t i_profile_level; + + int i_vc1; + uint8_t *p_vc1; + +} MP4_Box_data_dvc1_t; + +typedef struct +{ uint16_t i_little_endian; } MP4_Box_data_enda_t; @@ -1139,6 +1149,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_dvc1_t *p_dvc1; MP4_Box_data_enda_t *p_enda; MP4_Box_data_gnre_t *p_gnre; MP4_Box_data_trkn_t *p_trkn; diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index 738cdb0..c0803cb 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -1898,7 +1898,7 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track, p_track->fmt.i_codec = VLC_FOURCC( 'M','J','2','C' ); break; case( 0xa3 ): /* vc1 */ - p_track->fmt.i_codec = VLC_FOURCC( 'W','V','C','1' ); + p_track->fmt.i_codec = VLC_CODEC_VC1; break; case( 0xa4 ): p_track->fmt.i_codec = VLC_CODEC_DIRAC; @@ -2012,6 +2012,26 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track, } break; + case VLC_FOURCC( 'v', 'c', '-', '1' ): + { + MP4_Box_t *p_dvc1 = MP4_BoxGet( p_sample, "dvc1" ); + if( p_dvc1 ) + { + p_track->fmt.i_extra = p_dvc1->data.p_dvc1->i_vc1; + if( p_track->fmt.i_extra > 0 ) + { + p_track->fmt.p_extra = malloc( p_dvc1->data.p_dvc1->i_vc1 ); + memcpy( p_track->fmt.p_extra, p_dvc1->data.p_dvc1->p_vc1, + p_track->fmt.i_extra ); + } + } + else + { + msg_Err( p_demux, "missing dvc1" ); + } + break; + } + /* avc1: send avcC (h264 without annexe B, ie without start code)*/ case VLC_FOURCC( 'a', 'v', 'c', '1' ): { _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
