From 073c4e14727fffdff30fccbd1753aca1d14861ba Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Fri, 26 Aug 2011 13:01:42 -0400 Subject: [PATCH] More precise CELT/SILK delay compensation to reduce mode switching glitches --- src/opus_encoder.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 2eec5f8c..4186e32b 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -181,8 +181,15 @@ OpusEncoder *opus_encoder_init(OpusEncoder* st, int Fs, int channels, int applic st->encoder_buffer = st->Fs/100; st->delay_compensation = st->Fs/400; - if (st->Fs > 16000) - st->delay_compensation += 10; + /* This part is meant to compensate for the resampler delay as a function + of the API sampling rate */ + if (st->Fs == 48000) + st->delay_compensation += 23; + else if (st->Fs == 24000) + st->delay_compensation += 15; + else + st->delay_compensation += 2; + return st; failure: