* modules/codec/ffmpeg/video.c: use PTS if available, if not find out the PTS from the DTS and the p_context->has_b_frames and p_pic->reference flags.
* video.c: video decoder using the ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: video.c,v 1.49 2003/11/23 03:55:01 fenrir Exp $
+ * $Id: video.c,v 1.50 2003/11/23 13:15:27 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
/* Video decoder specific part */
mtime_t input_pts;
+ mtime_t input_dts;
mtime_t i_pts;
AVFrame *p_ff_pic;
}
/* ***** misc init ***** */
- p_sys->input_pts = 0;
+ p_sys->input_pts = p_sys->input_dts = 0;
p_sys->i_pts = 0;
p_sys->b_has_b_frames = VLC_FALSE;
p_sys->i_late_frames = 0;
p_block = *pp_block;
- if( p_block->i_pts > 0 )
+ if( p_block->i_pts > 0 || p_block->i_dts > 0 )
{
p_sys->input_pts = p_block->i_pts;
- p_block->i_pts = 0; /* Make sure we don't reuse the same pts twice */
+ p_sys->input_dts = p_block->i_dts;
+
+ /* Make sure we don't reuse the same timestamps twice */
+ p_block->i_pts = p_block->i_dts = 0;
}
/* TODO implement it in a better way */
p_pic = (picture_t *)p_sys->p_ff_pic->opaque;
}
- /* Set the PTS
- * There is an ugly hack here because some demuxers pass us a dts
- * instead of a pts so this screw up things for streams with
- * B frames. */
+ /* Set the PTS */
+ if( p_sys->p_ff_pic->pts ) p_sys->i_pts = p_sys->p_ff_pic->pts;
+
+ /* Sanity check (seems to be needed for some streams ) */
if( p_sys->p_ff_pic->pict_type == FF_B_TYPE )
- p_sys->b_has_b_frames = VLC_TRUE;
- if( p_sys->p_ff_pic->pts &&
- ( !p_sys->p_context->has_b_frames || !p_sys->b_has_b_frames ||
- p_sys->p_ff_pic->pict_type == FF_B_TYPE ) )
{
- p_sys->i_pts = p_sys->p_ff_pic->pts;
+ p_sys->b_has_b_frames = VLC_TRUE;
}
/* Send decoded frame to vout */
picture_t *p_pic;
/* Set picture PTS */
- p_ff_pic->pts = p_sys->input_pts;
- p_sys->input_pts = 0;
+ if( p_sys->input_pts )
+ {
+ p_ff_pic->pts = p_sys->input_pts;
+ }
+ else if( p_sys->input_dts )
+ {
+ /* Some demuxers only set the dts so let's try to find a useful
+ * timestamp from this */
+ if( !p_context->has_b_frames || !p_sys->b_has_b_frames ||
+ !p_ff_pic->reference )
+ {
+ p_ff_pic->pts = p_sys->input_dts;
+ }
+ else p_ff_pic->pts = 0;
+ }
+ else p_ff_pic->pts = 0;
+
+ p_sys->input_pts = p_sys->input_dts = 0;
/* Not much to do in indirect rendering mode */
if( !p_sys->b_direct_rendering )
* asf.c : ASFv01 file input module for vlc
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
- * $Id: asf.c,v 1.45 2003/11/21 16:02:36 fenrir Exp $
+ * $Id: asf.c,v 1.46 2003/11/23 13:15:27 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
p_stream->i_time =
( (mtime_t)i_pts + i_payload * (mtime_t)i_pts_delta );
- p_frag->i_dts =
p_frag->i_pts =
input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
p_stream->i_time * 9 /100 );
+
+ if( p_stream->i_cat != VIDEO_ES )
+ p_frag->i_dts = p_frag->i_pts;
+ else
+ {
+ p_frag->i_dts = p_frag->i_pts;
+ p_frag->i_pts = 0;
+ }
}
block_ChainAppend( &p_stream->p_frame, p_frag );
* avi.c : AVI file Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: avi.c,v 1.74 2003/11/22 15:10:38 fenrir Exp $
+ * $Id: avi.c,v 1.75 2003/11/23 13:15:27 gbazin Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
unsigned int i_track_count = 0;
unsigned int i_track;
vlc_bool_t b_stream;
- vlc_bool_t b_play_audio;
/* cannot be more than 100 stream (dcXX or wbXX) */
avi_track_toread_t toread[100];
p_sys->i_time += 25*1000; /* read 25ms */
- /* Check if we need to send the audio data to decoder */
- b_play_audio = !p_input->stream.control.b_mute;
-
/* init toread */
for( i_track = 0; i_track < p_sys->i_track; i_track++ )
{
b_stream = VLC_TRUE; /* at least one read succeed */
- p_frame->i_dts =
p_frame->i_pts =
input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
p_frame->i_pts * 9/100);
- //p_pes->i_rate = p_input->stream.control.i_rate;
- if( b_play_audio || tk->i_cat != AUDIO_ES )
- {
- es_out_Send( p_input->p_es_out, tk->p_es, p_frame );
- }
+
+ if( tk->i_cat != VIDEO_ES )
+ p_frame->i_dts = p_frame->i_pts;
else
{
- block_Release( p_frame );
+ p_frame->i_dts = p_frame->i_pts;
+ p_frame->i_pts = 0;
}
+
+ //p_pes->i_rate = p_input->stream.control.i_rate;
+ es_out_Send( p_input->p_es_out, tk->p_es, p_frame );
}
}
{
return( -1 );
}
- p_frame->i_dts =
p_frame->i_pts =
input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
AVI_GetPTS( p_stream ) * 9/100);
+ if( avi_pk.i_cat != VIDEO_ES )
+ p_frame->i_dts = p_frame->i_pts;
+ else
+ {
+ p_frame->i_dts = p_frame->i_pts;
+ p_frame->i_pts = 0;
+ }
+
//p_pes->i_rate = p_input->stream.control.i_rate;
es_out_Send( p_input->p_es_out, p_stream->p_es, p_frame );
}
* mkv.cpp : matroska demuxer
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: mkv.cpp,v 1.43 2003/11/21 00:38:01 gbazin Exp $
+ * $Id: mkv.cpp,v 1.44 2003/11/23 13:15:27 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
break;
}
- p_block->i_pts = i_pts;
- p_block->i_dts = i_pts;
+ if( tk.fmt.i_cat != VIDEO_ES )
+ p_block->i_dts = p_block->i_pts = i_pts;
+ else
+ {
+ p_block->i_dts = i_pts;
+ p_block->i_pts = 0;
+ }
if( tk.fmt.i_cat == SPU_ES && strcmp( tk.psz_codec, "S_VOBSUB" ) )
{
* mp4.c : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: mp4.c,v 1.40 2003/10/07 14:59:10 gbazin Exp $
+ * $Id: mp4.c,v 1.41 2003/11/23 13:15:27 gbazin Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
MP4_TrackUnselect( p_input, &track );
break;
}
- p_pes->i_dts =
- p_pes->i_pts = input_ClockGetTS( p_input,
- p_input->stream.p_selected_program,
- MP4_GetTrackPTS( &track ) * 9/100);
+
+ p_pes->i_pts =
+ input_ClockGetTS( p_input,
+ p_input->stream.p_selected_program,
+ MP4_GetTrackPTS( &track ) * 9/100 );
+
+ if( track.i_cat != VIDEO_ES )
+ p_pes->i_dts = p_pes->i_pts;
+ else
+ {
+ p_pes->i_dts = p_pes->i_pts;
+ p_pes->i_pts = 0;
+ }
if( track.p_es->p_decoder_fifo )
{
* ogg.c : ogg stream input module for vlc
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
- * $Id: ogg.c,v 1.45 2003/11/22 12:41:32 gbazin Exp $
+ * $Id: ogg.c,v 1.46 2003/11/23 13:15:27 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
int i_header_len = 0;
mtime_t i_pts;
+ /* Sanity check */
+ if( !p_oggpacket->bytes )
+ {
+ msg_Dbg( p_input, "discarding 0 sized packet" );
+ return;
+ }
+
if( p_stream->b_force_backup )
{
ogg_packet *p_packet_backup;
{
return;
}
- p_block->i_dts = p_block->i_pts = i_pts;
- if( p_stream->fmt.i_cat == SPU_ES ) p_block->i_dts = 0;
+ if( p_stream->fmt.i_cat == AUDIO_ES )
+ p_block->i_dts = p_block->i_pts = i_pts;
+ else if( p_stream->fmt.i_cat == SPU_ES )
+ {
+ p_block->i_pts = i_pts;
+ p_block->i_dts = 0;
+ }
+ else if( p_stream->fmt.i_codec == VLC_FOURCC( 't','h','e','o' ) )
+ p_block->i_dts = p_block->i_pts = i_pts;
+ else
+ {
+ p_block->i_dts = i_pts;
+ p_block->i_pts = 0;
+ }
if( p_stream->fmt.i_codec != VLC_FOURCC( 'v','o','r','b' ) &&
p_stream->fmt.i_codec != VLC_FOURCC( 's','p','x',' ' ) &&