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
116 #define DCTELEM_FUNCS(dctcoef, suffix) \
117 static void FUNCC(get_pixels ## suffix)(DCTELEM *av_restrict _block, \
118 const uint8_t *_pixels, \
121 const pixel *pixels = (const pixel *) _pixels; \
122 dctcoef *av_restrict block = (dctcoef *) _block; \
125 /* read the pixels */ \
127 block[0] = pixels[0]; \
128 block[1] = pixels[1]; \
129 block[2] = pixels[2]; \
130 block[3] = pixels[3]; \
131 block[4] = pixels[4]; \
132 block[5] = pixels[5]; \
133 block[6] = pixels[6]; \
134 block[7] = pixels[7]; \
135 pixels += line_size / sizeof(pixel); \
140 static void FUNCC(add_pixels8 ## suffix)(uint8_t *av_restrict _pixels, \
145 pixel *av_restrict pixels = (pixel *av_restrict)_pixels; \
146 dctcoef *block = (dctcoef*)_block; \
147 line_size /= sizeof(pixel); \
150 pixels[0] += block[0]; \
151 pixels[1] += block[1]; \
152 pixels[2] += block[2]; \
153 pixels[3] += block[3]; \
154 pixels[4] += block[4]; \
155 pixels[5] += block[5]; \
156 pixels[6] += block[6]; \
157 pixels[7] += block[7]; \
158 pixels += line_size; \
163 static void FUNCC(add_pixels4 ## suffix)(uint8_t *av_restrict _pixels, \
168 pixel *av_restrict pixels = (pixel *av_restrict)_pixels; \
169 dctcoef *block = (dctcoef*)_block; \
170 line_size /= sizeof(pixel); \
173 pixels[0] += block[0]; \
174 pixels[1] += block[1]; \
175 pixels[2] += block[2]; \
176 pixels[3] += block[3]; \
177 pixels += line_size; \
182 static void FUNCC(clear_block ## suffix)(DCTELEM *block) \
184 memset(block, 0, sizeof(dctcoef)*64); \
188 * memset(blocks, 0, sizeof(DCTELEM)*6*64) \
190 static void FUNCC(clear_blocks ## suffix)(DCTELEM *blocks) \
192 memset(blocks, 0, sizeof(dctcoef)*6*64); \
195 DCTELEM_FUNCS(DCTELEM, _16)
197 DCTELEM_FUNCS(dctcoef, _32)
200 #define PIXOP2(OPNAME, OP) \
201 static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
204 OP(*((pixel2*)(block )), AV_RN2P(pixels ));\
209 static void FUNCC(OPNAME ## _pixels4)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
212 OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
217 static void FUNCC(OPNAME ## _pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
220 OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
221 OP(*((pixel4*)(block+4*sizeof(pixel))), AV_RN4P(pixels+4*sizeof(pixel)));\
226 static inline void FUNCC(OPNAME ## _no_rnd_pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
227 FUNCC(OPNAME ## _pixels8)(block, pixels, line_size, h);\
230 static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
231 int src_stride1, int src_stride2, int h){\
235 a= AV_RN4P(&src1[i*src_stride1 ]);\
236 b= AV_RN4P(&src2[i*src_stride2 ]);\
237 OP(*((pixel4*)&dst[i*dst_stride ]), no_rnd_avg_pixel4(a, b));\
238 a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
239 b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
240 OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\
244 static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
245 int src_stride1, int src_stride2, int h){\
249 a= AV_RN4P(&src1[i*src_stride1 ]);\
250 b= AV_RN4P(&src2[i*src_stride2 ]);\
251 OP(*((pixel4*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
252 a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
253 b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
254 OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), rnd_avg_pixel4(a, b));\
258 static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
259 int src_stride1, int src_stride2, int h){\
263 a= AV_RN4P(&src1[i*src_stride1 ]);\
264 b= AV_RN4P(&src2[i*src_stride2 ]);\
265 OP(*((pixel4*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
269 static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
270 int src_stride1, int src_stride2, int h){\
274 a= AV_RN2P(&src1[i*src_stride1 ]);\
275 b= AV_RN2P(&src2[i*src_stride2 ]);\
276 OP(*((pixel2*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
280 static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
281 int src_stride1, int src_stride2, int h){\
282 FUNC(OPNAME ## _pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
283 FUNC(OPNAME ## _pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
286 static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
287 int src_stride1, int src_stride2, int h){\
288 FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
289 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);\
292 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
293 FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
296 static inline void FUNCC(OPNAME ## _pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
297 FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
300 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
301 FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
304 static inline void FUNCC(OPNAME ## _pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
305 FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
308 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,\
309 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
310 /* FIXME HIGH BIT DEPTH */\
313 uint32_t a, b, c, d, l0, l1, h0, h1;\
314 a= AV_RN32(&src1[i*src_stride1]);\
315 b= AV_RN32(&src2[i*src_stride2]);\
316 c= AV_RN32(&src3[i*src_stride3]);\
317 d= AV_RN32(&src4[i*src_stride4]);\
318 l0= (a&0x03030303UL)\
321 h0= ((a&0xFCFCFCFCUL)>>2)\
322 + ((b&0xFCFCFCFCUL)>>2);\
323 l1= (c&0x03030303UL)\
325 h1= ((c&0xFCFCFCFCUL)>>2)\
326 + ((d&0xFCFCFCFCUL)>>2);\
327 OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
328 a= AV_RN32(&src1[i*src_stride1+4]);\
329 b= AV_RN32(&src2[i*src_stride2+4]);\
330 c= AV_RN32(&src3[i*src_stride3+4]);\
331 d= AV_RN32(&src4[i*src_stride4+4]);\
332 l0= (a&0x03030303UL)\
335 h0= ((a&0xFCFCFCFCUL)>>2)\
336 + ((b&0xFCFCFCFCUL)>>2);\
337 l1= (c&0x03030303UL)\
339 h1= ((c&0xFCFCFCFCUL)>>2)\
340 + ((d&0xFCFCFCFCUL)>>2);\
341 OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
345 static inline void FUNCC(OPNAME ## _pixels4_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
346 FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
349 static inline void FUNCC(OPNAME ## _pixels4_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
350 FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
353 static inline void FUNCC(OPNAME ## _pixels2_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
354 FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
357 static inline void FUNCC(OPNAME ## _pixels2_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
358 FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
361 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,\
362 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
363 /* FIXME HIGH BIT DEPTH*/\
366 uint32_t a, b, c, d, l0, l1, h0, h1;\
367 a= AV_RN32(&src1[i*src_stride1]);\
368 b= AV_RN32(&src2[i*src_stride2]);\
369 c= AV_RN32(&src3[i*src_stride3]);\
370 d= AV_RN32(&src4[i*src_stride4]);\
371 l0= (a&0x03030303UL)\
374 h0= ((a&0xFCFCFCFCUL)>>2)\
375 + ((b&0xFCFCFCFCUL)>>2);\
376 l1= (c&0x03030303UL)\
378 h1= ((c&0xFCFCFCFCUL)>>2)\
379 + ((d&0xFCFCFCFCUL)>>2);\
380 OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
381 a= AV_RN32(&src1[i*src_stride1+4]);\
382 b= AV_RN32(&src2[i*src_stride2+4]);\
383 c= AV_RN32(&src3[i*src_stride3+4]);\
384 d= AV_RN32(&src4[i*src_stride4+4]);\
385 l0= (a&0x03030303UL)\
388 h0= ((a&0xFCFCFCFCUL)>>2)\
389 + ((b&0xFCFCFCFCUL)>>2);\
390 l1= (c&0x03030303UL)\
392 h1= ((c&0xFCFCFCFCUL)>>2)\
393 + ((d&0xFCFCFCFCUL)>>2);\
394 OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
397 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,\
398 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
399 FUNC(OPNAME ## _pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
400 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);\
402 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,\
403 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
404 FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
405 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);\
408 static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *p_block, const uint8_t *p_pixels, int line_size, int h)\
410 int i, a0, b0, a1, b1;\
411 pixel *block = (pixel*)p_block;\
412 const pixel *pixels = (const pixel*)p_pixels;\
413 line_size >>= sizeof(pixel)-1;\
420 for(i=0; i<h; i+=2){\
426 block[0]= (a1+a0)>>2; /* FIXME non put */\
427 block[1]= (b1+b0)>>2;\
437 block[0]= (a1+a0)>>2;\
438 block[1]= (b1+b0)>>2;\
444 static inline void FUNCC(OPNAME ## _pixels4_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
446 /* FIXME HIGH BIT DEPTH */\
448 const uint32_t a= AV_RN32(pixels );\
449 const uint32_t b= AV_RN32(pixels+1);\
450 uint32_t l0= (a&0x03030303UL)\
453 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
454 + ((b&0xFCFCFCFCUL)>>2);\
458 for(i=0; i<h; i+=2){\
459 uint32_t a= AV_RN32(pixels );\
460 uint32_t b= AV_RN32(pixels+1);\
461 l1= (a&0x03030303UL)\
463 h1= ((a&0xFCFCFCFCUL)>>2)\
464 + ((b&0xFCFCFCFCUL)>>2);\
465 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
468 a= AV_RN32(pixels );\
469 b= AV_RN32(pixels+1);\
470 l0= (a&0x03030303UL)\
473 h0= ((a&0xFCFCFCFCUL)>>2)\
474 + ((b&0xFCFCFCFCUL)>>2);\
475 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
481 static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
483 /* FIXME HIGH BIT DEPTH */\
487 const uint32_t a= AV_RN32(pixels );\
488 const uint32_t b= AV_RN32(pixels+1);\
489 uint32_t l0= (a&0x03030303UL)\
492 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
493 + ((b&0xFCFCFCFCUL)>>2);\
497 for(i=0; i<h; i+=2){\
498 uint32_t a= AV_RN32(pixels );\
499 uint32_t b= AV_RN32(pixels+1);\
500 l1= (a&0x03030303UL)\
502 h1= ((a&0xFCFCFCFCUL)>>2)\
503 + ((b&0xFCFCFCFCUL)>>2);\
504 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
507 a= AV_RN32(pixels );\
508 b= AV_RN32(pixels+1);\
509 l0= (a&0x03030303UL)\
512 h0= ((a&0xFCFCFCFCUL)>>2)\
513 + ((b&0xFCFCFCFCUL)>>2);\
514 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
518 pixels+=4-line_size*(h+1);\
519 block +=4-line_size*h;\
523 static inline void FUNCC(OPNAME ## _no_rnd_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
525 /* 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));\
560 pixels+=4-line_size*(h+1);\
561 block +=4-line_size*h;\
565 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
566 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_x2) , FUNCC(OPNAME ## _pixels8_x2) , 8*sizeof(pixel))\
567 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_y2) , FUNCC(OPNAME ## _pixels8_y2) , 8*sizeof(pixel))\
568 CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\
569 av_unused CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
570 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_x2) , FUNCC(OPNAME ## _no_rnd_pixels8_x2) , 8*sizeof(pixel))\
571 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pixels8_y2) , 8*sizeof(pixel))\
572 CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\
574 #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
575 #define op_put(a, b) a = b
582 #define put_no_rnd_pixels8_c put_pixels8_c
583 #define put_no_rnd_pixels16_c put_pixels16_c
585 #define H264_CHROMA_MC(OPNAME, OP)\
586 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){\
587 pixel *dst = (pixel*)p_dst;\
588 pixel *src = (pixel*)p_src;\
589 const int A=(8-x)*(8-y);\
590 const int B=( x)*(8-y);\
591 const int C=(8-x)*( y);\
592 const int D=( x)*( y);\
594 stride >>= sizeof(pixel)-1;\
596 av_assert2(x<8 && y<8 && x>=0 && y>=0);\
600 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
601 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
607 const int step= C ? stride : 1;\
609 OP(dst[0], (A*src[0] + E*src[step+0]));\
610 OP(dst[1], (A*src[1] + E*src[step+1]));\
617 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){\
618 pixel *dst = (pixel*)p_dst;\
619 pixel *src = (pixel*)p_src;\
620 const int A=(8-x)*(8-y);\
621 const int B=( x)*(8-y);\
622 const int C=(8-x)*( y);\
623 const int D=( x)*( y);\
625 stride >>= sizeof(pixel)-1;\
627 av_assert2(x<8 && y<8 && x>=0 && y>=0);\
631 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
632 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
633 OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
634 OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
640 const int step= C ? stride : 1;\
642 OP(dst[0], (A*src[0] + E*src[step+0]));\
643 OP(dst[1], (A*src[1] + E*src[step+1]));\
644 OP(dst[2], (A*src[2] + E*src[step+2]));\
645 OP(dst[3], (A*src[3] + E*src[step+3]));\
652 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){\
653 pixel *dst = (pixel*)p_dst;\
654 pixel *src = (pixel*)p_src;\
655 const int A=(8-x)*(8-y);\
656 const int B=( x)*(8-y);\
657 const int C=(8-x)*( y);\
658 const int D=( x)*( y);\
660 stride >>= sizeof(pixel)-1;\
662 av_assert2(x<8 && y<8 && x>=0 && y>=0);\
666 OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
667 OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
668 OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
669 OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
670 OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
671 OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
672 OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
673 OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
679 const int step= C ? stride : 1;\
681 OP(dst[0], (A*src[0] + E*src[step+0]));\
682 OP(dst[1], (A*src[1] + E*src[step+1]));\
683 OP(dst[2], (A*src[2] + E*src[step+2]));\
684 OP(dst[3], (A*src[3] + E*src[step+3]));\
685 OP(dst[4], (A*src[4] + E*src[step+4]));\
686 OP(dst[5], (A*src[5] + E*src[step+5]));\
687 OP(dst[6], (A*src[6] + E*src[step+6]));\
688 OP(dst[7], (A*src[7] + E*src[step+7]));\
695 #define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
696 #define op_put(a, b) a = (((b) + 32)>>6)
698 H264_CHROMA_MC(put_ , op_put)
699 H264_CHROMA_MC(avg_ , op_avg)
703 #define H264_LOWPASS(OPNAME, OP, OP2) \
704 static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
708 pixel *dst = (pixel*)p_dst;\
709 pixel *src = (pixel*)p_src;\
710 dstStride >>= sizeof(pixel)-1;\
711 srcStride >>= sizeof(pixel)-1;\
714 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
715 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
721 static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
725 pixel *dst = (pixel*)p_dst;\
726 pixel *src = (pixel*)p_src;\
727 dstStride >>= sizeof(pixel)-1;\
728 srcStride >>= sizeof(pixel)-1;\
731 const int srcB= src[-2*srcStride];\
732 const int srcA= src[-1*srcStride];\
733 const int src0= src[0 *srcStride];\
734 const int src1= src[1 *srcStride];\
735 const int src2= src[2 *srcStride];\
736 const int src3= src[3 *srcStride];\
737 const int src4= src[4 *srcStride];\
738 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
739 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
745 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){\
748 const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
751 pixel *dst = (pixel*)p_dst;\
752 pixel *src = (pixel*)p_src;\
753 dstStride >>= sizeof(pixel)-1;\
754 srcStride >>= sizeof(pixel)-1;\
756 for(i=0; i<h+5; i++)\
758 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
759 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
763 tmp -= tmpStride*(h+5-2);\
766 const int tmpB= tmp[-2*tmpStride] - pad;\
767 const int tmpA= tmp[-1*tmpStride] - pad;\
768 const int tmp0= tmp[0 *tmpStride] - pad;\
769 const int tmp1= tmp[1 *tmpStride] - pad;\
770 const int tmp2= tmp[2 *tmpStride] - pad;\
771 const int tmp3= tmp[3 *tmpStride] - pad;\
772 const int tmp4= tmp[4 *tmpStride] - pad;\
773 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
774 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
779 static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
783 pixel *dst = (pixel*)p_dst;\
784 pixel *src = (pixel*)p_src;\
785 dstStride >>= sizeof(pixel)-1;\
786 srcStride >>= sizeof(pixel)-1;\
789 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
790 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
791 OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
792 OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
798 static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
802 pixel *dst = (pixel*)p_dst;\
803 pixel *src = (pixel*)p_src;\
804 dstStride >>= sizeof(pixel)-1;\
805 srcStride >>= sizeof(pixel)-1;\
808 const int srcB= src[-2*srcStride];\
809 const int srcA= src[-1*srcStride];\
810 const int src0= src[0 *srcStride];\
811 const int src1= src[1 *srcStride];\
812 const int src2= src[2 *srcStride];\
813 const int src3= src[3 *srcStride];\
814 const int src4= src[4 *srcStride];\
815 const int src5= src[5 *srcStride];\
816 const int src6= src[6 *srcStride];\
817 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
818 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
819 OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
820 OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
826 static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
829 const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
832 pixel *dst = (pixel*)p_dst;\
833 pixel *src = (pixel*)p_src;\
834 dstStride >>= sizeof(pixel)-1;\
835 srcStride >>= sizeof(pixel)-1;\
837 for(i=0; i<h+5; i++)\
839 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
840 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
841 tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]) + pad;\
842 tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]) + pad;\
846 tmp -= tmpStride*(h+5-2);\
849 const int tmpB= tmp[-2*tmpStride] - pad;\
850 const int tmpA= tmp[-1*tmpStride] - pad;\
851 const int tmp0= tmp[0 *tmpStride] - pad;\
852 const int tmp1= tmp[1 *tmpStride] - pad;\
853 const int tmp2= tmp[2 *tmpStride] - pad;\
854 const int tmp3= tmp[3 *tmpStride] - pad;\
855 const int tmp4= tmp[4 *tmpStride] - pad;\
856 const int tmp5= tmp[5 *tmpStride] - pad;\
857 const int tmp6= tmp[6 *tmpStride] - pad;\
858 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
859 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
860 OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
861 OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
867 static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
871 pixel *dst = (pixel*)p_dst;\
872 pixel *src = (pixel*)p_src;\
873 dstStride >>= sizeof(pixel)-1;\
874 srcStride >>= sizeof(pixel)-1;\
877 OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
878 OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
879 OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
880 OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
881 OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
882 OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
883 OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
884 OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
890 static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
894 pixel *dst = (pixel*)p_dst;\
895 pixel *src = (pixel*)p_src;\
896 dstStride >>= sizeof(pixel)-1;\
897 srcStride >>= sizeof(pixel)-1;\
900 const int srcB= src[-2*srcStride];\
901 const int srcA= src[-1*srcStride];\
902 const int src0= src[0 *srcStride];\
903 const int src1= src[1 *srcStride];\
904 const int src2= src[2 *srcStride];\
905 const int src3= src[3 *srcStride];\
906 const int src4= src[4 *srcStride];\
907 const int src5= src[5 *srcStride];\
908 const int src6= src[6 *srcStride];\
909 const int src7= src[7 *srcStride];\
910 const int src8= src[8 *srcStride];\
911 const int src9= src[9 *srcStride];\
912 const int src10=src[10*srcStride];\
913 OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
914 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
915 OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
916 OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
917 OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
918 OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
919 OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
920 OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
926 static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
929 const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
932 pixel *dst = (pixel*)p_dst;\
933 pixel *src = (pixel*)p_src;\
934 dstStride >>= sizeof(pixel)-1;\
935 srcStride >>= sizeof(pixel)-1;\
937 for(i=0; i<h+5; i++)\
939 tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]) + pad;\
940 tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]) + pad;\
941 tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]) + pad;\
942 tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]) + pad;\
943 tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]) + pad;\
944 tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]) + pad;\
945 tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]) + pad;\
946 tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]) + pad;\
950 tmp -= tmpStride*(h+5-2);\
953 const int tmpB= tmp[-2*tmpStride] - pad;\
954 const int tmpA= tmp[-1*tmpStride] - pad;\
955 const int tmp0= tmp[0 *tmpStride] - pad;\
956 const int tmp1= tmp[1 *tmpStride] - pad;\
957 const int tmp2= tmp[2 *tmpStride] - pad;\
958 const int tmp3= tmp[3 *tmpStride] - pad;\
959 const int tmp4= tmp[4 *tmpStride] - pad;\
960 const int tmp5= tmp[5 *tmpStride] - pad;\
961 const int tmp6= tmp[6 *tmpStride] - pad;\
962 const int tmp7= tmp[7 *tmpStride] - pad;\
963 const int tmp8= tmp[8 *tmpStride] - pad;\
964 const int tmp9= tmp[9 *tmpStride] - pad;\
965 const int tmp10=tmp[10*tmpStride] - pad;\
966 OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
967 OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
968 OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
969 OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
970 OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
971 OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
972 OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
973 OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
979 static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
980 FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
981 FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
984 FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
985 FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
988 static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
989 FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
990 FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
993 FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
994 FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
997 static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
998 FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
999 FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
1000 src += 8*srcStride;\
1001 dst += 8*dstStride;\
1002 FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
1003 FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
1006 #define H264_MC(OPNAME, SIZE) \
1007 static av_unused void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, uint8_t *src, int stride){\
1008 FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
1011 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, uint8_t *src, int stride){\
1012 uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1013 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
1014 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
1017 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, uint8_t *src, int stride){\
1018 FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
1021 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, uint8_t *src, int stride){\
1022 uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1023 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
1024 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
1027 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, uint8_t *src, int stride){\
1028 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1029 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1030 uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1031 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1032 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1033 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1036 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, uint8_t *src, int stride){\
1037 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1038 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1039 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1040 FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
1043 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, uint8_t *src, int stride){\
1044 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1045 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1046 uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1047 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1048 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1049 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1052 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, uint8_t *src, int stride){\
1053 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1054 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1055 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1056 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1057 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1058 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1059 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1060 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1063 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, uint8_t *src, int stride){\
1064 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1065 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1066 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1067 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1068 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1069 FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1070 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1071 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1074 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, uint8_t *src, int stride){\
1075 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1076 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1077 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1078 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1079 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1080 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1081 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1082 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1085 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, uint8_t *src, int stride){\
1086 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1087 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1088 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1089 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1090 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1091 FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1092 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1093 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1096 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, uint8_t *src, int stride){\
1097 pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1098 FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
1101 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, uint8_t *src, int stride){\
1102 pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1103 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1104 uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1105 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1106 FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1107 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1110 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, uint8_t *src, int stride){\
1111 pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1112 uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1113 uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1114 FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1115 FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1116 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1119 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, uint8_t *src, int stride){\
1120 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1121 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1122 pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1123 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1124 uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1125 FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1126 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1127 FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1128 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1131 static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, uint8_t *src, int stride){\
1132 uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1133 uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1134 pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1135 uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1136 uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1137 FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1138 FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1139 FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1140 FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1143 #define op_avg(a, b) a = (((a)+CLIP(((b) + 16)>>5)+1)>>1)
1144 //#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
1145 #define op_put(a, b) a = CLIP(((b) + 16)>>5)
1146 #define op2_avg(a, b) a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
1147 #define op2_put(a, b) a = CLIP(((b) + 512)>>10)
1149 H264_LOWPASS(put_ , op_put, op2_put)
1150 H264_LOWPASS(avg_ , op_avg, op2_avg)
1165 # define put_h264_qpel8_mc00_8_c ff_put_pixels8x8_8_c
1166 # define avg_h264_qpel8_mc00_8_c ff_avg_pixels8x8_8_c
1167 # define put_h264_qpel16_mc00_8_c ff_put_pixels16x16_8_c
1168 # define avg_h264_qpel16_mc00_8_c ff_avg_pixels16x16_8_c
1169 #elif BIT_DEPTH == 9
1170 # define put_h264_qpel8_mc00_9_c ff_put_pixels8x8_9_c
1171 # define avg_h264_qpel8_mc00_9_c ff_avg_pixels8x8_9_c
1172 # define put_h264_qpel16_mc00_9_c ff_put_pixels16x16_9_c
1173 # define avg_h264_qpel16_mc00_9_c ff_avg_pixels16x16_9_c
1174 #elif BIT_DEPTH == 10
1175 # define put_h264_qpel8_mc00_10_c ff_put_pixels8x8_10_c
1176 # define avg_h264_qpel8_mc00_10_c ff_avg_pixels8x8_10_c
1177 # define put_h264_qpel16_mc00_10_c ff_put_pixels16x16_10_c
1178 # define avg_h264_qpel16_mc00_10_c ff_avg_pixels16x16_10_c
1179 #elif BIT_DEPTH == 12
1180 # define put_h264_qpel8_mc00_12_c ff_put_pixels8x8_12_c
1181 # define avg_h264_qpel8_mc00_12_c ff_avg_pixels8x8_12_c
1182 # define put_h264_qpel16_mc00_12_c ff_put_pixels16x16_12_c
1183 # define avg_h264_qpel16_mc00_12_c ff_avg_pixels16x16_12_c
1184 #elif BIT_DEPTH == 14
1185 # define put_h264_qpel8_mc00_14_c ff_put_pixels8x8_14_c
1186 # define avg_h264_qpel8_mc00_14_c ff_avg_pixels8x8_14_c
1187 # define put_h264_qpel16_mc00_14_c ff_put_pixels16x16_14_c
1188 # define avg_h264_qpel16_mc00_14_c ff_avg_pixels16x16_14_c
1191 void FUNCC(ff_put_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1192 FUNCC(put_pixels8)(dst, src, stride, 8);
1194 void FUNCC(ff_avg_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1195 FUNCC(avg_pixels8)(dst, src, stride, 8);
1197 void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1198 FUNCC(put_pixels16)(dst, src, stride, 16);
1200 void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1201 FUNCC(avg_pixels16)(dst, src, stride, 16);