changeset 7004:5bad976fae7b libavcodec

Split function rms() in two (it does two unrelated things)
author vitor
date Thu, 05 Jun 2008 16:11:51 +0000
parents c29f78dbe1bd
children 6e374f47da64
files ra144.c
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ra144.c	Thu Jun 05 02:20:15 2008 +0000
+++ b/ra144.c	Thu Jun 05 16:11:51 2008 +0000
@@ -174,7 +174,12 @@
     memcpy(statbuf, work + 40, 20);
 }
 
-static unsigned int rms(const int *data, int f)
+static unsigned int rescale_rms(int rms, int energy)
+{
+    return (rms * energy) >> 10;
+}
+
+static unsigned int rms(const int *data)
 {
     int x;
     unsigned int res = 0x10000;
@@ -197,7 +202,6 @@
         res = t_sqrt(res);
 
     res >>= (b + 10);
-    res = (res * f) >> 10;
     return res;
 }
 
@@ -314,13 +318,13 @@
         // coefficients
         if (copynew) {
             int_to_int16(decsp, ractx->lpc_coef);
-            return rms(ractx->lpc_refl, energy);
+            return rescale_rms(rms(ractx->lpc_refl), energy);
         } else {
             int_to_int16(decsp, ractx->lpc_coef_old);
-            return rms(ractx->lpc_refl_old, energy);
+            return rescale_rms(rms(ractx->lpc_refl_old), energy);
         }
     } else {
-        return rms(work, energy);
+        return rescale_rms(rms(work), energy);
     }
 }
 
@@ -358,7 +362,7 @@
     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] = rms(ractx->lpc_refl, energy);
+    refl_rms[3] = rescale_rms(rms(ractx->lpc_refl), energy);
 
     int_to_int16(block_coefs[3], ractx->lpc_coef);