[vlc-commits] demux: mp4: fix ctts sign storage

Francois Cartegnie git at videolan.org
Thu May 11 23:02:14 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu May 11 22:33:45 2017 +0200| [b05d1e2e884bc113bf35a06edf549c1a6827620a] | committer: Francois Cartegnie

demux: mp4: fix ctts sign storage

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

 modules/demux/mp4/libmp4.c | 7 ++++++-
 modules/demux/mp4/libmp4.h | 6 +++++-
 modules/demux/mp4/mp4.c    | 8 ++++----
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 5c43fbfee8..067009d9f4 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1020,7 +1020,12 @@ static int MP4_ReadBox_trun(  stream_t *p_stream, MP4_Box_t *p_box )
         if( p_box->data.p_trun->i_flags & MP4_TRUN_SAMPLE_FLAGS )
             MP4_GET4BYTES( p_sample->i_flags );
         if( p_box->data.p_trun->i_flags & MP4_TRUN_SAMPLE_TIME_OFFSET )
-            MP4_GET4BYTES( p_sample->i_composition_time_offset );
+        {
+            if( p_box->data.p_trun->i_flags == 0 )
+                MP4_GET4BYTES( p_sample->i_composition_time_offset.v0 );
+            else
+                MP4_GET4BYTES( p_sample->i_composition_time_offset.v1 );
+        }
     }
 
 #ifdef MP4_ULTRA_VERBOSE
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index de4e0e03aa..77cccbd8ee 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1157,7 +1157,11 @@ typedef struct MP4_descriptor_trun_sample_t
     uint32_t i_duration;
     uint32_t i_size;
     uint32_t i_flags;
-    uint32_t i_composition_time_offset; /* version == 0 ? signed : unsigned */
+    union
+    {
+        uint32_t v0;
+        int32_t  v1; /* version == 1 ? signed : unsigned */
+    } i_composition_time_offset;
 } MP4_descriptor_trun_sample_t;
 
 typedef struct MP4_Box_data_trun_s
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index beb82b985e..3f0ade0f4f 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -4210,11 +4210,11 @@ static int LeafParseTRUN( demux_t *p_demux, mp4_track_t *p_track,
         if( p_trun->i_flags & MP4_TRUN_SAMPLE_TIME_OFFSET )
         {
             if ( p_trun->i_version == 1 )
-                i_pts += (int32_t) p_trun->p_samples[i].i_composition_time_offset;
-            else if( p_trun->p_samples[i].i_composition_time_offset < 0xFF000000 )
-                i_pts += p_trun->p_samples[i].i_composition_time_offset;
+                i_pts += p_trun->p_samples[i].i_composition_time_offset.v1;
+            else if( p_trun->p_samples[i].i_composition_time_offset.v0 < 0xFF000000 )
+                i_pts += p_trun->p_samples[i].i_composition_time_offset.v0;
             else /* version 0 with negative */
-                i_pts += (int32_t) p_trun->p_samples[i].i_composition_time_offset;
+                i_pts += p_trun->p_samples[i].i_composition_time_offset.v1;
         }
 
         if( p_trun->i_flags & MP4_TRUN_SAMPLE_SIZE )



More information about the vlc-commits mailing list