Implements opus_packet_get_nb_samples()
This commit is contained in:
parent
512d849c24
commit
d0fd9d4baa
3 changed files with 24 additions and 5 deletions
|
@ -1050,8 +1050,8 @@ int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len)
|
|||
return packet[1]&0x3F;
|
||||
}
|
||||
|
||||
int opus_decoder_get_nb_samples(const OpusDecoder *dec,
|
||||
const unsigned char packet[], opus_int32 len)
|
||||
int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len,
|
||||
opus_int32 Fs)
|
||||
{
|
||||
int samples;
|
||||
int count = opus_packet_get_nb_frames(packet, len);
|
||||
|
@ -1059,10 +1059,16 @@ int opus_decoder_get_nb_samples(const OpusDecoder *dec,
|
|||
if (count<0)
|
||||
return count;
|
||||
|
||||
samples = count*opus_packet_get_samples_per_frame(packet, dec->Fs);
|
||||
samples = count*opus_packet_get_samples_per_frame(packet, Fs);
|
||||
/* Can't have more than 120 ms */
|
||||
if (samples*25 > dec->Fs*3)
|
||||
if (samples*25 > Fs*3)
|
||||
return OPUS_INVALID_PACKET;
|
||||
else
|
||||
return samples;
|
||||
}
|
||||
|
||||
int opus_decoder_get_nb_samples(const OpusDecoder *dec,
|
||||
const unsigned char packet[], opus_int32 len)
|
||||
{
|
||||
return opus_packet_get_nb_samples(packet, len, dec->Fs);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue