[vlc-commits] demux: mp4: fix trun sample ctts values

Francois Cartegnie git at videolan.org
Tue Oct 27 19:13:54 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Oct 23 23:47:19 2015 +0200| [ed863ecfc8b6f7c224396ec95082804d747dfc61] | committer: Francois Cartegnie

demux: mp4: fix trun sample ctts values

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

 modules/demux/mp4/mp4.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 033257f..d86f0e8 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -3856,10 +3856,12 @@ static int MP4_frg_GetChunk( demux_t *p_demux, MP4_Box_t *p_chunk, unsigned *i_t
 
         if( ret->p_sample_offset_pts )
         {
-            if ( p_trun_data->i_version == 0 )
+            if ( p_trun_data->i_version == 1 )
+                ret->p_sample_offset_pts[i] = (int32_t) p_trun_data->p_samples[i].i_composition_time_offset;
+            else if( p_trun_data->p_samples[i].i_composition_time_offset < 0xFF000000 )
+                ret->p_sample_offset_pts[i] = p_trun_data->p_samples[i].i_composition_time_offset;
+            else /* version 0 with negative */
                 ret->p_sample_offset_pts[i] = (int32_t) p_trun_data->p_samples[i].i_composition_time_offset;
-            else
-                ret->p_sample_offset_pts[i] = __MIN( INT32_MAX, p_trun_data->p_samples[i].i_composition_time_offset );
         }
 
         if( p_trun_data->i_flags & MP4_TRUN_SAMPLE_SIZE )
@@ -4521,8 +4523,10 @@ static int LeafParseTRUN( demux_t *p_demux, mp4_track_t *p_track,
         {
             if ( p_trun->i_version == 1 )
                 i_nzpts += CLOCK_FREQ * (int32_t) p_trun->p_samples[i].i_composition_time_offset / p_track->i_timescale;
-            else
+            else if( p_trun->p_samples[i].i_composition_time_offset < 0xFF000000 )
                 i_nzpts += CLOCK_FREQ * p_trun->p_samples[i].i_composition_time_offset / p_track->i_timescale;
+            else /* version 0 with negative */
+                i_nzpts += CLOCK_FREQ * (int32_t) p_trun->p_samples[i].i_composition_time_offset / p_track->i_timescale;
         }
 
         if( p_trun->i_flags & MP4_TRUN_SAMPLE_SIZE )



More information about the vlc-commits mailing list