From b28788c0275e150b17c209effb5d4dee34bfb5ef Mon Sep 17 00:00:00 2001 From: Michael Bradshaw Date: Wed, 21 Nov 2018 19:27:19 -0800 Subject: Modify release_picture_callback to take a picture instead of a data pointer --- include/dav1d/picture.h | 10 +++------- src/picture.c | 20 +++++++------------- src/picture.h | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/include/dav1d/picture.h b/include/dav1d/picture.h index e9d6541..f8e1025 100644 --- a/include/dav1d/picture.h +++ b/include/dav1d/picture.h @@ -192,14 +192,10 @@ typedef struct Dav1dPicAllocator { /** * Release the picture buffer. * - * @param buf The buffer that was returned by - * alloc_picture_callback(). - * @param allocator_tag The Dav1dPicture.allocator_data that was filled by - * alloc_picture_callback() - * @param cookie Custom pointer passed to all calls. + * @param pic The picture that was filled by alloc_picture_callback(). + * @param cookie Custom pointer passed to all calls. */ - void (*release_picture_callback)(uint8_t *buf, void *allocator_data, - void *cookie); + void (*release_picture_callback)(Dav1dPicture *pic, void *cookie); } Dav1dPicAllocator; /** diff --git a/src/picture.c b/src/picture.c index 2e48e8a..57935e2 100644 --- a/src/picture.c +++ b/src/picture.c @@ -74,28 +74,24 @@ int default_picture_allocator(Dav1dPicture *const p, void *cookie) { return 0; } -void default_picture_release(uint8_t *const data, void *const allocator_data, - void *cookie) -{ +void default_picture_release(Dav1dPicture *const p, void *cookie) { assert(cookie == NULL); #ifndef NDEBUG /* safety check */ - assert(allocator_data == data); + assert(p->allocator_data == p->data[0]); #endif - dav1d_free_aligned(data); + dav1d_free_aligned(p->data[0]); } struct pic_ctx_context { Dav1dPicAllocator allocator; - void *allocator_data; - uint8_t *data; + Dav1dPicture pic; void *extra_ptr; /* MUST BE AT THE END */ }; static void free_buffer(const uint8_t *const data, void *const user_data) { struct pic_ctx_context *pic_ctx = user_data; - pic_ctx->allocator.release_picture_callback(pic_ctx->data, - pic_ctx->allocator_data, + pic_ctx->allocator.release_picture_callback(&pic_ctx->pic, pic_ctx->allocator.cookie); free(pic_ctx); } @@ -134,12 +130,10 @@ static int picture_alloc_with_edges(Dav1dPicture *const p, } pic_ctx->allocator = *p_allocator; - pic_ctx->allocator_data = p->allocator_data; - pic_ctx->data = p->data[0]; + pic_ctx->pic = *p; if (!(p->ref = dav1d_ref_wrap(p->data[0], free_buffer, pic_ctx))) { - p_allocator->release_picture_callback(p->data[0], p->allocator_data, - p_allocator->cookie); + p_allocator->release_picture_callback(p, p_allocator->cookie); fprintf(stderr, "Failed to wrap picture: %s\n", strerror(errno)); return -ENOMEM; } diff --git a/src/picture.h b/src/picture.h index 12f1f97..3f86124 100644 --- a/src/picture.h +++ b/src/picture.h @@ -108,6 +108,6 @@ void dav1d_thread_picture_signal(const Dav1dThreadPicture *p, int y, enum PlaneType plane_type); int default_picture_allocator(Dav1dPicture *, void *cookie); -void default_picture_release(uint8_t *, void *allocator_data, void *cookie); +void default_picture_release(Dav1dPicture *, void *cookie); #endif /* __DAV1D_SRC_PICTURE_H__ */ -- cgit v1.2.3