From 973b879f95588581d860ade43a348d7cd73a9346 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Sat, 11 Jul 2020 23:09:59 +0800 Subject: [PATCH] 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: --- gst-libs/gst/vaapi/gstvaapiencoder_vp9.c | 34 ++++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapiencoder_vp9.h | 4 +++ 2 files changed, 38 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c index e9b711b9e7..fcad2e6934 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.c @@ -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; +} diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.h b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.h index b66290b7a8..6459c01b33 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_vp9.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_vp9.h @@ -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