Commit 42f1e3d6 authored by Koen Vos's avatar Koen Vos Committed by Jean-Marc Valin
Browse files

Two minor SILK fixes

- increases the max pitch lag by 1 (the thing Tim pointed out).  this brings the decoder in sync with the old one
- avoids that the first stereo frame is collapsed to mono
parent 1f65994e
......@@ -67,7 +67,7 @@ void silk_decode_pitch(
}
min_lag = silk_SMULBB( PE_MIN_LAG_MS, Fs_kHz );
max_lag = silk_SMULBB( PE_MAX_LAG_MS, Fs_kHz ) - 1;
max_lag = silk_SMULBB( PE_MAX_LAG_MS, Fs_kHz );
lag = min_lag + lagIndex;
for( k = 0; k < nb_subfr; k++ ) {
......
......@@ -154,7 +154,10 @@ opus_int silk_Encode(
ret += silk_init_encoder( &psEnc->state_Fxx[ 1 ] );
silk_memset( psEnc->sStereo.pred_prev_Q13, 0, sizeof( psEnc->sStereo.pred_prev_Q13 ) );
silk_memset( psEnc->sStereo.sSide, 0, sizeof( psEnc->sStereo.sSide ) );
silk_memset( psEnc->sStereo.mid_side_amp_Q0, 0, sizeof( psEnc->sStereo.mid_side_amp_Q0 ) );
psEnc->sStereo.mid_side_amp_Q0[ 0 ] = 0;
psEnc->sStereo.mid_side_amp_Q0[ 1 ] = 1;
psEnc->sStereo.mid_side_amp_Q0[ 2 ] = 0;
psEnc->sStereo.mid_side_amp_Q0[ 3 ] = 1;
psEnc->sStereo.width_prev_Q14 = 0;
psEnc->sStereo.smth_width_Q14 = SILK_FIX_CONST( 1, 14 );
if( psEnc->nChannelsAPI == 2 ) {
......@@ -232,7 +235,7 @@ opus_int silk_Encode(
if( encControl->nChannelsAPI == 2 && encControl->nChannelsInternal == 2 ) {
int id = psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded;
for( n = 0; n < nSamplesFromInput; n++ ) {
buf[ n+delay ] = samplesIn[ 2 * n ];
buf[ n+delay ] = samplesIn[ 2 * n ];
}
silk_memcpy(buf, &psEnc->state_Fxx[ 0 ].sCmn.delayBuf[MAX_ENCODER_DELAY-delay], delay*sizeof(opus_int16));
/* Making sure to start both resamplers from the same state when switching from mono to stereo */
......
......@@ -467,7 +467,7 @@ opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoic
for( k = 0; k < nb_subfr; k++ ) {
pitch_out[ k ] = lag_new + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size );
pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag, max_lag );
pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag, PE_MAX_LAG_MS * Fs_kHz );
}
*lagIndex = (opus_int16)( lag_new - min_lag );
*contourIndex = (opus_int8)CBimax;
......@@ -477,7 +477,7 @@ opus_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoic
*LTPCorr = (silk_float)sqrt( CCmax / nb_subfr ); /* Output normalized correlation */
for( k = 0; k < nb_subfr; k++ ) {
pitch_out[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size );
pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag_8kHz, max_lag_8kHz );
pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag_8kHz, PE_MAX_LAG_MS * Fs_kHz );
}
*lagIndex = (opus_int16)( lag - min_lag_8kHz );
*contourIndex = (opus_int8)CBimax;
......
......@@ -558,7 +558,7 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1
for( k = 0; k < nb_subfr; k++ ) {
pitch_out[ k ] = lag_new + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size );
pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag, max_lag );
pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag, PE_MAX_LAG_MS * Fs_kHz );
}
*lagIndex = (opus_int16)( lag_new - min_lag);
*contourIndex = (opus_int8)CBimax;
......@@ -568,7 +568,7 @@ opus_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1
*LTPCorr_Q15 = (opus_int)silk_SQRT_APPROX( silk_LSHIFT( CCmax, 13 ) ); /* Output normalized correlation */
for( k = 0; k < nb_subfr; k++ ) {
pitch_out[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size );
pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag_8kHz, max_lag_8kHz );
pitch_out[ k ] = silk_LIMIT( pitch_out[ k ], min_lag_8kHz, PE_MAX_LAG_MS * Fs_kHz );
}
*lagIndex = (opus_int16)( lag - min_lag_8kHz );
*contourIndex = (opus_int8)CBimax;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment