ref: d4ddfdf519280fd0f35c897f56c1fb25fdc239a4
parent: a408309589e909f759d7ecc7adf86d939fd2fc9f
author: James Almer <[email protected]>
date: Wed Nov 28 12:57:09 EST 2018
obu: ensure that the frame header reference is writable
--- a/src/obu.c
+++ b/src/obu.c
@@ -1267,6 +1267,8 @@
c->frame_hdr_ref = dav1d_ref_create(sizeof(Dav1dFrameHeader));
if (!c->frame_hdr_ref) return -ENOMEM;
}
+ // ensure that the reference is writable
+ assert(dav1d_ref_is_writable(c->frame_hdr_ref));
c->frame_hdr = c->frame_hdr_ref->data;
memset(c->frame_hdr, 0, sizeof(*c->frame_hdr));
c->frame_hdr->temporal_id = temporal_id;
--- a/src/ref.c
+++ b/src/ref.c
@@ -84,3 +84,7 @@
}
*pref = NULL;
}
+
+int dav1d_ref_is_writable(Dav1dRef *const ref) {
+ return atomic_load(&ref->ref_cnt) == 1;
+}
--- a/src/ref.h
+++ b/src/ref.h
@@ -48,4 +48,6 @@
void dav1d_ref_inc(Dav1dRef *ref);
void dav1d_ref_dec(Dav1dRef **ref);
+int dav1d_ref_is_writable(Dav1dRef *ref);
+
#endif /* __DAV1D_SRC_REF_H__ */