From 01743f4ecd42b2974072d31604c2e91941488dd8 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Mon, 15 Feb 2016 16:04:52 -0800 Subject: 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. --- video/mp_image_pool.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'video/mp_image_pool.c') diff --git a/video/mp_image_pool.c b/video/mp_image_pool.c index 3c56f8931f..10966eeefc 100644 --- a/video/mp_image_pool.c +++ b/video/mp_image_pool.c @@ -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; -- cgit v1.2.3