comparison acelp_vectors.c @ 11052:00fcecde822b libavcodec

Add no_repeat_mask option, so that single-pulse vectors can also be expressed in a AMRFixed structure and handled by ff_set_fixed_vector().
author rbultje
date Fri, 29 Jan 2010 16:49:06 +0000
parents 3f66d1d80e03
children c2e19a511e26
comparison
equal deleted inserted replaced
11051:5d4991dd23de 11052:00fcecde822b
162 int half_pulse_count, int bits) 162 int half_pulse_count, int bits)
163 { 163 {
164 int i; 164 int i;
165 int mask = (1 << bits) - 1; 165 int mask = (1 << bits) - 1;
166 166
167 fixed_sparse->no_repeat_mask = 0;
167 fixed_sparse->n = 2 * half_pulse_count; 168 fixed_sparse->n = 2 * half_pulse_count;
168 for (i = 0; i < half_pulse_count; i++) { 169 for (i = 0; i < half_pulse_count; i++) {
169 const int pos1 = gray_decode[fixed_index[2*i+1] & mask] + i; 170 const int pos1 = gray_decode[fixed_index[2*i+1] & mask] + i;
170 const int pos2 = gray_decode[fixed_index[2*i ] & mask] + i; 171 const int pos2 = gray_decode[fixed_index[2*i ] & mask] + i;
171 const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0; 172 const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0;
241 void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size) 242 void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size)
242 { 243 {
243 int i; 244 int i;
244 245
245 for (i=0; i < in->n; i++) { 246 for (i=0; i < in->n; i++) {
246 int x = in->x[i]; 247 int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
247 float y = in->y[i] * scale; 248 float y = in->y[i] * scale;
248 249
249 do { 250 do {
250 out[x] += y; 251 out[x] += y;
251 y *= in->pitch_fac; 252 y *= in->pitch_fac;
252 x += in->pitch_lag; 253 x += in->pitch_lag;
253 } while (x < size); 254 } while (x < size && repeats);
254 } 255 }
255 } 256 }
256 257
257 void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size) 258 void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size)
258 { 259 {
259 int i; 260 int i;
260 261
261 for (i=0; i < in->n; i++) { 262 for (i=0; i < in->n; i++) {
262 int x = in->x[i]; 263 int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
263 264
264 do { 265 do {
265 out[x] = 0.0; 266 out[x] = 0.0;
266 x += in->pitch_lag; 267 x += in->pitch_lag;
267 } while (x < size); 268 } while (x < size && repeats);
268 } 269 }
269 } 270 }