[vlc-commits] demux: mp4: add support for wmapro

Francois Cartegnie git at videolan.org
Tue Oct 27 19:13:53 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Oct 23 15:21:01 2015 +0200| [9187e4c825810b81910f9934a9f60d4ec822e854] | committer: Francois Cartegnie

demux: mp4: add support for wmapro

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

 modules/demux/mp4/essetup.c |   42 ++++++++++++++++++++++++++++--------------
 modules/demux/mp4/libmp4.c  |    2 ++
 modules/demux/mp4/libmp4.h  |    2 ++
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index dbaf04e..8db8b9a 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -389,6 +389,27 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
     return 1;
 }
 
+static bool SetupAudioFromWaveFormatEx( es_format_t *p_fmt, const MP4_Box_t *p_WMA2 )
+{
+    if( p_WMA2 && BOXDATA(p_WMA2) )
+    {
+        wf_tag_to_fourcc(BOXDATA(p_WMA2)->Format.wFormatTag, &p_fmt->i_codec, NULL);
+        p_fmt->audio.i_channels = BOXDATA(p_WMA2)->Format.nChannels;
+        p_fmt->audio.i_rate = BOXDATA(p_WMA2)->Format.nSamplesPerSec;
+        p_fmt->i_bitrate = BOXDATA(p_WMA2)->Format.nAvgBytesPerSec * 8;
+        p_fmt->audio.i_blockalign = BOXDATA(p_WMA2)->Format.nBlockAlign;
+        p_fmt->audio.i_bitspersample = BOXDATA(p_WMA2)->Format.wBitsPerSample;
+        p_fmt->i_extra = BOXDATA(p_WMA2)->i_extra;
+        if( p_fmt->i_extra > 0 )
+        {
+            p_fmt->p_extra = malloc( BOXDATA(p_WMA2)->i_extra );
+            memcpy( p_fmt->p_extra, BOXDATA(p_WMA2)->p_extra, p_fmt->i_extra );
+        }
+        return true;
+    }
+    return false;
+}
+
 int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
 {
     MP4_Box_data_sample_soun_t *p_soun = p_sample->data.p_sample_soun;
@@ -714,21 +735,9 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
         }
         case ATOM_WMA2:
         {
-            MP4_Box_t *p_WMA2 = MP4_BoxGet( p_sample, "wave/WMA2" );
-            if( p_WMA2 && BOXDATA(p_WMA2) )
+            if( SetupAudioFromWaveFormatEx( &p_track->fmt,
+                                            MP4_BoxGet( p_sample, "wave/WMA2" ) ) )
             {
-                p_track->fmt.audio.i_channels = BOXDATA(p_WMA2)->Format.nChannels;
-                p_track->fmt.audio.i_rate = BOXDATA(p_WMA2)->Format.nSamplesPerSec;
-                p_track->fmt.i_bitrate = BOXDATA(p_WMA2)->Format.nAvgBytesPerSec * 8;
-                p_track->fmt.audio.i_blockalign = BOXDATA(p_WMA2)->Format.nBlockAlign;
-                p_track->fmt.audio.i_bitspersample = BOXDATA(p_WMA2)->Format.wBitsPerSample;
-                p_track->fmt.i_extra = BOXDATA(p_WMA2)->i_extra;
-                if( p_track->fmt.i_extra > 0 )
-                {
-                    p_track->fmt.p_extra = malloc( BOXDATA(p_WMA2)->i_extra );
-                    memcpy( p_track->fmt.p_extra, BOXDATA(p_WMA2)->p_extra,
-                            p_track->fmt.i_extra );
-                }
                 p_track->p_asf = MP4_BoxGet( p_sample, "wave/ASF " );
             }
             else
@@ -737,6 +746,11 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
             }
             break;
         }
+        case ATOM_wma: /* isml wmapro */
+        {
+            if( !SetupAudioFromWaveFormatEx( &p_track->fmt, MP4_BoxGet( p_sample, "wfex" ) ) )
+                msg_Err( p_demux, "missing wfex for wma" );
+        }
 
         default:
             msg_Dbg( p_demux, "Unrecognized FourCC %4.4s", (char *)&p_sample->i_type );
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 47945ef..a2dcc97 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -3779,11 +3779,13 @@ static const struct
     { ATOM_OggS,    MP4_ReadBox_sample_soun,  ATOM_stsd },
     { ATOM_alac,    MP4_ReadBox_sample_soun,  ATOM_stsd },
     { ATOM_WMA2,    MP4_ReadBox_sample_soun,  ATOM_stsd }, /* flip4mac */
+    { ATOM_wma,     MP4_ReadBox_sample_soun,  ATOM_stsd }, /* ismv wmapro */
     { ATOM_Opus,    MP4_ReadBox_sample_soun,  ATOM_stsd },
     /* Sound extensions */
     { ATOM_chan,    MP4_ReadBox_stsdext_chan, 0 },
     { ATOM_WMA2,    MP4_ReadBox_WMA2,         ATOM_wave }, /* flip4mac */
     { ATOM_dOps,    MP4_ReadBox_Binary,       ATOM_Opus },
+    { ATOM_wfex,    MP4_ReadBox_WMA2,         ATOM_wma  }, /* ismv formatex */
 
     { ATOM_drmi,    MP4_ReadBox_sample_vide,  ATOM_stsd },
     { ATOM_vide,    MP4_ReadBox_sample_vide,  ATOM_stsd },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index adb84a1..757c589 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -163,6 +163,7 @@ typedef int64_t stime_t;
 #define ATOM_dec3 VLC_FOURCC( 'd', 'e', 'c', '3' )
 #define ATOM_dvc1 VLC_FOURCC( 'd', 'v', 'c', '1' )
 #define ATOM_WMA2 VLC_FOURCC( 'W', 'M', 'A', '2' )
+#define ATOM_wma  VLC_FOURCC( 'w', 'm', 'a', ' ' )
 #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' )
@@ -216,6 +217,7 @@ typedef int64_t stime_t;
 #define ATOM_dv5p VLC_FOURCC( 'd', 'v', '5', 'p' )
 #define ATOM_raw  VLC_FOURCC( 'r', 'a', 'w', ' ' )
 #define ATOM_dOps VLC_FOURCC( 'd', 'O', 'p', 's' )
+#define ATOM_wfex VLC_FOURCC( 'w', 'f', 'e', 'x' )
 
 #define ATOM_jpeg VLC_FOURCC( 'j', 'p', 'e', 'g' )
 



More information about the vlc-commits mailing list