Statistics
| Branch: | Revision:

ffmpeg / libavcodec / cavsdsp.c @ 0abc2e73

History | View | Annotate | Download (21.3 KB)

1
/*
2
 * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
3
 *
4
 * DSP functions
5
 *
6
 * Copyright (c) 2006  Stefan Gehrer <stefan.gehrer@gmx.de>
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
 */
22

    
23
#include <stdio.h>
24
#include "dsputil.h"
25
#include "cavsdsp.h"
26

    
27
/*****************************************************************************
28
 *
29
 * in-loop deblocking filter
30
 *
31
 ****************************************************************************/
32

    
33
#define P2 p0_p[-3*stride]
34
#define P1 p0_p[-2*stride]
35
#define P0 p0_p[-1*stride]
36
#define Q0 p0_p[ 0*stride]
37
#define Q1 p0_p[ 1*stride]
38
#define Q2 p0_p[ 2*stride]
39

    
40
static inline void loop_filter_l2(uint8_t *p0_p,int stride,int alpha, int beta) {
41
    int p0 = P0;
42
    int q0 = Q0;
43

    
44
    if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
45
        int s = p0 + q0 + 2;
46
        alpha = (alpha>>2) + 2;
47
        if(abs(P2-p0) < beta && abs(p0-q0) < alpha) {
48
            P0 = (P1 + p0 + s) >> 2;
49
            P1 = (2*P1 + s) >> 2;
50
        } else
51
            P0 = (2*P1 + s) >> 2;
52
        if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) {
53
            Q0 = (Q1 + q0 + s) >> 2;
54
            Q1 = (2*Q1 + s) >> 2;
55
        } else
56
            Q0 = (2*Q1 + s) >> 2;
57
    }
58
}
59

    
60
static inline void loop_filter_l1(uint8_t *p0_p, int stride, int alpha, int beta, int tc) {
61
    int p0 = P0;
62
    int q0 = Q0;
63

    
64
    if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
65
        int delta = clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc);
66
        P0 = clip_uint8(p0+delta);
67
        Q0 = clip_uint8(q0-delta);
68
        if(abs(P2-p0)<beta) {
69
            delta = clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc);
70
            P1 = clip_uint8(P1+delta);
71
        }
72
        if(abs(Q2-q0)<beta) {
73
            delta = clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc);
74
            Q1 = clip_uint8(Q1-delta);
75
        }
76
    }
77
}
78

    
79
static inline void loop_filter_c2(uint8_t *p0_p,int stride,int alpha, int beta) {
80
    int p0 = P0;
81
    int q0 = Q0;
82

    
83
    if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
84
        int s = p0 + q0 + 2;
85
        alpha = (alpha>>2) + 2;
86
        if(abs(P2-p0) < beta && abs(p0-q0) < alpha) {
87
            P0 = (P1 + p0 + s) >> 2;
88
        } else
89
            P0 = (2*P1 + s) >> 2;
90
        if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) {
91
            Q0 = (Q1 + q0 + s) >> 2;
92
        } else
93
            Q0 = (2*Q1 + s) >> 2;
94
    }
95
}
96

    
97
static inline void loop_filter_c1(uint8_t *p0_p,int stride,int alpha, int beta,
98
                                  int tc) {
99
    if(abs(P0-Q0)<alpha && abs(P1-P0)<beta && abs(Q1-Q0)<beta) {
100
        int delta = clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc);
101
        P0 = clip_uint8(P0+delta);
102
        Q0 = clip_uint8(Q0-delta);
103
    }
