[vlc-commits] demux: mp4: absolute pos is unsigned

Francois Cartegnie git at videolan.org
Tue May 5 20:36:03 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue May  5 17:06:20 2015 +0200| [ba3a2185e5b13b5587d7e8feeeb4e8b25bf1dae5] | committer: Francois Cartegnie

demux: mp4: absolute pos is unsigned

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

 modules/demux/mp4/libmp4.c |   11 +++++++----
 modules/demux/mp4/libmp4.h |    2 +-
 modules/demux/mp4/mp4.c    |    5 +++--
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index c021e22..436a2be 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -244,7 +244,8 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
         return 0;
     }
 
-    off_t i_end = p_container->i_pos + p_container->i_size;
+    uint64_t i_end = p_container->i_pos + p_container->i_size;
+    int i_tell;
 
     do
     {
@@ -263,7 +264,8 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
         /* chain this box with the father and the other at same level */
         MP4_BoxAddChild( p_container, p_box );
 
-        if( p_container->i_size && stream_Tell( p_stream ) == i_end )
+        i_tell = stream_Tell( p_stream );
+        if( p_container->i_size && i_tell >= 0 && (unsigned)i_tell == i_end )
             break;
 
         if( p_box->i_type == i_last_child )
@@ -274,7 +276,8 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
 
     } while( MP4_NextBox( p_stream, p_box ) == 1 );
 
-    if ( p_container->i_size && stream_Tell( p_stream ) != i_end )
+    i_tell = stream_Tell( p_stream );
+    if ( p_container->i_size && i_tell >= 0 && (unsigned)i_tell != i_end )
         MP4_Seek( p_stream, i_end );
 
     return 1;
@@ -4003,7 +4006,7 @@ static MP4_Box_t *MP4_ReadBox( stream_t *p_stream, MP4_Box_t *p_father )
 
     if( !(MP4_Box_Function[i_index].MP4_ReadBox_function)( p_stream, p_box ) )
     {
-        off_t i_end = p_box->i_pos + p_box->i_size;
+        uint64_t i_end = p_box->i_pos + p_box->i_size;
         MP4_BoxFree( p_stream, p_box );
         MP4_Seek( p_stream, i_end ); /* Skip the failed box */
         return NULL;
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 1196623..86bf749 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1489,7 +1489,7 @@ typedef struct MP4_Box_s MP4_Box_t;
 /* the most basic structure */
 struct MP4_Box_s
 {
-    off_t        i_pos;      /* absolute position */
+    uint64_t     i_pos;      /* absolute position */
 
     uint32_t     i_type;
     uint32_t     i_shortsize;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index fa79924..6db7dd4 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -4037,7 +4037,7 @@ static MP4_Box_t * LoadNextChunk( demux_t *p_demux )
     return p_chunk;
 }
 
-static bool BoxExistsInRootTree( MP4_Box_t *p_root, uint32_t i_type, off_t i_pos )
+static bool BoxExistsInRootTree( MP4_Box_t *p_root, uint32_t i_type, uint64_t i_pos )
 {
     while ( p_root )
     {
@@ -5125,7 +5125,8 @@ static int DemuxAsLeaf( demux_t *p_demux )
 
         if ( p_sys->context.i_current_box_type != ATOM_mdat )
         {
-            if ( ! BoxExistsInRootTree( p_sys->p_root, p_sys->context.i_current_box_type, stream_Tell( p_demux->s ) ) )
+            const int i_tell = stream_Tell( p_demux->s );
+            if ( i_tell >= 0 && ! BoxExistsInRootTree( p_sys->p_root, p_sys->context.i_current_box_type, (uint64_t)i_tell ) )
             {// only if !b_probed ??
                 MP4_Box_t *p_vroot = LoadNextChunk( p_demux );
 



More information about the vlc-commits mailing list