libs: encoder: h265: No need to check hw_max_profile.

In h265, higher profile idc number does not mean better compression
performance and may be not compatible with the lower profile idc.
So, it is not suitable to find the heighest idc for hw to ensure the
compatibility.

On the other side, when the entrypoint of the selected profile is valid,
it means the hw really support this profile, no need to check it again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/349>
This commit is contained in:
He Junyan 2020-07-02 23:33:31 +08:00
parent daecc5bfa1
commit 579aa4cab1

View file

@ -98,7 +98,6 @@ struct _GstVaapiEncoderH265
GstVaapiEntrypoint entrypoint;
guint8 profile_idc;
guint8 max_profile_idc;
guint8 hw_max_profile_idc;
guint8 level_idc;
guint32 idr_period;
guint32 init_qp;
@ -1058,37 +1057,6 @@ _check_vps_sps_pps_status (GstVaapiEncoderH265 * encoder,
}
}
/* Determines the largest supported profile by the underlying hardware */
static gboolean
ensure_hw_profile_limits (GstVaapiEncoderH265 * encoder)
{
GstVaapiDisplay *const display = GST_VAAPI_ENCODER_DISPLAY (encoder);
GArray *profiles;
guint i, profile_idc, max_profile_idc;
if (encoder->hw_max_profile_idc)
return TRUE;
profiles = gst_vaapi_display_get_encode_profiles (display);
if (!profiles)
return FALSE;
max_profile_idc = 0;
for (i = 0; i < profiles->len; i++) {
const GstVaapiProfile profile =
g_array_index (profiles, GstVaapiProfile, i);
profile_idc = gst_vaapi_utils_h265_get_profile_idc (profile);
if (!profile_idc)
continue;
if (max_profile_idc < profile_idc)
max_profile_idc = profile_idc;
}
g_array_unref (profiles);
encoder->hw_max_profile_idc = max_profile_idc;
return TRUE;
}
/* Derives the profile supported by the underlying hardware */
static gboolean
ensure_hw_profile (GstVaapiEncoderH265 * encoder)
@ -2300,12 +2268,6 @@ ensure_profile_tier_level (GstVaapiEncoderH265 * encoder)
return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
}
/* Check HW constraints */
if (!ensure_hw_profile_limits (encoder))
return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
if (encoder->profile_idc > encoder->hw_max_profile_idc)
return GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE;
/* Ensure bitrate if not set already and derive the right level to use */
ensure_bitrate (encoder);