typefinding: add AAC profile to ADTS caps
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Wed, 10 Mar 2010 13:32:53 +0000 (13:32 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Mon, 12 Apr 2010 14:04:23 +0000 (15:04 +0100)
This looks at the AAC profile for ADTS streams and adds the profile as a
string in the corresponding caps.

Profile is the actual profile, base-profile denotes the minimum codec
requirements to decode this stream. In this case they're always the
same, but they may differ e.g. in case of certain HE-AAC streams that
can be partially decoded by LC decoders (with loss of quality of course)
if no suitable HE-AAC decoder is available.

Fixes #612312.

gst/typefind/gsttypefindfunctions.c

index fecf7bf..887dc2f 100644 (file)
@@ -650,6 +650,8 @@ static GstStaticCaps aac_caps = GST_STATIC_CAPS ("audio/mpeg, "
 static void
 aac_type_find (GstTypeFind * tf, gpointer unused)
 {
+  /* LUT to convert the AudioObjectType from the ADTS header to a string */
+  static const gchar profile_to_string[][5] = { "main", "lc", "ssr", "ltp" };
   DataScanCtx c = { 0, NULL, 0 };
 
   while (c.offset < AAC_AMOUNT) {
@@ -680,14 +682,17 @@ aac_type_find (GstTypeFind * tf, gpointer unused)
 
       snc = GST_READ_UINT16_BE (c.data + len);
       if ((snc & 0xfff6) == 0xfff0) {
-        gint mpegversion;
+        gint mpegversion, profile;
 
         mpegversion = (c.data[1] & 0x08) ? 2 : 4;
+        profile = c.data[2] >> 6;
         GST_DEBUG ("Found second ADTS-%d syncpoint at offset 0x%"
             G_GINT64_MODIFIER "x, framelen %u", mpegversion, c.offset, len);
         gst_type_find_suggest_simple (tf, GST_TYPE_FIND_LIKELY, "audio/mpeg",
             "framed", G_TYPE_BOOLEAN, FALSE,
             "mpegversion", G_TYPE_INT, mpegversion,
+            "base-profile", G_TYPE_STRING, profile_to_string[profile],
+            "profile", G_TYPE_STRING, profile_to_string[profile],
             "stream-type", G_TYPE_STRING, "adts", NULL);
         break;
       }