00001
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include "dsp.h"
00047
00048 #if defined(FORCE_ALL_GENERICS) || \
00049 defined(FORCE_GENERIC_WIN16_GAUSS) || \
00050 !defined(TARGET_SPECIFIC_WIN16_GAUSS)
00051
00052 #include "win_gauss.h"
00053
00054
00055
00056
00057
00058
00059 void dsp16_win_gauss(dsp16_t *vect1, int size)
00060 {
00061 int k, i;
00062 S32 x, res;
00063 dsp16_t s, t;
00064
00065 const S32 cst_a = (S32) DSP_Q(32-DSP16_QB, DSP16_QB, 1./CST_LN_2) >> 1;
00066
00067 const S32 cst_b = (S32) DSP16_Q(CST_LN_2);
00068
00069 const S32 cst_c = (S32) DSP_Q(32-DSP16_QB, DSP16_QB, 1./DSP_GAUSS_TETA) >> (DSP16_QB >> 1);
00070
00071
00072 t = DSP16_Q(0.);
00073
00074 s = (DSP16_Q(1.)/(size-1)) << 1;
00075
00076
00077 for(i=0; i<(size >> 1); i++)
00078 {
00079
00080 res = (((S32) (t - DSP16_Q(1.)))) >> ((DSP16_QB >> 1) + 1);
00081 #if (DSP16_QB & 1)
00082 res >>= 1;
00083 #endif
00084 res *= cst_c;
00085
00086
00087 res = res >> (DSP16_QB >> 1);
00088 #if (DSP16_QB & 1)
00089 res *= -(res >> 1);
00090 #else
00091 res *= -res;
00092 #endif
00093
00094
00095
00096
00097 x = res >> (DSP16_QB - 2);
00098 k = (x*cst_a) >> (DSP16_QB + 1);
00099
00100 if (k < -31)
00101 x = 0;
00102 else
00103 {
00104
00105 x = ((S32) res) - cst_b*((S32) ++k);
00106
00107 if (x > 0)
00108 x = ((S32) res) - cst_b*((S32) ++k);
00109
00110 x = dsp16_op_exp(x) >> dsp16_op_abs(k);
00111 }
00112
00113
00114 vect1[i] = x;
00115
00116 vect1[size-i-1] = x;
00117
00118 t += s;
00119 }
00120
00121
00122 if (size & 1)
00123 vect1[size >> 1] = DSP16_Q(1.);
00124 }
00125
00126 #endif
00127
00128 #if defined(FORCE_ALL_GENERICS) || \
00129 defined(FORCE_GENERIC_WIN32_GAUSS) || \
00130 !defined(TARGET_SPECIFIC_WIN32_GAUSS)
00131
00132
00133
00134
00135
00136
00137 void dsp32_win_gauss(dsp32_t *vect1, int size)
00138 {
00139 int k, i;
00140 dsp32_t s, t;
00141 S64 x, res;
00142
00143 const S64 cst_a = (S64) ((1LL/CST_LN_2)*(1LL << (DSP32_QB-1)));
00144
00145 const S64 cst_b = (S64) DSP32_Q(CST_LN_2);
00146
00147 const S64 cst_c = (S64) ((1LL/DSP_GAUSS_TETA)*(1LL << (DSP32_QB-(DSP32_QB >> 1))));
00148
00149
00150 t = DSP32_Q(0.);
00151
00152 s = (DSP32_Q(1.)/(size-1)) << 1;
00153
00154
00155 for(i=0; i<(size >> 1); i++)
00156 {
00157
00158 res = (((S64) (t - DSP32_Q(1.)))) >> ((DSP32_QB >> 1) + 1);
00159 #if (DSP32_QB & 1)
00160 res >>= 1;
00161 #endif
00162 res *= cst_c;
00163
00164
00165 res = res >> (DSP32_QB >> 1);
00166 #if (DSP32_QB & 1)
00167 res *= -(res >> 1);
00168 #else
00169 res *= -res;
00170 #endif
00171
00172
00173
00174
00175 x = res >> (DSP32_QB - 2);
00176 k = (x*cst_a) >> (DSP32_QB + 1);
00177
00178 if (k < -31)
00179 x = 0;
00180 else
00181 {
00182
00183 x = ((S64) res) - cst_b*((S64) ++k);
00184
00185 if (x > 0)
00186 x = ((S64) res) - cst_b*((S64) ++k);
00187
00188 x = dsp32_op_exp(x) >> dsp32_op_abs(k);
00189 }
00190
00191
00192 vect1[i] = x;
00193
00194 vect1[size-i-1] = x;
00195
00196 t += s;
00197 }
00198
00199
00200 if (size & 1)
00201 vect1[size >> 1] = DSP32_Q(1.);
00202 }
00203
00204 #endif