image: add gst_vaapi_image_format_from_video() helper.

This commit is contained in:
Gwenole Beauchesne 2011-12-12 18:13:19 +01:00
parent efcdec08fb
commit 55738da35b
5 changed files with 36 additions and 20 deletions

View file

@ -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

View file

@ -143,6 +143,7 @@ libgstvaapi_@GST_MAJORMINOR@_la_CFLAGS = \
-I$(top_srcdir)/gst-libs \
$(GST_BASE_CFLAGS) \
$(GST_BASEVIDEO_CFLAGS) \
$(GST_VIDEO_CFLAGS) \
$(GST_CFLAGS) \
$(LIBAVCODEC_CFLAGS) \
$(LIBVA_CFLAGS) \

View file

@ -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

View file

@ -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);

View file

@ -542,25 +542,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,
@ -592,7 +573,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;