| 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 "define.h"cxx . . $ `<file>/external/opusfile/opus/silk/define.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 | /* LPC analysis */ |
| 37 | void silk_find_LPC_FLPcxx . . $ silk_find_LPC_FLP(d5c4183a9082d97b).( |
| 38 | silk_encoder_statecxx . . $ silk_encoder_state# *psEncC, /* I/O Encoder state */ |
| 39 | opus_int16cxx . . $ opus_int16# NLSF_Q15[], /* O NLSFs */ |
| 40 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! x[], /* I Input signal */ |
| 41 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! minInvGain /* I Inverse of max prediction gain */ |
| 42 | ) |
| 43 | { |
| 44 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! k, subfr_length; |
| 45 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! a[ MAX_LPC_ORDERcxx . . $ `external/opusfile/opus/silk/define.h:142:9`! ]; |
| 46 | |
| 47 | /* Used only for NLSF interpolation */ |
| 48 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! res_nrg, res_nrg_2nd, res_nrg_interp; |
| 49 | opus_int16cxx . . $ opus_int16# NLSF0_Q15[ MAX_LPC_ORDERcxx . . $ `external/opusfile/opus/silk/define.h:142:9`! ]; |
| 50 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! a_tmp[ MAX_LPC_ORDERcxx . . $ `external/opusfile/opus/silk/define.h:142:9`! ]; |
| 51 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! LPC_res[ MAX_FRAME_LENGTHcxx . . $ `external/opusfile/opus/silk/define.h:97:9`! + MAX_NB_SUBFRcxx . . $ `external/opusfile/opus/silk/define.h:90:9`! * MAX_LPC_ORDERcxx . . $ `external/opusfile/opus/silk/define.h:142:9`! ]; |
| 52 | |
| 53 | subfr_length = psEncC->subfr_lengthcxx . . $ $anonymous_type_c9846ade8c67dd67_7#subfr_length. + psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder.; |
| 54 | |
| 55 | /* Default: No interpolation */ |
| 56 | psEncC->indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..NLSFInterpCoef_Q2cxx . . $ $anonymous_type_c9846ade8c67dd67_6#NLSFInterpCoef_Q2. = 4; |
| 57 | |
| 58 | /* Burg AR analysis for the full frame */ |
| 59 | res_nrg = silk_burg_modified_FLPcxx . . $ silk_burg_modified_FLP(4297ace9da296b3).( a, x, minInvGain, subfr_length, psEncC->nb_subfrcxx . . $ $anonymous_type_c9846ade8c67dd67_7#nb_subfr., psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. ); |
| 60 | |
| 61 | if( psEncC->useInterpolatedNLSFscxx . . $ $anonymous_type_c9846ade8c67dd67_7#useInterpolatedNLSFs. && !psEncC->first_frame_after_resetcxx . . $ $anonymous_type_c9846ade8c67dd67_7#first_frame_after_reset. && psEncC->nb_subfrcxx . . $ $anonymous_type_c9846ade8c67dd67_7#nb_subfr. == MAX_NB_SUBFRcxx . . $ `external/opusfile/opus/silk/define.h:90:9`! ) { |
| 62 | /* Optimal solution for last 10 ms; subtract residual energy here, as that's easier than */ |
| 63 | /* adding it to the residual energy of the first 10 ms in each iteration of the search below */ |
| 64 | res_nrg -= silk_burg_modified_FLPcxx . . $ silk_burg_modified_FLP(4297ace9da296b3).( a_tmp, x + ( MAX_NB_SUBFRcxx . . $ `external/opusfile/opus/silk/define.h:90:9`! / 2 ) * subfr_length, minInvGain, subfr_length, MAX_NB_SUBFRcxx . . $ `external/opusfile/opus/silk/define.h:90:9`! / 2, psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. ); |
| 65 | |
| 66 | /* Convert to NLSFs */ |
| 67 | silk_A2NLSF_FLPcxx . . $ silk_A2NLSF_FLP(ed90014d4b5d0971).( NLSF_Q15, a_tmp, psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. ); |
| 68 | |
| 69 | /* Search over interpolation indices to find the one with lowest residual energy */ |
| 70 | res_nrg_2nd = silk_float_MAXcxx . . $ `external/opusfile/opus/silk/typedef.h:37:10`!; |
| 71 | for( k = 3; k >= 0; k-- ) { |
| 72 | /* Interpolate NLSFs for first half */ |
| 73 | silk_interpolatecxx . . $ silk_interpolate(2b9c185163305420).( NLSF0_Q15, psEncC->prev_NLSFq_Q15cxx . . $ $anonymous_type_c9846ade8c67dd67_7#prev_NLSFq_Q15., NLSF_Q15, k, psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. ); |
| 74 | |
| 75 | /* Convert to LPC for residual energy evaluation */ |
| 76 | silk_NLSF2A_FLPcxx . . $ silk_NLSF2A_FLP(8cfbf1a895630048).( a_tmp, NLSF0_Q15, psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder., psEncC->archcxx . . $ $anonymous_type_c9846ade8c67dd67_7#arch. ); |
| 77 | |
| 78 | /* Calculate residual energy with LSF interpolation */ |
| 79 | silk_LPC_analysis_filter_FLPcxx . . $ silk_LPC_analysis_filter_FLP(97761e1dab2d1d16).( LPC_res, a_tmp, x, 2 * subfr_length, psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. ); |
| 80 | res_nrg_interp = (silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`!)( |
| 81 | silk_energy_FLPcxx . . $ silk_energy_FLP(b1731ecc7d336c81).( LPC_res + psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder., subfr_length - psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. ) + |
| 82 | silk_energy_FLPcxx . . $ silk_energy_FLP(b1731ecc7d336c81).( LPC_res + psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. + subfr_length, subfr_length - psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. ) ); |
| 83 | |
| 84 | /* Determine whether current interpolated NLSFs are best so far */ |
| 85 | if( res_nrg_interp < res_nrg ) { |
| 86 | /* Interpolation has lower residual energy */ |
| 87 | res_nrg = res_nrg_interp; |
| 88 | psEncC->indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..NLSFInterpCoef_Q2cxx . . $ $anonymous_type_c9846ade8c67dd67_6#NLSFInterpCoef_Q2. = (opus_int8cxx . . $ opus_int8#)k; |
| 89 | } else if( res_nrg_interp > res_nrg_2nd ) { |
| 90 | /* No reason to continue iterating - residual energies will continue to climb */ |
| 91 | break; |
| 92 | } |
| 93 | res_nrg_2nd = res_nrg_interp; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | if( psEncC->indicescxx . . $ $anonymous_type_c9846ade8c67dd67_7#indices..NLSFInterpCoef_Q2cxx . . $ $anonymous_type_c9846ade8c67dd67_6#NLSFInterpCoef_Q2. == 4 ) { |
| 98 | /* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */ |
| 99 | silk_A2NLSF_FLPcxx . . $ silk_A2NLSF_FLP(ed90014d4b5d0971).( NLSF_Q15, a, psEncC->predictLPCOrdercxx . . $ $anonymous_type_c9846ade8c67dd67_7#predictLPCOrder. ); |
| 100 | } |
| 101 | |
| 102 | celt_assertcxx . . $ `external/opusfile/opus/celt/arch.h:80:9`!( psEncC->indices.NLSFInterpCoef_Q2 == 4 || |
| 103 | ( psEncC->useInterpolatedNLSFs && !psEncC->first_frame_after_reset && psEncC->nb_subfr == MAX_NB_SUBFRcxx . . $ `external/opusfile/opus/silk/define.h:90:9`! ) ); |
| 104 | } |