104
}
105

    
106
#undef P0
107
#undef P1
108
#undef P2
109
#undef Q0
110
#undef Q1
111
#undef Q2
112

    
113
void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
114
                           int bs1, int bs2) {
115
    int i;
116
    if(bs1==2)
117
        for(i=0;i<16;i++)
118
            loop_filter_l2(d + i*stride,1,alpha,beta);
119
    else {
120
        if(bs1)
121
            for(i=0;i<8;i++)
122
                loop_filter_l1(d + i*stride,1,alpha,beta,tc);
123
        if (bs2)
124
            for(i=8;i<16;i++)
125
                loop_filter_l1(d + i*stride,1,alpha,beta,tc);
126
    }
127
}
128

    
129
void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc,
130
                           int bs1, int bs2) {
131
    int i;
132
    if(bs1==2)
133
        for(i=0;i<16;i++)
134
            loop_filter_l2(d + i,stride,alpha,beta);
135
    else {
136
        if(bs1)
137
            for(i=0;i<8;i++)
138
                loop_filter_l1(d + i,stride,alpha,beta,tc);
139
        if (bs2)
140
            for(i=8;i<16;i++)
141
                loop_filter_l1(d + i,stride,alpha,beta,tc);
142
    }
143
}
144

    
145
void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
146
                           int bs1, int bs2) {
147
    int i;
148
    if(bs1==2)
149
        for(i=0;i<8;i++)
150
            loop_filter_c2(d + i*stride,1,alpha,beta);
151
    else {
152
        if(bs1)
153
            for(i=0;i<4;i++)
154
                loop_filter_c1(d + i*stride,1,alpha,beta,tc);
155
        if (bs2)
156
            for(i=4;i<8;i++)
157
                loop_filter_c1(d + i*stride,1,alpha,beta,tc);
158
    }
159
}
160

    
161
void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc,
162
                           int bs1, int bs2) {
163
    int i;
164
    if(bs1==2)
165
        for(i=0;i<8;i++)
166
            loop_filter_c2(d + i,stride,alpha,beta);
167
    else {
168
        if(bs1)
169
            for(i=0;i<4;i++)
170
                loop_filter_c1(d + i,stride,alpha,beta,tc);
171
        if (bs2)
172
            for(i=4;i<8;i++)
173
                loop_filter_c1(d + i,stride,alpha,beta,tc);
174
    }
175
}
176

    
177
/*****************************************************************************
178
 *
179
 * inverse transform
180
 *
181
 ****************************************************************************/
182

    
183
void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) {
184
    int i;
185
    DCTELEM (*src)[8] = (DCTELEM(*)[8])block;
186
    uint8_t *cm = cropTbl + MAX_NEG_CROP;
187

    
188
    for( i = 0; i < 8; i++ ) {
189
        const int a0 =  3*src[i][1] - (src[i][7]<<1);
190
        const int a1 =  3*src[i][3] + (src[i][5]<<1);
191
        const int a2 =  (src[i][3]<<1) - 3*src[i][5];
192
        const int a3 =  (src[i][1]<<1) + 3*src[i][7];
193

    
194
        const int b4 = ((a0 + a1 + a3)<<1) + a1;
195
        const int b5 = ((a0 - a1 + a2)<<1) + a0;
196
        const int b6 = ((a3 - a2 - a1)<<1) + a3;
197
        const int b7 = ((a0 - a2 - a3)<<1) - a2;
198

    
199
        const int a7 = (src[i][2]<<2) - 10*src[i][6];
200
        const int a6 = (src[i][6]<<2) + 10*src[i][2];
201
        const int a5 = (src[i][0] - src[i][4]) << 3;
202
        const int a4 = (src[i][0] + src[i][4]) << 3;
203

    
204
        const int b0 = a4 + a6;
205
        const int b1 = a5 + a7;
206
        const int b2 = a5 - a7;
207
        const int b3 = a4 - a6;
208

    
209
        src[i][0] = (b0 + b4 + 4) >> 3;
210
        src[i][1] = (b1 + b5 + 4) >> 3;
211
        src[i][2] = (b2 + b6 + 4) >> 3;
212
        src[i][3] = (b3 + b7 + 4) >> 3;
213
        src[i][4] = (b3 - b7 + 4) >> 3;
214
        src[i][5] = (b2 - b6 + 4) >> 3;
215
        src[i][6] = (b1 - b5 + 4) >> 3;
216
        src[i][7] = (b0 - b4 + 4) >> 3;
217
    }
218
    for( i = 0; i < 8; i++ ) {
219
        const int a0 =  3*src[1][i] - (src[7][i]<<1);
220
        const int a1 =  3*src[3][i] + (src[5][i]<<1);
221
        const int a2 =  (src[3][i]<<1) - 3*src[5][i];
222
        const int a3 =  (src[1][i]<<1) + 3*src[7][i];
223

    
224
        const int b4 = ((a0 + a1 + a3)<<1) + a1;
225
        const int b5 = ((a0 - a1 + a2)<<1) + a0;
226
        const int b6 = ((a3 - a2 - a1)<<1) + a3;
227
        const int b7 = ((a0 - a2 - a3)<<1) - a2;
228

    
229
        const int a7 = (src[2][i]<<2) - 10*src[6][i];
230
        const int a6 = (src[6][i]<<2) + 10*src[2][i];
231
        const int a5 = (src[0][i] - src[4][i]) << 3;
232
        const int a4 = (src[0][i] + src[4][i]) << 3;
233

    
234
        const int b0 = a4 + a6;
235
        const int b1 = a5 + a7;
236
        const int b2 = a5 - a7;
237
        const int b3 = a4 - a6;
238

    
239
        dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4 + 64) >> 7)];
