shithub: opus

Download patch

ref: 331e9fe0fd37597908279f58e56065b7aedae699
parent: 663a7fe938b3e211ecef57966a14df0d1c9a03f5
author: Jean-Marc Valin <[email protected]>
date: Tue Sep 6 10:30:19 EDT 2011

s/OPUS_CORRUPTED_DATA/OPUS_INVALID_PACKET/

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -2289,7 +2289,7 @@
       {
          data0 = fromOpus(data0);
          if (data0<0)
-            return OPUS_CORRUPTED_DATA;
+            return OPUS_INVALID_PACKET;
       }
       st->end = IMAX(1, st->mode->effEBands-2*(data0>>5));
       LM = (data0>>3)&0x3;
@@ -2297,7 +2297,7 @@
       data++;
       len--;
       if (LM>st->mode->maxLM)
-         return OPUS_CORRUPTED_DATA;
+         return OPUS_INVALID_PACKET;
       if (frame_size < st->mode->shortMdctSize<<LM)
          return OPUS_BUFFER_TOO_SMALL;
       else
--- a/libcelt/opus_defines.h
+++ b/libcelt/opus_defines.h
@@ -66,7 +66,7 @@
 /** An internal error was detected */
 #define OPUS_INTERNAL_ERROR   -3
 /** The data passed (e.g. compressed data to decoder) is corrupted */
-#define OPUS_CORRUPTED_DATA   -4
+#define OPUS_INVALID_PACKET   -4
 /** Invalid/unsupported request number */
 #define OPUS_UNIMPLEMENTED    -5
 /** An encoder or decoder structure is invalid or already freed */
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -295,7 +295,7 @@
             			pcm_ptr[i] = 0;
             	} else {
             	   RESTORE_STACK;
-            	   return OPUS_CORRUPTED_DATA;
+            	   return OPUS_INVALID_PACKET;
             	}
             }
             pcm_ptr += silk_frame_size * st->channels;
@@ -325,7 +325,7 @@
             len -= redundancy_bytes;
             if (len<0) {
                RESTORE_STACK;
-               return OPUS_CORRUPTED_DATA;
+               return OPUS_INVALID_PACKET;
             }
             /* Shrink decoder because of raw bits */
             dec.storage -= redundancy_bytes;
@@ -502,7 +502,7 @@
       if (!self_delimited)
       {
          if (len&0x1)
-            return OPUS_CORRUPTED_DATA;
+            return OPUS_INVALID_PACKET;
          size[0] = last_size = len/2;
       }
       break;
@@ -512,7 +512,7 @@
       bytes = parse_size(data, len, size);
       len -= bytes;
       if (size[0]<0 || size[0] > len)
-         return OPUS_CORRUPTED_DATA;
+         return OPUS_INVALID_PACKET;
       data += bytes;
       last_size = len-size[0];
       break;
@@ -519,12 +519,12 @@
       /* Multiple CBR/VBR frames (from 0 to 120 ms) */
    case 3:
       if (len<1)
-         return OPUS_CORRUPTED_DATA;
+         return OPUS_INVALID_PACKET;
       /* Number of frames encoded in bits 0 to 5 */
       ch = *data++;
       count = ch&0x3F;
       if (count <= 0 || framesize*count > 5760)
-          return OPUS_CORRUPTED_DATA;
+          return OPUS_INVALID_PACKET;
       len--;
       /* Padding flag is bit 6 */
       if (ch&0x40)
@@ -533,7 +533,7 @@
          int p;
          do {
             if (len<=0)
-               return OPUS_CORRUPTED_DATA;
+               return OPUS_INVALID_PACKET;
             p = *data++;
             len--;
             padding += p==255 ? 254: p;
@@ -541,7 +541,7 @@
          len -= padding;
       }
       if (len<0)
-         return OPUS_CORRUPTED_DATA;
+         return OPUS_INVALID_PACKET;
       /* VBR flag is bit 7 */
       cbr = !(ch&0x80);
       if (cbr)
