ref: 337d8f9457a1e311643c635dbede33e5a7873a16
parent: bf659082088189bae4abe8bdccb19bbe5c74a868
author: James Almer <jamrial@gmail.com>
date: Wed Jan 23 19:40:34 EST 2019
data: factorize setting Dav1dDataProps to default values
--- a/src/data.c
+++ b/src/data.c
@@ -47,11 +47,7 @@
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 @@
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;
}
@@ -130,6 +122,16 @@
dav1d_ref_dec(&dst->user_data.ref);
*dst = *src;
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) {
--- a/src/data.h
+++ b/src/data.h
@@ -43,6 +43,8 @@
*/
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,
--- a/src/picture.c
+++ b/src/picture.c
@@ -118,15 +118,11 @@
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);