vah264enc: Move rate-control enum to encoder class helper.
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 13 Apr 2022 03:56:59 +0000 (05:56 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 16 Apr 2022 11:11:51 +0000 (11:11 +0000)
Since it's a common enumeration used, as user setting property, for
most of codecs.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2169>

subprojects/gst-plugins-bad/sys/va/gstvaencoder.c
subprojects/gst-plugins-bad/sys/va/gstvaencoder.h
subprojects/gst-plugins-bad/sys/va/gstvah264enc.c

index f37b8d4..f2c3c31 100644 (file)
@@ -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;
+}
index 3dd9a1a..bb142eb 100644 (file)
@@ -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,
index 653c26c..02f91df 100644 (file)
@@ -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);
 }