- mlt_frame_get_image( this, image, format, width, height, 1 );
- deinterlace_yuv( *image, *image, *width * 2, *height );
- mlt_properties_set_int( mlt_frame_properties( this ), "progressive", 1 );
- return 0;
+ // Get the input image
+ int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+
+ // Only continue if we have no error and the right colour space
+ if ( error == 0 && *format == mlt_image_yuv422 )
+ {
+ // Check that we want progressive and we aren't already progressive
+ if ( !mlt_properties_get_int( mlt_frame_properties( this ), "progressive" ) &&
+ mlt_properties_get_int( mlt_frame_properties( this ), "consumer_progressive" ) )
+ {
+ // Deinterlace the image
+ deinterlace_yuv( *image, *image, *width * 2, *height );
+
+ // Make sure that others know the frame is deinterlaced
+ mlt_properties_set_int( mlt_frame_properties( this ), "progressive", 1 );
+ }
+ }
+
+ return error;