summaryrefslogtreecommitdiff
path: root/silk/dec_API.c
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2012-02-17 16:09:21 -0500
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-02-17 16:18:08 -0500
commit17c5966045b463fde45418000b03c95eb5cd7e09 (patch)
tree531ef169caf43a0421cf785f9e0e173e8fcbb4a0 /silk/dec_API.c
parentc4ff3a0423060761d4587fef214fa231d252ed90 (diff)
downloadopus-17c5966045b463fde45418000b03c95eb5cd7e09.tar.gz
Last updates for draft -11v0.9.9
- Draft updates - Updated code to produce and check test vectors - Making sure that the test vectors pass at all rates as well as for mono and stereo
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 ];
+ }
}
}