Commit aaba9f8e authored by James Almer's avatar James Almer

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.
parent eb37d5cc
Pipeline #3859 passed with stages
in 5 minutes and 10 seconds
......@@ -95,6 +95,20 @@ int dav1d_data_wrap_user_data_internal(Dav1dData *const buf,
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);
......
......@@ -30,6 +30,8 @@
#include "dav1d/data.h"
void dav1d_data_ref(Dav1dData *dst, const Dav1dData *src);
/**
* Move a data reference.
*/
......
......@@ -1323,10 +1323,8 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
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 ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment