* copy.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: copy.c,v 1.23 2004/01/25 17:58:30 murray Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
p_block = *pp_block;
*pp_block = NULL;
- if( p_block->i_pts <= 0 )
- {
- p_block->i_pts = p_block->i_dts;
- }
- else if( p_block->i_dts <= 0 )
+ if( p_block->i_dts <= 0 )
{
p_block->i_dts = p_block->i_pts;
}
- if( p_block->i_pts <= 0 )
+ if( p_block->i_dts <= 0 )
{
- msg_Dbg( p_dec, "need pts > 0" );
+ msg_Dbg( p_dec, "need dts > 0" );
block_Release( p_block );
return NULL;
}
return p_ret;
}
-
int i_crop_right;
int i_crop_left;
+ mtime_t i_input_dts;
mtime_t i_input_pts;
+ vlc_bool_t b_input_has_b_frames;
+
mtime_t i_output_pts;
};
p_sys->f_rc_buffer_aggressivity = 0.1;
p_sys->i_threads = 0;
p_sys->b_trellis = 0;
+ p_sys->b_input_has_b_frames = VLC_FALSE;
if( ( codec = sout_cfg_find_value( p_stream->p_cfg, "acodec" ) ) )
{
i_data = in->i_size;
p_data = in->p_buffer;
-
+
for( ;; )
{
block_t *p_block;
/* decode frame */
frame = id->p_ff_pic;
p_sys->i_input_pts = in->i_pts;
+ p_sys->i_input_dts = in->i_dts;
if( id->ff_dec )
{
i_used = avcodec_decode_video( id->ff_dec_c, frame,
/* Set PTS */
frame->pts = p_sys->i_input_pts ? p_sys->i_input_pts :
AV_NOPTS_VALUE;
+
+ frame->pict_type = FF_I_TYPE;
}
if( i_used < 0 )
p_sys->i_output_pts = frame->pts;
}
+ /* Sanity check (seems to be needed for some streams ) */
+ if( frame->pict_type == FF_B_TYPE )
+ {
+ p_sys->b_input_has_b_frames = VLC_TRUE;
+ }
+
if( !id->b_enc_inited )
{
/* Hack because of the copy packetizer which can fail to detect the
sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_context->opaque;
/* Set PTS */
- p_frame->pts = p_sys->i_input_pts ? p_sys->i_input_pts : AV_NOPTS_VALUE;
+ if( p_sys->i_input_pts )
+ {
+ p_frame->pts = p_sys->i_input_pts;
+ }
+ else if( p_sys->i_input_dts )
+ {
+ /* Some demuxers/packetizers only set the dts so let's try to find a
+ * useful timestamp from this */
+ if( !p_context->has_b_frames || !p_sys->b_input_has_b_frames ||
+ !p_frame->reference )
+ {
+ p_frame->pts = p_sys->i_input_dts;
+ }
+ else p_frame->pts = AV_NOPTS_VALUE;
+ }
+ else p_frame->pts = AV_NOPTS_VALUE;
+
+ p_sys->i_input_pts = 0;
+ p_sys->i_input_dts = 0;
return avcodec_default_get_buffer( p_context, p_frame );
}