gst/typefind/gsttypefindfunctions.c: Lower the probability of mp3 typefinding functio...
authorEdward Hervey <bilboed@bilboed.com>
Thu, 2 Nov 2006 17:26:03 +0000 (17:26 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Thu, 2 Nov 2006 17:26:03 +0000 (17:26 +0000)
Original commit message from CVS:
* gst/typefind/gsttypefindfunctions.c: (mp3_type_find_at_offset):
Lower the probability of mp3 typefinding functions if we don't find a
valid mp3 header at the start of the file.
Closes #369482

ChangeLog
gst/typefind/gsttypefindfunctions.c

index 2fe7bd952ef6be30dd9b1f4098372677655bee66..8681d5ef477ee4f3104f36728f6c4a20ce0aff13 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-02  Edward Hervey  <edward@fluendo.com>
+
+       * gst/typefind/gsttypefindfunctions.c: (mp3_type_find_at_offset):
+       Lower the probability of mp3 typefinding functions if we don't find a
+       valid mp3 header at the start of the file.
+       Closes #369482
+
 2006-11-02  Wim Taymans  <wim@fluendo.com>
 
        * ext/theora/gsttheoradec.h:
index c3f8410a33f7c0953fb7fe60b1d904b0c20ddffd..cff87ed8c9c5b5f333998dbad423ae4db2db9e8e 100644 (file)
@@ -620,6 +620,7 @@ static GstStaticCaps mp3_caps = GST_STATIC_CAPS ("audio/mpeg, "
 #define GST_MP3_TYPEFIND_TRY_HEADERS (5)
 #define GST_MP3_TYPEFIND_TRY_SYNC (GST_TYPE_FIND_MAXIMUM * 100) /* 10kB */
 #define GST_MP3_TYPEFIND_SYNC_SIZE (2048)
+#define GST_MP3_WRONG_HEADER (10)
 
 static void
 mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
@@ -631,6 +632,7 @@ mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
   guint64 skipped;
   gint last_free_offset = -1;
   gint last_free_framelen = -1;
+  gboolean headerstart = TRUE;
 
   *found_layer = 0;
   *found_prob = 0;
@@ -685,6 +687,10 @@ mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
             last_free_framelen = -1;
           }
 
+          /* Mark the fact that we didn't find a valid header at the beginning */
+          if (found == 0)
+            headerstart = FALSE;
+
           GST_LOG ("%d. header at offset %" G_GUINT64_FORMAT
               " (0x%" G_GINT64_MODIFIER "x) was not an mp3 header "
               "(possibly-free: %s)", found + 1, start_off + offset,
@@ -719,6 +725,9 @@ mp3_type_find_at_offset (GstTypeFind * tf, guint64 start_off,
             (GST_MP3_TYPEFIND_TRY_SYNC - skipped) /
             GST_MP3_TYPEFIND_TRY_HEADERS / GST_MP3_TYPEFIND_TRY_SYNC;
 
+        if (!headerstart
+            && ((probability - GST_MP3_WRONG_HEADER) > GST_TYPE_FIND_MINIMUM))
+          probability -= GST_MP3_WRONG_HEADER;
         if (probability < GST_TYPE_FIND_MINIMUM)
           probability = GST_TYPE_FIND_MINIMUM;
         if (start_off > 0)