libs: encoder: vp9: Add allowed_profiles.

We need the allowed_profiles to store the allowed profiles in down
stream's caps.
Command line like:
  vaapivp9enc ! capsfilter caps=video/x-vp9,profile="{ (string)1, \
    (string)3 }"
We need to store GST_VAAPI_PROFILE_VP9_1 and GST_VAAPI_PROFILE_VP9_3
in this list.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/380>
This commit is contained in:
He Junyan 2020-07-11 23:09:59 +08:00 committed by Víctor Manuel Jáquez Leal
parent ba58557c14
commit 973b879f95
2 changed files with 38 additions and 0 deletions

View file

@ -104,6 +104,7 @@ struct _GstVaapiEncoderVP9
GstVaapiSurfaceProxy *ref_list[GST_VP9_REF_FRAMES]; /* reference list */
guint ref_list_idx; /* next free slot in ref_list */
GstVaapiEntrypoint entrypoint;
GArray *allowed_profiles;
/* Bitrate contral parameters, CPB = Coded Picture Buffer */
guint bitrate_bits; /* bitrate (bits) */
@ -560,6 +561,19 @@ gst_vaapi_encoder_vp9_init (GstVaapiEncoderVP9 * encoder)
memset (encoder->ref_list, 0,
G_N_ELEMENTS (encoder->ref_list) * sizeof (encoder->ref_list[0]));
encoder->ref_list_idx = 0;
encoder->allowed_profiles = NULL;
}
static void
gst_vaapi_encoder_vp9_finalize (GObject * object)
{
GstVaapiEncoderVP9 *const encoder = GST_VAAPI_ENCODER_VP9 (object);
if (encoder->allowed_profiles)
g_array_unref (encoder->allowed_profiles);
G_OBJECT_CLASS (gst_vaapi_encoder_vp9_parent_class)->finalize (object);
}
/**
@ -678,6 +692,7 @@ gst_vaapi_encoder_vp9_class_init (GstVaapiEncoderVP9Class * klass)
object_class->set_property = gst_vaapi_encoder_vp9_set_property;
object_class->get_property = gst_vaapi_encoder_vp9_get_property;
object_class->finalize = gst_vaapi_encoder_vp9_finalize;
properties[ENCODER_VP9_PROP_RATECONTROL] =
g_param_spec_enum ("rate-control",
@ -763,3 +778,22 @@ gst_vaapi_encoder_vp9_new (GstVaapiDisplay * display)
{
return g_object_new (GST_TYPE_VAAPI_ENCODER_VP9, "display", display, NULL);
}
/**
* gst_vaapi_encoder_vp9_set_allowed_profiles:
* @encoder: a #GstVaapiEncoderVP9
* @profiles: a #GArray of all allowed #GstVaapiProfile.
*
* Set the all allowed profiles for the encoder.
*
* Return value: %TRUE on success
*/
gboolean
gst_vaapi_encoder_vp9_set_allowed_profiles (GstVaapiEncoderVP9 * encoder,
GArray * profiles)
{
g_return_val_if_fail (profiles != 0, FALSE);
encoder->allowed_profiles = g_array_ref (profiles);
return TRUE;
}

View file

@ -43,6 +43,10 @@ gst_vaapi_encoder_vp9_get_type (void) G_GNUC_CONST;
GstVaapiEncoder *
gst_vaapi_encoder_vp9_new (GstVaapiDisplay * display);
gboolean
gst_vaapi_encoder_vp9_set_allowed_profiles (GstVaapiEncoderVP9 * encoder,
GArray * profiles);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiEncoderVP9, gst_object_unref)
G_END_DECLS