summaryrefslogtreecommitdiffstats
path: root/video/mp_image.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-02-13 12:12:14 +0100
committerwm4 <wm4@nowhere>2017-02-13 13:12:29 +0100
commita779ce6eac1a43954b37889f5368ee2cead12a1d (patch)
treed1b3dec44e50345d47d34477394a79c2035681f8 /video/mp_image.c
parent27cc06e39cc21d5ea76139e1b0957bccc18b1326 (diff)
downloadmpv-a779ce6eac1a43954b37889f5368ee2cead12a1d.tar.bz2
mpv-a779ce6eac1a43954b37889f5368ee2cead12a1d.tar.xz
mp_image: use AVFrame.opaque_ref to pass through mpv-only fields
We can do this now, which means we can pass a mp_image through libavfilter without loss. Currently, this affects relatively obscure fields only.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r--video/mp_image.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/video/mp_image.c b/video/mp_image.c
index 37d8f67343..e4e6ffa266 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -41,6 +41,9 @@
#include "video/filter/vf.h"
+#define HAVE_OPAQUE_REF (LIBAVUTIL_VERSION_MICRO >= 100 && \
+ LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(55, 47, 100))
+
static bool mp_image_alloc_planes(struct mp_image *mpi)
{
assert(!mpi->planes[0]);
@@ -721,6 +724,15 @@ static void mp_image_copy_fields_from_av_frame(struct mp_image *dst,
};
dst->params.chroma_location = avchroma_location_to_mp(src->chroma_location);
+
+#if HAVE_OPAQUE_REF
+ if (src->opaque_ref) {
+ struct mp_image_params *p = (void *)src->opaque_ref->data;
+ dst->params.rotate = p->rotate;
+ dst->params.stereo_in = p->stereo_in;
+ dst->params.stereo_out = p->stereo_out;
+ }
+#endif
}
// Copy properties and data of the mp_image into the AVFrame, without taking
@@ -756,6 +768,14 @@ static void mp_image_copy_fields_to_av_frame(struct AVFrame *dst,
dst->color_trc = mp_csp_trc_to_avcol_trc(src->params.color.gamma);
dst->chroma_location = mp_chroma_location_to_av(src->params.chroma_location);
+
+#if HAVE_OPAQUE_REF
+ av_buffer_unref(&dst->opaque_ref);
+ dst->opaque_ref = av_buffer_alloc(sizeof(struct mp_image_params));
+ if (!dst->opaque_ref)
+ abort();
+ *(struct mp_image_params *)dst->opaque_ref->data = src->params;
+#endif
}
// Create a new mp_image reference to av_frame.