Commit 6c955787 authored by Gildas Bazin's avatar Gildas Bazin

* src/input/input_dec.c: fix for input_EndDecoder() when using the async mode.

* modules/packetizer/copy.c: better not send pts instead of invalid ones.
* modules/stream_out/transcode.c: when no pts, use dts wherever possible (low delay / b frame).
parent 116b248f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* copy.c * copy.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -261,18 +261,14 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block ) ...@@ -261,18 +261,14 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block )
p_block = *pp_block; p_block = *pp_block;
*pp_block = NULL; *pp_block = NULL;
if( p_block->i_pts <= 0 ) if( p_block->i_dts <= 0 )
{
p_block->i_pts = p_block->i_dts;
}
else if( p_block->i_dts <= 0 )
{ {
p_block->i_dts = p_block->i_pts; 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 ); block_Release( p_block );
return NULL; return NULL;
} }
...@@ -285,4 +281,3 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block ) ...@@ -285,4 +281,3 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block )
return p_ret; return p_ret;
} }
...@@ -136,7 +136,10 @@ struct sout_stream_sys_t ...@@ -136,7 +136,10 @@ struct sout_stream_sys_t
int i_crop_right; int i_crop_right;
int i_crop_left; int i_crop_left;
mtime_t i_input_dts;
mtime_t i_input_pts; mtime_t i_input_pts;
vlc_bool_t b_input_has_b_frames;
mtime_t i_output_pts; mtime_t i_output_pts;
}; };
...@@ -167,6 +170,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -167,6 +170,7 @@ static int Open( vlc_object_t *p_this )
p_sys->f_rc_buffer_aggressivity = 0.1; p_sys->f_rc_buffer_aggressivity = 0.1;
p_sys->i_threads = 0; p_sys->i_threads = 0;
p_sys->b_trellis = 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" ) ) ) if( ( codec = sout_cfg_find_value( p_stream->p_cfg, "acodec" ) ) )
{ {
...@@ -1330,7 +1334,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1330,7 +1334,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
i_data = in->i_size; i_data = in->i_size;
p_data = in->p_buffer; p_data = in->p_buffer;
for( ;; ) for( ;; )
{ {
block_t *p_block; block_t *p_block;
...@@ -1340,6 +1344,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1340,6 +1344,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
/* decode frame */ /* decode frame */
frame = id->p_ff_pic; frame = id->p_ff_pic;
p_sys->i_input_pts = in->i_pts; p_sys->i_input_pts = in->i_pts;
p_sys->i_input_dts = in->i_dts;
if( id->ff_dec ) if( id->ff_dec )
{ {
i_used = avcodec_decode_video( id->ff_dec_c, frame, i_used = avcodec_decode_video( id->ff_dec_c, frame,
...@@ -1358,6 +1363,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1358,6 +1363,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
/* Set PTS */ /* Set PTS */
frame->pts = p_sys->i_input_pts ? p_sys->i_input_pts : frame->pts = p_sys->i_input_pts ? p_sys->i_input_pts :
AV_NOPTS_VALUE; AV_NOPTS_VALUE;
frame->pict_type = FF_I_TYPE;
} }
if( i_used < 0 ) if( i_used < 0 )
...@@ -1380,6 +1387,12 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1380,6 +1387,12 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
p_sys->i_output_pts = frame->pts; 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 ) if( !id->b_enc_inited )
{ {
/* Hack because of the copy packetizer which can fail to detect the /* Hack because of the copy packetizer which can fail to detect the
...@@ -1758,7 +1771,25 @@ static int transcode_video_ffmpeg_getframebuf(struct AVCodecContext *p_context, ...@@ -1758,7 +1771,25 @@ static int transcode_video_ffmpeg_getframebuf(struct AVCodecContext *p_context,
sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_context->opaque; sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_context->opaque;
/* Set PTS */ /* 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 ); return avcodec_default_get_buffer( p_context, p_frame );
} }
...@@ -285,7 +285,8 @@ void input_DecodeBlock( decoder_t * p_dec, block_t *p_block ) ...@@ -285,7 +285,8 @@ void input_DecodeBlock( decoder_t * p_dec, block_t *p_block )
if( p_dec->p_owner->p_input->b_out_pace_control ) if( p_dec->p_owner->p_input->b_out_pace_control )
{ {
/* FIXME !!!!! */ /* FIXME !!!!! */
while( p_dec->p_owner->p_fifo->i_depth > 10 ) while( !p_dec->b_die && !p_dec->b_error &&
p_dec->p_owner->p_fifo->i_depth > 10 )
{ {
msleep( 1000 ); msleep( 1000 );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment