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:
tina.legrand@webrtc.org
2012-12-19 09:52:45 +00:00
parent 515ef2428c
commit 4275ab1ca0
3 changed files with 35 additions and 2 deletions

View File

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