3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
8 * This file is part of FFmpeg.
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.
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.
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
30 #include "bit_depth_template.c"
32 static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
37 AV_WN2P(dst , AV_RN2P(src ));
43 static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
48 AV_WN4P(dst , AV_RN4P(src ));
54 static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
59 AV_WN4P(dst , AV_RN4P(src ));
60 AV_WN4P(dst+4*sizeof(pixel), AV_RN4P(src+4*sizeof(pixel)));
66 static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
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)));
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)
84 pixel *buf = (pixel*)p_buf;
85 int wrap = p_wrap / sizeof(pixel);
86 pixel *ptr, *last_line;
91 for(i=0;i<height;i++) {
94 for (j = 0; j < w; j++) {
96 ptr[j+width] = ptr[width-1];
99 memset(ptr - w, ptr[0], w);
100 memset(ptr + width, ptr[width-1], w);
105 /* top and bottom + corners */
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
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
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){
131 int start_y, start_x, end_y, end_x;
134 src+= (h-1-src_y)*linesize;
136 }else if(src_y<=-block_h){
137 src+= (1-block_h-src_y)*linesize;
141 src+= (w-1-src_x)*sizeof(pixel);
143 }else if(src_x<=-block_w){
144 src+= (1-block_w-src_x)*sizeof(pixel);
148 start_y= FFMAX(0, -src_y);
149 start_x= FFMAX(0, -src_x);
150 end_y= FFMIN(block_h, h-src_y);
151 end_x= FFMIN(block_w, w-src_x);
152 assert(start_y < end_y && block_h);
153 assert(start_x < end_x && block_w);
156 src += start_y*linesize + start_x*sizeof(pixel);
157 buf += start_x*sizeof(pixel);
160 for(y=0; y<start_y; y++){
161 memcpy(buf, src, w*sizeof(pixel));
165 // copy existing part
167 memcpy(buf, src, w*sizeof(pixel));
174 for(; y<block_h; y++){
175 memcpy(buf, src, w*sizeof(pixel));
179 buf -= block_h * linesize + start_x*sizeof(pixel);
181 pixel *bufp = (pixel*)buf;
183 for(x=0; x<start_x; x++){
184 bufp[x] = bufp[start_x];
188 for(x=end_x; x<block_w; x++){
189 bufp[x] = bufp[end_x - 1];
195 #define DCTELEM_FUNCS(dctcoef, suffix) \
196 static void FUNCC(get_pixels ## suffix)(DCTELEM *restrict _block, \
197 const uint8_t *_pixels, \
200 const pixel *pixels = (const pixel *) _pixels; \
201 dctcoef *restrict block = (dctcoef *) _block; \
204 /* read the pixels */ \
206 block[0] = pixels[0]; \
207 block[1] = pixels[1]; \
208 block[2] = pixels[2]; \
209 block[3] = pixels[3]; \
210 block[4] = pixels[4]; \
211 block[5] = pixels[5]; \
212 block[6] = pixels[6]; \
213 block[7] = pixels[7]; \
214 pixels += line_size / sizeof(pixel); \
219 static void FUNCC(add_pixels8 ## suffix)(uint8_t *restrict _pixels, \
224 pixel *restrict pixels = (pixel *restrict)_pixels; \
225 dctcoef *block = (dctcoef*)_block; \
226 line_size /= sizeof(pixel); \
229 pixels[0] += block[0]; \
230 pixels[1] += block[1]; \
231 pixels[2] += block[2]; \
232 pixels[3] += block[3]; \
233 pixels[4] += block[4]; \
234 pixels[5] += block[5]; \
235 pixels[6] += block[6]; \
236 pixels[7] += block[7]; \
237 pixels += line_size; \
242 static void FUNCC(add_pixels4 ## suffix)(uint8_t *restrict _pixels, \
247 pixel *restrict pixels = (pixel *restrict)_pixels; \
248 dctcoef *block = (dctcoef*)_block; \
249 line_size /= sizeof(pixel); \
252 pixels[0] += block[0]; \
253 pixels[1] += block[1]; \
254 pixels[2] += block[2]; \
255 pixels[3] += block[3]; \
256 pixels += line_size; \
261 static void FUNCC(clear_block ## suffix)(DCTELEM *block) \
263 memset(block, 0, sizeof(dctcoef)*64); \
267 * memset(blocks, 0, sizeof(DCTELEM)*6*64) \
269 static void FUNCC(clear_blocks ## suffix)(DCTELEM *blocks) \
271 memset(blocks, 0, sizeof(dctcoef)*6*64); \
274 DCTELEM_FUNCS(DCTELEM, _16)
276 DCTELEM_FUNCS(dctcoef, _32)
279 #define PIXOP2(OPNAME, OP) \
280 static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
283 OP(*((pixel2*)(block )), AV_RN2P(pixels ));\
288 static void FUNCC(OPNAME ## _pixels4)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
291 OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
296 static void FUNCC(OPNAME ## _pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
299 OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
300 OP(*((pixel4*)(block+4*sizeof(pixel))), AV_RN4P(pixels+4*sizeof(pixel)));\
305 static inline void FUNCC(OPNAME ## _no_rnd_pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
306 FUNCC(OPNAME ## _pixels8)(block, pixels, line_size, h);\
309 static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
310 int src_stride1, int src_stride2, int h){\
314 a= AV_RN4P(&src1[i*src_stride1 ]);\
315 b= AV_RN4P(&src2[i*src_stride2 ]);\
316 OP(*((pixel4*)&dst[i*dst_stride ]), no_rnd_avg_pixel4(a, b));\
317 a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
318 b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
319 OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\
323 static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
324 int src_stride1, int src_stride2, int h){\
328 a= AV_RN4P(&src1[i*src_stride1 ]);\
329 b= AV_RN4P(&src2[i*src_stride2 ]);\
330 OP(*((pixel4*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
331 a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
332 b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
333 OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), rnd_avg_pixel4(a, b));\
337 static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
338 int src_stride1, int src_stride2, int h){\
342 a= AV_RN4P(&src1[i*src_stride1 ]);\
343 b= AV_RN4P(&src2[i*src_stride2 ]);\
344 OP(*((pixel4*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
348 static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
349 int src_stride1, int src_stride2, int h){\
353 a= AV_RN2P(&src1[i*src_stride1 ]);\
354 b= AV_RN2P(&src2[i*src_stride2 ]);\
355 OP(*((pixel2*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
359 static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
360 int src_stride1, int src_stride2, int h){\
361 FUNC(OPNAME ## _pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
362 FUNC(OPNAME ## _pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
365 static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
366 int src_stride1, int src_stride2, int h){\
367 FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
368 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 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
372 FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
375 static inline void FUNCC(OPNAME ## _pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
376 FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
379 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
380 FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
383 static inline void FUNCC(OPNAME ## _pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
384 FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
387 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,\
388 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
389 /* FIXME HIGH BIT DEPTH */\
392 uint32_t a, b, c, d, l0, l1, h0, h1;\
393 a= AV_RN32(&src1[i*src_stride1]);\
394 b= AV_RN32(&src2[i*src_stride2]);\
395 c= AV_RN32(&src3[i*src_stride3]);\
396 d= AV_RN32(&src4[i*src_stride4]);\
397 l0= (a&0x03030303UL)\
400 h0= ((a&0xFCFCFCFCUL)>>2)\
401 + ((b&0xFCFCFCFCUL)>>2);\
402 l1= (c&0x03030303UL)\
404 h1= ((c&0xFCFCFCFCUL)>>2)\
405 + ((d&0xFCFCFCFCUL)>>2);\
406 OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
407 a= AV_RN32(&src1[i*src_stride1+4]);\
408 b= AV_RN32(&src2[i*src_stride2+4]);\
409 c= AV_RN32(&src3[i*src_stride3+4]);\
410 d= AV_RN32(&src4[i*src_stride4+4]);\
411 l0= (a&0x03030303UL)\
414 h0= ((a&0xFCFCFCFCUL)>>2)\
415 + ((b&0xFCFCFCFCUL)>>2);\
416 l1= (c&0x03030303UL)\
418 h1= ((c&0xFCFCFCFCUL)>>2)\
419 + ((d&0xFCFCFCFCUL)>>2);\
420 OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
424 static inline void FUNCC(OPNAME ## _pixels4_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
425 FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
428 static inline void FUNCC(OPNAME ## _pixels4_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
429 FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
432 static inline void FUNCC(OPNAME ## _pixels2_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
433 FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
436 static inline void FUNCC(OPNAME ## _pixels2_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
437 FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
440 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,\
441 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
442 /* FIXME HIGH BIT DEPTH*/\
445 uint32_t a, b, c, d, l0, l1, h0, h1;\
446 a= AV_RN32(&src1[i*src_stride1]);\
447 b= AV_RN32(&src2[i*src_stride2]);\
448 c= AV_RN32(&src3[i*src_stride3]);\
449 d= AV_RN32(&src4[i*src_stride4]);\
450 l0= (a&0x03030303UL)\
453 h0= ((a&0xFCFCFCFCUL)>>2)\
454 + ((b&0xFCFCFCFCUL)>>2);\
455 l1= (c&0x03030303UL)\
457 h1= ((c&0xFCFCFCFCUL)>>2)\
458 + ((d&0xFCFCFCFCUL)>>2);\
459 OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
460 a= AV_RN32(&src1[i*src_stride1+4]);\
461 b= AV_RN32(&src2[i*src_stride2+4]);\
462 c= AV_RN32(&src3[i*src_stride3+4]);\
463 d= AV_RN32(&src4[i*src_stride4+4]);\
464 l0= (a&0x03030303UL)\
467 h0= ((a&0xFCFCFCFCUL)>>2)\
468 + ((b&0xFCFCFCFCUL)>>2);\
469 l1= (c&0x03030303UL)\
471 h1= ((c&0xFCFCFCFCUL)>>2)\
472 + ((d&0xFCFCFCFCUL)>>2);\
473 OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
476 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,\
477 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
478 FUNC(OPNAME ## _pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
479 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);\
481 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,\
482 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
483 FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
484 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 static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *p_block, const uint8_t *p_pixels, int line_size, int h)\
489 int i, a0, b0, a1, b1;\
490 pixel *block = (pixel*)p_block;\
491 const pixel *pixels = (const pixel*)p_pixels;\
492 line_size >>= sizeof(pixel)-1;\
499 for(i=0; i<h; i+=2){\
505 block[0]= (a1+a0)>>2; /* FIXME non put */\
506 block[1]= (b1+b0)>>2;\
516 block[0]= (a1+a0)>>2;\
517 block[1]= (b1+b0)>>2;\
523 static inline void FUNCC(OPNAME ## _pixels4_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
525 /* FIXME HIGH BIT DEPTH */\
527 const uint32_t a= AV_RN32(pixels );\
528 const uint32_t b= AV_RN32(pixels+1);\
529 uint32_t l0= (a&0x03030303UL)\
532 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
533 + ((b&0xFCFCFCFCUL)>>2);\
537 for(i=0; i<h; i+=2){\
538 uint32_t a= AV_RN32(pixels );\
539 uint32_t b= AV_RN32(pixels+1);\
540 l1= (a&0x03030303UL)\
542 h1= ((a&0xFCFCFCFCUL)>>2)\
543 + ((b&0xFCFCFCFCUL)>>2);\
544 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
547 a= AV_RN32(pixels );\
548 b= AV_RN32(pixels+1);\
549 l0= (a&0x03030303UL)\
552 h0= ((a&0xFCFCFCFCUL)>>2)\
553 + ((b&0xFCFCFCFCUL)>>2);\
554 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
560 static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
562 /* FIXME HIGH BIT DEPTH */\
566 const uint32_t a= AV_RN32(pixels );\
567 const uint32_t b= AV_RN32(pixels+1);\
568 uint32_t l0= (a&0x03030303UL)\
571 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
572 + ((b&0xFCFCFCFCUL)>>2);\
576 for(i=0; i<h; i+=2){\
577 uint32_t a= AV_RN32(pixels );\
578 uint32_t b= AV_RN32(pixels+1);\
579 l1= (a&0x03030303UL)\
581 h1= ((a&0xFCFCFCFCUL)>>2)\
582 + ((b&0xFCFCFCFCUL)>>2);\
583 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
586 a= AV_RN32(pixels );\
587 b= AV_RN32(pixels+1);\
588 l0= (a&0x03030303UL)\
591 h0= ((a&0xFCFCFCFCUL)>>2)\
592 + ((b&0xFCFCFCFCUL)>>2);\
593 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
597 pixels+=4-line_size*(h+1);\
598 block +=4-line_size*h;\
602 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
604 /* FIXME HIGH BIT DEPTH */\
608 const uint32_t a= AV_RN32(pixels );\
609 const uint32_t b= AV_RN32(pixels+1);\
610 uint32_t l0= (a&0x03030303UL)\
613 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
614 + ((b&0xFCFCFCFCUL)>>2);\
618 for(i=0; i<h; i+=2){\
619 uint32_t a= AV_RN32(pixels );\
620 uint32_t b= AV_RN32(pixels+1);\
621 l1= (a&0x03030303UL)\
623 h1= ((a&0xFCFCFCFCUL)>>2)\
624 + ((b&0xFCFCFCFCUL)>>2);\
625 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
628 a= AV_RN32(pixels );\
629 b= AV_RN32(pixels+1);\
630 l0= (a&0x03030303UL)\
633 h0= ((a&0xFCFCFCFCUL)>>2)\
634 + ((b&0xFCFCFCFCUL)>>2);\
635 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
639 pixels+=4-line_size*(h+1);\
640 block +=4-line_size*h;\
644 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
645 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_x2) , FUNCC(OPNAME ## _pixels8_x2) , 8*sizeof(pixel))\
646 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_y2) , FUNCC(OPNAME ## _pixels8_y2) , 8*sizeof(pixel))\
647 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\
648 av_unused CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
649 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_x2) , FUNCC(OPNAME ## _no_rnd_pixels8_x2) , 8*sizeof(pixel))\
650 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pixels8_y2) , 8*sizeof(pixel))\
651 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\
653 #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
654 #define op_put(a, b) a = b
661 #define put_no_rnd_pixels8_c put_pixels8_c
662 #define put_no_rnd_pixels16_c put_pixels16_c
664 static void FUNCC(put_no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
665 FUNC(put_no_rnd_pixels16_l2)(dst, a, b, stride, stride, stride, h);
668 static void FUNCC(put_no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
669 FUNC(put_no_rnd_pixels8_l2)(dst, a, b, stride, stride, stride, h);
672 #define H264_CHROMA_MC(OPNAME, OP)\
673 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){\
674 pixel *dst = (pixel*)p_dst;\
675 pixel *src = (pixel*)p_src;\
676 const int A=(8-x)*(8-y);\
677 const int B=( x)*(8-y);\
678 const int C=(8-x)*( y);\
679 const int D=( x)*( y);\
681 stride >>= sizeof(pixel)-1;\
683 assert(x<8 && y<8 && x>=0 && y>=0);\
687 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
688 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
694 const int step= C ? stride : 1;\
696 OP(dst[0], (A*src[0] + E*src[step+0]));\
697 OP(dst[1], (A*src[1] + E*src[step+1]));\
704 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){\
705 pixel *dst = (pixel*)p_dst;\
706 pixel *src = (pixel*)p_src;\
707 const int A=(8-x)*(8-y);\
708 const int B=( x)*(8-y);\
709 const int C=(8-x)*( y);\
710 const int D=( x)*( y);\
712 stride >>= sizeof(pixel)-1;\
714 assert(x<8 && y<8 && x>=0 && y>=0);\
718 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
719 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
720 OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
721 OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
727 const int step= C ? stride : 1;\
729 OP(dst[0], (A*src[0] + E*src[step+0]));\
730 OP(dst[1], (A*src[1] + E*src[step+1]));\
731 OP(dst[2], (A*src[2] + E*src[step+2]));\
732 OP(dst[3], (A*src[3] + E*src[step+3]));\
739 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){\
740 pixel *dst = (pixel*)p_dst;\
741 pixel *src = (pixel*)p_src;\
742 const int A=(8-x)*(8-y);\
743 const int B=( x)*(8-y);\
744 const int C=(8-x)*( y);\
745 const int D=( x)*( y);\
747 stride >>= sizeof(pixel)-1;\
749 assert(x<8 && y<8 && x>=0 && y>=0);\
753 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
754 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
755 OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
756 OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
757 OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
758 OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
759 OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
760 OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
766 const int step= C ? stride : 1;\
768 OP(dst[0], (A*src[0] + E*src[step+0]));\
769 OP(dst[1], (A*src[1] + E*src[step+1]));\
770 OP(dst[2], (A*src[2] + E*src[step+2]));\
771 OP(dst[3], (A*src[3] + E*src[step+3]));\
772 OP(dst[4], (A*src[4] + E*src[step+4]));\
773 OP(dst[5], (A*src[5] + E*src[step+5]));\
774 OP(dst[6], (A*src[6] + E*src[step+6]));\
775 OP(dst[7], (A*src[7] + E*src[step+7]));\
782 #define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
783 #define op_put(a, b) a = (((b) + 32)>>6)
785 H264_CHROMA_MC(put_ , op_put)
786 H264_CHROMA_MC(avg_ , op_avg)
790 #define H264_LOWPASS(OPNAME, OP, OP2) \
791 static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
795 pixel *dst = (pixel*)p_dst;\
796 pixel *src = (pixel*)p_src;\
797 dstStride >>= sizeof(pixel)-1;\
798 srcStride >>= sizeof(pixel)-1;\
801 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
802 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
808 static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
812 pixel *dst = (pixel*)p_dst;\
813 pixel *src = (pixel*)p_src;\
814 dstStride >>= sizeof(pixel)-1;\
815 srcStride >>= sizeof(pixel)-1;\
818 const int srcB= src[-2*srcStride];\
819 const int srcA= src[-1*srcStride];\
820 const int src0= src[0 *srcStride];\
821 const int src1= src[1 *srcStride];\
822 const int src2= src[2 *srcStride];\
823 const int src3= src[3 *srcStride];\
824 const int src4= src[4 *srcStride];\
825 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
826 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
832 static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *p_dst, int16_t *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
835 const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
838 pixel *dst = (pixel*)p_dst;\
839 pixel *src = (pixel*)p_src;\
840 dstStride >>= sizeof(pixel)-1;\
841 srcStride >>= sizeof(pixel)-1;\
843 for(i=0; i<h+5; i++)\
845 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
846 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
850 tmp -= tmpStride*(h+5-2);\
853 const int tmpB= tmp[-2*tmpStride] - pad;\
854 const int tmpA= tmp[-1*tmpStride] - pad;\
855 const int tmp0= tmp[0 *tmpStride] - pad;\
856 const int tmp1= tmp[1 *tmpStride] - pad;\
857 const int tmp2= tmp[2 *tmpStride] - pad;\
858 const int tmp3= tmp[3 *tmpStride] - pad;\
859 const int tmp4= tmp[4 *tmpStride] - pad;\
860 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
861 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
866 static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
870 pixel *dst = (pixel*)p_dst;\
871 pixel *src = (pixel*)p_src;\
872 dstStride >>= sizeof(pixel)-1;\
873 srcStride >>= sizeof(pixel)-1;\
876 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
877 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
878 OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
879 OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
885 static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
889 pixel *dst = (pixel*)p_dst;\
890 pixel *src = (pixel*)p_src;\
891 dstStride >>= sizeof(pixel)-1;\
892 srcStride >>= sizeof(pixel)-1;\
895 const int srcB= src[-2*srcStride];\
896 const int srcA= src[-1*srcStride];\
897 const int src0= src[0 *srcStride];\
898 const int src1= src[1 *srcStride];\
899 const int src2= src[2 *srcStride];\
900 const int src3= src[3 *srcStride];\
901 const int src4= src[4 *srcStride];\
902 const int src5= src[5 *srcStride];\
903 const int src6= src[6 *srcStride];\
904 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
905 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
906 OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
907 OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
913 static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *p_dst, int16_t *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
916 const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
919 pixel *dst = (pixel*)p_dst;\
920 pixel *src = (pixel*)p_src;\
921 dstStride >>= sizeof(pixel)-1;\
922 srcStride >>= sizeof(pixel)-1;\
924 for(i=0; i<h+5; i++)\
926 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
927 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
928 tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]) + pad;\
929 tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]) + pad;\
933 tmp -= tmpStride*(h+5-2);\
936 const int tmpB= tmp[-2*tmpStride] - pad;\
937 const int tmpA= tmp[-1*tmpStride] - pad;\
938 const int tmp0= tmp[0 *tmpStride] - pad;\
939 const int tmp1= tmp[1 *tmpStride] - pad;\
940 const int tmp2= tmp[2 *tmpStride] - pad;\
941 const int tmp3= tmp[3 *tmpStride] - pad;\
942 const int tmp4= tmp[4 *tmpStride] - pad;\
943 const int tmp5= tmp[5 *tmpStride] - pad;\
944 const int tmp6= tmp[6 *tmpStride] - pad;\
945 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
946 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
947 OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
948 OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
954 static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
958 pixel *dst = (pixel*)p_dst;\
959 pixel *src = (pixel*)p_src;\
960 dstStride >>= sizeof(pixel)-1;\
961 srcStride >>= sizeof(pixel)-1;\
964 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
965 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
966 OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
967 OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
968 OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
969 OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
970 OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
971 OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
977 static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
981 pixel *dst = (pixel*)p_dst;\
982 pixel *src = (pixel*)p_src;\
983 dstStride >>= sizeof(pixel)-1;\
984 srcStride >>= sizeof(pixel)-1;\
987 const int srcB= src[-2*srcStride];\
988 const int srcA= src[-1*srcStride];\
989 const int src0= src[0 *srcStride];\
990 const int src1= src[1 *srcStride];\
991 const int src2= src[2 *srcStride];\
992 const int src3= src[3 *srcStride];\
993 const int src4= src[4 *srcStride];\
994 const int src5= src[5 *srcStride];\
995 const int src6= src[6 *srcStride];\
996 const int src7= src[7 *srcStride];\
997 const int src8= src[8 *srcStride];\
998 const int src9= src[9 *srcStride];\
999 const int src10=src[10*srcStride];\
1000 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
1001 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
1002 OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
1003 OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
1004 OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
1005 OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
1006 OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
1007 OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
1013 static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *p_dst, int16_t *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
1016 const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
1019 pixel *dst = (pixel*)p_dst;\
1020 pixel *src = (pixel*)p_src;\
1021 dstStride >>= sizeof(pixel)-1;\
1022 srcStride >>= sizeof(pixel)-1;\
1023 src -= 2*srcStride;\
1024 for(i=0; i<h+5; i++)\
1026 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]) + pad;\
1027 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]) + pad;\
1028 tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]) + pad;\
1029 tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]) + pad;\
1030 tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]) + pad;\
1031 tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]) + pad;\
1032 tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]) + pad;\
1033 tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]) + pad;\
1037 tmp -= tmpStride*(h+5-2);\
1040 const int tmpB= tmp[-2*tmpStride] - pad;\
1041 const int tmpA= tmp[-1*tmpStride] - pad;\
1042 const int tmp0= tmp[0 *tmpStride] - pad;\
1043 const int tmp1= tmp[1 *tmpStride] - pad;\
1044 const int tmp2= tmp[2 *tmpStride] - pad;\
1045 const int tmp3= tmp[3 *tmpStride] - pad;\
1046 const int tmp4= tmp[4 *tmpStride] - pad;\
1047 const int tmp5= tmp[5 *tmpStride] - pad;\
1048 const int tmp6= tmp[6 *tmpStride] - pad;\
1049 const int tmp7= tmp[7 *tmpStride] - pad;\
1050 const int tmp8= tmp[8 *tmpStride] - pad;\
1051 const int tmp9= tmp[9 *tmpStride] - pad;\
1052 const int tmp10=tmp[10*tmpStride] - pad;\
1053 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
1054 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
1055 OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
1056 OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
1057 OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
1058 OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
1059 OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
1060 OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
1066 static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1067 FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
1068 FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1069 src += 8*srcStride;\
1070 dst += 8*dstStride;\
1071 FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
1072 FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1075 static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1076 FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
1077 FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1078 src += 8*srcStride;\
1079 dst += 8*dstStride;\
1080 FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
1081 FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1084 static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
1085 FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
1086 FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
1087 src += 8*srcStride;\
1088 dst += 8*dstStride;\
1089 FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
1090 FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
1093 #define H264_MC(OPNAME, SIZE) \
1094 static av_unused void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, uint8_t *src, int stride){\
1095 FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
1098 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, uint8_t *src, int stride){\
1099 uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1100 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
1101 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
1104 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, uint8_t *src, int stride){\
1105 FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
1108 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, uint8_t *src, int stride){\
1109 uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1110 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
1111 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
1114 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, uint8_t *src, int stride){\
1115 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1116 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1117 uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1118 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1119 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1120 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1123 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, uint8_t *src, int stride){\
1124 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1125 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1126 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1127 FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
1130 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, uint8_t *src, int stride){\
1131 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1132 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1133 uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1134 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1135 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1136 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1139 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, uint8_t *src, int stride){\
1140 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1141 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1142 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1143 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1144 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1145 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1146 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1147 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1150 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, uint8_t *src, int stride){\
1151 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1152 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1153 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1154 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1155 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1156 FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1157 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1158 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1161 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, uint8_t *src, int stride){\
1162 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1163 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1164 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1165 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1166 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1167 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1168 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1169 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1172 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, uint8_t *src, int stride){\
1173 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1174 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1175 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1176 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1177 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1178 FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1179 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1180 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1183 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, uint8_t *src, int stride){\
1184 int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1185 FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
1188 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, uint8_t *src, int stride){\
1189 int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1190 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1191 uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1192 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1193 FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1194 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1197 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, uint8_t *src, int stride){\
1198 int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1199 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1200 uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1201 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1202 FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1203 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1206 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, uint8_t *src, int stride){\
1207 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1208 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1209 int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1210 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1211 uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1212 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1213 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1214 FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1215 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1218 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, uint8_t *src, int stride){\
1219 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1220 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1221 int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1222 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1223 uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1224 FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1225 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1226 FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1227 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1230 #define op_avg(a, b) a = (((a)+CLIP(((b) + 16)>>5)+1)>>1)
1231 //#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
1232 #define op_put(a, b) a = CLIP(((b) + 16)>>5)
1233 #define op2_avg(a, b) a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
1234 #define op2_put(a, b) a = CLIP(((b) + 512)>>10)
1236 H264_LOWPASS(put_ , op_put, op2_put)
1237 H264_LOWPASS(avg_ , op_avg, op2_avg)
1252 # define put_h264_qpel8_mc00_8_c ff_put_pixels8x8_8_c
1253 # define avg_h264_qpel8_mc00_8_c ff_avg_pixels8x8_8_c
1254 # define put_h264_qpel16_mc00_8_c ff_put_pixels16x16_8_c
1255 # define avg_h264_qpel16_mc00_8_c ff_avg_pixels16x16_8_c
1256 #elif BIT_DEPTH == 9
1257 # define put_h264_qpel8_mc00_9_c ff_put_pixels8x8_9_c
1258 # define avg_h264_qpel8_mc00_9_c ff_avg_pixels8x8_9_c
1259 # define put_h264_qpel16_mc00_9_c ff_put_pixels16x16_9_c
1260 # define avg_h264_qpel16_mc00_9_c ff_avg_pixels16x16_9_c
1261 #elif BIT_DEPTH == 10
1262 # define put_h264_qpel8_mc00_10_c ff_put_pixels8x8_10_c
1263 # define avg_h264_qpel8_mc00_10_c ff_avg_pixels8x8_10_c
1264 # define put_h264_qpel16_mc00_10_c ff_put_pixels16x16_10_c
1265 # define avg_h264_qpel16_mc00_10_c ff_avg_pixels16x16_10_c
1268 void FUNCC(ff_put_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1269 FUNCC(put_pixels8)(dst, src, stride, 8);
1271 void FUNCC(ff_avg_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1272 FUNCC(avg_pixels8)(dst, src, stride, 8);
1274 void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1275 FUNCC(put_pixels16)(dst, src, stride, 16);
1277 void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1278 FUNCC(avg_pixels16)(dst, src, stride, 16);