int max_frequency;
unsigned int invalid_pts_counter;
double resample_factor;
+ mlt_cache image_cache;
#ifdef VDPAU
struct
{
// Get the producer properties
mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
+ // Get the image cache
+ if ( ! this->image_cache )
+ this->image_cache = mlt_cache_init();
+ mlt_cache_item item = mlt_cache_get( this->image_cache, (void*) position );
+ *buffer = mlt_cache_item_data( item, NULL );
+ if ( *buffer )
+ {
+ // Cache hit
+ mlt_properties_set_data( frame_properties, "avformat.image_cache", item, 0, ( mlt_destructor )mlt_cache_item_close, NULL );
+ mlt_properties_set_data( frame_properties, "image", *buffer, 0, NULL, NULL );
+ goto exit_get_image;
+ }
+ // Cache miss
+ int image_size = 0;
+
avformat_lock();
// Fetch the video format context
|| ( !use_new_seek && this->current_position > req_position ) ) )
{
// Duplicate it
- if ( allocate_buffer( frame_properties, codec_context, buffer, format, width, height ) )
+ if ( ( image_size = allocate_buffer( frame_properties, codec_context, buffer, format, width, height ) ) )
#ifdef VDPAU
if ( this->vdpau && this->vdpau->buffer )
{
// Now handle the picture if we have one
if ( got_picture )
{
- if ( allocate_buffer( frame_properties, codec_context, buffer, format, width, height ) )
+ if ( ( image_size = allocate_buffer( frame_properties, codec_context, buffer, format, width, height ) ) )
{
#ifdef VDPAU
if ( this->vdpau )
avformat_unlock();
+ if ( this->got_picture && image_size > 0 )
+ {
+ // Copy buffer to image cache
+ uint8_t *image = mlt_pool_alloc( image_size );
+ memcpy( image, *buffer, image_size );
+ mlt_cache_put( this->image_cache, (void*) position, image, image_size, mlt_pool_release );
+ }
+
+exit_get_image:
// Set the progressive flag
mlt_properties_set_int( frame_properties, "progressive",
!this->av_frame->interlaced_frame || !!mlt_properties_get_int( properties, "force_progressive" ) );
#ifdef VDPAU
vdpau_producer_close( this );
#endif
+ if ( this->image_cache )
+ mlt_cache_close( this->image_cache );
free( this );
}