]> git.sesse.net Git - mlt/commitdiff
fix hang/crash using yadif deinterlace with image producer
authorDan Dennedy <dan@dennedy.org>
Tue, 25 Sep 2012 04:02:16 +0000 (21:02 -0700)
committerDan Dennedy <dan@dennedy.org>
Tue, 25 Sep 2012 04:02:16 +0000 (21:02 -0700)
src/modules/xine/filter_deinterlace.c

index 2f3cdae28c01187da092d72333f0e33390d17fe1..8c7cf003e6cd4036ba80b878d39f309b82fa9ed0 100644 (file)
@@ -112,13 +112,22 @@ static int deinterlace_yadif( mlt_frame frame, mlt_filter filter, uint8_t **imag
        int next_height = *height;
        
        mlt_log_debug( MLT_FILTER_SERVICE(filter), "previous %d current %d next %d\n",
-               previous_frame? mlt_frame_get_position(previous_frame) : -1,
-               mlt_frame_get_position(frame),
-               next_frame?  mlt_frame_get_position(next_frame) : -1);
+               previous_frame? mlt_frame_original_position(previous_frame) : -1,
+               mlt_frame_original_position(frame),
+               next_frame?  mlt_frame_original_position(next_frame) : -1);
 
        if ( !previous_frame || !next_frame )
                return 1;
 
+       // Some producers like pixbuf want rescale_width & _height, but will not get them if you request
+       // the previous image first. So, on the first iteration, we make the previous frame the same
+       // as the current frame.
+       if ( !mlt_properties_get_int( MLT_FILTER_PROPERTIES(filter), "_notfirst" ) )
+       {
+               previous_frame = frame;
+               mlt_properties_set_int( MLT_FILTER_PROPERTIES(filter), "_notfirst", 1 );
+       }
+
        // Get the preceding frame's image
        int error = mlt_frame_get_image( previous_frame, &previous_image, format, &previous_width, &previous_height, 0 );
        int progressive = mlt_properties_get_int( MLT_FRAME_PROPERTIES( previous_frame ), "progressive" );
@@ -127,8 +136,7 @@ static int deinterlace_yadif( mlt_frame frame, mlt_filter filter, uint8_t **imag
        if ( !error && previous_image && !progressive )
        {
                // OK, now we know we have work to do and can request the image in our format
-               *format = mlt_image_yuv422;
-               error = mlt_frame_get_image( previous_frame, &previous_image, format, &previous_width, &previous_height, 0 );
+               frame->convert_image( previous_frame, &previous_image, format, mlt_image_yuv422 );
 
                // Get the current frame's image
                *format = mlt_image_yuv422;