s/OPUS_CORRUPTED_DATA/OPUS_INVALID_PACKET/

This commit is contained in:
Jean-Marc Valin 2011-09-06 14:30:19 -04:00
parent 663a7fe938
commit 331e9fe0fd
5 changed files with 24 additions and 24 deletions

View file

@ -2289,7 +2289,7 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
{
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 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
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

View file

@ -66,7 +66,7 @@ extern "C" {
/** 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 */

View file

@ -295,7 +295,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
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 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
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 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
if (!self_delimited)
{
if (len&0x1)
return OPUS_CORRUPTED_DATA;
return OPUS_INVALID_PACKET;
size[0] = last_size = len/2;
}
break;
@ -512,19 +512,19 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
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;
/* 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 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
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 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
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 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
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 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
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 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
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 @@ int opus_packet_get_nb_frames(const unsigned char packet[], int len)
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 @@ int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char pack
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;
}

View file

@ -561,7 +561,7 @@ static int opus_multistream_decode_native(
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 @@ static int opus_multistream_decode_native(
if (s>0 && ret != frame_size)
{
RESTORE_STACK;
return OPUS_CORRUPTED_DATA;
return OPUS_INVALID_PACKET;
}
if (ret <= 0)
{

View file

@ -76,14 +76,14 @@ int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, int l
} 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);
/* 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);