image: add gst_vaapi_image_format_from_video() helper.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 12 Dec 2011 17:13:19 +0000 (18:13 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 12 Dec 2011 17:32:29 +0000 (18:32 +0100)
docs/reference/libs/libs-sections.txt
gst-libs/gst/vaapi/Makefile.am
gst-libs/gst/vaapi/gstvaapiimageformat.c
gst-libs/gst/vaapi/gstvaapiimageformat.h
gst/vaapi/gstvaapiconvert.c

index 722d6b4..d271a26 100644 (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
index 94995ec..7677174 100644 (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)                         \
index 9218c68..cac410a 100644 (file)
@@ -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
  *
index f83e3ba..da45341 100644 (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);
 
index 919eaba..a0db024 100644 (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;