]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/transcode.c
* modules/mux/ogg.c, modules/stream_out/transcode.c: better fix for the starting...
[vlc] / modules / stream_out / transcode.c
index 54c188f169d9af3e640a4cc9b741d798d96f0d48..53bb67bcdcc1a9432c89fe02b3f9c3379646e69e 100644 (file)
@@ -2,7 +2,7 @@
  * transcode.c
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: transcode.c,v 1.37 2003/10/09 09:39:16 gbazin Exp $
+ * $Id: transcode.c,v 1.41 2003/10/09 19:31:38 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -1004,7 +1004,7 @@ static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream,
                     p_out->i_size = header[i].bytes;
                     p_out->i_length = 0;
 
-                    p_out->i_dts = p_out->i_pts = 0;
+                    p_out->i_dts = p_out->i_pts = id->i_dts;
 
                     sout_BufferChain( out, p_out );
                 }
@@ -1223,7 +1223,7 @@ static int transcode_video_ffmpeg_new( sout_stream_t *p_stream,
 
 
     /* find encoder */
-    id->ff_enc = NULL;
+    id->ff_enc = id->ff_enc_c = NULL;
     i_ff_codec = get_ff_codec( id->f_dst.i_fourcc );
     if( i_ff_codec != 0 )
     {
@@ -1361,7 +1361,7 @@ static void transcode_video_ffmpeg_close ( sout_stream_t *p_stream, sout_stream_
     if( id->p_encoder )
     {
         /* External encoding */
-        module_Unneed( p_stream, id->p_encoder->p_module );
+        module_Unneed( id->p_encoder, id->p_encoder->p_module );
         vlc_object_destroy( id->p_encoder->p_module );
     }
     else if( id->b_enc_inited )
@@ -1395,7 +1395,7 @@ static void transcode_video_ffmpeg_close ( sout_stream_t *p_stream, sout_stream_
     }
 
     free( id->ff_dec_c );
-    free( id->ff_enc_c );
+    if( id->ff_enc_c ) free( id->ff_enc_c );
     free( id->p_buffer );
 }
 
@@ -1496,6 +1496,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
                 sout_buffer_t *p_out;
                 p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
                 memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
+                p_out->i_dts = id->i_dts;
+                p_out->i_pts = id->i_dts;
                 sout_BufferChain( out, p_out );
             }
 
@@ -1600,7 +1602,6 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
         }
 
         /* convert size and crop */
-        if( !id->p_encoder )
         if( id->ff_dec_c->width  != id->f_dst.i_width ||
             id->ff_dec_c->height != id->f_dst.i_height ||
             p_sys->i_crop_top > 0 || p_sys->i_crop_bottom > 0 ||
@@ -1638,7 +1639,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
         }
 
         /* Set the pts of the frame being encoded (segfaults with mpeg4!)*/
-        if( id->f_dst.i_fourcc == VLC_FOURCC( 'm', 'p', 'g', 'v' ) )
+        if( id->p_encoder ||
+            id->f_dst.i_fourcc == VLC_FOURCC( 'm', 'p', 'g', 'v' ) )
             frame->pts = p_sys->i_output_pts;
         else
             frame->pts = 0;
@@ -1676,6 +1678,8 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
                 sout_buffer_t *p_out;
                 p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
                 memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
+                p_out->i_dts = p_block->i_dts;
+                p_out->i_pts = p_block->i_pts;
                 sout_BufferChain( out, p_out );
                 block_Release( p_block );
             }