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" ); /* Allocate the image */ int size = *width * ( *height ) * 4; /* 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_properties_set_data( properties, "image", image_copy, image_size, mlt_pool_release, NULL ); // We're going to pass the copy on *buffer = image_copy; /* Update the frame */ mlt_properties_set_data( properties, "image", *buffer, size, mlt_pool_release, NULL ); mlt_log_debug( MLT_PRODUCER_SERVICE( &this->parent ), "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 ) { int error = 0; /* Obtain properties of frame */ mlt_properties properties = MLT_FRAME_PROPERTIES( frame ); /* Obtain the producer for this frame */ producer_ktitle self = mlt_properties_get_data( properties, "producer_kdenlivetitle", NULL ); /* Obtain properties of producer */ mlt_producer producer = &self->parent; mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer ); if ( mlt_properties_get_int( properties, "rescale_width" ) > 0 ) *width = mlt_properties_get_int( properties, "rescale_width" ); if ( mlt_properties_get_int( properties, "rescale_height" ) > 0 ) *height = mlt_properties_get_int( properties, "rescale_height" ); mlt_service_lock( MLT_PRODUCER_SERVICE( producer ) ); /* Allocate the image */ 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( self, frame, *format, *width, *height, mlt_frame_original_position( frame ), 1 ); } else { drawKdenliveTitle( self, frame, *format, *width, *height, mlt_frame_original_position( frame ), 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" ); *format = self->format; if ( self->current_image ) { // Clone the image and the alpha int image_size = mlt_image_format_size( self->format, self->current_width, self->current_height, NULL ); uint8_t *image_copy = mlt_pool_alloc( image_size ); // We use height-1 because mlt_image_format_size() uses height + 1. // XXX Remove -1 when mlt_image_format_size() is changed. memcpy( image_copy, self->current_image, mlt_image_format_size( self->format, self->current_width, self->current_height - 1, NULL ) ); // 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; // Clone the alpha channel if ( self->current_alpha ) { image_copy = mlt_pool_alloc( self->current_width * self->current_height ); memcpy( image_copy, self->current_alpha, self->current_width * self->current_height ); mlt_frame_set_alpha( frame, image_copy, self->current_width * self->current_height, mlt_pool_release ); } } else { error = 1; } mlt_service_unlock( MLT_PRODUCER_SERVICE( producer ) ); return error; }