[vlc-commits] Support VC-1 in mp4, as muxed by L-Smash

Jean-Baptiste Kempf git at videolan.org
Tue Apr 10 12:04:07 CEST 2012


vlc/vlc-2.0 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Apr  6 15:30:19 2012 +0200| [106bf7aaa02727d61b31155bdbb1bb630de4dd5f] | committer: Jean-Baptiste Kempf

Support VC-1 in mp4, as muxed by L-Smash

We received already complaints/samples by 4 people in the last week-end...
(cherry picked from commit b4dc61ce93b6706c67139dad1259f1a3b788f18c)
(cherry picked from commit ba1316be2521e153593ca75e588b78d5077caec3)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=106bf7aaa02727d61b31155bdbb1bb630de4dd5f
---

 modules/demux/mp4/libmp4.c |   34 ++++++++++++++++++++++++++++++++++
 modules/demux/mp4/libmp4.h |   11 +++++++++++
 modules/demux/mp4/mp4.c    |   22 +++++++++++++++++++++-
 3 files changed, 66 insertions(+), 1 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 50f1a58..c583e7b 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1259,6 +1259,39 @@ 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 */
+    if( p_dvc1->i_profile_level & 0xf0 >> 4 != 0x06 )
+    {
+        msg_Warn( p_stream, "unsupported VC-1 profile, please report" );
+        MP4_READBOX_EXIT( 0 );
+    }
+
+
+    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;
@@ -2908,6 +2941,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 1ffa90d..d98e624 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -126,6 +126,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' )
@@ -954,6 +955,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;
@@ -1056,6 +1066,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 4a8ebd4..bfbea39 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -1924,7 +1924,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;
@@ -2035,6 +2035,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' ):
             {



More information about the vlc-commits mailing list