From 09397fa0d85ffdc5aff819a72a700c7e2b4031a5 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Tue, 9 Jul 2013 15:44:35 +0200 Subject: [PATCH] plugins: port to new video format API. --- gst/vaapi/gstvaapidownload.c | 16 ++++++++-------- gst/vaapi/gstvaapiuploader.c | 16 +++++++--------- gst/vaapi/gstvaapivideomemory.c | 8 +------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/gst/vaapi/gstvaapidownload.c b/gst/vaapi/gstvaapidownload.c index 4f0d20dc6c..4988800cc4 100644 --- a/gst/vaapi/gstvaapidownload.c +++ b/gst/vaapi/gstvaapidownload.c @@ -79,7 +79,7 @@ struct _GstVaapiDownload { GstCaps *allowed_caps; TransformSizeCache transform_size_cache[2]; GstVaapiVideoPool *images; - GstVaapiImageFormat image_format; + GstVideoFormat image_format; guint image_width; guint image_height; unsigned int images_reset : 1; @@ -252,7 +252,7 @@ gst_vaapidownload_init(GstVaapiDownload *download) download->allowed_caps = NULL; download->images = NULL; download->images_reset = FALSE; - download->image_format = (GstVaapiImageFormat)0; + download->image_format = GST_VIDEO_FORMAT_UNKNOWN; download->image_width = 0; download->image_height = 0; @@ -293,11 +293,11 @@ gst_vaapidownload_stop(GstBaseTransform *trans) return TRUE; } -static GstVaapiImageFormat +static GstVideoFormat get_surface_format(GstVaapiSurface *surface) { GstVaapiImage *image; - GstVaapiImageFormat format = GST_VAAPI_IMAGE_NV12; + GstVideoFormat format = GST_VIDEO_FORMAT_NV12; /* XXX: NV12 is assumed by default */ image = gst_vaapi_surface_derive_image(surface); @@ -313,7 +313,7 @@ gst_vaapidownload_update_src_caps(GstVaapiDownload *download, GstBuffer *buffer) { GstVaapiVideoMeta *meta; GstVaapiSurface *surface; - GstVaapiImageFormat format; + GstVideoFormat format; GstPad *srcpad; GstCaps *in_caps, *out_caps; @@ -334,7 +334,7 @@ gst_vaapidownload_update_src_caps(GstVaapiDownload *download, GstBuffer *buffer) return FALSE; } - out_caps = gst_vaapi_image_format_get_caps(format); + out_caps = gst_video_format_to_caps(format); if (!out_caps) { GST_WARNING("failed to create caps from format %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS(format)); @@ -485,10 +485,10 @@ static gboolean gst_vaapidownload_ensure_image_pool(GstVaapiDownload *download, GstCaps *caps) { GstStructure * const structure = gst_caps_get_structure(caps, 0); - GstVaapiImageFormat format; + GstVideoFormat format; gint width, height; - format = gst_vaapi_image_format_from_caps(caps); + format = gst_video_format_from_caps(caps); gst_structure_get_int(structure, "width", &width); gst_structure_get_int(structure, "height", &height); diff --git a/gst/vaapi/gstvaapiuploader.c b/gst/vaapi/gstvaapiuploader.c index 8413fe679f..814e73e19a 100755 --- a/gst/vaapi/gstvaapiuploader.c +++ b/gst/vaapi/gstvaapiuploader.c @@ -141,10 +141,10 @@ ensure_allowed_caps(GstVaapiUploader *uploader) for (i = 0; i < n_structures; i++) { GstStructure * const structure = gst_caps_get_structure(image_caps, i); GstVaapiImage *image; - GstVaapiImageFormat format; + GstVideoFormat format; - format = gst_vaapi_image_format_from_structure(structure); - if (!format) + format = gst_video_format_from_structure(structure); + if (format == GST_VIDEO_FORMAT_UNKNOWN) continue; image = gst_vaapi_image_new(priv->display, format, WIDTH, HEIGHT); if (!image) @@ -309,7 +309,7 @@ gst_vaapi_uploader_ensure_caps( { GstVaapiUploaderPrivate *priv; GstVaapiImage *image; - GstVaapiImageFormat vaformat; + GstVideoFormat format; GstVideoInfo vi; g_return_val_if_fail(GST_VAAPI_IS_UPLOADER(uploader), FALSE); @@ -323,19 +323,17 @@ gst_vaapi_uploader_ensure_caps( priv = uploader->priv; priv->direct_rendering = 0; - /* Translate from Gst video format to VA image format */ + /* Strip out non-YUV formats */ if (!gst_video_info_from_caps(&vi, src_caps)) return FALSE; if (!GST_VIDEO_INFO_IS_YUV(&vi)) return FALSE; - vaformat = gst_vaapi_image_format_from_video(GST_VIDEO_INFO_FORMAT(&vi)); - if (!vaformat) - return FALSE; + format = GST_VIDEO_INFO_FORMAT(&vi); /* Check if we can alias source and output buffers (same data_size) */ image = gst_vaapi_video_pool_get_object(priv->images); if (image) { - if (gst_vaapi_image_get_format(image) == vaformat && + if (gst_vaapi_image_get_format(image) == format && gst_vaapi_image_is_linear(image) && gst_vaapi_image_get_data_size(image) == GST_VIDEO_INFO_SIZE(&vi)) priv->direct_rendering = 1; diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c index db27b08f15..31cf259fd5 100644 --- a/gst/vaapi/gstvaapivideomemory.c +++ b/gst/vaapi/gstvaapivideomemory.c @@ -37,13 +37,7 @@ GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapivideomemory); static GstVaapiImage * new_image(GstVaapiDisplay *display, const GstVideoInfo *vip) { - GstVaapiImageFormat format; - - format = gst_vaapi_image_format_from_video(GST_VIDEO_INFO_FORMAT(vip)); - if (!format) - return NULL; - - return gst_vaapi_image_new(display, format, + return gst_vaapi_image_new(display, GST_VIDEO_INFO_FORMAT(vip), GST_VIDEO_INFO_WIDTH(vip), GST_VIDEO_INFO_HEIGHT(vip)); }