[vlc-devel] [PATCH] Fix crash when scaling up with threads >= 1

David Menestrina dmenest-vlc at ofb.net
Mon May 3 22:55:05 CEST 2010


The code was creating new images based on the decoder output format
and then passing them to the encoder input without transforming them.
These new images were only duplicates, so now we call a new
duplicate_picture function which makes a copy of a picture with the
same format as the original.
---
 modules/stream_out/transcode/video.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/stream_out/transcode/video.c
b/modules/stream_out/transcode/video.c
index 5bcc08a..bd32a8a 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -99,6 +99,14 @@ static picture_t *video_new_buffer_decoder(
decoder_t *p_dec )
     return picture_NewFromFormat( &p_dec->fmt_out.video );
 }

+static picture_t *duplicate_picture( picture_t *p_pic )
+{
+    picture_t *dup = picture_NewFromFormat( &p_pic->format );
+    if ( dup )
+        picture_Copy( dup, p_pic );
+    return dup;
+}
+
 static picture_t *transcode_video_filter_buffer_new( filter_t *p_filter )
 {
     p_filter->fmt_out.video.i_chroma = p_filter->fmt_out.i_codec;
@@ -680,10 +688,9 @@ int transcode_video_process( sout_stream_t
*p_stream, sout_stream_id_t *id,
             if( picture_IsReferenced( p_pic ) &&
!filter_chain_GetLength( id->p_f_chain ) )
             {
                 /* We can't modify the picture, we need to duplicate it */
-                picture_t *p_tmp = video_new_buffer_decoder( id->p_decoder );
+                picture_t *p_tmp = duplicate_picture( p_pic );
                 if( p_tmp )
                 {
-                    picture_Copy( p_tmp, p_pic );
                     picture_Release( p_pic );
                     p_pic = p_tmp;
                 }
@@ -742,10 +749,9 @@ int transcode_video_process( sout_stream_t
*p_stream, sout_stream_id_t *id,
             if( p_sys->i_threads >= 1 )
             {
                 /* We can't modify the picture, we need to duplicate it */
-                p_pic2 = video_new_buffer_decoder( id->p_decoder );
+                p_pic2 = duplicate_picture( p_pic );
                 if( p_pic2 != NULL )
                 {
-                    picture_Copy( p_pic2, p_pic );
                     p_pic2->date = i_pts;
                 }
             }
--
1.6.0.4



More information about the vlc-devel mailing list