2
0

vc1dsp_mmx.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /*
  2. * VC-1 and WMV3 - DSP functions MMX-optimized
  3. * Copyright (c) 2007 Christophe GISQUET <christophe.gisquet@free.fr>
  4. *
  5. * Permission is hereby granted, free of charge, to any person
  6. * obtaining a copy of this software and associated documentation
  7. * files (the "Software"), to deal in the Software without
  8. * restriction, including without limitation the rights to use,
  9. * copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following
  12. * conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  19. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  21. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. */
  26. #include "libavutil/cpu.h"
  27. #include "libavutil/mem.h"
  28. #include "libavutil/x86/asm.h"
  29. #include "libavutil/x86/cpu.h"
  30. #include "libavcodec/vc1dsp.h"
  31. #include "constants.h"
  32. #include "fpel.h"
  33. #include "vc1dsp.h"
  34. #if HAVE_6REGS && HAVE_INLINE_ASM && HAVE_MMX_EXTERNAL
  35. void ff_vc1_put_ver_16b_shift2_mmx(int16_t *dst,
  36. const uint8_t *src, x86_reg stride,
  37. int rnd, int64_t shift);
  38. void ff_vc1_put_hor_16b_shift2_mmx(uint8_t *dst, x86_reg stride,
  39. const int16_t *src, int rnd);
  40. void ff_vc1_avg_hor_16b_shift2_mmxext(uint8_t *dst, x86_reg stride,
  41. const int16_t *src, int rnd);
  42. #define OP_PUT(S,D)
  43. #define OP_AVG(S,D) "pavgb " #S ", " #D " \n\t"
  44. /** Add rounder from mm7 to mm3 and pack result at destination */
  45. #define NORMALIZE_MMX(SHIFT) \
  46. "paddw %%mm7, %%mm3 \n\t" /* +bias-r */ \
  47. "paddw %%mm7, %%mm4 \n\t" /* +bias-r */ \
  48. "psraw "SHIFT", %%mm3 \n\t" \
  49. "psraw "SHIFT", %%mm4 \n\t"
  50. #define TRANSFER_DO_PACK(OP) \
  51. "packuswb %%mm4, %%mm3 \n\t" \
  52. OP((%2), %%mm3) \
  53. "movq %%mm3, (%2) \n\t"
  54. #define TRANSFER_DONT_PACK(OP) \
  55. OP(0(%2), %%mm3) \
  56. OP(8(%2), %%mm4) \
  57. "movq %%mm3, 0(%2) \n\t" \
  58. "movq %%mm4, 8(%2) \n\t"
  59. /** @see MSPEL_FILTER13_CORE for use as UNPACK macro */
  60. #define DO_UNPACK(reg) "punpcklbw %%mm0, " reg "\n\t"
  61. #define DONT_UNPACK(reg)
  62. /** Compute the rounder 32-r or 8-r and unpacks it to mm7 */
  63. #define LOAD_ROUNDER_MMX(ROUND) \
  64. "movd "ROUND", %%mm7 \n\t" \
  65. "punpcklwd %%mm7, %%mm7 \n\t" \
  66. "punpckldq %%mm7, %%mm7 \n\t"
  67. /**
  68. * Purely vertical or horizontal 1/2 shift interpolation.
  69. * Sacrifice mm6 for *9 factor.
  70. */
  71. #define VC1_SHIFT2(OP, OPNAME)\
  72. static void OPNAME ## vc1_shift2_mmx(uint8_t *dst, const uint8_t *src,\
  73. x86_reg stride, int rnd, x86_reg offset)\
  74. {\
  75. rnd = 8-rnd;\
  76. __asm__ volatile(\
  77. "mov $8, %%"FF_REG_c" \n\t"\
  78. LOAD_ROUNDER_MMX("%5")\
  79. "movq "MANGLE(ff_pw_9)", %%mm6\n\t"\
  80. "1: \n\t"\
  81. "movd 0(%0 ), %%mm3 \n\t"\
  82. "movd 4(%0 ), %%mm4 \n\t"\
  83. "movd 0(%0,%2), %%mm1 \n\t"\
  84. "movd 4(%0,%2), %%mm2 \n\t"\
  85. "add %2, %0 \n\t"\
  86. "punpcklbw %%mm0, %%mm3 \n\t"\
  87. "punpcklbw %%mm0, %%mm4 \n\t"\
  88. "punpcklbw %%mm0, %%mm1 \n\t"\
  89. "punpcklbw %%mm0, %%mm2 \n\t"\
  90. "paddw %%mm1, %%mm3 \n\t"\
  91. "paddw %%mm2, %%mm4 \n\t"\
  92. "movd 0(%0,%3), %%mm1 \n\t"\
  93. "movd 4(%0,%3), %%mm2 \n\t"\
  94. "pmullw %%mm6, %%mm3 \n\t" /* 0,9,9,0*/\
  95. "pmullw %%mm6, %%mm4 \n\t" /* 0,9,9,0*/\
  96. "punpcklbw %%mm0, %%mm1 \n\t"\
  97. "punpcklbw %%mm0, %%mm2 \n\t"\
  98. "psubw %%mm1, %%mm3 \n\t" /*-1,9,9,0*/\
  99. "psubw %%mm2, %%mm4 \n\t" /*-1,9,9,0*/\
  100. "movd 0(%0,%2), %%mm1 \n\t"\
  101. "movd 4(%0,%2), %%mm2 \n\t"\
  102. "punpcklbw %%mm0, %%mm1 \n\t"\
  103. "punpcklbw %%mm0, %%mm2 \n\t"\
  104. "psubw %%mm1, %%mm3 \n\t" /*-1,9,9,-1*/\
  105. "psubw %%mm2, %%mm4 \n\t" /*-1,9,9,-1*/\
  106. NORMALIZE_MMX("$4")\
  107. "packuswb %%mm4, %%mm3 \n\t"\
  108. OP((%1), %%mm3)\
  109. "movq %%mm3, (%1) \n\t"\
  110. "add %6, %0 \n\t"\
  111. "add %4, %1 \n\t"\
  112. "dec %%"FF_REG_c" \n\t"\
  113. "jnz 1b \n\t"\
  114. : "+r"(src), "+r"(dst)\
  115. : "r"(offset), "r"(-2*offset), "g"(stride), "m"(rnd),\
  116. "g"(stride-offset)\
  117. NAMED_CONSTRAINTS_ADD(ff_pw_9)\
  118. : "%"FF_REG_c, "memory"\
  119. );\
  120. }
  121. VC1_SHIFT2(OP_PUT, put_)
  122. VC1_SHIFT2(OP_AVG, avg_)
  123. /**
  124. * Core of the 1/4 and 3/4 shift bicubic interpolation.
  125. *
  126. * @param UNPACK Macro unpacking arguments from 8 to 16 bits (can be empty).
  127. * @param MOVQ "movd 1" or "movq 2", if data read is already unpacked.
  128. * @param A1 Address of 1st tap (beware of unpacked/packed).
  129. * @param A2 Address of 2nd tap
  130. * @param A3 Address of 3rd tap
  131. * @param A4 Address of 4th tap
  132. */
  133. #define MSPEL_FILTER13_CORE(UNPACK, MOVQ, A1, A2, A3, A4) \
  134. MOVQ "*0+"A1", %%mm1 \n\t" \
  135. MOVQ "*4+"A1", %%mm2 \n\t" \
  136. UNPACK("%%mm1") \
  137. UNPACK("%%mm2") \
  138. "pmullw "MANGLE(ff_pw_3)", %%mm1\n\t" \
  139. "pmullw "MANGLE(ff_pw_3)", %%mm2\n\t" \
  140. MOVQ "*0+"A2", %%mm3 \n\t" \
  141. MOVQ "*4+"A2", %%mm4 \n\t" \
  142. UNPACK("%%mm3") \
  143. UNPACK("%%mm4") \
  144. "pmullw %%mm6, %%mm3 \n\t" /* *18 */ \
  145. "pmullw %%mm6, %%mm4 \n\t" /* *18 */ \
  146. "psubw %%mm1, %%mm3 \n\t" /* 18,-3 */ \
  147. "psubw %%mm2, %%mm4 \n\t" /* 18,-3 */ \
  148. MOVQ "*0+"A4", %%mm1 \n\t" \
  149. MOVQ "*4+"A4", %%mm2 \n\t" \
  150. UNPACK("%%mm1") \
  151. UNPACK("%%mm2") \
  152. "psllw $2, %%mm1 \n\t" /* 4* */ \
  153. "psllw $2, %%mm2 \n\t" /* 4* */ \
  154. "psubw %%mm1, %%mm3 \n\t" /* -4,18,-3 */ \
  155. "psubw %%mm2, %%mm4 \n\t" /* -4,18,-3 */ \
  156. MOVQ "*0+"A3", %%mm1 \n\t" \
  157. MOVQ "*4+"A3", %%mm2 \n\t" \
  158. UNPACK("%%mm1") \
  159. UNPACK("%%mm2") \
  160. "pmullw %%mm5, %%mm1 \n\t" /* *53 */ \
  161. "pmullw %%mm5, %%mm2 \n\t" /* *53 */ \
  162. "paddw %%mm1, %%mm3 \n\t" /* 4,53,18,-3 */ \
  163. "paddw %%mm2, %%mm4 \n\t" /* 4,53,18,-3 */
  164. /**
  165. * Macro to build the vertical 16 bits version of vc1_put_shift[13].
  166. * Here, offset=src_stride. Parameters passed A1 to A4 must use
  167. * %3 (src_stride) and %4 (3*src_stride).
  168. *
  169. * @param NAME Either 1 or 3
  170. * @see MSPEL_FILTER13_CORE for information on A1->A4
  171. */
  172. #define MSPEL_FILTER13_VER_16B(NAME, A1, A2, A3, A4) \
  173. static void \
  174. vc1_put_ver_16b_ ## NAME ## _mmx(int16_t *dst, const uint8_t *src, \
  175. x86_reg src_stride, \
  176. int rnd, int64_t shift) \
  177. { \
  178. int h = 8; \
  179. src -= src_stride; \
  180. __asm__ volatile( \
  181. LOAD_ROUNDER_MMX("%5") \
  182. "movq "MANGLE(ff_pw_53)", %%mm5\n\t" \
  183. "movq "MANGLE(ff_pw_18)", %%mm6\n\t" \
  184. ".p2align 3 \n\t" \
  185. "1: \n\t" \
  186. MSPEL_FILTER13_CORE(DO_UNPACK, "movd 1", A1, A2, A3, A4) \
  187. NORMALIZE_MMX("%6") \
  188. TRANSFER_DONT_PACK(OP_PUT) \
  189. /* Last 3 (in fact 4) bytes on the line */ \
  190. "movd 8+"A1", %%mm1 \n\t" \
  191. DO_UNPACK("%%mm1") \
  192. "movq %%mm1, %%mm3 \n\t" \
  193. "paddw %%mm1, %%mm1 \n\t" \
  194. "paddw %%mm3, %%mm1 \n\t" /* 3* */ \
  195. "movd 8+"A2", %%mm3 \n\t" \
  196. DO_UNPACK("%%mm3") \
  197. "pmullw %%mm6, %%mm3 \n\t" /* *18 */ \
  198. "psubw %%mm1, %%mm3 \n\t" /*18,-3 */ \
  199. "movd 8+"A3", %%mm1 \n\t" \
  200. DO_UNPACK("%%mm1") \
  201. "pmullw %%mm5, %%mm1 \n\t" /* *53 */ \
  202. "paddw %%mm1, %%mm3 \n\t" /*53,18,-3 */ \
  203. "movd 8+"A4", %%mm1 \n\t" \
  204. DO_UNPACK("%%mm1") \
  205. "psllw $2, %%mm1 \n\t" /* 4* */ \
  206. "psubw %%mm1, %%mm3 \n\t" \
  207. "paddw %%mm7, %%mm3 \n\t" \
  208. "psraw %6, %%mm3 \n\t" \
  209. "movq %%mm3, 16(%2) \n\t" \
  210. "add %3, %1 \n\t" \
  211. "add $24, %2 \n\t" \
  212. "decl %0 \n\t" \
  213. "jnz 1b \n\t" \
  214. : "+r"(h), "+r" (src), "+r" (dst) \
  215. : "r"(src_stride), "r"(3*src_stride), \
  216. "m"(rnd), "m"(shift) \
  217. NAMED_CONSTRAINTS_ADD(ff_pw_3,ff_pw_53,ff_pw_18) \
  218. : "memory" \
  219. ); \
  220. }
  221. /**
  222. * Macro to build the horizontal 16 bits version of vc1_put_shift[13].
  223. * Here, offset=16 bits, so parameters passed A1 to A4 should be simple.
  224. *
  225. * @param NAME Either 1 or 3
  226. * @see MSPEL_FILTER13_CORE for information on A1->A4
  227. */
  228. #define MSPEL_FILTER13_HOR_16B(NAME, A1, A2, A3, A4, OP, OPNAME) \
  229. static void \
  230. OPNAME ## vc1_hor_16b_ ## NAME ## _mmx(uint8_t *dst, x86_reg stride, \
  231. const int16_t *src, int rnd) \
  232. { \
  233. int h = 8; \
  234. src -= 1; \
  235. rnd -= (-4+58+13-3)*256; /* Add -256 bias */ \
  236. __asm__ volatile( \
  237. LOAD_ROUNDER_MMX("%4") \
  238. "movq "MANGLE(ff_pw_18)", %%mm6 \n\t" \
  239. "movq "MANGLE(ff_pw_53)", %%mm5 \n\t" \
  240. ".p2align 3 \n\t" \
  241. "1: \n\t" \
  242. MSPEL_FILTER13_CORE(DONT_UNPACK, "movq 2", A1, A2, A3, A4) \
  243. NORMALIZE_MMX("$7") \
  244. /* Remove bias */ \
  245. "paddw "MANGLE(ff_pw_128)", %%mm3 \n\t" \
  246. "paddw "MANGLE(ff_pw_128)", %%mm4 \n\t" \
  247. TRANSFER_DO_PACK(OP) \
  248. "add $24, %1 \n\t" \
  249. "add %3, %2 \n\t" \
  250. "decl %0 \n\t" \
  251. "jnz 1b \n\t" \
  252. : "+r"(h), "+r" (src), "+r" (dst) \
  253. : "r"(stride), "m"(rnd) \
  254. NAMED_CONSTRAINTS_ADD(ff_pw_3,ff_pw_18,ff_pw_53,ff_pw_128) \
  255. : "memory" \
  256. ); \
  257. }
  258. /**
  259. * Macro to build the 8 bits, any direction, version of vc1_put_shift[13].
  260. * Here, offset=src_stride. Parameters passed A1 to A4 must use
  261. * %3 (offset) and %4 (3*offset).
  262. *
  263. * @param NAME Either 1 or 3
  264. * @see MSPEL_FILTER13_CORE for information on A1->A4
  265. */
  266. #define MSPEL_FILTER13_8B(NAME, A1, A2, A3, A4, OP, OPNAME) \
  267. static void \
  268. OPNAME ## vc1_## NAME ## _mmx(uint8_t *dst, const uint8_t *src, \
  269. x86_reg stride, int rnd, x86_reg offset) \
  270. { \
  271. int h = 8; \
  272. src -= offset; \
  273. rnd = 32-rnd; \
  274. __asm__ volatile ( \
  275. LOAD_ROUNDER_MMX("%6") \
  276. "movq "MANGLE(ff_pw_53)", %%mm5 \n\t" \
  277. "movq "MANGLE(ff_pw_18)", %%mm6 \n\t" \
  278. ".p2align 3 \n\t" \
  279. "1: \n\t" \
  280. MSPEL_FILTER13_CORE(DO_UNPACK, "movd 1", A1, A2, A3, A4) \
  281. NORMALIZE_MMX("$6") \
  282. TRANSFER_DO_PACK(OP) \
  283. "add %5, %1 \n\t" \
  284. "add %5, %2 \n\t" \
  285. "decl %0 \n\t" \
  286. "jnz 1b \n\t" \
  287. : "+r"(h), "+r" (src), "+r" (dst) \
  288. : "r"(offset), "r"(3*offset), "g"(stride), "m"(rnd) \
  289. NAMED_CONSTRAINTS_ADD(ff_pw_53,ff_pw_18,ff_pw_3) \
  290. : "memory" \
  291. ); \
  292. }
  293. /** 1/4 shift bicubic interpolation */
  294. MSPEL_FILTER13_8B (shift1, "0(%1,%4 )", "0(%1,%3,2)", "0(%1,%3 )", "0(%1 )", OP_PUT, put_)
  295. MSPEL_FILTER13_8B (shift1, "0(%1,%4 )", "0(%1,%3,2)", "0(%1,%3 )", "0(%1 )", OP_AVG, avg_)
  296. MSPEL_FILTER13_VER_16B(shift1, "0(%1,%4 )", "0(%1,%3,2)", "0(%1,%3 )", "0(%1 )")
  297. MSPEL_FILTER13_HOR_16B(shift1, "2*3(%1)", "2*2(%1)", "2*1(%1)", "2*0(%1)", OP_PUT, put_)
  298. MSPEL_FILTER13_HOR_16B(shift1, "2*3(%1)", "2*2(%1)", "2*1(%1)", "2*0(%1)", OP_AVG, avg_)
  299. /** 3/4 shift bicubic interpolation */
  300. MSPEL_FILTER13_8B (shift3, "0(%1 )", "0(%1,%3 )", "0(%1,%3,2)", "0(%1,%4 )", OP_PUT, put_)
  301. MSPEL_FILTER13_8B (shift3, "0(%1 )", "0(%1,%3 )", "0(%1,%3,2)", "0(%1,%4 )", OP_AVG, avg_)
  302. MSPEL_FILTER13_VER_16B(shift3, "0(%1 )", "0(%1,%3 )", "0(%1,%3,2)", "0(%1,%4 )")
  303. MSPEL_FILTER13_HOR_16B(shift3, "2*0(%1)", "2*1(%1)", "2*2(%1)", "2*3(%1)", OP_PUT, put_)
  304. MSPEL_FILTER13_HOR_16B(shift3, "2*0(%1)", "2*1(%1)", "2*2(%1)", "2*3(%1)", OP_AVG, avg_)
  305. typedef void (*vc1_mspel_mc_filter_ver_16bits)(int16_t *dst, const uint8_t *src, x86_reg src_stride, int rnd, int64_t shift);
  306. typedef void (*vc1_mspel_mc_filter_hor_16bits)(uint8_t *dst, x86_reg dst_stride, const int16_t *src, int rnd);
  307. typedef void (*vc1_mspel_mc_filter_8bits)(uint8_t *dst, const uint8_t *src, x86_reg stride, int rnd, x86_reg offset);
  308. /**
  309. * Interpolate fractional pel values by applying proper vertical then
  310. * horizontal filter.
  311. *
  312. * @param dst Destination buffer for interpolated pels.
  313. * @param src Source buffer.
  314. * @param stride Stride for both src and dst buffers.
  315. * @param hmode Horizontal filter (expressed in quarter pixels shift).
  316. * @param hmode Vertical filter.
  317. * @param rnd Rounding bias.
  318. */
  319. #define VC1_MSPEL_MC(OP, INSTR)\
  320. static void OP ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride,\
  321. int hmode, int vmode, int rnd)\
  322. {\
  323. static const vc1_mspel_mc_filter_ver_16bits vc1_put_shift_ver_16bits[] =\
  324. { NULL, vc1_put_ver_16b_shift1_mmx, ff_vc1_put_ver_16b_shift2_mmx, vc1_put_ver_16b_shift3_mmx };\
  325. static const vc1_mspel_mc_filter_hor_16bits vc1_put_shift_hor_16bits[] =\
  326. { NULL, OP ## vc1_hor_16b_shift1_mmx, ff_vc1_ ## OP ## hor_16b_shift2_ ## INSTR, OP ## vc1_hor_16b_shift3_mmx };\
  327. static const vc1_mspel_mc_filter_8bits vc1_put_shift_8bits[] =\
  328. { NULL, OP ## vc1_shift1_mmx, OP ## vc1_shift2_mmx, OP ## vc1_shift3_mmx };\
  329. \
  330. __asm__ volatile(\
  331. "pxor %%mm0, %%mm0 \n\t"\
  332. ::: "memory"\
  333. );\
  334. \
  335. if (vmode) { /* Vertical filter to apply */\
  336. if (hmode) { /* Horizontal filter to apply, output to tmp */\
  337. static const int shift_value[] = { 0, 5, 1, 5 };\
  338. int shift = (shift_value[hmode]+shift_value[vmode])>>1;\
  339. int r;\
  340. LOCAL_ALIGNED(16, int16_t, tmp, [12*8]);\
  341. \
  342. r = (1<<(shift-1)) + rnd-1;\
  343. vc1_put_shift_ver_16bits[vmode](tmp, src-1, stride, r, shift);\
  344. \
  345. vc1_put_shift_hor_16bits[hmode](dst, stride, tmp+1, 64-rnd);\
  346. return;\
  347. }\
  348. else { /* No horizontal filter, output 8 lines to dst */\
  349. vc1_put_shift_8bits[vmode](dst, src, stride, 1-rnd, stride);\
  350. return;\
  351. }\
  352. }\
  353. \
  354. /* Horizontal mode with no vertical mode */\
  355. vc1_put_shift_8bits[hmode](dst, src, stride, rnd, 1);\
  356. } \
  357. static void OP ## vc1_mspel_mc_16(uint8_t *dst, const uint8_t *src, \
  358. int stride, int hmode, int vmode, int rnd)\
  359. { \
  360. OP ## vc1_mspel_mc(dst + 0, src + 0, stride, hmode, vmode, rnd); \
  361. OP ## vc1_mspel_mc(dst + 8, src + 8, stride, hmode, vmode, rnd); \
  362. dst += 8*stride; src += 8*stride; \
  363. OP ## vc1_mspel_mc(dst + 0, src + 0, stride, hmode, vmode, rnd); \
  364. OP ## vc1_mspel_mc(dst + 8, src + 8, stride, hmode, vmode, rnd); \
  365. }
  366. VC1_MSPEL_MC(put_, mmx)
  367. VC1_MSPEL_MC(avg_, mmxext)
  368. /** Macro to ease bicubic filter interpolation functions declarations */
  369. #define DECLARE_FUNCTION(a, b) \
  370. static void put_vc1_mspel_mc ## a ## b ## _mmx(uint8_t *dst, \
  371. const uint8_t *src, \
  372. ptrdiff_t stride, \
  373. int rnd) \
  374. { \
  375. put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
  376. }\
  377. static void avg_vc1_mspel_mc ## a ## b ## _mmxext(uint8_t *dst, \
  378. const uint8_t *src, \
  379. ptrdiff_t stride, \
  380. int rnd) \
  381. { \
  382. avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
  383. }\
  384. static void put_vc1_mspel_mc ## a ## b ## _16_mmx(uint8_t *dst, \
  385. const uint8_t *src, \
  386. ptrdiff_t stride, \
  387. int rnd) \
  388. { \
  389. put_vc1_mspel_mc_16(dst, src, stride, a, b, rnd); \
  390. }\
  391. static void avg_vc1_mspel_mc ## a ## b ## _16_mmxext(uint8_t *dst, \
  392. const uint8_t *src,\
  393. ptrdiff_t stride, \
  394. int rnd) \
  395. { \
  396. avg_vc1_mspel_mc_16(dst, src, stride, a, b, rnd); \
  397. }
  398. DECLARE_FUNCTION(0, 1)
  399. DECLARE_FUNCTION(0, 2)
  400. DECLARE_FUNCTION(0, 3)
  401. DECLARE_FUNCTION(1, 0)
  402. DECLARE_FUNCTION(1, 1)
  403. DECLARE_FUNCTION(1, 2)
  404. DECLARE_FUNCTION(1, 3)
  405. DECLARE_FUNCTION(2, 0)
  406. DECLARE_FUNCTION(2, 1)
  407. DECLARE_FUNCTION(2, 2)
  408. DECLARE_FUNCTION(2, 3)
  409. DECLARE_FUNCTION(3, 0)
  410. DECLARE_FUNCTION(3, 1)
  411. DECLARE_FUNCTION(3, 2)
  412. DECLARE_FUNCTION(3, 3)
  413. #define FN_ASSIGN(OP, X, Y, INSN) \
  414. dsp->OP##vc1_mspel_pixels_tab[1][X+4*Y] = OP##vc1_mspel_mc##X##Y##INSN; \
  415. dsp->OP##vc1_mspel_pixels_tab[0][X+4*Y] = OP##vc1_mspel_mc##X##Y##_16##INSN
  416. av_cold void ff_vc1dsp_init_mmx(VC1DSPContext *dsp)
  417. {
  418. FN_ASSIGN(put_, 0, 1, _mmx);
  419. FN_ASSIGN(put_, 0, 2, _mmx);
  420. FN_ASSIGN(put_, 0, 3, _mmx);
  421. FN_ASSIGN(put_, 1, 0, _mmx);
  422. FN_ASSIGN(put_, 1, 1, _mmx);
  423. FN_ASSIGN(put_, 1, 2, _mmx);
  424. FN_ASSIGN(put_, 1, 3, _mmx);
  425. FN_ASSIGN(put_, 2, 0, _mmx);
  426. FN_ASSIGN(put_, 2, 1, _mmx);
  427. FN_ASSIGN(put_, 2, 2, _mmx);
  428. FN_ASSIGN(put_, 2, 3, _mmx);
  429. FN_ASSIGN(put_, 3, 0, _mmx);
  430. FN_ASSIGN(put_, 3, 1, _mmx);
  431. FN_ASSIGN(put_, 3, 2, _mmx);
  432. FN_ASSIGN(put_, 3, 3, _mmx);
  433. }
  434. av_cold void ff_vc1dsp_init_mmxext(VC1DSPContext *dsp)
  435. {
  436. FN_ASSIGN(avg_, 0, 1, _mmxext);
  437. FN_ASSIGN(avg_, 0, 2, _mmxext);
  438. FN_ASSIGN(avg_, 0, 3, _mmxext);
  439. FN_ASSIGN(avg_, 1, 0, _mmxext);
  440. FN_ASSIGN(avg_, 1, 1, _mmxext);
  441. FN_ASSIGN(avg_, 1, 2, _mmxext);
  442. FN_ASSIGN(avg_, 1, 3, _mmxext);
  443. FN_ASSIGN(avg_, 2, 0, _mmxext);
  444. FN_ASSIGN(avg_, 2, 1, _mmxext);
  445. FN_ASSIGN(avg_, 2, 2, _mmxext);
  446. FN_ASSIGN(avg_, 2, 3, _mmxext);
  447. FN_ASSIGN(avg_, 3, 0, _mmxext);
  448. FN_ASSIGN(avg_, 3, 1, _mmxext);
  449. FN_ASSIGN(avg_, 3, 2, _mmxext);
  450. FN_ASSIGN(avg_, 3, 3, _mmxext);
  451. }
  452. #endif /* HAVE_6REGS && HAVE_INLINE_ASM && HAVE_MMX_EXTERNAL */