diff options
author | 2016-02-15 16:04:52 -0800 | |
---|---|---|
committer | 2016-02-16 12:36:50 -0800 | |
commit | 01743f4ecd42b2974072d31604c2e91941488dd8 (patch) | |
tree | 056a317b7ca394998c3c58faa2373795568501d7 /video | |
parent | cd0a34feb3675ae3867ae57177000c70e144e721 (diff) |
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.
Diffstat (limited to 'video')
-rw-r--r-- | video/mp_image_pool.c | 13 | ||||
-rw-r--r-- | video/mp_image_pool.h | 2 |
2 files changed, 11 insertions, 4 deletions
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; diff --git a/video/mp_image_pool.h b/video/mp_image_pool.h index c2307da887..32beb89d9b 100644 --- a/video/mp_image_pool.h +++ b/video/mp_image_pool.h @@ -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); |