chroma_type =
gst_vaapi_utils_h265_get_chroma_type (sps->chroma_format_idc,
- sps->bit_depth_luma_minus8 + 8);
+ sps->bit_depth_luma_minus8 + 8, sps->bit_depth_chroma_minus8 + 8);
if (!chroma_type) {
GST_ERROR ("unsupported chroma_format_idc %u", sps->chroma_format_idc);
return GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT;
/** Returns GstVaapiChromaType from H.265 chroma_format_idc value */
GstVaapiChromaType
gst_vaapi_utils_h265_get_chroma_type (guint chroma_format_idc,
- guint luma_bit_depth)
+ guint luma_bit_depth, guint chroma_bit_depth)
{
GstVaapiChromaType chroma_type = (GstVaapiChromaType) 0;
+ guint depth = 0;
+
+ if (luma_bit_depth < 8 || chroma_bit_depth < 8 ||
+ luma_bit_depth > 16 || chroma_bit_depth > 16) {
+ GST_WARNING ("invalid luma_bit_depth or chroma_bit_depth value");
+ return chroma_type;
+ }
+
+ depth = MAX (luma_bit_depth, chroma_bit_depth);
switch (chroma_format_idc) {
case 0:
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV400;
break;
case 1:
- if (luma_bit_depth == 8)
+ if (depth == 8)
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
- else if (luma_bit_depth > 8)
+ else if (depth > 8 && depth <= 10)
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420_10BPP;
break;
case 2:
- if (luma_bit_depth == 8)
+ if (depth == 8)
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV422;
- else if (luma_bit_depth > 8)
+ else if (depth > 8 && depth <= 10)
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV422_10BPP;
break;
case 3:
- if (luma_bit_depth == 8)
+ if (depth == 8)
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV444;
- else if (luma_bit_depth > 8)
+ else if (depth > 8 && depth <= 10)
chroma_type = GST_VAAPI_CHROMA_TYPE_YUV444_10BPP;
break;
default:
- GST_DEBUG ("unsupported chroma_format_idc value");
- chroma_type = (GstVaapiChromaType) 0;
break;
}
+
+ if (chroma_type == (GstVaapiChromaType) 0)
+ GST_DEBUG ("unsupported chroma_format_idc value");
+
return chroma_type;
}
/* Returns GstVaapiChromaType from H.265 chroma_format_idc value */
G_GNUC_INTERNAL
GstVaapiChromaType
-gst_vaapi_utils_h265_get_chroma_type (guint chroma_format_idc, guint luma_bit_depth);
+gst_vaapi_utils_h265_get_chroma_type (guint chroma_format_idc,
+ guint luma_bit_depth, guint chroma_bit_depth);
/* Returns H.265 chroma_format_idc value from GstVaapiChromaType */
G_GNUC_INTERNAL