FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/cavsdsp.c
Date: 2021-09-26 18:22:30
Exec Total Coverage
Lines: 181 181 100.0%
Branches: 156 156 100.0%

Line Branch Exec Source
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 1732320 static inline void loop_filter_l2(uint8_t *p0_p, ptrdiff_t stride, int alpha, int beta)
46 {
47 1732320 int p0 = P0;
48 1732320 int q0 = Q0;
49
50
6/6
✓ Branch 0 taken 1662535 times.
✓ Branch 1 taken 69785 times.
✓ Branch 2 taken 1596114 times.
✓ Branch 3 taken 66421 times.
✓ Branch 4 taken 1547636 times.
✓ Branch 5 taken 48478 times.
1732320 if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
51 1547636 int s = p0 + q0 + 2;
52 1547636 alpha = (alpha>>2) + 2;
53
4/4
✓ Branch 0 taken 1505317 times.
✓ Branch 1 taken 42319 times.
✓ Branch 2 taken 1473212 times.
✓ Branch 3 taken 32105 times.
1547636 if(abs(P2-p0) < beta && abs(p0-q0) < alpha) {
54 1473212 P0 = (P1 + p0 + s) >> 2;
55 1473212 P1 = (2*P1 + s) >> 2;
56 } else
57 74424 P0 = (2*P1 + s) >> 2;
58
4/4
✓ Branch 0 taken 1504857 times.
✓ Branch 1 taken 42779 times.
✓ Branch 2 taken 1472174 times.
✓ Branch 3 taken 32683 times.
1547636 if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) {
59 1472174 Q0 = (Q1 + q0 + s) >> 2;
60 1472174 Q1 = (2*Q1 + s) >> 2;
61 } else
62 75462 Q0 = (2*Q1 + s) >> 2;
63 }
64 1732320 }
65
66 2746000 static inline void loop_filter_l1(uint8_t *p0_p, ptrdiff_t stride, int alpha, int beta, int tc)
67 {
68 2746000 int p0 = P0;
69 2746000 int q0 = Q0;
70
71
6/6
✓ Branch 0 taken 2435884 times.
✓ Branch 1 taken 310116 times.
✓ Branch 2 taken 2245950 times.
✓ Branch 3 taken 189934 times.
✓ Branch 4 taken 2131300 times.
✓ Branch 5 taken 114650 times.
2746000 if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
72 2131300 int delta = av_clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc);
73 2131300 P0 = av_clip_uint8(p0+delta);
74 2131300 Q0 = av_clip_uint8(q0-delta);
75
2/2
✓ Branch 0 taken 2053935 times.
✓ Branch 1 taken 77365 times.
2131300 if(abs(P2-p0)<beta) {
76 2053935 delta = av_clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc);
77 2053935 P1 = av_clip_uint8(P1+delta);
78 }
79
2/2
✓ Branch 0 taken 2050257 times.
✓ Branch 1 taken 81043 times.
2131300 if(abs(Q2-q0)<beta) {
80 2050257 delta = av_clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc);
81 2050257 Q1 = av_clip_uint8(Q1-delta);
82 }
83 }
84 2746000 }
85
86 921312 static inline void loop_filter_c2(uint8_t *p0_p, ptrdiff_t stride, int alpha, int beta)
87 {
88 921312 int p0 = P0;
89 921312 int q0 = Q0;
90
91
6/6
✓ Branch 0 taken 899663 times.
✓ Branch 1 taken 21649 times.
✓ Branch 2 taken 876265 times.
✓ Branch 3 taken 23398 times.
✓ Branch 4 taken 855849 times.
✓ Branch 5 taken 20416 times.
921312 if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
92 855849 int s = p0 + q0 + 2;
93 855849 alpha = (alpha>>2) + 2;
94
4/4
✓ Branch 0 taken 836871 times.
✓ Branch 1 taken 18978 times.
✓ Branch 2 taken 820111 times.
✓ Branch 3 taken 16760 times.
855849 if(abs(P2-p0) < beta && abs(p0-q0) < alpha) {
95 820111 P0 = (P1 + p0 + s) >> 2;
96 } else
97 35738 P0 = (2*P1 + s) >> 2;
98
4/4
✓ Branch 0 taken 836442 times.
✓ Branch 1 taken 19407 times.
✓ Branch 2 taken 820095 times.
✓ Branch 3 taken 16347 times.
855849 if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) {
99 820095 Q0 = (Q1 + q0 + s) >> 2;
100 } else
101 35754 Q0 = (2*Q1 + s) >> 2;
102 }
103 921312 }
104
105 1980296 static inline void loop_filter_c1(uint8_t *p0_p, ptrdiff_t stride, int alpha, int beta,
106 int tc)
107 {
108
6/6
✓ Branch 0 taken 1866889 times.
✓ Branch 1 taken 113407 times.
✓ Branch 2 taken 1759013 times.
✓ Branch 3 taken 107876 times.
✓ Branch 4 taken 1684429 times.
✓ Branch 5 taken 74584 times.
1980296 if(abs(P0-Q0)<alpha && abs(P1-P0)<beta && abs(Q1-Q0)<beta) {
109 1684429 int delta = av_clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc);
110 1684429 P0 = av_clip_uint8(P0+delta);
111 1684429 Q0 = av_clip_uint8(Q0-delta);
112 }
113 1980296 }
114
115 #undef P0
116 #undef P1
117 #undef P2
118 #undef Q0
119 #undef Q1
120 #undef Q2
121
122 262099 static void cavs_filter_lv_c(uint8_t *d, ptrdiff_t stride, int alpha, int beta, int tc,
123 int bs1, int bs2)
124 {
125 int i;
126
2/2
✓ Branch 0 taken 53868 times.
✓ Branch 1 taken 208231 times.
262099 if(bs1==2)
127
2/2
✓ Branch 0 taken 861888 times.
✓ Branch 1 taken 53868 times.
915756 for(i=0;i<16;i++)
128 861888 loop_filter_l2(d + i*stride,1,alpha,beta);
129 else {
130
2/2
✓ Branch 0 taken 86137 times.
✓ Branch 1 taken 122094 times.
208231 if(bs1)
131
2/2
✓ Branch 0 taken 689096 times.
✓ Branch 1 taken 86137 times.
775233 for(i=0;i<8;i++)
132 689096 loop_filter_l1(d + i*stride,1,alpha,beta,tc);
133
2/2
✓ Branch 0 taken 84020 times.
✓ Branch 1 taken 124211 times.
208231 if (bs2)
134
2/2
✓ Branch 0 taken 672160 times.
✓ Branch 1 taken 84020 times.
756180 for(i=8;i<16;i++)
135 672160 loop_filter_l1(d + i*stride,1,alpha,beta,tc);
136 }
137 262099 }
138
139 260436 static void cavs_filter_lh_c(uint8_t *d, ptrdiff_t stride, int alpha, int beta, int tc,
140 int bs1, int bs2)
141 {
142 int i;
143
2/2
✓ Branch 0 taken 54402 times.
✓ Branch 1 taken 206034 times.
260436 if(bs1==2)
144
2/2
✓ Branch 0 taken 870432 times.
✓ Branch 1 taken 54402 times.
924834 for(i=0;i<16;i++)
145 870432 loop_filter_l2(d + i,stride,alpha,beta);
146 else {
147
2/2
✓ Branch 0 taken 85916 times.
✓ Branch 1 taken 120118 times.
206034 if(bs1)
148
2/2
✓ Branch 0 taken 687328 times.
✓ Branch 1 taken 85916 times.
773244 for(i=0;i<8;i++)
149 687328 loop_filter_l1(d + i,stride,alpha,beta,tc);
150
2/2
✓ Branch 0 taken 87177 times.
✓ Branch 1 taken 118857 times.
206034 if (bs2)
151
2/2
✓ Branch 0 taken 697416 times.
✓ Branch 1 taken 87177 times.
784593 for(i=8;i<16;i++)
152 697416 loop_filter_l1(d + i,stride,alpha,beta,tc);
153 }
154 260436 }
155
156 255482 static void cavs_filter_cv_c(uint8_t *d, ptrdiff_t stride, int alpha, int beta, int tc,
157 int bs1, int bs2)
158 {
159 int i;
160
2/2
✓ Branch 0 taken 57048 times.
✓ Branch 1 taken 198434 times.
255482 if(bs1==2)
161
2/2
✓ Branch 0 taken 456384 times.
✓ Branch 1 taken 57048 times.
513432 for(i=0;i<8;i++)
162 456384 loop_filter_c2(d + i*stride,1,alpha,beta);
163 else {
164
2/2
✓ Branch 0 taken 125214 times.
✓ Branch 1 taken 73220 times.
198434 if(bs1)
165
2/2
✓ Branch 0 taken 500856 times.
✓ Branch 1 taken 125214 times.
626070 for(i=0;i<4;i++)
166 500856 loop_filter_c1(d + i*stride,1,alpha,beta,tc);
167
2/2
✓ Branch 0 taken 122028 times.
✓ Branch 1 taken 76406 times.
198434 if (bs2)
168
2/2
✓ Branch 0 taken 488112 times.
✓ Branch 1 taken 122028 times.
610140 for(i=4;i<8;i++)
169 488112 loop_filter_c1(d + i*stride,1,alpha,beta,tc);
170 }
171 255482 }
172
173 252156 static void cavs_filter_ch_c(uint8_t *d, ptrdiff_t stride, int alpha, int beta, int tc,
174 int bs1, int bs2)
175 {
176 int i;
177
2/2
✓ Branch 0 taken 58116 times.
✓ Branch 1 taken 194040 times.
252156 if(bs1==2)
178
2/2
✓ Branch 0 taken 464928 times.
✓ Branch 1 taken 58116 times.
523044 for(i=0;i<8;i++)
179 464928 loop_filter_c2(d + i,stride,alpha,beta);
180 else {
181
2/2
✓ Branch 0 taken 122564 times.
✓ Branch 1 taken 71476 times.
194040 if(bs1)
182
2/2
✓ Branch 0 taken 490256 times.
✓ Branch 1 taken 122564 times.
612820 for(i=0;i<4;i++)
183 490256 loop_filter_c1(d + i,stride,alpha,beta,tc);
184
2/2
✓ Branch 0 taken 125268 times.
✓ Branch 1 taken 68772 times.
194040 if (bs2)
185
2/2
✓ Branch 0 taken 501072 times.
✓ Branch 1 taken 125268 times.
626340 for(i=4;i<8;i++)
186 501072 loop_filter_c1(d + i,stride,alpha,beta,tc);
187 }
188 252156 }
189
190 /*****************************************************************************
191 *
192 * inverse transform
193 *
194 ****************************************************************************/
195
196 351600 static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, ptrdiff_t stride)
197 {
198 int i;
199 351600 int16_t (*src)[8] = (int16_t(*)[8])block;
200
201 351600 src[0][0] += 8;
202
203
2/2
✓ Branch 0 taken 2812800 times.
✓ Branch 1 taken 351600 times.
3164400 for( i = 0; i < 8; i++ ) {
204 2812800 const int a0 = 3 * src[i][1] - 2 * src[i][7];
205 2812800 const int a1 = 3 * src[i][3] + 2 * src[i][5];
206 2812800 const int a2 = 2 * src[i][3] - 3 * src[i][5];
207 2812800 const int a3 = 2 * src[i][1] + 3 * src[i][7];
208
209 2812800 const int b4 = 2 * (a0 + a1 + a3) + a1;
210 2812800 const int b5 = 2 * (a0 - a1 + a2) + a0;
211 2812800 const int b6 = 2 * (a3 - a2 - a1) + a3;
212 2812800 const int b7 = 2 * (a0 - a2 - a3) - a2;
213
214 2812800 const int a7 = 4 * src[i][2] - 10 * src[i][6];
215 2812800 const int a6 = 4 * src[i][6] + 10 * src[i][2];
216 2812800 const int a5 = 8 * (src[i][0] - src[i][4]) + 4;
217 2812800 const int a4 = 8 * (src[i][0] + src[i][4]) + 4;
218
219 2812800 const int b0 = a4 + a6;
220 2812800 const int b1 = a5 + a7;
221 2812800 const int b2 = a5 - a7;
222 2812800 const int b3 = a4 - a6;
223
224 2812800 src[i][0] = (b0 + b4) >> 3;
225 2812800 src[i][1] = (b1 + b5) >> 3;
226 2812800 src[i][2] = (b2 + b6) >> 3;
227 2812800 src[i][3] = (b3 + b7) >> 3;
228 2812800 src[i][4] = (b3 - b7) >> 3;
229 2812800 src[i][5] = (b2 - b6) >> 3;
230 2812800 src[i][6] = (b1 - b5) >> 3;
231 2812800 src[i][7] = (b0 - b4) >> 3;
232 }
233
2/2
✓ Branch 0 taken 2812800 times.
✓ Branch 1 taken 351600 times.
3164400 for( i = 0; i < 8; i++ ) {
234 2812800 const int a0 = 3 * src[1][i] - 2 * src[7][i];
235 2812800 const int a1 = 3 * src[3][i] + 2 * src[5][i];
236 2812800 const int a2 = 2 * src[3][i] - 3 * src[5][i];
237 2812800 const int a3 = 2 * src[1][i] + 3 * src[7][i];
238
239 2812800 const int b4 = 2 * (a0 + a1 + a3) + a1;
240 2812800 const int b5 = 2 * (a0 - a1 + a2) + a0;
241 2812800 const int b6 = 2 * (a3 - a2 - a1) + a3;
242 2812800 const int b7 = 2 * (a0 - a2 - a3) - a2;
243
244 2812800 const int a7 = 4 * src[2][i] - 10 * src[6][i];
245 2812800 const int a6 = 4 * src[6][i] + 10 * src[2][i];
246 2812800 const int a5 = 8 * (src[0][i] - src[4][i]);
247 2812800 const int a4 = 8 * (src[0][i] + src[4][i]);
248
249 2812800 const int b0 = a4 + a6;
250 2812800 const int b1 = a5 + a7;
251 2812800 const int b2 = a5 - a7;
252 2812800 const int b3 = a4 - a6;
253
254 2812800 dst[i + 0*stride] = av_clip_uint8( dst[i + 0*stride] + ((b0 + b4) >> 7));
255 2812800 dst[i + 1*stride] = av_clip_uint8( dst[i + 1*stride] + ((b1 + b5) >> 7));
256 2812800 dst[i + 2*stride] = av_clip_uint8( dst[i + 2*stride] + ((b2 + b6) >> 7));
257 2812800 dst[i + 3*stride] = av_clip_uint8( dst[i + 3*stride] + ((b3 + b7) >> 7));
258 2812800 dst[i + 4*stride] = av_clip_uint8( dst[i + 4*stride] + ((b3 - b7) >> 7));
259 2812800 dst[i + 5*stride] = av_clip_uint8( dst[i + 5*stride] + ((b2 - b6) >> 7));
260 2812800 dst[i + 6*stride] = av_clip_uint8( dst[i + 6*stride] + ((b1 - b5) >> 7));
261 2812800 dst[i + 7*stride] = av_clip_uint8( dst[i + 7*stride] + ((b0 - b4) >> 7));
262 }
263 351600 }
264
265 /*****************************************************************************
266 *
267 * motion compensation
268 *
269 ****************************************************************************/
270
271 #define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \
272 static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
273 { \
274 const int h=8;\
275 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
276 int i;\
277 for(i=0; i<h; i++)\
278 {\
279 OP(dst[0], A*src[-2] + B*src[-1] + C*src[0] + D*src[1] + E*src[2] + F*src[3]);\
280 OP(dst[1], A*src[-1] + B*src[ 0] + C*src[1] + D*src[2] + E*src[3] + F*src[4]);\
281 OP(dst[2], A*src[ 0] + B*src[ 1] + C*src[2] + D*src[3] + E*src[4] + F*src[5]);\
282 OP(dst[3], A*src[ 1] + B*src[ 2] + C*src[3] + D*src[4] + E*src[5] + F*src[6]);\
283 OP(dst[4], A*src[ 2] + B*src[ 3] + C*src[4] + D*src[5] + E*src[6] + F*src[7]);\
284 OP(dst[5], A*src[ 3] + B*src[ 4] + C*src[5] + D*src[6] + E*src[7] + F*src[8]);\
285 OP(dst[6], A*src[ 4] + B*src[ 5] + C*src[6] + D*src[7] + E*src[8] + F*src[9]);\
286 OP(dst[7], A*src[ 5] + B*src[ 6] + C*src[7] + D*src[8] + E*src[9] + F*src[10]);\
287 dst+=dstStride;\
288 src+=srcStride;\
289 }\
290 }\
291 \
292 static void OPNAME ## cavs_filt8_v_ ## NAME(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
293 { \
294 const int w=8;\
295 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
296 int i;\
297 for(i=0; i<w; i++)\
298 {\
299 const int srcB= src[-2*srcStride];\
300 const int srcA= src[-1*srcStride];\
301 const int src0= src[0 *srcStride];\
302 const int src1= src[1 *srcStride];\
303 const int src2= src[2 *srcStride];\
304 const int src3= src[3 *srcStride];\
305 const int src4= src[4 *srcStride];\
306 const int src5= src[5 *srcStride];\
307 const int src6= src[6 *srcStride];\
308 const int src7= src[7 *srcStride];\
309 const int src8= src[8 *srcStride];\
310 const int src9= src[9 *srcStride];\
311 const int src10= src[10 *srcStride];\
312 OP(dst[0*dstStride], A*srcB + B*srcA + C*src0 + D*src1 + E*src2 + F*src3);\
313 OP(dst[1*dstStride], A*srcA + B*src0 + C*src1 + D*src2 + E*src3 + F*src4);\
314 OP(dst[2*dstStride], A*src0 + B*src1 + C*src2 + D*src3 + E*src4 + F*src5);\
315 OP(dst[3*dstStride], A*src1 + B*src2 + C*src3 + D*src4 + E*src5 + F*src6);\
316 OP(dst[4*dstStride], A*src2 + B*src3 + C*src4 + D*src5 + E*src6 + F*src7);\
317 OP(dst[5*dstStride], A*src3 + B*src4 + C*src5 + D*src6 + E*src7 + F*src8);\
318 OP(dst[6*dstStride], A*src4 + B*src5 + C*src6 + D*src7 + E*src8 + F*src9);\
319 OP(dst[7*dstStride], A*src5 + B*src6 + C*src7 + D*src8 + E*src9 + F*src10);\
320 dst++;\
321 src++;\
322 }\
323 }\
324 \
325 static void OPNAME ## cavs_filt16_v_ ## NAME(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
326 { \
327 OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\
328 OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
329 src += 8*srcStride;\
330 dst += 8*dstStride;\
331 OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\
332 OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
333 }\
334 \
335 static void OPNAME ## cavs_filt16_h_ ## NAME(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
336 { \
337 OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\
338 OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
339 src += 8*srcStride;\
340 dst += 8*dstStride;\
341 OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\
342 OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
343 }\
344
345 #define CAVS_SUBPIX_HV(OPNAME, OP, NAME, AH, BH, CH, DH, EH, FH, AV, BV, CV, DV, EV, FV, FULL) \
346 static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, ptrdiff_t dstStride, ptrdiff_t srcStride)\
347 { \
348 int16_t temp[8*(8+5)];\
349 int16_t *tmp = temp;\
350 const int h=8;\
351 const int w=8;\
352 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
353 int i;\
354 src1 -= 2*srcStride;\
355 for(i=0; i<h+5; i++)\
356 {\
357 tmp[0]= AH*src1[-2] + BH*src1[-1] + CH*src1[0] + DH*src1[1] + EH*src1[2] + FH*src1[3];\
358 tmp[1]= AH*src1[-1] + BH*src1[ 0] + CH*src1[1] + DH*src1[2] + EH*src1[3] + FH*src1[4];\
359 tmp[2]= AH*src1[ 0] + BH*src1[ 1] + CH*src1[2] + DH*src1[3] + EH*src1[4] + FH*src1[5];\
360 tmp[3]= AH*src1[ 1] + BH*src1[ 2] + CH*src1[3] + DH*src1[4] + EH*src1[5] + FH*src1[6];\
361 tmp[4]= AH*src1[ 2] + BH*src1[ 3] + CH*src1[4] + DH*src1[5] + EH*src1[6] + FH*src1[7];\
362 tmp[5]= AH*src1[ 3] + BH*src1[ 4] + CH*src1[5] + DH*src1[6] + EH*src1[7] + FH*src1[8];\
363 tmp[6]= AH*src1[ 4] + BH*src1[ 5] + CH*src1[6] + DH*src1[7] + EH*src1[8] + FH*src1[9];\
364 tmp[7]= AH*src1[ 5] + BH*src1[ 6] + CH*src1[7] + DH*src1[8] + EH*src1[9] + FH*src1[10];\
365 tmp+=8;\
366 src1+=srcStride;\
367 }\
368 if(FULL) {\
369 tmp = temp+8*2; \
370 for(i=0; i<w; i++) \
371 { \
372 const int tmpB= tmp[-2*8]; \
373 const int tmpA= tmp[-1*8]; \
374 const int tmp0= tmp[0 *8]; \
375 const int tmp1= tmp[1 *8]; \
376 const int tmp2= tmp[2 *8]; \
377 const int tmp3= tmp[3 *8]; \
378 const int tmp4= tmp[4 *8]; \
379 const int tmp5= tmp[5 *8]; \
380 const int tmp6= tmp[6 *8]; \
381 const int tmp7= tmp[7 *8]; \
382 const int tmp8= tmp[8 *8]; \
383 const int tmp9= tmp[9 *8]; \
384 const int tmp10=tmp[10*8]; \
385 OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3 + 64*src2[0*srcStride]); \
386 OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4 + 64*src2[1*srcStride]); \
387 OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5 + 64*src2[2*srcStride]); \
388 OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6 + 64*src2[3*srcStride]); \
389 OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7 + 64*src2[4*srcStride]); \
390 OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8 + 64*src2[5*srcStride]); \
391 OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9 + 64*src2[6*srcStride]); \
392 OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10 + 64*src2[7*srcStride]); \
393 dst++; \
394 tmp++; \
395 src2++; \
396 } \
397 } else {\
398 tmp = temp+8*2; \
399 for(i=0; i<w; i++) \
400 { \
401 const int tmpB= tmp[-2*8]; \
402 const int tmpA= tmp[-1*8]; \
403 const int tmp0= tmp[0 *8]; \
404 const int tmp1= tmp[1 *8]; \
405 const int tmp2= tmp[2 *8]; \
406 const int tmp3= tmp[3 *8]; \
407 const int tmp4= tmp[4 *8]; \
408 const int tmp5= tmp[5 *8]; \
409 const int tmp6= tmp[6 *8]; \
410 const int tmp7= tmp[7 *8]; \
411 const int tmp8= tmp[8 *8]; \
412 const int tmp9= tmp[9 *8]; \
413 const int tmp10=tmp[10*8]; \
414 OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3); \
415 OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4); \
416 OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5); \
417 OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6); \
418 OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7); \
419 OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8); \
420 OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9); \
421 OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10); \
422 dst++; \
423 tmp++; \
424 } \
425 }\
426 }\
427 \
428 static void OPNAME ## cavs_filt16_hv_ ## NAME(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, ptrdiff_t dstStride, ptrdiff_t srcStride)\
429 { \
430 OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
431 OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
432 src1 += 8*srcStride;\
433 src2 += 8*srcStride;\
434 dst += 8*dstStride;\
435 OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
436 OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
437 }\
438
439 #define CAVS_MC(OPNAME, SIZE) \
440 static void OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
441 {\
442 OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\
443 }\
444 \
445 static void OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
446 {\
447 OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\
448 }\
449 \
450 static void OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
451 {\
452 OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\
453 }\
454 \
455 static void OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
456 {\
457 OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\
458 }\
459 \
460 static void OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
461 {\
462 OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\
463 }\
464 \
465 static void OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
466 {\
467 OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\
468 }\
469 \
470 static void OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
471 {\
472 OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \
473 }\
474 \
475 static void OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
476 {\
477 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \
478 }\
479 \
480 static void OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
481 {\
482 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \
483 }\
484 \
485 static void OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
486 {\
487 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \
488 }\
489 \
490 static void OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
491 {\
492 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \
493 }\
494 \
495 static void OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
496 {\
497 OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \
498 }\
499 \
500 static void OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
501 {\
502 OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \
503 }\
504 \
505 static void OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
506 {\
507 OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \
508 }\
509 \
510 static void OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
511 {\
512 OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \
513 }\
514
515 #define op_put1(a, b) a = cm[((b)+4)>>3]
516 #define op_put2(a, b) a = cm[((b)+64)>>7]
517 #define op_put3(a, b) a = cm[((b)+32)>>6]
518 #define op_put4(a, b) a = cm[((b)+512)>>10]
519 #define op_avg1(a, b) a = ((a)+cm[((b)+4)>>3] +1)>>1
520 #define op_avg2(a, b) a = ((a)+cm[((b)+64)>>7] +1)>>1
521 #define op_avg3(a, b) a = ((a)+cm[((b)+32)>>6] +1)>>1
522 #define op_avg4(a, b) a = ((a)+cm[((b)+512)>>10]+1)>>1
523
2/2
✓ Branch 0 taken 264360 times.
✓ Branch 1 taken 33045 times.
598762 CAVS_SUBPIX(put_ , op_put1, hpel, 0, -1, 5, 5, -1, 0)
524
2/2
✓ Branch 0 taken 362240 times.
✓ Branch 1 taken 45280 times.
410831 CAVS_SUBPIX(put_ , op_put2, qpel_l, -1, -2, 96, 42, -7, 0)
525
2/2
✓ Branch 0 taken 363560 times.
✓ Branch 1 taken 45445 times.
412414 CAVS_SUBPIX(put_ , op_put2, qpel_r, 0, -7, 42, 96, -2, -1)
526
4/4
✓ Branch 0 taken 34710 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 21360 times.
✓ Branch 3 taken 2670 times.
58902 CAVS_SUBPIX_HV(put_, op_put3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0)
527
4/4
✓ Branch 0 taken 47762 times.
✓ Branch 1 taken 3674 times.
✓ Branch 2 taken 29392 times.
✓ Branch 3 taken 3674 times.
81062 CAVS_SUBPIX_HV(put_, op_put4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0)
528
4/4
✓ Branch 0 taken 45981 times.
✓ Branch 1 taken 3537 times.
✓ Branch 2 taken 28296 times.
✓ Branch 3 taken 3537 times.
78014 CAVS_SUBPIX_HV(put_, op_put4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0)
529
4/4
✓ Branch 0 taken 52949 times.
✓ Branch 1 taken 4073 times.
✓ Branch 2 taken 32584 times.
✓ Branch 3 taken 4073 times.
89866 CAVS_SUBPIX_HV(put_, op_put4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0)
530
4/4
✓ Branch 0 taken 47047 times.
✓ Branch 1 taken 3619 times.
✓ Branch 2 taken 28952 times.
✓ Branch 3 taken 3619 times.
79837 CAVS_SUBPIX_HV(put_, op_put4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0)
531
4/4
✓ Branch 0 taken 286923 times.
✓ Branch 1 taken 22071 times.
✓ Branch 2 taken 176568 times.
✓ Branch 3 taken 22071 times.
487181 CAVS_SUBPIX_HV(put_, op_put2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
532
2/2
✓ Branch 0 taken 169192 times.
✓ Branch 1 taken 21149 times.
190773 CAVS_SUBPIX(avg_ , op_avg1, hpel, 0, -1, 5, 5, -1, 0)
533
2/2
✓ Branch 0 taken 76672 times.
✓ Branch 1 taken 9584 times.
86383 CAVS_SUBPIX(avg_ , op_avg2, qpel_l, -1, -2, 96, 42, -7, 0)
534
2/2
✓ Branch 0 taken 89968 times.
✓ Branch 1 taken 11246 times.
101449 CAVS_SUBPIX(avg_ , op_avg2, qpel_r, 0, -7, 42, 96, -2, -1)
535
4/4
✓ Branch 0 taken 25701 times.
✓ Branch 1 taken 1977 times.
✓ Branch 2 taken 15816 times.
✓ Branch 3 taken 1977 times.
43554 CAVS_SUBPIX_HV(avg_, op_avg3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0)
536
4/4
✓ Branch 0 taken 8723 times.
✓ Branch 1 taken 671 times.
✓ Branch 2 taken 5368 times.
✓ Branch 3 taken 671 times.
14767 CAVS_SUBPIX_HV(avg_, op_avg4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0)
537
4/4
✓ Branch 0 taken 8008 times.
✓ Branch 1 taken 616 times.
✓ Branch 2 taken 4928 times.
✓ Branch 3 taken 616 times.
13563 CAVS_SUBPIX_HV(avg_, op_avg4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0)
538
4/4
✓ Branch 0 taken 9282 times.
✓ Branch 1 taken 714 times.
✓ Branch 2 taken 5712 times.
✓ Branch 3 taken 714 times.
15717 CAVS_SUBPIX_HV(avg_, op_avg4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0)
539
4/4
✓ Branch 0 taken 11453 times.
✓ Branch 1 taken 881 times.
✓ Branch 2 taken 7048 times.
✓ Branch 3 taken 881 times.
19395 CAVS_SUBPIX_HV(avg_, op_avg4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0)
540
4/4
✓ Branch 0 taken 38922 times.
✓ Branch 1 taken 2994 times.
✓ Branch 2 taken 23952 times.
✓ Branch 3 taken 2994 times.
65941 CAVS_SUBPIX_HV(avg_, op_avg2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
541 117854 CAVS_MC(put_, 8)
542 11390 CAVS_MC(put_, 16)
543 45972 CAVS_MC(avg_, 8)
544 965 CAVS_MC(avg_, 16)
545
546 #define put_cavs_qpel8_mc00_c ff_put_pixels8x8_c
547 #define avg_cavs_qpel8_mc00_c ff_avg_pixels8x8_c
548 #define put_cavs_qpel16_mc00_c ff_put_pixels16x16_c
549 #define avg_cavs_qpel16_mc00_c ff_avg_pixels16x16_c
550
551 4 av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) {
552 #define dspfunc(PFX, IDX, NUM) \
553 c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
554 c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
555 c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
556 c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
557 c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
558 c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
559 c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
560 c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
561 c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
562 c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
563 c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
564 c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
565 c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
566 c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
567 c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
568 c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
569 4 dspfunc(put_cavs_qpel, 0, 16);
570 4 dspfunc(put_cavs_qpel, 1, 8);
571 4 dspfunc(avg_cavs_qpel, 0, 16);
572 4 dspfunc(avg_cavs_qpel, 1, 8);
573 4 c->cavs_filter_lv = cavs_filter_lv_c;
574 4 c->cavs_filter_lh = cavs_filter_lh_c;
575 4 c->cavs_filter_cv = cavs_filter_cv_c;
576 4 c->cavs_filter_ch = cavs_filter_ch_c;
577 4 c->cavs_idct8_add = cavs_idct8_add_c;
578 4 c->idct_perm = FF_IDCT_PERM_NONE;
579
580 if (ARCH_X86)
581 4 ff_cavsdsp_init_x86(c, avctx);
582 4 }
583