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.

579 lines
18KB

  1. /*
  2. * MMX optimized forward DCT
  3. * The gcc porting is Copyright (c) 2001 Fabrice Bellard.
  4. * cleanup/optimizations are Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  5. * SSE2 optimization is Copyright (c) 2004 Denes Balatoni.
  6. *
  7. * from fdctam32.c - AP922 MMX(3D-Now) forward-DCT
  8. *
  9. * Intel Application Note AP-922 - fast, precise implementation of DCT
  10. * http://developer.intel.com/vtune/cbts/appnotes.htm
  11. *
  12. * Also of inspiration:
  13. * a page about fdct at http://www.geocities.com/ssavekar/dct.htm
  14. * Skal's fdct at http://skal.planet-d.net/coding/dct.html
  15. *
  16. * This file is part of FFmpeg.
  17. *
  18. * FFmpeg is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU Lesser General Public
  20. * License as published by the Free Software Foundation; either
  21. * version 2.1 of the License, or (at your option) any later version.
  22. *
  23. * FFmpeg is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. * Lesser General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU Lesser General Public
  29. * License along with FFmpeg; if not, write to the Free Software
  30. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  31. */
  32. #include "libavutil/common.h"
  33. #include "libavcodec/dsputil.h"
  34. //////////////////////////////////////////////////////////////////////
  35. //
  36. // constants for the forward DCT
  37. // -----------------------------
  38. //
  39. // Be sure to check that your compiler is aligning all constants to QWORD
  40. // (8-byte) memory boundaries! Otherwise the unaligned memory access will
  41. // severely stall MMX execution.
  42. //
  43. //////////////////////////////////////////////////////////////////////
  44. #define BITS_FRW_ACC 3 //; 2 or 3 for accuracy
  45. #define SHIFT_FRW_COL BITS_FRW_ACC
  46. #define SHIFT_FRW_ROW (BITS_FRW_ACC + 17 - 3)
  47. #define RND_FRW_ROW (1 << (SHIFT_FRW_ROW-1))
  48. //#define RND_FRW_COL (1 << (SHIFT_FRW_COL-1))
  49. #define X8(x) x,x,x,x,x,x,x,x
  50. //concatenated table, for forward DCT transformation
  51. DECLARE_ALIGNED(16, static const int16_t, fdct_tg_all_16)[24] = {
  52. X8(13036), // tg * (2<<16) + 0.5
  53. X8(27146), // tg * (2<<16) + 0.5
  54. X8(-21746) // tg * (2<<16) + 0.5
  55. };
  56. DECLARE_ALIGNED(16, static const int16_t, ocos_4_16)[8] = {
  57. X8(23170) //cos * (2<<15) + 0.5
  58. };
  59. DECLARE_ALIGNED(16, static const int16_t, fdct_one_corr)[8] = { X8(1) };
  60. DECLARE_ALIGNED(8, static const int32_t, fdct_r_row)[2] = {RND_FRW_ROW, RND_FRW_ROW };
  61. static struct
  62. {
  63. DECLARE_ALIGNED(16, const int32_t, fdct_r_row_sse2)[4];
  64. } fdct_r_row_sse2 =
  65. {{
  66. RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW
  67. }};
  68. //DECLARE_ALIGNED(16, static const long, fdct_r_row_sse2)[4] = {RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW};
  69. DECLARE_ALIGNED(8, static const int16_t, tab_frw_01234567)[] = { // forward_dct coeff table
  70. 16384, 16384, 22725, 19266,
  71. 16384, 16384, 12873, 4520,
  72. 21407, 8867, 19266, -4520,
  73. -8867, -21407, -22725, -12873,
  74. 16384, -16384, 12873, -22725,
  75. -16384, 16384, 4520, 19266,
  76. 8867, -21407, 4520, -12873,
  77. 21407, -8867, 19266, -22725,
  78. 22725, 22725, 31521, 26722,
  79. 22725, 22725, 17855, 6270,
  80. 29692, 12299, 26722, -6270,
  81. -12299, -29692, -31521, -17855,
  82. 22725, -22725, 17855, -31521,
  83. -22725, 22725, 6270, 26722,
  84. 12299, -29692, 6270, -17855,
  85. 29692, -12299, 26722, -31521,
  86. 21407, 21407, 29692, 25172,
  87. 21407, 21407, 16819, 5906,
  88. 27969, 11585, 25172, -5906,
  89. -11585, -27969, -29692, -16819,
  90. 21407, -21407, 16819, -29692,
  91. -21407, 21407, 5906, 25172,
  92. 11585, -27969, 5906, -16819,
  93. 27969, -11585, 25172, -29692,
  94. 19266, 19266, 26722, 22654,
  95. 19266, 19266, 15137, 5315,
  96. 25172, 10426, 22654, -5315,
  97. -10426, -25172, -26722, -15137,
  98. 19266, -19266, 15137, -26722,
  99. -19266, 19266, 5315, 22654,
  100. 10426, -25172, 5315, -15137,
  101. 25172, -10426, 22654, -26722,
  102. 16384, 16384, 22725, 19266,
  103. 16384, 16384, 12873, 4520,
  104. 21407, 8867, 19266, -4520,
  105. -8867, -21407, -22725, -12873,
  106. 16384, -16384, 12873, -22725,
  107. -16384, 16384, 4520, 19266,
  108. 8867, -21407, 4520, -12873,
  109. 21407, -8867, 19266, -22725,
  110. 19266, 19266, 26722, 22654,
  111. 19266, 19266, 15137, 5315,
  112. 25172, 10426, 22654, -5315,
  113. -10426, -25172, -26722, -15137,
  114. 19266, -19266, 15137, -26722,
  115. -19266, 19266, 5315, 22654,
  116. 10426, -25172, 5315, -15137,
  117. 25172, -10426, 22654, -26722,
  118. 21407, 21407, 29692, 25172,
  119. 21407, 21407, 16819, 5906,
  120. 27969, 11585, 25172, -5906,
  121. -11585, -27969, -29692, -16819,
  122. 21407, -21407, 16819, -29692,
  123. -21407, 21407, 5906, 25172,
  124. 11585, -27969, 5906, -16819,
  125. 27969, -11585, 25172, -29692,
  126. 22725, 22725, 31521, 26722,
  127. 22725, 22725, 17855, 6270,
  128. 29692, 12299, 26722, -6270,
  129. -12299, -29692, -31521, -17855,
  130. 22725, -22725, 17855, -31521,
  131. -22725, 22725, 6270, 26722,
  132. 12299, -29692, 6270, -17855,
  133. 29692, -12299, 26722, -31521,
  134. };
  135. static struct
  136. {
  137. DECLARE_ALIGNED(16, const int16_t, tab_frw_01234567_sse2)[256];
  138. } tab_frw_01234567_sse2 =
  139. {{
  140. //DECLARE_ALIGNED(16, static const int16_t, tab_frw_01234567_sse2)[] = { // forward_dct coeff table
  141. #define TABLE_SSE2 C4, C4, C1, C3, -C6, -C2, -C1, -C5, \
  142. C4, C4, C5, C7, C2, C6, C3, -C7, \
  143. -C4, C4, C7, C3, C6, -C2, C7, -C5, \
  144. C4, -C4, C5, -C1, C2, -C6, C3, -C1,
  145. // c1..c7 * cos(pi/4) * 2^15
  146. #define C1 22725
  147. #define C2 21407
  148. #define C3 19266
  149. #define C4 16384
  150. #define C5 12873
  151. #define C6 8867
  152. #define C7 4520
  153. TABLE_SSE2
  154. #undef C1
  155. #undef C2
  156. #undef C3
  157. #undef C4
  158. #undef C5
  159. #undef C6
  160. #undef C7
  161. #define C1 31521
  162. #define C2 29692
  163. #define C3 26722
  164. #define C4 22725
  165. #define C5 17855
  166. #define C6 12299
  167. #define C7 6270
  168. TABLE_SSE2
  169. #undef C1
  170. #undef C2
  171. #undef C3
  172. #undef C4
  173. #undef C5
  174. #undef C6
  175. #undef C7
  176. #define C1 29692
  177. #define C2 27969
  178. #define C3 25172
  179. #define C4 21407
  180. #define C5 16819
  181. #define C6 11585
  182. #define C7 5906
  183. TABLE_SSE2
  184. #undef C1
  185. #undef C2
  186. #undef C3
  187. #undef C4
  188. #undef C5
  189. #undef C6
  190. #undef C7
  191. #define C1 26722
  192. #define C2 25172
  193. #define C3 22654
  194. #define C4 19266
  195. #define C5 15137
  196. #define C6 10426
  197. #define C7 5315
  198. TABLE_SSE2
  199. #undef C1
  200. #undef C2
  201. #undef C3
  202. #undef C4
  203. #undef C5
  204. #undef C6
  205. #undef C7
  206. #define C1 22725
  207. #define C2 21407
  208. #define C3 19266
  209. #define C4 16384
  210. #define C5 12873
  211. #define C6 8867
  212. #define C7 4520
  213. TABLE_SSE2
  214. #undef C1
  215. #undef C2
  216. #undef C3
  217. #undef C4
  218. #undef C5
  219. #undef C6
  220. #undef C7
  221. #define C1 26722
  222. #define C2 25172
  223. #define C3 22654
  224. #define C4 19266
  225. #define C5 15137
  226. #define C6 10426
  227. #define C7 5315
  228. TABLE_SSE2
  229. #undef C1
  230. #undef C2
  231. #undef C3
  232. #undef C4
  233. #undef C5
  234. #undef C6
  235. #undef C7
  236. #define C1 29692
  237. #define C2 27969
  238. #define C3 25172
  239. #define C4 21407
  240. #define C5 16819
  241. #define C6 11585
  242. #define C7 5906
  243. TABLE_SSE2
  244. #undef C1
  245. #undef C2
  246. #undef C3
  247. #undef C4
  248. #undef C5
  249. #undef C6
  250. #undef C7
  251. #define C1 31521
  252. #define C2 29692
  253. #define C3 26722
  254. #define C4 22725
  255. #define C5 17855
  256. #define C6 12299
  257. #define C7 6270
  258. TABLE_SSE2
  259. }};
  260. #define S(s) AV_TOSTRING(s) //AV_STRINGIFY is too long
  261. #define FDCT_COL(cpu, mm, mov)\
  262. static av_always_inline void fdct_col_##cpu(const int16_t *in, int16_t *out, int offset)\
  263. {\
  264. __asm__ volatile (\
  265. #mov" 16(%0), %%"#mm"0 \n\t" \
  266. #mov" 96(%0), %%"#mm"1 \n\t" \
  267. #mov" %%"#mm"0, %%"#mm"2 \n\t" \
  268. #mov" 32(%0), %%"#mm"3 \n\t" \
  269. "paddsw %%"#mm"1, %%"#mm"0 \n\t" \
  270. #mov" 80(%0), %%"#mm"4 \n\t" \
  271. "psllw $"S(SHIFT_FRW_COL)", %%"#mm"0 \n\t" \
  272. #mov" (%0), %%"#mm"5 \n\t" \
  273. "paddsw %%"#mm"3, %%"#mm"4 \n\t" \
  274. "paddsw 112(%0), %%"#mm"5 \n\t" \
  275. "psllw $"S(SHIFT_FRW_COL)", %%"#mm"4 \n\t" \
  276. #mov" %%"#mm"0, %%"#mm"6 \n\t" \
  277. "psubsw %%"#mm"1, %%"#mm"2 \n\t" \
  278. #mov" 16(%1), %%"#mm"1 \n\t" \
  279. "psubsw %%"#mm"4, %%"#mm"0 \n\t" \
  280. #mov" 48(%0), %%"#mm"7 \n\t" \
  281. "pmulhw %%"#mm"0, %%"#mm"1 \n\t" \
  282. "paddsw 64(%0), %%"#mm"7 \n\t" \
  283. "psllw $"S(SHIFT_FRW_COL)", %%"#mm"5 \n\t" \
  284. "paddsw %%"#mm"4, %%"#mm"6 \n\t" \
  285. "psllw $"S(SHIFT_FRW_COL)", %%"#mm"7 \n\t" \
  286. #mov" %%"#mm"5, %%"#mm"4 \n\t" \
  287. "psubsw %%"#mm"7, %%"#mm"5 \n\t" \
  288. "paddsw %%"#mm"5, %%"#mm"1 \n\t" \
  289. "paddsw %%"#mm"7, %%"#mm"4 \n\t" \
  290. "por (%2), %%"#mm"1 \n\t" \
  291. "psllw $"S(SHIFT_FRW_COL)"+1, %%"#mm"2 \n\t" \
  292. "pmulhw 16(%1), %%"#mm"5 \n\t" \
  293. #mov" %%"#mm"4, %%"#mm"7 \n\t" \
  294. "psubsw 80(%0), %%"#mm"3 \n\t" \
  295. "psubsw %%"#mm"6, %%"#mm"4 \n\t" \
  296. #mov" %%"#mm"1, 32(%3) \n\t" \
  297. "paddsw %%"#mm"6, %%"#mm"7 \n\t" \
  298. #mov" 48(%0), %%"#mm"1 \n\t" \
  299. "psllw $"S(SHIFT_FRW_COL)"+1, %%"#mm"3 \n\t" \
  300. "psubsw 64(%0), %%"#mm"1 \n\t" \
  301. #mov" %%"#mm"2, %%"#mm"6 \n\t" \
  302. #mov" %%"#mm"4, 64(%3) \n\t" \
  303. "paddsw %%"#mm"3, %%"#mm"2 \n\t" \
  304. "pmulhw (%4), %%"#mm"2 \n\t" \
  305. "psubsw %%"#mm"3, %%"#mm"6 \n\t" \
  306. "pmulhw (%4), %%"#mm"6 \n\t" \
  307. "psubsw %%"#mm"0, %%"#mm"5 \n\t" \
  308. "por (%2), %%"#mm"5 \n\t" \
  309. "psllw $"S(SHIFT_FRW_COL)", %%"#mm"1 \n\t" \
  310. "por (%2), %%"#mm"2 \n\t" \
  311. #mov" %%"#mm"1, %%"#mm"4 \n\t" \
  312. #mov" (%0), %%"#mm"3 \n\t" \
  313. "paddsw %%"#mm"6, %%"#mm"1 \n\t" \
  314. "psubsw 112(%0), %%"#mm"3 \n\t" \
  315. "psubsw %%"#mm"6, %%"#mm"4 \n\t" \
  316. #mov" (%1), %%"#mm"0 \n\t" \
  317. "psllw $"S(SHIFT_FRW_COL)", %%"#mm"3 \n\t" \
  318. #mov" 32(%1), %%"#mm"6 \n\t" \
  319. "pmulhw %%"#mm"1, %%"#mm"0 \n\t" \
  320. #mov" %%"#mm"7, (%3) \n\t" \
  321. "pmulhw %%"#mm"4, %%"#mm"6 \n\t" \
  322. #mov" %%"#mm"5, 96(%3) \n\t" \
  323. #mov" %%"#mm"3, %%"#mm"7 \n\t" \
  324. #mov" 32(%1), %%"#mm"5 \n\t" \
  325. "psubsw %%"#mm"2, %%"#mm"7 \n\t" \
  326. "paddsw %%"#mm"2, %%"#mm"3 \n\t" \
  327. "pmulhw %%"#mm"7, %%"#mm"5 \n\t" \
  328. "paddsw %%"#mm"3, %%"#mm"0 \n\t" \
  329. "paddsw %%"#mm"4, %%"#mm"6 \n\t" \
  330. "pmulhw (%1), %%"#mm"3 \n\t" \
  331. "por (%2), %%"#mm"0 \n\t" \
  332. "paddsw %%"#mm"7, %%"#mm"5 \n\t" \
  333. "psubsw %%"#mm"6, %%"#mm"7 \n\t" \
  334. #mov" %%"#mm"0, 16(%3) \n\t" \
  335. "paddsw %%"#mm"4, %%"#mm"5 \n\t" \
  336. #mov" %%"#mm"7, 48(%3) \n\t" \
  337. "psubsw %%"#mm"1, %%"#mm"3 \n\t" \
  338. #mov" %%"#mm"5, 80(%3) \n\t" \
  339. #mov" %%"#mm"3, 112(%3) \n\t" \
  340. : \
  341. : "r" (in + offset), "r" (fdct_tg_all_16), "r" (fdct_one_corr), \
  342. "r" (out + offset), "r" (ocos_4_16)); \
  343. }
  344. FDCT_COL(mmx, mm, movq)
  345. FDCT_COL(sse2, xmm, movdqa)
  346. static av_always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
  347. {
  348. __asm__ volatile(
  349. #define FDCT_ROW_SSE2_H1(i,t) \
  350. "movq " #i "(%0), %%xmm2 \n\t" \
  351. "movq " #i "+8(%0), %%xmm0 \n\t" \
  352. "movdqa " #t "+32(%1), %%xmm3 \n\t" \
  353. "movdqa " #t "+48(%1), %%xmm7 \n\t" \
  354. "movdqa " #t "(%1), %%xmm4 \n\t" \
  355. "movdqa " #t "+16(%1), %%xmm5 \n\t"
  356. #define FDCT_ROW_SSE2_H2(i,t) \
  357. "movq " #i "(%0), %%xmm2 \n\t" \
  358. "movq " #i "+8(%0), %%xmm0 \n\t" \
  359. "movdqa " #t "+32(%1), %%xmm3 \n\t" \
  360. "movdqa " #t "+48(%1), %%xmm7 \n\t"
  361. #define FDCT_ROW_SSE2(i) \
  362. "movq %%xmm2, %%xmm1 \n\t" \
  363. "pshuflw $27, %%xmm0, %%xmm0 \n\t" \
  364. "paddsw %%xmm0, %%xmm1 \n\t" \
  365. "psubsw %%xmm0, %%xmm2 \n\t" \
  366. "punpckldq %%xmm2, %%xmm1 \n\t" \
  367. "pshufd $78, %%xmm1, %%xmm2 \n\t" \
  368. "pmaddwd %%xmm2, %%xmm3 \n\t" \
  369. "pmaddwd %%xmm1, %%xmm7 \n\t" \
  370. "pmaddwd %%xmm5, %%xmm2 \n\t" \
  371. "pmaddwd %%xmm4, %%xmm1 \n\t" \
  372. "paddd %%xmm7, %%xmm3 \n\t" \
  373. "paddd %%xmm2, %%xmm1 \n\t" \
  374. "paddd %%xmm6, %%xmm3 \n\t" \
  375. "paddd %%xmm6, %%xmm1 \n\t" \
  376. "psrad %3, %%xmm3 \n\t" \
  377. "psrad %3, %%xmm1 \n\t" \
  378. "packssdw %%xmm3, %%xmm1 \n\t" \
  379. "movdqa %%xmm1, " #i "(%4) \n\t"
  380. "movdqa (%2), %%xmm6 \n\t"
  381. FDCT_ROW_SSE2_H1(0,0)
  382. FDCT_ROW_SSE2(0)
  383. FDCT_ROW_SSE2_H2(64,0)
  384. FDCT_ROW_SSE2(64)
  385. FDCT_ROW_SSE2_H1(16,64)
  386. FDCT_ROW_SSE2(16)
  387. FDCT_ROW_SSE2_H2(112,64)
  388. FDCT_ROW_SSE2(112)
  389. FDCT_ROW_SSE2_H1(32,128)
  390. FDCT_ROW_SSE2(32)
  391. FDCT_ROW_SSE2_H2(96,128)
  392. FDCT_ROW_SSE2(96)
  393. FDCT_ROW_SSE2_H1(48,192)
  394. FDCT_ROW_SSE2(48)
  395. FDCT_ROW_SSE2_H2(80,192)
  396. FDCT_ROW_SSE2(80)
  397. :
  398. : "r" (in), "r" (tab_frw_01234567_sse2.tab_frw_01234567_sse2), "r" (fdct_r_row_sse2.fdct_r_row_sse2), "i" (SHIFT_FRW_ROW), "r" (out)
  399. );
  400. }
  401. static av_always_inline void fdct_row_mmx2(const int16_t *in, int16_t *out, const int16_t *table)
  402. {
  403. __asm__ volatile (
  404. "pshufw $0x1B, 8(%0), %%mm5 \n\t"
  405. "movq (%0), %%mm0 \n\t"
  406. "movq %%mm0, %%mm1 \n\t"
  407. "paddsw %%mm5, %%mm0 \n\t"
  408. "psubsw %%mm5, %%mm1 \n\t"
  409. "movq %%mm0, %%mm2 \n\t"
  410. "punpckldq %%mm1, %%mm0 \n\t"
  411. "punpckhdq %%mm1, %%mm2 \n\t"
  412. "movq (%1), %%mm1 \n\t"
  413. "movq 8(%1), %%mm3 \n\t"
  414. "movq 16(%1), %%mm4 \n\t"
  415. "movq 24(%1), %%mm5 \n\t"
  416. "movq 32(%1), %%mm6 \n\t"
  417. "movq 40(%1), %%mm7 \n\t"
  418. "pmaddwd %%mm0, %%mm1 \n\t"
  419. "pmaddwd %%mm2, %%mm3 \n\t"
  420. "pmaddwd %%mm0, %%mm4 \n\t"
  421. "pmaddwd %%mm2, %%mm5 \n\t"
  422. "pmaddwd %%mm0, %%mm6 \n\t"
  423. "pmaddwd %%mm2, %%mm7 \n\t"
  424. "pmaddwd 48(%1), %%mm0 \n\t"
  425. "pmaddwd 56(%1), %%mm2 \n\t"
  426. "paddd %%mm1, %%mm3 \n\t"
  427. "paddd %%mm4, %%mm5 \n\t"
  428. "paddd %%mm6, %%mm7 \n\t"
  429. "paddd %%mm0, %%mm2 \n\t"
  430. "movq (%2), %%mm0 \n\t"
  431. "paddd %%mm0, %%mm3 \n\t"
  432. "paddd %%mm0, %%mm5 \n\t"
  433. "paddd %%mm0, %%mm7 \n\t"
  434. "paddd %%mm0, %%mm2 \n\t"
  435. "psrad $"S(SHIFT_FRW_ROW)", %%mm3 \n\t"
  436. "psrad $"S(SHIFT_FRW_ROW)", %%mm5 \n\t"
  437. "psrad $"S(SHIFT_FRW_ROW)", %%mm7 \n\t"
  438. "psrad $"S(SHIFT_FRW_ROW)", %%mm2 \n\t"
  439. "packssdw %%mm5, %%mm3 \n\t"
  440. "packssdw %%mm2, %%mm7 \n\t"
  441. "movq %%mm3, (%3) \n\t"
  442. "movq %%mm7, 8(%3) \n\t"
  443. :
  444. : "r" (in), "r" (table), "r" (fdct_r_row), "r" (out));
  445. }
  446. static av_always_inline void fdct_row_mmx(const int16_t *in, int16_t *out, const int16_t *table)
  447. {
  448. //FIXME reorder (I do not have an old MMX-only CPU here to benchmark ...)
  449. __asm__ volatile(
  450. "movd 12(%0), %%mm1 \n\t"
  451. "punpcklwd 8(%0), %%mm1 \n\t"
  452. "movq %%mm1, %%mm2 \n\t"
  453. "psrlq $0x20, %%mm1 \n\t"
  454. "movq 0(%0), %%mm0 \n\t"
  455. "punpcklwd %%mm2, %%mm1 \n\t"
  456. "movq %%mm0, %%mm5 \n\t"
  457. "paddsw %%mm1, %%mm0 \n\t"
  458. "psubsw %%mm1, %%mm5 \n\t"
  459. "movq %%mm0, %%mm2 \n\t"
  460. "punpckldq %%mm5, %%mm0 \n\t"
  461. "punpckhdq %%mm5, %%mm2 \n\t"
  462. "movq 0(%1), %%mm1 \n\t"
  463. "movq 8(%1), %%mm3 \n\t"
  464. "movq 16(%1), %%mm4 \n\t"
  465. "movq 24(%1), %%mm5 \n\t"
  466. "movq 32(%1), %%mm6 \n\t"
  467. "movq 40(%1), %%mm7 \n\t"
  468. "pmaddwd %%mm0, %%mm1 \n\t"
  469. "pmaddwd %%mm2, %%mm3 \n\t"
  470. "pmaddwd %%mm0, %%mm4 \n\t"
  471. "pmaddwd %%mm2, %%mm5 \n\t"
  472. "pmaddwd %%mm0, %%mm6 \n\t"
  473. "pmaddwd %%mm2, %%mm7 \n\t"
  474. "pmaddwd 48(%1), %%mm0 \n\t"
  475. "pmaddwd 56(%1), %%mm2 \n\t"
  476. "paddd %%mm1, %%mm3 \n\t"
  477. "paddd %%mm4, %%mm5 \n\t"
  478. "paddd %%mm6, %%mm7 \n\t"
  479. "paddd %%mm0, %%mm2 \n\t"
  480. "movq (%2), %%mm0 \n\t"
  481. "paddd %%mm0, %%mm3 \n\t"
  482. "paddd %%mm0, %%mm5 \n\t"
  483. "paddd %%mm0, %%mm7 \n\t"
  484. "paddd %%mm0, %%mm2 \n\t"
  485. "psrad $"S(SHIFT_FRW_ROW)", %%mm3 \n\t"
  486. "psrad $"S(SHIFT_FRW_ROW)", %%mm5 \n\t"
  487. "psrad $"S(SHIFT_FRW_ROW)", %%mm7 \n\t"
  488. "psrad $"S(SHIFT_FRW_ROW)", %%mm2 \n\t"
  489. "packssdw %%mm5, %%mm3 \n\t"
  490. "packssdw %%mm2, %%mm7 \n\t"
  491. "movq %%mm3, 0(%3) \n\t"
  492. "movq %%mm7, 8(%3) \n\t"
  493. :
  494. : "r" (in), "r" (table), "r" (fdct_r_row), "r" (out));
  495. }
  496. void ff_fdct_mmx(int16_t *block)
  497. {
  498. DECLARE_ALIGNED(8, int64_t, align_tmp)[16];
  499. int16_t * block1= (int16_t*)align_tmp;
  500. const int16_t *table= tab_frw_01234567;
  501. int i;
  502. fdct_col_mmx(block, block1, 0);
  503. fdct_col_mmx(block, block1, 4);
  504. for(i=8;i>0;i--) {
  505. fdct_row_mmx(block1, block, table);
  506. block1 += 8;
  507. table += 32;
  508. block += 8;
  509. }
  510. }
  511. void ff_fdct_mmx2(int16_t *block)
  512. {
  513. DECLARE_ALIGNED(8, int64_t, align_tmp)[16];
  514. int16_t *block1= (int16_t*)align_tmp;
  515. const int16_t *table= tab_frw_01234567;
  516. int i;
  517. fdct_col_mmx(block, block1, 0);
  518. fdct_col_mmx(block, block1, 4);
  519. for(i=8;i>0;i--) {
  520. fdct_row_mmx2(block1, block, table);
  521. block1 += 8;
  522. table += 32;
  523. block += 8;
  524. }
  525. }
  526. void ff_fdct_sse2(int16_t *block)
  527. {
  528. DECLARE_ALIGNED(16, int64_t, align_tmp)[16];
  529. int16_t * const block1= (int16_t*)align_tmp;
  530. fdct_col_sse2(block, block1, 0);
  531. fdct_row_sse2(block1, block);
  532. }