Commit 9b635526 authored by Gwenole Beauchesne's avatar Gwenole Beauchesne

image: add gst_vaapi_image_format_from_video() helper.

parent 6175e876
......@@ -377,6 +377,7 @@ gst_vaapi_image_format_is_yuv
gst_vaapi_image_format
gst_vaapi_image_format_from_caps
gst_vaapi_image_format_from_fourcc
gst_vaapi_image_format_from_video
gst_vaapi_image_format_get_va_format
gst_vaapi_image_format_get_caps
gst_vaapi_image_format_get_score
......
......@@ -138,6 +138,7 @@ libgstvaapi_@GST_MAJORMINOR@includedir = \
libgstvaapi_@GST_MAJORMINOR@_la_CFLAGS = \
-I$(top_srcdir)/gst-libs \
$(GST_BASE_CFLAGS) \
$(GST_VIDEO_CFLAGS) \
$(GST_CFLAGS) \
$(LIBAVCODEC_CFLAGS) \
$(LIBVA_CFLAGS) \
......
......@@ -233,6 +233,35 @@ gst_vaapi_image_format_from_fourcc(guint32 fourcc)
return (GstVaapiImageFormat)fourcc;
}
/**
* gst_vaapi_image_format_from_video:
* @format: a #GstVideoFormat
*
* Converts a #GstVideoFormat into the corresponding
* #GstVaapiImageFormat. If the image format cannot be represented by
* #GstVaapiImageFormat, then zero is returned.
*
* Return value: the #GstVaapiImageFormat describing the video format
*/
GstVaapiImageFormat
gst_vaapi_image_format_from_video(GstVideoFormat format)
{
GstVaapiImageFormat va_format;
switch (format) {
case GST_VIDEO_FORMAT_NV12: va_format = GST_VAAPI_IMAGE_NV12; break;
case GST_VIDEO_FORMAT_YV12: va_format = GST_VAAPI_IMAGE_YV12; break;
case GST_VIDEO_FORMAT_I420: va_format = GST_VAAPI_IMAGE_I420; break;
case GST_VIDEO_FORMAT_AYUV: va_format = GST_VAAPI_IMAGE_AYUV; break;
case GST_VIDEO_FORMAT_ARGB: va_format = GST_VAAPI_IMAGE_ARGB; break;
case GST_VIDEO_FORMAT_RGBA: va_format = GST_VAAPI_IMAGE_RGBA; break;
case GST_VIDEO_FORMAT_ABGR: va_format = GST_VAAPI_IMAGE_ABGR; break;
case GST_VIDEO_FORMAT_BGRA: va_format = GST_VAAPI_IMAGE_BGRA; break;
default: va_format = (GstVaapiImageFormat)0; break;
}
return va_format;
}
/**
* gst_vaapi_image_format_get_va_format:
* @format: a #GstVaapiImageFormat
......
......@@ -23,6 +23,7 @@
#define GST_VAAPI_IMAGE_FORMAT_H
#include <gst/gstvalue.h>
#include <gst/video/video.h>
G_BEGIN_DECLS
......@@ -75,6 +76,9 @@ gst_vaapi_image_format_from_caps(GstCaps *caps);
GstVaapiImageFormat
gst_vaapi_image_format_from_fourcc(guint32 fourcc);
GstVaapiImageFormat
gst_vaapi_image_format_from_video(GstVideoFormat format);
const VAImageFormat *
gst_vaapi_image_format_get_va_format(GstVaapiImageFormat format);
......
......@@ -496,25 +496,6 @@ gst_vaapiconvert_ensure_surface_pool(GstVaapiConvert *convert, GstCaps *caps)
return TRUE;
}
static GstVaapiImageFormat
gst_video_format_to_vaapi_image_format(GstVideoFormat vformat)
{
GstVaapiImageFormat vaformat;
switch (vformat) {
case GST_VIDEO_FORMAT_NV12: vaformat = GST_VAAPI_IMAGE_NV12; break;
case GST_VIDEO_FORMAT_YV12: vaformat = GST_VAAPI_IMAGE_YV12; break;
case GST_VIDEO_FORMAT_I420: vaformat = GST_VAAPI_IMAGE_I420; break;
case GST_VIDEO_FORMAT_AYUV: vaformat = GST_VAAPI_IMAGE_AYUV; break;
case GST_VIDEO_FORMAT_ARGB: vaformat = GST_VAAPI_IMAGE_ARGB; break;
case GST_VIDEO_FORMAT_RGBA: vaformat = GST_VAAPI_IMAGE_RGBA; break;
case GST_VIDEO_FORMAT_ABGR: vaformat = GST_VAAPI_IMAGE_ABGR; break;
case GST_VIDEO_FORMAT_BGRA: vaformat = GST_VAAPI_IMAGE_BGRA; break;
default: vaformat = (GstVaapiImageFormat)0; break;
}
return vaformat;
}
static void
gst_vaapiconvert_ensure_direct_rendering_caps(
GstVaapiConvert *convert,
......@@ -546,7 +527,7 @@ gst_vaapiconvert_ensure_direct_rendering_caps(
return;
if (!gst_video_format_is_yuv(vformat))
return;
vaformat = gst_video_format_to_vaapi_image_format(vformat);
vaformat = gst_vaapi_image_format_from_video(vformat);
if (!vaformat)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment