From ef5c6d351f04ff5d711912971d77c4be75963800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 25 Jul 2013 11:56:07 +0100 Subject: [PATCH] typefinding: don't detect mp3 based on just a few bits Remove dodgy code that detects mp3 with as little as a valid frame sync at the beginning. This was only used in some unit tests in -good where there were only a few bytes after the id3 tag. We now require at least two frame headers. Fixes mis-dection of text files with UTF-16 LE BOM as mp3. https://bugzilla.gnome.org/show_bug.cgi?id=681368 --- gst/typefind/gsttypefindfunctions.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 71b9234a47..5c4f958fdf 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -1462,14 +1462,14 @@ mp3_type_find (GstTypeFind * tf, gpointer unused) goto suggest; } - /* 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 && mp3_type_frame_length_from_header (GST_READ_UINT32_BE (data), - &layer, NULL, NULL, NULL, NULL, 0) != 0) { - if (prob == 0) - prob = GST_TYPE_FIND_POSSIBLE - 10; - else - prob = MAX (GST_TYPE_FIND_POSSIBLE - 10, prob + 10); + /* a valid header right at the start makes it more likely + * that this is actually plain mpeg-1 audio */ + if (prob > 0) { + data = gst_type_find_peek (tf, 0, 4); /* use min. frame size? */ + if (data && mp3_type_frame_length_from_header (GST_READ_UINT32_BE (data), + &layer, NULL, NULL, NULL, NULL, 0) != 0) { + prob = MIN (prob + 10, GST_TYPE_FIND_MAXIMUM); + } } if (prob > 0)