VLC 4.0.0-dev
Loading...
Searching...
No Matches
picture_pool.c File Reference
Include dependency graph for picture_pool.c:

Data Structures

struct  picture_pool_t
 

Macros

#define POOL_MAX   256
 

Functions

static void picture_pool_Destroy (picture_pool_t *pool)
 
void picture_pool_Release (picture_pool_t *pool)
 Releases a pool created by picture_pool_New() or picture_pool_NewFromFormat().
 
static void picture_pool_ReleaseClone (picture_t *clone)
 
static picture_tpicture_pool_ClonePicture (picture_pool_t *pool, picture_t *picture)
 
static void picture_pool_AppendPic (picture_pool_t *pool, picture_t *pic)
 
static picture_pool_tpicture_pool_NewCommon (void)
 
picture_pool_tpicture_pool_New (unsigned count, picture_t *const *tab)
 Creates a pool of preallocated pictures.
 
picture_pool_tpicture_pool_NewFromFormat (const video_format_t *fmt, unsigned count)
 Allocates pictures from the heap and creates a picture pool with them.
 
static picture_tpicture_pool_GetAvailableLocked (picture_pool_t *pool)
 
picture_tpicture_pool_Get (picture_pool_t *pool)
 Obtains a picture from a pool if any is immediately available.
 
picture_tpicture_pool_Wait (picture_pool_t *pool)
 Obtains a picture from a pool.
 

Macro Definition Documentation

◆ POOL_MAX

#define POOL_MAX   256

Function Documentation

◆ picture_pool_AppendPic()

static void picture_pool_AppendPic ( picture_pool_t pool,
picture_t pic 
)
static

◆ picture_pool_ClonePicture()

◆ picture_pool_Destroy()

◆ picture_pool_Get()

picture_t * picture_pool_Get ( picture_pool_t pool)

Obtains a picture from a pool if any is immediately available.

The picture must be released with picture_Release().

Returns
a picture, or NULL if all pictures in the pool are allocated
Note
This function is thread-safe.

References picture_pool_t::available_list, picture_pool_t::lock, picture_pool_ClonePicture(), picture_pool_GetAvailableLocked(), picture_pool_t::refs, vlc_atomic_rc_get(), vlc_list_is_empty(), vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by PrerenderPicture(), SourceConverterBuffer(), and VoutVideoFilterInteractiveNewPicture().

◆ picture_pool_GetAvailableLocked()

◆ picture_pool_New()

picture_pool_t * picture_pool_New ( unsigned  count,
picture_t *const *  tab 
)

Creates a pool of preallocated pictures.

Free pictures can be allocated from the pool, and are returned to the pool when they are no longer referenced.

This avoids allocating and deallocationg pictures repeatedly, and ensures that memory consumption remains within limits.

To obtain a picture from the pool, use picture_pool_Get(). To increase and decrease the reference count, use picture_Hold() and picture_Release() respectively.

Parameters
countnumber of pictures in the array
tabarray of pictures
Returns
a pointer to the new pool on success, or NULL on error (pictures are not released on error)

References count, picture_pool_AppendPic(), picture_pool_NewCommon(), POOL_MAX, and unlikely.

◆ picture_pool_NewCommon()

◆ picture_pool_NewFromFormat()

picture_pool_t * picture_pool_NewFromFormat ( const video_format_t fmt,
unsigned  count 
)

Allocates pictures from the heap and creates a picture pool with them.

This is a convenience wrapper for picture_NewFromFormat() and picture_pool_New().

Parameters
fmtvideo format of pictures to allocate from the heap
countnumber of pictures to allocate
Returns
a pointer to the new pool on success, NULL on error

References count, picture_NewFromFormat(), picture_pool_AppendPic(), picture_pool_NewCommon(), picture_pool_Release(), POOL_MAX, unlikely, and vlc_assert_unreachable.

Referenced by ChangeFilters(), ModuleThread_UpdateVideoFormat(), vout_Start(), and VoutSetupConverter().

◆ picture_pool_Release()

void picture_pool_Release ( picture_pool_t pool)

Releases a pool created by picture_pool_New() or picture_pool_NewFromFormat().

Note
If there are no pending references to the pooled pictures, and the picture_resource_t.pf_destroy callback was not NULL, it will be invoked. Otherwise the default callback will be used.
Warning
If there are pending references (a.k.a. late pictures), the pictures will remain valid until the all pending references are dropped by picture_Release().

References picture_pool_t::available_list, picture_pool_t::inuse_list, list, picture_pool_t::lock, picture_priv_t::picture, picture_pool_Destroy(), picture_Release(), picture_priv_t::pool, picture_priv_t::pool_node, picture_pool_t::released, vlc_list_foreach, vlc_list_remove(), vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by ChangeFilters(), CreateVoutIfNeeded(), DeleteDecoder(), picture_pool_NewFromFormat(), vout_ReleaseDisplay(), vout_Start(), VoutConverterRelease(), and VoutSetupConverter().

◆ picture_pool_ReleaseClone()

◆ picture_pool_Wait()

picture_t * picture_pool_Wait ( picture_pool_t pool)

Obtains a picture from a pool.

The picture must be released with picture_Release().

Returns
a picture or NULL on memory error
Note
This function is thread-safe.

References picture_pool_t::available_list, picture_pool_t::lock, picture_pool_ClonePicture(), picture_pool_GetAvailableLocked(), picture_pool_t::refs, vlc_atomic_rc_get(), vlc_cond_wait(), vlc_list_is_empty(), vlc_mutex_lock(), vlc_mutex_unlock(), and picture_pool_t::wait.

Referenced by ModuleThread_NewVideoBuffer().