summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorHe Junyan <junyan.he@intel.com>2021-05-14 11:49:01 +0800
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-08-25 01:47:21 +0000
commitc27c158cb2efe285f6fcf909cb49e8a0ac88c568 (patch)
tree0c918650b4f2976dd651daafe708bee1368c608e /gst
parente0a56f339193e057415bfaf7cfea5106e5e97590 (diff)
plugins: video memory: Add a GST_MAP_VAAPI flag to peek the surface.
Just like what we do in VA plugins, the GST_MAP_VAAPI can directly peek the surface of the VA buffers. The old flag 0 just peek the surface proxy, which may not be convenient for the users who do not want to include our headers. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/435>
Diffstat (limited to 'gst')
-rw-r--r--gst/vaapi/gstvaapivideomemory.c16
-rw-r--r--gst/vaapi/gstvaapivideomemory.h2
2 files changed, 16 insertions, 2 deletions
diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c
index 750385a4..8c1f5887 100644
--- a/gst/vaapi/gstvaapivideomemory.c
+++ b/gst/vaapi/gstvaapivideomemory.c
@@ -378,6 +378,7 @@ gst_vaapi_video_memory_new (GstAllocator * base_allocator,
mem->meta = meta ? gst_vaapi_video_meta_ref (meta) : NULL;
mem->map_type = 0;
mem->map_count = 0;
+ mem->map_surface_id = VA_INVALID_ID;
mem->usage_flag = allocator->usage_flag;
g_mutex_init (&mem->lock);
@@ -437,8 +438,9 @@ gst_vaapi_video_memory_map (GstMemory * base_mem, gsize maxsize, guint flags)
g_mutex_lock (&mem->lock);
if (mem->map_count == 0) {
- switch (flags & GST_MAP_READWRITE) {
+ switch (flags & (GST_MAP_READWRITE | GST_MAP_VAAPI)) {
case 0:
+ case GST_MAP_VAAPI:
// No flags set: return a GstVaapiSurfaceProxy
gst_vaapi_surface_proxy_replace (&mem->proxy,
gst_vaapi_video_meta_get_surface_proxy (mem->meta));
@@ -462,7 +464,16 @@ gst_vaapi_video_memory_map (GstMemory * base_mem, gsize maxsize, guint flags)
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE:
if (!mem->proxy)
goto error_no_surface_proxy;
- data = mem->proxy;
+
+ if (flags == GST_MAP_VAAPI) {
+ mem->map_surface_id = GST_VAAPI_SURFACE_PROXY_SURFACE_ID (mem->proxy);
+ if (mem->map_surface_id == VA_INVALID_ID)
+ goto error_no_current_surface;
+
+ data = &mem->map_surface_id;
+ } else {
+ data = mem->proxy;
+ }
break;
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR:
if (!mem->image)
@@ -515,6 +526,7 @@ gst_vaapi_video_memory_unmap_full (GstMemory * base_mem, GstMapInfo * info)
if (mem->map_count == 1) {
switch (mem->map_type) {
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE:
+ mem->map_surface_id = VA_INVALID_ID;
gst_vaapi_surface_proxy_replace (&mem->proxy, NULL);
break;
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR:
diff --git a/gst/vaapi/gstvaapivideomemory.h b/gst/vaapi/gstvaapivideomemory.h
index 41a05888..23d68ad7 100644
--- a/gst/vaapi/gstvaapivideomemory.h
+++ b/gst/vaapi/gstvaapivideomemory.h
@@ -128,6 +128,7 @@ struct _GstVaapiVideoMemory
GstVaapiVideoMeta *meta;
guint map_type;
gint map_count;
+ VASurfaceID map_surface_id;
GstVaapiImageUsageFlags usage_flag;
GMutex lock;
};
@@ -157,6 +158,7 @@ gst_vaapi_video_memory_sync (GstVaapiVideoMemory * mem);
/* ------------------------------------------------------------------------ */
/* --- GstVaapiVideoAllocator --- */
/* ------------------------------------------------------------------------ */
+#define GST_MAP_VAAPI (GST_MAP_FLAG_LAST << 1)
#define GST_VAAPI_VIDEO_ALLOCATOR_CAST(allocator) \
((GstVaapiVideoAllocator *) (allocator))