| OLD | NEW |
| 1 /*********************************************************************** | 1 /*********************************************************************** |
| 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
| 3 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
| 4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
| 5 are met: | 5 are met: |
| 6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
| 7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
| 8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
| 9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
| 10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include "main_FIX.h" | 32 #include "main_FIX.h" |
| 33 #include "stack_alloc.h" | 33 #include "stack_alloc.h" |
| 34 #include "tuning_parameters.h" | 34 #include "tuning_parameters.h" |
| 35 | 35 |
| 36 /* Find pitch lags */ | 36 /* Find pitch lags */ |
| 37 void silk_find_pitch_lags_FIX( | 37 void silk_find_pitch_lags_FIX( |
| 38 silk_encoder_state_FIX *psEnc, /* I
/O encoder state
*/ | 38 silk_encoder_state_FIX *psEnc, /* I
/O encoder state
*/ |
| 39 silk_encoder_control_FIX *psEncCtrl, /* I
/O encoder control
*/ | 39 silk_encoder_control_FIX *psEncCtrl, /* I
/O encoder control
*/ |
| 40 opus_int16 res[], /* O
residual
*/ | 40 opus_int16 res[], /* O
residual
*/ |
| 41 const opus_int16 x[] /* I
Speech signal
*/ | 41 const opus_int16 x[], /* I
Speech signal
*/ |
| 42 int arch /* I
Run-time architecture
*/ |
| 42 ) | 43 ) |
| 43 { | 44 { |
| 44 opus_int buf_len, i, scale; | 45 opus_int buf_len, i, scale; |
| 45 opus_int32 thrhld_Q13, res_nrg; | 46 opus_int32 thrhld_Q13, res_nrg; |
| 46 const opus_int16 *x_buf, *x_buf_ptr; | 47 const opus_int16 *x_buf, *x_buf_ptr; |
| 47 VARDECL( opus_int16, Wsig ); | 48 VARDECL( opus_int16, Wsig ); |
| 48 opus_int16 *Wsig_ptr; | 49 opus_int16 *Wsig_ptr; |
| 49 opus_int32 auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ]; | 50 opus_int32 auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ]; |
| 50 opus_int16 rc_Q15[ MAX_FIND_PITCH_LPC_ORDER ]; | 51 opus_int16 rc_Q15[ MAX_FIND_PITCH_LPC_ORDER ]; |
| 51 opus_int32 A_Q24[ MAX_FIND_PITCH_LPC_ORDER ]; | 52 opus_int32 A_Q24[ MAX_FIND_PITCH_LPC_ORDER ]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 Wsig_ptr += psEnc->sCmn.la_pitch; | 80 Wsig_ptr += psEnc->sCmn.la_pitch; |
| 80 x_buf_ptr += psEnc->sCmn.la_pitch; | 81 x_buf_ptr += psEnc->sCmn.la_pitch; |
| 81 silk_memcpy( Wsig_ptr, x_buf_ptr, ( psEnc->sCmn.pitch_LPC_win_length - silk_
LSHIFT( psEnc->sCmn.la_pitch, 1 ) ) * sizeof( opus_int16 ) ); | 82 silk_memcpy( Wsig_ptr, x_buf_ptr, ( psEnc->sCmn.pitch_LPC_win_length - silk_
LSHIFT( psEnc->sCmn.la_pitch, 1 ) ) * sizeof( opus_int16 ) ); |
| 82 | 83 |
| 83 /* Last LA_LTP samples */ | 84 /* Last LA_LTP samples */ |
| 84 Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT( psEnc->sCmn.la_
pitch, 1 ); | 85 Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT( psEnc->sCmn.la_
pitch, 1 ); |
| 85 x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT( psEnc->sCmn.la_
pitch, 1 ); | 86 x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT( psEnc->sCmn.la_
pitch, 1 ); |
| 86 silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch ); | 87 silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch ); |
| 87 | 88 |
| 88 /* Calculate autocorrelation sequence */ | 89 /* Calculate autocorrelation sequence */ |
| 89 silk_autocorr( auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, ps
Enc->sCmn.pitchEstimationLPCOrder + 1 ); | 90 silk_autocorr( auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, ps
Enc->sCmn.pitchEstimationLPCOrder + 1, arch ); |
| 90 | 91 |
| 91 /* Add white noise, as fraction of energy */ | 92 /* Add white noise, as fraction of energy */ |
| 92 auto_corr[ 0 ] = silk_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SILK_FIX_CONST
( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ) + 1; | 93 auto_corr[ 0 ] = silk_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SILK_FIX_CONST
( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ) + 1; |
| 93 | 94 |
| 94 /* Calculate the reflection coefficients using schur */ | 95 /* Calculate the reflection coefficients using schur */ |
| 95 res_nrg = silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder
); | 96 res_nrg = silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder
); |
| 96 | 97 |
| 97 /* Prediction gain */ | 98 /* Prediction gain */ |
| 98 psEncCtrl->predGain_Q16 = silk_DIV32_varQ( auto_corr[ 0 ], silk_max_int( res
_nrg, 1 ), 16 ); | 99 psEncCtrl->predGain_Q16 = silk_DIV32_varQ( auto_corr[ 0 ], silk_max_int( res
_nrg, 1 ), 16 ); |
| 99 | 100 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 120 thrhld_Q13 = silk_SMLAWB( thrhld_Q13, SILK_FIX_CONST( -0.1, 21 ), psE
nc->sCmn.speech_activity_Q8 ); | 121 thrhld_Q13 = silk_SMLAWB( thrhld_Q13, SILK_FIX_CONST( -0.1, 21 ), psE
nc->sCmn.speech_activity_Q8 ); |
| 121 thrhld_Q13 = silk_SMLABB( thrhld_Q13, SILK_FIX_CONST( -0.15, 13 ), silk
_RSHIFT( psEnc->sCmn.prevSignalType, 1 ) ); | 122 thrhld_Q13 = silk_SMLABB( thrhld_Q13, SILK_FIX_CONST( -0.15, 13 ), silk
_RSHIFT( psEnc->sCmn.prevSignalType, 1 ) ); |
| 122 thrhld_Q13 = silk_SMLAWB( thrhld_Q13, SILK_FIX_CONST( -0.1, 14 ), psEn
c->sCmn.input_tilt_Q15 ); | 123 thrhld_Q13 = silk_SMLAWB( thrhld_Q13, SILK_FIX_CONST( -0.1, 14 ), psEn
c->sCmn.input_tilt_Q15 ); |
| 123 thrhld_Q13 = silk_SAT16( thrhld_Q13 ); | 124 thrhld_Q13 = silk_SAT16( thrhld_Q13 ); |
| 124 | 125 |
| 125 /*****************************************/ | 126 /*****************************************/ |
| 126 /* Call pitch estimator */ | 127 /* Call pitch estimator */ |
| 127 /*****************************************/ | 128 /*****************************************/ |
| 128 if( silk_pitch_analysis_core( res, psEncCtrl->pitchL, &psEnc->sCmn.indic
es.lagIndex, &psEnc->sCmn.indices.contourIndex, | 129 if( silk_pitch_analysis_core( res, psEncCtrl->pitchL, &psEnc->sCmn.indic
es.lagIndex, &psEnc->sCmn.indices.contourIndex, |
| 129 &psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstim
ationThreshold_Q16, | 130 &psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstim
ationThreshold_Q16, |
| 130 (opus_int)thrhld_Q13, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstim
ationComplexity, psEnc->sCmn.nb_subfr ) == 0 ) | 131 (opus_int)thrhld_Q13, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstim
ationComplexity, psEnc->sCmn.nb_subfr, |
| 132 psEnc->sCmn.arch) == 0 ) |
| 131 { | 133 { |
| 132 psEnc->sCmn.indices.signalType = TYPE_VOICED; | 134 psEnc->sCmn.indices.signalType = TYPE_VOICED; |
| 133 } else { | 135 } else { |
| 134 psEnc->sCmn.indices.signalType = TYPE_UNVOICED; | 136 psEnc->sCmn.indices.signalType = TYPE_UNVOICED; |
| 135 } | 137 } |
| 136 } else { | 138 } else { |
| 137 silk_memset( psEncCtrl->pitchL, 0, sizeof( psEncCtrl->pitchL ) ); | 139 silk_memset( psEncCtrl->pitchL, 0, sizeof( psEncCtrl->pitchL ) ); |
| 138 psEnc->sCmn.indices.lagIndex = 0; | 140 psEnc->sCmn.indices.lagIndex = 0; |
| 139 psEnc->sCmn.indices.contourIndex = 0; | 141 psEnc->sCmn.indices.contourIndex = 0; |
| 140 psEnc->LTPCorr_Q15 = 0; | 142 psEnc->LTPCorr_Q15 = 0; |
| 141 } | 143 } |
| 142 RESTORE_STACK; | 144 RESTORE_STACK; |
| 143 } | 145 } |
| OLD | NEW |