diff mbox

[FFmpeg-devel,v2,1/8] hwcontext_internal: add ff_hwframe_map_replace

Message ID 20180422164751.22628-2-atomnuker@gmail.com
State Superseded
Headers show

Commit Message

Rostislav Pehlivanov April 22, 2018, 4:47 p.m. UTC
Used to fix unmapping when no direct interop exists between APIs.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
---
 libavutil/hwcontext.c          | 7 +++++++
 libavutil/hwcontext_internal.h | 5 +++++
 2 files changed, 12 insertions(+)

Comments

Rostislav Pehlivanov June 21, 2018, 3:35 p.m. UTC | #1
On 22 April 2018 at 17:47, Rostislav Pehlivanov <atomnuker@gmail.com> wrote:

> Used to fix unmapping when no direct interop exists between APIs.
>
> Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
> ---
>  libavutil/hwcontext.c          | 7 +++++++
>  libavutil/hwcontext_internal.h | 5 +++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> index 70c556ecac..f9ce2f5b13 100644
> --- a/libavutil/hwcontext.c
> +++ b/libavutil/hwcontext.c
> @@ -871,3 +871,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);
> +}
> diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_
> internal.h
> index 332062ddaa..77dc47ddd6 100644
> --- a/libavutil/hwcontext_internal.h
> +++ b/libavutil/hwcontext_internal.h
> @@ -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;
> --
> 2.17.0
>
>
Pushed
diff mbox

Patch

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 70c556ecac..f9ce2f5b13 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -871,3 +871,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);
+}
diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h
index 332062ddaa..77dc47ddd6 100644
--- a/libavutil/hwcontext_internal.h
+++ b/libavutil/hwcontext_internal.h
@@ -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;