]> git.sesse.net Git - mlt/blobdiff - src/modules/core/producer_consumer.c
Refactor to use mlt_frame_set_image/_alpha.
[mlt] / src / modules / core / producer_consumer.c
index 7cfd7e4a028c28841e1a96e9f214e0ec5003eeb2..22bb23220aa8d47c6be1479c2c1257d12e15b817 100644 (file)
@@ -52,10 +52,19 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format
 
        // Update the frame
        mlt_properties properties = mlt_frame_properties( frame );
-       mlt_properties_set_data( properties, "image", new_image, size, mlt_pool_release, NULL );
+       mlt_frame_set_image( frame, new_image, size, mlt_pool_release );
        memcpy( new_image, *image, size );
        mlt_properties_set( properties, "progressive", mlt_properties_get( MLT_FRAME_PROPERTIES(nested_frame), "progressive" ) );
        *image = new_image;
+       
+       // Copy the alpha channel
+       uint8_t *alpha = mlt_properties_get_data( MLT_FRAME_PROPERTIES( nested_frame ), "alpha", &size );
+       if ( alpha && size > 0 )
+       {
+               new_image = mlt_pool_alloc( size );
+               memcpy( new_image, alpha, size );
+               mlt_frame_set_alpha( frame, new_image, size, mlt_pool_release );
+       }
 
        return result;
 }
@@ -150,7 +159,9 @@ static int get_frame( mlt_producer this, mlt_frame_ptr frame, int index )
 
                // Seek the producer to the correct place
                // Calculate our positions
-               double actual_position = mlt_producer_get_speed( this ) * (double)mlt_producer_position( this );
+               double actual_position = (double)mlt_producer_position( this );
+               if ( mlt_producer_get_speed( this ) != 0 )
+                       actual_position *= mlt_producer_get_speed( this );
                mlt_position need_first = floor( actual_position );
                mlt_producer_seek( cx->producer, need_first );
                
@@ -207,7 +218,7 @@ static void producer_close( mlt_producer this )
 
 mlt_producer producer_consumer_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
 {
-       mlt_producer this = mlt_producer_new( );
+       mlt_producer this = mlt_producer_new( profile );
 
        // Encapsulate the real producer
        mlt_profile temp_profile = mlt_profile_init( NULL );