240
        dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5 + 64) >> 7)];
241
        dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6 + 64) >> 7)];
242
        dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7 + 64) >> 7)];
243
        dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7 + 64) >> 7)];
244
        dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6 + 64) >> 7)];
245
        dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5 + 64) >> 7)];
246
        dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4 + 64) >> 7)];
247
    }
248
}
249

    
250
/*****************************************************************************
251
 *
252
 * motion compensation
253
 *
254
 ****************************************************************************/
255

    
256
#define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \
257
static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
258
    const int h=8;\
259
    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
260
    int i;\
261
    for(i=0; i<h; i++)\
262
    {\
263
        OP(dst[0], A*src[-2] + B*src[-1] + C*src[0] + D*src[1] + E*src[2] + F*src[3]);\
264
        OP(dst[1], A*src[-1] + B*src[ 0] + C*src[1] + D*src[2] + E*src[3] + F*src[4]);\
265
        OP(dst[2], A*src[ 0] + B*src[ 1] + C*src[2] + D*src[3] + E*src[4] + F*src[5]);\
266
        OP(dst[3], A*src[ 1] + B*src[ 2] + C*src[3] + D*src[4] + E*src[5] + F*src[6]);\
267
        OP(dst[4], A*src[ 2] + B*src[ 3] + C*src[4] + D*src[5] + E*src[6] + F*src[7]);\
268
        OP(dst[5], A*src[ 3] + B*src[ 4] + C*src[5] + D*src[6] + E*src[7] + F*src[8]);\
269
        OP(dst[6], A*src[ 4] + B*src[ 5] + C*src[6] + D*src[7] + E*src[8] + F*src[9]);\
270
        OP(dst[7], A*src[ 5] + B*src[ 6] + C*src[7] + D*src[8] + E*src[9] + F*src[10]);\
271
        dst+=dstStride;\
272
        src+=srcStride;\
273
    }\
274
}\
275
\
276
static void OPNAME ## cavs_filt8_v_  ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
277
    const int w=8;\
278
    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
279
    int i;\
280
    for(i=0; i<w; i++)\
