From 7c692265d80b614d07dea38a590c16e6272586ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 20 Oct 2016 17:02:49 +0200 Subject: [PATCH] vaapivideomemory: add direct upload flag Adds the direct-upload flag in the GstVaapiVideoAllocator and GstVaapiVideoMemory. It still doesn't apply any functional change. --- gst/vaapi/gstvaapivideomemory.c | 17 +++++++++++++++-- gst/vaapi/gstvaapivideomemory.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c index 5df6399b6b..d26830b93a 100644 --- a/gst/vaapi/gstvaapivideomemory.c +++ b/gst/vaapi/gstvaapivideomemory.c @@ -76,6 +76,12 @@ use_direct_rendering (GstVaapiImageUsageFlags flag) return flag == GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_RENDER; } +static inline gboolean +use_direct_uploading (GstVaapiImageUsageFlags flag) +{ + return flag == GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_UPLOAD; +} + static guchar * get_image_data (GstVaapiImage * image) { @@ -707,7 +713,7 @@ allocator_configure_surface_info (GstVaapiDisplay * display, const GstVideoInfo *vinfo; GstVaapiSurface *surface = NULL; GstVaapiImage *image = NULL; - gboolean updated, has_direct_rendering; + gboolean updated, has_direct_uploading, has_direct_rendering; GstVideoFormat fmt; vinfo = &allocator->video_info; @@ -735,15 +741,22 @@ allocator_configure_surface_info (GstVaapiDisplay * display, has_direct_rendering = updated && use_direct_rendering (req_usage_flag) && (GST_VAAPI_IMAGE_FORMAT (image) == GST_VIDEO_INFO_FORMAT (vinfo)); + has_direct_uploading = updated && use_direct_uploading (req_usage_flag) + && (GST_VAAPI_IMAGE_FORMAT (image) == GST_VIDEO_INFO_FORMAT (vinfo)); gst_vaapi_image_unmap (image); GST_INFO_OBJECT (allocator, "has %sdirect-rendering for %s surfaces", has_direct_rendering ? "" : "no ", GST_VIDEO_INFO_FORMAT_STRING (&allocator->surface_info)); + GST_INFO_OBJECT (allocator, "has %sdirect-uploading for %s surfaces", + has_direct_uploading ? "" : "no ", + GST_VIDEO_INFO_FORMAT_STRING (&allocator->surface_info)); - if (has_direct_rendering) + if (has_direct_rendering && !has_direct_uploading) allocator->usage_flag = GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_RENDER; + else if (!has_direct_rendering && has_direct_uploading) + allocator->usage_flag = GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_UPLOAD; bail: if (image) diff --git a/gst/vaapi/gstvaapivideomemory.h b/gst/vaapi/gstvaapivideomemory.h index f2446e4bf1..c7a866ee7b 100644 --- a/gst/vaapi/gstvaapivideomemory.h +++ b/gst/vaapi/gstvaapivideomemory.h @@ -94,6 +94,8 @@ typedef enum * GstVaapiImageUsageFlags: * @GST_VAAPI_IMAGE_USAGE_FLAG_NATIVE_FORMATS: will use vaCreateImage + * va{Put,Get}Image when writing or reading onto the system memory. + * @GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_UPLOAD: will try to use + * vaDeriveImage when writing data from the system memory. * @GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_RENDER: will try to use * vaDeriveImage with reading data onto the system memory. * @@ -101,6 +103,7 @@ typedef enum **/ typedef enum { GST_VAAPI_IMAGE_USAGE_FLAG_NATIVE_FORMATS, + GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_UPLOAD, GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_RENDER, } GstVaapiImageUsageFlags;