From afb40e7277573822d3a8262b2717367e20b0252f Mon Sep 17 00:00:00 2001 From: Vitor Sessak Date: Tue, 24 Jun 2008 21:32:34 +0000 Subject: [PATCH] Simplify interp() Originally committed as revision 13953 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/ra144.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c index d880c43edc..4e0b2c7a9a 100644 --- a/libavcodec/ra144.c +++ b/libavcodec/ra144.c @@ -301,7 +301,7 @@ static int eval_refl(int *refl, const int16_t *coefs, RA144Context *ractx) } static int interp(RA144Context *ractx, int16_t *out, int block_num, - int copynew, int energy) + int copyold, int energy) { int work[10]; int a = block_num + 1; @@ -316,13 +316,8 @@ static int interp(RA144Context *ractx, int16_t *out, int block_num, if (eval_refl(work, out, ractx)) { // The interpolated coefficients are unstable, copy either new or old // coefficients - if (copynew) { - int_to_int16(out, ractx->lpc_coef[0]); - return rescale_rms(ractx->lpc_refl_rms[0], energy); - } else { - int_to_int16(out, ractx->lpc_coef[1]); - return rescale_rms(ractx->lpc_refl_rms[1], energy); - } + int_to_int16(out, ractx->lpc_coef[copyold]); + return rescale_rms(ractx->lpc_refl_rms[copyold], energy); } else { return rescale_rms(rms(work), energy); } @@ -359,10 +354,10 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, energy = energy_tab[get_bits(&gb, 5)]; - refl_rms[0] = interp(ractx, block_coefs[0], 0, 0, ractx->old_energy); - refl_rms[1] = interp(ractx, block_coefs[1], 1, energy > ractx->old_energy, + refl_rms[0] = interp(ractx, block_coefs[0], 0, 1, ractx->old_energy); + refl_rms[1] = interp(ractx, block_coefs[1], 1, energy <= ractx->old_energy, t_sqrt(energy*ractx->old_energy) >> 12); - refl_rms[2] = interp(ractx, block_coefs[2], 2, 1, energy); + refl_rms[2] = interp(ractx, block_coefs[2], 2, 0, energy); refl_rms[3] = rescale_rms(ractx->lpc_refl_rms[0], energy); int_to_int16(block_coefs[3], ractx->lpc_coef[0]);