- // Obtain properties of frame
- mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
-
- // Obtain the producer for this frame
- mlt_producer producer = mlt_properties_get_data( properties, "producer_kdenlivetitle", NULL );
-
- // Obtain properties of producer
- // save extra data
- //mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
- // Allocate the image
- int size = *width * ( *height ) * 4;
-
- *buffer = mlt_pool_alloc( size);
- // Update the frame
- mlt_properties_set_int( properties, "width", *width );
- mlt_properties_set_int( properties, "height", *height );
-
- // Update the frame
- mlt_properties_set_data( properties, "image", *buffer, size, mlt_pool_release, NULL );
-
- if ( 1 )
- {
- // Allocate the image
- *format = mlt_image_rgb24a;
- //*format = mlt_image_yuv422;
- 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 );
- refresh_kdenlivetitle(*buffer, *width, *height, position );
- mlt_log_debug( MLT_PRODUCER_SERVICE(producer), "width:%d height:%d %s\n",*width,*height, mlt_image_format_name( *format ) );
- }
- return 0;
+static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
+{
+ /* Obtain properties of frame */
+ mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
+
+ /* Obtain the producer for this frame */
+ producer_ktitle this = mlt_properties_get_data( properties, "producer_kdenlivetitle", NULL );
+
+ /* Obtain properties of producer */
+ mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( &this->parent );
+
+ *width = mlt_properties_get_int( properties, "rescale_width" );
+ *height = mlt_properties_get_int( properties, "rescale_height" );
+
+ mlt_service_lock( MLT_PRODUCER_SERVICE( &this->parent ) );
+
+ /* Allocate the image */
+ *format = mlt_image_rgb24a;
+ mlt_position time = mlt_producer_position( &this->parent ) + mlt_producer_get_in( &this->parent );
+ if ( mlt_properties_get_int( producer_props, "force_reload" ) ) {
+ if (mlt_properties_get_int( producer_props, "force_reload" ) > 1) read_xml(producer_props);
+ mlt_properties_set_int( producer_props, "force_reload", 0 );
+ drawKdenliveTitle( this, frame, *width, *height, time, 1);
+ }
+ else drawKdenliveTitle( this, frame, *width, *height, time, 0);
+
+ // Get width and height (may have changed during the refresh)
+ *width = mlt_properties_get_int( properties, "width" );
+ *height = mlt_properties_get_int( properties, "height" );
+
+ if ( this->current_image )
+ {
+ // Clone the image and the alpha
+ int image_size = this->current_width * ( this->current_height ) * 4;
+ uint8_t *image_copy = mlt_pool_alloc( image_size );
+ memcpy( image_copy, this->current_image, image_size );
+ // Now update properties so we free the copy after
+ mlt_frame_set_image( frame, image_copy, image_size, mlt_pool_release );
+ // We're going to pass the copy on
+ *buffer = image_copy;
+
+ mlt_log_debug( MLT_PRODUCER_SERVICE( &this->parent ), "width:%d height:%d %s\n", *width, *height, mlt_image_format_name( *format ) );
+ }
+
+ mlt_service_unlock( MLT_PRODUCER_SERVICE( &this->parent ) );
+
+ return 0;