281
    {\
282
        const int srcB= src[-2*srcStride];\
283
        const int srcA= src[-1*srcStride];\
284
        const int src0= src[0 *srcStride];\
285
        const int src1= src[1 *srcStride];\
286
        const int src2= src[2 *srcStride];\
287
        const int src3= src[3 *srcStride];\
288
        const int src4= src[4 *srcStride];\
289
        const int src5= src[5 *srcStride];\
290
        const int src6= src[6 *srcStride];\
291
        const int src7= src[7 *srcStride];\
292
        const int src8= src[8 *srcStride];\
293
        const int src9= src[9 *srcStride];\
294
        const int src10= src[10 *srcStride];\
295
        OP(dst[0*dstStride], A*srcB + B*srcA + C*src0 + D*src1 + E*src2 + F*src3);\
296
        OP(dst[1*dstStride], A*srcA + B*src0 + C*src1 + D*src2 + E*src3 + F*src4);\
297
        OP(dst[2*dstStride], A*src0 + B*src1 + C*src2 + D*src3 + E*src4 + F*src5);\
298
        OP(dst[3*dstStride], A*src1 + B*src2 + C*src3 + D*src4 + E*src5 + F*src6);\
299
        OP(dst[4*dstStride], A*src2 + B*src3 + C*src4 + D*src5 + E*src6 + F*src7);\
300
        OP(dst[5*dstStride], A*src3 + B*src4 + C*src5 + D*src6 + E*src7 + F*src8);\
301
        OP(dst[6*dstStride], A*src4 + B*src5 + C*src6 + D*src7 + E*src8 + F*src9);\
302
        OP(dst[7*dstStride], A*src5 + B*src6 + C*src7 + D*src8 + E*src9 + F*src10);\
303
        dst++;\
304
        src++;\
305
    }\
306
}\
307
\
308
static void OPNAME ## cavs_filt16_v_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
309
    OPNAME ## cavs_filt8_v_ ## NAME(dst  , src  , dstStride, srcStride);\
310
    OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
311
    src += 8*srcStride;\
312
    dst += 8*dstStride;\
313
    OPNAME ## cavs_filt8_v_ ## NAME(dst  , src  , dstStride, srcStride);\
314
    OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
315
}\
316
\
317
static void OPNAME ## cavs_filt16_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
318
    OPNAME ## cavs_filt8_h_ ## NAME(dst  , src  , dstStride, srcStride);\
319
    OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
320
    src += 8*srcStride;\
321
    dst += 8*dstStride;\
322
    OPNAME ## cavs_filt8_h_ ## NAME(dst  , src  , dstStride, srcStride);\
323
    OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
324
}\
325

    
326
#define CAVS_SUBPIX_HV(OPNAME, OP, NAME, AH, BH, CH, DH, EH, FH, AV, BV, CV, DV, EV, FV, FULL) \
327
static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int srcStride){\
328
    int16_t temp[8*(8+5)];\
329
    int16_t *tmp = temp;\
330
    const int h=8;\
331
    const int w=8;\
332
    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
333
    int i;\
334
    src1 -= 2*srcStride;\
335
    for(i=0; i<h+5; i++)\
336
    {\
337
        tmp[0]= AH*src1[-2] + BH*src1[-1] + CH*src1[0] + DH*src1[1] + EH*src1[2] + FH*src1[3];\
338
        tmp[1]= AH*src1[-1] + BH*src1[ 0] + CH*src1[1] + DH*src1[2] + EH*src1[3] + FH*src1[4];\
339
        tmp[2]= AH*src1[ 0] + BH*src1[ 1] + CH*src1[2] + DH*src1[3] + EH*src1[4] + FH*src1[5];\
340
        tmp[3]= AH*src1[ 1] + BH*src1[ 2] + CH*src1[3] + DH*src1[4] + EH*src1[5] + FH*src1[6];\
341
        tmp[4]= AH*src1[ 2] + BH*src1[ 3] + CH*src1[4] + DH*src1[5] + EH*src1[6] + FH*src1[7];\
342
        tmp[5]= AH*src1[ 3] + BH*src1[ 4] + CH*src1[5] + DH*src1[6] + EH*src1[7] + FH*src1[8];\
343
        tmp[6]= AH*src1[ 4] + BH*src1[ 5] + CH*src1[6] + DH*src1[7] + EH*src1[8] + FH*src1[9];\
344
        tmp[7]= AH*src1[ 5] + BH*src1[ 6] + CH*src1[7] + DH*src1[8] + EH*src1[9] + FH*src1[10];\
345
        tmp+=8;\
346
        src1+=srcStride;\
347
    }\
348
    if(FULL) {\
349
      tmp = temp+8*2;                           \
350
      for(i=0; i<w; i++)                        \
351
        {                                       \
352
          const int tmpB= tmp[-2*8];    \
353
          const int tmpA= tmp[-1*8];    \
354
          const int tmp0= tmp[0 *8];    \
355
          const int tmp1= tmp[1 *8];    \
356
          const int tmp2= tmp[2 *8];    \
357
          const int tmp3= tmp[3 *8];    \
358
          const int tmp4= tmp[4 *8];    \
359
          const int tmp5= tmp[5 *8];    \
360
          const int tmp6= tmp[6 *8];    \
361
          const int tmp7= tmp[7 *8];    \
362
          const int tmp8= tmp[8 *8];    \
363
          const int tmp9= tmp[9 *8];    \
364
          const int tmp10=tmp[10*8];                            \
365
          OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3 + 64*src2[0*srcStride]); \
366
          OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4 + 64*src2[1*srcStride]); \
367
          OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5 + 64*src2[2*srcStride]); \
