mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 17:12:36 +00:00
1568161aad
Refcounting will conceptually allocate and free images all the time when using the filter chain. Add a pool that makes these reallocations cheap. This only affects the image data, not mp_image structs and similar small allocations. Small allocations are always fast with reasonable memory managers, while large image data will trigger mmap/munmap calls each time.
23 lines
694 B
C
23 lines
694 B
C
#ifndef MPV_MP_IMAGE_POOL_H
|
|
#define MPV_MP_IMAGE_POOL_H
|
|
|
|
struct mp_image_pool {
|
|
int max_count;
|
|
|
|
struct mp_image **images;
|
|
int num_images;
|
|
struct pool_trampoline *trampoline;
|
|
};
|
|
|
|
struct mp_image_pool *mp_image_pool_new(int max_count);
|
|
struct mp_image *mp_image_pool_get(struct mp_image_pool *pool, unsigned int fmt,
|
|
int w, int h);
|
|
void mp_image_pool_clear(struct mp_image_pool *pool);
|
|
|
|
struct mp_image *mp_image_pool_new_copy(struct mp_image_pool *pool,
|
|
struct mp_image *img);
|
|
void mp_image_pool_make_writeable(struct mp_image_pool *pool,
|
|
struct mp_image *img);
|
|
|
|
#endif
|