comparison acelp_vectors.c @ 10463:9f35b262d3f0 libavcodec

Commit some functions that are used by both SIPR and AMR. Based on AMR SoC code by Robert Swain and Colin McQuillan.
author vitor
date Tue, 27 Oct 2009 23:53:18 +0000
parents 139d30c8c274
children 5f2ced30548b
comparison
equal deleted inserted replaced
10462:dd97c2418d4e 10463:9f35b262d3f0
21 */ 21 */
22 22
23 #include <inttypes.h> 23 #include <inttypes.h>
24 #include "avcodec.h" 24 #include "avcodec.h"
25 #include "acelp_vectors.h" 25 #include "acelp_vectors.h"
26 #include "celp_math.h"
26 27
27 const uint8_t ff_fc_2pulses_9bits_track1[16] = 28 const uint8_t ff_fc_2pulses_9bits_track1[16] =
28 { 29 {
29 1, 3, 30 1, 3,
30 6, 8, 31 6, 8,
153 154
154 for(i=0; i<length; i++) 155 for(i=0; i<length; i++)
155 out[i] = weight_coeff_a * in_a[i] 156 out[i] = weight_coeff_a * in_a[i]
156 + weight_coeff_b * in_b[i]; 157 + weight_coeff_b * in_b[i];
157 } 158 }
159
160 void ff_adaptative_gain_control(float *buf_out, float speech_energ,
161 int size, float alpha, float *gain_mem)
162 {
163 int i;
164 float postfilter_energ = ff_dot_productf(buf_out, buf_out, size);
165 float gain_scale_factor = 1.0;
166 float mem = *gain_mem;
167
168 if (postfilter_energ)
169 gain_scale_factor = sqrt(speech_energ / postfilter_energ);
170
171 gain_scale_factor *= 1.0 - alpha;
172
173 for (i = 0; i < size; i++) {
174 mem = alpha * mem + gain_scale_factor;
175 buf_out[i] *= mem;
176 }
177
178 *gain_mem = mem;
179 }