libs: encoder: Add a helper function to check the tile support.

Encoding by tiles separation now is a very common feature for all
relative new codecs, such as HEVC, AV1, and VP9. Just make this
check as a common helper function of the encoder base class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/294>
This commit is contained in:
He Junyan 2020-03-05 12:44:45 +08:00
parent 85bc355019
commit 6c76e81cb6
2 changed files with 42 additions and 0 deletions

View file

@ -1679,6 +1679,43 @@ gst_vaapi_encoder_ensure_max_num_ref_frames (GstVaapiEncoder * encoder,
return TRUE;
}
/**
* gst_vaapi_encoder_ensure_tile_support:
* @encoder: a #GstVaapiEncoder
* @profile: a #GstVaapiProfile
* @entrypoint: a #GstVaapiEntrypoint
*
* This function will query VAConfigAttribEncTileSupport to check
* whether the encoder support tile.
*
* We need to pass the @profile and the @entrypoint, because at the
* moment the encoder base class, still doesn't have them assigned,
* and this function is meant to be called by the derived classes
* while they are configured.
*
* Returns: %TRUE if supported, %FALSE if not.
**/
gboolean
gst_vaapi_encoder_ensure_tile_support (GstVaapiEncoder * encoder,
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint)
{
guint tile = 0;
#if VA_CHECK_VERSION(1,0,1)
VAProfile va_profile;
VAEntrypoint va_entrypoint;
va_profile = gst_vaapi_profile_get_va_profile (profile);
va_entrypoint = gst_vaapi_entrypoint_get_va_entrypoint (entrypoint);
if (!gst_vaapi_get_config_attribute (encoder->display, va_profile,
va_entrypoint, VAConfigAttribEncTileSupport, &tile))
return FALSE;
#endif
return tile > 0;
}
GstVaapiProfile
gst_vaapi_encoder_get_profile (GstVaapiEncoder * encoder)
{

View file

@ -384,6 +384,11 @@ gboolean
gst_vaapi_encoder_ensure_max_num_ref_frames (GstVaapiEncoder * encoder,
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint);
G_GNUC_INTERNAL
gboolean
gst_vaapi_encoder_ensure_tile_support (GstVaapiEncoder * encoder,
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint);
G_END_DECLS
#endif /* GST_VAAPI_ENCODER_PRIV_H */