]> git.sesse.net Git - mlt/blobdiff - src/modules/frei0r/producer_frei0r.c
Work around for vid.stab chroma skew when using 4:2:2
[mlt] / src / modules / frei0r / producer_frei0r.c
index 0f16c862d3cfc50b9e985791475138bc32114ef7..7e24be456582b3ad20bc8cba8489cdd9b693511d 100644 (file)
@@ -36,6 +36,12 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        // Obtain properties of producer
        mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
 
+       // Choose suitable out values if nothing specific requested
+       if ( *width <= 0 )
+               *width = mlt_service_profile( MLT_PRODUCER_SERVICE(producer) )->width;
+       if ( *height <= 0 )
+               *height = mlt_service_profile( MLT_PRODUCER_SERVICE(producer) )->height;
+
        // Allocate the image
        int size = *width * ( *height + 1 ) * 4;
 
@@ -43,18 +49,15 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        *buffer = mlt_pool_alloc( size );
 
        // Update the frame
-       mlt_properties_set_data( properties, "image", *buffer, size, mlt_pool_release, NULL );
-       mlt_properties_set_int( properties, "width", *width );
-       mlt_properties_set_int( properties, "height", *height );
+       mlt_frame_set_image( frame, *buffer, size, mlt_pool_release );
 
        *format = mlt_image_rgb24a;
        if ( *buffer != NULL )
        {
-               mlt_position in = mlt_producer_get_in( producer );
-               mlt_position out = mlt_producer_get_out( producer );
-               mlt_position time = mlt_frame_get_position( frame );
-               double position = ( double )( time - in ) / ( double )( out - in + 1 );
-               process_frei0r_item( producer_type, position, producer_props, frame, buffer, width, height );
+               double position = mlt_frame_get_position( frame );
+               mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( producer ) );
+               double time = position / mlt_profile_fps( profile );
+               process_frei0r_item( MLT_PRODUCER_SERVICE(producer), position, time, producer_props, frame, buffer, width, height );
        }
 
     return 0;
@@ -81,7 +84,8 @@ int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index )
 
                // Set producer-specific frame properties
                mlt_properties_set_int( properties, "progressive", 1 );
-               mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( producer_props, "aspect_ratio" ) );
+               mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( producer ) );
+               mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( profile ) );
 
                // Push the get_image method
                mlt_frame_push_get_image( *frame, producer_get_image );