vc1dsp_mmx.c 23 KB

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