]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vp3dsp.c
DCA: ARM/NEON optimised lfe_fir
[ffmpeg] / libavcodec / vp3dsp.c
index 9a19dcaf461ca50ee35451c549c65f1d45817d0b..87b64de385eac865b3b7600220989a31e03e6e49 100644 (file)
@@ -1,28 +1,29 @@
 /*
  * 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
  */
 
 /**
- * @file vp3dsp.c
+ * @file libavcodec/vp3dsp.c
  * Standard C DSP-oriented functions cribbed from the original VP3
  * 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);
@@ -227,3 +222,34 @@ void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*
 void ff_vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/){
     idct(dest, line_size, block, 2);
 }
+
+void ff_vp3_v_loop_filter_c(uint8_t *first_pixel, int stride, int *bounding_values)
+{
+    unsigned char *end;
+    int filter_value;
+    const int nstride= -stride;
+
+    for (end= first_pixel + 8; first_pixel < end; first_pixel++) {
+        filter_value =
+            (first_pixel[2 * nstride] - first_pixel[ stride])
+         +3*(first_pixel[0          ] - first_pixel[nstride]);
+        filter_value = bounding_values[(filter_value + 4) >> 3];
+        first_pixel[nstride] = av_clip_uint8(first_pixel[nstride] + filter_value);
+        first_pixel[0] = av_clip_uint8(first_pixel[0] - filter_value);
+    }
+}
+
+void ff_vp3_h_loop_filter_c(uint8_t *first_pixel, int stride, int *bounding_values)
+{
+    unsigned char *end;
+    int filter_value;
+
+    for (end= first_pixel + 8*stride; first_pixel != end; first_pixel += stride) {
+        filter_value =
+            (first_pixel[-2] - first_pixel[ 1])
+         +3*(first_pixel[ 0] - first_pixel[-1]);
+        filter_value = bounding_values[(filter_value + 4) >> 3];
+        first_pixel[-1] = av_clip_uint8(first_pixel[-1] + filter_value);
+        first_pixel[ 0] = av_clip_uint8(first_pixel[ 0] - filter_value);
+    }
+}