s/OPUS_CORRUPTED_DATA/OPUS_INVALID_PACKET/
This commit is contained in:
parent
663a7fe938
commit
331e9fe0fd
5 changed files with 24 additions and 24 deletions
|
@ -2289,7 +2289,7 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
|
||||||
{
|
{
|
||||||
data0 = fromOpus(data0);
|
data0 = fromOpus(data0);
|
||||||
if (data0<0)
|
if (data0<0)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
}
|
}
|
||||||
st->end = IMAX(1, st->mode->effEBands-2*(data0>>5));
|
st->end = IMAX(1, st->mode->effEBands-2*(data0>>5));
|
||||||
LM = (data0>>3)&0x3;
|
LM = (data0>>3)&0x3;
|
||||||
|
@ -2297,7 +2297,7 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
|
||||||
data++;
|
data++;
|
||||||
len--;
|
len--;
|
||||||
if (LM>st->mode->maxLM)
|
if (LM>st->mode->maxLM)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
if (frame_size < st->mode->shortMdctSize<<LM)
|
if (frame_size < st->mode->shortMdctSize<<LM)
|
||||||
return OPUS_BUFFER_TOO_SMALL;
|
return OPUS_BUFFER_TOO_SMALL;
|
||||||
else
|
else
|
||||||
|
|
|
@ -66,7 +66,7 @@ extern "C" {
|
||||||
/** An internal error was detected */
|
/** An internal error was detected */
|
||||||
#define OPUS_INTERNAL_ERROR -3
|
#define OPUS_INTERNAL_ERROR -3
|
||||||
/** The data passed (e.g. compressed data to decoder) is corrupted */
|
/** 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 */
|
/** Invalid/unsupported request number */
|
||||||
#define OPUS_UNIMPLEMENTED -5
|
#define OPUS_UNIMPLEMENTED -5
|
||||||
/** An encoder or decoder structure is invalid or already freed */
|
/** An encoder or decoder structure is invalid or already freed */
|
||||||
|
|
|
@ -295,7 +295,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
|
||||||
pcm_ptr[i] = 0;
|
pcm_ptr[i] = 0;
|
||||||
} else {
|
} else {
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pcm_ptr += silk_frame_size * st->channels;
|
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;
|
len -= redundancy_bytes;
|
||||||
if (len<0) {
|
if (len<0) {
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
}
|
}
|
||||||
/* Shrink decoder because of raw bits */
|
/* Shrink decoder because of raw bits */
|
||||||
dec.storage -= redundancy_bytes;
|
dec.storage -= redundancy_bytes;
|
||||||
|
@ -502,7 +502,7 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
|
||||||
if (!self_delimited)
|
if (!self_delimited)
|
||||||
{
|
{
|
||||||
if (len&0x1)
|
if (len&0x1)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
size[0] = last_size = len/2;
|
size[0] = last_size = len/2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -512,19 +512,19 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
|
||||||
bytes = parse_size(data, len, size);
|
bytes = parse_size(data, len, size);
|
||||||
len -= bytes;
|
len -= bytes;
|
||||||
if (size[0]<0 || size[0] > len)
|
if (size[0]<0 || size[0] > len)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
data += bytes;
|
data += bytes;
|
||||||
last_size = len-size[0];
|
last_size = len-size[0];
|
||||||
break;
|
break;
|
||||||
/* Multiple CBR/VBR frames (from 0 to 120 ms) */
|
/* Multiple CBR/VBR frames (from 0 to 120 ms) */
|
||||||
case 3:
|
case 3:
|
||||||
if (len<1)
|
if (len<1)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
/* Number of frames encoded in bits 0 to 5 */
|
/* Number of frames encoded in bits 0 to 5 */
|
||||||
ch = *data++;
|
ch = *data++;
|
||||||
count = ch&0x3F;
|
count = ch&0x3F;
|
||||||
if (count <= 0 || framesize*count > 5760)
|
if (count <= 0 || framesize*count > 5760)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
len--;
|
len--;
|
||||||
/* Padding flag is bit 6 */
|
/* Padding flag is bit 6 */
|
||||||
if (ch&0x40)
|
if (ch&0x40)
|
||||||
|
@ -533,7 +533,7 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
|
||||||
int p;
|
int p;
|
||||||
do {
|
do {
|
||||||
if (len<=0)
|
if (len<=0)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
p = *data++;
|
p = *data++;
|
||||||
len--;
|
len--;
|
||||||
padding += p==255 ? 254: p;
|
padding += p==255 ? 254: p;
|
||||||
|
@ -541,7 +541,7 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
|
||||||
len -= padding;
|
len -= padding;
|
||||||
}
|
}
|
||||||
if (len<0)
|
if (len<0)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
/* VBR flag is bit 7 */
|
/* VBR flag is bit 7 */
|
||||||
cbr = !(ch&0x80);
|
cbr = !(ch&0x80);
|
||||||
if (cbr)
|
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);
|
bytes = parse_size(data, len, size+i);
|
||||||
len -= bytes;
|
len -= bytes;
|
||||||
if (size[i]<0 || size[i] > len)
|
if (size[i]<0 || size[i] > len)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
data += bytes;
|
data += bytes;
|
||||||
last_size -= bytes+size[i];
|
last_size -= bytes+size[i];
|
||||||
}
|
}
|
||||||
if (last_size<0)
|
if (last_size<0)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
} else if (!self_delimited)
|
} else if (!self_delimited)
|
||||||
{
|
{
|
||||||
/* CBR case */
|
/* CBR case */
|
||||||
last_size = len/count;
|
last_size = len/count;
|
||||||
if (last_size*count!=len)
|
if (last_size*count!=len)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
for (i=0;i<count-1;i++)
|
for (i=0;i<count-1;i++)
|
||||||
size[i] = last_size;
|
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);
|
bytes = parse_size(data, len, size+count-1);
|
||||||
len -= bytes;
|
len -= bytes;
|
||||||
if (size[count-1]<0 || size[count-1] > len)
|
if (size[count-1]<0 || size[count-1] > len)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
data += bytes;
|
data += bytes;
|
||||||
/* For CBR packets, apply the size to all the frames. */
|
/* For CBR packets, apply the size to all the frames. */
|
||||||
if (cbr)
|
if (cbr)
|
||||||
{
|
{
|
||||||
if (size[count-1]*count > len)
|
if (size[count-1]*count > len)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
for (i=0;i<count-1;i++)
|
for (i=0;i<count-1;i++)
|
||||||
size[i] = size[count-1];
|
size[i] = size[count-1];
|
||||||
} else if(size[count-1] > last_size)
|
} else if(size[count-1] > last_size)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
/* Because it's not encoded explicitly, it's possible the size of the
|
/* 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.
|
1275.
|
||||||
Reject them here.*/
|
Reject them here.*/
|
||||||
if (last_size > 1275)
|
if (last_size > 1275)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
size[count-1] = last_size;
|
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)
|
else if (count!=3)
|
||||||
return 2;
|
return 2;
|
||||||
else if (len<2)
|
else if (len<2)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
else
|
else
|
||||||
return packet[1]&0x3F;
|
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);
|
samples = count*opus_packet_get_samples_per_frame(packet, dec->Fs);
|
||||||
/* Can't have more than 120 ms */
|
/* Can't have more than 120 ms */
|
||||||
if (samples*25 > dec->Fs*3)
|
if (samples*25 > dec->Fs*3)
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
else
|
else
|
||||||
return samples;
|
return samples;
|
||||||
}
|
}
|
||||||
|
|
|
@ -561,7 +561,7 @@ static int opus_multistream_decode_native(
|
||||||
if (len<=0)
|
if (len<=0)
|
||||||
{
|
{
|
||||||
RESTORE_STACK;
|
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);
|
ret = opus_decode_native(dec, data, len, buf, frame_size, decode_fec, 1, &packet_offset);
|
||||||
data += packet_offset;
|
data += packet_offset;
|
||||||
|
@ -574,7 +574,7 @@ static int opus_multistream_decode_native(
|
||||||
if (s>0 && ret != frame_size)
|
if (s>0 && ret != frame_size)
|
||||||
{
|
{
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
return OPUS_CORRUPTED_DATA;
|
return OPUS_INVALID_PACKET;
|
||||||
}
|
}
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,14 +76,14 @@ int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, int l
|
||||||
} else if ((rp->toc&0xFC) != (data[0]&0xFC))
|
} else if ((rp->toc&0xFC) != (data[0]&0xFC))
|
||||||
{
|
{
|
||||||
/*fprintf(stderr, "toc mismatch: 0x%x vs 0x%x\n", rp->toc, data[0]);*/
|
/*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);
|
curr_nb_frames = opus_packet_get_nb_frames(data, len);
|
||||||
|
|
||||||
/* Check the 120 ms maximum packet size */
|
/* Check the 120 ms maximum packet size */
|
||||||
if ((curr_nb_frames+rp->nb_frames)*rp->framesize > 5760)
|
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);
|
opus_packet_parse(data, len, &tmp_toc, &rp->frames[rp->nb_frames], &rp->len[rp->nb_frames], NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue