jidctfst-sse2-64.asm 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. ;
  2. ; jidctfst.asm - fast integer IDCT (64-bit SSE2)
  3. ;
  4. ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
  5. ; Copyright (C) 2009, D. R. Commander.
  6. ;
  7. ; Based on the x86 SIMD extension for IJG JPEG library
  8. ; Copyright (C) 1999-2006, MIYASAKA Masaru.
  9. ; For conditions of distribution and use, see copyright notice in jsimdext.inc
  10. ;
  11. ; This file should be assembled with NASM (Netwide Assembler),
  12. ; can *not* be assembled with Microsoft's MASM or any compatible
  13. ; assembler (including Borland's Turbo Assembler).
  14. ; NASM is available from http://nasm.sourceforge.net/ or
  15. ; http://sourceforge.net/project/showfiles.php?group_id=6208
  16. ;
  17. ; This file contains a fast, not so accurate integer implementation of
  18. ; the inverse DCT (Discrete Cosine Transform). The following code is
  19. ; based directly on the IJG's original jidctfst.c; see the jidctfst.c
  20. ; for more details.
  21. ;
  22. ; [TAB8]
  23. %include "jsimdext.inc"
  24. %include "jdct.inc"
  25. ; --------------------------------------------------------------------------
  26. %define CONST_BITS 8 ; 14 is also OK.
  27. %define PASS1_BITS 2
  28. %if IFAST_SCALE_BITS != PASS1_BITS
  29. %error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'."
  30. %endif
  31. %if CONST_BITS == 8
  32. F_1_082 equ 277 ; FIX(1.082392200)
  33. F_1_414 equ 362 ; FIX(1.414213562)
  34. F_1_847 equ 473 ; FIX(1.847759065)
  35. F_2_613 equ 669 ; FIX(2.613125930)
  36. F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1)
  37. %else
  38. ; NASM cannot do compile-time arithmetic on floating-point constants.
  39. %define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n))
  40. F_1_082 equ DESCALE(1162209775,30-CONST_BITS) ; FIX(1.082392200)
  41. F_1_414 equ DESCALE(1518500249,30-CONST_BITS) ; FIX(1.414213562)
  42. F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065)
  43. F_2_613 equ DESCALE(2805822602,30-CONST_BITS) ; FIX(2.613125930)
  44. F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
  45. %endif
  46. ; --------------------------------------------------------------------------
  47. SECTION SEG_CONST
  48. ; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow)
  49. ; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw)
  50. %define PRE_MULTIPLY_SCALE_BITS 2
  51. %define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
  52. alignz 16
  53. global EXTN(jconst_idct_ifast_sse2)
  54. EXTN(jconst_idct_ifast_sse2):
  55. PW_F1414 times 8 dw F_1_414 << CONST_SHIFT
  56. PW_F1847 times 8 dw F_1_847 << CONST_SHIFT
  57. PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT
  58. PW_F1082 times 8 dw F_1_082 << CONST_SHIFT
  59. PB_CENTERJSAMP times 16 db CENTERJSAMPLE
  60. alignz 16
  61. ; --------------------------------------------------------------------------
  62. SECTION SEG_TEXT
  63. BITS 64
  64. ;
  65. ; Perform dequantization and inverse DCT on one block of coefficients.
  66. ;
  67. ; GLOBAL(void)
  68. ; jsimd_idct_ifast_sse2 (void *dct_table, JCOEFPTR coef_block,
  69. ; JSAMPARRAY output_buf, JDIMENSION output_col)
  70. ;
  71. ; r10 = jpeg_component_info *compptr
  72. ; r11 = JCOEFPTR coef_block
  73. ; r12 = JSAMPARRAY output_buf
  74. ; r13 = JDIMENSION output_col
  75. %define original_rbp rbp+0
  76. %define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
  77. %define WK_NUM 2
  78. align 16
  79. global EXTN(jsimd_idct_ifast_sse2)
  80. EXTN(jsimd_idct_ifast_sse2):
  81. push rbp
  82. mov rax,rsp ; rax = original rbp
  83. sub rsp, byte 4
  84. and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
  85. mov [rsp],rax
  86. mov rbp,rsp ; rbp = aligned rbp
  87. lea rsp, [wk(0)]
  88. collect_args
  89. ; ---- Pass 1: process columns from input.
  90. mov rdx, r10 ; quantptr
  91. mov rsi, r11 ; inptr
  92. %ifndef NO_ZERO_COLUMN_TEST_IFAST_SSE2
  93. mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)]
  94. or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)]
  95. jnz near .columnDCT
  96. movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
  97. movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
  98. por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
  99. por xmm1, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
  100. por xmm0, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
  101. por xmm1, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
  102. por xmm0, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
  103. por xmm1,xmm0
  104. packsswb xmm1,xmm1
  105. packsswb xmm1,xmm1
  106. movd eax,xmm1
  107. test rax,rax
  108. jnz short .columnDCT
  109. ; -- AC terms all zero
  110. movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
  111. pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)]
  112. movdqa xmm7,xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07)
  113. punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
  114. punpckhwd xmm7,xmm7 ; xmm7=(04 04 05 05 06 06 07 07)
  115. pshufd xmm6,xmm0,0x00 ; xmm6=col0=(00 00 00 00 00 00 00 00)
  116. pshufd xmm2,xmm0,0x55 ; xmm2=col1=(01 01 01 01 01 01 01 01)
  117. pshufd xmm5,xmm0,0xAA ; xmm5=col2=(02 02 02 02 02 02 02 02)
  118. pshufd xmm0,xmm0,0xFF ; xmm0=col3=(03 03 03 03 03 03 03 03)
  119. pshufd xmm1,xmm7,0x00 ; xmm1=col4=(04 04 04 04 04 04 04 04)
  120. pshufd xmm4,xmm7,0x55 ; xmm4=col5=(05 05 05 05 05 05 05 05)
  121. pshufd xmm3,xmm7,0xAA ; xmm3=col6=(06 06 06 06 06 06 06 06)
  122. pshufd xmm7,xmm7,0xFF ; xmm7=col7=(07 07 07 07 07 07 07 07)
  123. movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1
  124. movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3
  125. jmp near .column_end
  126. %endif
  127. .columnDCT:
  128. ; -- Even part
  129. movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
  130. movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
  131. pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
  132. pmullw xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
  133. movdqa xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
  134. movdqa xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
  135. pmullw xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
  136. pmullw xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
  137. movdqa xmm4,xmm0
  138. movdqa xmm5,xmm1
  139. psubw xmm0,xmm2 ; xmm0=tmp11
  140. psubw xmm1,xmm3
  141. paddw xmm4,xmm2 ; xmm4=tmp10
  142. paddw xmm5,xmm3 ; xmm5=tmp13
  143. psllw xmm1,PRE_MULTIPLY_SCALE_BITS
  144. pmulhw xmm1,[rel PW_F1414]
  145. psubw xmm1,xmm5 ; xmm1=tmp12
  146. movdqa xmm6,xmm4
  147. movdqa xmm7,xmm0
  148. psubw xmm4,xmm5 ; xmm4=tmp3
  149. psubw xmm0,xmm1 ; xmm0=tmp2
  150. paddw xmm6,xmm5 ; xmm6=tmp0
  151. paddw xmm7,xmm1 ; xmm7=tmp1
  152. movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=tmp3
  153. movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=tmp2
  154. ; -- Odd part
  155. movdqa xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
  156. movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
  157. pmullw xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
  158. pmullw xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
  159. movdqa xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
  160. movdqa xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
  161. pmullw xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
  162. pmullw xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_IFAST_MULT_TYPE)]
  163. movdqa xmm4,xmm2
  164. movdqa xmm0,xmm5
  165. psubw xmm2,xmm1 ; xmm2=z12
  166. psubw xmm5,xmm3 ; xmm5=z10
  167. paddw xmm4,xmm1 ; xmm4=z11
  168. paddw xmm0,xmm3 ; xmm0=z13
  169. movdqa xmm1,xmm5 ; xmm1=z10(unscaled)
  170. psllw xmm2,PRE_MULTIPLY_SCALE_BITS
  171. psllw xmm5,PRE_MULTIPLY_SCALE_BITS
  172. movdqa xmm3,xmm4
  173. psubw xmm4,xmm0
  174. paddw xmm3,xmm0 ; xmm3=tmp7
  175. psllw xmm4,PRE_MULTIPLY_SCALE_BITS
  176. pmulhw xmm4,[rel PW_F1414] ; xmm4=tmp11
  177. ; To avoid overflow...
  178. ;
  179. ; (Original)
  180. ; tmp12 = -2.613125930 * z10 + z5;
  181. ;
  182. ; (This implementation)
  183. ; tmp12 = (-1.613125930 - 1) * z10 + z5;
  184. ; = -1.613125930 * z10 - z10 + z5;
  185. movdqa xmm0,xmm5
  186. paddw xmm5,xmm2
  187. pmulhw xmm5,[rel PW_F1847] ; xmm5=z5
  188. pmulhw xmm0,[rel PW_MF1613]
  189. pmulhw xmm2,[rel PW_F1082]
  190. psubw xmm0,xmm1
  191. psubw xmm2,xmm5 ; xmm2=tmp10
  192. paddw xmm0,xmm5 ; xmm0=tmp12
  193. ; -- Final output stage
  194. psubw xmm0,xmm3 ; xmm0=tmp6
  195. movdqa xmm1,xmm6
  196. movdqa xmm5,xmm7
  197. paddw xmm6,xmm3 ; xmm6=data0=(00 01 02 03 04 05 06 07)
  198. paddw xmm7,xmm0 ; xmm7=data1=(10 11 12 13 14 15 16 17)
  199. psubw xmm1,xmm3 ; xmm1=data7=(70 71 72 73 74 75 76 77)
  200. psubw xmm5,xmm0 ; xmm5=data6=(60 61 62 63 64 65 66 67)
  201. psubw xmm4,xmm0 ; xmm4=tmp5
  202. movdqa xmm3,xmm6 ; transpose coefficients(phase 1)
  203. punpcklwd xmm6,xmm7 ; xmm6=(00 10 01 11 02 12 03 13)
  204. punpckhwd xmm3,xmm7 ; xmm3=(04 14 05 15 06 16 07 17)
  205. movdqa xmm0,xmm5 ; transpose coefficients(phase 1)
  206. punpcklwd xmm5,xmm1 ; xmm5=(60 70 61 71 62 72 63 73)
  207. punpckhwd xmm0,xmm1 ; xmm0=(64 74 65 75 66 76 67 77)
  208. movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
  209. movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp3
  210. movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(60 70 61 71 62 72 63 73)
  211. movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(64 74 65 75 66 76 67 77)
  212. paddw xmm2,xmm4 ; xmm2=tmp4
  213. movdqa xmm5,xmm7
  214. movdqa xmm0,xmm1
  215. paddw xmm7,xmm4 ; xmm7=data2=(20 21 22 23 24 25 26 27)
  216. paddw xmm1,xmm2 ; xmm1=data4=(40 41 42 43 44 45 46 47)
  217. psubw xmm5,xmm4 ; xmm5=data5=(50 51 52 53 54 55 56 57)
  218. psubw xmm0,xmm2 ; xmm0=data3=(30 31 32 33 34 35 36 37)
  219. movdqa xmm4,xmm7 ; transpose coefficients(phase 1)
  220. punpcklwd xmm7,xmm0 ; xmm7=(20 30 21 31 22 32 23 33)
  221. punpckhwd xmm4,xmm0 ; xmm4=(24 34 25 35 26 36 27 37)
  222. movdqa xmm2,xmm1 ; transpose coefficients(phase 1)
  223. punpcklwd xmm1,xmm5 ; xmm1=(40 50 41 51 42 52 43 53)
  224. punpckhwd xmm2,xmm5 ; xmm2=(44 54 45 55 46 56 47 57)
  225. movdqa xmm0,xmm3 ; transpose coefficients(phase 2)
  226. punpckldq xmm3,xmm4 ; xmm3=(04 14 24 34 05 15 25 35)
  227. punpckhdq xmm0,xmm4 ; xmm0=(06 16 26 36 07 17 27 37)
  228. movdqa xmm5,xmm6 ; transpose coefficients(phase 2)
  229. punpckldq xmm6,xmm7 ; xmm6=(00 10 20 30 01 11 21 31)
  230. punpckhdq xmm5,xmm7 ; xmm5=(02 12 22 32 03 13 23 33)
  231. movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(60 70 61 71 62 72 63 73)
  232. movdqa xmm7, XMMWORD [wk(1)] ; xmm7=(64 74 65 75 66 76 67 77)
  233. movdqa XMMWORD [wk(0)], xmm3 ; wk(0)=(04 14 24 34 05 15 25 35)
  234. movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(06 16 26 36 07 17 27 37)
  235. movdqa xmm3,xmm1 ; transpose coefficients(phase 2)
  236. punpckldq xmm1,xmm4 ; xmm1=(40 50 60 70 41 51 61 71)
  237. punpckhdq xmm3,xmm4 ; xmm3=(42 52 62 72 43 53 63 73)
  238. movdqa xmm0,xmm2 ; transpose coefficients(phase 2)
  239. punpckldq xmm2,xmm7 ; xmm2=(44 54 64 74 45 55 65 75)
  240. punpckhdq xmm0,xmm7 ; xmm0=(46 56 66 76 47 57 67 77)
  241. movdqa xmm4,xmm6 ; transpose coefficients(phase 3)
  242. punpcklqdq xmm6,xmm1 ; xmm6=col0=(00 10 20 30 40 50 60 70)
  243. punpckhqdq xmm4,xmm1 ; xmm4=col1=(01 11 21 31 41 51 61 71)
  244. movdqa xmm7,xmm5 ; transpose coefficients(phase 3)
  245. punpcklqdq xmm5,xmm3 ; xmm5=col2=(02 12 22 32 42 52 62 72)
  246. punpckhqdq xmm7,xmm3 ; xmm7=col3=(03 13 23 33 43 53 63 73)
  247. movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(04 14 24 34 05 15 25 35)
  248. movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(06 16 26 36 07 17 27 37)
  249. movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=col1
  250. movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=col3
  251. movdqa xmm4,xmm1 ; transpose coefficients(phase 3)
  252. punpcklqdq xmm1,xmm2 ; xmm1=col4=(04 14 24 34 44 54 64 74)
  253. punpckhqdq xmm4,xmm2 ; xmm4=col5=(05 15 25 35 45 55 65 75)
  254. movdqa xmm7,xmm3 ; transpose coefficients(phase 3)
  255. punpcklqdq xmm3,xmm0 ; xmm3=col6=(06 16 26 36 46 56 66 76)
  256. punpckhqdq xmm7,xmm0 ; xmm7=col7=(07 17 27 37 47 57 67 77)
  257. .column_end:
  258. ; -- Prefetch the next coefficient block
  259. prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
  260. prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
  261. prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
  262. prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
  263. ; ---- Pass 2: process rows from work array, store into output array.
  264. mov rax, [original_rbp]
  265. mov rdi, r12 ; (JSAMPROW *)
  266. mov eax, r13d
  267. ; -- Even part
  268. ; xmm6=col0, xmm5=col2, xmm1=col4, xmm3=col6
  269. movdqa xmm2,xmm6
  270. movdqa xmm0,xmm5
  271. psubw xmm6,xmm1 ; xmm6=tmp11
  272. psubw xmm5,xmm3
  273. paddw xmm2,xmm1 ; xmm2=tmp10
  274. paddw xmm0,xmm3 ; xmm0=tmp13
  275. psllw xmm5,PRE_MULTIPLY_SCALE_BITS
  276. pmulhw xmm5,[rel PW_F1414]
  277. psubw xmm5,xmm0 ; xmm5=tmp12
  278. movdqa xmm1,xmm2
  279. movdqa xmm3,xmm6
  280. psubw xmm2,xmm0 ; xmm2=tmp3
  281. psubw xmm6,xmm5 ; xmm6=tmp2
  282. paddw xmm1,xmm0 ; xmm1=tmp0
  283. paddw xmm3,xmm5 ; xmm3=tmp1
  284. movdqa xmm0, XMMWORD [wk(0)] ; xmm0=col1
  285. movdqa xmm5, XMMWORD [wk(1)] ; xmm5=col3
  286. movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp3
  287. movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp2
  288. ; -- Odd part
  289. ; xmm0=col1, xmm5=col3, xmm4=col5, xmm7=col7
  290. movdqa xmm2,xmm0
  291. movdqa xmm6,xmm4
  292. psubw xmm0,xmm7 ; xmm0=z12
  293. psubw xmm4,xmm5 ; xmm4=z10
  294. paddw xmm2,xmm7 ; xmm2=z11
  295. paddw xmm6,xmm5 ; xmm6=z13
  296. movdqa xmm7,xmm4 ; xmm7=z10(unscaled)
  297. psllw xmm0,PRE_MULTIPLY_SCALE_BITS
  298. psllw xmm4,PRE_MULTIPLY_SCALE_BITS
  299. movdqa xmm5,xmm2
  300. psubw xmm2,xmm6
  301. paddw xmm5,xmm6 ; xmm5=tmp7
  302. psllw xmm2,PRE_MULTIPLY_SCALE_BITS
  303. pmulhw xmm2,[rel PW_F1414] ; xmm2=tmp11
  304. ; To avoid overflow...
  305. ;
  306. ; (Original)
  307. ; tmp12 = -2.613125930 * z10 + z5;
  308. ;
  309. ; (This implementation)
  310. ; tmp12 = (-1.613125930 - 1) * z10 + z5;
  311. ; = -1.613125930 * z10 - z10 + z5;
  312. movdqa xmm6,xmm4
  313. paddw xmm4,xmm0
  314. pmulhw xmm4,[rel PW_F1847] ; xmm4=z5
  315. pmulhw xmm6,[rel PW_MF1613]
  316. pmulhw xmm0,[rel PW_F1082]
  317. psubw xmm6,xmm7
  318. psubw xmm0,xmm4 ; xmm0=tmp10
  319. paddw xmm6,xmm4 ; xmm6=tmp12
  320. ; -- Final output stage
  321. psubw xmm6,xmm5 ; xmm6=tmp6
  322. movdqa xmm7,xmm1
  323. movdqa xmm4,xmm3
  324. paddw xmm1,xmm5 ; xmm1=data0=(00 10 20 30 40 50 60 70)
  325. paddw xmm3,xmm6 ; xmm3=data1=(01 11 21 31 41 51 61 71)
  326. psraw xmm1,(PASS1_BITS+3) ; descale
  327. psraw xmm3,(PASS1_BITS+3) ; descale
  328. psubw xmm7,xmm5 ; xmm7=data7=(07 17 27 37 47 57 67 77)
  329. psubw xmm4,xmm6 ; xmm4=data6=(06 16 26 36 46 56 66 76)
  330. psraw xmm7,(PASS1_BITS+3) ; descale
  331. psraw xmm4,(PASS1_BITS+3) ; descale
  332. psubw xmm2,xmm6 ; xmm2=tmp5
  333. packsswb xmm1,xmm4 ; xmm1=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
  334. packsswb xmm3,xmm7 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
  335. movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp2
  336. movdqa xmm6, XMMWORD [wk(0)] ; xmm6=tmp3
  337. paddw xmm0,xmm2 ; xmm0=tmp4
  338. movdqa xmm4,xmm5
  339. movdqa xmm7,xmm6
  340. paddw xmm5,xmm2 ; xmm5=data2=(02 12 22 32 42 52 62 72)
  341. paddw xmm6,xmm0 ; xmm6=data4=(04 14 24 34 44 54 64 74)
  342. psraw xmm5,(PASS1_BITS+3) ; descale
  343. psraw xmm6,(PASS1_BITS+3) ; descale
  344. psubw xmm4,xmm2 ; xmm4=data5=(05 15 25 35 45 55 65 75)
  345. psubw xmm7,xmm0 ; xmm7=data3=(03 13 23 33 43 53 63 73)
  346. psraw xmm4,(PASS1_BITS+3) ; descale
  347. psraw xmm7,(PASS1_BITS+3) ; descale
  348. movdqa xmm2,[rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP]
  349. packsswb xmm5,xmm6 ; xmm5=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74)
  350. packsswb xmm7,xmm4 ; xmm7=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75)
  351. paddb xmm1,xmm2
  352. paddb xmm3,xmm2
  353. paddb xmm5,xmm2
  354. paddb xmm7,xmm2
  355. movdqa xmm0,xmm1 ; transpose coefficients(phase 1)
  356. punpcklbw xmm1,xmm3 ; xmm1=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71)
  357. punpckhbw xmm0,xmm3 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77)
  358. movdqa xmm6,xmm5 ; transpose coefficients(phase 1)
  359. punpcklbw xmm5,xmm7 ; xmm5=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73)
  360. punpckhbw xmm6,xmm7 ; xmm6=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75)
  361. movdqa xmm4,xmm1 ; transpose coefficients(phase 2)
  362. punpcklwd xmm1,xmm5 ; xmm1=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
  363. punpckhwd xmm4,xmm5 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73)
  364. movdqa xmm2,xmm6 ; transpose coefficients(phase 2)
  365. punpcklwd xmm6,xmm0 ; xmm6=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
  366. punpckhwd xmm2,xmm0 ; xmm2=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77)
  367. movdqa xmm3,xmm1 ; transpose coefficients(phase 3)
  368. punpckldq xmm1,xmm6 ; xmm1=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
  369. punpckhdq xmm3,xmm6 ; xmm3=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
  370. movdqa xmm7,xmm4 ; transpose coefficients(phase 3)
  371. punpckldq xmm4,xmm2 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
  372. punpckhdq xmm7,xmm2 ; xmm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
  373. pshufd xmm5,xmm1,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
  374. pshufd xmm0,xmm3,0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
  375. pshufd xmm6,xmm4,0x4E ; xmm6=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
  376. pshufd xmm2,xmm7,0x4E ; xmm2=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
  377. mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
  378. mov rsi, JSAMPROW [rdi+2*SIZEOF_JSAMPROW]
  379. movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm1
  380. movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3
  381. mov rdx, JSAMPROW [rdi+4*SIZEOF_JSAMPROW]
  382. mov rsi, JSAMPROW [rdi+6*SIZEOF_JSAMPROW]
  383. movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4
  384. movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm7
  385. mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
  386. mov rsi, JSAMPROW [rdi+3*SIZEOF_JSAMPROW]
  387. movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5
  388. movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm0
  389. mov rdx, JSAMPROW [rdi+5*SIZEOF_JSAMPROW]
  390. mov rsi, JSAMPROW [rdi+7*SIZEOF_JSAMPROW]
  391. movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
  392. movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2
  393. uncollect_args
  394. mov rsp,rbp ; rsp <- aligned rbp
  395. pop rsp ; rsp <- original rbp
  396. pop rbp
  397. ret
  398. ret
  399. ; For some reason, the OS X linker does not honor the request to align the
  400. ; segment unless we do this.
  401. align 16