From ff829c660be288ee09846ad28493db64aea58c09 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Sat, 11 Jul 2020 23:17:02 +0800 Subject: libs: util: vpx: add get_chroma_format_idc for VP9 Part-of: --- gst-libs/gst/vaapi/gstvaapiutils_vpx.c | 31 +++++++++++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapiutils_vpx.h | 3 +++ 2 files changed, 34 insertions(+) (limited to 'gst-libs') diff --git a/gst-libs/gst/vaapi/gstvaapiutils_vpx.c b/gst-libs/gst/vaapi/gstvaapiutils_vpx.c index 2882c2f0..d6bdd816 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils_vpx.c +++ b/gst-libs/gst/vaapi/gstvaapiutils_vpx.c @@ -21,6 +21,7 @@ */ #include "gstvaapiutils_vpx.h" +#include "gstvaapisurface.h" struct map { @@ -86,3 +87,33 @@ gst_vaapi_utils_vp9_get_profile_string (GstVaapiProfile profile) return m ? m->name : NULL; } + +/** Returns VP9 chroma_format_idc value from GstVaapiChromaType */ +guint +gst_vaapi_utils_vp9_get_chroma_format_idc (guint chroma_type) +{ + guint chroma_format_idc; + + switch (chroma_type) { + case GST_VAAPI_CHROMA_TYPE_YUV400: + chroma_format_idc = 0; + break; + case GST_VAAPI_CHROMA_TYPE_YUV420: + case GST_VAAPI_CHROMA_TYPE_YUV420_10BPP: + chroma_format_idc = 1; + break; + case GST_VAAPI_CHROMA_TYPE_YUV422: + case GST_VAAPI_CHROMA_TYPE_YUV422_10BPP: + chroma_format_idc = 2; + break; + case GST_VAAPI_CHROMA_TYPE_YUV444: + case GST_VAAPI_CHROMA_TYPE_YUV444_10BPP: + chroma_format_idc = 3; + break; + default: + GST_DEBUG ("unsupported GstVaapiChromaType value"); + chroma_format_idc = 1; + break; + } + return chroma_format_idc; +} diff --git a/gst-libs/gst/vaapi/gstvaapiutils_vpx.h b/gst-libs/gst/vaapi/gstvaapiutils_vpx.h index a83510ce..acead5a5 100644 --- a/gst-libs/gst/vaapi/gstvaapiutils_vpx.h +++ b/gst-libs/gst/vaapi/gstvaapiutils_vpx.h @@ -35,6 +35,9 @@ gst_vaapi_utils_vp9_get_profile_from_string (const gchar * str); const gchar * gst_vaapi_utils_vp9_get_profile_string (GstVaapiProfile profile); +guint +gst_vaapi_utils_vp9_get_chroma_format_idc (guint chroma_type); + G_END_DECLS #endif /* GST_VAAPI_UTILS_VPX_H */ -- cgit v1.2.3