From 55738da35b684b3ebffa3f3510e347cc654b1cd9 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Mon, 12 Dec 2011 18:13:19 +0100 Subject: [PATCH] image: add gst_vaapi_image_format_from_video() helper. --- docs/reference/libs/libs-sections.txt | 1 + gst-libs/gst/vaapi/Makefile.am | 1 + gst-libs/gst/vaapi/gstvaapiimageformat.c | 29 +++++++++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapiimageformat.h | 4 ++++ gst/vaapi/gstvaapiconvert.c | 21 +-------------------- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/docs/reference/libs/libs-sections.txt b/docs/reference/libs/libs-sections.txt index 722d6b4..d271a26 100644 --- a/docs/reference/libs/libs-sections.txt +++ b/docs/reference/libs/libs-sections.txt @@ -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 diff --git a/gst-libs/gst/vaapi/Makefile.am b/gst-libs/gst/vaapi/Makefile.am index 94995ec..7677174 100644 --- a/gst-libs/gst/vaapi/Makefile.am +++ b/gst-libs/gst/vaapi/Makefile.am @@ -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) \ diff --git a/gst-libs/gst/vaapi/gstvaapiimageformat.c b/gst-libs/gst/vaapi/gstvaapiimageformat.c index 9218c68..cac410a 100644 --- a/gst-libs/gst/vaapi/gstvaapiimageformat.c +++ b/gst-libs/gst/vaapi/gstvaapiimageformat.c @@ -234,6 +234,35 @@ gst_vaapi_image_format_from_fourcc(guint32 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 * diff --git a/gst-libs/gst/vaapi/gstvaapiimageformat.h b/gst-libs/gst/vaapi/gstvaapiimageformat.h index f83e3ba..da45341 100644 --- a/gst-libs/gst/vaapi/gstvaapiimageformat.h +++ b/gst-libs/gst/vaapi/gstvaapiimageformat.h @@ -23,6 +23,7 @@ #define GST_VAAPI_IMAGE_FORMAT_H #include +#include 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); diff --git a/gst/vaapi/gstvaapiconvert.c b/gst/vaapi/gstvaapiconvert.c index 919eaba..a0db024 100644 --- a/gst/vaapi/gstvaapiconvert.c +++ b/gst/vaapi/gstvaapiconvert.c @@ -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; -- 2.7.4