plugins: upgrade to newer APIs (GstVideoInfo based helpers).

Use GstVideoInfo and gst_video_info_from_caps() helper wherever possible.
Also use the newly added gst_vaapi_image_format_from_structure() helper
in GstVaapiUploader::ensure_allowed_caps().
This commit is contained in:
Gwenole Beauchesne 2013-03-20 12:57:18 +01:00
parent 4fa2315557
commit 13c5d3244b
2 changed files with 14 additions and 31 deletions

View file

@ -627,31 +627,26 @@ gst_vaapisink_set_caps(GstBaseSink *base_sink, GstCaps *caps)
{
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
GstStructure * const structure = gst_caps_get_structure(caps, 0);
GstVideoInfo vi;
guint win_width, win_height;
gint video_width, video_height, video_par_n = 1, video_par_d = 1;
#if USE_DRM
if (sink->display_type == GST_VAAPI_DISPLAY_TYPE_DRM)
return TRUE;
#endif
if (!structure)
if (!gst_video_info_from_caps(&vi, caps))
return FALSE;
if (!gst_structure_get_int(structure, "width", &video_width))
return FALSE;
if (!gst_structure_get_int(structure, "height", &video_height))
return FALSE;
sink->video_width = video_width;
sink->video_height = video_height;
sink->video_width = GST_VIDEO_INFO_WIDTH(&vi);
sink->video_height = GST_VIDEO_INFO_HEIGHT(&vi);
sink->video_par_n = GST_VIDEO_INFO_PAR_N(&vi);
sink->video_par_d = GST_VIDEO_INFO_PAR_D(&vi);
GST_DEBUG("video pixel-aspect-ratio %d/%d",
sink->video_par_n, sink->video_par_d);
if (gst_structure_has_name(structure, "video/x-raw-yuv"))
sink->use_video_raw = TRUE;
gst_video_parse_caps_pixel_aspect_ratio(caps, &video_par_n, &video_par_d);
sink->video_par_n = video_par_n;
sink->video_par_d = video_par_d;
GST_DEBUG("video pixel-aspect-ratio %d/%d", video_par_n, video_par_d);
gst_caps_replace(&sink->caps, caps);
if (!gst_vaapisink_ensure_display(sink))

View file

@ -148,11 +148,8 @@ ensure_allowed_caps(GstVaapiUploader *uploader)
GstStructure * const structure = gst_caps_get_structure(image_caps, i);
GstVaapiImage *image;
GstVaapiImageFormat format;
guint32 fourcc;
if (!gst_structure_get_fourcc(structure, "format", &fourcc))
continue;
format = gst_vaapi_image_format_from_fourcc(fourcc);
format = gst_vaapi_image_format_from_structure(structure);
if (!format)
continue;
image = gst_vaapi_image_new(priv->display, format, WIDTH, HEIGHT);
@ -320,9 +317,7 @@ gst_vaapi_uploader_ensure_caps(
GstVaapiUploaderPrivate *priv;
GstVaapiImage *image;
GstVaapiImageFormat vaformat;
GstVideoFormat vformat;
GstStructure *structure;
gint width, height;
GstVideoInfo vi;
g_return_val_if_fail(GST_VAAPI_IS_UPLOADER(uploader), FALSE);
g_return_val_if_fail(src_caps != NULL, FALSE);
@ -335,18 +330,12 @@ gst_vaapi_uploader_ensure_caps(
priv = uploader->priv;
priv->direct_rendering = 0;
structure = gst_caps_get_structure(src_caps, 0);
if (!structure)
return FALSE;
gst_structure_get_int(structure, "width", &width);
gst_structure_get_int(structure, "height", &height);
/* Translate from Gst video format to VA image format */
if (!gst_video_format_parse_caps(src_caps, &vformat, NULL, NULL))
if (!gst_video_info_from_caps(&vi, src_caps))
return FALSE;
if (!gst_video_format_is_yuv(vformat))
if (!GST_VIDEO_INFO_IS_YUV(&vi))
return FALSE;
vaformat = gst_vaapi_image_format_from_video(vformat);
vaformat = gst_vaapi_image_format_from_video(GST_VIDEO_INFO_FORMAT(&vi));
if (!vaformat)
return FALSE;
@ -355,8 +344,7 @@ gst_vaapi_uploader_ensure_caps(
if (image) {
if (gst_vaapi_image_get_format(image) == vaformat &&
gst_vaapi_image_is_linear(image) &&
(gst_vaapi_image_get_data_size(image) ==
gst_video_format_get_size(vformat, width, height)))
gst_vaapi_image_get_data_size(image) == GST_VIDEO_INFO_SIZE(&vi))
priv->direct_rendering = 1;
gst_vaapi_video_pool_put_object(priv->images, image);
}