ref: 48a7486ae52d7427577fb44856fe6377b7d724f7
parent: 2044016e6a3d8daed4566921e8b177f6bfd68811
author: James Almer <jamrial@gmail.com>
date: Tue Nov 6 17:59:33 EST 2018
picture: add dav1d_picture_move_ref()
--- a/src/lib.c
+++ b/src/lib.c
@@ -206,15 +206,13 @@
in->data += res;
if (!in->sz) dav1d_data_unref(in);
if (c->out.data[0]) {
- dav1d_picture_ref(out, &c->out);
- dav1d_picture_unref(&c->out);
+ dav1d_picture_move_ref(out, &c->out);
return 0;
}
}
if (c->out.data[0]) {
- dav1d_picture_ref(out, &c->out);
- dav1d_picture_unref(&c->out);
+ dav1d_picture_move_ref(out, &c->out);
return 0;
}
--- a/src/picture.c
+++ b/src/picture.c
@@ -185,6 +185,18 @@
*dst = *src;
}
+void dav1d_picture_move_ref(Dav1dPicture *const dst, Dav1dPicture *const src) {
+ validate_input(dst != NULL);
+ validate_input(dst->data[0] == NULL);
+ validate_input(src != NULL);
+
+ if (src->ref)
+ validate_input(src->data[0] != NULL);
+
+ *dst = *src;
+ memset(src, 0, sizeof(*src));
+}
+
void dav1d_thread_picture_ref(Dav1dThreadPicture *dst,
const Dav1dThreadPicture *src)
{
--- a/src/picture.h
+++ b/src/picture.h
@@ -68,6 +68,11 @@
void dav1d_thread_picture_unref(Dav1dThreadPicture *p);
/**
+ * Move a picture reference.
+ */
+void dav1d_picture_move_ref(Dav1dPicture *dst, Dav1dPicture *src);
+
+/**
* Wait for picture to reach a certain stage.
*
* y is in full-pixel units. If pt is not UV, this is in luma