comparison acelp_vectors.c @ 10676:8ee37f5571dc libavcodec

Commit functions used by both AMRNB and SIPR
author vitor
date Sat, 12 Dec 2009 13:58:07 +0000
parents 8e91a3efdbd2
children 608d19b30fa3
comparison
equal deleted inserted replaced
10675:03d02e21b432 10676:8ee37f5571dc
125 } 125 }
126 126
127 fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192; 127 fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192;
128 } 128 }
129 129
130 void ff_decode_10_pulses_35bits(const int16_t *fixed_index,
131 AMRFixed *fixed_sparse,
132 const uint8_t *gray_decode,
133 int half_pulse_count, int bits)
134 {
135 int i;
136 int mask = (1 << bits) - 1;
137
138 fixed_sparse->n = 2 * half_pulse_count;
139 for (i = 0; i < half_pulse_count; i++) {
140 const int pos1 = gray_decode[fixed_index[2*i+1] & mask] + i;
141 const int pos2 = gray_decode[fixed_index[2*i ] & mask] + i;
142 const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0;
143 fixed_sparse->x[2*i+1] = pos1;
144 fixed_sparse->x[2*i ] = pos2;
145 fixed_sparse->y[2*i+1] = sign;
146 fixed_sparse->y[2*i ] = pos2 < pos1 ? -sign : sign;
147 }
148 }
149
130 void ff_acelp_weighted_vector_sum( 150 void ff_acelp_weighted_vector_sum(
131 int16_t* out, 151 int16_t* out,
132 const int16_t *in_a, 152 const int16_t *in_a,
133 const int16_t *in_b, 153 const int16_t *in_b,
134 int16_t weight_coeff_a, 154 int16_t weight_coeff_a,
186 if (scalefactor) 206 if (scalefactor)
187 scalefactor = sqrt(sum_of_squares / scalefactor); 207 scalefactor = sqrt(sum_of_squares / scalefactor);
188 for (i = 0; i < n; i++) 208 for (i = 0; i < n; i++)
189 out[i] = in[i] * scalefactor; 209 out[i] = in[i] * scalefactor;
190 } 210 }
211
212 void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size)
213 {
214 int i;
215
216 for (i=0; i < in->n; i++) {
217 int x = in->x[i];
218 float y = in->y[i] * scale;
219 out[x] += y;
220
221 x += in->pitch_lag;
222 while (x < size) {
223 y *= in->pitch_fac;
224 out[x] += y;
225 x += in->pitch_lag;
226 }
227 }
228 }
229
230 void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size)
231 {
232 int i;
233
234 for (i=0; i < in->n; i++) {
235 int x = in->x[i];
236 out[x] = 0.0;
237
238 x += in->pitch_lag;
239 while (x < size) {
240 out[x] = 0.0;
241 x += in->pitch_lag;
242 }
243 }
244 }