summaryrefslogtreecommitdiffstats
path: root/video/mp_image_pool.c
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2016-02-15 16:04:52 -0800
committerKevin Mitchell <kevmitch@gmail.com>2016-02-16 12:36:50 -0800
commit01743f4ecd42b2974072d31604c2e91941488dd8 (patch)
tree056a317b7ca394998c3c58faa2373795568501d7 /video/mp_image_pool.c
parentcd0a34feb3675ae3867ae57177000c70e144e721 (diff)
downloadmpv-01743f4ecd42b2974072d31604c2e91941488dd8.tar.bz2
mpv-01743f4ecd42b2974072d31604c2e91941488dd8.tar.xz
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/mp_image_pool.c')
-rw-r--r--video/mp_image_pool.c13
1 files changed, 9 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;