ref: 9f90e57a9b785682bc52e3cacf0d9f85637ea5d1
parent: 6312d9a39bef93eee98584573d4c1e19119befbc
author: Jean-Marc Valin <[email protected]>
date: Tue Sep 27 10:10:23 EDT 2011
Fixes a glitch in SILK mono->stereo switching For these transitions, we now start the left and right resamplers from the same state.
--- a/silk/enc_API.c
+++ b/silk/enc_API.c
@@ -219,6 +219,10 @@
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 @@
&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;
--- a/silk/fixed/structs_FIX.h
+++ b/silk/fixed/structs_FIX.h
@@ -120,6 +120,7 @@
opus_int32 nBitsExceeded;
opus_int nChannelsAPI;
opus_int nChannelsInternal;
+ opus_int nPrevChannelsInternal;
opus_int timeSinceSwitchAllowed_ms;
opus_int allowBandwidthSwitch;
} silk_encoder;
--- a/silk/float/structs_FLP.h
+++ b/silk/float/structs_FLP.h
@@ -118,6 +118,7 @@
opus_int32 nBitsExceeded;
opus_int nChannelsAPI;
opus_int nChannelsInternal;
+ opus_int nPrevChannelsInternal;
opus_int timeSinceSwitchAllowed_ms;
opus_int allowBandwidthSwitch;
} silk_encoder;