[xiph-cvs] cvs commit: ices/src mp3.c

Brendan brendan at xiph.org
Sun Mar 16 12:20:12 PST 2003



brendan     03/03/16 15:20:11

  Modified:    src      mp3.c
  Log:
  Ignore free bit rate frames, since I don't have the tools to parse them, they
  seem to be more rare than simple corrupt headers, and they are likely to
  induce disaster when they hit the LAME decoder.

Revision  Changes    Path
1.27      +8 -8      ices/src/mp3.c

Index: mp3.c
===================================================================
RCS file: /cvs/ice/ices/src/mp3.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- mp3.c	16 Mar 2003 08:32:34 -0000	1.26
+++ mp3.c	16 Mar 2003 20:20:11 -0000	1.27
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: mp3.c,v 1.26 2003/03/16 08:32:34 brendan Exp $
+ * $Id: mp3.c,v 1.27 2003/03/16 20:20:11 brendan Exp $
  */
 
 #include "definitions.h"
@@ -99,7 +99,7 @@
   ices_mp3_in_t* mp3_data = (ices_mp3_in_t*) source->data;
   unsigned char *buffer;
   mp3_header_t mh;
-  size_t len;
+  size_t len, framelen;
   int rc = 0;
   int off = 0;
 
@@ -141,8 +141,9 @@
 
     /* we must be able to read at least 4 bytes of header */
     while (mp3_data->len - mp3_data->pos >= 4) {
-      if ((rc = mp3_parse_frame(buffer + mp3_data->pos, &mh))) {
-        size_t framelen;
+      /* don't bother with free bit rate MP3s - they are so rare that a parse error is more likely */
+      if ((rc = mp3_parse_frame(buffer + mp3_data->pos, &mh))
+          && (framelen = mp3_frame_length (&mh))) {
         mp3_header_t next_header;
 
         source->samplerate = mh.samplerate;
@@ -154,8 +155,6 @@
         }
 
         /* check next frame if possible */
-        if ((framelen = mp3_frame_length (&mh)) <= 0)
-          break;
         if (mp3_fill_buffer (source, framelen + 4) <= 0)
           break;
 
@@ -386,8 +385,9 @@
   header->layer = 4 - ((buf[1] >> 1) & 0x3);
   header->emphasis = (buf[3]) & 0x3;
 
-  if ((bitrate_idx == 0xF) || (samplerate_idx == 0x3)
-      || (header->layer == 4) || (header->emphasis == 2))
+  /* free bit rate (idx == 0) is legal, but ices can't handle it reliably */
+  if (bitrate_idx == 0xF || samplerate_idx == 0x3
+      || header->layer == 4 || header->emphasis == 2)
     return 0;
 
   header->error_protection = !(buf[1] & 0x1);

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list