[vlc-commits] demux/mp4: fix PTS computation

Frédéric Yhuel git at videolan.org
Mon Sep 24 12:47:03 CEST 2012


vlc | branch: master | Frédéric Yhuel <yhuelf at gmail.com> | Sun Sep 23 18:23:38 2012 +0200| [5a72f814368a14e31bfbce3c7a3402068e3f648a] | committer: Jean-Baptiste Kempf

demux/mp4: fix PTS computation

p_sample_offset_pts must be NULL if MP4_TRUN_SAMPLE_TIME_OFFSET is not
present. Then MP4_TrackGetPTSDelta would return -1 (instead of 0
previously), and PTS of video frames would be set to VLC_TS_INVALID,
which is the right thing to do in that case.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/demux/mp4/mp4.c |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index c83be06..f45e9fd 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -3459,11 +3459,16 @@ static int MP4_frg_GetChunk( demux_t *p_demux, MP4_Box_t *p_chunk, unsigned *i_t
         return VLC_ENOMEM;
 
     ret->p_sample_count_pts = calloc( ret->i_sample_count, sizeof( uint32_t ) );
-    ret->p_sample_offset_pts = calloc( ret->i_sample_count, sizeof( int32_t ) );
-
-    if( !ret->p_sample_count_pts || !ret->p_sample_offset_pts )
+    if( !ret->p_sample_count_pts )
         return VLC_ENOMEM;
 
+    if( p_trun_data->i_flags & MP4_TRUN_SAMPLE_TIME_OFFSET )
+    {
+        ret->p_sample_offset_pts = calloc( ret->i_sample_count, sizeof( int32_t ) );
+        if( !ret->p_sample_offset_pts )
+            return VLC_ENOMEM;
+    }
+
     ret->p_sample_size = calloc( ret->i_sample_count, sizeof( uint32_t ) );
     if( !ret->p_sample_size )
         return VLC_ENOMEM;
@@ -3489,13 +3494,11 @@ static int MP4_frg_GetChunk( demux_t *p_demux, MP4_Box_t *p_chunk, unsigned *i_t
 
         ret->p_sample_count_dts[i] = ret->p_sample_count_pts[i] = 1;
 
-        if( p_trun_data->i_flags & MP4_TRUN_SAMPLE_TIME_OFFSET )
+        if( ret->p_sample_offset_pts )
         {
             ret->p_sample_offset_pts[i] =
                         p_trun_data->p_samples[i].i_composition_time_offset;
         }
-        else
-            ret->p_sample_offset_pts[i] = 0;
 
         if( p_trun_data->i_flags & MP4_TRUN_SAMPLE_SIZE )
             len = ret->p_sample_size[i] = p_trun_data->p_samples[i].i_size;



More information about the vlc-commits mailing list