368
          OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6 + 64*src2[3*srcStride]); \
369
          OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7 + 64*src2[4*srcStride]); \
370
          OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8 + 64*src2[5*srcStride]); \
371
          OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9 + 64*src2[6*srcStride]); \
372
          OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10 + 64*src2[7*srcStride]); \
373
          dst++;                                                        \
374
          tmp++;                                                        \
375
          src2++;                                                       \
376
        }                                                               \
377
    } else {\
378
      tmp = temp+8*2;                           \
379
      for(i=0; i<w; i++)                        \
380
        {                                       \
381
          const int tmpB= tmp[-2*8];    \
382
          const int tmpA= tmp[-1*8];    \
383
          const int tmp0= tmp[0 *8];    \
384
          const int tmp1= tmp[1 *8];    \
385
          const int tmp2= tmp[2 *8];    \
386
          const int tmp3= tmp[3 *8];    \
387
          const int tmp4= tmp[4 *8];    \
388
          const int tmp5= tmp[5 *8];    \
389
          const int tmp6= tmp[6 *8];    \
390
          const int tmp7= tmp[7 *8];    \
391
          const int tmp8= tmp[8 *8];    \
392
          const int tmp9= tmp[9 *8];    \
393
          const int tmp10=tmp[10*8];                            \
394
          OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3); \
395
          OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4); \
396
          OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5); \
397
          OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6); \
398
          OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7); \
399
          OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8); \
400
          OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9); \
401
          OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10); \
402
          dst++;                                                        \
403
          tmp++;                                                        \
404
        }                                                               \
405
    }\
406
}\
407
\
408
static void OPNAME ## cavs_filt16_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int srcStride){ \
409
    OPNAME ## cavs_filt8_hv_ ## NAME(dst  , src1,   src2  , dstStride, srcStride); \
410
    OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
411
    src1 += 8*srcStride;\
412
    src2 += 8*srcStride;\
413
    dst += 8*dstStride;\
414
    OPNAME ## cavs_filt8_hv_ ## NAME(dst  , src1,   src2  , dstStride, srcStride); \
415
    OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
416
}\
417

    
418
#define CAVS_MC(OPNAME, SIZE) \
419
void OPNAME ## cavs_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\
420
    OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
421
}\
422
void OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
423
    OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\
424
}\
425
\
426
void OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
427
    OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\
428
}\
429
\
430
void OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
431
    OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\
432
}\
433
\
434
void OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
435
    OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\
436
}\
437
\
438
void OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
439
    OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\
440
}\
441
\
442
void OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
443
    OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\
444
}\
445
\
446
void OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
447
  OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \
448
}\
449
\
450
void OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
451
  OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \
452
}\
453
\
454
void OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
455
  OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \
456
}\
457
\
458
void OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
459
  OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \
460
}\
461
\
462
void OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
463
  OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \
