FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qpeldsp.c
Go to the documentation of this file.
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 "libavutil/attributes.h"
33 #include "copy_block.h"
34 #include "qpeldsp.h"
35 #include "diracdsp.h"
36 
37 #define BIT_DEPTH 8
38 #include "hpel_template.c"
39 #include "pel_template.c"
40 #include "qpel_template.c"
41 
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, \
45  int h) \
46 { \
47  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
48  int i; \
49  \
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])); \
59  dst += dstStride; \
60  src += srcStride; \
61  } \
62 } \
63  \
64 static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, const uint8_t *src, \
65  int dstStride, int srcStride) \
66 { \
67  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
68  const int w = 8; \
69  int i; \
70  \
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)); \
89  dst++; \
90  src++; \
91  } \
92 } \
93  \
94 static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, \
95  const uint8_t *src, \
96  int dstStride, int srcStride, \
97  int h) \
98 { \
99  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
100  int i; \
101  \
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])); \
119  dst += dstStride; \
120  src += srcStride; \
121  } \
122 } \
123  \
124 static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, \
125  const uint8_t *src, \
126  int dstStride, int srcStride) \
127 { \
128  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
129  const int w = 16; \
130  int i; \
131  \
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)); \
166  dst++; \
167  src++; \
168  } \
169 } \
170  \
171 static void OPNAME ## qpel8_mc10_c(uint8_t *dst, const uint8_t *src, \
172  ptrdiff_t stride) \
173 { \
174  uint8_t half[64]; \
175  \
176  put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8); \
177  OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8); \
178 } \
179  \
180 static void OPNAME ## qpel8_mc20_c(uint8_t *dst, const uint8_t *src, \
181  ptrdiff_t stride) \
182 { \
183  OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8); \
184 } \
185  \
186 static void OPNAME ## qpel8_mc30_c(uint8_t *dst, const uint8_t *src, \
187  ptrdiff_t stride) \
188 { \
189  uint8_t half[64]; \
190  \
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); \
193 } \
194  \
195 static void OPNAME ## qpel8_mc01_c(uint8_t *dst, const uint8_t *src, \
196  ptrdiff_t stride) \
197 { \
198  uint8_t full[16 * 9]; \
199  uint8_t half[64]; \
200  \
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); \
204 } \
205  \
206 static void OPNAME ## qpel8_mc02_c(uint8_t *dst, const uint8_t *src, \
207  ptrdiff_t stride) \
208 { \
209  uint8_t full[16 * 9]; \
210  \
211  copy_block9(full, src, 16, stride, 9); \
212  OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16); \
213 } \
214  \
215 static void OPNAME ## qpel8_mc03_c(uint8_t *dst, const uint8_t *src, \
216  ptrdiff_t stride) \
217 { \
218  uint8_t full[16 * 9]; \
219  uint8_t half[64]; \
220  \
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); \
224 } \
225  \
226 void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, const uint8_t *src, \
227  ptrdiff_t stride) \
228 { \
229  uint8_t full[16 * 9]; \
230  uint8_t halfH[72]; \
231  uint8_t halfV[64]; \
232  uint8_t halfHV[64]; \
233  \
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); \
240 } \
241  \
242 static void OPNAME ## qpel8_mc11_c(uint8_t *dst, const uint8_t *src, \
243  ptrdiff_t stride) \
244 { \
245  uint8_t full[16 * 9]; \
246  uint8_t halfH[72]; \
247  uint8_t halfHV[64]; \
248  \
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); \
254 } \
255  \
256 void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, const uint8_t *src, \
257  ptrdiff_t stride) \
258 { \
259  uint8_t full[16 * 9]; \
260  uint8_t halfH[72]; \
261  uint8_t halfV[64]; \
262  uint8_t halfHV[64]; \
263  \
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); \
270 } \
271  \
272 static void OPNAME ## qpel8_mc31_c(uint8_t *dst, const uint8_t *src, \
273  ptrdiff_t stride) \
274 { \
275  uint8_t full[16 * 9]; \
276  uint8_t halfH[72]; \
277  uint8_t halfHV[64]; \
278  \
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); \
284 } \
285  \
286 void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, const uint8_t *src, \
287  ptrdiff_t stride) \
288 { \
289  uint8_t full[16 * 9]; \
290  uint8_t halfH[72]; \
291  uint8_t halfV[64]; \
292  uint8_t halfHV[64]; \
293  \
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); \
300 } \
301  \
302 static void OPNAME ## qpel8_mc13_c(uint8_t *dst, const uint8_t *src, \
303  ptrdiff_t stride) \
304 { \
305  uint8_t full[16 * 9]; \
306  uint8_t halfH[72]; \
307  uint8_t halfHV[64]; \
308  \
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); \
314 } \
315  \
316 void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, const uint8_t *src, \
317  ptrdiff_t stride) \
318 { \
319  uint8_t full[16 * 9]; \
320  uint8_t halfH[72]; \
321  uint8_t halfV[64]; \
322  uint8_t halfHV[64]; \
323  \
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); \
330 } \
331  \
332 static void OPNAME ## qpel8_mc33_c(uint8_t *dst, const uint8_t *src, \
333  ptrdiff_t stride) \
334 { \
335  uint8_t full[16 * 9]; \
336  uint8_t halfH[72]; \
337  uint8_t halfHV[64]; \
338  \
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); \
344 } \
345  \
346 static void OPNAME ## qpel8_mc21_c(uint8_t *dst, const uint8_t *src, \
347  ptrdiff_t stride) \
348 { \
349  uint8_t halfH[72]; \
350  uint8_t halfHV[64]; \
351  \
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); \
355 } \
356  \
357 static void OPNAME ## qpel8_mc23_c(uint8_t *dst, const uint8_t *src, \
358  ptrdiff_t stride) \
359 { \
360  uint8_t halfH[72]; \
361  uint8_t halfHV[64]; \
362  \
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); \
366 } \
367  \
368 void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, const uint8_t *src, \
369  ptrdiff_t stride) \
370 { \
371  uint8_t full[16 * 9]; \
372  uint8_t halfH[72]; \
373  uint8_t halfV[64]; \
374  uint8_t halfHV[64]; \
375  \
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); \
381 } \
382  \
383 static void OPNAME ## qpel8_mc12_c(uint8_t *dst, const uint8_t *src, \
384  ptrdiff_t stride) \
385 { \
386  uint8_t full[16 * 9]; \
387  uint8_t halfH[72]; \
388  \
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); \
393 } \
394  \
395 void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, const uint8_t *src, \
396  ptrdiff_t stride) \
397 { \
398  uint8_t full[16 * 9]; \
399  uint8_t halfH[72]; \
400  uint8_t halfV[64]; \
401  uint8_t halfHV[64]; \
402  \
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); \
408 } \
409  \
410 static void OPNAME ## qpel8_mc32_c(uint8_t *dst, const uint8_t *src, \
411  ptrdiff_t stride) \
412 { \
413  uint8_t full[16 * 9]; \
414  uint8_t halfH[72]; \
415  \
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); \
420 } \
421  \
422 static void OPNAME ## qpel8_mc22_c(uint8_t *dst, const uint8_t *src, \
423  ptrdiff_t stride) \
424 { \
425  uint8_t halfH[72]; \
426  \
427  put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9); \
428  OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8); \
429 } \
430  \
431 static void OPNAME ## qpel16_mc10_c(uint8_t *dst, const uint8_t *src, \
432  ptrdiff_t stride) \
433 { \
434  uint8_t half[256]; \
435  \
436  put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16); \
437  OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16); \
438 } \
439  \
440 static void OPNAME ## qpel16_mc20_c(uint8_t *dst, const uint8_t *src, \
441  ptrdiff_t stride) \
442 { \
443  OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16); \
444 } \
445  \
446 static void OPNAME ## qpel16_mc30_c(uint8_t *dst, const uint8_t *src, \
447  ptrdiff_t stride) \
448 { \
449  uint8_t half[256]; \
450  \
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); \
453 } \
454  \
455 static void OPNAME ## qpel16_mc01_c(uint8_t *dst, const uint8_t *src, \
456  ptrdiff_t stride) \
457 { \
458  uint8_t full[24 * 17]; \
459  uint8_t half[256]; \
460  \
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); \
464 } \
465  \
466 static void OPNAME ## qpel16_mc02_c(uint8_t *dst, const uint8_t *src, \
467  ptrdiff_t stride) \
468 { \
469  uint8_t full[24 * 17]; \
470  \
471  copy_block17(full, src, 24, stride, 17); \
472  OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24); \
473 } \
474  \
475 static void OPNAME ## qpel16_mc03_c(uint8_t *dst, const uint8_t *src, \
476  ptrdiff_t stride) \
477 { \
478  uint8_t full[24 * 17]; \
479  uint8_t half[256]; \
480  \
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); \
484 } \
485  \
486 void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, const uint8_t *src, \
487  ptrdiff_t stride) \
488 { \
489  uint8_t full[24 * 17]; \
490  uint8_t halfH[272]; \
491  uint8_t halfV[256]; \
492  uint8_t halfHV[256]; \
493  \
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); \
500 } \
501  \
502 static void OPNAME ## qpel16_mc11_c(uint8_t *dst, const uint8_t *src, \
503  ptrdiff_t stride) \
504 { \
505  uint8_t full[24 * 17]; \
506  uint8_t halfH[272]; \
507  uint8_t halfHV[256]; \
508  \
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); \
514 } \
515  \
516 void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, const uint8_t *src, \
517  ptrdiff_t stride) \
518 { \
519  uint8_t full[24 * 17]; \
520  uint8_t halfH[272]; \
521  uint8_t halfV[256]; \
522  uint8_t halfHV[256]; \
523  \
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); \
530 } \
531  \
532 static void OPNAME ## qpel16_mc31_c(uint8_t *dst, const uint8_t *src, \
533  ptrdiff_t stride) \
534 { \
535  uint8_t full[24 * 17]; \
536  uint8_t halfH[272]; \
537  uint8_t halfHV[256]; \
538  \
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); \
544 } \
545  \
546 void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, const uint8_t *src, \
547  ptrdiff_t stride) \
548 { \
549  uint8_t full[24 * 17]; \
550  uint8_t halfH[272]; \
551  uint8_t halfV[256]; \
552  uint8_t halfHV[256]; \
553  \
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); \
560 } \
561  \
562 static void OPNAME ## qpel16_mc13_c(uint8_t *dst, const uint8_t *src, \
563  ptrdiff_t stride) \
564 { \
565  uint8_t full[24 * 17]; \
566  uint8_t halfH[272]; \
567  uint8_t halfHV[256]; \
568  \
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); \
574 } \
575  \
576 void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, const uint8_t *src, \
577  ptrdiff_t stride) \
578 { \
579  uint8_t full[24 * 17]; \
580  uint8_t halfH[272]; \
581  uint8_t halfV[256]; \
582  uint8_t halfHV[256]; \
583  \
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); \
590 } \
591  \
592 static void OPNAME ## qpel16_mc33_c(uint8_t *dst, const uint8_t *src, \
593  ptrdiff_t stride) \
594 { \
595  uint8_t full[24 * 17]; \
596  uint8_t halfH[272]; \
597  uint8_t halfHV[256]; \
598  \
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); \
604 } \
605  \
606 static void OPNAME ## qpel16_mc21_c(uint8_t *dst, const uint8_t *src, \
607  ptrdiff_t stride) \
608 { \
609  uint8_t halfH[272]; \
610  uint8_t halfHV[256]; \
611  \
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); \
615 } \
616  \
617 static void OPNAME ## qpel16_mc23_c(uint8_t *dst, const uint8_t *src, \
618  ptrdiff_t stride) \
619 { \
620  uint8_t halfH[272]; \
621  uint8_t halfHV[256]; \
622  \
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); \
626 } \
627  \
628 void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, const uint8_t *src, \
629  ptrdiff_t stride) \
630 { \
631  uint8_t full[24 * 17]; \
632  uint8_t halfH[272]; \
633  uint8_t halfV[256]; \
634  uint8_t halfHV[256]; \
635  \
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); \
641 } \
642  \
643 static void OPNAME ## qpel16_mc12_c(uint8_t *dst, const uint8_t *src, \
644  ptrdiff_t stride) \
645 { \
646  uint8_t full[24 * 17]; \
647  uint8_t halfH[272]; \
648  \
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); \
653 } \
654  \
655 void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, const uint8_t *src, \
656  ptrdiff_t stride) \
657 { \
658  uint8_t full[24 * 17]; \
659  uint8_t halfH[272]; \
660  uint8_t halfV[256]; \
661  uint8_t halfHV[256]; \
662  \
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); \
668 } \
669  \
670 static void OPNAME ## qpel16_mc32_c(uint8_t *dst, const uint8_t *src, \
671  ptrdiff_t stride) \
672 { \
673  uint8_t full[24 * 17]; \
674  uint8_t halfH[272]; \
675  \
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); \
680 } \
681  \
682 static void OPNAME ## qpel16_mc22_c(uint8_t *dst, const uint8_t *src, \
683  ptrdiff_t stride) \
684 { \
685  uint8_t halfH[272]; \
686  \
687  put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17); \
688  OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16); \
689 }
690 
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]
694 
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)
698 
699 #undef op_avg
700 #undef op_put
701 #undef op_put_no_rnd
702 
703 void ff_put_pixels8x8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
704 {
705  put_pixels8_8_c(dst, src, stride, 8);
706 }
707 
708 void ff_avg_pixels8x8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
709 {
710  avg_pixels8_8_c(dst, src, stride, 8);
711 }
712 
713 void ff_put_pixels16x16_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
714 {
715  put_pixels16_8_c(dst, src, stride, 16);
716 }
717 
718 void ff_avg_pixels16x16_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
719 {
720  avg_pixels16_8_c(dst, src, stride, 16);
721 }
722 
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
729 
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,
732  int h)
733 {
734  put_pixels8_l2_8(dst, src1, src2, dst_stride, src_stride1, src_stride2, h);
735 
736 }
737 
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)\
741 {\
742  OPNAME ## _pixels8_8_c(dst, src[0], stride, h);\
743 }\
744 void ff_ ## OPNAME ## _dirac_pixels16_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
745 {\
746  OPNAME ## _pixels16_8_c(dst, src[0], stride, h);\
747 }\
748 void ff_ ## OPNAME ## _dirac_pixels32_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
749 {\
750  OPNAME ## _pixels16_8_c(dst , src[0] , stride, h);\
751  OPNAME ## _pixels16_8_c(dst+16, src[0]+16, stride, h);\
752 }\
753 void ff_ ## OPNAME ## _dirac_pixels8_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
754 {\
755  OPNAME ## _pixels8_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
756 }\
757 void ff_ ## OPNAME ## _dirac_pixels16_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
758 {\
759  OPNAME ## _pixels16_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
760 }\
761 void ff_ ## OPNAME ## _dirac_pixels32_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
762 {\
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);\
765 }\
766 void ff_ ## OPNAME ## _dirac_pixels8_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
767 {\
768  OPNAME ## _pixels8_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
769 }\
770 void ff_ ## OPNAME ## _dirac_pixels16_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
771 {\
772  OPNAME ## _pixels16_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
773 }\
774 void ff_ ## OPNAME ## _dirac_pixels32_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
775 {\
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);\
778 }
779 DIRAC_MC(put)
780 DIRAC_MC(avg)
781 #endif
782 
784 {
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
802 
803  dspfunc(put_qpel, 0, 16);
804  dspfunc(put_qpel, 1, 8);
805 
806  dspfunc(put_no_rnd_qpel, 0, 16);
807  dspfunc(put_no_rnd_qpel, 1, 8);
808 
809  dspfunc(avg_qpel, 0, 16);
810  dspfunc(avg_qpel, 1, 8);
811 
812  if (ARCH_X86)
814 }
void ff_qpeldsp_init_x86(QpelDSPContext *c)
Definition: qpeldsp_init.c:529
void ff_put_pixels8_l2_8(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h)
Definition: qpeldsp.c:730
Macro definitions for various function/variable attributes.
#define _(x)
uint8_t
#define av_cold
Definition: attributes.h:74
#define op_put_no_rnd(a, b)
Definition: qpeldsp.c:693
quarterpel DSP functions
void ff_put_pixels8x8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition: qpeldsp.c:703
#define QPEL_MC(r, OPNAME, RND, OP)
Definition: qpeldsp.c:42
quarterpel DSP function templates
void ff_avg_pixels16x16_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition: qpeldsp.c:718
AVS_Value src
Definition: avisynth_c.h:482
void ff_put_pixels16x16_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition: qpeldsp.c:713
#define op_put(a, b)
Definition: qpeldsp.c:692
#define dspfunc(PFX, IDX, NUM)
quarterpel DSP context
Definition: qpeldsp.h:72
#define op_avg(a, b)
Definition: qpeldsp.c:691
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
static double c[64]
av_cold void ff_qpeldsp_init(QpelDSPContext *c)
Definition: qpeldsp.c:783
void ff_avg_pixels8x8_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition: qpeldsp.c:708