[vlc-devel] [PATCH] demux/mp4: fix PTS computation
Frédéric Yhuel
yhuelf at gmail.com
Sun Sep 23 18:23:38 CEST 2012
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.
---
modules/demux/mp4/mp4.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index c83be06..211a952 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -3247,7 +3247,8 @@ static int FreeAndResetChunk( mp4_chunk_t *ck )
free( ck->p_sample_count_dts );
free( ck->p_sample_delta_dts );
free( ck->p_sample_count_pts );
- free( ck->p_sample_offset_pts );
+ if( ck->p_sample_offset_pts )
+ free( ck->p_sample_offset_pts );
free( ck->p_sample_size );
for( uint32_t i = 0; i < ck->i_sample_count; i++ )
free( ck->p_sample_data[i] );
@@ -3459,11 +3460,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 +3495,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;
--
1.7.9.5
More information about the vlc-devel
mailing list