obu: ensure that the frame header reference is writable

parent a4083095
......@@ -1267,6 +1267,8 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
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;
......
......@@ -84,3 +84,7 @@ void dav1d_ref_dec(Dav1dRef **const pref) {
}
*pref = NULL;
}
int dav1d_ref_is_writable(Dav1dRef *const ref) {
return atomic_load(&ref->ref_cnt) == 1;
}
......@@ -48,4 +48,6 @@ Dav1dRef *dav1d_ref_wrap(const uint8_t *ptr,
void dav1d_ref_inc(Dav1dRef *ref);
void dav1d_ref_dec(Dav1dRef **ref);
int dav1d_ref_is_writable(Dav1dRef *ref);
#endif /* __DAV1D_SRC_REF_H__ */
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