]> git.sesse.net Git - mlt/commitdiff
Optimize some deinterlace filter logic.
authorDan Dennedy <dan@dennedy.org>
Mon, 9 Aug 2010 04:10:19 +0000 (21:10 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 9 Aug 2010 04:10:19 +0000 (21:10 -0700)
Prevents YADIF from fetching current frame image if previous frame image
is signalled progressive. Also, tells mlt_service to stop decorating
frame with previous and next frames when producer is determined to be
progressive or deinterlace is not requested.

src/modules/xine/filter_deinterlace.c

index c1da374e333d70b520319ac12e0be3e48b4a707d..eac2a84b59f812a621323efd42d2b9730dffc651 100644 (file)
@@ -43,7 +43,7 @@ int deinterlace_yadif( mlt_frame frame, mlt_filter filter, uint8_t **image, mlt_
        int next_height = *height;
        yadif_filter *yadif = mlt_properties_get_data( MLT_FILTER_PROPERTIES( filter ), "yadif", NULL );
        
-       mlt_log_debug( MLT_FILTER_SERVICE(filter), "previous %d current %d next %d\n", 
+       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);
@@ -53,15 +53,15 @@ int deinterlace_yadif( mlt_frame frame, mlt_filter filter, uint8_t **image, mlt_
 
        // Get the preceding frame's image
        int error = mlt_frame_get_image( previous_frame, &previous_image, format, &previous_width, &previous_height, 0 );
-       
-       if ( !error && previous_image && *format == mlt_image_yuv422 )
+
+       // Check that we aren't already progressive
+       if ( !error && previous_image  && *format == mlt_image_yuv422 &&
+                !mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "progressive" ) )
        {
                // Get the current frame's image
                error = mlt_frame_get_image( frame, image, format, width, height, 0 );
-               
-               // Check that we aren't already progressive
-               if ( !error && *image && *format == mlt_image_yuv422 &&
-                    !mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "progressive" ) ) 
+
+               if ( !error && *image && *format == mlt_image_yuv422 )
                {
                        // Get the following frame's image
                        error = mlt_frame_get_image( next_frame, &next_image, format, &next_width, &next_height, 0 );
@@ -213,15 +213,18 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                }
        }
        else
+       {
+               // Pass through
+               error = mlt_frame_get_image( this, image, format, width, height, writable );
+       }
+
+       if ( !deinterlace || progressive )
        {
                // 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 );
-
-               // Pass through
-               error = mlt_frame_get_image( this, image, format, width, height, writable );
        }
-       
+
        return error;
 }