From 0ce3dce03aaea3e777ebf68504d5afb3f5e3f9e1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 23 Jul 2017 09:27:51 +0200 Subject: mp_image_pool: disallow adding read only frames Remove the feature of adding read-only frames to mp_image_pool_add(). This makes no sense, because an image pool is an allocator, and must always return writable images. Also check these assumptions earlier. --- video/mp_image_pool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'video') diff --git a/video/mp_image_pool.c b/video/mp_image_pool.c index 9a848af925..547e626468 100644 --- a/video/mp_image_pool.c +++ b/video/mp_image_pool.c @@ -152,9 +152,9 @@ struct mp_image *mp_image_pool_get_no_alloc(struct mp_image_pool *pool, int fmt, // This assumes the buffer is at this point exclusively owned by us: we // can't track whether the buffer is unique otherwise. // (av_buffer_is_writable() checks the refcount of the new buffer only.) - int flags = av_buffer_is_writable(new->bufs[0]) ? 0 : AV_BUFFER_FLAG_READONLY; + assert(av_buffer_is_writable(new->bufs[0])); ref->bufs[0] = av_buffer_create(new->bufs[0]->data, new->bufs[0]->size, - unref_image, new, flags); + unref_image, new, 0); if (!ref->bufs[0]) { talloc_free(ref); return NULL; @@ -169,6 +169,10 @@ struct mp_image *mp_image_pool_get_no_alloc(struct mp_image_pool *pool, int fmt, void mp_image_pool_add(struct mp_image_pool *pool, struct mp_image *new) { + assert(new->bufs[0]); + assert(!new->bufs[1]); + assert(mp_image_is_writeable(new)); + struct image_flags *it = talloc_ptrtype(new, it); *it = (struct image_flags) { .pool_alive = true }; new->priv = it; -- cgit v1.2.3