From 6c76e81cb6d08d54ae57b112c46541b6116ea9d3 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Thu, 5 Mar 2020 12:44:45 +0800 Subject: [PATCH] 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: --- gst-libs/gst/vaapi/gstvaapiencoder.c | 37 +++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapiencoder_priv.h | 5 +++ 2 files changed, 42 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index ec71fec2b9..22b0e248e6 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -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) { diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h index 0de0bbfafa..189c3791a7 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h @@ -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 */