diff options
author | U. Artie Eoff <ullysses.a.eoff@intel.com> | 2020-02-04 11:32:54 -0800 |
---|---|---|
committer | U. Artie Eoff <ullysses.a.eoff@intel.com> | 2020-02-05 09:59:43 -0800 |
commit | bc2c483f138087a33750ea40ba1bbff5c6812f35 (patch) | |
tree | 9992a8163f1efdccc55b1cb3344d1e676e24b0c1 /gst-libs | |
parent | c42938fd53b54e8ead9b5dee452a007908c96888 (diff) |
libs: utils: map GstVideoColorimetry to VAAPI VPP
Fallback to VAProcColorStandardExplicit if there is no
1:1 mapping.
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiutils.c | 36 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiutils.h | 5 |
2 files changed, 41 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.c b/gst-libs/gst/vaapi/gstvaapiutils.c index 1169db30..925510d2 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils.c +++ b/gst-libs/gst/vaapi/gstvaapiutils.c @@ -951,3 +951,39 @@ to_GstVaapiBufferMemoryType (guint va_type) return GST_VAAPI_BUFFER_MEMORY_TYPE_USER_PTR; return 0; } + +/** + * from_GstVideoColorimetry: + * @colorimetry: a #GstVideoColorimetry type + * + * VPP: maps the #GstVideoColorimetry type to the VAProcColorStandardType. If + * @colorimetry is NULL or colorimetry->primaries are unknown, then returns + * VAProcColorStandardNone. If there is no 1:1 correlation, then returns + * VAProcColorStandardExplicit. Otherwise, the correlating + * VAProcColorStandardType is returned. + * + * Returns: a VAProcColorStandardType. + **/ +guint +from_GstVideoColorimetry (const GstVideoColorimetry * const colorimetry) +{ + if (!colorimetry + || colorimetry->primaries == GST_VIDEO_COLOR_PRIMARIES_UNKNOWN) + return VAProcColorStandardNone; + if (gst_video_colorimetry_matches (colorimetry, GST_VIDEO_COLORIMETRY_BT709)) + return VAProcColorStandardBT709; + /* NOTE: VAProcColorStandardBT2020 in VAAPI is the same as + * GST_VIDEO_COLORIMETRY_BT2020_10 in gstreamer. */ + if (gst_video_colorimetry_matches (colorimetry, + GST_VIDEO_COLORIMETRY_BT2020_10)) + return VAProcColorStandardBT2020; + if (gst_video_colorimetry_matches (colorimetry, GST_VIDEO_COLORIMETRY_BT601)) + return VAProcColorStandardBT601; + if (gst_video_colorimetry_matches (colorimetry, + GST_VIDEO_COLORIMETRY_SMPTE240M)) + return VAProcColorStandardSMPTE240M; + if (gst_video_colorimetry_matches (colorimetry, GST_VIDEO_COLORIMETRY_SRGB)) + return VAProcColorStandardSRGB; + + return VAProcColorStandardExplicit; +} diff --git a/gst-libs/gst/vaapi/gstvaapiutils.h b/gst-libs/gst/vaapi/gstvaapiutils.h index cf19fb30..b2c0867d 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils.h +++ b/gst-libs/gst/vaapi/gstvaapiutils.h @@ -26,6 +26,7 @@ #define GST_VAAPI_UTILS_H #include <glib.h> +#include <gst/video/video.h> #include <va/va.h> /** calls vaInitialize() redirecting the logging mechanism */ @@ -166,4 +167,8 @@ G_GNUC_INTERNAL guint to_GstVaapiBufferMemoryType (guint va_type); +G_GNUC_INTERNAL +guint +from_GstVideoColorimetry (const GstVideoColorimetry *const colorimetry); + #endif /* GST_VAAPI_UTILS_H */ |