@@ -553,18 +553,18 @@
             bytes = parse_size(data, len, size+i);
             len -= bytes;
             if (size[i]<0 || size[i] > len)
-               return OPUS_CORRUPTED_DATA;
+               return OPUS_INVALID_PACKET;
             data += bytes;
             last_size -= bytes+size[i];
          }
          if (last_size<0)
-            return OPUS_CORRUPTED_DATA;
+            return OPUS_INVALID_PACKET;
       } else if (!self_delimited)
       {
          /* CBR case */
          last_size = len/count;
          if (last_size*count!=len)
-            return OPUS_CORRUPTED_DATA;
+            return OPUS_INVALID_PACKET;
          for (i=0;i<count-1;i++)
             size[i] = last_size;
       }
@@ -576,17 +576,17 @@
       bytes = parse_size(data, len, size+count-1);
       len -= bytes;
       if (size[count-1]<0 || size[count-1] > len)
-         return OPUS_CORRUPTED_DATA;
+         return OPUS_INVALID_PACKET;
       data += bytes;
       /* For CBR packets, apply the size to all the frames. */
       if (cbr)
       {
          if (size[count-1]*count > len)
-            return OPUS_CORRUPTED_DATA;
+            return OPUS_INVALID_PACKET;
          for (i=0;i<count-1;i++)
             size[i] = size[count-1];
       } else if(size[count-1] > last_size)
-         return OPUS_CORRUPTED_DATA;
+         return OPUS_INVALID_PACKET;
    } else
    {
       /* Because it's not encoded explicitly, it's possible the size of the
@@ -594,7 +594,7 @@
           1275.
          Reject them here.*/
       if (last_size > 1275)
-        return OPUS_CORRUPTED_DATA;
+        return OPUS_INVALID_PACKET;
       size[count-1] = last_size;
    }
 
@@ -839,7 +839,7 @@
 	else if (count!=3)
 		return 2;
 	else if (len<2)
-		return OPUS_CORRUPTED_DATA;
+		return OPUS_INVALID_PACKET;
 	else
 		return packet[1]&0x3F;
 }
@@ -851,7 +851,7 @@
 	samples = count*opus_packet_get_samples_per_frame(packet, dec->Fs);
 	/* Can't have more than 120 ms */
 	if (samples*25 > dec->Fs*3)
-		return OPUS_CORRUPTED_DATA;
+		return OPUS_INVALID_PACKET;
 	else
 		return samples;
 }
--- a/src/opus_multistream.c
+++ b/src/opus_multistream.c
@@ -561,7 +561,7 @@
       if (len<=0)
       {
          RESTORE_STACK;
-         return OPUS_CORRUPTED_DATA;
+         return OPUS_INVALID_PACKET;
       }
       ret = opus_decode_native(dec, data, len, buf, frame_size, decode_fec, 1, &packet_offset);
       data += packet_offset;
@@ -574,7 +574,7 @@
       if (s>0 && ret != frame_size)
       {
          RESTORE_STACK;
-         return OPUS_CORRUPTED_DATA;
+         return OPUS_INVALID_PACKET;
       }
       if (ret <= 0)
       {
--- a/src/repacketizer.c
+++ b/src/repacketizer.c
@@ -76,7 +76,7 @@
    } else if ((rp->toc&0xFC) != (data[0]&0xFC))
    {
       /*fprintf(stderr, "toc mismatch: 0x%x vs 0x%x\n", rp->toc, data[0]);*/
-      return OPUS_CORRUPTED_DATA;
+      return OPUS_INVALID_PACKET;
    }
    curr_nb_frames = opus_packet_get_nb_frames(data, len);
 
@@ -83,7 +83,7 @@
    /* Check the 120 ms maximum packet size */
    if ((curr_nb_frames+rp->nb_frames)*rp->framesize > 5760)
    {
-      return OPUS_CORRUPTED_DATA;
+      return OPUS_INVALID_PACKET;
    }
 
    opus_packet_parse(data, len, &tmp_toc, &rp->frames[rp->nb_frames], &rp->len[rp->nb_frames], NULL);