opus_packet_parse() now returns the payload offset rather than the pointer
This commit is contained in:
parent
8fe8b8e0b6
commit
6bb1c1838d
2 changed files with 8 additions and 6 deletions
|
@ -219,7 +219,7 @@ OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
|
||||||
|
|
||||||
OPUS_EXPORT int opus_packet_parse(const unsigned char *data, int len,
|
OPUS_EXPORT int opus_packet_parse(const unsigned char *data, int len,
|
||||||
unsigned char *out_toc, const unsigned char *frames[48],
|
unsigned char *out_toc, const unsigned char *frames[48],
|
||||||
short size[48], const unsigned char **payload);
|
short size[48], int *payload_offset);
|
||||||
|
|
||||||
OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data);
|
OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data);
|
||||||
OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data, int Fs);
|
OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data, int Fs);
|
||||||
|
|
|
@ -446,12 +446,13 @@ static int parse_size(const unsigned char *data, int len, short *size)
|
||||||
|
|
||||||
int opus_packet_parse(const unsigned char *data, int len,
|
int opus_packet_parse(const unsigned char *data, int len,
|
||||||
unsigned char *out_toc, const unsigned char *frames[48],
|
unsigned char *out_toc, const unsigned char *frames[48],
|
||||||
short size[48], const unsigned char **payload)
|
short size[48], int *payload_offset)
|
||||||
{
|
{
|
||||||
int i, bytes;
|
int i, bytes;
|
||||||
int count;
|
int count;
|
||||||
unsigned char ch, toc;
|
unsigned char ch, toc;
|
||||||
int framesize;
|
int framesize;
|
||||||
|
const unsigned char *data0 = data;
|
||||||
|
|
||||||
if (size==NULL)
|
if (size==NULL)
|
||||||
return OPUS_BAD_ARG;
|
return OPUS_BAD_ARG;
|
||||||
|
@ -556,8 +557,8 @@ int opus_packet_parse(const unsigned char *data, int len,
|
||||||
if (out_toc)
|
if (out_toc)
|
||||||
*out_toc = toc;
|
*out_toc = toc;
|
||||||
|
|
||||||
if (payload)
|
if (payload_offset)
|
||||||
*payload = data;
|
*payload_offset = data-data0;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -571,7 +572,7 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data,
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int i, nb_samples;
|
int i, nb_samples;
|
||||||
int count;
|
int count, offset;
|
||||||
unsigned char toc;
|
unsigned char toc;
|
||||||
/* 48 x 2.5 ms = 120 ms */
|
/* 48 x 2.5 ms = 120 ms */
|
||||||
short size[48];
|
short size[48];
|
||||||
|
@ -584,10 +585,11 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data,
|
||||||
st->frame_size = opus_packet_get_samples_per_frame(data, st->Fs);
|
st->frame_size = opus_packet_get_samples_per_frame(data, st->Fs);
|
||||||
st->stream_channels = opus_packet_get_nb_channels(data);
|
st->stream_channels = opus_packet_get_nb_channels(data);
|
||||||
|
|
||||||
count = opus_packet_parse(data, len, &toc, NULL, size, &data);
|
count = opus_packet_parse(data, len, &toc, NULL, size, &offset);
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
|
data += offset;
|
||||||
if (count*st->frame_size > frame_size)
|
if (count*st->frame_size > frame_size)
|
||||||
return OPUS_BAD_ARG;
|
return OPUS_BAD_ARG;
|
||||||
nb_samples=0;
|
nb_samples=0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue