]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blobdiff - libavcodec/cavsdsp.c
frsh: Export information about the last RTP contract and VRES
[frescor/ffmpeg.git] / libavcodec / cavsdsp.c
index 71aaddba5868dac6245fc9139c916bd316f87a32..69d3bd23232cbac630461598a953b68a63e3b490 100644 (file)
@@ -5,24 +5,25 @@
  *
  * Copyright (c) 2006  Stefan Gehrer <stefan.gehrer@gmx.de>
  *
- * 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
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <stdio.h>
 #include "dsputil.h"
-#include "cavsdsp.h"
 
 /*****************************************************************************
  *
@@ -62,16 +63,16 @@ static inline void loop_filter_l1(uint8_t *p0_p, int stride, int alpha, int beta
     int q0 = Q0;
 
     if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
-        int delta = clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc);
-        P0 = clip_uint8(p0+delta);
-        Q0 = clip_uint8(q0-delta);
+        int delta = av_clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc);
+        P0 = av_clip_uint8(p0+delta);
+        Q0 = av_clip_uint8(q0-delta);
         if(abs(P2-p0)<beta) {
-            delta = clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc);
-            P1 = clip_uint8(P1+delta);
+            delta = av_clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc);
+            P1 = av_clip_uint8(P1+delta);
         }
         if(abs(Q2-q0)<beta) {
-            delta = clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc);
-            Q1 = clip_uint8(Q1-delta);
+            delta = av_clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc);
+            Q1 = av_clip_uint8(Q1-delta);
         }
     }
 }
@@ -97,9 +98,9 @@ static inline void loop_filter_c2(uint8_t *p0_p,int stride,int alpha, int beta)
 static inline void loop_filter_c1(uint8_t *p0_p,int stride,int alpha, int beta,
                                   int tc) {
     if(abs(P0-Q0)<alpha && abs(P1-P0)<beta && abs(Q1-Q0)<beta) {
-        int delta = clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc);
-        P0 = clip_uint8(P0+delta);
-        Q0 = clip_uint8(Q0-delta);
+        int delta = av_clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc);
+        P0 = av_clip_uint8(P0+delta);
+        Q0 = av_clip_uint8(Q0-delta);
     }
 }
 
@@ -110,7 +111,7 @@ static inline void loop_filter_c1(uint8_t *p0_p,int stride,int alpha, int beta,
 #undef Q1
 #undef Q2
 
-void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
+static void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
                            int bs1, int bs2) {
     int i;
     if(bs1==2)
@@ -126,7 +127,7 @@ void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
     }
 }
 
-void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc,
+static void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc,
                            int bs1, int bs2) {
     int i;
     if(bs1==2)
@@ -142,7 +143,7 @@ void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc,
     }
 }
 
-void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
+static void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
                            int bs1, int bs2) {
     int i;
     if(bs1==2)
@@ -158,7 +159,7 @@ void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
     }
 }
 
-void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc,
+static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc,
                            int bs1, int bs2) {
     int i;
     if(bs1==2)
@@ -180,10 +181,12 @@ void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc,
  *
  ****************************************************************************/
 
-void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) {
+static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) {
     int i;
     DCTELEM (*src)[8] = (DCTELEM(*)[8])block;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+
+    src[0][0] += 8;
 
     for( i = 0; i < 8; i++ ) {
         const int a0 =  3*src[i][1] - (src[i][7]<<1);
@@ -198,22 +201,22 @@ void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) {
 
         const int a7 = (src[i][2]<<2) - 10*src[i][6];
         const int a6 = (src[i][6]<<2) + 10*src[i][2];
-        const int a5 = (src[i][0] - src[i][4]) << 3;
-        const int a4 = (src[i][0] + src[i][4]) << 3;
+        const int a5 = ((src[i][0] - src[i][4]) << 3) + 4;
+        const int a4 = ((src[i][0] + src[i][4]) << 3) + 4;
 
         const int b0 = a4 + a6;
         const int b1 = a5 + a7;
         const int b2 = a5 - a7;
         const int b3 = a4 - a6;
 
-        src[i][0] = (b0 + b4 + 4) >> 3;
-        src[i][1] = (b1 + b5 + 4) >> 3;
-        src[i][2] = (b2 + b6 + 4) >> 3;
-        src[i][3] = (b3 + b7 + 4) >> 3;
-        src[i][4] = (b3 - b7 + 4) >> 3;
-        src[i][5] = (b2 - b6 + 4) >> 3;
-        src[i][6] = (b1 - b5 + 4) >> 3;
-        src[i][7] = (b0 - b4 + 4) >> 3;
+        src[i][0] = (b0 + b4) >> 3;
+        src[i][1] = (b1 + b5) >> 3;
+        src[i][2] = (b2 + b6) >> 3;
+        src[i][3] = (b3 + b7) >> 3;
+        src[i][4] = (b3 - b7) >> 3;
+        src[i][5] = (b2 - b6) >> 3;
+        src[i][6] = (b1 - b5) >> 3;
+        src[i][7] = (b0 - b4) >> 3;
     }
     for( i = 0; i < 8; i++ ) {
         const int a0 =  3*src[1][i] - (src[7][i]<<1);
@@ -236,14 +239,14 @@ void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) {
         const int b2 = a5 - a7;
         const int b3 = a4 - a6;
 
-        dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4 + 64) >> 7)];
-        dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5 + 64) >> 7)];
-        dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6 + 64) >> 7)];
-        dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7 + 64) >> 7)];
-        dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7 + 64) >> 7)];
-        dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6 + 64) >> 7)];
-        dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5 + 64) >> 7)];
-        dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4 + 64) >> 7)];
+        dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4) >> 7)];
+        dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5) >> 7)];
+        dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6) >> 7)];
+        dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7) >> 7)];
+        dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7) >> 7)];
+        dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6) >> 7)];
+        dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5) >> 7)];
+        dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4) >> 7)];
     }
 }
 
