shithub: dav1d

Download patch

ref: b28788c0275e150b17c209effb5d4dee34bfb5ef
parent: 27860ee5c4a2976f6818ee2b95c34fe5b8bbf42e
author: Michael Bradshaw <mjbshaw@google.com>
date: Wed Nov 21 14:27:19 EST 2018

Modify release_picture_callback to take a picture instead of a data pointer

--- a/include/dav1d/picture.h
+++ b/include/dav1d/picture.h
@@ -192,14 +192,10 @@
     /**
      * 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;
 
 /**
--- a/src/picture.c
+++ b/src/picture.c
@@ -74,20 +74,17 @@
     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 */
 };
 
@@ -94,8 +91,7 @@
 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 @@
     }
 
     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;
     }
--- a/src/picture.h
+++ b/src/picture.h
@@ -108,6 +108,6 @@
                                  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__ */