comparison ra144.c @ 7447:16737361e9ab libavcodec

Cosmetics: rename loop counter vars to i,j
author vitor
date Tue, 29 Jul 2008 18:07:11 +0000
parents 3c7f3265f970
children 85ab7655ad4d
comparison
equal deleted inserted replaced
7446:a4ebced5d4a2 7447:16737361e9ab
83 static void eval_coefs(int *coefs, const int *refl) 83 static void eval_coefs(int *coefs, const int *refl)
84 { 84 {
85 int buffer[10]; 85 int buffer[10];
86 int *b1 = buffer; 86 int *b1 = buffer;
87 int *b2 = coefs; 87 int *b2 = coefs;
88 int x, y; 88 int i, j;
89 89
90 for (x=0; x < 10; x++) { 90 for (i=0; i < 10; i++) {
91 b1[x] = refl[x] << 4; 91 b1[i] = refl[i] << 4;
92 92
93 for (y=0; y < x; y++) 93 for (j=0; j < i; j++)
94 b1[y] = ((refl[x] * b2[x-y-1]) >> 12) + b2[y]; 94 b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j];
95 95
96 FFSWAP(int *, b1, b2); 96 FFSWAP(int *, b1, b2);
97 } 97 }
98 98
99 for (x=0; x < 10; x++) 99 for (i=0; i < 10; i++)
100 coefs[x] >>= 4; 100 coefs[i] >>= 4;
101 } 101 }
102 102
103 /** 103 /**
104 * Copy the last offset values of *source to *target. If those values are not 104 * Copy the last offset values of *source to *target. If those values are not
105 * enough to fill the target buffer, fill it with another copy of those values. 105 * enough to fill the target buffer, fill it with another copy of those values.
149 return (rms * energy) >> 10; 149 return (rms * energy) >> 10;
150 } 150 }
151 151
152 static unsigned int rms(const int *data) 152 static unsigned int rms(const int *data)
153 { 153 {
154 int x; 154 int i;
155 unsigned int res = 0x10000; 155 unsigned int res = 0x10000;
156 int b = 0; 156 int b = 0;
157 157
158 for (x=0; x<10; x++) { 158 for (i=0; i < 10; i++) {
159 res = (((0x1000000 - data[x]*data[x]) >> 12) * res) >> 12; 159 res = (((0x1000000 - data[i]*data[i]) >> 12) * res) >> 12;
160 160
161 if (res == 0) 161 if (res == 0)
162 return 0; 162 return 0;
163 163
164 while (res <= 0x3fff) { 164 while (res <= 0x3fff) {
218 218
219 static void int_to_int16(int16_t *out, const int *inp) 219 static void int_to_int16(int16_t *out, const int *inp)
220 { 220 {
221 int i; 221 int i;
222 222
223 for (i=0; i<30; i++) 223 for (i=0; i < 30; i++)
224 *(out++) = *(inp++); 224 *(out++) = *(inp++);
225 } 225 }
226 226
227 /** 227 /**
228 * Evaluate the reflection coefficients from the filter coefficients. 228 * Evaluate the reflection coefficients from the filter coefficients.
280 int copyold, int energy) 280 int copyold, int energy)
281 { 281 {
282 int work[10]; 282 int work[10];
283 int a = block_num + 1; 283 int a = block_num + 1;
284 int b = NBLOCKS - a; 284 int b = NBLOCKS - a;
285 int x; 285 int i;
286 286
287 // Interpolate block coefficients from the this frame forth block and 287 // Interpolate block coefficients from the this frame forth block and
288 // last frame forth block 288 // last frame forth block
289 for (x=0; x<30; x++) 289 for (i=0; i<30; i++)
290 out[x] = (a * ractx->lpc_coef[0][x] + b * ractx->lpc_coef[1][x])>> 2; 290 out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2;
291 291
292 if (eval_refl(work, out, ractx)) { 292 if (eval_refl(work, out, ractx)) {
293 // The interpolated coefficients are unstable, copy either new or old 293 // The interpolated coefficients are unstable, copy either new or old
294 // coefficients 294 // coefficients
295 int_to_int16(out, ractx->lpc_coef[copyold]); 295 int_to_int16(out, ractx->lpc_coef[copyold]);
305 { 305 {
306 static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; 306 static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2};
307 unsigned int refl_rms[4]; // RMS of the reflection coefficients 307 unsigned int refl_rms[4]; // RMS of the reflection coefficients
308 uint16_t block_coefs[4][30]; // LPC coefficients of each sub-block 308 uint16_t block_coefs[4][30]; // LPC coefficients of each sub-block
309 unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame 309 unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame
310 int i, c; 310 int i, j;
311 int16_t *data = vdata; 311 int16_t *data = vdata;
312 unsigned int energy; 312 unsigned int energy;
313 313
314 RA144Context *ractx = avctx->priv_data; 314 RA144Context *ractx = avctx->priv_data;
315 GetBitContext gb; 315 GetBitContext gb;
336 refl_rms[2] = interp(ractx, block_coefs[2], 2, 0, energy); 336 refl_rms[2] = interp(ractx, block_coefs[2], 2, 0, energy);
337 refl_rms[3] = rescale_rms(ractx->lpc_refl_rms[0], energy); 337 refl_rms[3] = rescale_rms(ractx->lpc_refl_rms[0], energy);
338 338
339 int_to_int16(block_coefs[3], ractx->lpc_coef[0]); 339 int_to_int16(block_coefs[3], ractx->lpc_coef[0]);
340 340
341 for (c=0; c<4; c++) { 341 for (i=0; i < 4; i++) {
342 do_output_subblock(ractx, block_coefs[c], refl_rms[c], &gb); 342 do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb);
343 343
344 for (i=0; i<BLOCKSIZE; i++) 344 for (j=0; j < BLOCKSIZE; j++)
345 *data++ = av_clip_int16(ractx->curr_sblock[i + 10] << 2); 345 *data++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2);
346 } 346 }
347 347
348 ractx->old_energy = energy; 348 ractx->old_energy = energy;
349 ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0]; 349 ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0];
350 350