@@ -256,7 +259,7 @@ void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) {
 #define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \
 static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
     const int h=8;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
     int i;\
     for(i=0; i<h; i++)\
     {\
@@ -275,7 +278,7 @@ static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstS
 \
 static void OPNAME ## cavs_filt8_v_  ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
     const int w=8;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
     int i;\
     for(i=0; i<w; i++)\
     {\
@@ -329,7 +332,7 @@ static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_
     int16_t *tmp = temp;\
     const int h=8;\
     const int w=8;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
     int i;\
     src1 -= 2*srcStride;\
     for(i=0; i<h+5; i++)\
@@ -416,66 +419,63 @@ static void OPNAME ## cavs_filt16_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8
 }\
 
 #define CAVS_MC(OPNAME, SIZE) \
-void OPNAME ## cavs_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
-}\
-void OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
     OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
     OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
     OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
     OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
     OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
     OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \
 }\
 \
-void OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
+static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
   OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \
 }\
 
@@ -509,3 +509,37 @@ CAVS_MC(put_, 8)
 CAVS_MC(put_, 16)
 CAVS_MC(avg_, 8)
 CAVS_MC(avg_, 16)
+
+void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
+void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
+void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
+void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
+
+void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) {
+#define dspfunc(PFX, IDX, NUM) \
+    c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \
+    c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \
+    c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_c; \
+    c->PFX ## _pixels_tab[IDX][ 3] = ff_ ## PFX ## NUM ## _mc30_c; \
+    c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_c; \
+    c->PFX ## _pixels_tab[IDX][ 5] = ff_ ## PFX ## NUM ## _mc11_c; \
+    c->PFX ## _pixels_tab[IDX][ 6] = ff_ ## PFX ## NUM ## _mc21_c; \
+    c->PFX ## _pixels_tab[IDX][ 7] = ff_ ## PFX ## NUM ## _mc31_c; \
+    c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_c; \
+    c->PFX ## _pixels_tab[IDX][ 9] = ff_ ## PFX ## NUM ## _mc12_c; \
+    c->PFX ## _pixels_tab[IDX][10] = ff_ ## PFX ## NUM ## _mc22_c; \
+    c->PFX ## _pixels_tab[IDX][11] = ff_ ## PFX ## NUM ## _mc32_c; \
+    c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_c; \
+    c->PFX ## _pixels_tab[IDX][13] = ff_ ## PFX ## NUM ## _mc13_c; \
+    c->PFX ## _pixels_tab[IDX][14] = ff_ ## PFX ## NUM ## _mc23_c; \
+    c->PFX ## _pixels_tab[IDX][15] = ff_ ## PFX ## NUM ## _mc33_c
+    dspfunc(put_cavs_qpel, 0, 16);
+    dspfunc(put_cavs_qpel, 1, 8);
+    dspfunc(avg_cavs_qpel, 0, 16);
+    dspfunc(avg_cavs_qpel, 1, 8);
+    c->cavs_filter_lv = cavs_filter_lv_c;
+    c->cavs_filter_lh = cavs_filter_lh_c;
+    c->cavs_filter_cv = cavs_filter_cv_c;
+    c->cavs_filter_ch = cavs_filter_ch_c;
+    c->cavs_idct8_add = cavs_idct8_add_c;
+}