Mercurial > libavcodec.hg
comparison ra144.c @ 6921:fbcb4507aefe libavcodec
Simplify implementation and use of dec2()
author | vitor |
---|---|
date | Wed, 28 May 2008 18:59:09 +0000 |
parents | 67c615c7e19c |
children | 8b2d8d412558 |
comparison
equal
deleted
inserted
replaced
6920:d02af7474bff | 6921:fbcb4507aefe |
---|---|
287 FFSWAP(int *, bp1, bp2); | 287 FFSWAP(int *, bp1, bp2); |
288 } | 288 } |
289 return retval; | 289 return retval; |
290 } | 290 } |
291 | 291 |
292 static int dec2(int16_t *decsp, const int *data, const int *inp, | 292 static int dec2(RA144Context *ractx, int16_t *decsp, int block_num, |
293 int f, const int *inp2, int a) | 293 int copynew, int f) |
294 { | 294 { |
295 int work[10]; | 295 int work[10]; |
296 int a = block_num + 1; | |
296 int b = NBLOCKS - a; | 297 int b = NBLOCKS - a; |
297 int x; | 298 int x; |
298 | 299 |
300 // Interpolate block coefficients from the this frame forth block and | |
301 // last frame forth block | |
299 for (x=0; x<30; x++) | 302 for (x=0; x<30; x++) |
300 decsp[x] = (a * inp[x] + b * inp2[x]) >> 2; | 303 decsp[x] = (a * ractx->lpc_coef[x] + b * ractx->lpc_coef_old[x])>> 2; |
301 | 304 |
302 if (eq(decsp, work)) | 305 if (eq(decsp, work)) { |
303 return dec1(decsp, data, inp, f); | 306 // The interpolated coefficients are unstable, copy either new or old |
304 else | 307 // coefficients |
308 if (copynew) | |
309 return dec1(decsp, ractx->lpc_refl, ractx->lpc_coef, f); | |
310 else | |
311 return dec1(decsp, ractx->lpc_refl_old, ractx->lpc_coef_old, f); | |
312 } else { | |
305 return rms(work, f); | 313 return rms(work, f); |
314 } | |
306 } | 315 } |
307 | 316 |
308 /* Uncompress one block (20 bytes -> 160*2 bytes) */ | 317 /* Uncompress one block (20 bytes -> 160*2 bytes) */ |
309 static int ra144_decode_frame(AVCodecContext * avctx, | 318 static int ra144_decode_frame(AVCodecContext * avctx, |
310 void *vdata, int *data_size, | 319 void *vdata, int *data_size, |
335 do_voice(ractx->lpc_refl, ractx->lpc_coef); | 344 do_voice(ractx->lpc_refl, ractx->lpc_coef); |
336 | 345 |
337 energy = decodeval[get_bits(&gb, 5) << 1]; // Useless table entries? | 346 energy = decodeval[get_bits(&gb, 5) << 1]; // Useless table entries? |
338 a = t_sqrt(energy*ractx->old_energy) >> 12; | 347 a = t_sqrt(energy*ractx->old_energy) >> 12; |
339 | 348 |
340 gbuf1[0] = dec2(gbuf2[0], ractx->lpc_refl_old, ractx->lpc_coef_old, ractx->old_energy, ractx->lpc_coef, 3); | 349 gbuf1[0] = dec2(ractx, gbuf2[0], 0, 0, ractx->old_energy); |
341 if (ractx->old_energy < energy) { | 350 gbuf1[1] = dec2(ractx, gbuf2[1], 1, energy > ractx->old_energy, a); |
342 gbuf1[1] = dec2(gbuf2[1], ractx->lpc_refl, ractx->lpc_coef, a, ractx->lpc_coef_old, 2); | 351 gbuf1[2] = dec2(ractx, gbuf2[2], 2, 1, energy); |
343 } else { | |
344 gbuf1[1] = dec2(gbuf2[1], ractx->lpc_refl_old, ractx->lpc_coef_old, a, ractx->lpc_coef, 2); | |
345 } | |
346 gbuf1[2] = dec2(gbuf2[2], ractx->lpc_refl, ractx->lpc_coef, energy, ractx->lpc_coef_old, 3); | |
347 gbuf1[3] = dec1(gbuf2[3], ractx->lpc_refl, ractx->lpc_coef, energy); | 352 gbuf1[3] = dec1(gbuf2[3], ractx->lpc_refl, ractx->lpc_coef, energy); |
348 | 353 |
349 /* do output */ | 354 /* do output */ |
350 for (c=0; c<4; c++) { | 355 for (c=0; c<4; c++) { |
351 do_output_subblock(ractx, gbuf2[c], gbuf1[c], data, &gb); | 356 do_output_subblock(ractx, gbuf2[c], gbuf1[c], data, &gb); |