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.

488 lines
24KB

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