changeset 897:44a922a4a591 trunk

[svn] - fix validation of mpeg2 files, by ccr.
author nenolod
date Sat, 24 Mar 2007 17:31:14 -0700
parents f0846bdd9de6
children 06ecbb1e3dbb
files ChangeLog src/madplug/plugin.c
diffstat 2 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 24 09:44:44 2007 -0700
+++ b/ChangeLog	Sat Mar 24 17:31:14 2007 -0700
@@ -1,3 +1,11 @@
+2007-03-24 16:44:44 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [1892]
+  - small cleanups.
+  
+  trunk/src/madplug/decoder.c |   36 ++++++++++++++++++++----------------
+  1 file changed, 20 insertions(+), 16 deletions(-)
+
+
 2007-03-24 16:29:41 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
   revision [1890]
   - now wma can handle wide characters in metadata.
--- a/src/madplug/plugin.c	Sat Mar 24 09:44:44 2007 -0700
+++ b/src/madplug/plugin.c	Sat Mar 24 17:31:14 2007 -0700
@@ -198,7 +198,7 @@
     layer = (head >> 17) & 0x3;
     if (!layer)
         return FALSE; /* 00 = reserved */
-    layer = 3 - layer;
+    layer = 4 - layer;
 
     /* check if bitrate index bits (12-15) are acceptable */
     bitIndex = (head >> 12) & 0xf;
@@ -243,7 +243,10 @@
             if (bitRate > 192)
                 return FALSE;
         } else {
-            /* any other mode with bitrates 32-56 and 80 */
+            /* any other mode with bitrates 32-56 and 80.
+             * NOTICE! this check is not entirely correct, but I think
+             * it is sufficient in most cases.
+             */
             if (((bitRate >= 32 && bitRate <= 56) || bitRate == 80))
                 return FALSE;
         }
@@ -252,8 +255,11 @@
     /* calculate approx. frame size */
     padding = (head >> 9) & 1;
     sampleRate = mp3_samplerate_table[version][sampleIndex];
-    *frameSize = (144 * bitRate * 1000) / (sampleRate + padding);
-        
+    if (layer == 1)
+        *frameSize = ((12 * bitRate * 1000 / sampleRate) + padding) * 4; 
+    else
+        *frameSize = (144 * bitRate * 1000) / (sampleRate + padding);
+    
     /* check if bits 16 - 19 are all set (MPEG 1 Layer I, not protected?) */
     if (((head >> 19) & 1) == 1 &&
         ((head >> 17) & 3) == 3 && ((head >> 16) & 1) == 1)