2 * quarterpel DSP functions
3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 * This file is part of FFmpeg.
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.
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.
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
25 * quarterpel DSP functions
32 #include "libavutil/attributes.h"
33 #include "copy_block.h"
38 #include "hpel_template.c"
39 #include "pel_template.c"
40 #include "qpel_template.c"
42 #define QPEL_MC(r, OPNAME, RND, OP) \
43 static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, const uint8_t *src, \
44 int dstStride, int srcStride, \
47 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
50 for (i = 0; i < h; i++) { \
51 OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
52 OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
53 OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
54 OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
55 OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
56 OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[8])); \
57 OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[8]) * 3 - (src[3] + src[7])); \
58 OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[8]) * 6 + (src[5] + src[7]) * 3 - (src[4] + src[6])); \
64 static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, const uint8_t *src, \
65 int dstStride, int srcStride) \
67 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
71 for (i = 0; i < w; i++) { \
72 const int src0 = src[0 * srcStride]; \
73 const int src1 = src[1 * srcStride]; \
74 const int src2 = src[2 * srcStride]; \
75 const int src3 = src[3 * srcStride]; \
76 const int src4 = src[4 * srcStride]; \
77 const int src5 = src[5 * srcStride]; \
78 const int src6 = src[6 * srcStride]; \
79 const int src7 = src[7 * srcStride]; \
80 const int src8 = src[8 * srcStride]; \
81 OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
82 OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
83 OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
84 OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
85 OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
86 OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src8)); \
87 OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src8) * 3 - (src3 + src7)); \
88 OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src8) * 6 + (src5 + src7) * 3 - (src4 + src6)); \
94 static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, \
96 int dstStride, int srcStride, \
99 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
102 for (i = 0; i < h; i++) { \
103 OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
104 OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
105 OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
106 OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
107 OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
108 OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[9])); \
109 OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[9]) * 3 - (src[3] + src[10])); \
110 OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[9]) * 6 + (src[5] + src[10]) * 3 - (src[4] + src[11])); \
111 OP(dst[8], (src[8] + src[9]) * 20 - (src[7] + src[10]) * 6 + (src[6] + src[11]) * 3 - (src[5] + src[12])); \
112 OP(dst[9], (src[9] + src[10]) * 20 - (src[8] + src[11]) * 6 + (src[7] + src[12]) * 3 - (src[6] + src[13])); \
113 OP(dst[10], (src[10] + src[11]) * 20 - (src[9] + src[12]) * 6 + (src[8] + src[13]) * 3 - (src[7] + src[14])); \
114 OP(dst[11], (src[11] + src[12]) * 20 - (src[10] + src[13]) * 6 + (src[9] + src[14]) * 3 - (src[8] + src[15])); \
115 OP(dst[12], (src[12] + src[13]) * 20 - (src[11] + src[14]) * 6 + (src[10] + src[15]) * 3 - (src[9] + src[16])); \
116 OP(dst[13], (src[13] + src[14]) * 20 - (src[12] + src[15]) * 6 + (src[11] + src[16]) * 3 - (src[10] + src[16])); \
117 OP(dst[14], (src[14] + src[15]) * 20 - (src[13] + src[16]) * 6 + (src[12] + src[16]) * 3 - (src[11] + src[15])); \
118 OP(dst[15], (src[15] + src[16]) * 20 - (src[14] + src[16]) * 6 + (src[13] + src[15]) * 3 - (src[12] + src[14])); \
124 static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, \
125 const uint8_t *src, \
126 int dstStride, int srcStride) \
128 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
132 for (i = 0; i < w; i++) { \
133 const int src0 = src[0 * srcStride]; \
134 const int src1 = src[1 * srcStride]; \
135 const int src2 = src[2 * srcStride]; \
136 const int src3 = src[3 * srcStride]; \
137 const int src4 = src[4 * srcStride]; \
138 const int src5 = src[5 * srcStride]; \
139 const int src6 = src[6 * srcStride]; \
140 const int src7 = src[7 * srcStride]; \
141 const int src8 = src[8 * srcStride]; \
142 const int src9 = src[9 * srcStride]; \
143 const int src10 = src[10 * srcStride]; \
144 const int src11 = src[11 * srcStride]; \
145 const int src12 = src[12 * srcStride]; \
146 const int src13 = src[13 * srcStride]; \
147 const int src14 = src[14 * srcStride]; \
148 const int src15 = src[15 * srcStride]; \
149 const int src16 = src[16 * srcStride]; \
150 OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
151 OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
152 OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
153 OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
154 OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
155 OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src9)); \
156 OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src9) * 3 - (src3 + src10)); \
157 OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src9) * 6 + (src5 + src10) * 3 - (src4 + src11)); \
158 OP(dst[8 * dstStride], (src8 + src9) * 20 - (src7 + src10) * 6 + (src6 + src11) * 3 - (src5 + src12)); \
159 OP(dst[9 * dstStride], (src9 + src10) * 20 - (src8 + src11) * 6 + (src7 + src12) * 3 - (src6 + src13)); \
160 OP(dst[10 * dstStride], (src10 + src11) * 20 - (src9 + src12) * 6 + (src8 + src13) * 3 - (src7 + src14)); \
161 OP(dst[11 * dstStride], (src11 + src12) * 20 - (src10 + src13) * 6 + (src9 + src14) * 3 - (src8 + src15)); \
162 OP(dst[12 * dstStride], (src12 + src13) * 20 - (src11 + src14) * 6 + (src10 + src15) * 3 - (src9 + src16)); \
163 OP(dst[13 * dstStride], (src13 + src14) * 20 - (src12 + src15) * 6 + (src11 + src16) * 3 - (src10 + src16)); \
164 OP(dst[14 * dstStride], (src14 + src15) * 20 - (src13 + src16) * 6 + (src12 + src16) * 3 - (src11 + src15)); \
165 OP(dst[15 * dstStride], (src15 + src16) * 20 - (src14 + src16) * 6 + (src13 + src15) * 3 - (src12 + src14)); \
171 static void OPNAME ## qpel8_mc10_c(uint8_t *dst, const uint8_t *src, \
176 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
177 OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8); \
180 static void OPNAME ## qpel8_mc20_c(uint8_t *dst, const uint8_t *src, \
183 OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8); \
186 static void OPNAME ## qpel8_mc30_c(uint8_t *dst, const uint8_t *src, \
191 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
192 OPNAME ## pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8); \
195 static void OPNAME ## qpel8_mc01_c(uint8_t *dst, const uint8_t *src, \
198 uint8_t full[16 * 9]; \
201 copy_block9(full, src, 16, stride, 9); \
202 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
203 OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8); \
206 static void OPNAME ## qpel8_mc02_c(uint8_t *dst, const uint8_t *src, \
209 uint8_t full[16 * 9]; \
211 copy_block9(full, src, 16, stride, 9); \
212 OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \
215 static void OPNAME ## qpel8_mc03_c(uint8_t *dst, const uint8_t *src, \
218 uint8_t full[16 * 9]; \
221 copy_block9(full, src, 16, stride, 9); \
222 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16); \
223 OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8); \
226 void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, const uint8_t *src, \
229 uint8_t full[16 * 9]; \
232 uint8_t halfHV[64]; \
234 copy_block9(full, src, 16, stride, 9); \
235 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
236 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
237 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
238 OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV, \
239 stride, 16, 8, 8, 8, 8); \
242 static void OPNAME ## qpel8_mc11_c(uint8_t *dst, const uint8_t *src, \
245 uint8_t full[16 * 9]; \
247 uint8_t halfHV[64]; \
249 copy_block9(full, src, 16, stride, 9); \
250 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
251 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
252 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
253 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
256 void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, const uint8_t *src, \
259 uint8_t full[16 * 9]; \
262 uint8_t halfHV[64]; \
264 copy_block9(full, src, 16, stride, 9); \
265 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
266 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
267 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
268 OPNAME ## pixels8_l4_8(dst, full + 1, halfH, halfV, halfHV, \
269 stride, 16, 8, 8, 8, 8); \
272 static void OPNAME ## qpel8_mc31_c(uint8_t *dst, const uint8_t *src, \
275 uint8_t full[16 * 9]; \
277 uint8_t halfHV[64]; \
279 copy_block9(full, src, 16, stride, 9); \
280 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
281 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
282 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
283 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
286 void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, const uint8_t *src, \
289 uint8_t full[16 * 9]; \
292 uint8_t halfHV[64]; \
294 copy_block9(full, src, 16, stride, 9); \
295 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
296 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
297 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
298 OPNAME ## pixels8_l4_8(dst, full + 16, halfH + 8, halfV, halfHV, \
299 stride, 16, 8, 8, 8, 8); \
302 static void OPNAME ## qpel8_mc13_c(uint8_t *dst, const uint8_t *src, \
305 uint8_t full[16 * 9]; \
307 uint8_t halfHV[64]; \
309 copy_block9(full, src, 16, stride, 9); \
310 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
311 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
312 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
313 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
316 void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, const uint8_t *src, \
319 uint8_t full[16 * 9]; \
322 uint8_t halfHV[64]; \
324 copy_block9(full, src, 16, stride, 9); \
325 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
326 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
327 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
328 OPNAME ## pixels8_l4_8(dst, full + 17, halfH + 8, halfV, halfHV, \
329 stride, 16, 8, 8, 8, 8); \
332 static void OPNAME ## qpel8_mc33_c(uint8_t *dst, const uint8_t *src, \
335 uint8_t full[16 * 9]; \
337 uint8_t halfHV[64]; \
339 copy_block9(full, src, 16, stride, 9); \
340 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
341 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
342 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
343 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
346 static void OPNAME ## qpel8_mc21_c(uint8_t *dst, const uint8_t *src, \
350 uint8_t halfHV[64]; \
352 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
353 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
354 OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8); \
357 static void OPNAME ## qpel8_mc23_c(uint8_t *dst, const uint8_t *src, \
361 uint8_t halfHV[64]; \
363 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
364 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
365 OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8); \
368 void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, const uint8_t *src, \
371 uint8_t full[16 * 9]; \
374 uint8_t halfHV[64]; \
376 copy_block9(full, src, 16, stride, 9); \
377 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
378 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16); \
379 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
380 OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); \
383 static void OPNAME ## qpel8_mc12_c(uint8_t *dst, const uint8_t *src, \
386 uint8_t full[16 * 9]; \
389 copy_block9(full, src, 16, stride, 9); \
390 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
391 put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9); \
392 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
395 void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, const uint8_t *src, \
398 uint8_t full[16 * 9]; \
401 uint8_t halfHV[64]; \
403 copy_block9(full, src, 16, stride, 9); \
404 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
405 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16); \
406 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8); \
407 OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8); \
410 static void OPNAME ## qpel8_mc32_c(uint8_t *dst, const uint8_t *src, \
413 uint8_t full[16 * 9]; \
416 copy_block9(full, src, 16, stride, 9); \
417 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9); \
418 put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9); \
419 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
422 static void OPNAME ## qpel8_mc22_c(uint8_t *dst, const uint8_t *src, \
427 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
428 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
431 static void OPNAME ## qpel16_mc10_c(uint8_t *dst, const uint8_t *src, \
436 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
437 OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16); \
440 static void OPNAME ## qpel16_mc20_c(uint8_t *dst, const uint8_t *src, \
443 OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16); \
446 static void OPNAME ## qpel16_mc30_c(uint8_t *dst, const uint8_t *src, \
451 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
452 OPNAME ## pixels16_l2_8(dst, src + 1, half, stride, stride, 16, 16); \
455 static void OPNAME ## qpel16_mc01_c(uint8_t *dst, const uint8_t *src, \
458 uint8_t full[24 * 17]; \
461 copy_block17(full, src, 24, stride, 17); \
462 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
463 OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16); \
466 static void OPNAME ## qpel16_mc02_c(uint8_t *dst, const uint8_t *src, \
469 uint8_t full[24 * 17]; \
471 copy_block17(full, src, 24, stride, 17); \
472 OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \
475 static void OPNAME ## qpel16_mc03_c(uint8_t *dst, const uint8_t *src, \
478 uint8_t full[24 * 17]; \
481 copy_block17(full, src, 24, stride, 17); \
482 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24); \
483 OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16); \
486 void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, const uint8_t *src, \
489 uint8_t full[24 * 17]; \
490 uint8_t halfH[272]; \
491 uint8_t halfV[256]; \
492 uint8_t halfHV[256]; \
494 copy_block17(full, src, 24, stride, 17); \
495 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
496 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
497 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
498 OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV, \
499 stride, 24, 16, 16, 16, 16); \
502 static void OPNAME ## qpel16_mc11_c(uint8_t *dst, const uint8_t *src, \
505 uint8_t full[24 * 17]; \
506 uint8_t halfH[272]; \
507 uint8_t halfHV[256]; \
509 copy_block17(full, src, 24, stride, 17); \
510 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
511 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
512 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
513 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
516 void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, const uint8_t *src, \
519 uint8_t full[24 * 17]; \
520 uint8_t halfH[272]; \
521 uint8_t halfV[256]; \
522 uint8_t halfHV[256]; \
524 copy_block17(full, src, 24, stride, 17); \
525 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
526 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
527 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
528 OPNAME ## pixels16_l4_8(dst, full + 1, halfH, halfV, halfHV, \
529 stride, 24, 16, 16, 16, 16); \
532 static void OPNAME ## qpel16_mc31_c(uint8_t *dst, const uint8_t *src, \
535 uint8_t full[24 * 17]; \
536 uint8_t halfH[272]; \
537 uint8_t halfHV[256]; \
539 copy_block17(full, src, 24, stride, 17); \
540 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
541 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
542 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
543 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
546 void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, const uint8_t *src, \
549 uint8_t full[24 * 17]; \
550 uint8_t halfH[272]; \
551 uint8_t halfV[256]; \
552 uint8_t halfHV[256]; \
554 copy_block17(full, src, 24, stride, 17); \
555 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
556 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
557 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
558 OPNAME ## pixels16_l4_8(dst, full + 24, halfH + 16, halfV, halfHV, \
559 stride, 24, 16, 16, 16, 16); \
562 static void OPNAME ## qpel16_mc13_c(uint8_t *dst, const uint8_t *src, \
565 uint8_t full[24 * 17]; \
566 uint8_t halfH[272]; \
567 uint8_t halfHV[256]; \
569 copy_block17(full, src, 24, stride, 17); \
570 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
571 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
572 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
573 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
576 void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, const uint8_t *src, \
579 uint8_t full[24 * 17]; \
580 uint8_t halfH[272]; \
581 uint8_t halfV[256]; \
582 uint8_t halfHV[256]; \
584 copy_block17(full, src, 24, stride, 17); \
585 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
586 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
587 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
588 OPNAME ## pixels16_l4_8(dst, full + 25, halfH + 16, halfV, halfHV, \
589 stride, 24, 16, 16, 16, 16); \
592 static void OPNAME ## qpel16_mc33_c(uint8_t *dst, const uint8_t *src, \
595 uint8_t full[24 * 17]; \
596 uint8_t halfH[272]; \
597 uint8_t halfHV[256]; \
599 copy_block17(full, src, 24, stride, 17); \
600 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
601 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
602 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
603 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
606 static void OPNAME ## qpel16_mc21_c(uint8_t *dst, const uint8_t *src, \
609 uint8_t halfH[272]; \
610 uint8_t halfHV[256]; \
612 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
613 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
614 OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16); \
617 static void OPNAME ## qpel16_mc23_c(uint8_t *dst, const uint8_t *src, \
620 uint8_t halfH[272]; \
621 uint8_t halfHV[256]; \
623 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
624 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
625 OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16); \
628 void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, const uint8_t *src, \
631 uint8_t full[24 * 17]; \
632 uint8_t halfH[272]; \
633 uint8_t halfV[256]; \
634 uint8_t halfHV[256]; \
636 copy_block17(full, src, 24, stride, 17); \
637 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
638 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24); \
639 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
640 OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16); \
643 static void OPNAME ## qpel16_mc12_c(uint8_t *dst, const uint8_t *src, \
646 uint8_t full[24 * 17]; \
647 uint8_t halfH[272]; \
649 copy_block17(full, src, 24, stride, 17); \
650 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
651 put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17); \
652 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
655 void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, const uint8_t *src, \
658 uint8_t full[24 * 17]; \
659 uint8_t halfH[272]; \
660 uint8_t halfV[256]; \
661 uint8_t halfHV[256]; \
663 copy_block17(full, src, 24, stride, 17); \
664 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
665 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24); \
666 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16); \
667 OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16); \
670 static void OPNAME ## qpel16_mc32_c(uint8_t *dst, const uint8_t *src, \
673 uint8_t full[24 * 17]; \
674 uint8_t halfH[272]; \
676 copy_block17(full, src, 24, stride, 17); \
677 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17); \
678 put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17); \
679 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
682 static void OPNAME ## qpel16_mc22_c(uint8_t *dst, const uint8_t *src, \
685 uint8_t halfH[272]; \
687 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
688 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
691 #define op_avg(a, b) a = (((a) + cm[((b) + 16) >> 5] + 1) >> 1)
692 #define op_put(a, b) a = cm[((b) + 16) >> 5]
693 #define op_put_no_rnd(a, b) a = cm[((b) + 15) >> 5]
695 QPEL_MC(0, put_, _, op_put)
696 QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
697 QPEL_MC(0, avg_, _, op_avg)
703 void ff_put_pixels8x8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
705 put_pixels8_8_c(dst, src, stride, 8);
708 void ff_avg_pixels8x8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
710 avg_pixels8_8_c(dst, src, stride, 8);
713 void ff_put_pixels16x16_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
715 put_pixels16_8_c(dst, src, stride, 16);
718 void ff_avg_pixels16x16_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
720 avg_pixels16_8_c(dst, src, stride, 16);
723 #define put_qpel8_mc00_c ff_put_pixels8x8_c
724 #define avg_qpel8_mc00_c ff_avg_pixels8x8_c
725 #define put_qpel16_mc00_c ff_put_pixels16x16_c
726 #define avg_qpel16_mc00_c ff_avg_pixels16x16_c
727 #define put_no_rnd_qpel8_mc00_c ff_put_pixels8x8_c
728 #define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
730 void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
731 int dst_stride, int src_stride1, int src_stride2,
734 put_pixels8_l2_8(dst, src1, src2, dst_stride, src_stride1, src_stride2, h);
738 #if CONFIG_DIRAC_DECODER
739 #define DIRAC_MC(OPNAME)\
740 void ff_ ## OPNAME ## _dirac_pixels8_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
742 OPNAME ## _pixels8_8_c(dst, src[0], stride, h);\
744 void ff_ ## OPNAME ## _dirac_pixels16_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
746 OPNAME ## _pixels16_8_c(dst, src[0], stride, h);\
748 void ff_ ## OPNAME ## _dirac_pixels32_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
750 OPNAME ## _pixels16_8_c(dst , src[0] , stride, h);\
751 OPNAME ## _pixels16_8_c(dst+16, src[0]+16, stride, h);\
753 void ff_ ## OPNAME ## _dirac_pixels8_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
755 OPNAME ## _pixels8_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
757 void ff_ ## OPNAME ## _dirac_pixels16_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
759 OPNAME ## _pixels16_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
761 void ff_ ## OPNAME ## _dirac_pixels32_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
763 OPNAME ## _pixels16_l2_8(dst , src[0] , src[1] , stride, stride, stride, h);\
764 OPNAME ## _pixels16_l2_8(dst+16, src[0]+16, src[1]+16, stride, stride, stride, h);\
766 void ff_ ## OPNAME ## _dirac_pixels8_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
768 OPNAME ## _pixels8_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
770 void ff_ ## OPNAME ## _dirac_pixels16_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
772 OPNAME ## _pixels16_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
774 void ff_ ## OPNAME ## _dirac_pixels32_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
776 OPNAME ## _pixels16_l4_8(dst , src[0] , src[1] , src[2] , src[3] , stride, stride, stride, stride, stride, h);\
777 OPNAME ## _pixels16_l4_8(dst+16, src[0]+16, src[1]+16, src[2]+16, src[3]+16, stride, stride, stride, stride, stride, h);\
783 av_cold void ff_qpeldsp_init(QpelDSPContext *c)
785 #define dspfunc(PFX, IDX, NUM) \
786 c->PFX ## _pixels_tab[IDX][0] = PFX ## NUM ## _mc00_c; \
787 c->PFX ## _pixels_tab[IDX][1] = PFX ## NUM ## _mc10_c; \
788 c->PFX ## _pixels_tab[IDX][2] = PFX ## NUM ## _mc20_c; \
789 c->PFX ## _pixels_tab[IDX][3] = PFX ## NUM ## _mc30_c; \
790 c->PFX ## _pixels_tab[IDX][4] = PFX ## NUM ## _mc01_c; \
791 c->PFX ## _pixels_tab[IDX][5] = PFX ## NUM ## _mc11_c; \
792 c->PFX ## _pixels_tab[IDX][6] = PFX ## NUM ## _mc21_c; \
793 c->PFX ## _pixels_tab[IDX][7] = PFX ## NUM ## _mc31_c; \
794 c->PFX ## _pixels_tab[IDX][8] = PFX ## NUM ## _mc02_c; \
795 c->PFX ## _pixels_tab[IDX][9] = PFX ## NUM ## _mc12_c; \
796 c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
797 c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
798 c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
799 c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
800 c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
801 c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
803 dspfunc(put_qpel, 0, 16);
804 dspfunc(put_qpel, 1, 8);
806 dspfunc(put_no_rnd_qpel, 0, 16);
807 dspfunc(put_no_rnd_qpel, 1, 8);
809 dspfunc(avg_qpel, 0, 16);
810 dspfunc(avg_qpel, 1, 8);
813 ff_qpeldsp_init_x86(c);
815 ff_qpeldsp_init_mips(c);