| 1 | /*********************************************************************** |
| 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
| 3 | Redistribution and use in source and binary forms, with or without |
| 4 | modification, are permitted provided that the following conditions |
| 5 | are met: |
| 6 | - Redistributions of source code must retain the above copyright notice, |
| 7 | this list of conditions and the following disclaimer. |
| 8 | - Redistributions in binary form must reproduce the above copyright |
| 9 | notice, this list of conditions and the following disclaimer in the |
| 10 | documentation and/or other materials provided with the distribution. |
| 11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the |
| 12 | names of specific contributors, may be used to endorse or promote |
| 13 | products derived from this software without specific prior written |
| 14 | permission. |
| 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 | POSSIBILITY OF SUCH DAMAGE. |
| 26 | ***********************************************************************/ |
| 27 | |
| 28 | //#ifdef HAVE_CONFIG_H |
| 29 | #include "opus__config.h"cxx . . $ `<file>/external/opusfile/opus/opus__config.h`/ |
| 30 | //#endif |
| 31 | |
| 32 | #include <stdlib.h> |
| 33 | #include "main_FLP.h"cxx . . $ `<file>/external/opusfile/opus/silk/float/main_FLP.h`/ |
| 34 | #include "tuning_parameters.h"cxx . . $ `<file>/external/opusfile/opus/silk/tuning_parameters.h`/ |
| 35 | |
| 36 | void silk_find_pitch_lags_FLPcxx . . $ silk_find_pitch_lags_FLP(939f966e969441ae).( |
| 37 | silk_encoder_state_FLPcxx . . $ silk_encoder_state_FLP# *psEnc, /* I/O Encoder state FLP */ |
| 38 | silk_encoder_control_FLPcxx . . $ silk_encoder_control_FLP# *psEncCtrl, /* I/O Encoder control FLP */ |
| 39 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! res[], /* O Residual */ |
| 40 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! x[], /* I Speech signal */ |
| 41 | int arch /* I Run-time architecture */ |
| 42 | ) |
| 43 | { |
| 44 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! buf_len; |
| 45 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! thrhld, res_nrg; |
| 46 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *x_buf_ptr, *x_buf; |
| 47 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! auto_corr[ MAX_FIND_PITCH_LPC_ORDERcxx . . $ `external/opusfile/opus/silk/define.h:104:9`! + 1 ]; |
| 48 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! A[ MAX_FIND_PITCH_LPC_ORDERcxx . . $ `external/opusfile/opus/silk/define.h:104:9`! ]; |
| 49 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! refl_coef[ MAX_FIND_PITCH_LPC_ORDERcxx . . $ `external/opusfile/opus/silk/define.h:104:9`! ]; |
| 50 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! Wsig[ FIND_PITCH_LPC_WIN_MAXcxx . . $ `external/opusfile/opus/silk/define.h:109:9`! ]; |
| 51 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *Wsig_ptr; |
| 52 | |
| 53 | /******************************************/ |
| 54 | /* Set up buffer lengths etc based on Fs */ |
| 55 | /******************************************/ |
| 56 | buf_len = psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..la_pitchcxx . . $ $anonymous_type_c9846ade8c67dd67_7#la_pitch. + psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..frame_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_7#frame_length. + psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..ltp_mem_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_7#ltp_mem_length.; |
| 57 | |
| 58 | /* Safety check */ |
| 59 | celt_assertcxx . . $ `external/opusfile/opus/celt/arch.h:80:9`!( buf_len >= psEnc->sCmn.pitch_LPC_win_length ); |
| 60 | |
| 61 | x_buf = x - psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..ltp_mem_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_7#ltp_mem_length.; |
| 62 | |
| 63 | /******************************************/ |
| 64 | /* Estimate LPC AR coeficients */ |
| 65 | /******************************************/ |
| 66 | |
| 67 | /* Calculate windowed signal */ |
| 68 | |
| 69 | /* First LA_LTP samples */ |
| 70 | x_buf_ptr = x_buf + buf_len - psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitch_LPC_win_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitch_LPC_win_length.; |
| 71 | Wsig_ptr = Wsig; |
| 72 | silk_apply_sine_window_FLPcxx . . $ silk_apply_sine_window_FLP(5bf2be13bedcea69).( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..la_pitchcxx . . $ $anonymous_type_c9846ade8c67dd67_7#la_pitch. ); |
| 73 | |
| 74 | /* Middle non-windowed samples */ |
| 75 | Wsig_ptr += psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..la_pitchcxx . . $ $anonymous_type_c9846ade8c67dd67_7#la_pitch.; |
| 76 | x_buf_ptr += psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..la_pitchcxx . . $ $anonymous_type_c9846ade8c67dd67_7#la_pitch.; |
| 77 | silk_memcpycxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:420:9`!( Wsig_ptr, x_buf_ptr, ( psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ) ) * sizeof( silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! ) ); |
| 78 | |
| 79 | /* Last LA_LTP samples */ |
| 80 | Wsig_ptr += psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitch_LPC_win_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitch_LPC_win_length. - ( psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..la_pitchcxx . . $ $anonymous_type_c9846ade8c67dd67_7#la_pitch. << 1 ); |
| 81 | x_buf_ptr += psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitch_LPC_win_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitch_LPC_win_length. - ( psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..la_pitchcxx . . $ $anonymous_type_c9846ade8c67dd67_7#la_pitch. << 1 ); |
| 82 | silk_apply_sine_window_FLPcxx . . $ silk_apply_sine_window_FLP(5bf2be13bedcea69).( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..la_pitchcxx . . $ $anonymous_type_c9846ade8c67dd67_7#la_pitch. ); |
| 83 | |
| 84 | /* Calculate autocorrelation sequence */ |
| 85 | silk_autocorrelation_FLPcxx . . $ silk_autocorrelation_FLP(5bf2be13bedcea69).( auto_corr, Wsig, psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitch_LPC_win_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitch_LPC_win_length., psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitchEstimationLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitchEstimationLPCOrder. + 1 ); |
| 86 | |
| 87 | /* Add white noise, as a fraction of the energy */ |
| 88 | auto_corr[ 0 ] += auto_corr[ 0 ] * FIND_PITCH_WHITE_NOISE_FRACTIONcxx . . $ `external/opusfile/opus/silk/tuning_parameters.h:44:9`! + 1; |
| 89 | |
| 90 | /* Calculate the reflection coefficients using Schur */ |
| 91 | res_nrg = silk_schur_FLPcxx . . $ silk_schur_FLP(5541a936430c01ec).( refl_coef, auto_corr, psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitchEstimationLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitchEstimationLPCOrder. ); |
| 92 | |
| 93 | /* Prediction gain */ |
| 94 | psEncCtrl->predGaincxx . . $ $anonymous_type_f1d9da68e5821ba3_2#predGain. = auto_corr[ 0 ] / silk_max_floatcxx . . $ `external/opusfile/opus/silk/float/SigProc_FLP.h:146:9`!( res_nrg, 1.0f ); |
| 95 | |
| 96 | /* Convert reflection coefficients to prediction coefficients */ |
| 97 | silk_k2a_FLPcxx . . $ silk_k2a_FLP(8e5bb7dd50cd87b6).( A, refl_coef, psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitchEstimationLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitchEstimationLPCOrder. ); |
| 98 | |
| 99 | /* Bandwidth expansion */ |
| 100 | silk_bwexpander_FLPcxx . . $ silk_bwexpander_FLP(aa182a3194b62131).( A, psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitchEstimationLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitchEstimationLPCOrder., FIND_PITCH_BANDWIDTH_EXPANSIONcxx . . $ `external/opusfile/opus/silk/tuning_parameters.h:47:9`! ); |
| 101 | |
| 102 | /*****************************************/ |
| 103 | /* LPC analysis filtering */ |
| 104 | /*****************************************/ |
| 105 | silk_LPC_analysis_filter_FLPcxx . . $ silk_LPC_analysis_filter_FLP(97761e1dab2d1d16).( res, A, x_buf, buf_len, psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitchEstimationLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitchEstimationLPCOrder. ); |
| 106 | |
| 107 | if( psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..signalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_6#signalType. != TYPE_NO_VOICE_ACTIVITYcxx . . $ `external/opusfile/opus/silk/define.h:70:9`! && psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..first_frame_after_resetcxx . . $ $anonymous_type_c9846ade8c67dd67_7#first_frame_after_reset. == 0 ) { |
| 108 | /* Threshold for pitch estimator */ |
| 109 | thrhld = 0.6f; |
| 110 | thrhld -= 0.004f * psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitchEstimationLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitchEstimationLPCOrder.; |
| 111 | thrhld -= 0.1f * psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..speech_activity_Q8cxx . . $ $anonymous_type_c9846ade8c67dd67_7#speech_activity_Q8. * ( 1.0f / 256.0f ); |
| 112 | thrhld -= 0.15f * (psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..prevSignalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_7#prevSignalType. >> 1); |
| 113 | thrhld -= 0.1f * psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..input_tilt_Q15cxx . . $ $anonymous_type_c9846ade8c67dd67_7#input_tilt_Q15. * ( 1.0f / 32768.0f ); |
| 114 | |
| 115 | /*****************************************/ |
| 116 | /* Call Pitch estimator */ |
| 117 | /*****************************************/ |
| 118 | if( silk_pitch_analysis_core_FLPcxx . . $ silk_pitch_analysis_core_FLP(29067da6902c468d).( res, psEncCtrl->pitchLcxx . . $ $anonymous_type_f1d9da68e5821ba3_2#pitchL., &psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..lagIndexcxx . . $ $anonymous_type_c9846ade8c67dd67_6#lagIndex., |
| 119 | &psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..contourIndexcxx . . $ $anonymous_type_c9846ade8c67dd67_6#contourIndex., &psEnc->LTPCorrcxx . . $ $anonymous_type_f1d9da68e5821ba3_1#LTPCorr., psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..prevLagcxx . . $ $anonymous_type_c9846ade8c67dd67_7#prevLag., psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitchEstimationThreshold_Q16cxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitchEstimationThreshold_Q16. / 65536.0f, |
| 120 | thrhld, psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..fs_kHzcxx . . $ $anonymous_type_c9846ade8c67dd67_7#fs_kHz., psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..pitchEstimationComplexitycxx . . $ $anonymous_type_c9846ade8c67dd67_7#pitchEstimationComplexity., psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..nb_subfrcxx . . $ $anonymous_type_c9846ade8c67dd67_7#nb_subfr., arch ) == 0 ) |
| 121 | { |
| 122 | psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..signalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_6#signalType. = TYPE_VOICEDcxx . . $ `external/opusfile/opus/silk/define.h:72:9`!; |
| 123 | } else { |
| 124 | psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..signalTypecxx . . $ $anonymous_type_c9846ade8c67dd67_6#signalType. = TYPE_UNVOICEDcxx . . $ `external/opusfile/opus/silk/define.h:71:9`!; |
| 125 | } |
| 126 | } else { |
| 127 | silk_memsetcxx . . $ `external/opusfile/opus/silk/SigProc_FIX.h:421:9`!( psEncCtrl->pitchL, 0, sizeof( psEncCtrl->pitchL ) ); |
| 128 | psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..lagIndexcxx . . $ $anonymous_type_c9846ade8c67dd67_6#lagIndex. = 0; |
| 129 | psEnc->sCmncxx . . $ $anonymous_type_f1d9da68e5821ba3_1#sCmn..indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..contourIndexcxx . . $ $anonymous_type_c9846ade8c67dd67_6#contourIndex. = 0; |
| 130 | psEnc->LTPCorrcxx . . $ $anonymous_type_f1d9da68e5821ba3_1#LTPCorr. = 0; |
| 131 | } |
| 132 | } |