From 1b43baf3c896763ea034f5eed05dde3d6026ed48 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Mon, 21 Aug 2023 16:54:31 +0800 Subject: [PATCH] va: baseenc: Use va_get_surface_usage_hint() to get the usage hint Part-of: --- subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c | 10 ++++++++-- subprojects/gst-plugins-bad/sys/va/gstvaencoder.c | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c b/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c index 75c38060ad..ed81e0b3aa 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c @@ -196,7 +196,7 @@ _get_sinkpad_pool (GstVaBaseEnc * base) { GstAllocator *allocator; GstAllocationParams params = { 0, }; - guint size, usage_hint = 0; + guint size, usage_hint; GArray *surface_formats = NULL; GstCaps *caps = NULL; @@ -216,6 +216,9 @@ _get_sinkpad_pool (GstVaBaseEnc * base) allocator = gst_va_allocator_new (base->display, surface_formats); + usage_hint = va_get_surface_usage_hint (base->display, + VAEntrypointEncSlice, GST_PAD_SINK, FALSE); + base->priv->raw_pool = gst_va_pool_new_with_config (caps, size, 1, 0, usage_hint, GST_VA_FEATURE_AUTO, allocator, ¶ms); gst_clear_caps (&caps); @@ -405,7 +408,7 @@ gst_va_base_enc_propose_allocation (GstVideoEncoder * venc, GstQuery * query) GstCaps *caps; GstVideoInfo info; gboolean need_pool = FALSE; - guint size, usage_hint = 0; + guint size, usage_hint; gst_query_parse_allocation (query, &caps, &need_pool); if (!caps) @@ -416,6 +419,9 @@ gst_va_base_enc_propose_allocation (GstVideoEncoder * venc, GstQuery * query) return FALSE; } + usage_hint = va_get_surface_usage_hint (base->display, + VAEntrypointEncSlice, GST_PAD_SINK, gst_video_is_dma_drm_caps (caps)); + size = GST_VIDEO_INFO_SIZE (&info); gst_allocation_params_init (¶ms); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c index d1e8ed1d0e..abe5171a03 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c @@ -26,6 +26,7 @@ #include "gstvaencoder.h" #include +#include #include "gstvacaps.h" #include "gstvaprofile.h" @@ -305,7 +306,7 @@ _create_reconstruct_pool (GstVaDisplay * display, GArray * surface_formats, guint max_buffers) { GstAllocator *allocator = NULL; - guint usage_hint = VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER; + guint usage_hint; GstVideoInfo info; GstAllocationParams params = { 0, }; GstBufferPool *pool; @@ -314,6 +315,9 @@ _create_reconstruct_pool (GstVaDisplay * display, GArray * surface_formats, gst_video_info_set_format (&info, format, coded_width, coded_height); + usage_hint = va_get_surface_usage_hint (display, + VAEntrypointEncSlice, GST_PAD_SINK, FALSE); + size = GST_VIDEO_INFO_SIZE (&info); caps = gst_video_info_to_caps (&info);