]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vp3dsp.c
Simplify l1mv/l1ref calculation.
[ffmpeg] / libavcodec / vp3dsp.c
index 9a19dcaf461ca50ee35451c549c65f1d45817d0b..d374a85f6ea814e5f278245c40230e4fb36ce369 100644 (file)
@@ -1,18 +1,20 @@
 /*
  * Copyright (C) 2004 the ffmpeg project
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -22,7 +24,6 @@
  * source code.
  */
 
-#include "common.h"
 #include "avcodec.h"
 #include "dsputil.h"
 
 
 #define M(a,b) (((a) * (b))>>16)
 
-static always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
+static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
 {
     int16_t *ip = input;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
 
     int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H;
     int Ed, Gd, Add, Bdd, Fd, Hd;
@@ -112,8 +113,13 @@ static always_inline void idct(uint8_t *dst, int stride, int16_t *input, int typ
             Cd = A + C;
             Dd = B + D;
 
-            E = M(xC4S4, (ip[0*8] + ip[4*8]));
-            F = M(xC4S4, (ip[0*8] - ip[4*8]));
+            E = M(xC4S4, (ip[0*8] + ip[4*8])) + 8;
+            F = M(xC4S4, (ip[0*8] - ip[4*8])) + 8;
+
+            if(type==1){  //HACK
+                E += 16*128;
+                F += 16*128;
+            }
 
             G = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]);
             H = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]);
@@ -127,17 +133,6 @@ static always_inline void idct(uint8_t *dst, int stride, int16_t *input, int typ
             Fd = F - Ad;
             Hd = Bd + H;
 
-            if(type==1){  //HACK
-                Gd += 16*128;
-                Add+= 16*128;
-                Ed += 16*128;
-                Fd += 16*128;
-            }
-            Gd += IdctAdjustBeforeShift;
-            Add += IdctAdjustBeforeShift;
-            Ed += IdctAdjustBeforeShift;
-            Fd += IdctAdjustBeforeShift;
-
             /* Final sequence of operations over-write original inputs. */
             if(type==0){
                 ip[0*8] = (Gd + Cd )  >> 4;
@@ -195,7 +190,7 @@ static always_inline void idct(uint8_t *dst, int stride, int16_t *input, int typ
                 dst[4*stride]=
                 dst[5*stride]=
                 dst[6*stride]=
-                dst[7*stride]= 128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
+                dst[7*stride]= cm[128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20)];
             }else{
                 if(ip[0*8]){
                     int v= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);