mirror of
https://github.com/mpv-player/mpv
synced 2024-12-22 14:52:43 +00:00
mp_image_pool: add mp_image_pool_add
Provide a way for the user to add mp_images to the pool. This is required for dxva2, for which using set_allocator is extremely awkward since all the d3d9 surfaces must be allocated in advance and all together.
This commit is contained in:
parent
cd0a34feb3
commit
01743f4ecd
@ -164,6 +164,14 @@ struct mp_image *mp_image_pool_get_no_alloc(struct mp_image_pool *pool, int fmt,
|
||||
return ref;
|
||||
}
|
||||
|
||||
void mp_image_pool_add(struct mp_image_pool *pool, struct mp_image *new)
|
||||
{
|
||||
struct image_flags *it = talloc_ptrtype(new, it);
|
||||
*it = (struct image_flags) { .pool_alive = true };
|
||||
new->priv = it;
|
||||
MP_TARRAY_APPEND(pool, pool->images, pool->num_images, new);
|
||||
}
|
||||
|
||||
// Return a new image of given format/size. The only difference to
|
||||
// mp_image_alloc() is that there is a transparent mechanism to recycle image
|
||||
// data allocations through this pool.
|
||||
@ -186,10 +194,7 @@ struct mp_image *mp_image_pool_get(struct mp_image_pool *pool, int fmt,
|
||||
}
|
||||
if (!new)
|
||||
return NULL;
|
||||
struct image_flags *it = talloc_ptrtype(new, it);
|
||||
*it = (struct image_flags) { .pool_alive = true };
|
||||
new->priv = it;
|
||||
MP_TARRAY_APPEND(pool, pool->images, pool->num_images, new);
|
||||
mp_image_pool_add(pool, new);
|
||||
new = mp_image_pool_get_no_alloc(pool, fmt, w, h);
|
||||
}
|
||||
return new;
|
||||
|
@ -8,6 +8,8 @@ struct mp_image_pool;
|
||||
struct mp_image_pool *mp_image_pool_new(int max_count);
|
||||
struct mp_image *mp_image_pool_get(struct mp_image_pool *pool, int fmt,
|
||||
int w, int h);
|
||||
// the reference to "new" is transferred to the pool
|
||||
void mp_image_pool_add(struct mp_image_pool *pool, struct mp_image *new);
|
||||
void mp_image_pool_clear(struct mp_image_pool *pool);
|
||||
|
||||
void mp_image_pool_set_lru(struct mp_image_pool *pool);
|
||||
|
Loading…
Reference in New Issue
Block a user