[vlc-commits] mp4: preserve header size

Rémi Denis-Courmont git at videolan.org
Fri Nov 24 20:54:33 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov 23 23:27:43 2017 +0200| [05f435640069ea4923e1bb49faf9a93e7bb6dc02] | committer: Rémi Denis-Courmont

mp4: preserve header size

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

 modules/demux/mp4/libmp4.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index fcda84e3a8..334e447b49 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -113,21 +113,21 @@ static char *mp4_getstringz( uint8_t **restrict in, int64_t *restrict size )
     int64_t i_read = p_box->i_size; \
     if( maxread < (uint64_t)i_read ) i_read = maxread;\
     uint8_t *p_peek, *p_buff; \
-    ssize_t i_actually_read; \
+    const size_t header_size = mp4_box_headersize( p_box ); \
     if( !( p_peek = p_buff = malloc( i_read ) ) ) \
     { \
         return( 0 ); \
     } \
-    i_actually_read = vlc_stream_Read( p_stream, p_peek, i_read ); \
-    if( i_actually_read < 0 || i_actually_read < i_read )\
+    ssize_t val = vlc_stream_Read( p_stream, p_peek, i_read ); \
+    if( val < 0 || val < i_read )\
     { \
         msg_Warn( p_stream, "MP4_READBOX_ENTER: I got %zd bytes, "\
-        "but I requested %" PRId64, i_actually_read, i_read );\
+        "but I requested %" PRId64, val, i_read );\
         free( p_buff ); \
         return( 0 ); \
     } \
-    p_peek += mp4_box_headersize( p_box ); \
-    i_read -= mp4_box_headersize( p_box ); \
+    p_peek += header_size; \
+    i_read -= header_size; \
     if( !( p_box->data.p_payload = calloc( 1, sizeof( MP4_Box_data_TYPE_t ) ) ) ) \
     { \
         free( p_buff ); \
@@ -2377,6 +2377,8 @@ static int MP4_ReadBox_sample_soun( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_ENTER( MP4_Box_data_sample_soun_t, MP4_FreeBox_sample_soun );
     p_box->data.p_sample_soun->p_qt_description = NULL;
 
+    ssize_t i_actually_read = i_read + header_size;
+
     /* Sanity check needed because the "wave" box does also contain an
      * "mp4a" box that we don't understand. */
     if( i_read < 28 )
@@ -2554,6 +2556,8 @@ int MP4_ReadBox_sample_vide( stream_t *p_stream, MP4_Box_t *p_box )
     p_box->i_handler = ATOM_vide;
     MP4_READBOX_ENTER( MP4_Box_data_sample_vide_t, MP4_FreeBox_sample_vide );
 
+    ssize_t i_actually_read = i_read + header_size;
+
     for( unsigned i = 0; i < 6 ; i++ )
     {
         MP4_GET1BYTE( p_box->data.p_sample_vide->i_reserved1[i] );



More information about the vlc-commits mailing list