mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
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>
This commit is contained in:
parent
e0a56f3391
commit
c27c158cb2
2 changed files with 16 additions and 2 deletions
|
@ -378,6 +378,7 @@ gst_vaapi_video_memory_new (GstAllocator * base_allocator,
|
||||||
mem->meta = meta ? gst_vaapi_video_meta_ref (meta) : NULL;
|
mem->meta = meta ? gst_vaapi_video_meta_ref (meta) : NULL;
|
||||||
mem->map_type = 0;
|
mem->map_type = 0;
|
||||||
mem->map_count = 0;
|
mem->map_count = 0;
|
||||||
|
mem->map_surface_id = VA_INVALID_ID;
|
||||||
mem->usage_flag = allocator->usage_flag;
|
mem->usage_flag = allocator->usage_flag;
|
||||||
g_mutex_init (&mem->lock);
|
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);
|
g_mutex_lock (&mem->lock);
|
||||||
if (mem->map_count == 0) {
|
if (mem->map_count == 0) {
|
||||||
switch (flags & GST_MAP_READWRITE) {
|
switch (flags & (GST_MAP_READWRITE | GST_MAP_VAAPI)) {
|
||||||
case 0:
|
case 0:
|
||||||
|
case GST_MAP_VAAPI:
|
||||||
// No flags set: return a GstVaapiSurfaceProxy
|
// No flags set: return a GstVaapiSurfaceProxy
|
||||||
gst_vaapi_surface_proxy_replace (&mem->proxy,
|
gst_vaapi_surface_proxy_replace (&mem->proxy,
|
||||||
gst_vaapi_video_meta_get_surface_proxy (mem->meta));
|
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:
|
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE:
|
||||||
if (!mem->proxy)
|
if (!mem->proxy)
|
||||||
goto error_no_surface_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;
|
break;
|
||||||
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR:
|
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR:
|
||||||
if (!mem->image)
|
if (!mem->image)
|
||||||
|
@ -515,6 +526,7 @@ gst_vaapi_video_memory_unmap_full (GstMemory * base_mem, GstMapInfo * info)
|
||||||
if (mem->map_count == 1) {
|
if (mem->map_count == 1) {
|
||||||
switch (mem->map_type) {
|
switch (mem->map_type) {
|
||||||
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE:
|
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE:
|
||||||
|
mem->map_surface_id = VA_INVALID_ID;
|
||||||
gst_vaapi_surface_proxy_replace (&mem->proxy, NULL);
|
gst_vaapi_surface_proxy_replace (&mem->proxy, NULL);
|
||||||
break;
|
break;
|
||||||
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR:
|
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR:
|
||||||
|
|
|
@ -128,6 +128,7 @@ struct _GstVaapiVideoMemory
|
||||||
GstVaapiVideoMeta *meta;
|
GstVaapiVideoMeta *meta;
|
||||||
guint map_type;
|
guint map_type;
|
||||||
gint map_count;
|
gint map_count;
|
||||||
|
VASurfaceID map_surface_id;
|
||||||
GstVaapiImageUsageFlags usage_flag;
|
GstVaapiImageUsageFlags usage_flag;
|
||||||
GMutex lock;
|
GMutex lock;
|
||||||
};
|
};
|
||||||
|
@ -157,6 +158,7 @@ gst_vaapi_video_memory_sync (GstVaapiVideoMemory * mem);
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
/* --- GstVaapiVideoAllocator --- */
|
/* --- GstVaapiVideoAllocator --- */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
#define GST_MAP_VAAPI (GST_MAP_FLAG_LAST << 1)
|
||||||
|
|
||||||
#define GST_VAAPI_VIDEO_ALLOCATOR_CAST(allocator) \
|
#define GST_VAAPI_VIDEO_ALLOCATOR_CAST(allocator) \
|
||||||
((GstVaapiVideoAllocator *) (allocator))
|
((GstVaapiVideoAllocator *) (allocator))
|
||||||
|
|
Loading…
Reference in a new issue