[FFmpeg-devel,3/7] hwcontext_vaapi: Pass correct read/write flags when exporting surfaces

Submitted by Mark Thompson on March 11, 2018, 10:41 p.m.

Details

Message ID 20180311224156.23986-3-sw@jkqxz.net
State Accepted
Commit ca9f13bbce4836f44fbc18bb30a350fea4075e08
Headers show

Commit Message

Mark Thompson March 11, 2018, 10:41 p.m.
---
 libavutil/hwcontext_vaapi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Rostislav Pehlivanov March 12, 2018, 12:03 a.m.
On 11 March 2018 at 22:41, Mark Thompson <sw@jkqxz.net> wrote:

> ---
>  libavutil/hwcontext_vaapi.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 15f1c4d1c0..8e4bef9f1b 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -1094,15 +1094,20 @@ static int vaapi_map_to_drm_esh(AVHWFramesContext
> *hwfc, AVFrame *dst,
>      VAStatus vas;
>      VADRMPRIMESurfaceDescriptor va_desc;
>      AVDRMFrameDescriptor *drm_desc = NULL;
> +    uint32_t export_flags;
>      int err, i, j;
>
>      surface_id = (VASurfaceID)(uintptr_t)src->data[3];
>
> +    export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS;
> +    if (flags & AV_HWFRAME_MAP_READ)
> +        export_flags |= VA_EXPORT_SURFACE_READ_ONLY;
> +    if (flags & AV_HWFRAME_MAP_WRITE)
> +        export_flags |= VA_EXPORT_SURFACE_WRITE_ONLY;
> +
>      vas = vaExportSurfaceHandle(hwctx->display, surface_id,
>                                  VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
> -                                VA_EXPORT_SURFACE_READ_ONLY |
> -                                VA_EXPORT_SURFACE_SEPARATE_LAYERS,
> -                                &va_desc);
> +                                export_flags, &va_desc);
>      if (vas != VA_STATUS_SUCCESS) {
>          if (vas == VA_STATUS_ERROR_UNIMPLEMENTED)
>              return AVERROR(ENOSYS);
> --
> 2.16.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

LGTM

Patch hide | download patch | download mbox

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 15f1c4d1c0..8e4bef9f1b 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1094,15 +1094,20 @@  static int vaapi_map_to_drm_esh(AVHWFramesContext *hwfc, AVFrame *dst,
     VAStatus vas;
     VADRMPRIMESurfaceDescriptor va_desc;
     AVDRMFrameDescriptor *drm_desc = NULL;
+    uint32_t export_flags;
     int err, i, j;
 
     surface_id = (VASurfaceID)(uintptr_t)src->data[3];
 
+    export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS;
+    if (flags & AV_HWFRAME_MAP_READ)
+        export_flags |= VA_EXPORT_SURFACE_READ_ONLY;
+    if (flags & AV_HWFRAME_MAP_WRITE)
+        export_flags |= VA_EXPORT_SURFACE_WRITE_ONLY;
+
     vas = vaExportSurfaceHandle(hwctx->display, surface_id,
                                 VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
-                                VA_EXPORT_SURFACE_READ_ONLY |
-                                VA_EXPORT_SURFACE_SEPARATE_LAYERS,
-                                &va_desc);
+                                export_flags, &va_desc);
     if (vas != VA_STATUS_SUCCESS) {
         if (vas == VA_STATUS_ERROR_UNIMPLEMENTED)
             return AVERROR(ENOSYS);