3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * note, many functions in here may use MMX which trashes the FPU state, it is
27 * absolutely necessary to call emms_c() between dsp & float/double code
30 #ifndef AVCODEC_DSPUTIL_H
31 #define AVCODEC_DSPUTIL_H
33 #include "libavutil/intreadwrite.h"
40 void ff_fdct_ifast(int16_t *data);
41 void ff_fdct_ifast248(int16_t *data);
42 void ff_jpeg_fdct_islow_8(int16_t *data);
43 void ff_jpeg_fdct_islow_10(int16_t *data);
44 void ff_fdct248_islow_8(int16_t *data);
45 void ff_fdct248_islow_10(int16_t *data);
47 void ff_j_rev_dct(int16_t *data);
48 void ff_j_rev_dct4(int16_t *data);
49 void ff_j_rev_dct2(int16_t *data);
50 void ff_j_rev_dct1(int16_t *data);
52 void ff_fdct_mmx(int16_t *block);
53 void ff_fdct_mmxext(int16_t *block);
54 void ff_fdct_sse2(int16_t *block);
56 #define H264_IDCT(depth) \
57 void ff_h264_idct8_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
58 void ff_h264_idct_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
59 void ff_h264_idct8_dc_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
60 void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
61 void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
62 void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
63 void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
64 void ff_h264_idct_add8_422_ ## depth ## _c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
65 void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
66 void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(int16_t *output, int16_t *input, int qmul);\
67 void ff_h264_chroma422_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul);\
68 void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul);
76 void ff_svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp);
77 void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc);
80 extern const uint8_t ff_alternate_horizontal_scan[64];
81 extern const uint8_t ff_alternate_vertical_scan[64];
82 extern const uint8_t ff_zigzag_direct[64];
83 extern const uint8_t ff_zigzag248_direct[64];
85 /* pixel operations */
86 #define MAX_NEG_CROP 1024
89 extern uint32_t ff_squareTbl[512];
90 extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
92 #define PUTAVG_PIXELS(depth)\
93 void ff_put_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
94 void ff_avg_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
95 void ff_put_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
96 void ff_avg_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);
104 #define ff_put_pixels8x8_c ff_put_pixels8x8_8_c
105 #define ff_avg_pixels8x8_c ff_avg_pixels8x8_8_c
106 #define ff_put_pixels16x16_c ff_put_pixels16x16_8_c
107 #define ff_avg_pixels16x16_c ff_avg_pixels16x16_8_c
110 void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride);
111 void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride);
112 void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride);
113 void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride);
115 /* 1/2^n downscaling functions from imgconvert.c */
116 void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
117 void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
118 void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
120 void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
121 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
123 /* minimum alignment rules ;)
124 If you notice errors in the align stuff, need more alignment for some ASM code
125 for some CPU or need to use a function with less aligned data then send a mail
126 to the ffmpeg-devel mailing list, ...
128 !warning These alignments might not match reality, (missing attribute((align))
129 stuff somewhere possible).
130 I (Michael) did not check them, these are just the alignments which I think
131 could be reached easily ...
133 !future video codecs might need functions with less strict alignment
137 void get_pixels_c(int16_t *block, const uint8_t *pixels, int line_size);
138 void diff_pixels_c(int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride);
139 void put_pixels_clamped_c(const int16_t *block, uint8_t *pixels, int line_size);
140 void add_pixels_clamped_c(const int16_t *block, uint8_t *pixels, int line_size);
141 void clear_blocks_c(int16_t *blocks);
144 /* add and put pixel (decoding) */
145 // blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
146 //h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller than 4
147 typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h);
148 typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h);
149 typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
150 typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y);
152 typedef void (*op_fill_func)(uint8_t *block/*align width (8 or 16)*/, uint8_t value, int line_size, int h);
154 #define DEF_OLD_QPEL(name)\
155 void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
156 void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
157 void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
159 DEF_OLD_QPEL(qpel16_mc11_old_c)
160 DEF_OLD_QPEL(qpel16_mc31_old_c)
161 DEF_OLD_QPEL(qpel16_mc12_old_c)
162 DEF_OLD_QPEL(qpel16_mc32_old_c)
163 DEF_OLD_QPEL(qpel16_mc13_old_c)
164 DEF_OLD_QPEL(qpel16_mc33_old_c)
165 DEF_OLD_QPEL(qpel8_mc11_old_c)
166 DEF_OLD_QPEL(qpel8_mc31_old_c)
167 DEF_OLD_QPEL(qpel8_mc12_old_c)
168 DEF_OLD_QPEL(qpel8_mc32_old_c)
169 DEF_OLD_QPEL(qpel8_mc13_old_c)
170 DEF_OLD_QPEL(qpel8_mc33_old_c)
172 #define CALL_2X_PIXELS(a, b, n)\
173 static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
174 b(block , pixels , line_size, h);\
175 b(block+n, pixels+n, line_size, h);\
178 /* motion estimation */
179 // h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller than 2
180 // although currently h<4 is not used as functions with width <8 are neither used nor implemented
181 typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/;
186 typedef struct ScanTable{
187 const uint8_t *scantable;
188 uint8_t permutated[64];
189 uint8_t raster_end[64];
192 void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
193 void ff_init_scantable_permutation(uint8_t *idct_permutation,
194 int idct_permutation_type);
196 #define EMULATED_EDGE(depth) \
197 void ff_emulated_edge_mc_ ## depth (uint8_t *buf, const uint8_t *src, ptrdiff_t linesize,\
198 int block_w, int block_h,\
199 int src_x, int src_y, int w, int h);
207 typedef struct DSPContext {
209 * Size of DCT coefficients.
213 /* pixel ops : interface with DCT */
214 void (*get_pixels)(int16_t *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size);
215 void (*diff_pixels)(int16_t *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
216 void (*put_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
217 void (*put_signed_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
218 void (*add_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
219 void (*add_pixels8)(uint8_t *pixels, int16_t *block, int line_size);
220 void (*add_pixels4)(uint8_t *pixels, int16_t *block, int line_size);
221 int (*sum_abs_dctelem)(int16_t *block/*align 16*/);
223 * translational global motion compensation.
225 void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
227 * global motion compensation.
229 void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy,
230 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
231 void (*clear_block)(int16_t *block/*align 16*/);
232 void (*clear_blocks)(int16_t *blocks/*align 16*/);
233 int (*pix_sum)(uint8_t * pix, int line_size);
234 int (*pix_norm1)(uint8_t * pix, int line_size);
235 // 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4
237 me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
239 me_cmp_func hadamard8_diff[6];
240 me_cmp_func dct_sad[6];
241 me_cmp_func quant_psnr[6];
249 me_cmp_func dct_max[6];
250 me_cmp_func dct264_sad[6];
252 me_cmp_func me_pre_cmp[6];
253 me_cmp_func me_cmp[6];
254 me_cmp_func me_sub_cmp[6];
255 me_cmp_func mb_cmp[6];
256 me_cmp_func ildct_cmp[6]; //only width 16 used
257 me_cmp_func frame_skip_cmp[6]; //only width 8 used
259 int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
263 * Halfpel motion compensation with rounding (a+b+1)>>1.
264 * this is an array[4][4] of motion compensation functions for 4
265 * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
266 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
267 * @param block destination where the result is stored
268 * @param pixels source
269 * @param line_size number of bytes in a horizontal line of block
272 op_pixels_func put_pixels_tab[4][4];
275 * Halfpel motion compensation with rounding (a+b+1)>>1.
276 * This is an array[4][4] of motion compensation functions for 4
277 * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
278 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
279 * @param block destination into which the result is averaged (a+b+1)>>1
280 * @param pixels source
281 * @param line_size number of bytes in a horizontal line of block
284 op_pixels_func avg_pixels_tab[4][4];
287 * Halfpel motion compensation with no rounding (a+b)>>1.
288 * this is an array[2][4] of motion compensation functions for 2
289 * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
290 * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
291 * @param block destination where the result is stored
292 * @param pixels source
293 * @param line_size number of bytes in a horizontal line of block
296 op_pixels_func put_no_rnd_pixels_tab[2][4];
299 * Halfpel motion compensation with no rounding (a+b)>>1.
300 * this is an array[4] of motion compensation functions for 1
301 * horizontal blocksize (16) and the 4 halfpel positions<br>
302 * *pixels_tab[0][ xhalfpel + 2*yhalfpel ]
303 * @param block destination into which the result is averaged (a+b)>>1
304 * @param pixels source
305 * @param line_size number of bytes in a horizontal line of block
308 op_pixels_func avg_no_rnd_pixels_tab[4];
311 * Thirdpel motion compensation with rounding (a+b+1)>>1.
312 * this is an array[12] of motion compensation functions for the 9 thirdpe
314 * *pixels_tab[ xthirdpel + 4*ythirdpel ]
315 * @param block destination where the result is stored
316 * @param pixels source
317 * @param line_size number of bytes in a horizontal line of block
320 tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
321 tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
323 qpel_mc_func put_qpel_pixels_tab[2][16];
324 qpel_mc_func avg_qpel_pixels_tab[2][16];
325 qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
326 qpel_mc_func put_mspel_pixels_tab[8];
331 h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
332 h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
334 me_cmp_func pix_abs[2][4];
336 /* huffyuv specific */
337 void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
338 void (*diff_bytes)(uint8_t *dst/*align 16*/, const uint8_t *src1/*align 16*/, const uint8_t *src2/*align 1*/,int w);
340 * subtract huffyuv's variant of median prediction
341 * note, this might read from src1[-1], src2[-1]
343 void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top);
344 void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top);
345 int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left);
346 void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha);
347 /* this might write to dst[w] */
348 void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
349 void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len);
351 void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
352 void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
354 void (*h261_loop_filter)(uint8_t *src, int stride);
356 /* assume len is a multiple of 8, and arrays are 16-byte aligned */
357 void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
360 void (*fdct)(int16_t *block/* align 16*/);
361 void (*fdct248)(int16_t *block/* align 16*/);
364 void (*idct)(int16_t *block/* align 16*/);
367 * block -> idct -> clip to unsigned 8 bit -> dest.
368 * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
369 * @param line_size size in bytes of a horizontal line of dest
371 void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, int16_t *block/*align 16*/);
374 * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
375 * @param line_size size in bytes of a horizontal line of dest
377 void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, int16_t *block/*align 16*/);
380 * idct input permutation.
381 * several optimized IDCTs need a permutated input (relative to the normal order of the reference
383 * this permutation must be performed before the idct_put/add, note, normally this can be merged
384 * with the zigzag/alternate scan<br>
385 * an example to avoid confusion:
386 * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
387 * - (x -> reference dct -> reference idct -> x)
388 * - (x -> reference dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x)
389 * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...)
391 uint8_t idct_permutation[64];
392 int idct_permutation_type;
393 #define FF_NO_IDCT_PERM 1
394 #define FF_LIBMPEG2_IDCT_PERM 2
395 #define FF_SIMPLE_IDCT_PERM 3
396 #define FF_TRANSPOSE_IDCT_PERM 4
397 #define FF_PARTTRANS_IDCT_PERM 5
398 #define FF_SSE2_IDCT_PERM 6
400 int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
401 void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
402 #define BASIS_SHIFT 16
403 #define RECON_SHIFT 6
405 void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides);
406 #define EDGE_WIDTH 16
408 #define EDGE_BOTTOM 2
410 void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
413 * Calculate scalar product of two vectors.
414 * @param len length of vectors, should be multiple of 16
416 int32_t (*scalarproduct_int16)(const int16_t *v1, const int16_t *v2/*align 16*/, int len);
419 * Calculate scalar product of v1 and v2,
420 * and v1[i] += v3[i] * mul
421 * @param len length of vectors, should be multiple of 16
423 int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, const int16_t *v2, const int16_t *v3, int len, int mul);
426 * Apply symmetric window in 16-bit fixed-point.
427 * @param output destination array
428 * constraints: 16-byte aligned
429 * @param input source array
430 * constraints: 16-byte aligned
431 * @param window window array
432 * constraints: 16-byte aligned, at least len/2 elements
433 * @param len full window length
434 * constraints: multiple of ? greater than zero
436 void (*apply_window_int16)(int16_t *output, const int16_t *input,
437 const int16_t *window, unsigned int len);
440 * Clip each element in an array of int32_t to a given minimum and maximum value.
441 * @param dst destination array
442 * constraints: 16-byte aligned
443 * @param src source array
444 * constraints: 16-byte aligned
445 * @param min minimum value
446 * constraints: must be in the range [-(1 << 24), 1 << 24]
447 * @param max maximum value
448 * constraints: must be in the range [-(1 << 24), 1 << 24]
449 * @param len number of elements in the array
450 * constraints: multiple of 32 greater than zero
452 void (*vector_clip_int32)(int32_t *dst, const int32_t *src, int32_t min,
453 int32_t max, unsigned int len);
455 op_fill_func fill_block_tab[2];
458 void ff_dsputil_static_init(void);
459 void ff_dsputil_init(DSPContext* p, AVCodecContext *avctx);
460 attribute_deprecated void dsputil_init(DSPContext* c, AVCodecContext *avctx);
462 int ff_check_alignment(void);
465 * permute block according to permuatation.
466 * @param last last non zero element in scantable order
468 void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last);
470 void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
472 #define BYTE_VEC32(c) ((c)*0x01010101UL)
473 #define BYTE_VEC64(c) ((c)*0x0001000100010001UL)
475 static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
477 return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
480 static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
482 return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
485 static inline uint64_t rnd_avg64(uint64_t a, uint64_t b)
487 return (a | b) - (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1);
490 static inline uint64_t no_rnd_avg64(uint64_t a, uint64_t b)
492 return (a & b) + (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1);
495 static inline int get_penalty_factor(int lambda, int lambda2, int type){
499 return lambda>>FF_LAMBDA_SHIFT;
501 return (3*lambda)>>(FF_LAMBDA_SHIFT+1);
503 return (4*lambda)>>(FF_LAMBDA_SHIFT);
505 return (2*lambda)>>(FF_LAMBDA_SHIFT);
508 return (2*lambda)>>FF_LAMBDA_SHIFT;
513 return lambda2>>FF_LAMBDA_SHIFT;
519 void ff_dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
520 void ff_dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
521 void ff_dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
522 void ff_dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
523 void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
524 void ff_dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
525 void ff_dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
527 void ff_dsputil_init_dwt(DSPContext *c);
529 #if (ARCH_ARM && HAVE_NEON) || ARCH_PPC || HAVE_MMX
530 # define STRIDE_ALIGN 16
532 # define STRIDE_ALIGN 8
535 // Some broken preprocessors need a second expansion
536 // to be forced to tokenize __VA_ARGS__
539 #define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \
540 uint8_t la_##v[sizeof(t s o) + (a)]; \
541 t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
543 #define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \
544 DECLARE_ALIGNED(a, t, la_##v) s o; \
547 #define LOCAL_ALIGNED(a, t, v, ...) E(LOCAL_ALIGNED_A(a, t, v, __VA_ARGS__,,))
549 #if HAVE_LOCAL_ALIGNED_8
550 # define LOCAL_ALIGNED_8(t, v, ...) E(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,))
552 # define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED(8, t, v, __VA_ARGS__)
555 #if HAVE_LOCAL_ALIGNED_16
556 # define LOCAL_ALIGNED_16(t, v, ...) E(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,))
558 # define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__)
561 #define WRAPPER8_16_SQ(name8, name16)\
562 static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
564 score +=name8(s, dst , src , stride, 8);\
565 score +=name8(s, dst+8 , src+8 , stride, 8);\
569 score +=name8(s, dst , src , stride, 8);\
570 score +=name8(s, dst+8 , src+8 , stride, 8);\
576 static inline void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
581 AV_COPY16U(dst, src);
587 static inline void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
592 AV_COPY32U(dst, src);
598 static inline void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
603 AV_COPY64U(dst, src);
609 static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
614 AV_COPY64U(dst, src);
621 static inline void copy_block16(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
626 AV_COPY128U(dst, src);
632 static inline void copy_block17(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
637 AV_COPY128U(dst, src);
644 #endif /* AVCODEC_DSPUTIL_H */