gst/typefind/gsttypefindfunctions.c: In case we can't find the required number of...
authorTim-Philipp Müller <tim@centricular.net>
Tue, 7 Feb 2006 16:16:41 +0000 (16:16 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Tue, 7 Feb 2006 16:16:41 +0000 (16:16 +0000)
Original commit message from CVS:
* gst/typefind/gsttypefindfunctions.c: (mp3_type_find):
In case we can't find the required number of consecutive
mpeg audio frames to positively identify an MPEG audio
stream, check if there's at least a valid mpeg audio
frame right at offset 0 and if so suggest mpeg/audio
caps with a very low probability (#153004).

ChangeLog
gst/typefind/gsttypefindfunctions.c

index 514e9ac..ef9b250 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-02-07  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst/typefind/gsttypefindfunctions.c: (mp3_type_find):
+         In case we can't find the required number of consecutive
+         mpeg audio frames to positively identify an MPEG audio
+         stream, check if there's at least a valid mpeg audio
+         frame right at offset 0 and if so suggest mpeg/audio
+         caps with a very low probability (#153004).
+
 2006-02-07  Andy Wingo  <wingo@pobox.com>
 
        * gst/tcp/gsttcpclientsrc.c (gst_tcp_client_src_create): Switch to
index 4ce0db1..e8d8250 100644 (file)
@@ -553,7 +553,7 @@ mp3_type_find (GstTypeFind * tf, gpointer unused)
     guint64 start_off = (try == 0) ? 0 : length / 2;
 
     if (try != 0 && start_off == 0)
-      return;
+      break;
 
     size = 0;
     skipped = 0;
@@ -660,8 +660,9 @@ mp3_type_find (GstTypeFind * tf, gpointer unused)
                 G_TYPE_INT, layer, NULL);
             gst_type_find_suggest (tf, probability, caps);
             gst_caps_unref (caps);
+            return;
           }
-          return;
+          goto no_luck;
         }
       }
       data++;
@@ -669,6 +670,25 @@ mp3_type_find (GstTypeFind * tf, gpointer unused)
       size--;
     }
   }
+
+no_luck:
+
+  /* no luck so far, let's see if there's a valid header right at the start */
+  data = gst_type_find_peek (tf, 0, 4); /* use min. frame size? */
+  if (data) {
+    GstCaps *caps;
+    guint layer;
+
+    if (mp3_type_frame_length_from_header (GST_READ_UINT32_BE (data),
+            &layer, NULL, NULL, NULL, NULL, 0) != 0) {
+      caps = gst_caps_copy (MP3_CAPS);
+      gst_structure_set (gst_caps_get_structure (caps, 0), "layer",
+          G_TYPE_INT, layer, NULL);
+      GST_LOG ("possible mpeg audio layer %u frame at offset 0", layer);
+      gst_type_find_suggest (tf, GST_TYPE_FIND_POSSIBLE - 10, caps);
+      gst_caps_unref (caps);
+    }
+  }
 }
 
 /*** audio/x-ac3 ***/