Implement NetEq duration estimation for Opus.
Review URL: https://webrtc-codereview.appspot.com/983004 Patch from Ralph Giles <giles@webrtc.org>. git-svn-id: http://webrtc.googlecode.com/svn/trunk@3314 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -280,3 +280,21 @@ int16_t WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
|
||||
* number_of_lost_frames corresponds to. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WebRtcOpus_DurationEst(OpusDecInst* inst,
|
||||
const uint8_t* payload,
|
||||
int payload_length_bytes)
|
||||
{
|
||||
int frames, samples;
|
||||
frames = opus_packet_get_nb_frames(payload, payload_length_bytes);
|
||||
if (frames < 0) {
|
||||
/* Invalid payload data. */
|
||||
return 0;
|
||||
}
|
||||
samples = frames * opus_packet_get_samples_per_frame(payload, 48000);
|
||||
if (samples < 120 || samples > 5760) {
|
||||
/* Invalid payload duration. */
|
||||
return 0;
|
||||
}
|
||||
return samples;
|
||||
}
|
||||
|
Reference in New Issue
Block a user