Commit 337d8f94 authored by James Almer's avatar James Almer

data: factorize setting Dav1dDataProps to default values

parent bf659082
......@@ -47,11 +47,7 @@ uint8_t *dav1d_data_create_internal(Dav1dData *const buf, const size_t sz) {
if (!buf->ref) return NULL;
buf->data = buf->ref->const_data;
buf->sz = buf->m.size = sz;
buf->m.timestamp = INT64_MIN;
buf->m.duration = 0;
buf->m.offset = -1;
buf->m.user_data.data = NULL;
buf->m.user_data.ref = NULL;
dav1d_data_props_set_defaults(&buf->m);
return buf->ref->data;
}
......@@ -70,11 +66,7 @@ int dav1d_data_wrap_internal(Dav1dData *const buf, const uint8_t *const ptr,
if (!buf->ref) return -ENOMEM;
buf->data = ptr;
buf->sz = buf->m.size = sz;
buf->m.timestamp = INT64_MIN;
buf->m.duration = 0;
buf->m.offset = -1;
buf->m.user_data.data = NULL;
buf->m.user_data.ref = NULL;
dav1d_data_props_set_defaults(&buf->m);
return 0;
}
......@@ -132,6 +124,16 @@ void dav1d_data_props_copy(Dav1dDataProps *const dst,
if (dst->user_data.ref) dav1d_ref_inc(dst->user_data.ref);
}
void dav1d_data_props_set_defaults(Dav1dDataProps *const props) {
assert(props != NULL);
props->timestamp = INT64_MIN;
props->duration = 0;
props->offset = -1;
props->user_data.data = NULL;
props->user_data.ref = NULL;
}
void dav1d_data_unref_internal(Dav1dData *const buf) {
validate_input(buf != NULL);
......
......@@ -43,6 +43,8 @@ void dav1d_data_move_ref(Dav1dData *dst, Dav1dData *src);
*/
void dav1d_data_props_copy(Dav1dDataProps *dst, const Dav1dDataProps *src);
void dav1d_data_props_set_defaults(Dav1dDataProps *props);
uint8_t *dav1d_data_create_internal(Dav1dData *buf, size_t sz);
int dav1d_data_wrap_internal(Dav1dData *buf, const uint8_t *ptr, size_t sz,
void (*free_callback)(const uint8_t *data,
......
......@@ -118,15 +118,11 @@ static int picture_alloc_with_edges(Dav1dPicture *const p,
p->p.w = w;
p->p.h = h;
p->m.timestamp = INT64_MIN;
p->m.duration = 0;
p->m.offset = -1;
p->m.user_data.data = NULL;
p->m.user_data.ref = NULL;
p->seq_hdr = seq_hdr;
p->frame_hdr = frame_hdr;
p->p.layout = seq_hdr->layout;
p->p.bpc = bpc;
dav1d_data_props_set_defaults(&p->m);
int res = p_allocator->alloc_picture_callback(p, p_allocator->cookie);
if (res < 0) {
free(pic_ctx);
......
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