]> git.sesse.net Git - vlc/commitdiff
* src/input/input_dec.c: fix for input_EndDecoder() when using the async mode.
authorGildas Bazin <gbazin@videolan.org>
Sat, 6 Mar 2004 19:30:19 +0000 (19:30 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sat, 6 Mar 2004 19:30:19 +0000 (19:30 +0000)
* 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).

modules/packetizer/copy.c
modules/stream_out/transcode.c
src/input/input_dec.c

index 7e7108de3e5829d22db58a9e6f0f8b6c51964f23..87537475d66729919b2e3b0e04626c0607a25ee2 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -261,18 +261,14 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block )
     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;
     }
@@ -285,4 +281,3 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block )
 
     return p_ret;
 }
-
index 9238e0bdeb45cc6e67a1cae4cb6ca89e0644f9f7..d817b5f5840e82e8e80997a4d715e942f62f9b55 100644 (file)
@@ -136,7 +136,10 @@ struct sout_stream_sys_t
     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;
 };
 
@@ -167,6 +170,7 @@ static int Open( vlc_object_t *p_this )
     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" ) ) )
     {
@@ -1330,7 +1334,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
 
     i_data = in->i_size;
     p_data = in->p_buffer;
+
     for( ;; )
     {
         block_t *p_block;
@@ -1340,6 +1344,7 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
         /* 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,
@@ -1358,6 +1363,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
             /* 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 )
@@ -1380,6 +1387,12 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
             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
@@ -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;
 
     /* 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 );
 }
index ed46ec9999e8b2d88eb7e720105dead16f3247d9..c09c4a8bb8b2622cb8bd1db6c9c49707133bf417 100644 (file)
@@ -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 )
         {
             /* 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 );
             }