464
}\
465
\
466
void OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
467
  OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \
468
}\
469
\
470
void OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
471
  OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \
472
}\
473
\
474
void OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
475
  OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \
476
}\
477
\
478
void OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
479
  OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \
480
}\
481

    
482
#define op_put1(a, b)  a = cm[((b)+4)>>3]
483
#define op_put2(a, b)  a = cm[((b)+64)>>7]
484
#define op_put3(a, b)  a = cm[((b)+32)>>6]
485
#define op_put4(a, b)  a = cm[((b)+512)>>10]
486
#define op_avg1(a, b)  a = ((a)+cm[((b)+4)>>3]   +1)>>1
487
#define op_avg2(a, b)  a = ((a)+cm[((b)+64)>>7]  +1)>>1
488
#define op_avg3(a, b)  a = ((a)+cm[((b)+32)>>6]  +1)>>1
489
#define op_avg4(a, b)  a = ((a)+cm[((b)+512)>>10]+1)>>1
490
CAVS_SUBPIX(put_   , op_put1, hpel,    0, -1,  5,  5, -1,  0)
491
CAVS_SUBPIX(put_   , op_put2, qpel_l, -1, -2, 96, 42, -7,  0)
492
CAVS_SUBPIX(put_   , op_put2, qpel_r,  0, -7, 42, 96, -2, -1)
493
CAVS_SUBPIX_HV(put_, op_put3, jj,      0, -1,  5,  5, -1,  0,  0, -1,  5,  5, -1, 0, 0)
494
CAVS_SUBPIX_HV(put_, op_put4, ff,      0, -1,  5,  5, -1,  0, -1, -2, 96, 42, -7, 0, 0)
495
CAVS_SUBPIX_HV(put_, op_put4, ii,     -1, -2, 96, 42, -7,  0,  0, -1,  5,  5, -1, 0, 0)
496
CAVS_SUBPIX_HV(put_, op_put4, kk,      0, -7, 42, 96, -2, -1,  0, -1,  5,  5, -1, 0, 0)
497
CAVS_SUBPIX_HV(put_, op_put4, qq,      0, -1,  5,  5, -1,  0,  0, -7, 42, 96, -2,-1, 0)
498
CAVS_SUBPIX_HV(put_, op_put2, egpr,    0, -1,  5,  5, -1,  0,  0, -1,  5,  5, -1, 0, 1)
499
CAVS_SUBPIX(avg_   , op_avg1, hpel,    0, -1,  5,  5, -1,  0)
500
CAVS_SUBPIX(avg_   , op_avg2, qpel_l, -1, -2, 96, 42, -7,  0)
501
CAVS_SUBPIX(avg_   , op_avg2, qpel_r,  0, -7, 42, 96, -2, -1)
502
CAVS_SUBPIX_HV(avg_, op_avg3, jj,      0, -1,  5,  5, -1,  0,  0, -1,  5,  5, -1, 0, 0)
503
CAVS_SUBPIX_HV(avg_, op_avg4, ff,      0, -1,  5,  5, -1,  0, -1, -2, 96, 42, -7, 0, 0)
504
CAVS_SUBPIX_HV(avg_, op_avg4, ii,     -1, -2, 96, 42, -7,  0,  0, -1,  5,  5, -1, 0, 0)
505
CAVS_SUBPIX_HV(avg_, op_avg4, kk,      0, -7, 42, 96, -2, -1,  0, -1,  5,  5, -1, 0, 0)
506
CAVS_SUBPIX_HV(avg_, op_avg4, qq,      0, -1,  5,  5, -1,  0,  0, -7, 42, 96, -2,-1, 0)
507
CAVS_SUBPIX_HV(avg_, op_avg2, egpr,    0, -1,  5,  5, -1,  0,  0, -1,  5,  5, -1, 0, 1)
508
CAVS_MC(put_, 8)
509
CAVS_MC(put_, 16)
510
CAVS_MC(avg_, 8)
511
CAVS_MC(avg_, 16)