From 3a7c1ddb3cc341f19b75267dec9b818d9a444e0a Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 13 Apr 2022 05:56:59 +0200 Subject: [PATCH] vah264enc: Move rate-control enum to encoder class helper. Since it's a common enumeration used, as user setting property, for most of codecs. Part-of: --- subprojects/gst-plugins-bad/sys/va/gstvaencoder.c | 33 +++++++++++++++++++++++ subprojects/gst-plugins-bad/sys/va/gstvaencoder.h | 3 +++ subprojects/gst-plugins-bad/sys/va/gstvah264enc.c | 32 ++-------------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c index f37b8d4..f2c3c31 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.c @@ -1141,3 +1141,36 @@ gst_va_encode_picture_free (GstVaEncodePicture * pic) g_slice_free (GstVaEncodePicture, pic); } + +/** + * GstVaEncoderRateControl: + * + * Since: 1.22 + */ +GType +gst_va_encoder_rate_control_get_type (void) +{ + static gsize type = 0; + static const GEnumValue values[] = { + {VA_RC_CBR, "Constant Bitrate", "cbr"}, + {VA_RC_VBR, "Variable Bitrate", "vbr"}, + {VA_RC_VCM, "Video Conferencing Mode (Non HRD compliant)", "vcm"}, + {VA_RC_CQP, "Constant Quantizer", "cqp"}, + /* {VA_RC_VBR_CONSTRAINED, "VBR with peak rate higher than average bitrate", */ + /* "vbr-constrained"}, */ + /* {VA_RC_ICQ, "Intelligent Constant Quality", "icq"}, */ + /* {VA_RC_MB, "Macroblock based rate control", "mb"}, */ + /* {VA_RC_CFS, "Constant Frame Size", "cfs"}, */ + /* {VA_RC_PARALLEL, "Parallel BRC", "parallel"}, */ + /* {VA_RC_QVBR, "Quality defined VBR", "qvbr"}, */ + /* {VA_RC_AVBR, "Average VBR", "avbr"}, */ + {0, NULL, NULL} + }; + + if (g_once_init_enter (&type)) { + GType _type = g_enum_register_static ("GstVaEncoderRateControl", values); + g_once_init_leave (&type, _type); + } + + return type; +} diff --git a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.h b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.h index 3dd9a1a..bb142eb 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvaencoder.h +++ b/subprojects/gst-plugins-bad/sys/va/gstvaencoder.h @@ -44,6 +44,9 @@ struct _GstVaEncodePicture VABufferID coded_buffer; }; +#define GST_TYPE_VA_ENCODER_RATE_CONTROL (gst_va_encoder_rate_control_get_type()) +GType gst_va_encoder_rate_control_get_type (void); + gboolean gst_va_encoder_is_open (GstVaEncoder * self); gboolean gst_va_encoder_open (GstVaEncoder * self, VAProfile profile, diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c index 653c26c..02f91df 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c @@ -403,34 +403,6 @@ _rate_control_get_name (guint32 rc_mode) } /** - * GstVaH264EncRateControl: - * - * Since: 1.22 - */ -static GType -gst_va_h264_enc_rate_control_get_type (void) -{ - static gsize type = 0; - - static const GEnumValue values[] = { - {VA_RC_CBR, "Constant Bitrate", "cbr"}, - {VA_RC_VBR, "Variable Bitrate", "vbr"}, - {VA_RC_VCM, "Video Conferencing Mode (Non HRD compliant)", "vcm"}, - {VA_RC_CQP, "Constant Quantizer", "cqp"}, - {0, NULL, NULL} - }; - - if (g_once_init_enter (&type)) { - GType _type; - - _type = g_enum_register_static ("GstVaH264EncRateControl", values); - g_once_init_leave (&type, _type); - } - - return type; -} - -/** * GstVaH264Mbbrc: * * Since: 1.22 @@ -4464,7 +4436,7 @@ gst_va_h264_enc_class_init (gpointer g_klass, gpointer class_data) */ properties[PROP_RATE_CONTROL] = g_param_spec_enum ("rate-control", "rate control mode", "The desired rate control mode for the encoder", - gst_va_h264_enc_rate_control_get_type (), VA_RC_CBR, + GST_TYPE_VA_ENCODER_RATE_CONTROL, VA_RC_CBR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT); properties[PROP_DEVICE_PATH] = g_param_spec_string ("device-path", @@ -4473,7 +4445,7 @@ gst_va_h264_enc_class_init (gpointer g_klass, gpointer class_data) g_object_class_install_properties (object_class, N_PROPERTIES, properties); - gst_type_mark_as_plugin_api (gst_va_h264_enc_rate_control_get_type (), 0); + gst_type_mark_as_plugin_api (gst_va_encoder_rate_control_get_type (), 0); gst_type_mark_as_plugin_api (gst_va_h264_enc_mbbrc_get_type (), 0); } -- 2.7.4