From 8ffe11a9dff2b8995bd28b0ecd3b93436ab22d9b Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 24 Jul 2013 11:37:23 +0200 Subject: [PATCH] libs: add gst_vaapi_video_format_from_va_fourcc() helper. Add gst_vaapi_video_format_from_va_fourcc() helper that converts from a VA fourcc value to a suitable GstVideoFormat. --- gst-libs/gst/vaapi/video-format.c | 24 ++++++++++++++++++++++++ gst-libs/gst/vaapi/video-format.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/gst-libs/gst/vaapi/video-format.c b/gst-libs/gst/vaapi/video-format.c index 68198a4..e3bbecb 100644 --- a/gst-libs/gst/vaapi/video-format.c +++ b/gst-libs/gst/vaapi/video-format.c @@ -287,6 +287,30 @@ gst_vaapi_video_format_to_caps(GstVideoFormat format) } /** + * gst_vaapi_video_format_from_va_fourcc: + * @fourcc: a FOURCC value + * + * Converts a VA fourcc into the corresponding #GstVideoFormat. If no + * matching fourcc was found, then zero is returned. + * + * Return value: the #GstVideoFormat corresponding to the VA @fourcc + */ +GstVideoFormat +gst_vaapi_video_format_from_va_fourcc(guint32 fourcc) +{ + const GstVideoFormatMap *m; + + /* Note: VA fourcc values are now standardized and shall represent + a unique format. The associated VAImageFormat is just a hint to + determine RGBA component ordering */ + for (m = gst_vaapi_video_formats; m->format; m++) { + if (m->va_format.fourcc == fourcc) + return m->format; + } + return GST_VIDEO_FORMAT_UNKNOWN; +} + +/** * gst_vaapi_video_format_from_va_format: * @va_format: a #VAImageFormat * diff --git a/gst-libs/gst/vaapi/video-format.h b/gst-libs/gst/vaapi/video-format.h index a3d7d5b..84e9c75 100644 --- a/gst-libs/gst/vaapi/video-format.h +++ b/gst-libs/gst/vaapi/video-format.h @@ -47,6 +47,9 @@ GstCaps * gst_vaapi_video_format_to_caps(GstVideoFormat format); GstVideoFormat +gst_vaapi_video_format_from_va_fourcc(guint32 fourcc); + +GstVideoFormat gst_vaapi_video_format_from_va_format(const VAImageFormat *va_format); const VAImageFormat * -- 2.7.4