From 72d32a91d25e2b6ca5e2508f8a46c0dca25d172f Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Tue, 21 Jul 2020 10:03:19 +0200 Subject: [PATCH] libs: window: allow choosing the format for the vpp pool Signed-off-by: Michael Olbrich Part-of: --- gst-libs/gst/vaapi/gstvaapiwindow.c | 18 +++++++++++++++++- gst-libs/gst/vaapi/gstvaapiwindow_priv.h | 6 ++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vaapi/gstvaapiwindow.c b/gst-libs/gst/vaapi/gstvaapiwindow.c index 35ba42c..1908540 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow.c @@ -98,6 +98,19 @@ error_unsupported_format: } } +void +gst_vaapi_window_set_vpp_format_internal (GstVaapiWindow * window, + GstVideoFormat format, guint flags) +{ + if (window->surface_pool_format == format && + window->surface_pool_flags == flags) + return; + + gst_vaapi_video_pool_replace (&window->surface_pool, NULL); + window->surface_pool_format = format; + window->surface_pool_flags = flags; +} + static gboolean ensure_filter_surface_pool (GstVaapiWindow * window) { @@ -109,7 +122,8 @@ ensure_filter_surface_pool (GstVaapiWindow * window) /* Ensure VA surface pool is created */ /* XXX: optimize the surface format to use. e.g. YUY2 */ window->surface_pool = gst_vaapi_surface_pool_new (display, - GST_VIDEO_FORMAT_NV12, window->width, window->height, 0); + window->surface_pool_format, window->width, window->height, + window->surface_pool_flags); if (!window->surface_pool) { GST_WARNING ("failed to create surface pool for conversion"); return FALSE; @@ -229,6 +243,8 @@ gst_vaapi_window_new_internal (GType type, GstVaapiDisplay * display, if (!window) return NULL; + window->surface_pool_format = GST_VIDEO_FORMAT_NV12; + window->use_foreign_window = id != GST_VAAPI_ID_INVALID; GST_VAAPI_WINDOW_ID (window) = window->use_foreign_window ? id : 0; diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_priv.h b/gst-libs/gst/vaapi/gstvaapiwindow_priv.h index 09be19c..a0b0582 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_priv.h +++ b/gst-libs/gst/vaapi/gstvaapiwindow_priv.h @@ -83,6 +83,8 @@ struct _GstVaapiWindow guint check_geometry:1; /* for conversion */ + GstVideoFormat surface_pool_format; + guint surface_pool_flags; GstVaapiVideoPool *surface_pool; GstVaapiFilter *filter; gboolean has_vpp; @@ -138,6 +140,10 @@ gst_vaapi_window_vpp_convert_internal (GstVaapiWindow * window, GstVaapiSurface * surface, const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect, guint flags); +void +gst_vaapi_window_set_vpp_format_internal (GstVaapiWindow * window, + GstVideoFormat format, guint flags); + G_END_DECLS #endif /* GST_VAAPI_WINDOW_PRIV_H */ -- 2.7.4