FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cavsdsp.c
Go to the documentation of this file.
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 file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 #include <stdio.h>
26 
27 #include "idctdsp.h"
28 #include "mathops.h"
29 #include "cavsdsp.h"
30 #include "libavutil/common.h"
31 
32 /*****************************************************************************
33  *
34  * in-loop deblocking filter
35  *
36  ****************************************************************************/
37 
38 #define P2 p0_p[-3*stride]
39 #define P1 p0_p[-2*stride]
40 #define P0 p0_p[-1*stride]
41 #define Q0 p0_p[ 0*stride]
42 #define Q1 p0_p[ 1*stride]
43 #define Q2 p0_p[ 2*stride]
44 
45 static inline void loop_filter_l2(uint8_t *p0_p,int stride,int alpha, int beta) {
46  int p0 = P0;
47  int q0 = Q0;
48 
49  if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
50  int s = p0 + q0 + 2;
51  alpha = (alpha>>2) + 2;
52  if(abs(P2-p0) < beta && abs(p0-q0) < alpha) {
53  P0 = (P1 + p0 + s) >> 2;
54  P1 = (2*P1 + s) >> 2;
55  } else
56  P0 = (2*P1 + s) >> 2;
57  if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) {
58  Q0 = (Q1 + q0 + s) >> 2;
59  Q1 = (2*Q1 + s) >> 2;
60  } else
61  Q0 = (2*Q1 + s) >> 2;
62  }
63 }
64 
65 static inline void loop_filter_l1(uint8_t *p0_p, int stride, int alpha, int beta, int tc) {
66  int p0 = P0;
67  int q0 = Q0;
68 
69  if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
70  int delta = av_clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc);
71  P0 = av_clip_uint8(p0+delta);
72  Q0 = av_clip_uint8(q0-delta);
73  if(abs(P2-p0)<beta) {
74  delta = av_clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc);
75  P1 = av_clip_uint8(P1+delta);
76  }
77  if(abs(Q2-q0)<beta) {
78  delta = av_clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc);
79  Q1 = av_clip_uint8(Q1-delta);
80  }
81  }
82 }
83 
84 static inline void loop_filter_c2(uint8_t *p0_p,int stride,int alpha, int beta) {
85  int p0 = P0;
86  int q0 = Q0;
87 
88  if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
89  int s = p0 + q0 + 2;
90  alpha = (alpha>>2) + 2;
91  if(abs(P2-p0) < beta && abs(p0-q0) < alpha) {
92  P0 = (P1 + p0 + s) >> 2;
93  } else
94  P0 = (2*P1 + s) >> 2;
95  if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) {
96  Q0 = (Q1 + q0 + s) >> 2;
97  } else
98  Q0 = (2*Q1 + s) >> 2;
99  }
100 }
101 
102 static inline void loop_filter_c1(uint8_t *p0_p,int stride,int alpha, int beta,
103  int tc) {
104  if(abs(P0-Q0)<alpha && abs(P1-P0)<beta && abs(Q1-Q0)<beta) {
105  int delta = av_clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc);
106  P0 = av_clip_uint8(P0+delta);
107  Q0 = av_clip_uint8(Q0-delta);
108  }
109 }
110 
111 #undef P0
112 #undef P1
113 #undef P2
114 #undef Q0
115 #undef Q1
116 #undef Q2
117 
118 static void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
119  int bs1, int bs2) {
120  int i;
121  if(bs1==2)
122  for(i=0;i<16;i++)
123  loop_filter_l2(d + i*stride,1,alpha,beta);
124  else {
125  if(bs1)
126  for(i=0;i<8;i++)
127  loop_filter_l1(d + i*stride,1,alpha,beta,tc);
128  if (bs2)
129  for(i=8;i<16;i++)
130  loop_filter_l1(d + i*stride,1,alpha,beta,tc);
131  }
132 }
133 
134 static void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc,
135  int bs1, int bs2) {
136  int i;
137  if(bs1==2)
138  for(i=0;i<16;i++)
139  loop_filter_l2(d + i,stride,alpha,beta);
140  else {
141  if(bs1)
142  for(i=0;i<8;i++)
143  loop_filter_l1(d + i,stride,alpha,beta,tc);
144  if (bs2)
145  for(i=8;i<16;i++)
146  loop_filter_l1(d + i,stride,alpha,beta,tc);
147  }
148 }
149 
150 static void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
151  int bs1, int bs2) {
152  int i;
153  if(bs1==2)
154  for(i=0;i<8;i++)
155  loop_filter_c2(d + i*stride,1,alpha,beta);
156  else {
157  if(bs1)
158  for(i=0;i<4;i++)
159  loop_filter_c1(d + i*stride,1,alpha,beta,tc);
160  if (bs2)
161  for(i=4;i<8;i++)
162  loop_filter_c1(d + i*stride,1,alpha,beta,tc);
163  }
164 }
165 
166 static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc,
167  int bs1, int bs2) {
168  int i;
169  if(bs1==2)
170  for(i=0;i<8;i++)
171  loop_filter_c2(d + i,stride,alpha,beta);
172  else {
173  if(bs1)
174  for(i=0;i<4;i++)
175  loop_filter_c1(d + i,stride,alpha,beta,tc);
176  if (bs2)
177  for(i=4;i<8;i++)
178  loop_filter_c1(d + i,stride,alpha,beta,tc);
179  }
180 }
181 
182 /*****************************************************************************
183  *
184  * inverse transform
185  *
186  ****************************************************************************/
187 
188 static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) {
189  int i;
190  int16_t (*src)[8] = (int16_t(*)[8])block;
191 
192  src[0][0] += 8;
193 
194  for( i = 0; i < 8; i++ ) {
195  const int a0 = 3*src[i][1] - (src[i][7]<<1);
196  const int a1 = 3*src[i][3] + (src[i][5]<<1);
197  const int a2 = (src[i][3]<<1) - 3*src[i][5];
198  const int a3 = (src[i][1]<<1) + 3*src[i][7];
199 
200  const int b4 = ((a0 + a1 + a3)<<1) + a1;
201  const int b5 = ((a0 - a1 + a2)<<1) + a0;
202  const int b6 = ((a3 - a2 - a1)<<1) + a3;
203  const int b7 = ((a0 - a2 - a3)<<1) - a2;
204 
205  const int a7 = (src[i][2]<<2) - 10*src[i][6];
206  const int a6 = (src[i][6]<<2) + 10*src[i][2];
207  const int a5 = ((src[i][0] - src[i][4]) << 3) + 4;
208  const int a4 = ((src[i][0] + src[i][4]) << 3) + 4;
209 
210  const int b0 = a4 + a6;
211  const int b1 = a5 + a7;
212  const int b2 = a5 - a7;
213  const int b3 = a4 - a6;
214 
215  src[i][0] = (b0 + b4) >> 3;
216  src[i][1] = (b1 + b5) >> 3;
217  src[i][2] = (b2 + b6) >> 3;
218  src[i][3] = (b3 + b7) >> 3;
219  src[i][4] = (b3 - b7) >> 3;
220  src[i][5] = (b2 - b6) >> 3;
221  src[i][6] = (b1 - b5) >> 3;
222  src[i][7] = (b0 - b4) >> 3;
223  }
224  for( i = 0; i < 8; i++ ) {
225  const int a0 = 3*src[1][i] - (src[7][i]<<1);
226  const int a1 = 3*src[3][i] + (src[5][i]<<1);
227  const int a2 = (src[3][i]<<1) - 3*src[5][i];
228  const int a3 = (src[1][i]<<1) + 3*src[7][i];
229 
230  const int b4 = ((a0 + a1 + a3)<<1) + a1;
231  const int b5 = ((a0 - a1 + a2)<<1) + a0;
232  const int b6 = ((a3 - a2 - a1)<<1) + a3;
233  const int b7 = ((a0 - a2 - a3)<<1) - a2;
234 
235  const int a7 = (src[2][i]<<2) - 10*src[6][i];
236  const int a6 = (src[6][i]<<2) + 10*src[2][i];
237  const int a5 = (src[0][i] - src[4][i]) << 3;
238  const int a4 = (src[0][i] + src[4][i]) << 3;
239 
240  const int b0 = a4 + a6;
241  const int b1 = a5 + a7;
242  const int b2 = a5 - a7;
243  const int b3 = a4 - a6;
244 
245  dst[i + 0*stride] = av_clip_uint8( dst[i + 0*stride] + ((b0 + b4) >> 7));
246  dst[i + 1*stride] = av_clip_uint8( dst[i + 1*stride] + ((b1 + b5) >> 7));
247  dst[i + 2*stride] = av_clip_uint8( dst[i + 2*stride] + ((b2 + b6) >> 7));
248  dst[i + 3*stride] = av_clip_uint8( dst[i + 3*stride] + ((b3 + b7) >> 7));
249  dst[i + 4*stride] = av_clip_uint8( dst[i + 4*stride] + ((b3 - b7) >> 7));
250  dst[i + 5*stride] = av_clip_uint8( dst[i + 5*stride] + ((b2 - b6) >> 7));
251  dst[i + 6*stride] = av_clip_uint8( dst[i + 6*stride] + ((b1 - b5) >> 7));
252  dst[i + 7*stride] = av_clip_uint8( dst[i + 7*stride] + ((b0 - b4) >> 7));
253  }
254 }
255 
256 /*****************************************************************************
257  *
258  * motion compensation
259  *
260  ****************************************************************************/
261 
262 #define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \
263 static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
264  const int h=8;\
265  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
266  int i;\
267  for(i=0; i<h; i++)\
268  {\
269  OP(dst[0], A*src[-2] + B*src[-1] + C*src[0] + D*src[1] + E*src[2] + F*src[3]);\
270  OP(dst[1], A*src[-1] + B*src[ 0] + C*src[1] + D*src[2] + E*src[3] + F*src[4]);\
271  OP(dst[2], A*src[ 0] + B*src[ 1] + C*src[2] + D*src[3] + E*src[4] + F*src[5]);\
272  OP(dst[3], A*src[ 1] + B*src[ 2] + C*src[3] + D*src[4] + E*src[5] + F*src[6]);\
273  OP(dst[4], A*src[ 2] + B*src[ 3] + C*src[4] + D*src[5] + E*src[6] + F*src[7]);\
274  OP(dst[5], A*src[ 3] + B*src[ 4] + C*src[5] + D*src[6] + E*src[7] + F*src[8]);\
275  OP(dst[6], A*src[ 4] + B*src[ 5] + C*src[6] + D*src[7] + E*src[8] + F*src[9]);\
276  OP(dst[7], A*src[ 5] + B*src[ 6] + C*src[7] + D*src[8] + E*src[9] + F*src[10]);\
277  dst+=dstStride;\
278  src+=srcStride;\
279  }\
280 }\
281 \
282 static void OPNAME ## cavs_filt8_v_ ## NAME(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
283  const int w=8;\
284  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
285  int i;\
286  for(i=0; i<w; i++)\
287  {\
288  const int srcB= src[-2*srcStride];\
289  const int srcA= src[-1*srcStride];\
290  const int src0= src[0 *srcStride];\
291  const int src1= src[1 *srcStride];\
292  const int src2= src[2 *srcStride];\
293  const int src3= src[3 *srcStride];\
294  const int src4= src[4 *srcStride];\
295  const int src5= src[5 *srcStride];\
296  const int src6= src[6 *srcStride];\
297  const int src7= src[7 *srcStride];\
298  const int src8= src[8 *srcStride];\
299  const int src9= src[9 *srcStride];\
300  const int src10= src[10 *srcStride];\
301  OP(dst[0*dstStride], A*srcB + B*srcA + C*src0 + D*src1 + E*src2 + F*src3);\
302  OP(dst[1*dstStride], A*srcA + B*src0 + C*src1 + D*src2 + E*src3 + F*src4);\
303  OP(dst[2*dstStride], A*src0 + B*src1 + C*src2 + D*src3 + E*src4 + F*src5);\
304  OP(dst[3*dstStride], A*src1 + B*src2 + C*src3 + D*src4 + E*src5 + F*src6);\
305  OP(dst[4*dstStride], A*src2 + B*src3 + C*src4 + D*src5 + E*src6 + F*src7);\
306  OP(dst[5*dstStride], A*src3 + B*src4 + C*src5 + D*src6 + E*src7 + F*src8);\
307  OP(dst[6*dstStride], A*src4 + B*src5 + C*src6 + D*src7 + E*src8 + F*src9);\
308  OP(dst[7*dstStride], A*src5 + B*src6 + C*src7 + D*src8 + E*src9 + F*src10);\
309  dst++;\
310  src++;\
311  }\
312 }\
313 \
314 static void OPNAME ## cavs_filt16_v_ ## NAME(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
315  OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\
316  OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
317  src += 8*srcStride;\
318  dst += 8*dstStride;\
319  OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\
320  OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
321 }\
322 \
323 static void OPNAME ## cavs_filt16_h_ ## NAME(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
324  OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\
325  OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
326  src += 8*srcStride;\
327  dst += 8*dstStride;\
328  OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\
329  OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
330 }\
331 
332 #define CAVS_SUBPIX_HV(OPNAME, OP, NAME, AH, BH, CH, DH, EH, FH, AV, BV, CV, DV, EV, FV, FULL) \
333 static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dstStride, int srcStride){\
334  int16_t temp[8*(8+5)];\
335  int16_t *tmp = temp;\
336  const int h=8;\
337  const int w=8;\
338  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
339  int i;\
340  src1 -= 2*srcStride;\
341  for(i=0; i<h+5; i++)\
342  {\
343  tmp[0]= AH*src1[-2] + BH*src1[-1] + CH*src1[0] + DH*src1[1] + EH*src1[2] + FH*src1[3];\
344  tmp[1]= AH*src1[-1] + BH*src1[ 0] + CH*src1[1] + DH*src1[2] + EH*src1[3] + FH*src1[4];\
345  tmp[2]= AH*src1[ 0] + BH*src1[ 1] + CH*src1[2] + DH*src1[3] + EH*src1[4] + FH*src1[5];\
346  tmp[3]= AH*src1[ 1] + BH*src1[ 2] + CH*src1[3] + DH*src1[4] + EH*src1[5] + FH*src1[6];\
347  tmp[4]= AH*src1[ 2] + BH*src1[ 3] + CH*src1[4] + DH*src1[5] + EH*src1[6] + FH*src1[7];\
348  tmp[5]= AH*src1[ 3] + BH*src1[ 4] + CH*src1[5] + DH*src1[6] + EH*src1[7] + FH*src1[8];\
349  tmp[6]= AH*src1[ 4] + BH*src1[ 5] + CH*src1[6] + DH*src1[7] + EH*src1[8] + FH*src1[9];\
350  tmp[7]= AH*src1[ 5] + BH*src1[ 6] + CH*src1[7] + DH*src1[8] + EH*src1[9] + FH*src1[10];\
351  tmp+=8;\
352  src1+=srcStride;\
353  }\
354  if(FULL) {\
355  tmp = temp+8*2; \
356  for(i=0; i<w; i++) \
357  { \
358  const int tmpB= tmp[-2*8]; \
359  const int tmpA= tmp[-1*8]; \
360  const int tmp0= tmp[0 *8]; \
361  const int tmp1= tmp[1 *8]; \
362  const int tmp2= tmp[2 *8]; \
363  const int tmp3= tmp[3 *8]; \
364  const int tmp4= tmp[4 *8]; \
365  const int tmp5= tmp[5 *8]; \
366  const int tmp6= tmp[6 *8]; \
367  const int tmp7= tmp[7 *8]; \
368  const int tmp8= tmp[8 *8]; \
369  const int tmp9= tmp[9 *8]; \
370  const int tmp10=tmp[10*8]; \
371  OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3 + 64*src2[0*srcStride]); \
372  OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4 + 64*src2[1*srcStride]); \
373  OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5 + 64*src2[2*srcStride]); \
374  OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6 + 64*src2[3*srcStride]); \
375  OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7 + 64*src2[4*srcStride]); \
376  OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8 + 64*src2[5*srcStride]); \
377  OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9 + 64*src2[6*srcStride]); \
378  OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10 + 64*src2[7*srcStride]); \
379  dst++; \
380  tmp++; \
381  src2++; \
382  } \
383  } else {\
384  tmp = temp+8*2; \
385  for(i=0; i<w; i++) \
386  { \
387  const int tmpB= tmp[-2*8]; \
388  const int tmpA= tmp[-1*8]; \
389  const int tmp0= tmp[0 *8]; \
390  const int tmp1= tmp[1 *8]; \
391  const int tmp2= tmp[2 *8]; \
392  const int tmp3= tmp[3 *8]; \
393  const int tmp4= tmp[4 *8]; \
394  const int tmp5= tmp[5 *8]; \
395  const int tmp6= tmp[6 *8]; \
396  const int tmp7= tmp[7 *8]; \
397  const int tmp8= tmp[8 *8]; \
398  const int tmp9= tmp[9 *8]; \
399  const int tmp10=tmp[10*8]; \
400  OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3); \
401  OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4); \
402  OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5); \
403  OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6); \
404  OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7); \
405  OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8); \
406  OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9); \
407  OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10); \
408  dst++; \
409  tmp++; \
410  } \
411  }\
412 }\
413 \
414 static void OPNAME ## cavs_filt16_hv_ ## NAME(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dstStride, int srcStride){ \
415  OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
416  OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
417  src1 += 8*srcStride;\
418  src2 += 8*srcStride;\
419  dst += 8*dstStride;\
420  OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
421  OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
422 }\
423 
424 #define CAVS_MC(OPNAME, SIZE) \
425 static void OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
426 {\
427  OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\
428 }\
429 \
430 static void OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
431 {\
432  OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\
433 }\
434 \
435 static void OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
436 {\
437  OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\
438 }\
439 \
440 static void OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
441 {\
442  OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\
443 }\
444 \
445 static void OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
446 {\
447  OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\
448 }\
449 \
450 static void OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
451 {\
452  OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\
453 }\
454 \
455 static void OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
456 {\
457  OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \
458 }\
459 \
460 static void OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
461 {\
462  OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \
463 }\
464 \
465 static void OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
466 {\
467  OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \
468 }\
469 \
470 static void OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
471 {\
472  OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \
473 }\
474 \
475 static void OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
476 {\
477  OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \
478 }\
479 \
480 static void OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
481 {\
482  OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \
483 }\
484 \
485 static void OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
486 {\
487  OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \
488 }\
489 \
490 static void OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
491 {\
492  OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \
493 }\
494 \
495 static void OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
496 {\
497  OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \
498 }\
499 
500 #define op_put1(a, b) a = cm[((b)+4)>>3]
501 #define op_put2(a, b) a = cm[((b)+64)>>7]
502 #define op_put3(a, b) a = cm[((b)+32)>>6]
503 #define op_put4(a, b) a = cm[((b)+512)>>10]
504 #define op_avg1(a, b) a = ((a)+cm[((b)+4)>>3] +1)>>1
505 #define op_avg2(a, b) a = ((a)+cm[((b)+64)>>7] +1)>>1
506 #define op_avg3(a, b) a = ((a)+cm[((b)+32)>>6] +1)>>1
507 #define op_avg4(a, b) a = ((a)+cm[((b)+512)>>10]+1)>>1
508 CAVS_SUBPIX(put_ , op_put1, hpel, 0, -1, 5, 5, -1, 0)
509 CAVS_SUBPIX(put_ , op_put2, qpel_l, -1, -2, 96, 42, -7, 0)
510 CAVS_SUBPIX(put_ , op_put2, qpel_r, 0, -7, 42, 96, -2, -1)
511 CAVS_SUBPIX_HV(put_, op_put3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0)
512 CAVS_SUBPIX_HV(put_, op_put4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0)
513 CAVS_SUBPIX_HV(put_, op_put4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0)
514 CAVS_SUBPIX_HV(put_, op_put4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0)
515 CAVS_SUBPIX_HV(put_, op_put4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0)
516 CAVS_SUBPIX_HV(put_, op_put2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
517 CAVS_SUBPIX(avg_ , op_avg1, hpel, 0, -1, 5, 5, -1, 0)
518 CAVS_SUBPIX(avg_ , op_avg2, qpel_l, -1, -2, 96, 42, -7, 0)
519 CAVS_SUBPIX(avg_ , op_avg2, qpel_r, 0, -7, 42, 96, -2, -1)
520 CAVS_SUBPIX_HV(avg_, op_avg3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0)
521 CAVS_SUBPIX_HV(avg_, op_avg4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0)
522 CAVS_SUBPIX_HV(avg_, op_avg4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0)
523 CAVS_SUBPIX_HV(avg_, op_avg4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0)
524 CAVS_SUBPIX_HV(avg_, op_avg4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0)
525 CAVS_SUBPIX_HV(avg_, op_avg2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
526 CAVS_MC(put_, 8)
527 CAVS_MC(put_, 16)
528 CAVS_MC(avg_, 8)
529 CAVS_MC(avg_, 16)
530 
531 #define put_cavs_qpel8_mc00_c ff_put_pixels8x8_c
532 #define avg_cavs_qpel8_mc00_c ff_avg_pixels8x8_c
533 #define put_cavs_qpel16_mc00_c ff_put_pixels16x16_c
534 #define avg_cavs_qpel16_mc00_c ff_avg_pixels16x16_c
535 
537 #define dspfunc(PFX, IDX, NUM) \
538  c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
539  c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
540  c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
541  c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
542  c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
543  c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
544  c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
545  c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
546  c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
547  c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
548  c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
549  c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
550  c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
551  c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
552  c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
553  c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
554  dspfunc(put_cavs_qpel, 0, 16);
555  dspfunc(put_cavs_qpel, 1, 8);
556  dspfunc(avg_cavs_qpel, 0, 16);
557  dspfunc(avg_cavs_qpel, 1, 8);
564 
565  if (ARCH_X86)
566  ff_cavsdsp_init_x86(c, avctx);
567 }
const char * s
Definition: avisynth_c.h:768
static void loop_filter_c2(uint8_t *p0_p, int stride, int alpha, int beta)
Definition: cavsdsp.c:84
void(* cavs_idct8_add)(uint8_t *dst, int16_t *block, int stride)
Definition: cavsdsp.h:37
void(* cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2)
Definition: cavsdsp.h:35
#define P1
Definition: cavsdsp.c:39
#define op_put4(a, b)
Definition: cavsdsp.c:503
#define a0
Definition: regdef.h:46
void(* cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2)
Definition: cavsdsp.h:33
#define tc
Definition: regdef.h:69
#define a1
Definition: regdef.h:47
#define op_put1(a, b)
Definition: cavsdsp.c:500
#define Q0
Definition: cavsdsp.c:41
void(* cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2)
Definition: cavsdsp.h:34
static int16_t block[64]
Definition: dct.c:113
#define a3
Definition: regdef.h:49
uint8_t
#define av_cold
Definition: attributes.h:82
float delta
static void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc, int bs1, int bs2)
Definition: cavsdsp.c:134
av_cold void ff_cavsdsp_init(CAVSDSPContext *c, AVCodecContext *avctx)
Definition: cavsdsp.c:536
static void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc, int bs1, int bs2)
Definition: cavsdsp.c:118
#define op_avg1(a, b)
Definition: cavsdsp.c:504
static double alpha(void *priv, double x, double y)
Definition: vf_geq.c:99
static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride)
Definition: cavsdsp.c:188
static const uint8_t q0[256]
Definition: twofish.c:77
#define op_avg2(a, b)
Definition: cavsdsp.c:505
#define CAVS_MC(OPNAME, SIZE)
Definition: cavsdsp.c:424
#define Q1
Definition: cavsdsp.c:42
#define a2
Definition: regdef.h:48
static void loop_filter_l1(uint8_t *p0_p, int stride, int alpha, int beta, int tc)
Definition: cavsdsp.c:65
static void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc, int bs1, int bs2)
Definition: cavsdsp.c:150
#define src
Definition: vp9dsp.c:530
#define a5
Definition: regdef.h:51
#define dspfunc(PFX, IDX, NUM)
main external API structure.
Definition: avcodec.h:1675
int idct_perm
Definition: cavsdsp.h:38
av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx)
Definition: cavsdsp.c:564
#define P0
Definition: cavsdsp.c:40
static void loop_filter_l2(uint8_t *p0_p, int stride, int alpha, int beta)
Definition: cavsdsp.c:45
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
common internal and external API header
#define CAVS_SUBPIX_HV(OPNAME, OP, NAME, AH, BH, CH, DH, EH, FH, AV, BV, CV, DV, EV, FV, FULL)
Definition: cavsdsp.c:332
static double c[64]
static void loop_filter_c1(uint8_t *p0_p, int stride, int alpha, int beta, int tc)
Definition: cavsdsp.c:102
#define Q2
Definition: cavsdsp.c:43
#define a4
Definition: regdef.h:50
#define op_avg4(a, b)
Definition: cavsdsp.c:507
#define P2
Definition: cavsdsp.c:38
#define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F)
Definition: cavsdsp.c:262
#define op_avg3(a, b)
Definition: cavsdsp.c:506
#define op_put2(a, b)
Definition: cavsdsp.c:501
#define op_put3(a, b)
Definition: cavsdsp.c:502
static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc, int bs1, int bs2)
Definition: cavsdsp.c:166
void(* cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2)
Definition: cavsdsp.h:36
#define stride