ref: 61e9eb15cc8e84a20eb1a7e5747b9a10e8caf0be
parent: 4ed7e48e1db6d6913b00091ead62ff3440ea675d
author: Jean-Marc Valin <[email protected]>
date: Wed Feb 6 13:10:51 EST 2013
Adds a ramp up in the SILK prefill This improves quality of CELT->SILK switches by not having the SILK encoder attempt to encode a discontinuity. Overall, it's a small PQ improvement, confirmed by some listening.
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1087,6 +1087,20 @@
if (prefill)
{
opus_int32 zero=0;
+ const CELTMode *celt_mode;
+ int prefill_offset;
+ celt_encoder_ctl(celt_enc, CELT_GET_MODE(&celt_mode));
+ /* Use a smooth onset for the SILK prefill to avoid the encoder trying to encode
+ a discontinuity. The exact location is what we need to avoid leaving any "gap"
+ in the audio when mixing with the redundant CELT frame. Here we can afford to
+ overwrite st->delay_buffer because the only thing that uses it before it gets
+ rewritten is tmp_prefill[] and even then only the part after the ramp really
+ gets used (rather than sent to the encoder and discarded) */
+ prefill_offset = st->channels*(st->encoder_buffer-st->delay_compensation-st->Fs/400);
+ gain_fade(st->delay_buffer+prefill_offset, st->delay_buffer+prefill_offset,
+ 0, Q15ONE, celt_mode->overlap, st->Fs/400, st->channels, celt_mode->window, st->Fs);
+ for(i=0;i<prefill_offset;i++)
+ st->delay_buffer[i]=0;
#ifdef FIXED_POINT
pcm_silk = st->delay_buffer;
#else