Bug fix in WebRtcOpus_DurationEst

The function WebRtcOpus_DurationEst returned the number of samples
per packet in the native 48 kHz sample rate, while the decoder
function returns data in 32 kHz sample rate. This creates a discrepancy
that makes NetEQ's lip-sync functionality add too little delay.

BUG=1334
TEST=try bots

Review URL: https://webrtc-codereview.appspot.com/1069006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3403 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org 2013-01-23 11:57:03 +00:00
parent 8126602e26
commit 5dfb1f2cd3

View File

@ -217,7 +217,9 @@ int16_t WebRtcOpus_Decode(OpusDecInst* inst, int16_t* encoded,
buffer32[7 + i] = buffer16[i];
}
/* Resampling 3 samples to 2. Function divides the input in |blocks| number
* of 3-sample groups, and output is |blocks| number of 2-sample groups. */
* of 3-sample groups, and output is |blocks| number of 2-sample groups.
* When this is removed, the compensation in WebRtcOpus_DurationEst should be
* removed too. */
blocks = decoded_samples / 3;
WebRtcSpl_Resample48khzTo32khz(buffer32, buffer32, blocks);
output_samples = (int16_t) (blocks * 2);
@ -299,5 +301,9 @@ int WebRtcOpus_DurationEst(OpusDecInst* inst,
/* Invalid payload duration. */
return 0;
}
/* Compensate for the down-sampling from 48 kHz to 32 kHz.
* This should be removed when the resampling in WebRtcOpus_Decode is
* removed. */
samples = samples * 2 / 3;
return samples;
}