Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'silk/dec_API.c')
-rw-r--r--silk/dec_API.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/silk/dec_API.c b/silk/dec_API.c
index a0b841ce..8c9ed24a 100644
--- a/silk/dec_API.c
+++ b/silk/dec_API.c
@@ -92,6 +92,7 @@ opus_int silk_Decode( /* O Returns error co
silk_decoder *psDec = ( silk_decoder * )decState;
silk_decoder_state *channel_state = psDec->channel_state;
opus_int has_side;
+ opus_int stereo_to_mono;
/**********************************/
/* Test if first frame in payload */
@@ -107,6 +108,9 @@ opus_int silk_Decode( /* O Returns error co
ret += silk_init_decoder( &channel_state[ 1 ] );
}
+ stereo_to_mono = decControl->nChannelsInternal == 1 && psDec->nChannelsInternal == 2 &&
+ ( decControl->internalSampleRate == 1000*channel_state[ 0 ].fs_kHz );
+
if( channel_state[ 0 ].nFramesDecoded == 0 ) {
for( n = 0; n < decControl->nChannelsInternal; n++ ) {
opus_int fs_kHz_dec;
@@ -293,7 +297,7 @@ opus_int silk_Decode( /* O Returns error co
ret += silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec );
/* Interleave if stereo output and stereo stream */
- if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 2 ) {
+ if( decControl->nChannelsAPI == 2 ) {
for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ n + 2 * i ] = resample_out_ptr[ i ];
}
@@ -302,8 +306,18 @@ opus_int silk_Decode( /* O Returns error co
/* Create two channel output from mono stream */
if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 1 ) {
- for( i = 0; i < *nSamplesOut; i++ ) {
- samplesOut[ 0 + 2 * i ] = samplesOut[ 1 + 2 * i ] = resample_out_ptr[ i ];
+ if ( stereo_to_mono ){
+ /* Resample right channel for newly collapsed stereo just in case
+ we weren't doing collapsing when switching to mono */
+ ret += silk_resampler( &channel_state[ 1 ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ 0 ][ 1 ], nSamplesOutDec );
+
+ for( i = 0; i < *nSamplesOut; i++ ) {
+ samplesOut[ 1 + 2 * i ] = resample_out_ptr[ i ];
+ }
+ } else {
+ for( i = 0; i < *nSamplesOut; i++ ) {
+ samplesOut[ 1 + 2 * i ] = samplesOut[ 0 + 2 * i ];
+ }
}
}