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
path: root/silk
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2012-02-18 01:09:21 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-02-18 01:18:08 +0400
commit17c5966045b463fde45418000b03c95eb5cd7e09 (patch)
tree531ef169caf43a0421cf785f9e0e173e8fcbb4a0 /silk
parentc4ff3a0423060761d4587fef214fa231d252ed90 (diff)
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')
-rw-r--r--silk/dec_API.c20
-rw-r--r--silk/decoder_set_fs.c16
2 files changed, 17 insertions, 19 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 ];
+ }
}
}
diff --git a/silk/decoder_set_fs.c b/silk/decoder_set_fs.c
index e0a343f8..c0bf352b 100644
--- a/silk/decoder_set_fs.c
+++ b/silk/decoder_set_fs.c
@@ -49,25 +49,9 @@ opus_int silk_decoder_set_fs(
/* Initialize resampler when switching internal or external sampling frequency */
if( psDec->fs_kHz != fs_kHz || psDec->fs_API_hz != fs_API_Hz ) {
- /* Allocate worst case space for temporary upsampling, 8 to 48 kHz, so a factor 6 */
- opus_int16 temp_buf[ MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ ];
- silk_resampler_state_struct temp_resampler_state;
-
- if( psDec->fs_kHz != fs_kHz && psDec->fs_kHz > 0 ) {
- /* Initialize resampler for temporary resampling of outBuf data to the new internal sampling rate */
- ret += silk_resampler_init( &temp_resampler_state, silk_SMULBB( psDec->fs_kHz, 1000 ), silk_SMULBB( fs_kHz, 1000 ), 0 );
-
- /* Temporary resampling of outBuf data to the new internal sampling rate */
- silk_memcpy( temp_buf, psDec->outBuf, psDec->frame_length * sizeof( opus_int16 ) );
- ret += silk_resampler( &temp_resampler_state, psDec->outBuf, temp_buf, psDec->frame_length );
- }
-
/* Initialize the resampler for dec_API.c preparing resampling from fs_kHz to API_fs_Hz */
ret += silk_resampler_init( &psDec->resampler_state, silk_SMULBB( fs_kHz, 1000 ), fs_API_Hz, 0 );
- /* Correct resampler state by resampling buffered data from fs_kHz to API_fs_Hz */
- ret += silk_resampler( &psDec->resampler_state, temp_buf, psDec->outBuf, frame_length );
-
psDec->fs_API_hz = fs_API_Hz;
}