libs: encoder: h265: Support MAIN 4:4:4 10 profile.

Using Y410 as the input of the encoder can generate main_444_10 bit
streams.
This commit is contained in:
He Junyan 2020-04-02 15:14:15 +08:00
parent 80b6e006bc
commit 026c01875c
5 changed files with 32 additions and 3 deletions

View file

@ -667,7 +667,8 @@ is_chroma_type_supported (GstVaapiEncoder * encoder)
if (cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV420 && if (cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV420 &&
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV422 && cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV422 &&
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV420_10BPP && 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 &&
cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV444_10BPP)
goto unsupported; goto unsupported;
if (!get_config_attribute (encoder, VAConfigAttribRTFormat, &format)) if (!get_config_attribute (encoder, VAConfigAttribRTFormat, &format))

View file

@ -305,7 +305,8 @@ bs_write_profile_tier_level (GstBitWriter * bs,
/* additional indications specified for general_profile_idc from 4~10 */ /* additional indications specified for general_profile_idc from 4~10 */
if (seq_param->general_profile_idc == 4) { if (seq_param->general_profile_idc == 4) {
/* In A.3.5, Format range extensions profiles. /* In A.3.5, Format range extensions profiles.
Just support main444 profile now, may add more profiles when needed. */ Just support main444 and main444-10 profile now, may add more profiles
when needed. */
switch (profile) { switch (profile) {
case GST_VAAPI_PROFILE_H265_MAIN_444: case GST_VAAPI_PROFILE_H265_MAIN_444:
/* max_12bit_constraint_flag */ /* max_12bit_constraint_flag */
@ -327,6 +328,26 @@ bs_write_profile_tier_level (GstBitWriter * bs,
/* lower_bit_rate_constraint_flag */ /* lower_bit_rate_constraint_flag */
WRITE_UINT32 (bs, 1, 1); WRITE_UINT32 (bs, 1, 1);
break; break;
case GST_VAAPI_PROFILE_H265_MAIN_444_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, 0, 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: default:
GST_WARNING ("do not support the profile: %s of range extensions", GST_WARNING ("do not support the profile: %s of range extensions",
gst_vaapi_profile_get_va_name (profile)); gst_vaapi_profile_get_va_name (profile));
@ -1087,6 +1108,8 @@ ensure_profile (GstVaapiEncoderH265 * encoder)
profile = GST_VAAPI_PROFILE_H265_MAIN10; profile = GST_VAAPI_PROFILE_H265_MAIN10;
else if (format == GST_VIDEO_FORMAT_VUYA) else if (format == GST_VIDEO_FORMAT_VUYA)
profile = GST_VAAPI_PROFILE_H265_MAIN_444; profile = GST_VAAPI_PROFILE_H265_MAIN_444;
else if (format == GST_VIDEO_FORMAT_Y410)
profile = GST_VAAPI_PROFILE_H265_MAIN_444_10;
encoder->profile = profile; encoder->profile = profile;
encoder->profile_idc = gst_vaapi_utils_h265_get_profile_idc (profile); encoder->profile_idc = gst_vaapi_utils_h265_get_profile_idc (profile);

View file

@ -339,6 +339,8 @@ gst_vaapi_profile_from_codec_data_h265 (GstBuffer * buffer)
return GST_VAAPI_PROFILE_H265_MAIN_422_10; return GST_VAAPI_PROFILE_H265_MAIN_422_10;
case 5: case 5:
return GST_VAAPI_PROFILE_H265_MAIN_444; return GST_VAAPI_PROFILE_H265_MAIN_444;
case 6:
return GST_VAAPI_PROFILE_H265_MAIN_444_10;
} }
return 0; return 0;
} }

View file

@ -41,6 +41,7 @@ static const struct map gst_vaapi_h265_profile_map[] = {
{ GST_VAAPI_PROFILE_H265_MAIN10, "main-10" }, { GST_VAAPI_PROFILE_H265_MAIN10, "main-10" },
{ GST_VAAPI_PROFILE_H265_MAIN_STILL_PICTURE, "main-still-picture" }, { GST_VAAPI_PROFILE_H265_MAIN_STILL_PICTURE, "main-still-picture" },
{ GST_VAAPI_PROFILE_H265_MAIN_444, "main-444" }, { GST_VAAPI_PROFILE_H265_MAIN_444, "main-444" },
{ GST_VAAPI_PROFILE_H265_MAIN_444_10, "main-444-10" },
{ 0, NULL } { 0, NULL }
/* *INDENT-ON* */ /* *INDENT-ON* */
}; };
@ -267,6 +268,8 @@ gst_vaapi_utils_h265_get_profile_idc (GstVaapiProfile profile)
case GST_VAAPI_PROFILE_H265_MAIN_422_10: case GST_VAAPI_PROFILE_H265_MAIN_422_10:
/* Fall through */ /* Fall through */
case GST_VAAPI_PROFILE_H265_MAIN_444: case GST_VAAPI_PROFILE_H265_MAIN_444:
/* Fall through */
case GST_VAAPI_PROFILE_H265_MAIN_444_10:
profile_idc = GST_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSION; profile_idc = GST_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSION;
break; break;
default: default:

View file

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