[vlc-commits] demux: mp4: remove special handler for atom gnre

Francois Cartegnie git at videolan.org
Thu Oct 16 20:05:21 CEST 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Oct 16 16:34:29 2014 +0200| [5dacc81c8265ca0ebea56750812c68ab6e90f193] | committer: Francois Cartegnie

demux: mp4: remove special handler for atom gnre

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

 modules/demux/mp4/libmp4.c |   33 +--------------------------------
 modules/demux/mp4/libmp4.h |    7 -------
 modules/demux/mp4/meta.c   |   12 ++++++++++--
 3 files changed, 11 insertions(+), 41 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index ca21c01..f0c4433 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1774,37 +1774,6 @@ static int MP4_ReadBox_enda( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-static int MP4_ReadBox_gnre( stream_t *p_stream, MP4_Box_t *p_box )
-{
-    MP4_Box_data_gnre_t *p_gnre;
-    MP4_READBOX_ENTER( MP4_Box_data_gnre_t );
-
-    p_gnre = p_box->data.p_gnre;
-
-    uint32_t i_data_len;
-    uint32_t i_data_tag;
-
-    MP4_GET4BYTES( i_data_len );
-    MP4_GETFOURCC( i_data_tag );
-    if( i_data_len < 10 || i_data_tag != ATOM_data )
-        MP4_READBOX_EXIT( 0 );
-
-    uint32_t i_version;
-    VLC_UNUSED(i_version);
-    uint32_t i_reserved;
-    VLC_UNUSED(i_reserved);
-    MP4_GET4BYTES( i_version );
-    MP4_GET4BYTES( i_reserved );
-    MP4_GET2BYTES( p_gnre->i_genre );
-    if( p_gnre->i_genre == 0 )
-        MP4_READBOX_EXIT( 0 );
-#ifdef MP4_VERBOSE
-    msg_Dbg( p_stream, "read box: \"gnre\" genre=%i", p_gnre->i_genre );
-#endif
-
-    MP4_READBOX_EXIT( 1 );
-}
-
 static int MP4_ReadBox_sample_soun( stream_t *p_stream, MP4_Box_t *p_box )
 {
     p_box->i_handler = ATOM_soun;
@@ -3743,7 +3712,7 @@ static const struct
     { ATOM_0xa9wrt, MP4_ReadBox_0xa9xxx,      MP4_FreeBox_0xa9xxx, ATOM_ilst },
     { ATOM_chpl,    MP4_ReadBox_chpl,         MP4_FreeBox_chpl,    ATOM_ilst },
     { ATOM_covr,    MP4_ReadBoxContainer,     MP4_FreeBox_Common,  ATOM_ilst },
-    { ATOM_gnre,    MP4_ReadBox_gnre,         MP4_FreeBox_Common,  ATOM_ilst },
+    { ATOM_gnre,    MP4_ReadBox_Metadata,     MP4_FreeBox_Common,  ATOM_ilst },
     { ATOM_trkn,    MP4_ReadBox_Metadata,     MP4_FreeBox_Common,  ATOM_ilst },
 
     /* udta */
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 5fd1776..29ba812 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1191,12 +1191,6 @@ typedef struct
 
 typedef struct
 {
-    uint16_t i_genre;
-
-} MP4_Box_data_gnre_t;
-
-typedef struct
-{
     uint32_t i_entry_count;
     struct
     {
@@ -1377,7 +1371,6 @@ typedef union MP4_Box_data_s
     MP4_Box_data_chan_t *p_chan;
     MP4_Box_data_enda_t *p_enda;
     MP4_Box_data_keys_t *p_keys;
-    MP4_Box_data_gnre_t *p_gnre;
     MP4_Box_data_iods_t *p_iods;
     MP4_Box_data_pasp_t *p_pasp;
     MP4_Box_data_trex_t *p_trex;
diff --git a/modules/demux/mp4/meta.c b/modules/demux/mp4/meta.c
index 8cc3d61..480a3e8 100644
--- a/modules/demux/mp4/meta.c
+++ b/modules/demux/mp4/meta.c
@@ -243,9 +243,17 @@ static void SetupmdirMeta( vlc_meta_t *p_meta, MP4_Box_t *p_box )
     switch( p_box->i_type )
     {
     case ATOM_gnre:
-        if( p_box->data.p_gnre && p_box->data.p_gnre->i_genre <= NUM_GENRES )
-            vlc_meta_SetGenre( p_meta, ppsz_genres[p_box->data.p_gnre->i_genre - 1] );
+    {
+        const MP4_Box_t *p_data = MP4_BoxGet( p_box, "data" );
+        if ( p_data && BOXDATA(p_data) && BOXDATA(p_data)->i_blob >= 2 &&
+             BOXDATA(p_data)->e_wellknowntype == DATA_WKT_RESERVED )
+        {
+            const uint16_t i_genre = GetWBE(BOXDATA(p_data)->p_blob);
+            if( i_genre && i_genre <= NUM_GENRES )
+                vlc_meta_SetGenre( p_meta, ppsz_genres[i_genre - 1] );
+        }
         break;
+    }
     case ATOM_trkn:
     {
         const MP4_Box_t *p_data = MP4_BoxGet( p_box, "data" );



More information about the vlc-commits mailing list