Author: fejj
Date: 2008-01-28 18:07:06 -0500 (Mon, 28 Jan 2008)
New Revision: 94193

Modified:
   trunk/moon/src/pipeline.cpp
Log:
don't scan up to 16k, only scan up to MPEG_FRAME_LENGTH_MAX bytes, which is 
only 2881 bytes

Modified: trunk/moon/src/pipeline.cpp
===================================================================
--- trunk/moon/src/pipeline.cpp 2008-01-28 23:05:48 UTC (rev 94192)
+++ trunk/moon/src/pipeline.cpp 2008-01-28 23:07:06 UTC (rev 94193)
@@ -1326,6 +1326,8 @@
        return len;
 }
 
+#define MPEG_FRAME_LENGTH_MAX (((144 * 160000) / 8000) + 1)
+
 #define mpeg_frame_size(mpeg) (((mpeg)->bit_rate * (mpeg)->channels * 
mpeg_block_size (mpeg)) / (mpeg)->sample_rate)
 
 #define mpeg_frame_duration(mpeg) (48000000 / (mpeg)->sample_rate) * 8
@@ -1661,7 +1663,7 @@
                        
                        /* found a 0xff byte... could be a frame header */
                        if ((inptr + 3) < inend) {
-                               if (mpeg_parse_header (&mpeg, inptr) && 
mpeg.bit_rate && mpeg.sample_rate) {
+                               if (mpeg_parse_header (&mpeg, inptr) && 
mpeg.bit_rate) {
                                        /* validate that this is really an MPEG 
frame header by calculating the
                                         * position of the next frame header 
and checking that it looks like a
                                         * valid frame header too */
@@ -1669,7 +1671,7 @@
                                        pos = source->GetPosition ();
                                        
                                        if (source->Seek (start + offset + len, 
SEEK_SET) && source->ReadAll (hdr, 4)
-                                           && mpeg_parse_header (&mpeg, hdr) 
&& mpeg.bit_rate && mpeg.sample_rate) {
+                                           && mpeg_parse_header (&mpeg, hdr) 
&& mpeg.bit_rate) {
                                                /* everything checks out A-OK */
                                                return start + offset;
                                        }
@@ -1693,8 +1695,8 @@
                        memmove (buf, inptr, n);
                }
                
-               /* if we scan more than 16k, this surely isn't an mp3... */
-       } while (offset < 16384);
+               /* if we scan more than 'MPEG_FRAME_LENGTH_MAX' bytes, this is 
unlikely to be an mpeg audio stream */
+       } while (offset < MPEG_FRAME_LENGTH_MAX);
        
        return -1;
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to