summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
Diffstat (limited to 'video')
-rw-r--r--video/mp_image.c11
-rw-r--r--video/mp_image.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/video/mp_image.c b/video/mp_image.c
index e4e6ffa266..7e0dd173b7 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -177,6 +177,17 @@ void mp_image_steal_data(struct mp_image *dst, struct mp_image *src)
talloc_free(src);
}
+// Unref most data buffer (and clear the data array), but leave other fields
+// allocated. In particular, mp_image.hwctx is preserved.
+void mp_image_unref_data(struct mp_image *img)
+{
+ for (int n = 0; n < MP_MAX_PLANES; n++) {
+ img->planes[n] = NULL;
+ img->stride[n] = 0;
+ av_buffer_unref(&img->bufs[n]);
+ }
+}
+
// Return a new reference to img. The returned reference is owned by the caller,
// while img is left untouched.
struct mp_image *mp_image_new_ref(struct mp_image *img)
diff --git a/video/mp_image.h b/video/mp_image.h
index 6606f19c90..e3ffd55adc 100644
--- a/video/mp_image.h
+++ b/video/mp_image.h
@@ -124,6 +124,7 @@ int mp_image_plane_h(struct mp_image *mpi, int plane);
void mp_image_setfmt(mp_image_t* mpi, int out_fmt);
void mp_image_steal_data(struct mp_image *dst, struct mp_image *src);
+void mp_image_unref_data(struct mp_image *img);
struct mp_image *mp_image_new_dummy_ref(struct mp_image *img);
struct mp_image *mp_image_new_custom_ref(struct mp_image *img, void *arg,