From 5dfb1f2cd31c07708c32947375718245ef280724 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Wed, 23 Jan 2013 11:57:03 +0000 Subject: [PATCH] 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 --- webrtc/modules/audio_coding/codecs/opus/opus_interface.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c index 6b6ab6dcd6..2203fbd4ca 100644 --- a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c +++ b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c @@ -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; }