changeset 5742:f8029206caa2 libavcodec

simplify lpc
author lorenm
date Sun, 30 Sep 2007 03:36:13 +0000
parents 154b02065699
children 8ce32ae71c01
files flacenc.c
diffstat 1 files changed, 14 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/flacenc.c	Sun Sep 30 03:01:56 2007 +0000
+++ b/flacenc.c	Sun Sep 30 03:36:13 2007 +0000
@@ -876,10 +876,10 @@
 }
 
 #define LPC1(x) {\
-    int s = smp[i-(x)+1];\
+    int c = coefs[(x)-1];\
+    p0 += c*s;\
+    s = smp[i-(x)+1];\
     p1 += c*s;\
-    c = coefs[(x)-2];\
-    p0 += c*s;\
 }
 
 static av_always_inline void encode_residual_lpc_unrolled(
@@ -888,9 +888,8 @@
 {
     int i;
     for(i=order; i<n; i+=2) {
-        int c = coefs[order-1];
-        int p0 = c * smp[i-order];
-        int p1 = 0;
+        int s = smp[i-order];
+        int p0 = 0, p1 = 0;
         if(big) {
             switch(order) {
                 case 32: LPC1(32)
@@ -924,6 +923,7 @@
                          LPC1( 4)
                          LPC1( 3)
                          LPC1( 2)
+                         LPC1( 1)
             }
         } else {
             switch(order) {
@@ -934,9 +934,9 @@
                 case  4: LPC1( 4)
                 case  3: LPC1( 3)
                 case  2: LPC1( 2)
+                case  1: LPC1( 1)
             }
         }
-        p1 += c * smp[i];
         res[i  ] = smp[i  ] - (p0 >> shift);
         res[i+1] = smp[i+1] - (p1 >> shift);
     }
@@ -952,16 +952,15 @@
 #ifdef CONFIG_SMALL
     for(i=order; i<n; i+=2) {
         int j;
-        int32_t c = coefs[0];
-        int32_t p0 = 0, p1 = c*smp[i];
-        for(j=1; j<order; j++) {
-            int32_t s = smp[i-j];
+        int s = smp[i];
+        int p0 = 0, p1 = 0;
+        for(j=0; j<order; j++) {
+            int c = coefs[j];
+            p1 += c*s;
+            s = smp[i-j-1];
             p0 += c*s;
-            c = coefs[j];
-            p1 += c*s;
         }
-        p0 += c*smp[i-order];
-        res[i+0] = smp[i+0] - (p0 >> shift);
+        res[i  ] = smp[i  ] - (p0 >> shift);
         res[i+1] = smp[i+1] - (p1 >> shift);
     }
 #else