changeset 7128:614bc53e67a8 libavcodec

Use lpc_coef[2] instead of lpc_coef and lpc_coef_old
author vitor
date Tue, 24 Jun 2008 18:38:55 +0000
parents 8ab2d77fd502
children 322023e630a6
files ra144.c
diffstat 1 files changed, 19 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/ra144.c	Tue Jun 24 18:13:44 2008 +0000
+++ b/ra144.c	Tue Jun 24 18:38:55 2008 +0000
@@ -32,10 +32,12 @@
     unsigned int     old_energy;        ///< previous frame energy
 
     unsigned int     lpc_tables[2][10];
-    unsigned int    *lpc_coef;          ///< LPC coefficients
-    unsigned int    *lpc_coef_old;      ///< previous frame LPC coefficients
-    unsigned int     lpc_refl_rms;
-    unsigned int     lpc_refl_rms_old;
+
+    /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame
+     *  and lpc_coef[1] of the previous one */
+    unsigned int    *lpc_coef[2];
+
+    unsigned int     lpc_refl_rms[2];
 
     /** the current subblock padded by the last 10 values of the previous one*/
     int16_t curr_sblock[50];
@@ -49,8 +51,8 @@
 {
     RA144Context *ractx = avctx->priv_data;
 
-    ractx->lpc_coef     = ractx->lpc_tables[0];
-    ractx->lpc_coef_old = ractx->lpc_tables[1];
+    ractx->lpc_coef[0] = ractx->lpc_tables[0];
+    ractx->lpc_coef[1] = ractx->lpc_tables[1];
 
     return 0;
 }
@@ -310,17 +312,17 @@
     // Interpolate block coefficients from the this frame forth block and
     // last frame forth block
     for (x=0; x<30; x++)
-        out[x] = (a * ractx->lpc_coef[x] + b * ractx->lpc_coef_old[x])>> 2;
+        out[x] = (a * ractx->lpc_coef[0][x] + b * ractx->lpc_coef[1][x])>> 2;
 
     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);
-            return rescale_rms(ractx->lpc_refl_rms, energy);
+            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_old);
-            return rescale_rms(ractx->lpc_refl_rms_old, energy);
+            int_to_int16(out, ractx->lpc_coef[1]);
+            return rescale_rms(ractx->lpc_refl_rms[1], energy);
         }
     } else {
         return rescale_rms(rms(work), energy);
@@ -354,8 +356,8 @@
     for (i=0; i<10; i++)
         lpc_refl[i] = lpc_refl_cb[i][get_bits(&gb, sizes[i])];
 
-    eval_coefs(ractx->lpc_coef, lpc_refl);
-    ractx->lpc_refl_rms = rms(lpc_refl);
+    eval_coefs(ractx->lpc_coef[0], lpc_refl);
+    ractx->lpc_refl_rms[0] = rms(lpc_refl);
 
     energy = energy_tab[get_bits(&gb, 5)];
 
@@ -363,9 +365,9 @@
     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[3] = rescale_rms(ractx->lpc_refl_rms, energy);
+    refl_rms[3] = rescale_rms(ractx->lpc_refl_rms[0], energy);
 
-    int_to_int16(block_coefs[3], ractx->lpc_coef);
+    int_to_int16(block_coefs[3], ractx->lpc_coef[0]);
 
     for (c=0; c<4; c++) {
         do_output_subblock(ractx, block_coefs[c], refl_rms[c], &gb);
@@ -375,9 +377,9 @@
     }
 
     ractx->old_energy = energy;
-    ractx->lpc_refl_rms_old = ractx->lpc_refl_rms;
+    ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0];
 
-    FFSWAP(unsigned int *, ractx->lpc_coef_old, ractx->lpc_coef);
+    FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]);
 
     *data_size = 2*160;
     return 20;