shithub: dav1d

Download patch

ref: aaba9f8e770eefd4daede06bf01bf80c04a4f9b3
parent: eb37d5cc534ed805701b315a35e5ed07f281232c
author: James Almer <jamrial@gmail.com>
date: Mon Jan 7 14:39:46 EST 2019

data: add dav1d_data_ref()

Makes both picture and data modules more consistent API wise, and
does a few extra validation checks for the input arguments.

--- a/src/data.c
+++ b/src/data.c
@@ -95,6 +95,20 @@
     return 0;
 }
 
+
+void dav1d_data_ref(Dav1dData *const dst, const Dav1dData *const src) {
+    validate_input(dst != NULL);
+    validate_input(dst->data == NULL);
+    validate_input(src != NULL);
+
+    if (src->ref) {
+        validate_input(src->data != NULL);
+        dav1d_ref_inc(src->ref);
+    }
+    if (src->m.user_data.ref) dav1d_ref_inc(src->m.user_data.ref);
+    *dst = *src;
+}
+
 void dav1d_data_move_ref(Dav1dData *const dst, Dav1dData *const src) {
     validate_input(dst != NULL);
     validate_input(dst->data == NULL);
--- a/src/data.h
+++ b/src/data.h
@@ -30,6 +30,8 @@
 
 #include "dav1d/data.h"
 
+void dav1d_data_ref(Dav1dData *dst, const Dav1dData *src);
+
 /**
  * Move a data reference.
  */
--- a/src/obu.c
+++ b/src/obu.c
@@ -1323,10 +1323,8 @@
         const unsigned bit_pos = dav1d_get_bits_pos(&gb);
         assert((bit_pos & 7) == 0);
         assert(pkt_bytelen >= (bit_pos >> 3));
-        dav1d_ref_inc(in->ref);
-        c->tile[c->n_tile_data].data.ref = in->ref;
-        dav1d_data_props_copy(&c->tile[c->n_tile_data].data.m, &in->m);
-        c->tile[c->n_tile_data].data.data = in->data + (bit_pos >> 3);
+        dav1d_data_ref(&c->tile[c->n_tile_data].data, in);
+        c->tile[c->n_tile_data].data.data += bit_pos >> 3;
         c->tile[c->n_tile_data].data.sz = pkt_bytelen - (bit_pos >> 3);
         // ensure tile groups are in order and sane, see 6.10.1
         if (c->tile[c->n_tile_data].start > c->tile[c->n_tile_data].end ||