]> git.sesse.net Git - ffmpeg/blob - libavcodec/dsputil_template.c
Vivo demuxer
[ffmpeg] / libavcodec / dsputil_template.c
1 /*
2  * DSP utils
3  * Copyright (c) 2000, 2001 Fabrice Bellard
4  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5  *
6  * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24
25 /**
26  * @file
27  * DSP utils
28  */
29
30 #include "bit_depth_template.c"
31
32 static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
33 {
34     int i;
35     for(i=0; i<h; i++)
36     {
37         AV_WN2P(dst   , AV_RN2P(src   ));
38         dst+=dstStride;
39         src+=srcStride;
40     }
41 }
42
43 static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
44 {
45     int i;
46     for(i=0; i<h; i++)
47     {
48         AV_WN4P(dst   , AV_RN4P(src   ));
49         dst+=dstStride;
50         src+=srcStride;
51     }
52 }
53
54 static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
55 {
56     int i;
57     for(i=0; i<h; i++)
58     {
59         AV_WN4P(dst                , AV_RN4P(src                ));
60         AV_WN4P(dst+4*sizeof(pixel), AV_RN4P(src+4*sizeof(pixel)));
61         dst+=dstStride;
62         src+=srcStride;
63     }
64 }
65
66 static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
67 {
68     int i;
69     for(i=0; i<h; i++)
70     {
71         AV_WN4P(dst                 , AV_RN4P(src                 ));
72         AV_WN4P(dst+ 4*sizeof(pixel), AV_RN4P(src+ 4*sizeof(pixel)));
73         AV_WN4P(dst+ 8*sizeof(pixel), AV_RN4P(src+ 8*sizeof(pixel)));
74         AV_WN4P(dst+12*sizeof(pixel), AV_RN4P(src+12*sizeof(pixel)));
75         dst+=dstStride;
76         src+=srcStride;
77     }
78 }
79
80 /* draw the edges of width 'w' of an image of size width, height */
81 //FIXME check that this is ok for mpeg4 interlaced
82 static void FUNCC(draw_edges)(uint8_t *p_buf, int p_wrap, int width, int height, int w, int h, int sides)
83 {
84     pixel *buf = (pixel*)p_buf;
85     int wrap = p_wrap / sizeof(pixel);
86     pixel *ptr, *last_line;
87     int i;
88
89     /* left and right */
90     ptr = buf;
91     for(i=0;i<height;i++) {
92 #if BIT_DEPTH > 8
93         int j;
94         for (j = 0; j < w; j++) {
95             ptr[j-w] = ptr[0];
96             ptr[j+width] = ptr[width-1];
97         }
98 #else
99         memset(ptr - w, ptr[0], w);
100         memset(ptr + width, ptr[width-1], w);
101 #endif
102         ptr += wrap;
103     }
104
105     /* top and bottom + corners */
106     buf -= w;
107     last_line = buf + (height - 1) * wrap;
108     if (sides & EDGE_TOP)
109         for(i = 0; i < h; i++)
110             memcpy(buf - (i + 1) * wrap, buf, (width + w + w) * sizeof(pixel)); // top
111     if (sides & EDGE_BOTTOM)
112         for (i = 0; i < h; i++)
113             memcpy(last_line + (i + 1) * wrap, last_line, (width + w + w) * sizeof(pixel)); // bottom
114 }
115
116 /**
117  * Copy a rectangular area of samples to a temporary buffer and replicate the border samples.
118  * @param buf destination buffer
119  * @param src source buffer
120  * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers
121  * @param block_w width of block
122  * @param block_h height of block
123  * @param src_x x coordinate of the top left sample of the block in the source buffer
124  * @param src_y y coordinate of the top left sample of the block in the source buffer
125  * @param w width of the source buffer
126  * @param h height of the source buffer
127  */
128 void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, int block_w, int block_h,
129                                     int src_x, int src_y, int w, int h){
130     int x, y;
131     int start_y, start_x, end_y, end_x;
132
133     if(src_y>= h){
134         src-= src_y*linesize;
135         src+= (h-1)*linesize;
136         src_y=h-1;
137     }else if(src_y<=-block_h){
138         src-= src_y*linesize;
139         src+= (1-block_h)*linesize;
140         src_y=1-block_h;
141     }
142     if(src_x>= w){
143         src+= (w-1-src_x)*sizeof(pixel);
144         src_x=w-1;
145     }else if(src_x<=-block_w){
146         src+= (1-block_w-src_x)*sizeof(pixel);
147         src_x=1-block_w;
148     }
149
150     start_y= FFMAX(0, -src_y);
151     start_x= FFMAX(0, -src_x);
152     end_y= FFMIN(block_h, h-src_y);
153     end_x= FFMIN(block_w, w-src_x);
154     av_assert2(start_y < end_y && block_h);
155     av_assert2(start_x < end_x && block_w);
156
157     w    = end_x - start_x;
158     src += start_y*linesize + start_x*sizeof(pixel);
159     buf += start_x*sizeof(pixel);
160
161     //top
162     for(y=0; y<start_y; y++){
163         memcpy(buf, src, w*sizeof(pixel));
164         buf += linesize;
165     }
166
167     // copy existing part
168     for(; y<end_y; y++){
169         memcpy(buf, src, w*sizeof(pixel));
170         src += linesize;
171         buf += linesize;
172     }
173
174     //bottom
175     src -= linesize;
176     for(; y<block_h; y++){
177         memcpy(buf, src, w*sizeof(pixel));
178         buf += linesize;
179     }
180
181     buf -= block_h * linesize + start_x*sizeof(pixel);
182     while (block_h--){
183         pixel *bufp = (pixel*)buf;
184        //left
185         for(x=0; x<start_x; x++){
186             bufp[x] = bufp[start_x];
187         }
188
189        //right
190         for(x=end_x; x<block_w; x++){
191             bufp[x] = bufp[end_x - 1];
192         }
193         buf += linesize;
194     }
195 }
196
197 #define DCTELEM_FUNCS(dctcoef, suffix)                                  \
198 static void FUNCC(get_pixels ## suffix)(DCTELEM *av_restrict _block,    \
199                                         const uint8_t *_pixels,         \
200                                         int line_size)                  \
201 {                                                                       \
202     const pixel *pixels = (const pixel *) _pixels;                      \
203     dctcoef *av_restrict block = (dctcoef *) _block;                    \
204     int i;                                                              \
205                                                                         \
206     /* read the pixels */                                               \
207     for(i=0;i<8;i++) {                                                  \
208         block[0] = pixels[0];                                           \
209         block[1] = pixels[1];                                           \
210         block[2] = pixels[2];                                           \
211         block[3] = pixels[3];                                           \
212         block[4] = pixels[4];                                           \
213         block[5] = pixels[5];                                           \
214         block[6] = pixels[6];                                           \
215         block[7] = pixels[7];                                           \
216         pixels += line_size / sizeof(pixel);                            \
217         block += 8;                                                     \
218     }                                                                   \
219 }                                                                       \
220                                                                         \
221 static void FUNCC(add_pixels8 ## suffix)(uint8_t *av_restrict _pixels,  \
222                                          DCTELEM *_block,               \
223                                          int line_size)                 \
224 {                                                                       \
225     int i;                                                              \
226     pixel *av_restrict pixels = (pixel *av_restrict)_pixels;            \
227     dctcoef *block = (dctcoef*)_block;                                  \
228     line_size /= sizeof(pixel);                                         \
229                                                                         \
230     for(i=0;i<8;i++) {                                                  \
231         pixels[0] += block[0];                                          \
232         pixels[1] += block[1];                                          \
233         pixels[2] += block[2];                                          \
234         pixels[3] += block[3];                                          \
235         pixels[4] += block[4];                                          \
236         pixels[5] += block[5];                                          \
237         pixels[6] += block[6];                                          \
238         pixels[7] += block[7];                                          \
239         pixels += line_size;                                            \
240         block += 8;                                                     \
241     }                                                                   \
242 }                                                                       \
243                                                                         \
244 static void FUNCC(add_pixels4 ## suffix)(uint8_t *av_restrict _pixels,  \
245                                          DCTELEM *_block,               \
246                                          int line_size)                 \
247 {                                                                       \
248     int i;                                                              \
249     pixel *av_restrict pixels = (pixel *av_restrict)_pixels;            \
250     dctcoef *block = (dctcoef*)_block;                                  \
251     line_size /= sizeof(pixel);                                         \
252                                                                         \
253     for(i=0;i<4;i++) {                                                  \
254         pixels[0] += block[0];                                          \
255         pixels[1] += block[1];                                          \
256         pixels[2] += block[2];                                          \
257         pixels[3] += block[3];                                          \
258         pixels += line_size;                                            \
259         block += 4;                                                     \
260     }                                                                   \
261 }                                                                       \
262                                                                         \
263 static void FUNCC(clear_block ## suffix)(DCTELEM *block)                \
264 {                                                                       \
265     memset(block, 0, sizeof(dctcoef)*64);                               \
266 }                                                                       \
267                                                                         \
268 /**                                                                     \
269  * memset(blocks, 0, sizeof(DCTELEM)*6*64)                              \
270  */                                                                     \
271 static void FUNCC(clear_blocks ## suffix)(DCTELEM *blocks)              \
272 {                                                                       \
273     memset(blocks, 0, sizeof(dctcoef)*6*64);                            \
274 }
275
276 DCTELEM_FUNCS(DCTELEM, _16)
277 #if BIT_DEPTH > 8
278 DCTELEM_FUNCS(dctcoef, _32)
279 #endif
280
281 #define PIXOP2(OPNAME, OP) \
282 static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
283     int i;\
284     for(i=0; i<h; i++){\
285         OP(*((pixel2*)(block  )), AV_RN2P(pixels  ));\
286         pixels+=line_size;\
287         block +=line_size;\
288     }\
289 }\
290 static void FUNCC(OPNAME ## _pixels4)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
291     int i;\
292     for(i=0; i<h; i++){\
293         OP(*((pixel4*)(block  )), AV_RN4P(pixels  ));\
294         pixels+=line_size;\
295         block +=line_size;\
296     }\
297 }\
298 static void FUNCC(OPNAME ## _pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
299     int i;\
300     for(i=0; i<h; i++){\
301         OP(*((pixel4*)(block                )), AV_RN4P(pixels                ));\
302         OP(*((pixel4*)(block+4*sizeof(pixel))), AV_RN4P(pixels+4*sizeof(pixel)));\
303         pixels+=line_size;\
304         block +=line_size;\
305     }\
306 }\
307 static inline void FUNCC(OPNAME ## _no_rnd_pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
308     FUNCC(OPNAME ## _pixels8)(block, pixels, line_size, h);\
309 }\
310 \
311 static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
312                                                 int src_stride1, int src_stride2, int h){\
313     int i;\
314     for(i=0; i<h; i++){\
315         pixel4 a,b;\
316         a= AV_RN4P(&src1[i*src_stride1  ]);\
317         b= AV_RN4P(&src2[i*src_stride2  ]);\
318         OP(*((pixel4*)&dst[i*dst_stride  ]), no_rnd_avg_pixel4(a, b));\
319         a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
320         b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
321         OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\
322     }\
323 }\
324 \
325 static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
326                                                 int src_stride1, int src_stride2, int h){\
327     int i;\
328     for(i=0; i<h; i++){\
329         pixel4 a,b;\
330         a= AV_RN4P(&src1[i*src_stride1  ]);\
331         b= AV_RN4P(&src2[i*src_stride2  ]);\
332         OP(*((pixel4*)&dst[i*dst_stride  ]), rnd_avg_pixel4(a, b));\
333         a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
334         b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
335         OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), rnd_avg_pixel4(a, b));\
336     }\
337 }\
338 \
339 static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
340                                                 int src_stride1, int src_stride2, int h){\
341     int i;\
342     for(i=0; i<h; i++){\
343         pixel4 a,b;\
344         a= AV_RN4P(&src1[i*src_stride1  ]);\
345         b= AV_RN4P(&src2[i*src_stride2  ]);\
346         OP(*((pixel4*)&dst[i*dst_stride  ]), rnd_avg_pixel4(a, b));\
347     }\
348 }\
349 \
350 static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
351                                                 int src_stride1, int src_stride2, int h){\
352     int i;\
353     for(i=0; i<h; i++){\
354         pixel4 a,b;\
355         a= AV_RN2P(&src1[i*src_stride1  ]);\
356         b= AV_RN2P(&src2[i*src_stride2  ]);\
357         OP(*((pixel2*)&dst[i*dst_stride  ]), rnd_avg_pixel4(a, b));\
358     }\
359 }\
360 \
361 static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
362                                                 int src_stride1, int src_stride2, int h){\
363     FUNC(OPNAME ## _pixels8_l2)(dst  , src1  , src2  , dst_stride, src_stride1, src_stride2, h);\
364     FUNC(OPNAME ## _pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
365 }\
366 \
367 static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
368                                                 int src_stride1, int src_stride2, int h){\
369     FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst  , src1  , src2  , dst_stride, src_stride1, src_stride2, h);\
370     FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
371 }\
372 \
373 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
374     FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
375 }\
376 \
377 static inline void FUNCC(OPNAME ## _pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
378     FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
379 }\
380 \
381 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
382     FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
383 }\
384 \
385 static inline void FUNCC(OPNAME ## _pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
386     FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
387 }\
388 \
389 static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
390                  int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
391     /* FIXME HIGH BIT DEPTH */\
392     int i;\
393     for(i=0; i<h; i++){\
394         uint32_t a, b, c, d, l0, l1, h0, h1;\
395         a= AV_RN32(&src1[i*src_stride1]);\
396         b= AV_RN32(&src2[i*src_stride2]);\
397         c= AV_RN32(&src3[i*src_stride3]);\
398         d= AV_RN32(&src4[i*src_stride4]);\
399         l0=  (a&0x03030303UL)\
400            + (b&0x03030303UL)\
401            + 0x02020202UL;\
402         h0= ((a&0xFCFCFCFCUL)>>2)\
403           + ((b&0xFCFCFCFCUL)>>2);\
404         l1=  (c&0x03030303UL)\
405            + (d&0x03030303UL);\
406         h1= ((c&0xFCFCFCFCUL)>>2)\
407           + ((d&0xFCFCFCFCUL)>>2);\
408         OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
409         a= AV_RN32(&src1[i*src_stride1+4]);\
410         b= AV_RN32(&src2[i*src_stride2+4]);\
411         c= AV_RN32(&src3[i*src_stride3+4]);\
412         d= AV_RN32(&src4[i*src_stride4+4]);\
413         l0=  (a&0x03030303UL)\
414            + (b&0x03030303UL)\
415            + 0x02020202UL;\
416         h0= ((a&0xFCFCFCFCUL)>>2)\
417           + ((b&0xFCFCFCFCUL)>>2);\
418         l1=  (c&0x03030303UL)\
419            + (d&0x03030303UL);\
420         h1= ((c&0xFCFCFCFCUL)>>2)\
421           + ((d&0xFCFCFCFCUL)>>2);\
422         OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
423     }\
424 }\
425 \
426 static inline void FUNCC(OPNAME ## _pixels4_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
427     FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
428 }\
429 \
430 static inline void FUNCC(OPNAME ## _pixels4_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
431     FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
432 }\
433 \
434 static inline void FUNCC(OPNAME ## _pixels2_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
435     FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
436 }\
437 \
438 static inline void FUNCC(OPNAME ## _pixels2_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
439     FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
440 }\
441 \
442 static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
443                  int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
444     /* FIXME HIGH BIT DEPTH*/\
445     int i;\
446     for(i=0; i<h; i++){\
447         uint32_t a, b, c, d, l0, l1, h0, h1;\
448         a= AV_RN32(&src1[i*src_stride1]);\
449         b= AV_RN32(&src2[i*src_stride2]);\
450         c= AV_RN32(&src3[i*src_stride3]);\
451         d= AV_RN32(&src4[i*src_stride4]);\
452         l0=  (a&0x03030303UL)\
453            + (b&0x03030303UL)\
454            + 0x01010101UL;\
455         h0= ((a&0xFCFCFCFCUL)>>2)\
456           + ((b&0xFCFCFCFCUL)>>2);\
457         l1=  (c&0x03030303UL)\
458            + (d&0x03030303UL);\
459         h1= ((c&0xFCFCFCFCUL)>>2)\
460           + ((d&0xFCFCFCFCUL)>>2);\
461         OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
462         a= AV_RN32(&src1[i*src_stride1+4]);\
463         b= AV_RN32(&src2[i*src_stride2+4]);\
464         c= AV_RN32(&src3[i*src_stride3+4]);\
465         d= AV_RN32(&src4[i*src_stride4+4]);\
466         l0=  (a&0x03030303UL)\
467            + (b&0x03030303UL)\
468            + 0x01010101UL;\
469         h0= ((a&0xFCFCFCFCUL)>>2)\
470           + ((b&0xFCFCFCFCUL)>>2);\
471         l1=  (c&0x03030303UL)\
472            + (d&0x03030303UL);\
473         h1= ((c&0xFCFCFCFCUL)>>2)\
474           + ((d&0xFCFCFCFCUL)>>2);\
475         OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
476     }\
477 }\
478 static inline void FUNC(OPNAME ## _pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
479                  int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
480     FUNC(OPNAME ## _pixels8_l4)(dst  , src1  , src2  , src3  , src4  , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
481     FUNC(OPNAME ## _pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
482 }\
483 static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
484                  int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
485     FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst  , src1  , src2  , src3  , src4  , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
486     FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
487 }\
488 \
489 static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *p_block, const uint8_t *p_pixels, int line_size, int h)\
490 {\
491         int i, a0, b0, a1, b1;\
492         pixel *block = (pixel*)p_block;\
493         const pixel *pixels = (const pixel*)p_pixels;\
494         line_size >>= sizeof(pixel)-1;\
495         a0= pixels[0];\
496         b0= pixels[1] + 2;\
497         a0 += b0;\
498         b0 += pixels[2];\
499 \
500         pixels+=line_size;\
501         for(i=0; i<h; i+=2){\
502             a1= pixels[0];\
503             b1= pixels[1];\
504             a1 += b1;\
505             b1 += pixels[2];\
506 \
507             block[0]= (a1+a0)>>2; /* FIXME non put */\
508             block[1]= (b1+b0)>>2;\
509 \
510             pixels+=line_size;\
511             block +=line_size;\
512 \
513             a0= pixels[0];\
514             b0= pixels[1] + 2;\
515             a0 += b0;\
516             b0 += pixels[2];\
517 \
518             block[0]= (a1+a0)>>2;\
519             block[1]= (b1+b0)>>2;\
520             pixels+=line_size;\
521             block +=line_size;\
522         }\
523 }\
524 \
525 static inline void FUNCC(OPNAME ## _pixels4_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
526 {\
527         /* FIXME HIGH BIT DEPTH */\
528         int i;\
529         const uint32_t a= AV_RN32(pixels  );\
530         const uint32_t b= AV_RN32(pixels+1);\
531         uint32_t l0=  (a&0x03030303UL)\
532                     + (b&0x03030303UL)\
533                     + 0x02020202UL;\
534         uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
535                    + ((b&0xFCFCFCFCUL)>>2);\
536         uint32_t l1,h1;\
537 \
538         pixels+=line_size;\
539         for(i=0; i<h; i+=2){\
540             uint32_t a= AV_RN32(pixels  );\
541             uint32_t b= AV_RN32(pixels+1);\
542             l1=  (a&0x03030303UL)\
543                + (b&0x03030303UL);\
544             h1= ((a&0xFCFCFCFCUL)>>2)\
545               + ((b&0xFCFCFCFCUL)>>2);\
546             OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
547             pixels+=line_size;\
548             block +=line_size;\
549             a= AV_RN32(pixels  );\
550             b= AV_RN32(pixels+1);\
551             l0=  (a&0x03030303UL)\
552                + (b&0x03030303UL)\
553                + 0x02020202UL;\
554             h0= ((a&0xFCFCFCFCUL)>>2)\
555               + ((b&0xFCFCFCFCUL)>>2);\
556             OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
557             pixels+=line_size;\
558             block +=line_size;\
559         }\
560 }\
561 \
562 static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
563 {\
564     /* FIXME HIGH BIT DEPTH */\
565     int j;\
566     for(j=0; j<2; j++){\
567         int i;\
568         const uint32_t a= AV_RN32(pixels  );\
569         const uint32_t b= AV_RN32(pixels+1);\
570         uint32_t l0=  (a&0x03030303UL)\
571                     + (b&0x03030303UL)\
572                     + 0x02020202UL;\
573         uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
574                    + ((b&0xFCFCFCFCUL)>>2);\
575         uint32_t l1,h1;\
576 \
577         pixels+=line_size;\
578         for(i=0; i<h; i+=2){\
579             uint32_t a= AV_RN32(pixels  );\
580             uint32_t b= AV_RN32(pixels+1);\
581             l1=  (a&0x03030303UL)\
582                + (b&0x03030303UL);\
583             h1= ((a&0xFCFCFCFCUL)>>2)\
584               + ((b&0xFCFCFCFCUL)>>2);\
585             OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
586             pixels+=line_size;\
587             block +=line_size;\
588             a= AV_RN32(pixels  );\
589             b= AV_RN32(pixels+1);\
590             l0=  (a&0x03030303UL)\
591                + (b&0x03030303UL)\
592                + 0x02020202UL;\
593             h0= ((a&0xFCFCFCFCUL)>>2)\
594               + ((b&0xFCFCFCFCUL)>>2);\
595             OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
596             pixels+=line_size;\
597             block +=line_size;\
598         }\
599         pixels+=4-line_size*(h+1);\
600         block +=4-line_size*h;\
601     }\
602 }\
603 \
604 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
605 {\
606     /* FIXME HIGH BIT DEPTH */\
607     int j;\
608     for(j=0; j<2; j++){\
609         int i;\
610         const uint32_t a= AV_RN32(pixels  );\
611         const uint32_t b= AV_RN32(pixels+1);\
612         uint32_t l0=  (a&0x03030303UL)\
613                     + (b&0x03030303UL)\
614                     + 0x01010101UL;\
615         uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
616                    + ((b&0xFCFCFCFCUL)>>2);\
617         uint32_t l1,h1;\
618 \
619         pixels+=line_size;\
620         for(i=0; i<h; i+=2){\
621             uint32_t a= AV_RN32(pixels  );\
622             uint32_t b= AV_RN32(pixels+1);\
623             l1=  (a&0x03030303UL)\
624                + (b&0x03030303UL);\
625             h1= ((a&0xFCFCFCFCUL)>>2)\
626               + ((b&0xFCFCFCFCUL)>>2);\
627             OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
628             pixels+=line_size;\
629             block +=line_size;\
630             a= AV_RN32(pixels  );\
631             b= AV_RN32(pixels+1);\
632             l0=  (a&0x03030303UL)\
633                + (b&0x03030303UL)\
634                + 0x01010101UL;\
635             h0= ((a&0xFCFCFCFCUL)>>2)\
636               + ((b&0xFCFCFCFCUL)>>2);\
637             OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
638             pixels+=line_size;\
639             block +=line_size;\
640         }\
641         pixels+=4-line_size*(h+1);\
642         block +=4-line_size*h;\
643     }\
644 }\
645 \
646 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16)    , FUNCC(OPNAME ## _pixels8)    , 8*sizeof(pixel))\
647 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_x2) , FUNCC(OPNAME ## _pixels8_x2) , 8*sizeof(pixel))\
648 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_y2) , FUNCC(OPNAME ## _pixels8_y2) , 8*sizeof(pixel))\
649 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\
650 av_unused CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16)    , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
651 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_x2) , FUNCC(OPNAME ## _no_rnd_pixels8_x2) , 8*sizeof(pixel))\
652 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pixels8_y2) , 8*sizeof(pixel))\
653 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\
654
655 #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
656 #define op_put(a, b) a = b
657
658 PIXOP2(avg, op_avg)
659 PIXOP2(put, op_put)
660 #undef op_avg
661 #undef op_put
662
663 #define put_no_rnd_pixels8_c  put_pixels8_c
664 #define put_no_rnd_pixels16_c put_pixels16_c
665
666 static void FUNCC(put_no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
667     FUNC(put_no_rnd_pixels16_l2)(dst, a, b, stride, stride, stride, h);
668 }
669
670 static void FUNCC(put_no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
671     FUNC(put_no_rnd_pixels8_l2)(dst, a, b, stride, stride, stride, h);
672 }
673
674 #define H264_CHROMA_MC(OPNAME, OP)\
675 static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *p_dst/*align 8*/, uint8_t *p_src/*align 1*/, int stride, int h, int x, int y){\
676     pixel *dst = (pixel*)p_dst;\
677     pixel *src = (pixel*)p_src;\
678     const int A=(8-x)*(8-y);\
679     const int B=(  x)*(8-y);\
680     const int C=(8-x)*(  y);\
681     const int D=(  x)*(  y);\
682     int i;\
683     stride >>= sizeof(pixel)-1;\
684     \
685     av_assert2(x<8 && y<8 && x>=0 && y>=0);\
686 \
687     if(D){\
688         for(i=0; i<h; i++){\
689             OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
690             OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
691             dst+= stride;\
692             src+= stride;\
693         }\
694     }else{\
695         const int E= B+C;\
696         const int step= C ? stride : 1;\
697         for(i=0; i<h; i++){\
698             OP(dst[0], (A*src[0] + E*src[step+0]));\
699             OP(dst[1], (A*src[1] + E*src[step+1]));\
700             dst+= stride;\
701             src+= stride;\
702         }\
703     }\
704 }\
705 \
706 static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *p_dst/*align 8*/, uint8_t *p_src/*align 1*/, int stride, int h, int x, int y){\
707     pixel *dst = (pixel*)p_dst;\
708     pixel *src = (pixel*)p_src;\
709     const int A=(8-x)*(8-y);\
710     const int B=(  x)*(8-y);\
711     const int C=(8-x)*(  y);\
712     const int D=(  x)*(  y);\
713     int i;\
714     stride >>= sizeof(pixel)-1;\
715     \
716     av_assert2(x<8 && y<8 && x>=0 && y>=0);\
717 \
718     if(D){\
719         for(i=0; i<h; i++){\
720             OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
721             OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
722             OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
723             OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
724             dst+= stride;\
725             src+= stride;\
726         }\
727     }else{\
728         const int E= B+C;\
729         const int step= C ? stride : 1;\
730         for(i=0; i<h; i++){\
731             OP(dst[0], (A*src[0] + E*src[step+0]));\
732             OP(dst[1], (A*src[1] + E*src[step+1]));\
733             OP(dst[2], (A*src[2] + E*src[step+2]));\
734             OP(dst[3], (A*src[3] + E*src[step+3]));\
735             dst+= stride;\
736             src+= stride;\
737         }\
738     }\
739 }\
740 \
741 static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *p_dst/*align 8*/, uint8_t *p_src/*align 1*/, int stride, int h, int x, int y){\
742     pixel *dst = (pixel*)p_dst;\
743     pixel *src = (pixel*)p_src;\
744     const int A=(8-x)*(8-y);\
745     const int B=(  x)*(8-y);\
746     const int C=(8-x)*(  y);\
747     const int D=(  x)*(  y);\
748     int i;\
749     stride >>= sizeof(pixel)-1;\
750     \
751     av_assert2(x<8 && y<8 && x>=0 && y>=0);\
752 \
753     if(D){\
754         for(i=0; i<h; i++){\
755             OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
756             OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
757             OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
758             OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
759             OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
760             OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
761             OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
762             OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
763             dst+= stride;\
764             src+= stride;\
765         }\
766     }else{\
767         const int E= B+C;\
768         const int step= C ? stride : 1;\
769         for(i=0; i<h; i++){\
770             OP(dst[0], (A*src[0] + E*src[step+0]));\
771             OP(dst[1], (A*src[1] + E*src[step+1]));\
772             OP(dst[2], (A*src[2] + E*src[step+2]));\
773             OP(dst[3], (A*src[3] + E*src[step+3]));\
774             OP(dst[4], (A*src[4] + E*src[step+4]));\
775             OP(dst[5], (A*src[5] + E*src[step+5]));\
776             OP(dst[6], (A*src[6] + E*src[step+6]));\
777             OP(dst[7], (A*src[7] + E*src[step+7]));\
778             dst+= stride;\
779             src+= stride;\
780         }\
781     }\
782 }
783
784 #define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
785 #define op_put(a, b) a = (((b) + 32)>>6)
786
787 H264_CHROMA_MC(put_       , op_put)
788 H264_CHROMA_MC(avg_       , op_avg)
789 #undef op_avg
790 #undef op_put
791
792 #define H264_LOWPASS(OPNAME, OP, OP2) \
793 static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
794     const int h=2;\
795     INIT_CLIP\
796     int i;\
797     pixel *dst = (pixel*)p_dst;\
798     pixel *src = (pixel*)p_src;\
799     dstStride >>= sizeof(pixel)-1;\
800     srcStride >>= sizeof(pixel)-1;\
801     for(i=0; i<h; i++)\
802     {\
803         OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
804         OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
805         dst+=dstStride;\
806         src+=srcStride;\
807     }\
808 }\
809 \
810 static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
811     const int w=2;\
812     INIT_CLIP\
813     int i;\
814     pixel *dst = (pixel*)p_dst;\
815     pixel *src = (pixel*)p_src;\
816     dstStride >>= sizeof(pixel)-1;\
817     srcStride >>= sizeof(pixel)-1;\
818     for(i=0; i<w; i++)\
819     {\
820         const int srcB= src[-2*srcStride];\
821         const int srcA= src[-1*srcStride];\
822         const int src0= src[0 *srcStride];\
823         const int src1= src[1 *srcStride];\
824         const int src2= src[2 *srcStride];\
825         const int src3= src[3 *srcStride];\
826         const int src4= src[4 *srcStride];\
827         OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
828         OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
829         dst++;\
830         src++;\
831     }\
832 }\
833 \
834 static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
835     const int h=2;\
836     const int w=2;\
837     const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
838     INIT_CLIP\
839     int i;\
840     pixel *dst = (pixel*)p_dst;\
841     pixel *src = (pixel*)p_src;\
842     dstStride >>= sizeof(pixel)-1;\
843     srcStride >>= sizeof(pixel)-1;\
844     src -= 2*srcStride;\
845     for(i=0; i<h+5; i++)\
846     {\
847         tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
848         tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
849         tmp+=tmpStride;\
850         src+=srcStride;\
851     }\
852     tmp -= tmpStride*(h+5-2);\
853     for(i=0; i<w; i++)\
854     {\
855         const int tmpB= tmp[-2*tmpStride] - pad;\
856         const int tmpA= tmp[-1*tmpStride] - pad;\
857         const int tmp0= tmp[0 *tmpStride] - pad;\
858         const int tmp1= tmp[1 *tmpStride] - pad;\
859         const int tmp2= tmp[2 *tmpStride] - pad;\
860         const int tmp3= tmp[3 *tmpStride] - pad;\
861         const int tmp4= tmp[4 *tmpStride] - pad;\
862         OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
863         OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
864         dst++;\
865         tmp++;\
866     }\
867 }\
868 static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
869     const int h=4;\
870     INIT_CLIP\
871     int i;\
872     pixel *dst = (pixel*)p_dst;\
873     pixel *src = (pixel*)p_src;\
874     dstStride >>= sizeof(pixel)-1;\
875     srcStride >>= sizeof(pixel)-1;\
876     for(i=0; i<h; i++)\
877     {\
878         OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
879         OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
880         OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
881         OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
882         dst+=dstStride;\
883         src+=srcStride;\
884     }\
885 }\
886 \
887 static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
888     const int w=4;\
889     INIT_CLIP\
890     int i;\
891     pixel *dst = (pixel*)p_dst;\
892     pixel *src = (pixel*)p_src;\
893     dstStride >>= sizeof(pixel)-1;\
894     srcStride >>= sizeof(pixel)-1;\
895     for(i=0; i<w; i++)\
896     {\
897         const int srcB= src[-2*srcStride];\
898         const int srcA= src[-1*srcStride];\
899         const int src0= src[0 *srcStride];\
900         const int src1= src[1 *srcStride];\
901         const int src2= src[2 *srcStride];\
902         const int src3= src[3 *srcStride];\
903         const int src4= src[4 *srcStride];\
904         const int src5= src[5 *srcStride];\
905         const int src6= src[6 *srcStride];\
906         OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
907         OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
908         OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
909         OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
910         dst++;\
911         src++;\
912     }\
913 }\
914 \
915 static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
916     const int h=4;\
917     const int w=4;\
918     const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
919     INIT_CLIP\
920     int i;\
921     pixel *dst = (pixel*)p_dst;\
922     pixel *src = (pixel*)p_src;\
923     dstStride >>= sizeof(pixel)-1;\
924     srcStride >>= sizeof(pixel)-1;\
925     src -= 2*srcStride;\
926     for(i=0; i<h+5; i++)\
927     {\
928         tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
929         tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
930         tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]) + pad;\
931         tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]) + pad;\
932         tmp+=tmpStride;\
933         src+=srcStride;\
934     }\
935     tmp -= tmpStride*(h+5-2);\
936     for(i=0; i<w; i++)\
937     {\
938         const int tmpB= tmp[-2*tmpStride] - pad;\
939         const int tmpA= tmp[-1*tmpStride] - pad;\
940         const int tmp0= tmp[0 *tmpStride] - pad;\
941         const int tmp1= tmp[1 *tmpStride] - pad;\
942         const int tmp2= tmp[2 *tmpStride] - pad;\
943         const int tmp3= tmp[3 *tmpStride] - pad;\
944         const int tmp4= tmp[4 *tmpStride] - pad;\
945         const int tmp5= tmp[5 *tmpStride] - pad;\
946         const int tmp6= tmp[6 *tmpStride] - pad;\
947         OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
948         OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
949         OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
950         OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
951         dst++;\
952         tmp++;\
953     }\
954 }\
955 \
956 static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
957     const int h=8;\
958     INIT_CLIP\
959     int i;\
960     pixel *dst = (pixel*)p_dst;\
961     pixel *src = (pixel*)p_src;\
962     dstStride >>= sizeof(pixel)-1;\
963     srcStride >>= sizeof(pixel)-1;\
964     for(i=0; i<h; i++)\
965     {\
966         OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
967         OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
968         OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
969         OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
970         OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
971         OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
972         OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
973         OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
974         dst+=dstStride;\
975         src+=srcStride;\
976     }\
977 }\
978 \
979 static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
980     const int w=8;\
981     INIT_CLIP\
982     int i;\
983     pixel *dst = (pixel*)p_dst;\
984     pixel *src = (pixel*)p_src;\
985     dstStride >>= sizeof(pixel)-1;\
986     srcStride >>= sizeof(pixel)-1;\
987     for(i=0; i<w; i++)\
988     {\
989         const int srcB= src[-2*srcStride];\
990         const int srcA= src[-1*srcStride];\
991         const int src0= src[0 *srcStride];\
992         const int src1= src[1 *srcStride];\
993         const int src2= src[2 *srcStride];\
994         const int src3= src[3 *srcStride];\
995         const int src4= src[4 *srcStride];\
996         const int src5= src[5 *srcStride];\
997         const int src6= src[6 *srcStride];\
998         const int src7= src[7 *srcStride];\
999         const int src8= src[8 *srcStride];\
1000         const int src9= src[9 *srcStride];\
1001         const int src10=src[10*srcStride];\
1002         OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
1003         OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
1004         OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
1005         OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
1006         OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
1007         OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
1008         OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
1009         OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
1010         dst++;\
1011         src++;\
1012     }\
1013 }\
1014 \
1015 static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
1016     const int h=8;\
1017     const int w=8;\
1018     const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
1019     INIT_CLIP\
1020     int i;\
1021     pixel *dst = (pixel*)p_dst;\
1022     pixel *src = (pixel*)p_src;\
1023     dstStride >>= sizeof(pixel)-1;\
1024     srcStride >>= sizeof(pixel)-1;\
1025     src -= 2*srcStride;\
1026     for(i=0; i<h+5; i++)\
1027     {\
1028         tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]) + pad;\
1029         tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]) + pad;\
1030         tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]) + pad;\
1031         tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]) + pad;\
1032         tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]) + pad;\
1033         tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]) + pad;\
1034         tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]) + pad;\
1035         tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]) + pad;\
1036         tmp+=tmpStride;\
1037         src+=srcStride;\
1038     }\
1039     tmp -= tmpStride*(h+5-2);\
1040     for(i=0; i<w; i++)\
1041     {\
1042         const int tmpB= tmp[-2*tmpStride] - pad;\
1043         const int tmpA= tmp[-1*tmpStride] - pad;\
1044         const int tmp0= tmp[0 *tmpStride] - pad;\
1045         const int tmp1= tmp[1 *tmpStride] - pad;\
1046         const int tmp2= tmp[2 *tmpStride] - pad;\
1047         const int tmp3= tmp[3 *tmpStride] - pad;\
1048         const int tmp4= tmp[4 *tmpStride] - pad;\
1049         const int tmp5= tmp[5 *tmpStride] - pad;\
1050         const int tmp6= tmp[6 *tmpStride] - pad;\
1051         const int tmp7= tmp[7 *tmpStride] - pad;\
1052         const int tmp8= tmp[8 *tmpStride] - pad;\
1053         const int tmp9= tmp[9 *tmpStride] - pad;\
1054         const int tmp10=tmp[10*tmpStride] - pad;\
1055         OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
1056         OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
1057         OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
1058         OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
1059         OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
1060         OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
1061         OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
1062         OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
1063         dst++;\
1064         tmp++;\
1065     }\
1066 }\
1067 \
1068 static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1069     FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst                , src                , dstStride, srcStride);\
1070     FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1071     src += 8*srcStride;\
1072     dst += 8*dstStride;\
1073     FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst                , src                , dstStride, srcStride);\
1074     FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1075 }\
1076 \
1077 static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1078     FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst                , src                , dstStride, srcStride);\
1079     FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1080     src += 8*srcStride;\
1081     dst += 8*dstStride;\
1082     FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst                , src                , dstStride, srcStride);\
1083     FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1084 }\
1085 \
1086 static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
1087     FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst                , tmp  , src                , dstStride, tmpStride, srcStride);\
1088     FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
1089     src += 8*srcStride;\
1090     dst += 8*dstStride;\
1091     FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst                , tmp  , src                , dstStride, tmpStride, srcStride);\
1092     FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
1093 }\
1094
1095 #define H264_MC(OPNAME, SIZE) \
1096 static av_unused void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, uint8_t *src, int stride){\
1097     FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
1098 }\
1099 \
1100 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, uint8_t *src, int stride){\
1101     uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1102     FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
1103     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
1104 }\
1105 \
1106 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, uint8_t *src, int stride){\
1107     FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
1108 }\
1109 \
1110 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, uint8_t *src, int stride){\
1111     uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1112     FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
1113     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
1114 }\
1115 \
1116 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, uint8_t *src, int stride){\
1117     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1118     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1119     uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1120     FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel),  stride, SIZE + 5);\
1121     FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1122     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1123 }\
1124 \
1125 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, uint8_t *src, int stride){\
1126     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1127     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1128     FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel),  stride, SIZE + 5);\
1129     FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
1130 }\
1131 \
1132 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, uint8_t *src, int stride){\
1133     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1134     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1135     uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1136     FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel),  stride, SIZE + 5);\
1137     FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1138     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1139 }\
1140 \
1141 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, uint8_t *src, int stride){\
1142     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1143     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1144     uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1145     uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1146     FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1147     FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel),  stride, SIZE + 5);\
1148     FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1149     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1150 }\
1151 \
1152 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, uint8_t *src, int stride){\
1153     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1154     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1155     uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1156     uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1157     FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1158     FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel),  stride, SIZE + 5);\
1159     FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1160     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1161 }\
1162 \
1163 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, uint8_t *src, int stride){\
1164     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1165     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1166     uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1167     uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1168     FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1169     FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel),  stride, SIZE + 5);\
1170     FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1171     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1172 }\
1173 \
1174 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, uint8_t *src, int stride){\
1175     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1176     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1177     uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1178     uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1179     FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1180     FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel),  stride, SIZE + 5);\
1181     FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1182     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1183 }\
1184 \
1185 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, uint8_t *src, int stride){\
1186     pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1187     FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
1188 }\
1189 \
1190 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, uint8_t *src, int stride){\
1191     pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1192     uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1193     uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1194     FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1195     FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1196     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1197 }\
1198 \
1199 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, uint8_t *src, int stride){\
1200     pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1201     uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1202     uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1203     FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1204     FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1205     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1206 }\
1207 \
1208 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, uint8_t *src, int stride){\
1209     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1210     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1211     pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1212     uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1213     uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1214     FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel),  stride, SIZE + 5);\
1215     FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1216     FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1217     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1218 }\
1219 \
1220 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, uint8_t *src, int stride){\
1221     uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1222     uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1223     pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1224     uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1225     uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1226     FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel),  stride, SIZE + 5);\
1227     FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1228     FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1229     FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1230 }\
1231
1232 #define op_avg(a, b)  a = (((a)+CLIP(((b) + 16)>>5)+1)>>1)
1233 //#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
1234 #define op_put(a, b)  a = CLIP(((b) + 16)>>5)
1235 #define op2_avg(a, b)  a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
1236 #define op2_put(a, b)  a = CLIP(((b) + 512)>>10)
1237
1238 H264_LOWPASS(put_       , op_put, op2_put)
1239 H264_LOWPASS(avg_       , op_avg, op2_avg)
1240 H264_MC(put_, 2)
1241 H264_MC(put_, 4)
1242 H264_MC(put_, 8)
1243 H264_MC(put_, 16)
1244 H264_MC(avg_, 4)
1245 H264_MC(avg_, 8)
1246 H264_MC(avg_, 16)
1247
1248 #undef op_avg
1249 #undef op_put
1250 #undef op2_avg
1251 #undef op2_put
1252
1253 #if BIT_DEPTH == 8
1254 #   define put_h264_qpel8_mc00_8_c  ff_put_pixels8x8_8_c
1255 #   define avg_h264_qpel8_mc00_8_c  ff_avg_pixels8x8_8_c
1256 #   define put_h264_qpel16_mc00_8_c ff_put_pixels16x16_8_c
1257 #   define avg_h264_qpel16_mc00_8_c ff_avg_pixels16x16_8_c
1258 #elif BIT_DEPTH == 9
1259 #   define put_h264_qpel8_mc00_9_c  ff_put_pixels8x8_9_c
1260 #   define avg_h264_qpel8_mc00_9_c  ff_avg_pixels8x8_9_c
1261 #   define put_h264_qpel16_mc00_9_c ff_put_pixels16x16_9_c
1262 #   define avg_h264_qpel16_mc00_9_c ff_avg_pixels16x16_9_c
1263 #elif BIT_DEPTH == 10
1264 #   define put_h264_qpel8_mc00_10_c  ff_put_pixels8x8_10_c
1265 #   define avg_h264_qpel8_mc00_10_c  ff_avg_pixels8x8_10_c
1266 #   define put_h264_qpel16_mc00_10_c ff_put_pixels16x16_10_c
1267 #   define avg_h264_qpel16_mc00_10_c ff_avg_pixels16x16_10_c
1268 #elif BIT_DEPTH == 12
1269 #   define put_h264_qpel8_mc00_12_c  ff_put_pixels8x8_12_c
1270 #   define avg_h264_qpel8_mc00_12_c  ff_avg_pixels8x8_12_c
1271 #   define put_h264_qpel16_mc00_12_c ff_put_pixels16x16_12_c
1272 #   define avg_h264_qpel16_mc00_12_c ff_avg_pixels16x16_12_c
1273 #elif BIT_DEPTH == 14
1274 #   define put_h264_qpel8_mc00_14_c  ff_put_pixels8x8_14_c
1275 #   define avg_h264_qpel8_mc00_14_c  ff_avg_pixels8x8_14_c
1276 #   define put_h264_qpel16_mc00_14_c ff_put_pixels16x16_14_c
1277 #   define avg_h264_qpel16_mc00_14_c ff_avg_pixels16x16_14_c
1278 #endif
1279
1280 void FUNCC(ff_put_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1281     FUNCC(put_pixels8)(dst, src, stride, 8);
1282 }
1283 void FUNCC(ff_avg_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1284     FUNCC(avg_pixels8)(dst, src, stride, 8);
1285 }
1286 void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1287     FUNCC(put_pixels16)(dst, src, stride, 16);
1288 }
1289 void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1290     FUNCC(avg_pixels16)(dst, src, stride, 16);
1291 }
1292