diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-09-27 22:10:23 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-09-27 22:10:23 +0400 |
commit | 9f90e57a9b785682bc52e3cacf0d9f85637ea5d1 (patch) | |
tree | b8f2788013e503cc43352738e8d3deb3e6bd0c90 /silk/enc_API.c | |
parent | 6312d9a39bef93eee98584573d4c1e19119befbc (diff) |
Fixes a glitch in SILK mono->stereo switching
For these transitions, we now start the left and right resamplers
from the same state.
Diffstat (limited to 'silk/enc_API.c')
-rw-r--r-- | silk/enc_API.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/silk/enc_API.c b/silk/enc_API.c index 29d75686..e8a65563 100644 --- a/silk/enc_API.c +++ b/silk/enc_API.c @@ -219,6 +219,10 @@ opus_int silk_Encode( for( n = 0; n < nSamplesFromInput; n++ ) { buf[ n ] = samplesIn[ 2 * n ]; } + /* Making sure to start both resamplers from the same state when switching from mono to stereo */ + if(psEnc->nPrevChannelsInternal == 1) + silk_memcpy(&psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, sizeof(psEnc->state_Fxx[ 1 ].sCmn.resampler_state)); + ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput ); psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; @@ -245,6 +249,8 @@ opus_int silk_Encode( &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], samplesIn, nSamplesFromInput ); psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; } + psEnc->nPrevChannelsInternal = encControl->nChannelsInternal; + samplesIn += nSamplesFromInput * encControl->nChannelsAPI; nSamplesIn -= nSamplesFromInput; |