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

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:26:18 2014 +0200| [2b768994ce7a5f399552b9258bb9e46ec70a73b3] | committer: Francois Cartegnie

demux: mp4: remove special handler for trkn atom

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

 modules/demux/mp4/libmp4.c |   39 +--------------------------------------
 modules/demux/mp4/libmp4.h |    8 --------
 modules/demux/mp4/meta.c   |   14 +++++++-------
 3 files changed, 8 insertions(+), 53 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 4d8f651..ca21c01 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1805,43 +1805,6 @@ static int MP4_ReadBox_gnre( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
-static int MP4_ReadBox_trkn( stream_t *p_stream, MP4_Box_t *p_box )
-{
-    MP4_Box_data_trkn_t *p_trkn;
-    MP4_READBOX_ENTER( MP4_Box_data_trkn_t );
-
-    p_trkn = p_box->data.p_trkn;
-
-    uint32_t i_data_len;
-    uint32_t i_data_tag;
-
-    MP4_GET4BYTES( i_data_len );
-    MP4_GETFOURCC( i_data_tag );
-    if( i_data_len < 12 || 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( i_reserved );
-    MP4_GET2BYTES( p_trkn->i_track_number );
-#ifdef MP4_VERBOSE
-    msg_Dbg( p_stream, "read box: \"trkn\" number=%i", p_trkn->i_track_number );
-#endif
-    if( i_data_len > 15 )
-    {
-       MP4_GET2BYTES( p_trkn->i_track_total );
-#ifdef MP4_VERBOSE
-       msg_Dbg( p_stream, "read box: \"trkn\" total=%i", p_trkn->i_track_total );
-#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;
@@ -3781,7 +3744,7 @@ static const struct
     { 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_trkn,    MP4_ReadBox_trkn,         MP4_FreeBox_Common,  ATOM_ilst },
+    { ATOM_trkn,    MP4_ReadBox_Metadata,     MP4_FreeBox_Common,  ATOM_ilst },
 
     /* udta */
     { ATOM_0xa9ART, MP4_ReadBox_0xa9xxx,      MP4_FreeBox_0xa9xxx, ATOM_udta },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 2912d81..5fd1776 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1207,13 +1207,6 @@ typedef struct
 
 typedef struct
 {
-    uint32_t i_track_number;
-    uint32_t i_track_total;
-
-} MP4_Box_data_trkn_t;
-
-typedef struct
-{
     uint8_t  i_version;
     uint32_t i_flags;
 
@@ -1385,7 +1378,6 @@ typedef union MP4_Box_data_s
     MP4_Box_data_enda_t *p_enda;
     MP4_Box_data_keys_t *p_keys;
     MP4_Box_data_gnre_t *p_gnre;
-    MP4_Box_data_trkn_t *p_trkn;
     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 93f29b0..8cc3d61 100644
--- a/modules/demux/mp4/meta.c
+++ b/modules/demux/mp4/meta.c
@@ -248,16 +248,16 @@ static void SetupmdirMeta( vlc_meta_t *p_meta, MP4_Box_t *p_box )
         break;
     case ATOM_trkn:
     {
-        if ( p_box->data.p_trkn )
+        const MP4_Box_t *p_data = MP4_BoxGet( p_box, "data" );
+        if ( p_data && BOXDATA(p_data) && BOXDATA(p_data)->i_blob >= 4 &&
+             BOXDATA(p_data)->e_wellknowntype == DATA_WKT_RESERVED )
         {
-            char psz_trck[11];
-            snprintf( psz_trck, sizeof( psz_trck ), "%i",
-                      p_box->data.p_trkn->i_track_number );
+            char psz_trck[6];
+            snprintf( psz_trck, sizeof( psz_trck ), "%"PRIu16, GetWBE(&BOXDATA(p_data)->p_blob[2]) );
             vlc_meta_SetTrackNum( p_meta, psz_trck );
-            if( p_box->data.p_trkn->i_track_total > 0 )
+            if( BOXDATA(p_data)->i_blob >= 8 )
             {
-                snprintf( psz_trck, sizeof( psz_trck ), "%i",
-                          p_box->data.p_trkn->i_track_total );
+                snprintf( psz_trck, sizeof( psz_trck ), "%"PRIu16, GetWBE(&BOXDATA(p_data)->p_blob[4]) );
                 vlc_meta_Set( p_meta, vlc_meta_TrackTotal, psz_trck );
             }
         }



More information about the vlc-commits mailing list