]> git.sesse.net Git - mlt/commitdiff
fix yadif deinterlacer on streams with progressive & interlace
authorDan Dennedy <dan@dennedy.org>
Tue, 25 Sep 2012 04:20:37 +0000 (21:20 -0700)
committerDan Dennedy <dan@dennedy.org>
Tue, 25 Sep 2012 04:20:37 +0000 (21:20 -0700)
src/modules/xine/filter_deinterlace.c

index 8c7cf003e6cd4036ba80b878d39f309b82fa9ed0..caa21afda019b86512e1c4d991a683ac8d68a054 100644 (file)
@@ -239,23 +239,33 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                }
                if ( error || ( method > DEINTERLACE_NONE && method < DEINTERLACE_YADIF ) )
                {
-                       // Signal that we no longer need previous and next frames
                        mlt_service service = mlt_properties_get_data( MLT_FILTER_PROPERTIES(filter), "service", NULL );
-                       mlt_properties_set_int( MLT_SERVICE_PROPERTIES(service), "_need_previous_next", 0 );
-                       
+
+                       // Get the current frame's image
+                       int error2 = mlt_frame_get_image( frame, image, format, width, height, writable );
+                       progressive = mlt_properties_get_int( properties, "progressive" );
+
                        if ( error )
+                       {
                                method = DEINTERLACE_ONEFIELD;
+                               // If YADIF requested, prev/next cancelled because some previous frames were progressive,
+                               // but new frames are interlaced, then turn prev/next frames back on.
+                               if ( !progressive )
+                                       mlt_properties_set_int( MLT_SERVICE_PROPERTIES(service), "_need_previous_next", 1 );
+                       }
+                       else
+                       {
+                               // Signal that we no longer need previous and next frames
+                               mlt_properties_set_int( MLT_SERVICE_PROPERTIES(service), "_need_previous_next", 0 );
+                       }
                        
-                       // Get the current frame's image
-                       error = mlt_frame_get_image( frame, image, format, width, height, writable );
-                       progressive = mlt_properties_get_int( properties, "progressive" );
-                       if ( !error && !progressive )
+                       if ( !error2 && !progressive )
                        {
                                // OK, now we know we have work to do and can request the image in our format
-                               error = frame->convert_image( frame, image, format, mlt_image_yuv422 );
+                               error2 = frame->convert_image( frame, image, format, mlt_image_yuv422 );
 
                                // Check that we aren't already progressive
-                               if ( !error && *image && *format == mlt_image_yuv422 )
+                               if ( !error2 && *image && *format == mlt_image_yuv422 )
                                {
                                        // Deinterlace the image using one of the Xine deinterlacers
                                        int image_size = *width * *height * 2;