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-= src_y*linesize;
135 src+= (h-1)*linesize;
137 }else if(src_y<=-block_h){
138 src-= src_y*linesize;
139 src+= (1-block_h)*linesize;
143 src+= (w-1-src_x)*sizeof(pixel);
145 }else if(src_x<=-block_w){
146 src+= (1-block_w-src_x)*sizeof(pixel);
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);
158 src += start_y*linesize + start_x*sizeof(pixel);
159 buf += start_x*sizeof(pixel);
162 for(y=0; y<start_y; y++){
163 memcpy(buf, src, w*sizeof(pixel));
167 // copy existing part
169 memcpy(buf, src, w*sizeof(pixel));
176 for(; y<block_h; y++){
177 memcpy(buf, src, w*sizeof(pixel));
181 buf -= block_h * linesize + start_x*sizeof(pixel);
183 pixel *bufp = (pixel*)buf;
185 for(x=0; x<start_x; x++){
186 bufp[x] = bufp[start_x];
190 for(x=end_x; x<block_w; x++){
191 bufp[x] = bufp[end_x - 1];
197 #define DCTELEM_FUNCS(dctcoef, suffix) \
198 static void FUNCC(get_pixels ## suffix)(DCTELEM *av_restrict _block, \
199 const uint8_t *_pixels, \
202 const pixel *pixels = (const pixel *) _pixels; \
203 dctcoef *av_restrict block = (dctcoef *) _block; \
206 /* read the pixels */ \
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); \
221 static void FUNCC(add_pixels8 ## suffix)(uint8_t *av_restrict _pixels, \
226 pixel *av_restrict pixels = (pixel *av_restrict)_pixels; \
227 dctcoef *block = (dctcoef*)_block; \
228 line_size /= sizeof(pixel); \
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; \
244 static void FUNCC(add_pixels4 ## suffix)(uint8_t *av_restrict _pixels, \
249 pixel *av_restrict pixels = (pixel *av_restrict)_pixels; \
250 dctcoef *block = (dctcoef*)_block; \
251 line_size /= sizeof(pixel); \
254 pixels[0] += block[0]; \
255 pixels[1] += block[1]; \
256 pixels[2] += block[2]; \
257 pixels[3] += block[3]; \
258 pixels += line_size; \
263 static void FUNCC(clear_block ## suffix)(DCTELEM *block) \
265 memset(block, 0, sizeof(dctcoef)*64); \
269 * memset(blocks, 0, sizeof(DCTELEM)*6*64) \
271 static void FUNCC(clear_blocks ## suffix)(DCTELEM *blocks) \
273 memset(blocks, 0, sizeof(dctcoef)*6*64); \
276 DCTELEM_FUNCS(DCTELEM, _16)
278 DCTELEM_FUNCS(dctcoef, _32)
281 #define PIXOP2(OPNAME, OP) \
282 static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
285 OP(*((pixel2*)(block )), AV_RN2P(pixels ));\
290 static void FUNCC(OPNAME ## _pixels4)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
293 OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
298 static void FUNCC(OPNAME ## _pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
301 OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
302 OP(*((pixel4*)(block+4*sizeof(pixel))), AV_RN4P(pixels+4*sizeof(pixel)));\
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);\
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){\
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));\
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){\
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));\
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){\
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));\
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){\
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));\
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);\
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);\
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);\
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);\
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);\
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);\
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 */\
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)\
402 h0= ((a&0xFCFCFCFCUL)>>2)\
403 + ((b&0xFCFCFCFCUL)>>2);\
404 l1= (c&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)\
416 h0= ((a&0xFCFCFCFCUL)>>2)\
417 + ((b&0xFCFCFCFCUL)>>2);\
418 l1= (c&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));\
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);\
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);\
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);\
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);\
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*/\
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)\
455 h0= ((a&0xFCFCFCFCUL)>>2)\
456 + ((b&0xFCFCFCFCUL)>>2);\
457 l1= (c&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)\
469 h0= ((a&0xFCFCFCFCUL)>>2)\
470 + ((b&0xFCFCFCFCUL)>>2);\
471 l1= (c&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));\
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);\
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);\
489 static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *p_block, const uint8_t *p_pixels, int line_size, int h)\
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;\
501 for(i=0; i<h; i+=2){\
507 block[0]= (a1+a0)>>2; /* FIXME non put */\
508 block[1]= (b1+b0)>>2;\
518 block[0]= (a1+a0)>>2;\
519 block[1]= (b1+b0)>>2;\
525 static inline void FUNCC(OPNAME ## _pixels4_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
527 /* FIXME HIGH BIT DEPTH */\
529 const uint32_t a= AV_RN32(pixels );\
530 const uint32_t b= AV_RN32(pixels+1);\
531 uint32_t l0= (a&0x03030303UL)\
534 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
535 + ((b&0xFCFCFCFCUL)>>2);\
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)\
544 h1= ((a&0xFCFCFCFCUL)>>2)\
545 + ((b&0xFCFCFCFCUL)>>2);\
546 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
549 a= AV_RN32(pixels );\
550 b= AV_RN32(pixels+1);\
551 l0= (a&0x03030303UL)\
554 h0= ((a&0xFCFCFCFCUL)>>2)\
555 + ((b&0xFCFCFCFCUL)>>2);\
556 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
562 static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
564 /* FIXME HIGH BIT DEPTH */\
568 const uint32_t a= AV_RN32(pixels );\
569 const uint32_t b= AV_RN32(pixels+1);\
570 uint32_t l0= (a&0x03030303UL)\
573 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
574 + ((b&0xFCFCFCFCUL)>>2);\
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)\
583 h1= ((a&0xFCFCFCFCUL)>>2)\
584 + ((b&0xFCFCFCFCUL)>>2);\
585 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
588 a= AV_RN32(pixels );\
589 b= AV_RN32(pixels+1);\
590 l0= (a&0x03030303UL)\
593 h0= ((a&0xFCFCFCFCUL)>>2)\
594 + ((b&0xFCFCFCFCUL)>>2);\
595 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
599 pixels+=4-line_size*(h+1);\
600 block +=4-line_size*h;\
604 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
606 /* FIXME HIGH BIT DEPTH */\
610 const uint32_t a= AV_RN32(pixels );\
611 const uint32_t b= AV_RN32(pixels+1);\
612 uint32_t l0= (a&0x03030303UL)\
615 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
616 + ((b&0xFCFCFCFCUL)>>2);\
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)\
625 h1= ((a&0xFCFCFCFCUL)>>2)\
626 + ((b&0xFCFCFCFCUL)>>2);\
627 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
630 a= AV_RN32(pixels );\
631 b= AV_RN32(pixels+1);\
632 l0= (a&0x03030303UL)\
635 h0= ((a&0xFCFCFCFCUL)>>2)\
636 + ((b&0xFCFCFCFCUL)>>2);\
637 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
641 pixels+=4-line_size*(h+1);\
642 block +=4-line_size*h;\
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))\
655 #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
656 #define op_put(a, b) a = b
663 #define put_no_rnd_pixels8_c put_pixels8_c
664 #define put_no_rnd_pixels16_c put_pixels16_c
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);
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);
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);\
683 stride >>= sizeof(pixel)-1;\
685 av_assert2(x<8 && y<8 && x>=0 && y>=0);\
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]));\
696 const int step= C ? stride : 1;\
698 OP(dst[0], (A*src[0] + E*src[step+0]));\
699 OP(dst[1], (A*src[1] + E*src[step+1]));\
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);\
714 stride >>= sizeof(pixel)-1;\
716 av_assert2(x<8 && y<8 && x>=0 && y>=0);\
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]));\
729 const int step= C ? stride : 1;\
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]));\
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);\
749 stride >>= sizeof(pixel)-1;\
751 av_assert2(x<8 && y<8 && x>=0 && y>=0);\
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]));\
768 const int step= C ? stride : 1;\
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]));\
784 #define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
785 #define op_put(a, b) a = (((b) + 32)>>6)
787 H264_CHROMA_MC(put_ , op_put)
788 H264_CHROMA_MC(avg_ , op_avg)
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){\
797 pixel *dst = (pixel*)p_dst;\
798 pixel *src = (pixel*)p_src;\
799 dstStride >>= sizeof(pixel)-1;\
800 srcStride >>= sizeof(pixel)-1;\
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]));\
810 static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
814 pixel *dst = (pixel*)p_dst;\
815 pixel *src = (pixel*)p_src;\
816 dstStride >>= sizeof(pixel)-1;\
817 srcStride >>= sizeof(pixel)-1;\
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));\
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){\
837 const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
840 pixel *dst = (pixel*)p_dst;\
841 pixel *src = (pixel*)p_src;\
842 dstStride >>= sizeof(pixel)-1;\
843 srcStride >>= sizeof(pixel)-1;\
845 for(i=0; i<h+5; i++)\
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;\
852 tmp -= tmpStride*(h+5-2);\
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));\
868 static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
872 pixel *dst = (pixel*)p_dst;\
873 pixel *src = (pixel*)p_src;\
874 dstStride >>= sizeof(pixel)-1;\
875 srcStride >>= sizeof(pixel)-1;\
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]));\
887 static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
891 pixel *dst = (pixel*)p_dst;\
892 pixel *src = (pixel*)p_src;\
893 dstStride >>= sizeof(pixel)-1;\
894 srcStride >>= sizeof(pixel)-1;\
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));\
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){\
918 const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
921 pixel *dst = (pixel*)p_dst;\
922 pixel *src = (pixel*)p_src;\
923 dstStride >>= sizeof(pixel)-1;\
924 srcStride >>= sizeof(pixel)-1;\
926 for(i=0; i<h+5; i++)\
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;\
935 tmp -= tmpStride*(h+5-2);\
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));\
956 static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
960 pixel *dst = (pixel*)p_dst;\
961 pixel *src = (pixel*)p_src;\
962 dstStride >>= sizeof(pixel)-1;\
963 srcStride >>= sizeof(pixel)-1;\
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]));\
979 static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
983 pixel *dst = (pixel*)p_dst;\
984 pixel *src = (pixel*)p_src;\
985 dstStride >>= sizeof(pixel)-1;\
986 srcStride >>= sizeof(pixel)-1;\
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));\
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){\
1018 const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
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++)\
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;\
1039 tmp -= tmpStride*(h+5-2);\
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));\
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);\
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);\
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);\
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);\
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);\
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);\
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);\
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);\
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));\
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);\
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);\
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);\
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);\
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);\
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);\
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);\
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);\
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);\
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);\
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)
1238 H264_LOWPASS(put_ , op_put, op2_put)
1239 H264_LOWPASS(avg_ , op_avg, op2_avg)
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
1280 void FUNCC(ff_put_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1281 FUNCC(put_pixels8)(dst, src, stride, 8);
1283 void FUNCC(ff_avg_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1284 FUNCC(avg_pixels8)(dst, src, stride, 8);
1286 void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1287 FUNCC(put_pixels16)(dst, src, stride, 16);
1289 void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1290 FUNCC(avg_pixels16)(dst, src, stride, 16);