int next_width = *width;
int next_height = *height;
- mlt_log_debug( MLT_FILTER_SERVICE(filter), "previous %d current %d next %d\n",
+ mlt_log_debug( MLT_FILTER_SERVICE(filter), "previous " MLT_POSITION_FMT " current " MLT_POSITION_FMT " next " MLT_POSITION_FMT "\n",
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" );
// At this point - before image was requested - (progressive == 0) cannot be trusted because
// some producers (avformat) do not yet know.
- if ( deinterlace )
+ if ( deinterlace && !mlt_properties_get_int( properties, "test_image" ) )
{
// Determine deinterlace method
char *method_str = mlt_properties_get( MLT_FILTER_PROPERTIES( filter ), "method" );
else if ( strcmp( method_str, "greedy" ) == 0 )
method = DEINTERLACE_GREEDY;
+ // 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 use linearblend.
+ if ( ( method == DEINTERLACE_YADIF || method == DEINTERLACE_YADIF_NOSPATIAL ) &&
+ !mlt_properties_get_int( MLT_FILTER_PROPERTIES(filter), "_notfirst" ) )
+ {
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES(filter), "_notfirst", 1 );
+ method = DEINTERLACE_LINEARBLEND;
+ error = 1;
+ }
+
if ( method == DEINTERLACE_YADIF )
{
error = deinterlace_yadif( frame, filter, image, format, width, height, YADIF_MODE_TEMPORAL_SPATIAL );
}
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 );
-
- if ( error )
- method = DEINTERLACE_ONEFIELD;
-
+
// Get the current frame's image
- error = mlt_frame_get_image( frame, image, format, width, height, writable );
+ int error2 = mlt_frame_get_image( frame, image, format, width, height, writable );
progressive = mlt_properties_get_int( properties, "progressive" );
+
+ if ( error )
+ {
+ method = DEINTERLACE_LINEARBLEND;
+ // 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 );
+ }
+ error = error2;
+
if ( !error && !progressive )
{
// OK, now we know we have work to do and can request the image in our format