You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

511 lines
20KB

  1. /*
  2. * DSP utils
  3. * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  4. * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  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.
  12. *
  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.
  17. *
  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
  21. */
  22. /**
  23. * @file
  24. * DSP utils.
  25. * note, many functions in here may use MMX which trashes the FPU state, it is
  26. * absolutely necessary to call emms_c() between dsp & float/double code
  27. */
  28. #ifndef AVCODEC_DSPUTIL_H
  29. #define AVCODEC_DSPUTIL_H
  30. #include "libavutil/intreadwrite.h"
  31. #include "avcodec.h"
  32. //#define DEBUG
  33. /* dct code */
  34. void ff_fdct_ifast(int16_t *data);
  35. void ff_fdct_ifast248(int16_t *data);
  36. void ff_jpeg_fdct_islow_8(int16_t *data);
  37. void ff_jpeg_fdct_islow_10(int16_t *data);
  38. void ff_fdct248_islow_8(int16_t *data);
  39. void ff_fdct248_islow_10(int16_t *data);
  40. void ff_j_rev_dct(int16_t *data);
  41. void ff_j_rev_dct4(int16_t *data);
  42. void ff_j_rev_dct2(int16_t *data);
  43. void ff_j_rev_dct1(int16_t *data);
  44. void ff_fdct_mmx(int16_t *block);
  45. void ff_fdct_mmxext(int16_t *block);
  46. void ff_fdct_sse2(int16_t *block);
  47. /* encoding scans */
  48. extern const uint8_t ff_alternate_horizontal_scan[64];
  49. extern const uint8_t ff_alternate_vertical_scan[64];
  50. extern const uint8_t ff_zigzag_direct[64];
  51. extern const uint8_t ff_zigzag248_direct[64];
  52. /* pixel operations */
  53. #define MAX_NEG_CROP 1024
  54. /* temporary */
  55. extern uint32_t ff_squareTbl[512];
  56. extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
  57. #define PUTAVG_PIXELS(depth)\
  58. void ff_put_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
  59. void ff_avg_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
  60. void ff_put_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
  61. void ff_avg_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);
  62. PUTAVG_PIXELS( 8)
  63. PUTAVG_PIXELS( 9)
  64. PUTAVG_PIXELS(10)
  65. PUTAVG_PIXELS(12)
  66. PUTAVG_PIXELS(14)
  67. #define ff_put_pixels8x8_c ff_put_pixels8x8_8_c
  68. #define ff_avg_pixels8x8_c ff_avg_pixels8x8_8_c
  69. #define ff_put_pixels16x16_c ff_put_pixels16x16_8_c
  70. #define ff_avg_pixels16x16_c ff_avg_pixels16x16_8_c
  71. /* RV40 functions */
  72. void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride);
  73. void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride);
  74. void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride);
  75. void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride);
  76. void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
  77. int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
  78. /* minimum alignment rules ;)
  79. If you notice errors in the align stuff, need more alignment for some ASM code
  80. for some CPU or need to use a function with less aligned data then send a mail
  81. to the ffmpeg-devel mailing list, ...
  82. !warning These alignments might not match reality, (missing attribute((align))
  83. stuff somewhere possible).
  84. I (Michael) did not check them, these are just the alignments which I think
  85. could be reached easily ...
  86. !future video codecs might need functions with less strict alignment
  87. */
  88. /*
  89. void get_pixels_c(int16_t *block, const uint8_t *pixels, int line_size);
  90. void diff_pixels_c(int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride);
  91. void put_pixels_clamped_c(const int16_t *block, uint8_t *pixels, int line_size);
  92. void add_pixels_clamped_c(const int16_t *block, uint8_t *pixels, int line_size);
  93. void clear_blocks_c(int16_t *blocks);
  94. */
  95. /* add and put pixel (decoding) */
  96. // blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
  97. //h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller than 4
  98. typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, ptrdiff_t line_size, int h);
  99. 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);
  100. typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
  101. typedef void (*op_fill_func)(uint8_t *block/*align width (8 or 16)*/, uint8_t value, int line_size, int h);
  102. #define DEF_OLD_QPEL(name)\
  103. void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
  104. void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
  105. void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
  106. DEF_OLD_QPEL(qpel16_mc11_old_c)
  107. DEF_OLD_QPEL(qpel16_mc31_old_c)
  108. DEF_OLD_QPEL(qpel16_mc12_old_c)
  109. DEF_OLD_QPEL(qpel16_mc32_old_c)
  110. DEF_OLD_QPEL(qpel16_mc13_old_c)
  111. DEF_OLD_QPEL(qpel16_mc33_old_c)
  112. DEF_OLD_QPEL(qpel8_mc11_old_c)
  113. DEF_OLD_QPEL(qpel8_mc31_old_c)
  114. DEF_OLD_QPEL(qpel8_mc12_old_c)
  115. DEF_OLD_QPEL(qpel8_mc32_old_c)
  116. DEF_OLD_QPEL(qpel8_mc13_old_c)
  117. DEF_OLD_QPEL(qpel8_mc33_old_c)
  118. #define CALL_2X_PIXELS(a, b, n)\
  119. static void a(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
  120. b(block , pixels , line_size, h);\
  121. b(block+n, pixels+n, line_size, h);\
  122. }
  123. /* motion estimation */
  124. // h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller than 2
  125. // although currently h<4 is not used as functions with width <8 are neither used nor implemented
  126. 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))*/;
  127. /**
  128. * Scantable.
  129. */
  130. typedef struct ScanTable{
  131. const uint8_t *scantable;
  132. uint8_t permutated[64];
  133. uint8_t raster_end[64];
  134. } ScanTable;
  135. void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
  136. void ff_init_scantable_permutation(uint8_t *idct_permutation,
  137. int idct_permutation_type);
  138. #define EMULATED_EDGE(depth) \
  139. void ff_emulated_edge_mc_ ## depth (uint8_t *buf, const uint8_t *src, ptrdiff_t linesize,\
  140. int block_w, int block_h,\
  141. int src_x, int src_y, int w, int h);
  142. EMULATED_EDGE(8)
  143. EMULATED_EDGE(16)
  144. /**
  145. * DSPContext.
  146. */
  147. typedef struct DSPContext {
  148. /**
  149. * Size of DCT coefficients.
  150. */
  151. int dct_bits;
  152. /* pixel ops : interface with DCT */
  153. void (*get_pixels)(int16_t *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size);
  154. void (*diff_pixels)(int16_t *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
  155. void (*put_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
  156. void (*put_signed_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
  157. void (*add_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
  158. void (*add_pixels8)(uint8_t *pixels, int16_t *block, int line_size);
  159. void (*add_pixels4)(uint8_t *pixels, int16_t *block, int line_size);
  160. int (*sum_abs_dctelem)(int16_t *block/*align 16*/);
  161. /**
  162. * translational global motion compensation.
  163. */
  164. void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
  165. /**
  166. * global motion compensation.
  167. */
  168. void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy,
  169. int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
  170. void (*clear_block)(int16_t *block/*align 16*/);
  171. void (*clear_blocks)(int16_t *blocks/*align 16*/);
  172. int (*pix_sum)(uint8_t * pix, int line_size);
  173. int (*pix_norm1)(uint8_t * pix, int line_size);
  174. // 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4
  175. me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
  176. me_cmp_func sse[6];
  177. me_cmp_func hadamard8_diff[6];
  178. me_cmp_func dct_sad[6];
  179. me_cmp_func quant_psnr[6];
  180. me_cmp_func bit[6];
  181. me_cmp_func rd[6];
  182. me_cmp_func vsad[6];
  183. me_cmp_func vsse[6];
  184. me_cmp_func nsse[6];
  185. me_cmp_func w53[6];
  186. me_cmp_func w97[6];
  187. me_cmp_func dct_max[6];
  188. me_cmp_func dct264_sad[6];
  189. me_cmp_func me_pre_cmp[6];
  190. me_cmp_func me_cmp[6];
  191. me_cmp_func me_sub_cmp[6];
  192. me_cmp_func mb_cmp[6];
  193. me_cmp_func ildct_cmp[6]; //only width 16 used
  194. me_cmp_func frame_skip_cmp[6]; //only width 8 used
  195. int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
  196. int size);
  197. /**
  198. * Halfpel motion compensation with rounding (a+b+1)>>1.
  199. * this is an array[4][4] of motion compensation functions for 4
  200. * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
  201. * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
  202. * @param block destination where the result is stored
  203. * @param pixels source
  204. * @param line_size number of bytes in a horizontal line of block
  205. * @param h height
  206. */
  207. op_pixels_func put_pixels_tab[4][4];
  208. /**
  209. * Halfpel motion compensation with rounding (a+b+1)>>1.
  210. * This is an array[4][4] of motion compensation functions for 4
  211. * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
  212. * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
  213. * @param block destination into which the result is averaged (a+b+1)>>1
  214. * @param pixels source
  215. * @param line_size number of bytes in a horizontal line of block
  216. * @param h height
  217. */
  218. op_pixels_func avg_pixels_tab[4][4];
  219. /**
  220. * Halfpel motion compensation with no rounding (a+b)>>1.
  221. * this is an array[2][4] of motion compensation functions for 2
  222. * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
  223. * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
  224. * @param block destination where the result is stored
  225. * @param pixels source
  226. * @param line_size number of bytes in a horizontal line of block
  227. * @param h height
  228. */
  229. op_pixels_func put_no_rnd_pixels_tab[4][4];
  230. /**
  231. * Halfpel motion compensation with no rounding (a+b)>>1.
  232. * this is an array[4] of motion compensation functions for 1
  233. * horizontal blocksize (16) and the 4 halfpel positions<br>
  234. * *pixels_tab[0][ xhalfpel + 2*yhalfpel ]
  235. * @param block destination into which the result is averaged (a+b)>>1
  236. * @param pixels source
  237. * @param line_size number of bytes in a horizontal line of block
  238. * @param h height
  239. */
  240. op_pixels_func avg_no_rnd_pixels_tab[4];
  241. /**
  242. * Thirdpel motion compensation with rounding (a+b+1)>>1.
  243. * this is an array[12] of motion compensation functions for the 9 thirdpe
  244. * positions<br>
  245. * *pixels_tab[ xthirdpel + 4*ythirdpel ]
  246. * @param block destination where the result is stored
  247. * @param pixels source
  248. * @param line_size number of bytes in a horizontal line of block
  249. * @param h height
  250. */
  251. tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
  252. tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
  253. qpel_mc_func put_qpel_pixels_tab[2][16];
  254. qpel_mc_func avg_qpel_pixels_tab[2][16];
  255. qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
  256. qpel_mc_func put_mspel_pixels_tab[8];
  257. me_cmp_func pix_abs[2][4];
  258. /* huffyuv specific */
  259. void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
  260. void (*diff_bytes)(uint8_t *dst/*align 16*/, const uint8_t *src1/*align 16*/, const uint8_t *src2/*align 1*/,int w);
  261. /**
  262. * subtract huffyuv's variant of median prediction
  263. * note, this might read from src1[-1], src2[-1]
  264. */
  265. void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top);
  266. void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top);
  267. int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left);
  268. void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha);
  269. /* this might write to dst[w] */
  270. void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
  271. void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len);
  272. void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
  273. void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
  274. void (*h261_loop_filter)(uint8_t *src, int stride);
  275. /* assume len is a multiple of 8, and arrays are 16-byte aligned */
  276. void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
  277. /* (I)DCT */
  278. void (*fdct)(int16_t *block/* align 16*/);
  279. void (*fdct248)(int16_t *block/* align 16*/);
  280. /* IDCT really*/
  281. void (*idct)(int16_t *block/* align 16*/);
  282. /**
  283. * block -> idct -> clip to unsigned 8 bit -> dest.
  284. * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
  285. * @param line_size size in bytes of a horizontal line of dest
  286. */
  287. void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, int16_t *block/*align 16*/);
  288. /**
  289. * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
  290. * @param line_size size in bytes of a horizontal line of dest
  291. */
  292. void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, int16_t *block/*align 16*/);
  293. /**
  294. * idct input permutation.
  295. * several optimized IDCTs need a permutated input (relative to the normal order of the reference
  296. * IDCT)
  297. * this permutation must be performed before the idct_put/add, note, normally this can be merged
  298. * with the zigzag/alternate scan<br>
  299. * an example to avoid confusion:
  300. * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
  301. * - (x -> reference dct -> reference idct -> x)
  302. * - (x -> reference dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x)
  303. * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...)
  304. */
  305. uint8_t idct_permutation[64];
  306. int idct_permutation_type;
  307. #define FF_NO_IDCT_PERM 1
  308. #define FF_LIBMPEG2_IDCT_PERM 2
  309. #define FF_SIMPLE_IDCT_PERM 3
  310. #define FF_TRANSPOSE_IDCT_PERM 4
  311. #define FF_PARTTRANS_IDCT_PERM 5
  312. #define FF_SSE2_IDCT_PERM 6
  313. int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
  314. void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
  315. #define BASIS_SHIFT 16
  316. #define RECON_SHIFT 6
  317. void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides);
  318. #define EDGE_WIDTH 16
  319. #define EDGE_TOP 1
  320. #define EDGE_BOTTOM 2
  321. void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
  322. /**
  323. * Calculate scalar product of two vectors.
  324. * @param len length of vectors, should be multiple of 16
  325. */
  326. int32_t (*scalarproduct_int16)(const int16_t *v1, const int16_t *v2/*align 16*/, int len);
  327. /* ape functions */
  328. /**
  329. * Calculate scalar product of v1 and v2,
  330. * and v1[i] += v3[i] * mul
  331. * @param len length of vectors, should be multiple of 16
  332. */
  333. int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, const int16_t *v2, const int16_t *v3, int len, int mul);
  334. /**
  335. * Apply symmetric window in 16-bit fixed-point.
  336. * @param output destination array
  337. * constraints: 16-byte aligned
  338. * @param input source array
  339. * constraints: 16-byte aligned
  340. * @param window window array
  341. * constraints: 16-byte aligned, at least len/2 elements
  342. * @param len full window length
  343. * constraints: multiple of ? greater than zero
  344. */
  345. void (*apply_window_int16)(int16_t *output, const int16_t *input,
  346. const int16_t *window, unsigned int len);
  347. /**
  348. * Clip each element in an array of int32_t to a given minimum and maximum value.
  349. * @param dst destination array
  350. * constraints: 16-byte aligned
  351. * @param src source array
  352. * constraints: 16-byte aligned
  353. * @param min minimum value
  354. * constraints: must be in the range [-(1 << 24), 1 << 24]
  355. * @param max maximum value
  356. * constraints: must be in the range [-(1 << 24), 1 << 24]
  357. * @param len number of elements in the array
  358. * constraints: multiple of 32 greater than zero
  359. */
  360. void (*vector_clip_int32)(int32_t *dst, const int32_t *src, int32_t min,
  361. int32_t max, unsigned int len);
  362. op_fill_func fill_block_tab[2];
  363. } DSPContext;
  364. void ff_dsputil_static_init(void);
  365. void ff_dsputil_init(DSPContext* p, AVCodecContext *avctx);
  366. attribute_deprecated void dsputil_init(DSPContext* c, AVCodecContext *avctx);
  367. int ff_check_alignment(void);
  368. void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
  369. #define BYTE_VEC32(c) ((c)*0x01010101UL)
  370. #define BYTE_VEC64(c) ((c)*0x0001000100010001UL)
  371. static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
  372. {
  373. return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
  374. }
  375. static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
  376. {
  377. return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
  378. }
  379. static inline uint64_t rnd_avg64(uint64_t a, uint64_t b)
  380. {
  381. return (a | b) - (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1);
  382. }
  383. static inline uint64_t no_rnd_avg64(uint64_t a, uint64_t b)
  384. {
  385. return (a & b) + (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1);
  386. }
  387. void ff_dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
  388. void ff_dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
  389. void ff_dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
  390. void ff_dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
  391. void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
  392. void ff_dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
  393. void ff_dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
  394. void ff_dsputil_init_dwt(DSPContext *c);
  395. #if (ARCH_ARM && HAVE_NEON) || ARCH_PPC || HAVE_MMX
  396. # define STRIDE_ALIGN 16
  397. #else
  398. # define STRIDE_ALIGN 8
  399. #endif
  400. // Some broken preprocessors need a second expansion
  401. // to be forced to tokenize __VA_ARGS__
  402. #define E(x) x
  403. #define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \
  404. uint8_t la_##v[sizeof(t s o) + (a)]; \
  405. t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
  406. #define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \
  407. DECLARE_ALIGNED(a, t, la_##v) s o; \
  408. t (*v) o = la_##v
  409. #define LOCAL_ALIGNED(a, t, v, ...) E(LOCAL_ALIGNED_A(a, t, v, __VA_ARGS__,,))
  410. #if HAVE_LOCAL_ALIGNED_8
  411. # define LOCAL_ALIGNED_8(t, v, ...) E(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,))
  412. #else
  413. # define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED(8, t, v, __VA_ARGS__)
  414. #endif
  415. #if HAVE_LOCAL_ALIGNED_16
  416. # define LOCAL_ALIGNED_16(t, v, ...) E(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,))
  417. #else
  418. # define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__)
  419. #endif
  420. #define WRAPPER8_16_SQ(name8, name16)\
  421. static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
  422. int score=0;\
  423. score +=name8(s, dst , src , stride, 8);\
  424. score +=name8(s, dst+8 , src+8 , stride, 8);\
  425. if(h==16){\
  426. dst += 8*stride;\
  427. src += 8*stride;\
  428. score +=name8(s, dst , src , stride, 8);\
  429. score +=name8(s, dst+8 , src+8 , stride, 8);\
  430. }\
  431. return score;\
  432. }
  433. #endif /* AVCODEC_DSPUTIL_H */