fdkaacenc: Add support for enabling afterburner
authorSanchayan Maity <sanchayan@asymptotic.io>
Sat, 23 Jan 2021 13:05:12 +0000 (18:35 +0530)
committerSanchayan Maity <sanchayan@asymptotic.io>
Sat, 29 Oct 2022 10:27:52 +0000 (15:57 +0530)
This is an additional quality parameter. In the default configuration this
quality switch is deactivated because it would cause a workload increase
which might be significant. If workload is not an issue in the application
it can be recommended to activate this feature.

subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json
subprojects/gst-plugins-bad/ext/fdkaac/gstfdkaacenc.c
subprojects/gst-plugins-bad/ext/fdkaac/gstfdkaacenc.h

index d21c72f..8704ee9 100644 (file)
                     }
                 },
                 "properties": {
+                    "afterburner": {
+                        "blurb": "Additional quality control parameter. Can cause workload increase.",
+                        "conditionally-available": false,
+                        "construct": false,
+                        "construct-only": false,
+                        "controllable": false,
+                        "default": "false",
+                        "mutable": "null",
+                        "readable": true,
+                        "type": "gboolean",
+                        "writable": true
+                    },
                     "bitrate": {
                         "blurb": "Target Audio Bitrate (0 = fixed value based on  sample rate and channel count)",
                         "conditionally-available": false,
index fff0d76..af1b873 100644 (file)
@@ -30,7 +30,7 @@
 
 /* TODO:
  * - Add support for other AOT / profiles
- * - Expose more properties, e.g. afterburner and vbr
+ * - Expose more properties, e.g. vbr
  * - Signal encoder delay
  * - LOAS / LATM support
  */
@@ -38,6 +38,7 @@
 enum
 {
   PROP_0,
+  PROP_AFTERBURNER,
   PROP_BITRATE
 };
 
@@ -109,6 +110,9 @@ gst_fdkaacenc_set_property (GObject * object, guint prop_id,
     case PROP_BITRATE:
       self->bitrate = g_value_get_int (value);
       break;
+    case PROP_AFTERBURNER:
+      self->afterburner = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -126,6 +130,9 @@ gst_fdkaacenc_get_property (GObject * object, guint prop_id,
     case PROP_BITRATE:
       g_value_set_int (value, self->bitrate);
       break;
+    case PROP_AFTERBURNER:
+      g_value_set_boolean (value, self->afterburner);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -427,6 +434,16 @@ gst_fdkaacenc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
     return FALSE;
   }
 
+  if (self->afterburner) {
+    if ((err =
+            aacEncoder_SetParam (self->enc, AACENC_AFTERBURNER,
+                1)) != AACENC_OK) {
+      GST_ERROR_OBJECT (self, "Could not enable afterburner: %d", err);
+      return FALSE;
+    }
+
+    GST_INFO_OBJECT (self, "Afterburner enabled");
+  }
   if ((err = aacEncEncode (self->enc, NULL, NULL, NULL, NULL)) != AACENC_OK) {
     GST_ERROR_OBJECT (self, "Unable to initialize encoder: %d", err);
     return FALSE;
@@ -613,6 +630,7 @@ gst_fdkaacenc_init (GstFdkAacEnc * self)
   self->bitrate = DEFAULT_BITRATE;
   self->enc = NULL;
   self->is_drained = TRUE;
+  self->afterburner = FALSE;
 
   gst_audio_encoder_set_drainable (GST_AUDIO_ENCODER (self), TRUE);
 }
@@ -642,6 +660,17 @@ gst_fdkaacenc_class_init (GstFdkAacEncClass * klass)
           0, G_MAXINT, DEFAULT_BITRATE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  /**
+   * GstFdkAacEnc:afterburner:
+   *
+   * Afterburner - Quality Parameter.
+   *
+   * Since: 1.22
+   */
+  g_object_class_install_property (object_class, PROP_AFTERBURNER,
+      g_param_spec_boolean ("afterburner", "Afterburner - Quality Parameter",
+          "Additional quality control parameter. Can cause workload increase.",
+          FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   gst_element_class_add_static_pad_template (element_class, &sink_template);
   gst_element_class_add_static_pad_template (element_class, &src_template);
 
index 997f603..bd0863f 100644 (file)
@@ -51,6 +51,8 @@ struct _GstFdkAacEnc {
   gboolean need_reorder;
   const GstAudioChannelPosition *aac_positions;
   gboolean is_drained;
+
+  gboolean afterburner;
 };
 
 struct _GstFdkAacEncClass {