| 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 | #ifndef SILK_SIGPROC_FLP_H |
| 29 | #define SILK_SIGPROC_FLP_Hcxx . . $ `external/opusfile/opus/silk/float/SigProc_FLP.h:29:9`! |
| 30 | |
| 31 | #include "SigProc_FIX.h"cxx . . $ `<file>/external/opusfile/opus/silk/SigProc_FIX.h`/ |
| 32 | #include "float_cast.h"cxx . . $ `<file>/external/opusfile/opus/celt/float_cast.h`/ |
| 33 | #include <math.h> |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | extern "C" |
| 37 | { |
| 38 | #endif |
| 39 | |
| 40 | /********************************************************************/ |
| 41 | /* SIGNAL PROCESSING FUNCTIONS */ |
| 42 | /********************************************************************/ |
| 43 | |
| 44 | /* Chirp (bw expand) LP AR filter */ |
| 45 | void silk_bwexpander_FLPcxx . . $ silk_bwexpander_FLP(aa182a3194b62131).( |
| 46 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *ar, /* I/O AR filter to be expanded (without leading 1) */ |
| 47 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! d, /* I length of ar */ |
| 48 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! chirp /* I chirp factor (typically in range (0..1) ) */ |
| 49 | ); |
| 50 | |
| 51 | /* compute inverse of LPC prediction gain, and */ |
| 52 | /* test if LPC coefficients are stable (all poles within unit circle) */ |
| 53 | /* this code is based on silk_FLP_a2k() */ |
| 54 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! silk_LPC_inverse_pred_gain_FLPcxx . . $ silk_LPC_inverse_pred_gain_FLP(f4410a5452895fcd).( /* O return inverse prediction gain, energy domain */ |
| 55 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *A, /* I prediction coefficients [order] */ |
| 56 | opus_int32cxx . . $ opus_int32# order /* I prediction order */ |
| 57 | ); |
| 58 | |
| 59 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! silk_schur_FLPcxx . . $ silk_schur_FLP(5541a936430c01ec).( /* O returns residual energy */ |
| 60 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! refl_coef[], /* O reflection coefficients (length order) */ |
| 61 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! auto_corr[], /* I autocorrelation sequence (length order+1) */ |
| 62 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! order /* I order */ |
| 63 | ); |
| 64 | |
| 65 | void silk_k2a_FLPcxx . . $ silk_k2a_FLP(8e5bb7dd50cd87b6).( |
| 66 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *A, /* O prediction coefficients [order] */ |
| 67 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *rc, /* I reflection coefficients [order] */ |
| 68 | opus_int32cxx . . $ opus_int32# order /* I prediction order */ |
| 69 | ); |
| 70 | |
| 71 | /* compute autocorrelation */ |
| 72 | void silk_autocorrelation_FLPcxx . . $ silk_autocorrelation_FLP(5bf2be13bedcea69).( |
| 73 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *results, /* O result (length correlationCount) */ |
| 74 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *inputData, /* I input data to correlate */ |
| 75 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! inputDataSize, /* I length of input */ |
| 76 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! correlationCount /* I number of correlation taps to compute */ |
| 77 | ); |
| 78 | |
| 79 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! silk_pitch_analysis_core_FLPcxx . . $ silk_pitch_analysis_core_FLP(29067da6902c468d).( /* O Voicing estimate: 0 voiced, 1 unvoiced */ |
| 80 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *frame, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ |
| 81 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! *pitch_out, /* O Pitch lag values [nb_subfr] */ |
| 82 | opus_int16cxx . . $ opus_int16# *lagIndex, /* O Lag Index */ |
| 83 | opus_int8cxx . . $ opus_int8# *contourIndex, /* O Pitch contour Index */ |
| 84 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *LTPCorr, /* I/O Normalized correlation; input: value from previous frame */ |
| 85 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! prevLag, /* I Last lag of previous frame; set to zero is unvoiced */ |
| 86 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! search_thres1, /* I First stage threshold for lag candidates 0 - 1 */ |
| 87 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! search_thres2, /* I Final threshold for lag candidates 0 - 1 */ |
| 88 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! Fs_kHz, /* I sample frequency (kHz) */ |
| 89 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! complexity, /* I Complexity setting, 0-2, where 2 is highest */ |
| 90 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! nb_subfr, /* I Number of 5 ms subframes */ |
| 91 | int arch /* I Run-time architecture */ |
| 92 | ); |
| 93 | |
| 94 | void silk_insertion_sort_decreasing_FLPcxx . . $ silk_insertion_sort_decreasing_FLP(796df4a72e66606b).( |
| 95 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *a, /* I/O Unsorted / Sorted vector */ |
| 96 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! *idx, /* O Index vector for the sorted elements */ |
| 97 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! L, /* I Vector length */ |
| 98 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! K /* I Number of correctly sorted positions */ |
| 99 | ); |
| 100 | |
| 101 | /* Compute reflection coefficients from input signal */ |
| 102 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! silk_burg_modified_FLPcxx . . $ silk_burg_modified_FLP(4297ace9da296b3).( /* O returns residual energy */ |
| 103 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! A[], /* O prediction coefficients (length order) */ |
| 104 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! x[], /* I input signal, length: nb_subfr*(D+L_sub) */ |
| 105 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! minInvGain, /* I minimum inverse prediction gain */ |
| 106 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! subfr_length, /* I input signal subframe length (incl. D preceding samples) */ |
| 107 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! nb_subfr, /* I number of subframes stacked in x */ |
| 108 | const opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! D /* I order */ |
| 109 | ); |
| 110 | |
| 111 | /* multiply a vector by a constant */ |
| 112 | void silk_scale_vector_FLPcxx . . $ silk_scale_vector_FLP(10673a7d0b519349).( |
| 113 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *data1, |
| 114 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! gain, |
| 115 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! dataSize |
| 116 | ); |
| 117 | |
| 118 | /* copy and multiply a vector by a constant */ |
| 119 | void silk_scale_copy_vector_FLPcxx . . $ silk_scale_copy_vector_FLP(7445535a3bd3c98e).( |
| 120 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *data_out, |
| 121 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *data_in, |
| 122 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! gain, |
| 123 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! dataSize |
| 124 | ); |
| 125 | |
| 126 | /* inner product of two silk_float arrays, with result as double */ |
| 127 | double silk_inner_product_FLPcxx . . $ silk_inner_product_FLP(994296062db6b4e2).( |
| 128 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *data1, |
| 129 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *data2, |
| 130 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! dataSize |
| 131 | ); |
| 132 | |
| 133 | /* sum of squares of a silk_float array, with result as double */ |
| 134 | double silk_energy_FLPcxx . . $ silk_energy_FLP(b1731ecc7d336c81).( |
| 135 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *data, |
| 136 | opus_intcxx . . $ `external/opusfile/opus/opus_types.h:36:9`! dataSize |
| 137 | ); |
| 138 | |
| 139 | /********************************************************************/ |
| 140 | /* MACROS */ |
| 141 | /********************************************************************/ |
| 142 | |
| 143 | #define PIcxx . . $ `external/opusfile/opus/silk/float/SigProc_FLP.h:143:9`! (3.1415926536f) |
| 144 | |
| 145 | #define silk_min_floatcxx . . $ `external/opusfile/opus/silk/float/SigProc_FLP.h:145:9`!( a, b ) (((a) < (b)) ? (a) : (b)) |
| 146 | #define silk_max_floatcxx . . $ `external/opusfile/opus/silk/float/SigProc_FLP.h:146:9`!( a, b ) (((a) > (b)) ? (a) : (b)) |
| 147 | #define silk_abs_floatcxx . . $ `external/opusfile/opus/silk/float/SigProc_FLP.h:147:9`!( a ) ((silk_float)fabs(a)) |
| 148 | |
| 149 | /* sigmoid function */ |
| 150 | static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! silk_sigmoidcxx . . $ silk_sigmoid(fbcf3211dfe1bfd1).( silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! x ) |
| 151 | { |
| 152 | return (silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`!)(1.0 / (1.0 + expcxx . . $ exp(447c67c6676f75c3).(-x))); |
| 153 | } |
| 154 | |
| 155 | /* floating-point to integer conversion (rounding) */ |
| 156 | static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! opus_int32cxx . . $ opus_int32# silk_float2intcxx . . $ silk_float2int(1bb0578f3efdc255).( silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! x ) |
| 157 | { |
| 158 | return (opus_int32cxx . . $ opus_int32#)float2intcxx . . $ float2int(1bb0578f3efdc255).( x ); |
| 159 | } |
| 160 | |
| 161 | /* floating-point to integer conversion (rounding) */ |
| 162 | static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! void silk_float2short_arraycxx . . $ silk_float2short_array(ed90014d4b5d0971).( |
| 163 | opus_int16cxx . . $ opus_int16# *out, |
| 164 | const silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *in, |
| 165 | opus_int32cxx . . $ opus_int32# length |
| 166 | ) |
| 167 | { |
| 168 | opus_int32cxx . . $ opus_int32# k; |
| 169 | for( k = length - 1; k >= 0; k-- ) { |
| 170 | out[k] = silk_SAT16cxx . . $ opus_int32#( (opus_int32)float2int( in[k] ) ); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | /* integer to floating-point conversion */ |
| 175 | static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! void silk_short2float_arraycxx . . $ silk_short2float_array(18833b0d715537a5).( |
| 176 | silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! *out, |
| 177 | const opus_int16cxx . . $ opus_int16# *in, |
| 178 | opus_int32cxx . . $ opus_int32# length |
| 179 | ) |
| 180 | { |
| 181 | opus_int32cxx . . $ opus_int32# k; |
| 182 | for( k = length - 1; k >= 0; k-- ) { |
| 183 | out[k] = (silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`!)in[k]; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | /* using log2() helps the fixed-point conversion */ |
| 188 | static OPUS_INLINEcxx . . $ `external/opusfile/opus/opus_defines.h:110:10`! silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! silk_log2cxx . . $ silk_log2(2f2c9d02d22c701f).( double x ) |
| 189 | { |
| 190 | return ( silk_floatcxx . . $ `external/opusfile/opus/silk/typedef.h:36:10`! )( 3.32192809488736 * log10cxx . . $ log10(447c67c6676f75c3).( x ) ); |
| 191 | } |
| 192 | |
| 193 | #ifdef __cplusplus |
| 194 | } |
| 195 | #endif |
| 196 | |
| 197 | #endif /* SILK_SIGPROC_FLP_H */ |