diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c index a132e82746..6cdf1b39b6 100644 --- a/gst-libs/gst/vaapi/gstvaapicontext.c +++ b/gst-libs/gst/vaapi/gstvaapicontext.c @@ -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; } diff --git a/gst-libs/gst/vaapi/gstvaapiimagepool.c b/gst-libs/gst/vaapi/gstvaapiimagepool.c index 2f85bcabd9..8b9a140264 100644 --- a/gst-libs/gst/vaapi/gstvaapiimagepool.c +++ b/gst-libs/gst/vaapi/gstvaapiimagepool.c @@ -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; diff --git a/gst-libs/gst/vaapi/gstvaapiimagepool.h b/gst-libs/gst/vaapi/gstvaapiimagepool.h index 801cdaedd3..19677eb1c8 100644 --- a/gst-libs/gst/vaapi/gstvaapiimagepool.h +++ b/gst-libs/gst/vaapi/gstvaapiimagepool.h @@ -25,6 +25,7 @@ #include #include +#include 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 diff --git a/gst-libs/gst/vaapi/gstvaapisurfacepool.c b/gst-libs/gst/vaapi/gstvaapisurfacepool.c index f429b9d2f7..7f691540bb 100644 --- a/gst-libs/gst/vaapi/gstvaapisurfacepool.c +++ b/gst-libs/gst/vaapi/gstvaapisurfacepool.c @@ -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; diff --git a/gst-libs/gst/vaapi/gstvaapisurfacepool.h b/gst-libs/gst/vaapi/gstvaapisurfacepool.h index 48ea71edc7..7e47920651 100644 --- a/gst-libs/gst/vaapi/gstvaapisurfacepool.h +++ b/gst-libs/gst/vaapi/gstvaapisurfacepool.h @@ -25,6 +25,7 @@ #include #include +#include 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 diff --git a/gst-libs/gst/vaapi/gstvaapivideopool.h b/gst-libs/gst/vaapi/gstvaapivideopool.h index 03b6cffdc3..07ad7a35f3 100644 --- a/gst-libs/gst/vaapi/gstvaapivideopool.h +++ b/gst-libs/gst/vaapi/gstvaapivideopool.h @@ -24,7 +24,6 @@ #define GST_VAAPI_VIDEO_POOL_H #include -#include #include G_BEGIN_DECLS diff --git a/gst/vaapi/gstvaapidownload.c b/gst/vaapi/gstvaapidownload.c index 4988800cc4..133615efab 100644 --- a/gst/vaapi/gstvaapidownload.c +++ b/gst/vaapi/gstvaapidownload.c @@ -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; diff --git a/gst/vaapi/gstvaapiuploader.c b/gst/vaapi/gstvaapiuploader.c index 814e73e19a..dc3a0dce64 100755 --- a/gst/vaapi/gstvaapiuploader.c +++ b/gst/vaapi/gstvaapiuploader.c @@ -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; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 8c4d967dec..0bc4f73095 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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) diff --git a/tests/test-surfaces.c b/tests/test-surfaces.c index 806f8f31bc..bc55dd7f8f 100644 --- a/tests/test-surfaces.c +++ b/tests/test-surfaces.c @@ -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();