libs: encoder: h265: Add support for MAIN 4:2:2 10 profile.

Using YUY2 as the input of the encoder can generate main 4:2:2 bit
streams and using Y210 as the input of the encoder can generate main
4:2:2 10 bit streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/334>
This commit is contained in:
He Junyan 2020-04-03 14:53:40 +08:00 committed by Víctor Manuel Jáquez Leal
parent 5c67bdaf63
commit 8486f82d98
4 changed files with 29 additions and 4 deletions

View file

@ -668,7 +668,8 @@ is_chroma_type_supported (GstVaapiEncoder * encoder)
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV422 &&
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV420_10BPP &&
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV444 &&
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV444_10BPP)
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV444_10BPP &&
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV422_10BPP)
goto unsupported;
if (!get_config_attribute (encoder, VAConfigAttribRTFormat, &format))

View file

@ -305,8 +305,8 @@ bs_write_profile_tier_level (GstBitWriter * bs,
/* additional indications specified for general_profile_idc from 4~10 */
if (seq_param->general_profile_idc == 4) {
/* In A.3.5, Format range extensions profiles.
Just support main444 and main444-10 profile now, may add more profiles
when needed. */
Just support main444, main444-10 and main422-10 profile now, may add
more profiles when needed. */
switch (profile) {
case GST_VAAPI_PROFILE_H265_MAIN_444:
/* max_12bit_constraint_flag */
@ -348,6 +348,26 @@ bs_write_profile_tier_level (GstBitWriter * bs,
/* lower_bit_rate_constraint_flag */
WRITE_UINT32 (bs, 1, 1);
break;
case GST_VAAPI_PROFILE_H265_MAIN_422_10:
/* max_12bit_constraint_flag */
WRITE_UINT32 (bs, 1, 1);
/* max_10bit_constraint_flag */
WRITE_UINT32 (bs, 1, 1);
/* max_8bit_constraint_flag */
WRITE_UINT32 (bs, 0, 1);
/* max_422chroma_constraint_flag */
WRITE_UINT32 (bs, 1, 1);
/* max_420chroma_constraint_flag */
WRITE_UINT32 (bs, 0, 1);
/* max_monochrome_constraint_flag */
WRITE_UINT32 (bs, 0, 1);
/* intra_constraint_flag */
WRITE_UINT32 (bs, 0, 1);
/* one_picture_only_constraint_flag */
WRITE_UINT32 (bs, 0, 1);
/* lower_bit_rate_constraint_flag */
WRITE_UINT32 (bs, 1, 1);
break;
default:
GST_WARNING ("do not support the profile: %s of range extensions",
gst_vaapi_profile_get_va_name (profile));
@ -1110,6 +1130,8 @@ ensure_profile (GstVaapiEncoderH265 * encoder)
profile = GST_VAAPI_PROFILE_H265_MAIN_444;
else if (format == GST_VIDEO_FORMAT_Y410)
profile = GST_VAAPI_PROFILE_H265_MAIN_444_10;
else if (format == GST_VIDEO_FORMAT_Y210 || format == GST_VIDEO_FORMAT_YUY2)
profile = GST_VAAPI_PROFILE_H265_MAIN_422_10;
encoder->profile = profile;
encoder->profile_idc = gst_vaapi_utils_h265_get_profile_idc (profile);

View file

@ -42,6 +42,7 @@ static const struct map gst_vaapi_h265_profile_map[] = {
{ GST_VAAPI_PROFILE_H265_MAIN_STILL_PICTURE, "main-still-picture" },
{ GST_VAAPI_PROFILE_H265_MAIN_444, "main-444" },
{ GST_VAAPI_PROFILE_H265_MAIN_444_10, "main-444-10" },
{ GST_VAAPI_PROFILE_H265_MAIN_422_10, "main-422-10" },
{ 0, NULL }
/* *INDENT-ON* */
};
@ -445,6 +446,7 @@ gst_vaapi_utils_h265_get_chroma_format_idc (GstVaapiChromaType chroma_type)
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:

View file

@ -55,7 +55,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_vaapi_h265_encode_debug);
/* *INDENT-OFF* */
static const char gst_vaapiencode_h265_src_caps_str[] =
GST_CODEC_CAPS ", "
"profile = (string) { main, main-10, main-444, main-444-10 }";
"profile = (string) { main, main-10, main-444, main-444-10, main-422-10 }";
/* *INDENT-ON* */
/* *INDENT-OFF* */