libs: utils: map GstVideoColorimetry to VAAPI VPP

Fallback to VAProcColorStandardExplicit if there is no
1:1 mapping.
This commit is contained in:
U. Artie Eoff 2020-02-04 11:32:54 -08:00
parent c42938fd53
commit bc2c483f13
2 changed files with 41 additions and 0 deletions

View file

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

View file

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