hwcontext_internal: add ff_hwframe_map_replace
authorRostislav Pehlivanov <atomnuker@gmail.com>
Fri, 20 Apr 2018 04:30:03 +0000 (05:30 +0100)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Thu, 21 Jun 2018 15:34:06 +0000 (16:34 +0100)
Used to fix unmapping when no direct interop exists between APIs.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
libavutil/hwcontext.c
libavutil/hwcontext_internal.h

index 745016e..f1e404a 100644 (file)
@@ -870,3 +870,10 @@ fail:
     av_buffer_unref(&dst_ref);
     return ret;
 }
+
+int ff_hwframe_map_replace(AVFrame *dst, const AVFrame *src)
+{
+    HWMapDescriptor *hwmap = (HWMapDescriptor*)dst->buf[0]->data;
+    av_frame_unref(hwmap->source);
+    return av_frame_ref(hwmap->source, src);
+}
index 332062d..77dc47d 100644 (file)
@@ -156,6 +156,11 @@ int ff_hwframe_map_create(AVBufferRef *hwframe_ref,
                                         HWMapDescriptor *hwmap),
                           void *priv);
 
+/**
+ * Replace the current hwmap of dst with the one from src, used for indirect
+ * mappings like VAAPI->(DRM)->OpenCL/Vulkan where a direct interop is missing
+ */
+int ff_hwframe_map_replace(AVFrame *dst, const AVFrame *src);
 
 extern const HWContextType ff_hwcontext_type_cuda;
 extern const HWContextType ff_hwcontext_type_d3d11va;