fdkaacenc: fix output caps in case of implicit signaling and HE-AAC
authorTim-Philipp Müller <tim@centricular.com>
Sat, 22 Oct 2022 10:10:24 +0000 (11:10 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 25 Oct 2022 00:13:04 +0000 (00:13 +0000)
Need to put the actual profile in the output caps otherwise any
capsfilter after the encoder that was used to force the output
profile will fail, such as

  fdkaacenc ! audio/mpeg,stream-format=adts,profile=he-aac-v1 ! ..

because we put profile=lc in there to match the profile signaled
in the ADTS header. This is expressed through the base-profile=lc
in the GStreamer caps though, the profile needs to carry the
'real' profile.

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

subprojects/gst-plugins-bad/ext/fdkaac/gstfdkaacenc.c

index 54e46ba..fff0d76 100644 (file)
@@ -220,12 +220,13 @@ gst_fdkaacenc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
   GstCaps *allowed_caps;
   GstCaps *src_caps;
   AACENC_ERROR err;
-  gint transmux = 0, aot = AOT_AAC_LC;
+  gint transmux = 0;
   gint mpegversion = 4;
+  gint aot = AOT_AAC_LC;
+  const gchar *profile_str = "lc";
   CHANNEL_MODE channel_mode;
   AACENC_InfoStruct enc_info = { 0 };
   gint bitrate, signaling_mode;
-  const gchar *ext_profile;
 
   if (self->enc && !self->is_drained) {
     /* drain */
@@ -259,15 +260,19 @@ gst_fdkaacenc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
       if (strcmp (str, "lc") == 0) {
         GST_DEBUG_OBJECT (self, "using AAC-LC profile for output");
         aot = AOT_AAC_LC;
+        profile_str = "lc";
       } else if (strcmp (str, "he-aac-v1") == 0) {
         GST_DEBUG_OBJECT (self, "using SBR (HE-AACv1) profile for output");
         aot = AOT_SBR;
+        profile_str = "he-aac-v1";
       } else if (strcmp (str, "he-aac-v2") == 0) {
         GST_DEBUG_OBJECT (self, "using PS (HE-AACv2) profile for output");
         aot = AOT_PS;
+        profile_str = "he-aac-v2";
       } else if (strcmp (str, "ld") == 0) {
         GST_DEBUG_OBJECT (self, "using AAC-LD profile for output");
         aot = AOT_ER_AAC_LD;
+        profile_str = "ld";
       }
     }
 
@@ -466,12 +471,8 @@ gst_fdkaacenc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
       enc_info.confSize);
 
   /* The above only parses the "base" profile, which is always going to be LC.
-   * Let's retrieve the extension AOT and set it as our profile in the caps. */
-  ext_profile = gst_codec_utils_aac_get_extension_profile (enc_info.confBuf,
-      enc_info.confSize);
-
-  if (ext_profile)
-    gst_caps_set_simple (src_caps, "profile", G_TYPE_STRING, ext_profile, NULL);
+   * Set actual profile. */
+  gst_caps_set_simple (src_caps, "profile", G_TYPE_STRING, profile_str, NULL);
 
   /* An AAC-LC-only decoder will not decode a stream that uses explicit
    * hierarchical signaling */