summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst-libs/gst/vaapi/gstvaapicontext.c6
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurfacepool.c64
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurfacepool.h8
-rw-r--r--gst-libs/gst/vaapi/gstvaapiwindow_wayland.c6
-rw-r--r--gst/vaapi/gstvaapipostproc.c5
-rw-r--r--gst/vaapi/gstvaapiuploader.c2
-rw-r--r--gst/vaapi/gstvaapivideobufferpool.c2
-rw-r--r--gst/vaapi/gstvaapivideomemory.c6
-rw-r--r--gst/vaapi/gstvaapivideomemory.h2
-rw-r--r--tests/test-surfaces.c6
10 files changed, 69 insertions, 38 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c
index 185ed7fd..a2c68a32 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.c
+++ b/gst-libs/gst/vaapi/gstvaapicontext.c
@@ -134,7 +134,6 @@ static gboolean
context_create_surfaces (GstVaapiContext * context)
{
const GstVaapiContextInfo *const cip = &context->info;
- GstVideoInfo vi;
guint num_surfaces;
if (!gst_vaapi_context_overlay_reset (context))
@@ -149,10 +148,9 @@ context_create_surfaces (GstVaapiContext * context)
}
if (!context->surfaces_pool) {
- gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_ENCODED,
- cip->width, cip->height);
context->surfaces_pool =
- gst_vaapi_surface_pool_new (GST_VAAPI_OBJECT_DISPLAY (context), &vi);
+ gst_vaapi_surface_pool_new (GST_VAAPI_OBJECT_DISPLAY (context),
+ GST_VIDEO_FORMAT_ENCODED, cip->width, cip->height);
if (!context->surfaces_pool)
return FALSE;
}
diff --git a/gst-libs/gst/vaapi/gstvaapisurfacepool.c b/gst-libs/gst/vaapi/gstvaapisurfacepool.c
index 8af8eac9..02c06060 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfacepool.c
+++ b/gst-libs/gst/vaapi/gstvaapisurfacepool.c
@@ -45,25 +45,26 @@ struct _GstVaapiSurfacePool
GstVaapiVideoPool parent_instance;
GstVaapiChromaType chroma_type;
- GstVideoFormat format;
- guint width;
- guint height;
+ GstVideoInfo video_info;
+ guint alloc_flags;
};
static gboolean
-surface_pool_init (GstVaapiSurfacePool * pool, const GstVideoInfo * vip)
+surface_pool_init (GstVaapiSurfacePool * pool, const GstVideoInfo * vip,
+ guint flags)
{
- pool->format = GST_VIDEO_INFO_FORMAT (vip);
- pool->width = GST_VIDEO_INFO_WIDTH (vip);
- pool->height = GST_VIDEO_INFO_HEIGHT (vip);
+ const GstVideoFormat format = GST_VIDEO_INFO_FORMAT (vip);
- if (pool->format == GST_VIDEO_FORMAT_UNKNOWN)
+ pool->video_info = *vip;
+ pool->alloc_flags = flags;
+
+ if (format == GST_VIDEO_FORMAT_UNKNOWN)
return FALSE;
- if (pool->format == GST_VIDEO_FORMAT_ENCODED)
+ if (format == GST_VIDEO_FORMAT_ENCODED)
pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
else
- pool->chroma_type = gst_vaapi_video_format_get_chroma_type (pool->format);
+ pool->chroma_type = gst_vaapi_video_format_get_chroma_type (format);
if (!pool->chroma_type)
return FALSE;
return TRUE;
@@ -75,17 +76,18 @@ gst_vaapi_surface_pool_alloc_object (GstVaapiVideoPool * base_pool)
GstVaapiSurfacePool *const pool = GST_VAAPI_SURFACE_POOL (base_pool);
/* Try to allocate a surface with an explicit pixel format first */
- if (pool->format != GST_VIDEO_FORMAT_ENCODED) {
+ if (GST_VIDEO_INFO_FORMAT (&pool->video_info) != GST_VIDEO_FORMAT_ENCODED) {
GstVaapiSurface *const surface =
- gst_vaapi_surface_new_with_format (base_pool->display, pool->format,
- pool->width, pool->height);
+ gst_vaapi_surface_new_full (base_pool->display, &pool->video_info,
+ pool->alloc_flags);
if (surface)
return surface;
}
/* Otherwise, fallback to the original interface, based on chroma format */
return gst_vaapi_surface_new (base_pool->display,
- pool->chroma_type, pool->width, pool->height);
+ pool->chroma_type, GST_VIDEO_INFO_WIDTH (&pool->video_info),
+ GST_VIDEO_INFO_HEIGHT (&pool->video_info));
}
static inline const GstVaapiMiniObjectClass *
@@ -102,7 +104,36 @@ gst_vaapi_surface_pool_class (void)
/**
* gst_vaapi_surface_pool_new:
* @display: a #GstVaapiDisplay
+ * @format: a #GstVideoFormat
+ * @width: the desired width, in pixels
+ * @height: the desired height, in pixels
+ *
+ * Creates a new #GstVaapiVideoPool of #GstVaapiSurface with the specified
+ * format and dimensions. If @format is GST_VIDEO_FORMAT_ENCODED, then
+ * surfaces with best "native" format would be created. Typically, this is
+ * NV12 format, but this is implementation (driver) defined.
+ *
+ * Return value: the newly allocated #GstVaapiVideoPool
+ */
+GstVaapiVideoPool *
+gst_vaapi_surface_pool_new (GstVaapiDisplay * display, GstVideoFormat format,
+ guint width, guint height)
+{
+ GstVideoInfo vi;
+
+ g_return_val_if_fail (display != NULL, NULL);
+ g_return_val_if_fail (width > 0, NULL);
+ g_return_val_if_fail (height > 0, NULL);
+
+ gst_video_info_set_format (&vi, format, width, height);
+ return gst_vaapi_surface_pool_new_full (display, &vi, 0);
+}
+
+/**
+ * gst_vaapi_surface_pool_new_full:
+ * @display: a #GstVaapiDisplay
* @vip: a #GstVideoInfo
+ * @flags: (optional) allocation flags
*
* Creates a new #GstVaapiVideoPool of #GstVaapiSurface with the
* specified format and dimensions in @vip.
@@ -110,7 +141,8 @@ gst_vaapi_surface_pool_class (void)
* Return value: the newly allocated #GstVaapiVideoPool
*/
GstVaapiVideoPool *
-gst_vaapi_surface_pool_new (GstVaapiDisplay * display, const GstVideoInfo * vip)
+gst_vaapi_surface_pool_new_full (GstVaapiDisplay * display,
+ const GstVideoInfo * vip, guint flags)
{
GstVaapiVideoPool *pool;
@@ -124,7 +156,7 @@ gst_vaapi_surface_pool_new (GstVaapiDisplay * display, const GstVideoInfo * vip)
gst_vaapi_video_pool_init (pool, display,
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE);
- if (!surface_pool_init (GST_VAAPI_SURFACE_POOL (pool), vip))
+ if (!surface_pool_init (GST_VAAPI_SURFACE_POOL (pool), vip, flags))
goto error;
return pool;
diff --git a/gst-libs/gst/vaapi/gstvaapisurfacepool.h b/gst-libs/gst/vaapi/gstvaapisurfacepool.h
index 82d623b1..e0529a22 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfacepool.h
+++ b/gst-libs/gst/vaapi/gstvaapisurfacepool.h
@@ -37,8 +37,12 @@ G_BEGIN_DECLS
typedef struct _GstVaapiSurfacePool GstVaapiSurfacePool;
GstVaapiVideoPool *
-gst_vaapi_surface_pool_new (GstVaapiDisplay * display,
- const GstVideoInfo * vip);
+gst_vaapi_surface_pool_new (GstVaapiDisplay * display, GstVideoFormat format,
+ guint width, guint height);
+
+GstVaapiVideoPool *
+gst_vaapi_surface_pool_new_full (GstVaapiDisplay * display,
+ const GstVideoInfo * vip, guint flags);
G_END_DECLS
diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c
index 2c40e488..9846063d 100644
--- a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c
+++ b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c
@@ -348,14 +348,12 @@ vpp_convert (GstVaapiWindow * window,
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (window);
GstVaapiSurface *vpp_surface = NULL;
GstVaapiFilterStatus status;
- GstVideoInfo vi;
/* Ensure VA surface pool is created */
/* XXX: optimize the surface format to use. e.g. YUY2 */
if (!priv->surface_pool) {
- gst_video_info_set_format (&vi, priv->surface_format,
- window->width, window->height);
- priv->surface_pool = gst_vaapi_surface_pool_new (display, &vi);
+ priv->surface_pool = gst_vaapi_surface_pool_new (display,
+ priv->surface_format, window->width, window->height);
if (!priv->surface_pool)
return NULL;
gst_vaapi_filter_replace (&priv->filter, NULL);
diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c
index 756491b3..e701b8cd 100644
--- a/gst/vaapi/gstvaapipostproc.c
+++ b/gst/vaapi/gstvaapipostproc.c
@@ -1310,8 +1310,9 @@ ensure_srcpad_buffer_pool (GstVaapiPostproc * postproc, GstCaps * caps)
return TRUE;
postproc->filter_pool_info = vi;
- pool = gst_vaapi_surface_pool_new (GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc),
- &postproc->filter_pool_info);
+ pool =
+ gst_vaapi_surface_pool_new_full (GST_VAAPI_PLUGIN_BASE_DISPLAY (postproc),
+ &postproc->filter_pool_info, 0);
if (!pool)
return FALSE;
diff --git a/gst/vaapi/gstvaapiuploader.c b/gst/vaapi/gstvaapiuploader.c
index 6c702b92..c4e5d149 100644
--- a/gst/vaapi/gstvaapiuploader.c
+++ b/gst/vaapi/gstvaapiuploader.c
@@ -243,7 +243,7 @@ ensure_surface_pool (GstVaapiUploader * uploader, GstCaps * caps,
}
}
- pool = gst_vaapi_surface_pool_new (priv->display, &vi);
+ pool = gst_vaapi_surface_pool_new_full (priv->display, &vi, 0);
if (!pool)
return FALSE;
diff --git a/gst/vaapi/gstvaapivideobufferpool.c b/gst/vaapi/gstvaapivideobufferpool.c
index 4c642e7d..84be8e30 100644
--- a/gst/vaapi/gstvaapivideobufferpool.c
+++ b/gst/vaapi/gstvaapivideobufferpool.c
@@ -153,7 +153,7 @@ gst_vaapi_video_buffer_pool_set_config (GstBufferPool * pool,
GST_VIDEO_INFO_HEIGHT (cur_vip) != GST_VIDEO_INFO_HEIGHT (new_vip);
if (changed_caps) {
- allocator = gst_vaapi_video_allocator_new (priv->display, new_vip);
+ allocator = gst_vaapi_video_allocator_new (priv->display, new_vip, 0);
if (!allocator)
goto error_create_allocator;
gst_object_replace ((GstObject **) & priv->allocator,
diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c
index 184d78d2..33674f5e 100644
--- a/gst/vaapi/gstvaapivideomemory.c
+++ b/gst/vaapi/gstvaapivideomemory.c
@@ -650,7 +650,7 @@ gst_video_info_update_from_image (GstVideoInfo * vip, GstVaapiImage * image)
GstAllocator *
gst_vaapi_video_allocator_new (GstVaapiDisplay * display,
- const GstVideoInfo * vip)
+ const GstVideoInfo * vip, guint flags)
{
GstVaapiVideoAllocator *allocator;
GstVaapiSurface *surface;
@@ -695,8 +695,8 @@ gst_vaapi_video_allocator_new (GstVaapiDisplay * display,
gst_vaapi_object_unref (image);
}
- allocator->surface_pool = gst_vaapi_surface_pool_new (display,
- &allocator->surface_info);
+ allocator->surface_pool = gst_vaapi_surface_pool_new_full (display,
+ &allocator->surface_info, flags);
if (!allocator->surface_pool)
goto error_create_surface_pool;
diff --git a/gst/vaapi/gstvaapivideomemory.h b/gst/vaapi/gstvaapivideomemory.h
index 5681a1c0..ba29564a 100644
--- a/gst/vaapi/gstvaapivideomemory.h
+++ b/gst/vaapi/gstvaapivideomemory.h
@@ -187,7 +187,7 @@ gst_vaapi_video_allocator_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
GstAllocator *
gst_vaapi_video_allocator_new (GstVaapiDisplay * display,
- const GstVideoInfo * vip);
+ const GstVideoInfo * vip, guint flags);
G_END_DECLS
diff --git a/tests/test-surfaces.c b/tests/test-surfaces.c
index c958e075..734774f5 100644
--- a/tests/test-surfaces.c
+++ b/tests/test-surfaces.c
@@ -36,7 +36,6 @@ main(int argc, char *argv[])
GstVaapiID surface_id;
GstVaapiSurface *surfaces[MAX_SURFACES];
GstVaapiVideoPool *pool;
- GstVideoInfo vi;
gint i;
static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
@@ -60,9 +59,8 @@ main(int argc, char *argv[])
gst_vaapi_object_unref(surface);
- gst_video_info_set_format(&vi, GST_VIDEO_FORMAT_ENCODED, width, height);
-
- pool = gst_vaapi_surface_pool_new(display, &vi);
+ pool = gst_vaapi_surface_pool_new(display, GST_VIDEO_FORMAT_ENCODED,
+ width, height);
if (!pool)
g_error("could not create Gst/VA surface pool");