libs: util: vpx: add get_chroma_format_idc for VP9

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/380>
This commit is contained in:
He Junyan 2020-07-11 23:17:02 +08:00 committed by Víctor Manuel Jáquez Leal
parent 973b879f95
commit ff829c660b
2 changed files with 34 additions and 0 deletions

View file

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

View file

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