FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/qpeldsp.c
Date: 2022-07-04 00:18:54
Exec Total Coverage
Lines: 29 29 100.0%
Branches: 6 6 100.0%

Line Branch Exec Source
1 /*
2 * quarterpel DSP functions
3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg 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.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg 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 FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * quarterpel DSP functions
26 */
27
28 #include <stddef.h>
29 #include <stdint.h>
30
31 #include "config.h"
32 #include "config_components.h"
33 #include "libavutil/attributes.h"
34 #include "copy_block.h"
35 #include "qpeldsp.h"
36 #include "diracdsp.h"
37
38 #define BIT_DEPTH 8
39 #include "hpel_template.c"
40 #include "pel_template.c"
41 #include "qpel_template.c"
42
43 #define QPEL_MC(r, OPNAME, RND, OP) \
44 static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, const uint8_t *src, \
45 int dstStride, int srcStride, \
46 int h) \
47 { \
48 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
49 int i; \
50 \
51 for (i = 0; i < h; i++) { \
52 OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
53 OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
54 OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
55 OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
56 OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
57 OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[8])); \
58 OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[8]) * 3 - (src[3] + src[7])); \
59 OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[8]) * 6 + (src[5] + src[7]) * 3 - (src[4] + src[6])); \
60 dst += dstStride; \
61 src += srcStride; \
62 } \
63 } \
64 \
65 static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, const uint8_t *src, \
66 int dstStride, int srcStride) \
67 { \
68 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
69 const int w = 8; \
70 int i; \
71 \
72 for (i = 0; i < w; i++) { \
73 const int src0 = src[0 * srcStride]; \
74 const int src1 = src[1 * srcStride]; \
75 const int src2 = src[2 * srcStride]; \
76 const int src3 = src[3 * srcStride]; \
77 const int src4 = src[4 * srcStride]; \
78 const int src5 = src[5 * srcStride]; \
79 const int src6 = src[6 * srcStride]; \
80 const int src7 = src[7 * srcStride]; \
81 const int src8 = src[8 * srcStride]; \
82 OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
83 OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
84 OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
85 OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
86 OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
87 OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src8)); \
88 OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src8) * 3 - (src3 + src7)); \
89 OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src8) * 6 + (src5 + src7) * 3 - (src4 + src6)); \
90 dst++; \
91 src++; \
92 } \
93 } \
94 \
95 static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, \
96 const uint8_t *src, \
97 int dstStride, int srcStride, \
98 int h) \
99 { \
100 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
101 int i; \
102 \
103 for (i = 0; i < h; i++) { \
104 OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
105 OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
106 OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
107 OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
108 OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
109 OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[9])); \
110 OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[9]) * 3 - (src[3] + src[10])); \
111 OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[9]) * 6 + (src[5] + src[10]) * 3 - (src[4] + src[11])); \
112 OP(dst[8], (src[8] + src[9]) * 20 - (src[7] + src[10]) * 6 + (src[6] + src[11]) * 3 - (src[5] + src[12])); \
113 OP(dst[9], (src[9] + src[10]) * 20 - (src[8] + src[11]) * 6 + (src[7] + src[12]) * 3 - (src[6] + src[13])); \
114 OP(dst[10], (src[10] + src[11]) * 20 - (src[9] + src[12]) * 6 + (src[8] + src[13]) * 3 - (src[7] + src[14])); \
115 OP(dst[11], (src[11] + src[12]) * 20 - (src[10] + src[13]) * 6 + (src[9] + src[14]) * 3 - (src[8] + src[15])); \
116 OP(dst[12], (src[12] + src[13]) * 20 - (src[11] + src[14]) * 6 + (src[10] + src[15]) * 3 - (src[9] + src[16])); \
117 OP(dst[13], (src[13] + src[14]) * 20 - (src[12] + src[15]) * 6 + (src[11] + src[16]) * 3 - (src[10] + src[16])); \
118 OP(dst[14], (src[14] + src[15]) * 20 - (src[13] + src[16]) * 6 + (src[12] + src[16]) * 3 - (src[11] + src[15])); \
119 OP(dst[15], (src[15] + src[16]) * 20 - (src[14] + src[16]) * 6 + (src[13] + src[15]) * 3 - (src[12] + src[14])); \
120 dst += dstStride; \
121 src += srcStride; \
122 } \
123 } \
124 \
125 static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, \
126 const uint8_t *src, \
127 int dstStride, int srcStride) \
128 { \
129 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
130 const int w = 16; \
131 int i; \
132 \
133 for (i = 0; i < w; i++) { \
134 const int src0 = src[0 * srcStride]; \
135 const int src1 = src[1 * srcStride]; \
136 const int src2 = src[2 * srcStride]; \
137 const int src3 = src[3 * srcStride]; \
138 const int src4 = src[4 * srcStride]; \
139 const int src5 = src[5 * srcStride]; \
140 const int src6 = src[6 * srcStride]; \
141 const int src7 = src[7 * srcStride]; \
142 const int src8 = src[8 * srcStride]; \
143 const int src9 = src[9 * srcStride]; \
144 const int src10 = src[10 * srcStride]; \
145 const int src11 = src[11 * srcStride]; \
146 const int src12 = src[12 * srcStride]; \
147 const int src13 = src[13 * srcStride]; \
148 const int src14 = src[14 * srcStride]; \
149 const int src15 = src[15 * srcStride]; \
150 const int src16 = src[16 * srcStride]; \
151 OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
152 OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
153 OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
154 OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
155 OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
156 OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src9)); \
157 OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src9) * 3 - (src3 + src10)); \
158 OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src9) * 6 + (src5 + src10) * 3 - (src4 + src11)); \
159 OP(dst[8 * dstStride], (src8 + src9) * 20 - (src7 + src10) * 6 + (src6 + src11) * 3 - (src5 + src12)); \
160 OP(dst[9 * dstStride], (src9 + src10) * 20 - (src8 + src11) * 6 + (src7 + src12) * 3 - (src6 + src13)); \
161 OP(dst[10 * dstStride], (src10 + src11) * 20 - (src9 + src12) * 6 + (src8 + src13) * 3 - (src7 + src14)); \
162 OP(dst[11 * dstStride], (src11 + src12) * 20 - (src10 + src13) * 6 + (src9 + src14) * 3 - (src8 + src15)); \
163 OP(dst[12 * dstStride], (src12 + src13) * 20 - (src11 + src14) * 6 + (src10 + src15) * 3 - (src9 + src16)); \
164 OP(dst[13 * dstStride], (src13 + src14) * 20 - (src12 + src15) * 6 + (src11 + src16) * 3 - (src10 + src16)); \
165 OP(dst[14 * dstStride], (src14 + src15) * 20 - (src13 + src16) * 6 + (src12 + src16) * 3 - (src11 + src15)); \
166 OP(dst[15 * dstStride], (src15 + src16) * 20 - (src14 + src16) * 6 + (src13 + src15) * 3 - (src12 + src14)); \
167 dst++; \
168 src++; \
169 } \
170 } \
171 \
172 static void OPNAME ## qpel8_mc10_c(uint8_t *dst, const uint8_t *src, \
173 ptrdiff_t stride) \
174 { \
175 uint8_t half[64]; \
176 \
177 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
178 OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8); \
179 } \
180 \
181 static void OPNAME ## qpel8_mc20_c(uint8_t *dst, const uint8_t *src, \
182 ptrdiff_t stride) \
183 { \
184 OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8); \
185 } \
186 \
187 static void OPNAME ## qpel8_mc30_c(uint8_t *dst, const uint8_t *src, \
188 ptrdiff_t stride) \
189 { \
190 uint8_t half[64]; \
191 \
192 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
193 OPNAME ## pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8); \
194 } \
195 \
196 static void OPNAME ## qpel8_mc01_c(uint8_t *dst, const uint8_t *src, \
197 ptrdiff_t stride) \
198 { \
199 uint8_t full[16 * 9]; \
200 uint8_t half[64]; \
201 \
202 copy_block9(full, src, 16, stride, 9); \
203 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
204 OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8); \
205 } \
206 \
207 static void OPNAME ## qpel8_mc02_c(uint8_t *dst, const uint8_t *src, \
208 ptrdiff_t stride) \
209 { \
210 uint8_t full[16 * 9]; \
211 \
212 copy_block9(full, src, 16, stride, 9); \
213 OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \
214 } \
215 \
216 static void OPNAME ## qpel8_mc03_c(uint8_t *dst, const uint8_t *src, \
217 ptrdiff_t stride) \
218 { \
219 uint8_t full[16 * 9]; \
220 uint8_t half[64]; \
221 \
222 copy_block9(full, src, 16, stride, 9); \
223 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
224 OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8); \
225 } \
226 \
227 void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, const uint8_t *src, \
228 ptrdiff_t stride) \
229 { \
230 uint8_t full[16 * 9]; \
231 uint8_t halfH[72]; \
232 uint8_t halfV[64]; \
233 uint8_t halfHV[64]; \
234 \
235 copy_block9(full, src, 16, stride, 9); \
236 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
237 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
238 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
239 OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV, \
240 stride, 16, 8, 8, 8, 8); \
241 } \
242 \
243 static void OPNAME ## qpel8_mc11_c(uint8_t *dst, const uint8_t *src, \
244 ptrdiff_t stride) \
245 { \
246 uint8_t full[16 * 9]; \
247 uint8_t halfH[72]; \
248 uint8_t halfHV[64]; \
249 \
250 copy_block9(full, src, 16, stride, 9); \
251 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
252 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
253 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
254 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
255 } \
256 \
257 void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, const uint8_t *src, \
258 ptrdiff_t stride) \
259 { \
260 uint8_t full[16 * 9]; \
261 uint8_t halfH[72]; \
262 uint8_t halfV[64]; \
263 uint8_t halfHV[64]; \
264 \
265 copy_block9(full, src, 16, stride, 9); \
266 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
267 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
268 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
269 OPNAME ## pixels8_l4_8(dst, full + 1, halfH, halfV, halfHV, \
270 stride, 16, 8, 8, 8, 8); \
271 } \
272 \
273 static void OPNAME ## qpel8_mc31_c(uint8_t *dst, const uint8_t *src, \
274 ptrdiff_t stride) \
275 { \
276 uint8_t full[16 * 9]; \
277 uint8_t halfH[72]; \
278 uint8_t halfHV[64]; \
279 \
280 copy_block9(full, src, 16, stride, 9); \
281 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
282 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
283 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
284 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
285 } \
286 \
287 void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, const uint8_t *src, \
288 ptrdiff_t stride) \
289 { \
290 uint8_t full[16 * 9]; \
291 uint8_t halfH[72]; \
292 uint8_t halfV[64]; \
293 uint8_t halfHV[64]; \
294 \
295 copy_block9(full, src, 16, stride, 9); \
296 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
297 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
298 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
299 OPNAME ## pixels8_l4_8(dst, full + 16, halfH + 8, halfV, halfHV, \
300 stride, 16, 8, 8, 8, 8); \
301 } \
302 \
303 static void OPNAME ## qpel8_mc13_c(uint8_t *dst, const uint8_t *src, \
304 ptrdiff_t stride) \
305 { \
306 uint8_t full[16 * 9]; \
307 uint8_t halfH[72]; \
308 uint8_t halfHV[64]; \
309 \
310 copy_block9(full, src, 16, stride, 9); \
311 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
312 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
313 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
314 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
315 } \
316 \
317 void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, const uint8_t *src, \
318 ptrdiff_t stride) \
319 { \
320 uint8_t full[16 * 9]; \
321 uint8_t halfH[72]; \
322 uint8_t halfV[64]; \
323 uint8_t halfHV[64]; \
324 \
325 copy_block9(full, src, 16, stride, 9); \
326 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
327 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
328 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
329 OPNAME ## pixels8_l4_8(dst, full + 17, halfH + 8, halfV, halfHV, \
330 stride, 16, 8, 8, 8, 8); \
331 } \
332 \
333 static void OPNAME ## qpel8_mc33_c(uint8_t *dst, const uint8_t *src, \
334 ptrdiff_t stride) \
335 { \
336 uint8_t full[16 * 9]; \
337 uint8_t halfH[72]; \
338 uint8_t halfHV[64]; \
339 \
340 copy_block9(full, src, 16, stride, 9); \
341 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
342 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
343 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
344 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
345 } \
346 \
347 static void OPNAME ## qpel8_mc21_c(uint8_t *dst, const uint8_t *src, \
348 ptrdiff_t stride) \
349 { \
350 uint8_t halfH[72]; \
351 uint8_t halfHV[64]; \
352 \
353 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
354 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
355 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
356 } \
357 \
358 static void OPNAME ## qpel8_mc23_c(uint8_t *dst, const uint8_t *src, \
359 ptrdiff_t stride) \
360 { \
361 uint8_t halfH[72]; \
362 uint8_t halfHV[64]; \
363 \
364 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
365 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
366 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
367 } \
368 \
369 void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, const uint8_t *src, \
370 ptrdiff_t stride) \
371 { \
372 uint8_t full[16 * 9]; \
373 uint8_t halfH[72]; \
374 uint8_t halfV[64]; \
375 uint8_t halfHV[64]; \
376 \
377 copy_block9(full, src, 16, stride, 9); \
378 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
379 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
380 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
381 OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); \
382 } \
383 \
384 static void OPNAME ## qpel8_mc12_c(uint8_t *dst, const uint8_t *src, \
385 ptrdiff_t stride) \
386 { \
387 uint8_t full[16 * 9]; \
388 uint8_t halfH[72]; \
389 \
390 copy_block9(full, src, 16, stride, 9); \
391 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
392 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
393 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
394 } \
395 \
396 void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, const uint8_t *src, \
397 ptrdiff_t stride) \
398 { \
399 uint8_t full[16 * 9]; \
400 uint8_t halfH[72]; \
401 uint8_t halfV[64]; \
402 uint8_t halfHV[64]; \
403 \
404 copy_block9(full, src, 16, stride, 9); \
405 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
406 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
407 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
408 OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); \
409 } \
410 \
411 static void OPNAME ## qpel8_mc32_c(uint8_t *dst, const uint8_t *src, \
412 ptrdiff_t stride) \
413 { \
414 uint8_t full[16 * 9]; \
415 uint8_t halfH[72]; \
416 \
417 copy_block9(full, src, 16, stride, 9); \
418 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
419 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
420 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
421 } \
422 \
423 static void OPNAME ## qpel8_mc22_c(uint8_t *dst, const uint8_t *src, \
424 ptrdiff_t stride) \
425 { \
426 uint8_t halfH[72]; \
427 \
428 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
429 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
430 } \
431 \
432 static void OPNAME ## qpel16_mc10_c(uint8_t *dst, const uint8_t *src, \
433 ptrdiff_t stride) \
434 { \
435 uint8_t half[256]; \
436 \
437 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
438 OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16); \
439 } \
440 \
441 static void OPNAME ## qpel16_mc20_c(uint8_t *dst, const uint8_t *src, \
442 ptrdiff_t stride) \
443 { \
444 OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16); \
445 } \
446 \
447 static void OPNAME ## qpel16_mc30_c(uint8_t *dst, const uint8_t *src, \
448 ptrdiff_t stride) \
449 { \
450 uint8_t half[256]; \
451 \
452 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
453 OPNAME ## pixels16_l2_8(dst, src + 1, half, stride, stride, 16, 16); \
454 } \
455 \
456 static void OPNAME ## qpel16_mc01_c(uint8_t *dst, const uint8_t *src, \
457 ptrdiff_t stride) \
458 { \
459 uint8_t full[24 * 17]; \
460 uint8_t half[256]; \
461 \
462 copy_block17(full, src, 24, stride, 17); \
463 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
464 OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16); \
465 } \
466 \
467 static void OPNAME ## qpel16_mc02_c(uint8_t *dst, const uint8_t *src, \
468 ptrdiff_t stride) \
469 { \
470 uint8_t full[24 * 17]; \
471 \
472 copy_block17(full, src, 24, stride, 17); \
473 OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \
474 } \
475 \
476 static void OPNAME ## qpel16_mc03_c(uint8_t *dst, const uint8_t *src, \
477 ptrdiff_t stride) \
478 { \
479 uint8_t full[24 * 17]; \
480 uint8_t half[256]; \
481 \
482 copy_block17(full, src, 24, stride, 17); \
483 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
484 OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16); \
485 } \
486 \
487 void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, const uint8_t *src, \
488 ptrdiff_t stride) \
489 { \
490 uint8_t full[24 * 17]; \
491 uint8_t halfH[272]; \
492 uint8_t halfV[256]; \
493 uint8_t halfHV[256]; \
494 \
495 copy_block17(full, src, 24, stride, 17); \
496 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
497 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
498 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
499 OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV, \
500 stride, 24, 16, 16, 16, 16); \
501 } \
502 \
503 static void OPNAME ## qpel16_mc11_c(uint8_t *dst, const uint8_t *src, \
504 ptrdiff_t stride) \
505 { \
506 uint8_t full[24 * 17]; \
507 uint8_t halfH[272]; \
508 uint8_t halfHV[256]; \
509 \
510 copy_block17(full, src, 24, stride, 17); \
511 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
512 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
513 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
514 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
515 } \
516 \
517 void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, const uint8_t *src, \
518 ptrdiff_t stride) \
519 { \
520 uint8_t full[24 * 17]; \
521 uint8_t halfH[272]; \
522 uint8_t halfV[256]; \
523 uint8_t halfHV[256]; \
524 \
525 copy_block17(full, src, 24, stride, 17); \
526 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
527 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
528 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
529 OPNAME ## pixels16_l4_8(dst, full + 1, halfH, halfV, halfHV, \
530 stride, 24, 16, 16, 16, 16); \
531 } \
532 \
533 static void OPNAME ## qpel16_mc31_c(uint8_t *dst, const uint8_t *src, \
534 ptrdiff_t stride) \
535 { \
536 uint8_t full[24 * 17]; \
537 uint8_t halfH[272]; \
538 uint8_t halfHV[256]; \
539 \
540 copy_block17(full, src, 24, stride, 17); \
541 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
542 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
543 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
544 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
545 } \
546 \
547 void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, const uint8_t *src, \
548 ptrdiff_t stride) \
549 { \
550 uint8_t full[24 * 17]; \
551 uint8_t halfH[272]; \
552 uint8_t halfV[256]; \
553 uint8_t halfHV[256]; \
554 \
555 copy_block17(full, src, 24, stride, 17); \
556 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
557 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
558 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
559 OPNAME ## pixels16_l4_8(dst, full + 24, halfH + 16, halfV, halfHV, \
560 stride, 24, 16, 16, 16, 16); \
561 } \
562 \
563 static void OPNAME ## qpel16_mc13_c(uint8_t *dst, const uint8_t *src, \
564 ptrdiff_t stride) \
565 { \
566 uint8_t full[24 * 17]; \
567 uint8_t halfH[272]; \
568 uint8_t halfHV[256]; \
569 \
570 copy_block17(full, src, 24, stride, 17); \
571 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
572 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
573 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
574 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
575 } \
576 \
577 void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, const uint8_t *src, \
578 ptrdiff_t stride) \
579 { \
580 uint8_t full[24 * 17]; \
581 uint8_t halfH[272]; \
582 uint8_t halfV[256]; \
583 uint8_t halfHV[256]; \
584 \
585 copy_block17(full, src, 24, stride, 17); \
586 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
587 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
588 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
589 OPNAME ## pixels16_l4_8(dst, full + 25, halfH + 16, halfV, halfHV, \
590 stride, 24, 16, 16, 16, 16); \
591 } \
592 \
593 static void OPNAME ## qpel16_mc33_c(uint8_t *dst, const uint8_t *src, \
594 ptrdiff_t stride) \
595 { \
596 uint8_t full[24 * 17]; \
597 uint8_t halfH[272]; \
598 uint8_t halfHV[256]; \
599 \
600 copy_block17(full, src, 24, stride, 17); \
601 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
602 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
603 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
604 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
605 } \
606 \
607 static void OPNAME ## qpel16_mc21_c(uint8_t *dst, const uint8_t *src, \
608 ptrdiff_t stride) \
609 { \
610 uint8_t halfH[272]; \
611 uint8_t halfHV[256]; \
612 \
613 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
614 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
615 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
616 } \
617 \
618 static void OPNAME ## qpel16_mc23_c(uint8_t *dst, const uint8_t *src, \
619 ptrdiff_t stride) \
620 { \
621 uint8_t halfH[272]; \
622 uint8_t halfHV[256]; \
623 \
624 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
625 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
626 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
627 } \
628 \
629 void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, const uint8_t *src, \
630 ptrdiff_t stride) \
631 { \
632 uint8_t full[24 * 17]; \
633 uint8_t halfH[272]; \
634 uint8_t halfV[256]; \
635 uint8_t halfHV[256]; \
636 \
637 copy_block17(full, src, 24, stride, 17); \
638 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
639 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
640 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
641 OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16); \
642 } \
643 \
644 static void OPNAME ## qpel16_mc12_c(uint8_t *dst, const uint8_t *src, \
645 ptrdiff_t stride) \
646 { \
647 uint8_t full[24 * 17]; \
648 uint8_t halfH[272]; \
649 \
650 copy_block17(full, src, 24, stride, 17); \
651 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
652 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
653 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
654 } \
655 \
656 void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, const uint8_t *src, \
657 ptrdiff_t stride) \
658 { \
659 uint8_t full[24 * 17]; \
660 uint8_t halfH[272]; \
661 uint8_t halfV[256]; \
662 uint8_t halfHV[256]; \
663 \
664 copy_block17(full, src, 24, stride, 17); \
665 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
666 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
667 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
668 OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16); \
669 } \
670 \
671 static void OPNAME ## qpel16_mc32_c(uint8_t *dst, const uint8_t *src, \
672 ptrdiff_t stride) \
673 { \
674 uint8_t full[24 * 17]; \
675 uint8_t halfH[272]; \
676 \
677 copy_block17(full, src, 24, stride, 17); \
678 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
679 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
680 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
681 } \
682 \
683 static void OPNAME ## qpel16_mc22_c(uint8_t *dst, const uint8_t *src, \
684 ptrdiff_t stride) \
685 { \
686 uint8_t halfH[272]; \
687 \
688 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
689 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
690 }
691
692 #define op_avg(a, b) a = (((a) + cm[((b) + 16) >> 5] + 1) >> 1)
693 #define op_put(a, b) a = cm[((b) + 16) >> 5]
694 #define op_put_no_rnd(a, b) a = cm[((b) + 15) >> 5]
695
696
2/2
✓ Branch 0 taken 71434315 times.
✓ Branch 1 taken 6395017 times.
159776342 QPEL_MC(0, put_, _, op_put)
697
2/2
✓ Branch 0 taken 30174571 times.
✓ Branch 1 taken 2964571 times.
35013062 QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
698
2/2
✓ Branch 0 taken 8610880 times.
✓ Branch 1 taken 910408 times.
12107255 QPEL_MC(0, avg_, _, op_avg)
699
700 #undef op_avg
701 #undef op_put
702 #undef op_put_no_rnd
703
704 1825743 void ff_put_pixels8x8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
705 {
706 1825743 put_pixels8_8_c(dst, src, stride, 8);
707 1825743 }
708
709 1469531 void ff_avg_pixels8x8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
710 {
711 1469531 avg_pixels8_8_c(dst, src, stride, 8);
712 1469531 }
713
714 268806 void ff_put_pixels16x16_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
715 {
716 268806 put_pixels16_8_c(dst, src, stride, 16);
717 268806 }
718
719 97181 void ff_avg_pixels16x16_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
720 {
721 97181 avg_pixels16_8_c(dst, src, stride, 16);
722 97181 }
723
724 #define put_qpel8_mc00_c ff_put_pixels8x8_c
725 #define avg_qpel8_mc00_c ff_avg_pixels8x8_c
726 #define put_qpel16_mc00_c ff_put_pixels16x16_c
727 #define avg_qpel16_mc00_c ff_avg_pixels16x16_c
728 #define put_no_rnd_qpel8_mc00_c ff_put_pixels8x8_c
729 #define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
730
731 33272 void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
732 int dst_stride, int src_stride1, int src_stride2,
733 int h)
734 {
735 33272 put_pixels8_l2_8(dst, src1, src2, dst_stride, src_stride1, src_stride2, h);
736
737 33272 }
738
739 #if CONFIG_DIRAC_DECODER
740 #define DIRAC_MC(OPNAME)\
741 void ff_ ## OPNAME ## _dirac_pixels8_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
742 {\
743 OPNAME ## _pixels8_8_c(dst, src[0], stride, h);\
744 }\
745 void ff_ ## OPNAME ## _dirac_pixels16_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
746 {\
747 OPNAME ## _pixels16_8_c(dst, src[0], stride, h);\
748 }\
749 void ff_ ## OPNAME ## _dirac_pixels32_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
750 {\
751 OPNAME ## _pixels16_8_c(dst , src[0] , stride, h);\
752 OPNAME ## _pixels16_8_c(dst+16, src[0]+16, stride, h);\
753 }\
754 void ff_ ## OPNAME ## _dirac_pixels8_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
755 {\
756 OPNAME ## _pixels8_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
757 }\
758 void ff_ ## OPNAME ## _dirac_pixels16_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
759 {\
760 OPNAME ## _pixels16_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
761 }\
762 void ff_ ## OPNAME ## _dirac_pixels32_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
763 {\
764 OPNAME ## _pixels16_l2_8(dst , src[0] , src[1] , stride, stride, stride, h);\
765 OPNAME ## _pixels16_l2_8(dst+16, src[0]+16, src[1]+16, stride, stride, stride, h);\
766 }\
767 void ff_ ## OPNAME ## _dirac_pixels8_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
768 {\
769 OPNAME ## _pixels8_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
770 }\
771 void ff_ ## OPNAME ## _dirac_pixels16_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
772 {\
773 OPNAME ## _pixels16_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
774 }\
775 void ff_ ## OPNAME ## _dirac_pixels32_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
776 {\
777 OPNAME ## _pixels16_l4_8(dst , src[0] , src[1] , src[2] , src[3] , stride, stride, stride, stride, stride, h);\
778 OPNAME ## _pixels16_l4_8(dst+16, src[0]+16, src[1]+16, src[2]+16, src[3]+16, stride, stride, stride, stride, stride, h);\
779 }
780 211236 DIRAC_MC(put)
781 93834 DIRAC_MC(avg)
782 #endif
783
784 505 av_cold void ff_qpeldsp_init(QpelDSPContext *c)
785 {
786 #define dspfunc(PFX, IDX, NUM) \
787 c->PFX ## _pixels_tab[IDX][0] = PFX ## NUM ## _mc00_c; \
788 c->PFX ## _pixels_tab[IDX][1] = PFX ## NUM ## _mc10_c; \
789 c->PFX ## _pixels_tab[IDX][2] = PFX ## NUM ## _mc20_c; \
790 c->PFX ## _pixels_tab[IDX][3] = PFX ## NUM ## _mc30_c; \
791 c->PFX ## _pixels_tab[IDX][4] = PFX ## NUM ## _mc01_c; \
792 c->PFX ## _pixels_tab[IDX][5] = PFX ## NUM ## _mc11_c; \
793 c->PFX ## _pixels_tab[IDX][6] = PFX ## NUM ## _mc21_c; \
794 c->PFX ## _pixels_tab[IDX][7] = PFX ## NUM ## _mc31_c; \
795 c->PFX ## _pixels_tab[IDX][8] = PFX ## NUM ## _mc02_c; \
796 c->PFX ## _pixels_tab[IDX][9] = PFX ## NUM ## _mc12_c; \
797 c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
798 c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
799 c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
800 c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
801 c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
802 c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
803
804 505 dspfunc(put_qpel, 0, 16);
805 505 dspfunc(put_qpel, 1, 8);
806
807 505 dspfunc(put_no_rnd_qpel, 0, 16);
808 505 dspfunc(put_no_rnd_qpel, 1, 8);
809
810 505 dspfunc(avg_qpel, 0, 16);
811 505 dspfunc(avg_qpel, 1, 8);
812
813 #if ARCH_X86
814 505 ff_qpeldsp_init_x86(c);
815 #elif ARCH_MIPS
816 ff_qpeldsp_init_mips(c);
817 #endif
818 505 }
819