gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18354 - in Extractor: . src/plugins


From: gnunet
Subject: [GNUnet-SVN] r18354 - in Extractor: . src/plugins
Date: Mon, 28 Nov 2011 17:17:24 +0100

Author: grothoff
Date: 2011-11-28 17:17:24 +0100 (Mon, 28 Nov 2011)
New Revision: 18354

Modified:
   Extractor/AUTHORS
   Extractor/ChangeLog
   Extractor/src/plugins/mp3_extractor.c
Log:
Changes mp3 extractor to discard frames with frame_size <= 0.
Obviously, this is quite hacky, but:
  A) Files with 0 bitrate are rare.
  B) At least it won't trigger as easily on random binary data

Also, makes mp3 extractor check for at least 2 valid frames in a row.
That is, if frame size is not 0, then the next frame header after the
first one we found must also be valid, otherwise this is not
considered to be an mp3 file. This is the best i can do with such a
short and simple patch, further improvements are only possible with
something more complex, i think.




Modified: Extractor/AUTHORS
===================================================================
--- Extractor/AUTHORS   2011-11-28 16:17:01 UTC (rev 18353)
+++ Extractor/AUTHORS   2011-11-28 16:17:24 UTC (rev 18354)
@@ -57,6 +57,7 @@
 Vasil Dimov <address@hidden>
 Pavol Rusnak <address@hidden>
 Vidyut Samanta <address@hidden>
+LRN
 
 Translations:
 German - Karl Eichwalder <address@hidden>

Modified: Extractor/ChangeLog
===================================================================
--- Extractor/ChangeLog 2011-11-28 16:17:01 UTC (rev 18353)
+++ Extractor/ChangeLog 2011-11-28 16:17:24 UTC (rev 18354)
@@ -1,3 +1,6 @@
+Mon Nov 28 17:16:16 CET 2011
+       Reduce false-positives in MP3 extractor file format detection. -LRN
+
 Mon Nov 28 17:15:59 CET 2011
        Improved winsock2 detection. -LRN
 

Modified: Extractor/src/plugins/mp3_extractor.c
===================================================================
--- Extractor/src/plugins/mp3_extractor.c       2011-11-28 16:17:01 UTC (rev 
18353)
+++ Extractor/src/plugins/mp3_extractor.c       2011-11-28 16:17:24 UTC (rev 
18354)
@@ -207,6 +207,21 @@
       frame_size =
         144 * bitrate / (sample_rate ? sample_rate : 1) +
         ((header >> MPA_PADDING_SHIFT) & 0x1);
+      if (frame_size <= 0)
+       {
+         /* Technically, bitrate can be 0. However, but this particular
+          * extractor is incapable of correctly processing 0-bitrate files
+          * anyway. And bitrate == 0 might also mean that this is just a
+          * random binary sequence, which is far more likely to be true.
+          *
+          * amatus suggests to use a different algorithm and parse significant
+          * part of the file, then count the number of correct mpeg frames.
+          * If the the percentage of correct frames is below a threshold,
+          * then this is not an mpeg file at all.
+          */
+         frames -= 1;
+         break;
+       }
       avg_bps += bitrate / 1000;
 
       pos += frame_size - 4;
@@ -221,7 +236,7 @@
     }
   while ((header & MPA_SYNC_MASK) == MPA_SYNC_MASK);
 
-  if (!frames)
+  if (frames < 2)
     return 0;                /*no valid frames */
   ADDR ("audio/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
   avg_bps = avg_bps / frames;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]