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

@ -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;
}