jidctint-sse2.asm 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. ;
  2. ; jidctint.asm - accurate integer IDCT (SSE2)
  3. ;
  4. ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
  5. ;
  6. ; Based on the x86 SIMD extension for IJG JPEG library
  7. ; Copyright (C) 1999-2006, MIYASAKA Masaru.
  8. ; For conditions of distribution and use, see copyright notice in jsimdext.inc
  9. ;
  10. ; This file should be assembled with NASM (Netwide Assembler),
  11. ; can *not* be assembled with Microsoft's MASM or any compatible
  12. ; assembler (including Borland's Turbo Assembler).
  13. ; NASM is available from http://nasm.sourceforge.net/ or
  14. ; http://sourceforge.net/project/showfiles.php?group_id=6208
  15. ;
  16. ; This file contains a slow-but-accurate integer implementation of the
  17. ; inverse DCT (Discrete Cosine Transform). The following code is based
  18. ; directly on the IJG's original jidctint.c; see the jidctint.c for
  19. ; more details.
  20. ;
  21. ; [TAB8]
  22. %include "jsimdext.inc"
  23. %include "jdct.inc"
  24. ; --------------------------------------------------------------------------
  25. %define CONST_BITS 13
  26. %define PASS1_BITS 2
  27. %define DESCALE_P1 (CONST_BITS-PASS1_BITS)
  28. %define DESCALE_P2 (CONST_BITS+PASS1_BITS+3)
  29. %if CONST_BITS == 13
  30. F_0_298 equ 2446 ; FIX(0.298631336)
  31. F_0_390 equ 3196 ; FIX(0.390180644)
  32. F_0_541 equ 4433 ; FIX(0.541196100)
  33. F_0_765 equ 6270 ; FIX(0.765366865)
  34. F_0_899 equ 7373 ; FIX(0.899976223)
  35. F_1_175 equ 9633 ; FIX(1.175875602)
  36. F_1_501 equ 12299 ; FIX(1.501321110)
  37. F_1_847 equ 15137 ; FIX(1.847759065)
  38. F_1_961 equ 16069 ; FIX(1.961570560)
  39. F_2_053 equ 16819 ; FIX(2.053119869)
  40. F_2_562 equ 20995 ; FIX(2.562915447)
  41. F_3_072 equ 25172 ; FIX(3.072711026)
  42. %else
  43. ; NASM cannot do compile-time arithmetic on floating-point constants.
  44. %define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n))
  45. F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336)
  46. F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644)
  47. F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100)
  48. F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865)
  49. F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223)
  50. F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602)
  51. F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110)
  52. F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065)
  53. F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560)
  54. F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869)
  55. F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447)
  56. F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026)
  57. %endif
  58. ; --------------------------------------------------------------------------
  59. SECTION SEG_CONST
  60. alignz 16
  61. global EXTN(jconst_idct_islow_sse2)
  62. EXTN(jconst_idct_islow_sse2):
  63. PW_F130_F054 times 4 dw (F_0_541+F_0_765), F_0_541
  64. PW_F054_MF130 times 4 dw F_0_541, (F_0_541-F_1_847)
  65. PW_MF078_F117 times 4 dw (F_1_175-F_1_961), F_1_175
  66. PW_F117_F078 times 4 dw F_1_175, (F_1_175-F_0_390)
  67. PW_MF060_MF089 times 4 dw (F_0_298-F_0_899),-F_0_899
  68. PW_MF089_F060 times 4 dw -F_0_899, (F_1_501-F_0_899)
  69. PW_MF050_MF256 times 4 dw (F_2_053-F_2_562),-F_2_562
  70. PW_MF256_F050 times 4 dw -F_2_562, (F_3_072-F_2_562)
  71. PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1-1)
  72. PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2-1)
  73. PB_CENTERJSAMP times 16 db CENTERJSAMPLE
  74. alignz 16
  75. ; --------------------------------------------------------------------------
  76. SECTION SEG_TEXT
  77. BITS 32
  78. ;
  79. ; Perform dequantization and inverse DCT on one block of coefficients.
  80. ;
  81. ; GLOBAL(void)
  82. ; jsimd_idct_islow_sse2 (void *dct_table, JCOEFPTR coef_block,
  83. ; JSAMPARRAY output_buf, JDIMENSION output_col)
  84. ;
  85. %define dct_table(b) (b)+8 ; jpeg_component_info *compptr
  86. %define coef_block(b) (b)+12 ; JCOEFPTR coef_block
  87. %define output_buf(b) (b)+16 ; JSAMPARRAY output_buf
  88. %define output_col(b) (b)+20 ; JDIMENSION output_col
  89. %define original_ebp ebp+0
  90. %define wk(i) ebp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
  91. %define WK_NUM 12
  92. align 16
  93. global EXTN(jsimd_idct_islow_sse2)
  94. EXTN(jsimd_idct_islow_sse2):
  95. push ebp
  96. mov eax,esp ; eax = original ebp
  97. sub esp, byte 4
  98. and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
  99. mov [esp],eax
  100. mov ebp,esp ; ebp = aligned ebp
  101. lea esp, [wk(0)]
  102. pushpic ebx
  103. ; push ecx ; unused
  104. ; push edx ; need not be preserved
  105. push esi
  106. push edi
  107. get_GOT ebx ; get GOT address
  108. ; ---- Pass 1: process columns from input.
  109. ; mov eax, [original_ebp]
  110. mov edx, POINTER [dct_table(eax)] ; quantptr
  111. mov esi, JCOEFPTR [coef_block(eax)] ; inptr
  112. %ifndef NO_ZERO_COLUMN_TEST_ISLOW_SSE2
  113. mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
  114. or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
  115. jnz near .columnDCT
  116. movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
  117. movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
  118. por xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
  119. por xmm1, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
  120. por xmm0, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
  121. por xmm1, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
  122. por xmm0, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
  123. por xmm1,xmm0
  124. packsswb xmm1,xmm1
  125. packsswb xmm1,xmm1
  126. movd eax,xmm1
  127. test eax,eax
  128. jnz short .columnDCT
  129. ; -- AC terms all zero
  130. movdqa xmm5, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
  131. pmullw xmm5, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  132. psllw xmm5,PASS1_BITS
  133. movdqa xmm4,xmm5 ; xmm5=in0=(00 01 02 03 04 05 06 07)
  134. punpcklwd xmm5,xmm5 ; xmm5=(00 00 01 01 02 02 03 03)
  135. punpckhwd xmm4,xmm4 ; xmm4=(04 04 05 05 06 06 07 07)
  136. pshufd xmm7,xmm5,0x00 ; xmm7=col0=(00 00 00 00 00 00 00 00)
  137. pshufd xmm6,xmm5,0x55 ; xmm6=col1=(01 01 01 01 01 01 01 01)
  138. pshufd xmm1,xmm5,0xAA ; xmm1=col2=(02 02 02 02 02 02 02 02)
  139. pshufd xmm5,xmm5,0xFF ; xmm5=col3=(03 03 03 03 03 03 03 03)
  140. pshufd xmm0,xmm4,0x00 ; xmm0=col4=(04 04 04 04 04 04 04 04)
  141. pshufd xmm3,xmm4,0x55 ; xmm3=col5=(05 05 05 05 05 05 05 05)
  142. pshufd xmm2,xmm4,0xAA ; xmm2=col6=(06 06 06 06 06 06 06 06)
  143. pshufd xmm4,xmm4,0xFF ; xmm4=col7=(07 07 07 07 07 07 07 07)
  144. movdqa XMMWORD [wk(8)], xmm6 ; wk(8)=col1
  145. movdqa XMMWORD [wk(9)], xmm5 ; wk(9)=col3
  146. movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5
  147. movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7
  148. jmp near .column_end
  149. alignx 16,7
  150. %endif
  151. .columnDCT:
  152. ; -- Even part
  153. movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
  154. movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
  155. pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  156. pmullw xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  157. movdqa xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
  158. movdqa xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
  159. pmullw xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  160. pmullw xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  161. ; (Original)
  162. ; z1 = (z2 + z3) * 0.541196100;
  163. ; tmp2 = z1 + z3 * -1.847759065;
  164. ; tmp3 = z1 + z2 * 0.765366865;
  165. ;
  166. ; (This implementation)
  167. ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
  168. ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
  169. movdqa xmm4,xmm1 ; xmm1=in2=z2
  170. movdqa xmm5,xmm1
  171. punpcklwd xmm4,xmm3 ; xmm3=in6=z3
  172. punpckhwd xmm5,xmm3
  173. movdqa xmm1,xmm4
  174. movdqa xmm3,xmm5
  175. pmaddwd xmm4,[GOTOFF(ebx,PW_F130_F054)] ; xmm4=tmp3L
  176. pmaddwd xmm5,[GOTOFF(ebx,PW_F130_F054)] ; xmm5=tmp3H
  177. pmaddwd xmm1,[GOTOFF(ebx,PW_F054_MF130)] ; xmm1=tmp2L
  178. pmaddwd xmm3,[GOTOFF(ebx,PW_F054_MF130)] ; xmm3=tmp2H
  179. movdqa xmm6,xmm0
  180. paddw xmm0,xmm2 ; xmm0=in0+in4
  181. psubw xmm6,xmm2 ; xmm6=in0-in4
  182. pxor xmm7,xmm7
  183. pxor xmm2,xmm2
  184. punpcklwd xmm7,xmm0 ; xmm7=tmp0L
  185. punpckhwd xmm2,xmm0 ; xmm2=tmp0H
  186. psrad xmm7,(16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS
  187. psrad xmm2,(16-CONST_BITS) ; psrad xmm2,16 & pslld xmm2,CONST_BITS
  188. movdqa xmm0,xmm7
  189. paddd xmm7,xmm4 ; xmm7=tmp10L
  190. psubd xmm0,xmm4 ; xmm0=tmp13L
  191. movdqa xmm4,xmm2
  192. paddd xmm2,xmm5 ; xmm2=tmp10H
  193. psubd xmm4,xmm5 ; xmm4=tmp13H
  194. movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=tmp10L
  195. movdqa XMMWORD [wk(1)], xmm2 ; wk(1)=tmp10H
  196. movdqa XMMWORD [wk(2)], xmm0 ; wk(2)=tmp13L
  197. movdqa XMMWORD [wk(3)], xmm4 ; wk(3)=tmp13H
  198. pxor xmm5,xmm5
  199. pxor xmm7,xmm7
  200. punpcklwd xmm5,xmm6 ; xmm5=tmp1L
  201. punpckhwd xmm7,xmm6 ; xmm7=tmp1H
  202. psrad xmm5,(16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS
  203. psrad xmm7,(16-CONST_BITS) ; psrad xmm7,16 & pslld xmm7,CONST_BITS
  204. movdqa xmm2,xmm5
  205. paddd xmm5,xmm1 ; xmm5=tmp11L
  206. psubd xmm2,xmm1 ; xmm2=tmp12L
  207. movdqa xmm0,xmm7
  208. paddd xmm7,xmm3 ; xmm7=tmp11H
  209. psubd xmm0,xmm3 ; xmm0=tmp12H
  210. movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L
  211. movdqa XMMWORD [wk(5)], xmm7 ; wk(5)=tmp11H
  212. movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=tmp12L
  213. movdqa XMMWORD [wk(7)], xmm0 ; wk(7)=tmp12H
  214. ; -- Odd part
  215. movdqa xmm4, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
  216. movdqa xmm6, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
  217. pmullw xmm4, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  218. pmullw xmm6, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  219. movdqa xmm1, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
  220. movdqa xmm3, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
  221. pmullw xmm1, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  222. pmullw xmm3, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
  223. movdqa xmm5,xmm6
  224. movdqa xmm7,xmm4
  225. paddw xmm5,xmm3 ; xmm5=z3
  226. paddw xmm7,xmm1 ; xmm7=z4
  227. ; (Original)
  228. ; z5 = (z3 + z4) * 1.175875602;
  229. ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
  230. ; z3 += z5; z4 += z5;
  231. ;
  232. ; (This implementation)
  233. ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
  234. ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
  235. movdqa xmm2,xmm5
  236. movdqa xmm0,xmm5
  237. punpcklwd xmm2,xmm7
  238. punpckhwd xmm0,xmm7
  239. movdqa xmm5,xmm2
  240. movdqa xmm7,xmm0
  241. pmaddwd xmm2,[GOTOFF(ebx,PW_MF078_F117)] ; xmm2=z3L
  242. pmaddwd xmm0,[GOTOFF(ebx,PW_MF078_F117)] ; xmm0=z3H
  243. pmaddwd xmm5,[GOTOFF(ebx,PW_F117_F078)] ; xmm5=z4L
  244. pmaddwd xmm7,[GOTOFF(ebx,PW_F117_F078)] ; xmm7=z4H
  245. movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=z3L
  246. movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=z3H
  247. ; (Original)
  248. ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
  249. ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
  250. ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
  251. ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
  252. ; tmp0 += z1 + z3; tmp1 += z2 + z4;
  253. ; tmp2 += z2 + z3; tmp3 += z1 + z4;
  254. ;
  255. ; (This implementation)
  256. ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
  257. ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
  258. ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
  259. ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
  260. ; tmp0 += z3; tmp1 += z4;
  261. ; tmp2 += z3; tmp3 += z4;
  262. movdqa xmm2,xmm3
  263. movdqa xmm0,xmm3
  264. punpcklwd xmm2,xmm4
  265. punpckhwd xmm0,xmm4
  266. movdqa xmm3,xmm2
  267. movdqa xmm4,xmm0
  268. pmaddwd xmm2,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm2=tmp0L
  269. pmaddwd xmm0,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm0=tmp0H
  270. pmaddwd xmm3,[GOTOFF(ebx,PW_MF089_F060)] ; xmm3=tmp3L
  271. pmaddwd xmm4,[GOTOFF(ebx,PW_MF089_F060)] ; xmm4=tmp3H
  272. paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp0L
  273. paddd xmm0, XMMWORD [wk(11)] ; xmm0=tmp0H
  274. paddd xmm3,xmm5 ; xmm3=tmp3L
  275. paddd xmm4,xmm7 ; xmm4=tmp3H
  276. movdqa XMMWORD [wk(8)], xmm2 ; wk(8)=tmp0L
  277. movdqa XMMWORD [wk(9)], xmm0 ; wk(9)=tmp0H
  278. movdqa xmm2,xmm1
  279. movdqa xmm0,xmm1
  280. punpcklwd xmm2,xmm6
  281. punpckhwd xmm0,xmm6
  282. movdqa xmm1,xmm2
  283. movdqa xmm6,xmm0
  284. pmaddwd xmm2,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm2=tmp1L
  285. pmaddwd xmm0,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm0=tmp1H
  286. pmaddwd xmm1,[GOTOFF(ebx,PW_MF256_F050)] ; xmm1=tmp2L
  287. pmaddwd xmm6,[GOTOFF(ebx,PW_MF256_F050)] ; xmm6=tmp2H
  288. paddd xmm2,xmm5 ; xmm2=tmp1L
  289. paddd xmm0,xmm7 ; xmm0=tmp1H
  290. paddd xmm1, XMMWORD [wk(10)] ; xmm1=tmp2L
  291. paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H
  292. movdqa XMMWORD [wk(10)], xmm2 ; wk(10)=tmp1L
  293. movdqa XMMWORD [wk(11)], xmm0 ; wk(11)=tmp1H
  294. ; -- Final output stage
  295. movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L
  296. movdqa xmm7, XMMWORD [wk(1)] ; xmm7=tmp10H
  297. movdqa xmm2,xmm5
  298. movdqa xmm0,xmm7
  299. paddd xmm5,xmm3 ; xmm5=data0L
  300. paddd xmm7,xmm4 ; xmm7=data0H
  301. psubd xmm2,xmm3 ; xmm2=data7L
  302. psubd xmm0,xmm4 ; xmm0=data7H
  303. movdqa xmm3,[GOTOFF(ebx,PD_DESCALE_P1)] ; xmm3=[PD_DESCALE_P1]
  304. paddd xmm5,xmm3
  305. paddd xmm7,xmm3
  306. psrad xmm5,DESCALE_P1
  307. psrad xmm7,DESCALE_P1
  308. paddd xmm2,xmm3
  309. paddd xmm0,xmm3
  310. psrad xmm2,DESCALE_P1
  311. psrad xmm0,DESCALE_P1
  312. packssdw xmm5,xmm7 ; xmm5=data0=(00 01 02 03 04 05 06 07)
  313. packssdw xmm2,xmm0 ; xmm2=data7=(70 71 72 73 74 75 76 77)
  314. movdqa xmm4, XMMWORD [wk(4)] ; xmm4=tmp11L
  315. movdqa xmm3, XMMWORD [wk(5)] ; xmm3=tmp11H
  316. movdqa xmm7,xmm4
  317. movdqa xmm0,xmm3
  318. paddd xmm4,xmm1 ; xmm4=data1L
  319. paddd xmm3,xmm6 ; xmm3=data1H
  320. psubd xmm7,xmm1 ; xmm7=data6L
  321. psubd xmm0,xmm6 ; xmm0=data6H
  322. movdqa xmm1,[GOTOFF(ebx,PD_DESCALE_P1)] ; xmm1=[PD_DESCALE_P1]
  323. paddd xmm4,xmm1
  324. paddd xmm3,xmm1
  325. psrad xmm4,DESCALE_P1
  326. psrad xmm3,DESCALE_P1
  327. paddd xmm7,xmm1
  328. paddd xmm0,xmm1
  329. psrad xmm7,DESCALE_P1
  330. psrad xmm0,DESCALE_P1
  331. packssdw xmm4,xmm3 ; xmm4=data1=(10 11 12 13 14 15 16 17)
  332. packssdw xmm7,xmm0 ; xmm7=data6=(60 61 62 63 64 65 66 67)
  333. movdqa xmm6,xmm5 ; transpose coefficients(phase 1)
  334. punpcklwd xmm5,xmm4 ; xmm5=(00 10 01 11 02 12 03 13)
  335. punpckhwd xmm6,xmm4 ; xmm6=(04 14 05 15 06 16 07 17)
  336. movdqa xmm1,xmm7 ; transpose coefficients(phase 1)
  337. punpcklwd xmm7,xmm2 ; xmm7=(60 70 61 71 62 72 63 73)
  338. punpckhwd xmm1,xmm2 ; xmm1=(64 74 65 75 66 76 67 77)
  339. movdqa xmm3, XMMWORD [wk(6)] ; xmm3=tmp12L
  340. movdqa xmm0, XMMWORD [wk(7)] ; xmm0=tmp12H
  341. movdqa xmm4, XMMWORD [wk(10)] ; xmm4=tmp1L
  342. movdqa xmm2, XMMWORD [wk(11)] ; xmm2=tmp1H
  343. movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 01 11 02 12 03 13)
  344. movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=(04 14 05 15 06 16 07 17)
  345. movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=(60 70 61 71 62 72 63 73)
  346. movdqa XMMWORD [wk(5)], xmm1 ; wk(5)=(64 74 65 75 66 76 67 77)
  347. movdqa xmm5,xmm3
  348. movdqa xmm6,xmm0
  349. paddd xmm3,xmm4 ; xmm3=data2L
  350. paddd xmm0,xmm2 ; xmm0=data2H
  351. psubd xmm5,xmm4 ; xmm5=data5L
  352. psubd xmm6,xmm2 ; xmm6=data5H
  353. movdqa xmm7,[GOTOFF(ebx,PD_DESCALE_P1)] ; xmm7=[PD_DESCALE_P1]
  354. paddd xmm3,xmm7
  355. paddd xmm0,xmm7
  356. psrad xmm3,DESCALE_P1
  357. psrad xmm0,DESCALE_P1
  358. paddd xmm5,xmm7
  359. paddd xmm6,xmm7
  360. psrad xmm5,DESCALE_P1
  361. psrad xmm6,DESCALE_P1
  362. packssdw xmm3,xmm0 ; xmm3=data2=(20 21 22 23 24 25 26 27)
  363. packssdw xmm5,xmm6 ; xmm5=data5=(50 51 52 53 54 55 56 57)
  364. movdqa xmm1, XMMWORD [wk(2)] ; xmm1=tmp13L
  365. movdqa xmm4, XMMWORD [wk(3)] ; xmm4=tmp13H
  366. movdqa xmm2, XMMWORD [wk(8)] ; xmm2=tmp0L
  367. movdqa xmm7, XMMWORD [wk(9)] ; xmm7=tmp0H
  368. movdqa xmm0,xmm1
  369. movdqa xmm6,xmm4
  370. paddd xmm1,xmm2 ; xmm1=data3L
  371. paddd xmm4,xmm7 ; xmm4=data3H
  372. psubd xmm0,xmm2 ; xmm0=data4L
  373. psubd xmm6,xmm7 ; xmm6=data4H
  374. movdqa xmm2,[GOTOFF(ebx,PD_DESCALE_P1)] ; xmm2=[PD_DESCALE_P1]
  375. paddd xmm1,xmm2
  376. paddd xmm4,xmm2
  377. psrad xmm1,DESCALE_P1
  378. psrad xmm4,DESCALE_P1
  379. paddd xmm0,xmm2
  380. paddd xmm6,xmm2
  381. psrad xmm0,DESCALE_P1
  382. psrad xmm6,DESCALE_P1
  383. packssdw xmm1,xmm4 ; xmm1=data3=(30 31 32 33 34 35 36 37)
  384. packssdw xmm0,xmm6 ; xmm0=data4=(40 41 42 43 44 45 46 47)
  385. movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 01 11 02 12 03 13)
  386. movdqa xmm2, XMMWORD [wk(1)] ; xmm2=(04 14 05 15 06 16 07 17)
  387. movdqa xmm4,xmm3 ; transpose coefficients(phase 1)
  388. punpcklwd xmm3,xmm1 ; xmm3=(20 30 21 31 22 32 23 33)
  389. punpckhwd xmm4,xmm1 ; xmm4=(24 34 25 35 26 36 27 37)
  390. movdqa xmm6,xmm0 ; transpose coefficients(phase 1)
  391. punpcklwd xmm0,xmm5 ; xmm0=(40 50 41 51 42 52 43 53)
  392. punpckhwd xmm6,xmm5 ; xmm6=(44 54 45 55 46 56 47 57)
  393. movdqa xmm1,xmm7 ; transpose coefficients(phase 2)
  394. punpckldq xmm7,xmm3 ; xmm7=(00 10 20 30 01 11 21 31)
  395. punpckhdq xmm1,xmm3 ; xmm1=(02 12 22 32 03 13 23 33)
  396. movdqa xmm5,xmm2 ; transpose coefficients(phase 2)
  397. punpckldq xmm2,xmm4 ; xmm2=(04 14 24 34 05 15 25 35)
  398. punpckhdq xmm5,xmm4 ; xmm5=(06 16 26 36 07 17 27 37)
  399. movdqa xmm3, XMMWORD [wk(4)] ; xmm3=(60 70 61 71 62 72 63 73)
  400. movdqa xmm4, XMMWORD [wk(5)] ; xmm4=(64 74 65 75 66 76 67 77)
  401. movdqa XMMWORD [wk(6)], xmm2 ; wk(6)=(04 14 24 34 05 15 25 35)
  402. movdqa XMMWORD [wk(7)], xmm5 ; wk(7)=(06 16 26 36 07 17 27 37)
  403. movdqa xmm2,xmm0 ; transpose coefficients(phase 2)
  404. punpckldq xmm0,xmm3 ; xmm0=(40 50 60 70 41 51 61 71)
  405. punpckhdq xmm2,xmm3 ; xmm2=(42 52 62 72 43 53 63 73)
  406. movdqa xmm5,xmm6 ; transpose coefficients(phase 2)
  407. punpckldq xmm6,xmm4 ; xmm6=(44 54 64 74 45 55 65 75)
  408. punpckhdq xmm5,xmm4 ; xmm5=(46 56 66 76 47 57 67 77)
  409. movdqa xmm3,xmm7 ; transpose coefficients(phase 3)
  410. punpcklqdq xmm7,xmm0 ; xmm7=col0=(00 10 20 30 40 50 60 70)
  411. punpckhqdq xmm3,xmm0 ; xmm3=col1=(01 11 21 31 41 51 61 71)
  412. movdqa xmm4,xmm1 ; transpose coefficients(phase 3)
  413. punpcklqdq xmm1,xmm2 ; xmm1=col2=(02 12 22 32 42 52 62 72)
  414. punpckhqdq xmm4,xmm2 ; xmm4=col3=(03 13 23 33 43 53 63 73)
  415. movdqa xmm0, XMMWORD [wk(6)] ; xmm0=(04 14 24 34 05 15 25 35)
  416. movdqa xmm2, XMMWORD [wk(7)] ; xmm2=(06 16 26 36 07 17 27 37)
  417. movdqa XMMWORD [wk(8)], xmm3 ; wk(8)=col1
  418. movdqa XMMWORD [wk(9)], xmm4 ; wk(9)=col3
  419. movdqa xmm3,xmm0 ; transpose coefficients(phase 3)
  420. punpcklqdq xmm0,xmm6 ; xmm0=col4=(04 14 24 34 44 54 64 74)
  421. punpckhqdq xmm3,xmm6 ; xmm3=col5=(05 15 25 35 45 55 65 75)
  422. movdqa xmm4,xmm2 ; transpose coefficients(phase 3)
  423. punpcklqdq xmm2,xmm5 ; xmm2=col6=(06 16 26 36 46 56 66 76)
  424. punpckhqdq xmm4,xmm5 ; xmm4=col7=(07 17 27 37 47 57 67 77)
  425. movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5
  426. movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7
  427. .column_end:
  428. ; -- Prefetch the next coefficient block
  429. prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
  430. prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
  431. prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
  432. prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
  433. ; ---- Pass 2: process rows from work array, store into output array.
  434. mov eax, [original_ebp]
  435. mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
  436. mov eax, JDIMENSION [output_col(eax)]
  437. ; -- Even part
  438. ; xmm7=col0, xmm1=col2, xmm0=col4, xmm2=col6
  439. ; (Original)
  440. ; z1 = (z2 + z3) * 0.541196100;
  441. ; tmp2 = z1 + z3 * -1.847759065;
  442. ; tmp3 = z1 + z2 * 0.765366865;
  443. ;
  444. ; (This implementation)
  445. ; tmp2 = z2 * 0.541196100 + z3 * (0.541196100 - 1.847759065);
  446. ; tmp3 = z2 * (0.541196100 + 0.765366865) + z3 * 0.541196100;
  447. movdqa xmm6,xmm1 ; xmm1=in2=z2
  448. movdqa xmm5,xmm1
  449. punpcklwd xmm6,xmm2 ; xmm2=in6=z3
  450. punpckhwd xmm5,xmm2
  451. movdqa xmm1,xmm6
  452. movdqa xmm2,xmm5
  453. pmaddwd xmm6,[GOTOFF(ebx,PW_F130_F054)] ; xmm6=tmp3L
  454. pmaddwd xmm5,[GOTOFF(ebx,PW_F130_F054)] ; xmm5=tmp3H
  455. pmaddwd xmm1,[GOTOFF(ebx,PW_F054_MF130)] ; xmm1=tmp2L
  456. pmaddwd xmm2,[GOTOFF(ebx,PW_F054_MF130)] ; xmm2=tmp2H
  457. movdqa xmm3,xmm7
  458. paddw xmm7,xmm0 ; xmm7=in0+in4
  459. psubw xmm3,xmm0 ; xmm3=in0-in4
  460. pxor xmm4,xmm4
  461. pxor xmm0,xmm0
  462. punpcklwd xmm4,xmm7 ; xmm4=tmp0L
  463. punpckhwd xmm0,xmm7 ; xmm0=tmp0H
  464. psrad xmm4,(16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS
  465. psrad xmm0,(16-CONST_BITS) ; psrad xmm0,16 & pslld xmm0,CONST_BITS
  466. movdqa xmm7,xmm4
  467. paddd xmm4,xmm6 ; xmm4=tmp10L
  468. psubd xmm7,xmm6 ; xmm7=tmp13L
  469. movdqa xmm6,xmm0
  470. paddd xmm0,xmm5 ; xmm0=tmp10H
  471. psubd xmm6,xmm5 ; xmm6=tmp13H
  472. movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=tmp10L
  473. movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp10H
  474. movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=tmp13L
  475. movdqa XMMWORD [wk(3)], xmm6 ; wk(3)=tmp13H
  476. pxor xmm5,xmm5
  477. pxor xmm4,xmm4
  478. punpcklwd xmm5,xmm3 ; xmm5=tmp1L
  479. punpckhwd xmm4,xmm3 ; xmm4=tmp1H
  480. psrad xmm5,(16-CONST_BITS) ; psrad xmm5,16 & pslld xmm5,CONST_BITS
  481. psrad xmm4,(16-CONST_BITS) ; psrad xmm4,16 & pslld xmm4,CONST_BITS
  482. movdqa xmm0,xmm5
  483. paddd xmm5,xmm1 ; xmm5=tmp11L
  484. psubd xmm0,xmm1 ; xmm0=tmp12L
  485. movdqa xmm7,xmm4
  486. paddd xmm4,xmm2 ; xmm4=tmp11H
  487. psubd xmm7,xmm2 ; xmm7=tmp12H
  488. movdqa XMMWORD [wk(4)], xmm5 ; wk(4)=tmp11L
  489. movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=tmp11H
  490. movdqa XMMWORD [wk(6)], xmm0 ; wk(6)=tmp12L
  491. movdqa XMMWORD [wk(7)], xmm7 ; wk(7)=tmp12H
  492. ; -- Odd part
  493. movdqa xmm6, XMMWORD [wk(9)] ; xmm6=col3
  494. movdqa xmm3, XMMWORD [wk(8)] ; xmm3=col1
  495. movdqa xmm1, XMMWORD [wk(11)] ; xmm1=col7
  496. movdqa xmm2, XMMWORD [wk(10)] ; xmm2=col5
  497. movdqa xmm5,xmm6
  498. movdqa xmm4,xmm3
  499. paddw xmm5,xmm1 ; xmm5=z3
  500. paddw xmm4,xmm2 ; xmm4=z4
  501. ; (Original)
  502. ; z5 = (z3 + z4) * 1.175875602;
  503. ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644;
  504. ; z3 += z5; z4 += z5;
  505. ;
  506. ; (This implementation)
  507. ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602;
  508. ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644);
  509. movdqa xmm0,xmm5
  510. movdqa xmm7,xmm5
  511. punpcklwd xmm0,xmm4
  512. punpckhwd xmm7,xmm4
  513. movdqa xmm5,xmm0
  514. movdqa xmm4,xmm7
  515. pmaddwd xmm0,[GOTOFF(ebx,PW_MF078_F117)] ; xmm0=z3L
  516. pmaddwd xmm7,[GOTOFF(ebx,PW_MF078_F117)] ; xmm7=z3H
  517. pmaddwd xmm5,[GOTOFF(ebx,PW_F117_F078)] ; xmm5=z4L
  518. pmaddwd xmm4,[GOTOFF(ebx,PW_F117_F078)] ; xmm4=z4H
  519. movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=z3L
  520. movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=z3H
  521. ; (Original)
  522. ; z1 = tmp0 + tmp3; z2 = tmp1 + tmp2;
  523. ; tmp0 = tmp0 * 0.298631336; tmp1 = tmp1 * 2.053119869;
  524. ; tmp2 = tmp2 * 3.072711026; tmp3 = tmp3 * 1.501321110;
  525. ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447;
  526. ; tmp0 += z1 + z3; tmp1 += z2 + z4;
  527. ; tmp2 += z2 + z3; tmp3 += z1 + z4;
  528. ;
  529. ; (This implementation)
  530. ; tmp0 = tmp0 * (0.298631336 - 0.899976223) + tmp3 * -0.899976223;
  531. ; tmp1 = tmp1 * (2.053119869 - 2.562915447) + tmp2 * -2.562915447;
  532. ; tmp2 = tmp1 * -2.562915447 + tmp2 * (3.072711026 - 2.562915447);
  533. ; tmp3 = tmp0 * -0.899976223 + tmp3 * (1.501321110 - 0.899976223);
  534. ; tmp0 += z3; tmp1 += z4;
  535. ; tmp2 += z3; tmp3 += z4;
  536. movdqa xmm0,xmm1
  537. movdqa xmm7,xmm1
  538. punpcklwd xmm0,xmm3
  539. punpckhwd xmm7,xmm3
  540. movdqa xmm1,xmm0
  541. movdqa xmm3,xmm7
  542. pmaddwd xmm0,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm0=tmp0L
  543. pmaddwd xmm7,[GOTOFF(ebx,PW_MF060_MF089)] ; xmm7=tmp0H
  544. pmaddwd xmm1,[GOTOFF(ebx,PW_MF089_F060)] ; xmm1=tmp3L
  545. pmaddwd xmm3,[GOTOFF(ebx,PW_MF089_F060)] ; xmm3=tmp3H
  546. paddd xmm0, XMMWORD [wk(10)] ; xmm0=tmp0L
  547. paddd xmm7, XMMWORD [wk(11)] ; xmm7=tmp0H
  548. paddd xmm1,xmm5 ; xmm1=tmp3L
  549. paddd xmm3,xmm4 ; xmm3=tmp3H
  550. movdqa XMMWORD [wk(8)], xmm0 ; wk(8)=tmp0L
  551. movdqa XMMWORD [wk(9)], xmm7 ; wk(9)=tmp0H
  552. movdqa xmm0,xmm2
  553. movdqa xmm7,xmm2
  554. punpcklwd xmm0,xmm6
  555. punpckhwd xmm7,xmm6
  556. movdqa xmm2,xmm0
  557. movdqa xmm6,xmm7
  558. pmaddwd xmm0,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm0=tmp1L
  559. pmaddwd xmm7,[GOTOFF(ebx,PW_MF050_MF256)] ; xmm7=tmp1H
  560. pmaddwd xmm2,[GOTOFF(ebx,PW_MF256_F050)] ; xmm2=tmp2L
  561. pmaddwd xmm6,[GOTOFF(ebx,PW_MF256_F050)] ; xmm6=tmp2H
  562. paddd xmm0,xmm5 ; xmm0=tmp1L
  563. paddd xmm7,xmm4 ; xmm7=tmp1H
  564. paddd xmm2, XMMWORD [wk(10)] ; xmm2=tmp2L
  565. paddd xmm6, XMMWORD [wk(11)] ; xmm6=tmp2H
  566. movdqa XMMWORD [wk(10)], xmm0 ; wk(10)=tmp1L
  567. movdqa XMMWORD [wk(11)], xmm7 ; wk(11)=tmp1H
  568. ; -- Final output stage
  569. movdqa xmm5, XMMWORD [wk(0)] ; xmm5=tmp10L
  570. movdqa xmm4, XMMWORD [wk(1)] ; xmm4=tmp10H
  571. movdqa xmm0,xmm5
  572. movdqa xmm7,xmm4
  573. paddd xmm5,xmm1 ; xmm5=data0L
  574. paddd xmm4,xmm3 ; xmm4=data0H
  575. psubd xmm0,xmm1 ; xmm0=data7L
  576. psubd xmm7,xmm3 ; xmm7=data7H
  577. movdqa xmm1,[GOTOFF(ebx,PD_DESCALE_P2)] ; xmm1=[PD_DESCALE_P2]
  578. paddd xmm5,xmm1
  579. paddd xmm4,xmm1
  580. psrad xmm5,DESCALE_P2
  581. psrad xmm4,DESCALE_P2
  582. paddd xmm0,xmm1
  583. paddd xmm7,xmm1
  584. psrad xmm0,DESCALE_P2
  585. psrad xmm7,DESCALE_P2
  586. packssdw xmm5,xmm4 ; xmm5=data0=(00 10 20 30 40 50 60 70)
  587. packssdw xmm0,xmm7 ; xmm0=data7=(07 17 27 37 47 57 67 77)
  588. movdqa xmm3, XMMWORD [wk(4)] ; xmm3=tmp11L
  589. movdqa xmm1, XMMWORD [wk(5)] ; xmm1=tmp11H
  590. movdqa xmm4,xmm3
  591. movdqa xmm7,xmm1
  592. paddd xmm3,xmm2 ; xmm3=data1L
  593. paddd xmm1,xmm6 ; xmm1=data1H
  594. psubd xmm4,xmm2 ; xmm4=data6L
  595. psubd xmm7,xmm6 ; xmm7=data6H
  596. movdqa xmm2,[GOTOFF(ebx,PD_DESCALE_P2)] ; xmm2=[PD_DESCALE_P2]
  597. paddd xmm3,xmm2
  598. paddd xmm1,xmm2
  599. psrad xmm3,DESCALE_P2
  600. psrad xmm1,DESCALE_P2
  601. paddd xmm4,xmm2
  602. paddd xmm7,xmm2
  603. psrad xmm4,DESCALE_P2
  604. psrad xmm7,DESCALE_P2
  605. packssdw xmm3,xmm1 ; xmm3=data1=(01 11 21 31 41 51 61 71)
  606. packssdw xmm4,xmm7 ; xmm4=data6=(06 16 26 36 46 56 66 76)
  607. packsswb xmm5,xmm4 ; xmm5=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
  608. packsswb xmm3,xmm0 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
  609. movdqa xmm6, XMMWORD [wk(6)] ; xmm6=tmp12L
  610. movdqa xmm2, XMMWORD [wk(7)] ; xmm2=tmp12H
  611. movdqa xmm1, XMMWORD [wk(10)] ; xmm1=tmp1L
  612. movdqa xmm7, XMMWORD [wk(11)] ; xmm7=tmp1H
  613. movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
  614. movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
  615. movdqa xmm4,xmm6
  616. movdqa xmm0,xmm2
  617. paddd xmm6,xmm1 ; xmm6=data2L
  618. paddd xmm2,xmm7 ; xmm2=data2H
  619. psubd xmm4,xmm1 ; xmm4=data5L
  620. psubd xmm0,xmm7 ; xmm0=data5H
  621. movdqa xmm5,[GOTOFF(ebx,PD_DESCALE_P2)] ; xmm5=[PD_DESCALE_P2]
  622. paddd xmm6,xmm5
  623. paddd xmm2,xmm5
  624. psrad xmm6,DESCALE_P2
  625. psrad xmm2,DESCALE_P2
  626. paddd xmm4,xmm5
  627. paddd xmm0,xmm5
  628. psrad xmm4,DESCALE_P2
  629. psrad xmm0,DESCALE_P2
  630. packssdw xmm6,xmm2 ; xmm6=data2=(02 12 22 32 42 52 62 72)
  631. packssdw xmm4,xmm0 ; xmm4=data5=(05 15 25 35 45 55 65 75)
  632. movdqa xmm3, XMMWORD [wk(2)] ; xmm3=tmp13L
  633. movdqa xmm1, XMMWORD [wk(3)] ; xmm1=tmp13H
  634. movdqa xmm7, XMMWORD [wk(8)] ; xmm7=tmp0L
  635. movdqa xmm5, XMMWORD [wk(9)] ; xmm5=tmp0H
  636. movdqa xmm2,xmm3
  637. movdqa xmm0,xmm1
  638. paddd xmm3,xmm7 ; xmm3=data3L
  639. paddd xmm1,xmm5 ; xmm1=data3H
  640. psubd xmm2,xmm7 ; xmm2=data4L
  641. psubd xmm0,xmm5 ; xmm0=data4H
  642. movdqa xmm7,[GOTOFF(ebx,PD_DESCALE_P2)] ; xmm7=[PD_DESCALE_P2]
  643. paddd xmm3,xmm7
  644. paddd xmm1,xmm7
  645. psrad xmm3,DESCALE_P2
  646. psrad xmm1,DESCALE_P2
  647. paddd xmm2,xmm7
  648. paddd xmm0,xmm7
  649. psrad xmm2,DESCALE_P2
  650. psrad xmm0,DESCALE_P2
  651. movdqa xmm5,[GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm5=[PB_CENTERJSAMP]
  652. packssdw xmm3,xmm1 ; xmm3=data3=(03 13 23 33 43 53 63 73)
  653. packssdw xmm2,xmm0 ; xmm2=data4=(04 14 24 34 44 54 64 74)
  654. movdqa xmm7, XMMWORD [wk(0)] ; xmm7=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
  655. movdqa xmm1, XMMWORD [wk(1)] ; xmm1=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
  656. packsswb xmm6,xmm2 ; xmm6=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74)
  657. packsswb xmm3,xmm4 ; xmm3=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75)
  658. paddb xmm7,xmm5
  659. paddb xmm1,xmm5
  660. paddb xmm6,xmm5
  661. paddb xmm3,xmm5
  662. movdqa xmm0,xmm7 ; transpose coefficients(phase 1)
  663. punpcklbw xmm7,xmm1 ; xmm7=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71)
  664. punpckhbw xmm0,xmm1 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77)
  665. movdqa xmm2,xmm6 ; transpose coefficients(phase 1)
  666. punpcklbw xmm6,xmm3 ; xmm6=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73)
  667. punpckhbw xmm2,xmm3 ; xmm2=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75)
  668. movdqa xmm4,xmm7 ; transpose coefficients(phase 2)
  669. punpcklwd xmm7,xmm6 ; xmm7=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
  670. punpckhwd xmm4,xmm6 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73)
  671. movdqa xmm5,xmm2 ; transpose coefficients(phase 2)
  672. punpcklwd xmm2,xmm0 ; xmm2=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
  673. punpckhwd xmm5,xmm0 ; xmm5=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77)
  674. movdqa xmm1,xmm7 ; transpose coefficients(phase 3)
  675. punpckldq xmm7,xmm2 ; xmm7=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
  676. punpckhdq xmm1,xmm2 ; xmm1=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
  677. movdqa xmm3,xmm4 ; transpose coefficients(phase 3)
  678. punpckldq xmm4,xmm5 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
  679. punpckhdq xmm3,xmm5 ; xmm3=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
  680. pshufd xmm6,xmm7,0x4E ; xmm6=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
  681. pshufd xmm0,xmm1,0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
  682. pshufd xmm2,xmm4,0x4E ; xmm2=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
  683. pshufd xmm5,xmm3,0x4E ; xmm5=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
  684. mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
  685. mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
  686. movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm7
  687. movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm1
  688. mov edx, JSAMPROW [edi+4*SIZEOF_JSAMPROW]
  689. mov esi, JSAMPROW [edi+6*SIZEOF_JSAMPROW]
  690. movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm4
  691. movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm3
  692. mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
  693. mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
  694. movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6
  695. movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm0
  696. mov edx, JSAMPROW [edi+5*SIZEOF_JSAMPROW]
  697. mov esi, JSAMPROW [edi+7*SIZEOF_JSAMPROW]
  698. movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm2
  699. movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm5
  700. pop edi
  701. pop esi
  702. ; pop edx ; need not be preserved
  703. ; pop ecx ; unused
  704. poppic ebx
  705. mov esp,ebp ; esp <- aligned ebp
  706. pop esp ; esp <- original ebp
  707. pop ebp
  708. ret
  709. ; For some reason, the OS X linker does not honor the request to align the
  710. ; segment unless we do this.
  711. align 16