mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
Use GstVideoInfo for video pools.
Get rid of GstCaps to create surface/image pool, and use GstVideoInfo structures instead. Those are smaller, and allows for streamlining libgstvaapi more.
This commit is contained in:
parent
97c0316fe4
commit
4ca7922f4b
10 changed files with 64 additions and 75 deletions
|
@ -469,7 +469,7 @@ static gboolean
|
|||
gst_vaapi_context_create_surfaces(GstVaapiContext *context)
|
||||
{
|
||||
const GstVaapiContextInfo * const cip = &context->info;
|
||||
GstCaps *caps;
|
||||
GstVideoInfo vi;
|
||||
GstVaapiSurface *surface;
|
||||
guint i, num_surfaces;
|
||||
|
||||
|
@ -486,20 +486,10 @@ gst_vaapi_context_create_surfaces(GstVaapiContext *context)
|
|||
}
|
||||
|
||||
if (!context->surfaces_pool) {
|
||||
caps = gst_caps_new_simple(
|
||||
GST_VAAPI_SURFACE_CAPS_NAME,
|
||||
"type", G_TYPE_STRING, "vaapi",
|
||||
"width", G_TYPE_INT, cip->width,
|
||||
"height", G_TYPE_INT, cip->height,
|
||||
NULL
|
||||
);
|
||||
if (!caps)
|
||||
return FALSE;
|
||||
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),
|
||||
caps
|
||||
);
|
||||
gst_caps_unref(caps);
|
||||
GST_VAAPI_OBJECT_DISPLAY(context), &vi);
|
||||
if (!context->surfaces_pool)
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -47,17 +47,13 @@ struct _GstVaapiImagePool {
|
|||
};
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_image_pool_set_caps(GstVaapiVideoPool *base_pool, GstCaps *caps)
|
||||
image_pool_init(GstVaapiVideoPool *base_pool, const GstVideoInfo *vip)
|
||||
{
|
||||
GstVaapiImagePool * const pool = GST_VAAPI_IMAGE_POOL(base_pool);
|
||||
GstVideoInfo vi;
|
||||
|
||||
if (!gst_video_info_from_caps(&vi, caps))
|
||||
return FALSE;
|
||||
|
||||
pool->format = GST_VIDEO_INFO_FORMAT(&vi);
|
||||
pool->width = GST_VIDEO_INFO_WIDTH(&vi);
|
||||
pool->height = GST_VIDEO_INFO_HEIGHT(&vi);
|
||||
pool->format = GST_VIDEO_INFO_FORMAT(vip);
|
||||
pool->width = GST_VIDEO_INFO_WIDTH(vip);
|
||||
pool->height = GST_VIDEO_INFO_HEIGHT(vip);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -85,20 +81,20 @@ gst_vaapi_image_pool_class(void)
|
|||
/**
|
||||
* gst_vaapi_image_pool_new:
|
||||
* @display: a #GstVaapiDisplay
|
||||
* @caps: a #GstCaps
|
||||
* @vip: the #GstVideoInfo
|
||||
*
|
||||
* Creates a new #GstVaapiVideoPool of #GstVaapiImage with the
|
||||
* specified dimensions in @caps.
|
||||
* specified format and dimensions in @vip.
|
||||
*
|
||||
* Return value: the newly allocated #GstVaapiVideoPool
|
||||
*/
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, const GstVideoInfo *vip)
|
||||
{
|
||||
GstVaapiVideoPool *pool;
|
||||
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
|
||||
g_return_val_if_fail(vip != NULL, NULL);
|
||||
|
||||
pool = (GstVaapiVideoPool *)
|
||||
gst_vaapi_mini_object_new(gst_vaapi_image_pool_class());
|
||||
|
@ -107,7 +103,8 @@ gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
|||
|
||||
gst_vaapi_video_pool_init(pool, display,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE);
|
||||
if (!gst_vaapi_image_pool_set_caps(pool, caps))
|
||||
|
||||
if (!image_pool_init(pool, vip))
|
||||
goto error;
|
||||
return pool;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <gst/vaapi/gstvaapiimage.h>
|
||||
#include <gst/vaapi/gstvaapivideopool.h>
|
||||
#include <gst/vaapi/video-format.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -34,7 +35,7 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstVaapiImagePool GstVaapiImagePool;
|
||||
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps);
|
||||
gst_vaapi_image_pool_new(GstVaapiDisplay *display, const GstVideoInfo *vip);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -47,17 +47,11 @@ struct _GstVaapiSurfacePool {
|
|||
};
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_surface_pool_set_caps(GstVaapiVideoPool *base_pool, GstCaps *caps)
|
||||
surface_pool_init(GstVaapiSurfacePool *pool, const GstVideoInfo *vip)
|
||||
{
|
||||
GstVaapiSurfacePool * const pool = GST_VAAPI_SURFACE_POOL(base_pool);
|
||||
GstVideoInfo vi;
|
||||
|
||||
if (!gst_video_info_from_caps(&vi, caps))
|
||||
return FALSE;
|
||||
|
||||
pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||
pool->width = GST_VIDEO_INFO_WIDTH(&vi);
|
||||
pool->height = GST_VIDEO_INFO_HEIGHT(&vi);
|
||||
pool->width = GST_VIDEO_INFO_WIDTH(vip);
|
||||
pool->height = GST_VIDEO_INFO_HEIGHT(vip);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -85,20 +79,20 @@ gst_vaapi_surface_pool_class(void)
|
|||
/**
|
||||
* gst_vaapi_surface_pool_new:
|
||||
* @display: a #GstVaapiDisplay
|
||||
* @caps: a #GstCaps
|
||||
* @vip: a #GstVideoInfo
|
||||
*
|
||||
* Creates a new #GstVaapiVideoPool of #GstVaapiSurface with the
|
||||
* specified dimensions in @caps.
|
||||
* specified format and dimensions in @vip.
|
||||
*
|
||||
* Return value: the newly allocated #GstVaapiVideoPool
|
||||
*/
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, const GstVideoInfo *vip)
|
||||
{
|
||||
GstVaapiVideoPool *pool;
|
||||
|
||||
g_return_val_if_fail(display != NULL, NULL);
|
||||
g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
|
||||
g_return_val_if_fail(vip != NULL, NULL);
|
||||
|
||||
pool = (GstVaapiVideoPool *)
|
||||
gst_vaapi_mini_object_new(gst_vaapi_surface_pool_class());
|
||||
|
@ -107,7 +101,7 @@ gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
|||
|
||||
gst_vaapi_video_pool_init(pool, display,
|
||||
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE);
|
||||
if (!gst_vaapi_surface_pool_set_caps(pool, caps))
|
||||
if (!surface_pool_init(GST_VAAPI_SURFACE_POOL(pool), vip))
|
||||
goto error;
|
||||
return pool;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <gst/vaapi/gstvaapisurface.h>
|
||||
#include <gst/vaapi/gstvaapivideopool.h>
|
||||
#include <gst/vaapi/video-format.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -34,7 +35,7 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstVaapiSurfacePool GstVaapiSurfacePool;
|
||||
|
||||
GstVaapiVideoPool *
|
||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps);
|
||||
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, const GstVideoInfo *vip);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define GST_VAAPI_VIDEO_POOL_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <gst/gstcaps.h>
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
|
|
@ -484,13 +484,16 @@ gst_vaapidownload_transform_caps(
|
|||
static gboolean
|
||||
gst_vaapidownload_ensure_image_pool(GstVaapiDownload *download, GstCaps *caps)
|
||||
{
|
||||
GstStructure * const structure = gst_caps_get_structure(caps, 0);
|
||||
GstVideoInfo vi;
|
||||
GstVideoFormat format;
|
||||
gint width, height;
|
||||
guint width, height;
|
||||
|
||||
format = gst_video_format_from_caps(caps);
|
||||
gst_structure_get_int(structure, "width", &width);
|
||||
gst_structure_get_int(structure, "height", &height);
|
||||
if (!gst_video_info_from_caps(&vi, caps))
|
||||
return FALSE;
|
||||
|
||||
format = GST_VIDEO_INFO_FORMAT(&vi);
|
||||
width = GST_VIDEO_INFO_WIDTH(&vi);
|
||||
height = GST_VIDEO_INFO_HEIGHT(&vi);
|
||||
|
||||
if (format != download->image_format ||
|
||||
width != download->image_width ||
|
||||
|
@ -499,7 +502,7 @@ gst_vaapidownload_ensure_image_pool(GstVaapiDownload *download, GstCaps *caps)
|
|||
download->image_width = width;
|
||||
download->image_height = height;
|
||||
gst_vaapi_video_pool_replace(&download->images, NULL);
|
||||
download->images = gst_vaapi_image_pool_new(download->display, caps);
|
||||
download->images = gst_vaapi_image_pool_new(download->display, &vi);
|
||||
if (!download->images)
|
||||
return FALSE;
|
||||
download->images_reset = TRUE;
|
||||
|
|
|
@ -51,6 +51,7 @@ struct _GstVaapiUploaderPrivate {
|
|||
GstCaps *allowed_caps;
|
||||
GstVaapiVideoPool *images;
|
||||
GstCaps *image_caps;
|
||||
GstVideoFormat image_format;
|
||||
guint image_width;
|
||||
guint image_height;
|
||||
GstVaapiVideoPool *surfaces;
|
||||
|
@ -170,17 +171,25 @@ static gboolean
|
|||
ensure_image_pool(GstVaapiUploader *uploader, GstCaps *caps)
|
||||
{
|
||||
GstVaapiUploaderPrivate * const priv = uploader->priv;
|
||||
GstStructure * const structure = gst_caps_get_structure(caps, 0);
|
||||
gint width, height;
|
||||
GstVideoInfo vi;
|
||||
GstVideoFormat format;
|
||||
guint width, height;
|
||||
|
||||
gst_structure_get_int(structure, "width", &width);
|
||||
gst_structure_get_int(structure, "height", &height);
|
||||
if (!gst_video_info_from_caps(&vi, caps))
|
||||
return FALSE;
|
||||
|
||||
if (width != priv->image_width || height != priv->image_height) {
|
||||
format = GST_VIDEO_INFO_FORMAT(&vi);
|
||||
width = GST_VIDEO_INFO_WIDTH(&vi);
|
||||
height = GST_VIDEO_INFO_HEIGHT(&vi);
|
||||
|
||||
if (format != priv->image_format ||
|
||||
width != priv->image_width ||
|
||||
height != priv->image_height) {
|
||||
priv->image_format = format;
|
||||
priv->image_width = width;
|
||||
priv->image_height = height;
|
||||
gst_vaapi_video_pool_replace(&priv->images, NULL);
|
||||
priv->images = gst_vaapi_image_pool_new(priv->display, caps);
|
||||
priv->images = gst_vaapi_image_pool_new(priv->display, &vi);
|
||||
if (!priv->images)
|
||||
return FALSE;
|
||||
gst_caps_replace(&priv->image_caps, caps);
|
||||
|
@ -192,17 +201,20 @@ static gboolean
|
|||
ensure_surface_pool(GstVaapiUploader *uploader, GstCaps *caps)
|
||||
{
|
||||
GstVaapiUploaderPrivate * const priv = uploader->priv;
|
||||
GstStructure * const structure = gst_caps_get_structure(caps, 0);
|
||||
gint width, height;
|
||||
GstVideoInfo vi;
|
||||
guint width, height;
|
||||
|
||||
gst_structure_get_int(structure, "width", &width);
|
||||
gst_structure_get_int(structure, "height", &height);
|
||||
if (!gst_video_info_from_caps(&vi, caps))
|
||||
return FALSE;
|
||||
|
||||
width = GST_VIDEO_INFO_WIDTH(&vi);
|
||||
height = GST_VIDEO_INFO_HEIGHT(&vi);
|
||||
|
||||
if (width != priv->surface_width || height != priv->surface_height) {
|
||||
priv->surface_width = width;
|
||||
priv->surface_height = height;
|
||||
gst_vaapi_video_pool_replace(&priv->surfaces, NULL);
|
||||
priv->surfaces = gst_vaapi_surface_pool_new(priv->display, caps);
|
||||
priv->surfaces = gst_vaapi_surface_pool_new(priv->display, &vi);
|
||||
if (!priv->surfaces)
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -86,8 +86,9 @@ test_display_CFLAGS = $(TEST_CFLAGS)
|
|||
test_display_LDADD = libutils.la $(TEST_LIBS)
|
||||
|
||||
test_surfaces_SOURCES = test-surfaces.c
|
||||
test_surfaces_CFLAGS = $(TEST_CFLAGS)
|
||||
test_surfaces_LDADD = libutils.la $(TEST_LIBS)
|
||||
test_surfaces_CFLAGS = $(TEST_CFLAGS) $(GST_VIDEO_CFLAGS)
|
||||
test_surfaces_LDADD = libutils.la $(TEST_LIBS) $(GST_VIDEO_LIBS) \
|
||||
$(top_builddir)/gst-libs/gst/video/libgstvaapi-videoutils.la
|
||||
|
||||
test_subpicture_SOURCES = test-subpicture.c test-subpicture-data.c
|
||||
test_subpicture_CFLAGS = $(TEST_CFLAGS) $(GST_VIDEO_CFLAGS)
|
||||
|
|
|
@ -34,7 +34,7 @@ main(int argc, char *argv[])
|
|||
GstVaapiID surface_id;
|
||||
GstVaapiSurface *surfaces[MAX_SURFACES];
|
||||
GstVaapiVideoPool *pool;
|
||||
GstCaps *caps;
|
||||
GstVideoInfo vi;
|
||||
gint i;
|
||||
|
||||
static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||
|
@ -58,17 +58,9 @@ main(int argc, char *argv[])
|
|||
|
||||
gst_vaapi_object_unref(surface);
|
||||
|
||||
caps = gst_caps_new_simple(
|
||||
GST_VAAPI_SURFACE_CAPS_NAME,
|
||||
"type", G_TYPE_STRING, "vaapi",
|
||||
"width", G_TYPE_INT, width,
|
||||
"height", G_TYPE_INT, height,
|
||||
NULL
|
||||
);
|
||||
if (!caps)
|
||||
g_error("cound not create Gst/VA surface caps");
|
||||
gst_video_info_set_format(&vi, GST_VIDEO_FORMAT_ENCODED, width, height);
|
||||
|
||||
pool = gst_vaapi_surface_pool_new(display, caps);
|
||||
pool = gst_vaapi_surface_pool_new(display, &vi);
|
||||
if (!pool)
|
||||
g_error("could not create Gst/VA surface pool");
|
||||
|
||||
|
@ -107,7 +99,6 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Unref in random order to check objects are correctly refcounted */
|
||||
gst_vaapi_display_unref(display);
|
||||
gst_caps_unref(caps);
|
||||
gst_vaapi_video_pool_unref(pool);
|
||||
gst_vaapi_object_unref(surface);
|
||||
video_output_exit();
|
||||
|
|
Loading…
Reference in a new issue