va: compositor: Use va_get_surface_usage_hint() to get the usage hint

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5210>
This commit is contained in:
He Junyan 2023-08-21 17:17:43 +08:00 committed by Víctor Manuel Jáquez Leal
parent 1b43baf3c8
commit c927159f21

View file

@ -47,6 +47,7 @@
#include "gstvacompositor.h"
#include <gst/va/gstva.h>
#include <gst/va/vasurfaceimage.h>
#include <gst/video/video.h>
#include <va/va_drmcommon.h>
@ -562,7 +563,7 @@ gst_va_compositor_propose_allocation (GstAggregator * agg,
GstCaps *caps;
GstVideoInfo info;
gboolean update_allocator = FALSE;
guint size, usage_hint = VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC;
guint size, usage_hint;
gst_query_parse_allocation (query, &caps, NULL);
@ -575,6 +576,9 @@ gst_va_compositor_propose_allocation (GstAggregator * agg,
if (gst_query_get_n_allocation_pools (query) > 0)
return TRUE;
usage_hint = va_get_surface_usage_hint (self->display,
VAEntrypointVideoProc, GST_PAD_SINK, gst_video_is_dma_drm_caps (caps));
size = GST_VIDEO_INFO_SIZE (&info);
if (gst_query_get_n_allocation_params (query) > 0) {
@ -658,7 +662,7 @@ gst_va_compositor_decide_allocation (GstAggregator * agg, GstQuery * query)
GstCaps *caps = NULL;
GstStructure *config;
GstVideoInfo info;
guint min, max, size = 0, usage_hint = VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE;
guint min, max, size = 0, usage_hint;
gboolean update_pool, update_allocator, has_videometa, copy_frames;
gboolean dont_use_other_pool = FALSE;
@ -724,6 +728,9 @@ gst_va_compositor_decide_allocation (GstAggregator * agg, GstQuery * query)
if (!pool)
pool = gst_va_pool_new ();
usage_hint = va_get_surface_usage_hint (self->display,
VAEntrypointVideoProc, GST_PAD_SRC, gst_video_is_dma_drm_caps (caps));
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set_allocator (config, allocator, &params);
gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
@ -793,7 +800,7 @@ _get_sinkpad_pool (GstVaCompositor * self, GstVaCompositorPad * pad)
GstAllocationParams params = { 0, };
GstCaps *caps;
GstVideoInfo info;
guint size, usage_hint = VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ;
guint size, usage_hint;
if (pad->pool)
return pad->pool;
@ -809,6 +816,9 @@ _get_sinkpad_pool (GstVaCompositor * self, GstVaCompositorPad * pad)
return NULL;
}
usage_hint = va_get_surface_usage_hint (self->display,
VAEntrypointVideoProc, GST_PAD_SINK, FALSE);
size = GST_VIDEO_INFO_SIZE (&info);
allocator = gst_va_compositor_allocator_from_caps (self, caps);
@ -862,7 +872,7 @@ _try_import_dmabuf_unlocked (GstVaCompositor * self, GstVideoInfo * info,
{
GstVideoMeta *meta;
GstMemory *mems[GST_VIDEO_MAX_PLANES];
guint i, n_mem, n_planes;
guint i, n_mem, n_planes, usage_hint;
gsize offset[GST_VIDEO_MAX_PLANES];
uintptr_t fd[GST_VIDEO_MAX_PLANES];
@ -916,9 +926,12 @@ _try_import_dmabuf_unlocked (GstVaCompositor * self, GstVideoInfo * info,
fd[i] = gst_dmabuf_memory_get_fd (mems[i]);
}
usage_hint = va_get_surface_usage_hint (self->display,
VAEntrypointVideoProc, GST_PAD_SINK, TRUE);
/* Now create a VASurfaceID for the buffer */
return gst_va_dmabuf_memories_setup (self->display, info, n_planes,
mems, fd, offset, VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ);
mems, fd, offset, usage_hint);
}
extern GRecMutex GST_VA_SHARED_LOCK;