libs: window: allow choosing the format for the vpp pool
authorMichael Olbrich <m.olbrich@pengutronix.de>
Tue, 21 Jul 2020 08:03:19 +0000 (10:03 +0200)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 27 Jul 2020 15:02:19 +0000 (15:02 +0000)
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/346>

gst-libs/gst/vaapi/gstvaapiwindow.c
gst-libs/gst/vaapi/gstvaapiwindow_priv.h

index 35ba42c..1908540 100644 (file)
@@ -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;
 
index 09be19c..a0b0582 100644 (file)
@@ -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 */