mfint.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 55k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. /***************************************************************************
  2. *
  3. *                INTEL Corporation Proprietary Information  
  4. *
  5. *      
  6. *                  Copyright (c) 1996 Intel Corporation.
  7. *                         All rights reserved.
  8. *
  9. ***************************************************************************
  10. */
  11. /*
  12.  * jfdctint.c
  13.  *
  14.  * Copyright (C) 1991-1996, Thomas G. Lane.
  15.  * This file is part of the Independent JPEG Group's software.
  16.  * For conditions of distribution and use, see the accompanying README file.
  17.  *
  18.  * This file contains a slow-but-accurate integer implementation of the
  19.  * forward DCT (Discrete Cosine Transform).
  20.  *
  21.  * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
  22.  * on each column.  Direct algorithms are also available, but they are
  23.  * much more complex and seem not to be any faster when reduced to code.
  24.  *
  25.  * This implementation is based on an algorithm described in
  26.  *   C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
  27.  *   Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
  28.  *   Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
  29.  * The primary algorithm described there uses 11 multiplies and 29 adds.
  30.  * We use their alternate method with 12 multiplies and 32 adds.
  31.  * The advantage of this method is that no data path contains more than one
  32.  * multiplication; this allows a very simple and accurate implementation in
  33.  * scaled fixed-point arithmetic, with a minimal number of shifts.
  34.  */
  35. #define JPEG_INTERNALS
  36. #include "jinclude.h"
  37. #include "jpeglib.h"
  38. #include "jdct.h" /* Private declarations for DCT subsystem */
  39. #ifdef DCT_ISLOW_SUPPORTED
  40. /*
  41.  * This module is specialized to the case DATASIZE = 8.
  42.  */
  43. #if DCTSIZE != 8
  44.   Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
  45. #endif
  46. /*
  47.  * The poop on this scaling stuff is as follows:
  48.  *
  49.  * Each 1-D DCT step produces outputs which are a factor of sqrt(N)
  50.  * larger than the true DCT outputs.  The final outputs are therefore
  51.  * a factor of N larger than desired; since N=8 this can be cured by
  52.  * a simple right shift at the end of the algorithm.  The advantage of
  53.  * this arrangement is that we save two multiplications per 1-D DCT,
  54.  * because the y0 and y4 outputs need not be divided by sqrt(N).
  55.  * In the IJG code, this factor of 8 is removed by the quantization step
  56.  * (in jcdctmgr.c), NOT in this module.
  57.  *
  58.  * We have to do addition and subtraction of the integer inputs, which
  59.  * is no problem, and multiplication by fractional constants, which is
  60.  * a problem to do in integer arithmetic.  We multiply all the constants
  61.  * by CONST_SCALE and convert them to integer constants (thus retaining
  62.  * CONST_BITS bits of precision in the constants).  After doing a
  63.  * multiplication we have to divide the product by CONST_SCALE, with proper
  64.  * rounding, to produce the correct output.  This division can be done
  65.  * cheaply as a right shift of CONST_BITS bits.  We postpone shifting
  66.  * as long as possible so that partial sums can be added together with
  67.  * full fractional precision.
  68.  *
  69.  * The outputs of the first pass are scaled up by PASS1_BITS bits so that
  70.  * they are represented to better-than-integral precision.  These outputs
  71.  * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
  72.  * with the recommended scaling.  (For 12-bit sample data, the intermediate
  73.  * array is INT32 anyway.)
  74.  *
  75.  * To avoid overflow of the 32-bit intermediate results in pass 2, we must
  76.  * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26.  Error analysis
  77.  * shows that the values given below are the most effective.
  78.  */
  79. #if BITS_IN_JSAMPLE == 8
  80. #define CONST_BITS  13
  81. #define PASS1_BITS  2
  82. #else
  83. #define CONST_BITS  13
  84. #define PASS1_BITS  1 /* lose a little precision to avoid overflow */
  85. #endif
  86. /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
  87.  * causing a lot of useless floating-point operations at run time.
  88.  * To get around this we use the following pre-calculated constants.
  89.  * If you change CONST_BITS you may want to add appropriate values.
  90.  * (With a reasonable C compiler, you can just rely on the FIX() macro...)
  91.  */
  92. #if CONST_BITS == 13
  93. #define FIX_0_298631336  ((INT32)  2446) /* FIX(0.298631336) */
  94. #define FIX_0_390180644  ((INT32)  3196) /* FIX(0.390180644) */
  95. #define FIX_0_541196100  ((INT32)  4433) /* FIX(0.541196100) */
  96. #define FIX_0_765366865  ((INT32)  6270) /* FIX(0.765366865) */
  97. #define FIX_0_899976223  ((INT32)  7373) /* FIX(0.899976223) */
  98. #define FIX_1_175875602  ((INT32)  9633) /* FIX(1.175875602) */
  99. #define FIX_1_501321110  ((INT32)  12299) /* FIX(1.501321110) */
  100. #define FIX_1_847759065  ((INT32)  15137) /* FIX(1.847759065) */
  101. #define FIX_1_961570560  ((INT32)  16069) /* FIX(1.961570560) */
  102. #define FIX_2_053119869  ((INT32)  16819) /* FIX(2.053119869) */
  103. #define FIX_2_562915447  ((INT32)  20995) /* FIX(2.562915447) */
  104. #define FIX_3_072711026  ((INT32)  25172) /* FIX(3.072711026) */
  105. #else
  106. #define FIX_0_298631336  FIX(0.298631336)
  107. #define FIX_0_390180644  FIX(0.390180644)
  108. #define FIX_0_541196100  FIX(0.541196100)
  109. #define FIX_0_765366865  FIX(0.765366865)
  110. #define FIX_0_899976223  FIX(0.899976223)
  111. #define FIX_1_175875602  FIX(1.175875602)
  112. #define FIX_1_501321110  FIX(1.501321110)
  113. #define FIX_1_847759065  FIX(1.847759065)
  114. #define FIX_1_961570560  FIX(1.961570560)
  115. #define FIX_2_053119869  FIX(2.053119869)
  116. #define FIX_2_562915447  FIX(2.562915447)
  117. #define FIX_3_072711026  FIX(3.072711026)
  118. #endif
  119. const __int64 Const_1 = 0x0000000100000001;
  120. const __int64 Const_2 = 0x0002000200020002;
  121. const __int64 Const_1024 = 0x0000040000000400;
  122. const __int64 Const_16384 = 0x0000400000004000;
  123. const __int64 Const_FFFF = 0xFFFFFFFFFFFFFFFF;
  124.  
  125. const __int64 Const_0xFIX_0_298631336 = 0x0000098e0000098e;
  126. const __int64 Const_FIX_0_298631336x0 = 0x098e0000098e0000;
  127. const __int64 Const_0xFIX_0_390180644 = 0x00000c7c00000c7c;
  128. const __int64 Const_FIX_0_390180644x0 = 0x0c7c00000c7c0000;
  129. const __int64 Const_0xFIX_0_541196100 = 0x0000115100001151;
  130. const __int64 Const_FIX_0_541196100x0 = 0x1151000011510000;
  131. const __int64 Const_0xFIX_0_765366865 = 0x0000187e0000187e;
  132. const __int64 Const_FIX_0_765366865x0 = 0x187e0000187e0000;
  133. const __int64 Const_0xFIX_0_899976223 = 0x00001ccd00001ccd;
  134. const __int64 Const_FIX_0_899976223x0 = 0x1ccd00001ccd0000;
  135. const __int64 Const_0xFIX_1_175875602 = 0x000025a1000025a1;
  136. const __int64 Const_FIX_1_175875602x0 = 0x25a1000025a10000;
  137. const __int64 Const_0xFIX_1_501321110 = 0x0000300b0000300b;
  138. const __int64 Const_FIX_1_501321110x0 = 0x300b0000300b0000;
  139. const __int64 Const_0xFIX_1_847759065 = 0x00003b2100003b21;
  140. const __int64 Const_FIX_1_847759065x0 = 0x3b2100003b210000;
  141. const __int64 Const_0xFIX_1_961570560 = 0x00003ec500003ec5;
  142. const __int64 Const_FIX_1_961570560x0 = 0x3ec500003ec50000;
  143. const __int64 Const_0xFIX_2_053119869 = 0x000041b3000041b3;
  144. const __int64 Const_FIX_2_053119869x0 = 0x41b3000041b30000;
  145. const __int64 Const_0xFIX_2_562915447 = 0x0000520300005203;
  146. const __int64 Const_FIX_2_562915447x0 = 0x5203000052030000;
  147. const __int64 Const_0xFIX_3_072711026 = 0x0000625400006254;
  148. const __int64 Const_FIX_3_072711026x0 = 0x6254000062540000;
  149. /* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
  150.  * For 8-bit samples with the recommended scaling, all the variable
  151.  * and constant values involved are no more than 16 bits wide, so a
  152.  * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
  153.  * For 12-bit samples, a full 32-bit multiplication will be needed.
  154.  */
  155. #if BITS_IN_JSAMPLE == 8
  156. #define MULTIPLY(var,const)  MULTIPLY16C16(var,const)
  157. #else
  158. #define MULTIPLY(var,const)  ((var) * (const))
  159. #endif
  160. #define DATASIZE 32 
  161.  /*
  162.  * Perform the forward DCT on one block of samples.
  163.  */
  164. GLOBAL(void)
  165. mfdct8x8llm (DCTELEM * data)
  166. {
  167. __int64 qwTemp0, qwTemp2, qwTemp4, qwTemp6;
  168. __int64 qwZ1, qwZ2, qwZ4_even, qwZ4_odd;
  169. __int64 qwTmp4_Z3_Even, qwTmp4_Z3_Odd;
  170. __int64 qwTmp6_Z3_Even, qwTmp6_Z3_Odd;
  171. __int64 qwTmp5_Z4_Even, qwTmp5_Z4_Odd;
  172. __int64 qwScratch7, qwScratch6, qwScratch5;
  173. __asm{
  174. mov edi, [data]
  175. // transpose the bottom right quadrant(4X4) of the matrix
  176. //  ---------       ---------
  177. // | M1 | M2 |     | M1'| M3'|
  178. //  ---------  -->  ---------
  179. // | M3 | M4 |     | M2'| M4'|
  180. //  ---------       ---------
  181. // Get the 32-bit quantities and pack into 16 bits
  182. movq mm5, [edi][DATASIZE*4+16] //| w41 | w40 |
  183. movq mm3, [edi][DATASIZE*4+24] //| w43 | w42 |
  184. movq mm6, [edi][DATASIZE*5+16]
  185. packssdw mm5, mm3 //|w43|w42|w41|w40|
  186. movq mm7, [edi][DATASIZE*5+24]
  187. movq mm4, mm5 // copy w4---0,1,3,5,6
  188. movq mm3, [edi][DATASIZE*6+16]
  189. packssdw mm6, mm7
  190. movq mm2, [edi][DATASIZE*6+24]
  191. punpcklwd mm5, mm6 //mm6 = w5
  192. movq mm1, [edi][DATASIZE*7+16]
  193. packssdw mm3, mm2
  194. movq mm0, [edi][DATASIZE*7+24]
  195. punpckhwd mm4, mm6 //---0,1,3,5,6 
  196. packssdw mm1, mm0
  197. movq mm7, mm3 //---0,1,2,3,5,6 w6
  198. punpcklwd mm3, mm1 //mm1 = w7
  199. movq mm0, mm5 //---0,2,3,4,5,6,7
  200. movq mm2, [edi][DATASIZE*4] //| w01 | w00 |
  201. punpckhdq mm0, mm3 // transposed w5---0,2,4,6,7
  202. punpckhwd mm7, mm1 //---0,2,3,5,6,7
  203. movq mm1, [edi][DATASIZE*5+8]
  204. movq mm6, mm4 //---0,2,3,4,6,7
  205. movq [edi][DATASIZE*5+16], mm0  // store w5
  206. punpckldq mm5, mm3 // transposed w4
  207. movq mm3, [edi][DATASIZE*5]
  208. punpckldq mm4, mm7 // transposed w6
  209. movq mm0, [edi][DATASIZE*4+8]  //| w03 | w02 |
  210. punpckhdq mm6, mm7 // transposed w7---0,3,6,7
  211. // transpose the bottom left quadrant(4X4) of the matrix and place
  212. // in the top right quadrant while doing the same for the top
  213. // right quadrant
  214. //  ---------       ---------
  215. // | M1 | M2 |     | M1'| M3'|
  216. //  ---------  -->  ---------
  217. // | M3 | M4 |     | M2'| M4'|
  218. //  ---------       ---------
  219. movq [edi][DATASIZE*4+16], mm5  // store w4
  220. packssdw mm2, mm0 //|w03|w02|w01|w00|
  221. movq mm5, [edi][DATASIZE*7]
  222. packssdw mm3, mm1
  223. movq mm0, [edi][DATASIZE*7+8]
  224. movq [edi][DATASIZE*7+16], mm6  // store w7---5,6,7
  225. packssdw mm5, mm0
  226. movq mm6, [edi][DATASIZE*6]
  227. movq mm0, mm2 // copy w0---0,1,3,5,6
  228. movq mm7, [edi][DATASIZE*6+8]
  229. punpcklwd mm2, mm3 //mm6 = w1
  230. movq [edi][DATASIZE*6+16], mm4  // store w6---3,5,6,7
  231. packssdw mm6, mm7
  232. movq mm1, [edi][DATASIZE*0+24]
  233. punpckhwd mm0, mm3 //---0,1,3,5,6 
  234. movq mm7, mm6 //---0,1,2,3,5,6 w2
  235. punpcklwd mm6, mm5 //mm1 = w3
  236. movq mm3, [edi][DATASIZE*0+16]
  237. punpckhwd mm7, mm5 //---0,2,3,5,6,7
  238. movq mm4, [edi][DATASIZE*2+24]
  239. packssdw mm3, mm1
  240. movq mm1, mm2 //---0,2,3,4,5,6,7
  241. punpckldq mm2, mm6 // transposed w4
  242. movq mm5, [edi][DATASIZE*2+16]
  243. punpckhdq mm1, mm6 // transposed w5---0,2,4,6,7
  244. movq [edi][DATASIZE*0+16], mm2  // store w4
  245.   packssdw mm5, mm4
  246. movq mm4, [edi][DATASIZE*1+16]
  247. movq mm6, mm0 //---0,2,3,4,6,7
  248. movq mm2, [edi][DATASIZE*1+24]
  249. punpckldq mm0, mm7 // transposed w6
  250. movq [edi][DATASIZE*1+16], mm1  // store w5
  251. punpckhdq mm6, mm7 // transposed w7---0,3,6,7
  252. movq mm7, [edi][DATASIZE*3+24]
  253. packssdw mm4, mm2
  254. movq [edi][DATASIZE*2+16], mm0  // store w6---3,5,6,7
  255. movq mm1, mm3 // copy w4---0,1,3,5,6
  256. movq mm2, [edi][DATASIZE*3+16]
  257. punpcklwd mm3, mm4 //mm6 = w5
  258. movq [edi][DATASIZE*3+16], mm6  // store w7---5,6,7
  259. packssdw mm2, mm7
  260. // transpose the bottom left quadrant(4X4) of the matrix
  261. //  ---------       ---------
  262. // | M1 | M2 |     | M1'| M3'|
  263. //  ---------  -->  ---------
  264. // | M3 | M4 |     | M2'| M4'|
  265. //  ---------       ---------
  266.     movq mm6, [edi][DATASIZE*0] //| w01 | w00 |
  267. punpckhwd mm1, mm4 //---0,1,3,5,6
  268. movq mm7, mm5 //---0,1,2,3,5,6 w6
  269. punpcklwd mm5, mm2 //mm1 = w7
  270. movq mm4, [edi][DATASIZE*0+8] //| w03 | w02 |
  271. punpckhwd mm7, mm2 //---0,2,3,5,6,7
  272. movq mm0, mm3 //---0,2,3,4,5,6,7
  273. packssdw mm6, mm4 //|w03|w02|w01|w00|
  274. movq mm2, [edi][DATASIZE*2+8]
  275. punpckldq mm3, mm5 // transposed w4
  276. movq mm4, [edi][DATASIZE*1]
  277. punpckhdq mm0, mm5 // transposed w5---0,2,4,6,7
  278. movq [edi][DATASIZE*4], mm3  // store w4
  279. movq mm5, mm1 //---0,2,3,4,6,7
  280. movq mm3, [edi][DATASIZE*2]
  281. punpckldq mm1, mm7 // transposed w6
  282. movq [edi][DATASIZE*5], mm0  // store w5
  283. punpckhdq mm5, mm7 // transposed w7---0,3,6,7
  284. movq mm7, [edi][DATASIZE*1+8]
  285. packssdw mm3, mm2
  286. movq [edi][DATASIZE*7], mm5  // store w7---5,6,7
  287. movq mm2, mm6 // copy w0---0,1,3,5,6
  288. movq [edi][DATASIZE*6], mm1  // store w6---3,5,6,7
  289. packssdw mm4, mm7
  290. // transpose the top left quadrant(4X4) of the matrix
  291. //  ---------       ---------
  292. // | M1 | M2 |     | M1'| M3'|
  293. //  ---------  -->  ---------
  294. // | M3 | M4 |     | M2'| M4'|
  295. //  ---------       ---------
  296. // Get the 32-bit quantities and pack into 16 bits
  297. movq mm1, [edi][DATASIZE*3]
  298. punpcklwd mm6, mm4 //mm6 = w1
  299. movq mm0, [edi][DATASIZE*3+8]
  300. punpckhwd mm2, mm4 //---0,1,3,5,6 
  301. packssdw mm1, mm0
  302. movq mm5, mm3 //---0,1,2,3,5,6 w2
  303. punpcklwd mm3, mm1 //mm1 = w3
  304. movq mm0, mm6 //---0,2,3,4,5,6,7
  305. movq mm4, [edi][DATASIZE*7]
  306. punpckhwd mm5, mm1 //---0,2,3,5,6,7
  307. movq mm1, [edi][DATASIZE*4]
  308. punpckhdq mm6, mm3 // transposed w4
  309. punpckldq mm0, mm3 // transposed w5---0,2,4,6,7
  310. movq mm3, mm2 //---0,2,3,4,6,7
  311. movq [edi][DATASIZE*0], mm0  // store w4
  312. punpckldq mm2, mm5 // transposed w6
  313. movq [edi][DATASIZE*1], mm6  // store w5
  314. punpckhdq mm3, mm5 // transposed w7---0,3,6,7
  315. movq [edi][DATASIZE*2], mm2  // store w6---3,5,6,7
  316. paddw mm0, mm4
  317. movq [edi][DATASIZE*3], mm3  // store w7---5,6,7
  318. paddw mm3, mm1
  319. //******************************************************************************
  320. // End of transpose.  Begin row dct.
  321. //******************************************************************************
  322. // tmp0 = dataptr[DATASIZE*0] + dataptr[DATASIZE*7];
  323. movq mm7, mm0
  324. paddw mm0, mm3 //tmp10
  325. paddw mm6, [edi][DATASIZE*6]
  326. psubw mm7, mm3 //tmp13
  327. paddw mm2, [edi][DATASIZE*5]
  328. movq mm1, mm6
  329. // tmp10 = tmp0 + tmp3;
  330. paddw mm1, mm2 //tmp11
  331. psubw mm6, mm2 //tmp12
  332. //    dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);
  333. //    dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
  334. movq mm3, mm0
  335. paddw mm0, mm1 //tmp10 + tmp11
  336. psubw mm3, mm1 //tmp10 - tmp11
  337. psllw mm0, 2 // descale it
  338.   movq mm1, mm6 //copy tmp12
  339. psllw mm3, 2 // descale it
  340. // z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
  341. movq qwTemp0, mm0 //store 
  342. paddw mm1, mm7 //tmp12 + tmp13
  343. movq mm2, mm1 //copy
  344. // dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
  345. //    CONST_BITS-PASS1_BITS);
  346. // dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
  347. //    CONST_BITS-PASS1_BITS);
  348. pmaddwd mm1, Const_0xFIX_0_541196100 //| z12 | z10 |
  349. movq mm4, mm7
  350. pmaddwd mm7, Const_0xFIX_0_765366865 //| r2 | r0 |
  351. movq mm0, mm6
  352. pmaddwd mm2, Const_FIX_0_541196100x0 //| z13 | z11 |
  353. pmaddwd mm4, Const_FIX_0_765366865x0 //| r3 | r1 |
  354. pmaddwd mm6, Const_0xFIX_1_847759065 //| r2 | r0 |
  355. paddd mm7, mm1 // add z1
  356. pmaddwd mm0, Const_FIX_1_847759065x0 //| r3 | r1 |
  357. paddd mm7, Const_1024
  358. paddd mm4, mm2
  359. paddd mm4, Const_1024
  360. psrad mm7, 11 // descale it |  |R2|  |R0|
  361. //!!!!!! Negate the results in mm6 and mm0
  362. pxor mm6, Const_FFFF //invert result
  363. psrad mm4, 11 // descale it |  |R3|  |R1|
  364. paddd mm6, Const_1 // 2's complement
  365. movq mm5, mm7
  366. pxor mm0, Const_FFFF //invert result
  367. punpckldq mm7, mm4 //|  |R1|  |R0|
  368. paddd mm0, Const_1 // 2's complement
  369. punpckhdq mm5, mm4 //|  |R3|  |R2|
  370. movq qwTemp4, mm3 //store
  371. packssdw mm7, mm5
  372. movq mm5, Const_1024
  373. paddd mm6, mm1 // add z1
  374. movq qwTemp2, mm7 //store
  375. paddd mm6, mm5
  376. paddd mm0, mm2
  377. psrad mm6, 11 // descale it |  |R2|  |R0|
  378. paddd mm0, mm5
  379. movq mm5, mm6
  380. movq mm4, [edi][DATASIZE*3]
  381. psrad mm0, 11 // descale it |  |R3|  |R1|
  382. psubw mm4, [edi][DATASIZE*4]
  383. punpckldq mm6, mm0 //|  |R1|  |R0|
  384. movq mm7, [edi][DATASIZE*0]
  385. punpckhdq mm5, mm0 //|  |R3|  |R2|
  386. psubw mm7, [edi][DATASIZE*7]
  387. packssdw mm6, mm5
  388. // tmp4 = dataptr[3] - dataptr[4];
  389. movq mm5, [edi][DATASIZE*2]
  390. movq mm0, mm4
  391. psubw mm5, [edi][DATASIZE*5]
  392. movq mm2, mm4
  393. movq qwTemp6, mm6 //store
  394. paddw mm0, mm7 //z1
  395. movq mm6, [edi][DATASIZE*1]
  396. movq mm1, mm5
  397. psubw mm6, [edi][DATASIZE*6]
  398. movq mm3, mm5
  399. // z1 = tmp4 + tmp7;
  400. movq qwScratch5, mm5
  401. paddw mm3, mm7 //z4
  402. movq qwScratch7, mm7
  403. paddw mm2, mm6 //z3
  404. movq qwZ1, mm0 //store
  405. paddw mm1, mm6 //z2
  406. //     z3 = MULTIPLY(z3, - FIX_1_961570560);
  407. //     z4 = MULTIPLY(z4, - FIX_0_390180644);
  408. //     z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
  409. movq mm0, Const_FFFF
  410. movq mm5, mm2
  411. movq qwZ2, mm1
  412. movq mm7, mm2
  413. pmaddwd mm5, Const_0xFIX_1_961570560 //z32, z30
  414. paddw mm2, mm3 //z3 + z4
  415. pmaddwd mm7, Const_FIX_1_961570560x0 //z33, z31
  416. movq mm1, mm3
  417. movq qwScratch6, mm6
  418. movq mm6, mm2
  419. //     z3 += z5;
  420. //!!!!!! Negate the results
  421. pmaddwd mm2, Const_0xFIX_1_175875602 //z52, z50
  422. pxor mm5, mm0 //invert result
  423. paddd mm5, Const_1 // 2's complement
  424. pxor mm7, mm0 //invert result
  425. pmaddwd mm3, Const_0xFIX_0_390180644 //z42, z40
  426. pmaddwd mm1, Const_FIX_0_390180644x0 //z43, z41
  427. paddd mm5, mm2 //z3_even
  428. paddd mm7, Const_1 // 2's complement
  429. pmaddwd mm6, Const_FIX_1_175875602x0 //z53, z51
  430. pxor mm3, mm0 //invert result
  431. //     z4 += z5;
  432. //!!!!!! Negate the results
  433. paddd mm3, Const_1 // 2's complement
  434. pxor mm1, mm0 //invert result
  435. paddd mm1, Const_1 // 2's complement
  436. paddd mm3, mm2
  437. movq mm0, qwScratch6
  438. movq mm2, mm4
  439. //     tmp4 = MULTIPLY(tmp4, FIX_0_298631336);
  440. pmaddwd mm4, Const_0xFIX_0_298631336 //T42, T40
  441. paddd mm7, mm6 //z3_odd
  442. pmaddwd mm2, Const_FIX_0_298631336x0 //T43, T41
  443. paddd mm1, mm6
  444. movq mm6, mm0
  445. paddd mm4, mm5
  446. //     tmp6 = MULTIPLY(tmp6, FIX_3_072711026);
  447. pmaddwd mm6, Const_0xFIX_3_072711026 //T62, T60
  448. paddd mm2, mm7
  449. pmaddwd mm0, Const_FIX_3_072711026x0 //T63, T61
  450. movq qwTmp4_Z3_Odd, mm2
  451. movq qwTmp4_Z3_Even, mm4
  452. paddd mm6, mm5
  453. movq mm5, qwScratch5
  454. paddd mm0, mm7
  455. movq mm7, qwScratch7
  456. movq mm2, mm5
  457. movq qwTmp6_Z3_Even, mm6
  458. movq mm6, mm7
  459. //     tmp5 = MULTIPLY(tmp5, FIX_2_053119869);
  460. //     tmp7 = MULTIPLY(tmp7, FIX_1_501321110);
  461. pmaddwd mm5, Const_0xFIX_2_053119869 //T52, T50
  462. pmaddwd mm2, Const_FIX_2_053119869x0 //T53, T51
  463. pmaddwd mm7, Const_0xFIX_1_501321110 //T72, T70
  464. pmaddwd mm6, Const_FIX_1_501321110x0 //T73, T71
  465. paddd mm5, mm3
  466. movq qwTmp6_Z3_Odd, mm0
  467. paddd mm2, mm1
  468. movq qwTmp5_Z4_Even, mm5
  469. paddd mm7, mm3
  470. movq mm0, qwZ1
  471. paddd mm6, mm1
  472. //     z1 = MULTIPLY(z1, - FIX_0_899976223);
  473. movq mm1, Const_FFFF
  474. movq mm4, mm0
  475. //!!!!!! Negate the results
  476. pmaddwd mm0, Const_0xFIX_0_899976223 //z12, z10
  477. pmaddwd mm4, Const_FIX_0_899976223x0 //z13, z11
  478. movq mm3, qwTmp4_Z3_Even
  479. movq qwTmp5_Z4_Odd, mm2
  480. pxor mm0, mm1 //invert result
  481. movq mm2, qwTmp4_Z3_Odd
  482. pxor mm4, mm1 //invert result
  483. paddd mm4, Const_1 // 2's complement
  484. paddd mm7, mm0 //tmp7 + z1 + z4 EVEN
  485. paddd mm0, Const_1 // 2's complement
  486. paddd mm6, mm4 //tmp7 + z1 + z4 ODD
  487. //     dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
  488. paddd mm7, Const_1024 //rounding adj
  489. paddd mm3, mm0 //tmp4 + z1 + z3 EVEN
  490. paddd mm6, Const_1024 //rounding adj
  491. psrad mm7, 11 // descale it |  |R2|  |R0|
  492. psrad mm6, 11 // descale it |  |R3|  |R1|
  493. movq mm5, mm7
  494. punpckldq mm7, mm6 //|  |R1|  |R0|
  495. //     dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
  496. punpckhdq mm5, mm6 //|  |R3|  |R2|
  497. paddd mm2, mm4 //tmp4 + z1 + z3 ODD
  498. paddd mm3, Const_1024 //rounding adj
  499. packssdw mm7, mm5
  500. paddd mm2, Const_1024 //rounding adj
  501. psrad mm3, 11 // descale it |  |R2|  |R0|
  502. movq mm0, qwZ2
  503. psrad mm2, 11 // descale it |  |R3|  |R1|
  504. movq mm5, mm3
  505. movq mm4, mm0
  506. //     z2 = MULTIPLY(z2, - FIX_2_562915447);
  507. pmaddwd mm0, Const_0xFIX_2_562915447 //z22, z20
  508. punpckldq mm3, mm2 //|  |R1|  |R0|
  509. pmaddwd mm4, Const_FIX_2_562915447x0 //z23, z21
  510. punpckhdq mm5, mm2 //|  |R3|  |R2|
  511. movq mm2, Const_FFFF
  512. packssdw mm3, mm5
  513. movq [edi][DATASIZE*1], mm7 //store
  514. //!!!!!! Negate the results
  515. pxor mm0, mm2 //invert result
  516. movq mm5, Const_1
  517. pxor mm4, mm2 //invert result
  518. movq [edi][DATASIZE*7], mm3 //store
  519. paddd mm0, mm5 // 2's complement
  520. movq mm7, qwTmp6_Z3_Even
  521. paddd mm4, mm5 // 2's complement
  522. //     dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
  523. movq mm2, qwTmp6_Z3_Odd
  524. paddd mm7, mm0 //tmp6 + z2 + z3 EVEN
  525. paddd mm7, Const_1024 //rounding adj
  526. paddd mm2, mm4 //tmp6 + z2 + z3 ODD
  527. paddd mm2, Const_1024 //rounding adj
  528. psrad mm7, 11 // descale it |  |R2|  |R0|
  529. movq mm6, qwTemp0 //restore 
  530. psrad mm2, 11 // descale it |  |R3|  |R1|
  531. movq mm3, qwTmp5_Z4_Even
  532. movq mm5, mm7
  533. movq [edi][DATASIZE*0], mm6 //store 
  534. punpckldq mm7, mm2 //|  |R1|  |R0|
  535. movq mm1, qwTmp5_Z4_Odd
  536. punpckhdq mm5, mm2 //|  |R3|  |R2|
  537. movq mm6, qwTemp2 //restore 
  538. packssdw mm7, mm5
  539. movq mm5, Const_1024
  540. paddd mm3, mm0 //tmp5 + z2 + z4 EVEN
  541. //     dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
  542. movq [edi][DATASIZE*3], mm7 //store
  543. paddd mm1, mm4 //tmp5 + z2 + z4 ODD
  544. movq mm7, qwTemp4 //restore 
  545. paddd mm3, mm5 //rounding adj
  546. movq [edi][DATASIZE*2], mm6 //store 
  547. paddd mm1, mm5 //rounding adj
  548. movq [edi][DATASIZE*4], mm7 //store 
  549. psrad mm3, 11 // descale it |  |R2|  |R0|
  550. movq mm6, qwTemp6 //restore 
  551. psrad mm1, 11 // descale it |  |R3|  |R1|
  552. movq mm0, [edi][DATASIZE*0+16]
  553. movq mm5, mm3
  554. movq [edi][DATASIZE*6], mm6 //store 
  555. punpckldq mm3, mm1 //|  |R1|  |R0|
  556. paddw mm0, [edi][DATASIZE*7+16]
  557. punpckhdq mm5, mm1 //|  |R3|  |R2|
  558. movq mm1, [edi][DATASIZE*1+16]
  559. packssdw mm3, mm5
  560. paddw mm1, [edi][DATASIZE*6+16]
  561. movq mm7, mm0
  562. movq [edi][DATASIZE*5], mm3 //store
  563. movq mm6, mm1
  564. //******************************************************************************
  565. // This completes 4x8 dct locations.  Copy to do other 4x8.
  566. //******************************************************************************
  567. // tmp0 = dataptr[DATASIZE*0] + dataptr[DATASIZE*7];
  568. movq mm3, [edi][DATASIZE*3+16]
  569. paddw mm3, [edi][DATASIZE*4+16]
  570. movq mm2, [edi][DATASIZE*2+16]
  571. paddw mm0, mm3 //tmp10
  572. paddw mm2, [edi][DATASIZE*5+16]
  573. psubw mm7, mm3 //tmp13
  574. // tmp10 = tmp0 + tmp3;
  575. paddw mm1, mm2 //tmp11
  576. psubw mm6, mm2 //tmp12
  577. //    dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);
  578. //    dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
  579. movq mm3, mm0
  580. paddw mm0, mm1 //tmp10 + tmp11
  581. psubw mm3, mm1 //tmp10 - tmp11
  582. psllw mm0, 2 // descale it
  583.   movq mm1, mm6 //copy tmp12
  584. psllw mm3, 2 // descale it
  585. // z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
  586. movq qwTemp0, mm0 //store 
  587. paddw mm1, mm7 //tmp12 + tmp13
  588. //;;;  movq [edi][DATASIZE*6+16], mm4  ; store w6---3,5,6,7
  589. movq mm2, mm1 //copy
  590. // dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
  591. //    CONST_BITS-PASS1_BITS);
  592. // dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
  593. //    CONST_BITS-PASS1_BITS);
  594. pmaddwd mm1, Const_0xFIX_0_541196100 //| z12 | z10 |
  595. movq mm4, mm7
  596. pmaddwd mm7, Const_0xFIX_0_765366865 //| r2 | r0 |
  597. movq mm0, mm6
  598. pmaddwd mm2, Const_FIX_0_541196100x0 //| z13 | z11 |
  599. pmaddwd mm4, Const_FIX_0_765366865x0 //| r3 | r1 |
  600. pmaddwd mm6, Const_0xFIX_1_847759065 //| r2 | r0 |
  601. paddd mm7, mm1 // add z1
  602. pmaddwd mm0, Const_FIX_1_847759065x0 //| r3 | r1 |
  603. paddd mm7, Const_1024
  604. paddd mm4, mm2
  605. paddd mm4, Const_1024
  606. psrad mm7, 11 // descale it |  |R2|  |R0|
  607. //!!!!!! Negate the results in mm6 and mm0
  608. pxor mm6, Const_FFFF //invert result
  609. psrad mm4, 11 // descale it |  |R3|  |R1|
  610. paddd mm6, Const_1 // 2's complement
  611. movq mm5, mm7
  612. pxor mm0, Const_FFFF //invert result
  613. punpckldq mm7, mm4 //|  |R1|  |R0|
  614. paddd mm0, Const_1 // 2's complement
  615. punpckhdq mm5, mm4 //|  |R3|  |R2|
  616. movq qwTemp4, mm3 //store
  617. packssdw mm7, mm5
  618. movq mm5, Const_1024
  619. paddd mm6, mm1 // add z1
  620. movq qwTemp2, mm7 //store
  621. paddd mm0, mm2
  622. movq mm4, [edi][DATASIZE*3+16]
  623. paddd mm6, mm5
  624. psubw mm4, [edi][DATASIZE*4+16]
  625. psrad mm6, 11 // descale it |  |R2|  |R0|
  626. paddd mm0, mm5
  627. movq mm5, mm6
  628. movq mm7, [edi][DATASIZE*0+16]
  629. psrad mm0, 11 // descale it |  |R3|  |R1|
  630. psubw mm7, [edi][DATASIZE*7+16]
  631. punpckldq mm6, mm0 //|  |R1|  |R0|
  632. punpckhdq mm5, mm0 //|  |R3|  |R2|
  633. movq mm0, mm4
  634. packssdw mm6, mm5
  635. movq mm2, mm4
  636. // tmp4 = dataptr[3] - dataptr[4];
  637. movq mm5, [edi][DATASIZE*2+16]
  638. paddw mm0, mm7 //z1
  639. psubw mm5, [edi][DATASIZE*5+16]
  640. movq qwTemp6, mm6 //store
  641. movq mm1, mm5
  642. movq mm6, [edi][DATASIZE*1+16]
  643. movq mm3, mm5
  644. // z1 = tmp4 + tmp7;
  645. psubw mm6, [edi][DATASIZE*6+16]
  646. paddw mm3, mm7 //z4
  647. movq qwScratch7, mm7
  648. paddw mm2, mm6 //z3
  649. movq qwScratch5, mm5
  650. paddw mm1, mm6 //z2
  651. //     z3 = MULTIPLY(z3, - FIX_1_961570560);
  652. //     z4 = MULTIPLY(z4, - FIX_0_390180644);
  653. //     z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
  654. movq qwZ1, mm0 //store
  655. movq mm5, mm2
  656. movq qwZ2, mm1
  657. movq mm7, mm2
  658. movq mm0, Const_FFFF
  659. paddw mm2, mm3 //z3 + z4
  660. pmaddwd mm5, Const_0xFIX_1_961570560 //z32, z30
  661. movq mm1, mm3
  662. pmaddwd mm7, Const_FIX_1_961570560x0 //z33, z31
  663. movq qwScratch6, mm6
  664. movq mm6, mm2
  665. //     z3 += z5//
  666. //!!!!!! Negate the results
  667. pmaddwd mm2, Const_0xFIX_1_175875602 //z52, z50
  668. pxor mm5, mm0 //invert result
  669. paddd mm5, Const_1 // 2's complement
  670. pxor mm7, mm0 //invert result
  671. pmaddwd mm3, Const_0xFIX_0_390180644 //z42, z40
  672. pmaddwd mm1, Const_FIX_0_390180644x0 //z43, z41
  673. paddd mm5, mm2 //z3_even
  674. paddd mm7, Const_1 // 2's complement
  675. pmaddwd mm6, Const_FIX_1_175875602x0 //z53, z51
  676. pxor mm3, mm0 //invert result
  677. //     z4 += z5;
  678. //!!!!!! Negate the results
  679. paddd mm3, Const_1 // 2's complement
  680. pxor mm1, mm0 //invert result
  681. paddd mm1, Const_1 // 2's complement
  682. paddd mm3, mm2
  683. movq mm0, qwScratch6
  684. movq mm2, mm4
  685. //     tmp4 = MULTIPLY(tmp4, FIX_0_298631336);
  686. pmaddwd mm4, Const_0xFIX_0_298631336 //T42, T40
  687. paddd mm7, mm6 //z3_odd
  688. pmaddwd mm2, Const_FIX_0_298631336x0 //T43, T41
  689. paddd mm1, mm6
  690. movq mm6, mm0
  691. paddd mm4, mm5
  692. //     tmp6 = MULTIPLY(tmp6, FIX_3_072711026);
  693. pmaddwd mm6, Const_0xFIX_3_072711026 //T62, T60
  694. paddd mm2, mm7
  695. pmaddwd mm0, Const_FIX_3_072711026x0 //T63, T61
  696. movq qwTmp4_Z3_Odd, mm2
  697. movq qwTmp4_Z3_Even, mm4
  698. paddd mm6, mm5
  699. movq mm5, qwScratch5
  700. paddd mm0, mm7
  701. movq mm7, qwScratch7
  702. movq mm2, mm5
  703. movq qwTmp6_Z3_Even, mm6
  704. movq mm6, mm7
  705. //     tmp5 = MULTIPLY(tmp5, FIX_2_053119869);
  706. //     tmp7 = MULTIPLY(tmp7, FIX_1_501321110);
  707. pmaddwd mm5, Const_0xFIX_2_053119869 //T52, T50
  708. pmaddwd mm2, Const_FIX_2_053119869x0 //T53, T51
  709. pmaddwd mm7, Const_0xFIX_1_501321110 //T72, T70
  710. pmaddwd mm6, Const_FIX_1_501321110x0 //T73, T71
  711. paddd mm5, mm3
  712. movq qwTmp6_Z3_Odd, mm0
  713. paddd mm2, mm1
  714. movq qwTmp5_Z4_Even, mm5
  715. paddd mm7, mm3
  716. movq mm0, qwZ1
  717. paddd mm6, mm1
  718. //     z1 = MULTIPLY(z1, - FIX_0_899976223);
  719. movq mm1, Const_FFFF
  720. movq mm4, mm0
  721. //!!!!!! Negate the results
  722. pmaddwd mm0, Const_0xFIX_0_899976223 //z12, z10
  723. pmaddwd mm4, Const_FIX_0_899976223x0 //z13, z11
  724. movq mm3, qwTmp4_Z3_Even
  725. movq qwTmp5_Z4_Odd, mm2
  726. pxor mm0, mm1 //invert result
  727. movq mm2, qwTmp4_Z3_Odd
  728. pxor mm4, mm1 //invert result
  729. paddd mm4, Const_1 // 2's complement
  730. paddd mm7, mm0 //tmp7 + z1 + z4 EVEN
  731. paddd mm0, Const_1 // 2's complement
  732. paddd mm6, mm4 //tmp7 + z1 + z4 ODD
  733. //     dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
  734. paddd mm7, Const_1024 //rounding adj
  735. paddd mm3, mm0 //tmp4 + z1 + z3 EVEN
  736. paddd mm6, Const_1024 //rounding adj
  737. psrad mm7, 11 // descale it |  |R2|  |R0|
  738. psrad mm6, 11 // descale it |  |R3|  |R1|
  739. movq mm5, mm7
  740. punpckldq mm7, mm6 //|  |R1|  |R0|
  741. //     dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
  742. punpckhdq mm5, mm6 //|  |R3|  |R2|
  743. paddd mm2, mm4 //tmp4 + z1 + z3 ODD
  744. paddd mm3, Const_1024 //rounding adj
  745. packssdw mm7, mm5
  746. paddd mm2, Const_1024 //rounding adj
  747. psrad mm3, 11 // descale it |  |R2|  |R0|
  748. movq mm0, qwZ2
  749. psrad mm2, 11 // descale it |  |R3|  |R1|
  750. movq mm5, mm3
  751. movq mm4, mm0
  752. //     z2 = MULTIPLY(z2, - FIX_2_562915447);
  753. pmaddwd mm0, Const_0xFIX_2_562915447 //z22, z20
  754. punpckldq mm3, mm2 //|  |R1|  |R0|
  755. pmaddwd mm4, Const_FIX_2_562915447x0 //z23, z21
  756. punpckhdq mm5, mm2 //|  |R3|  |R2|
  757. movq mm2, Const_FFFF
  758. packssdw mm3, mm5
  759. movq [edi][DATASIZE*1+16], mm7 //store
  760. //!!!!!! Negate the results
  761. pxor mm0, mm2 //invert result
  762. movq mm5, Const_1
  763. pxor mm4, mm2 //invert result
  764. movq [edi][DATASIZE*7+16], mm3 //store
  765. paddd mm0, mm5 // 2's complement
  766. movq mm7, qwTmp6_Z3_Even
  767. paddd mm4, mm5 // 2's complement
  768. //     dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
  769. movq mm2, qwTmp6_Z3_Odd
  770. paddd mm7, mm0 //tmp6 + z2 + z3 EVEN
  771. paddd mm7, Const_1024 //rounding adj
  772. paddd mm2, mm4 //tmp6 + z2 + z3 ODD
  773. paddd mm2, Const_1024 //rounding adj
  774. psrad mm7, 11 // descale it |  |R2|  |R0|
  775. movq mm6, qwTemp0 //restore 
  776. psrad mm2, 11 // descale it |  |R3|  |R1|
  777. movq mm5, mm7
  778. movq [edi][DATASIZE*0+16], mm6 //store 
  779. punpckldq mm7, mm2 //|  |R1|  |R0|
  780. movq mm3, qwTmp5_Z4_Even
  781. punpckhdq mm5, mm2 //|  |R3|  |R2|
  782. movq mm1, qwTmp5_Z4_Odd
  783. packssdw mm7, mm5
  784. movq mm6, qwTemp2 //restore 
  785. paddd mm3, mm0 //tmp5 + z2 + z4 EVEN
  786. //     dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
  787. movq mm0, Const_1024
  788. paddd mm1, mm4 //tmp5 + z2 + z4 ODD
  789. movq [edi][DATASIZE*3+16], mm7 //store
  790. paddd mm3, mm0 //rounding adj
  791. movq mm7, qwTemp4 //restore 
  792. paddd mm1, mm0 //rounding adj
  793. movq [edi][DATASIZE*2+16], mm6 //store 
  794. psrad mm3, 11 // descale it |  |R2|  |R0|
  795. movq mm6, qwTemp6 //restore 
  796. psrad mm1, 11 // descale it |  |R3|  |R1|
  797. movq [edi][DATASIZE*4+16], mm7 //store 
  798. movq mm5, mm3
  799. movq [edi][DATASIZE*6+16], mm6 //store 
  800. punpckldq mm3, mm1 //|  |R1|  |R0|
  801. punpckhdq mm5, mm1 //|  |R3|  |R2|
  802. movq mm0, mm7 // copy w4---0,1,3,5,6
  803. movq mm1, [edi][DATASIZE*7+16]
  804. packssdw mm3, mm5
  805. movq [edi][DATASIZE*5+16], mm3 //store
  806. punpcklwd mm7, mm3 //mm6 = w5
  807. //******************************************************************************
  808. //******************************************************************************
  809. // This completes all 8x8 dct locations for the row case.
  810. // Now transpose the data for the columns.
  811. //******************************************************************************
  812. // transpose the bottom right quadrant(4X4) of the matrix
  813. //  ---------       ---------
  814. // | M1 | M2 |     | M1'| M3'|
  815. //  ---------  -->  ---------
  816. // | M3 | M4 |     | M2'| M4'|
  817. //  ---------       ---------
  818. movq mm4, mm7 //---0,2,3,4,5,6,7
  819. punpckhwd mm0, mm3 //---0,1,3,5,6 
  820. movq mm2, mm6 //---0,1,2,3,5,6 w6
  821. punpcklwd mm6, mm1 //mm1 = w7
  822. // tmp0 = dataptr[DATASIZE*0] + dataptr[DATASIZE*7]//
  823. movq mm5, [edi][DATASIZE*5]
  824. punpckldq mm7, mm6 // transposed w4
  825. punpckhdq mm4, mm6 // transposed w5---0,2,4,6,7
  826. movq mm6, mm0 //---0,2,3,4,6,7
  827. movq [edi][DATASIZE*4+16], mm7  // store w4
  828. punpckhwd mm2, mm1 //---0,2,3,5,6,7
  829. movq [edi][DATASIZE*5+16], mm4  // store w5
  830. punpckldq mm0, mm2 // transposed w6
  831. movq mm7, [edi][DATASIZE*4]
  832. punpckhdq mm6, mm2 // transposed w7---0,3,6,7
  833. movq [edi][DATASIZE*6+16], mm0  // store w6---3,5,6,7
  834. movq mm0, mm7 // copy w0---0,1,3,5,6
  835. movq [edi][DATASIZE*7+16], mm6  // store w7---5,6,7
  836. punpcklwd mm7, mm5 //mm6 = w1
  837. // transpose the bottom left quadrant(4X4) of the matrix and place
  838. // in the top right quadrant while doing the same for the top
  839. // right quadrant
  840. //  ---------       ---------
  841. // | M1 | M2 |     | M1'| M3'|
  842. //  ---------  -->  ---------
  843. // | M3 | M4 |     | M2'| M4'|
  844. //  ---------       ---------
  845. movq mm3, [edi][DATASIZE*6]
  846. punpckhwd mm0, mm5 //---0,1,3,5,6 
  847. movq mm1, [edi][DATASIZE*7]
  848. movq mm2, mm3 //---0,1,2,3,5,6 w2
  849. movq mm6, [edi][DATASIZE*0+16]
  850. punpcklwd mm3, mm1 //mm1 = w3
  851. movq mm5, [edi][DATASIZE*1+16]
  852. punpckhwd mm2, mm1 //---0,2,3,5,6,7
  853. movq mm4, mm7 //---0,2,3,4,5,6,7
  854. punpckldq mm7, mm3 // transposed w4
  855. punpckhdq mm4, mm3 // transposed w5---0,2,4,6,7
  856. movq mm3, mm0 //---0,2,3,4,6,7
  857. movq [edi][DATASIZE*0+16], mm7  // store w4
  858. punpckldq mm0, mm2 // transposed w6
  859. movq mm1, [edi][DATASIZE*2+16]
  860. punpckhdq mm3, mm2 // transposed w7---0,3,6,7
  861. movq [edi][DATASIZE*2+16], mm0  // store w6---3,5,6,7
  862. movq mm0, mm6 // copy w4---0,1,3,5,6
  863. movq mm7, [edi][DATASIZE*3+16]
  864. punpcklwd mm6, mm5 //mm6 = w5
  865. movq [edi][DATASIZE*1+16], mm4  // store w5
  866. punpckhwd mm0, mm5 //---0,1,3,5,6 
  867. // transpose the top right quadrant(4X4) of the matrix
  868. //  ---------       ---------
  869. // | M1 | M2 |     | M1'| M3'|
  870. //  ---------  -->  ---------
  871. // | M3 | M4 |     | M2'| M4'|
  872. //  ---------       ---------
  873. movq mm2, mm1 //---0,1,2,3,5,6 w6
  874. punpcklwd mm1, mm7 //mm1 = w7
  875. movq mm4, mm6 //---0,2,3,4,5,6,7
  876. punpckldq mm6, mm1 // transposed w4
  877. movq [edi][DATASIZE*3+16], mm3  // store w7---5,6,7
  878. punpckhdq mm4, mm1 // transposed w5---0,2,4,6,7
  879. movq [edi][DATASIZE*4], mm6  // store w4
  880. punpckhwd mm2, mm7 //---0,2,3,5,6,7
  881. movq mm7, [edi][DATASIZE*0]
  882. movq mm1, mm0 //---0,2,3,4,6,7
  883. movq mm3, [edi][DATASIZE*1]
  884. punpckldq mm0, mm2 // transposed w6
  885. movq [edi][DATASIZE*5], mm4  // store w5
  886. punpckhdq mm1, mm2 // transposed w7---0,3,6,7
  887. movq [edi][DATASIZE*6], mm0  // store w6---3,5,6,7
  888. movq mm2, mm7 // copy w0---0,1,3,5,6
  889. movq mm4, [edi][DATASIZE*3]
  890. punpcklwd mm7, mm3 //mm6 = w1
  891. // transpose the top left quadrant(4X4) of the matrix
  892. //  ---------       ---------
  893. // | M1 | M2 |     | M1'| M3'|
  894. //  ---------  -->  ---------
  895. // | M3 | M4 |     | M2'| M4'|
  896. //  ---------       ---------
  897. movq mm6, [edi][DATASIZE*2]
  898. punpckhwd mm2, mm3 //---0,1,3,5,6 
  899. movq mm0, mm6 //---0,1,2,3,5,6 w2
  900. punpcklwd mm6, mm4 //mm1 = w3
  901. movq [edi][DATASIZE*7], mm1  // store w7---5,6,7
  902. punpckhwd mm0, mm4 //---0,2,3,5,6,7
  903. movq mm1, mm7 //---0,2,3,4,5,6,7
  904. punpckldq mm7, mm6 // transposed w4
  905. punpckhdq mm1, mm6 // transposed w5---0,2,4,6,7
  906. movq mm6, mm2 //---0,2,3,4,6,7
  907.   movq [edi][DATASIZE*0], mm7  // store w4
  908. punpckldq mm2, mm0 // transposed w6
  909. paddw mm7, [edi][DATASIZE*7]
  910. punpckhdq mm6, mm0 // transposed w7---0,3,6,7
  911. movq [edi][DATASIZE*3], mm6  // store w7---5,6,7
  912. movq mm4, mm7
  913. paddw mm6, [edi][DATASIZE*4]
  914. movq [edi][DATASIZE*1], mm1  // store w5
  915. paddw mm7, mm6 //tmp10
  916. //******************************************************************************
  917. // This begins the column dct
  918. //******************************************************************************
  919. paddw mm1, [edi][DATASIZE*6]
  920. psubw mm4, mm6 //tmp13
  921. movq [edi][DATASIZE*2], mm2  // store w6---3,5,6,7
  922. movq mm6, mm1
  923. paddw mm2, [edi][DATASIZE*5]
  924. movq mm3, mm7
  925. paddw mm1, mm2 //tmp11
  926. psubw mm6, mm2 //tmp12
  927. //    dataptr[DATASIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
  928. //    dataptr[DATASIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
  929. paddw mm7, mm1 //tmp10 + tmp11
  930. paddw mm7, Const_2 // round  add 2 to each element
  931. psubw mm3, mm1 //tmp10 - tmp11
  932. paddw mm3, Const_2 // round  add 2 to each element
  933. psraw mm7, 2 // descale it
  934. // unpack word to dword sign extended
  935. movq mm5, mm7
  936. punpcklwd mm7, mm7
  937. psrad mm7, 16 // even results store in Temp0
  938. punpckhwd mm5, mm5
  939. psrad mm5, 16 // odd results store in array
  940. movq mm1, mm6 //copy tmp12
  941. movq qwTemp0, mm7 //store 
  942. psraw mm3, 2 // descale it
  943. movq [edi][DATASIZE*0+8], mm5
  944. movq mm5, mm3
  945. punpcklwd mm3, mm3
  946. paddw mm1, mm4 //tmp12 + tmp13
  947. psrad mm3, 16 // even results store in Temp4
  948. movq mm2, mm1 //copy
  949. // z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
  950. pmaddwd mm1, Const_0xFIX_0_541196100 //| z12 | z10 |
  951. punpckhwd mm5, mm5
  952. pmaddwd mm2, Const_FIX_0_541196100x0 //| z13 | z11 |
  953. movq mm7, mm4
  954. // dataptr[DATASIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
  955. //    CONST_BITS+PASS1_BITS);
  956. pmaddwd mm4, Const_FIX_0_765366865x0 //| r3 | r1 |
  957. psrad mm5, 16 // odd results store in array
  958. pmaddwd mm7, Const_0xFIX_0_765366865 //| r2 | r0 |
  959. movq mm0, mm6
  960. // dataptr[DATASIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
  961. //    CONST_BITS+PASS1_BITS);
  962. pmaddwd mm6, Const_0xFIX_1_847759065 //| r2 | r0 |
  963. movq qwTemp4, mm3 //store
  964. paddd mm4, mm2
  965. paddd mm4, Const_16384
  966. paddd mm7, mm1 // add z1
  967. paddd mm7, Const_16384
  968. psrad mm4, 15 // descale it |  |R3|  |R1|
  969. movq [edi][DATASIZE*4+8], mm5
  970. psrad mm7, 15 // descale it |  |R2|  |R0|
  971. pmaddwd mm0, Const_FIX_1_847759065x0 //| r3 | r1 |
  972. movq mm5, mm7
  973. //!!!!!! Negate result
  974. movq mm3, Const_1
  975. punpckldq mm7, mm4 //|  |R1|  |R0|
  976. pxor mm6, Const_FFFF //invert result
  977. punpckhdq mm5, mm4 //|  |R3|  |R2|
  978. movq qwTemp2, mm7 //store
  979. paddd mm6, mm3 // 2's complement
  980. pxor mm0, Const_FFFF //invert result
  981. paddd mm6, mm1 // add z1
  982. movq [edi][DATASIZE*2+8], mm5 //write out 2nd half in unused memory
  983. paddd mm0, mm3 // 2's complement
  984. movq mm3, Const_16384
  985. paddd mm0, mm2
  986. movq mm7, [edi][DATASIZE*0]
  987. paddd mm6, mm3
  988. movq mm4, [edi][DATASIZE*3]
  989. paddd mm0, mm3
  990. psubw mm7, [edi][DATASIZE*7]
  991. psrad mm6, 15 // descale it |  |R2|  |R0|
  992. psubw mm4, [edi][DATASIZE*4]
  993. psrad mm0, 15 // descale it |  |R3|  |R1|
  994. movq mm3, [edi][DATASIZE*2]
  995. movq mm5, mm6
  996. psubw mm3, [edi][DATASIZE*5]
  997. punpckldq mm6, mm0 //|  |R1|  |R0|
  998. punpckhdq mm5, mm0 //|  |R3|  |R2|
  999. movq mm0, mm4
  1000. movq qwTemp6, mm6 //store
  1001. movq mm2, mm4
  1002. // tmp4 = dataptr[3] - dataptr[4];
  1003. // z1 = tmp4 + tmp7;
  1004. movq mm6, [edi][DATASIZE*1]
  1005. paddw mm0, mm7 //z1
  1006. movq [edi][DATASIZE*6+8], mm5 //write out 2nd half in unused memory
  1007. movq mm1, mm3
  1008. psubw mm6, [edi][DATASIZE*6]
  1009. movq mm5, mm3
  1010. movq qwZ1, mm0 //store
  1011. paddw mm5, mm7 //z4
  1012. movq qwScratch7, mm7
  1013. paddw mm1, mm6 //z2
  1014. movq qwScratch5, mm3
  1015. paddw mm2, mm6 //z3
  1016. movq qwZ2, mm1
  1017. movq mm3, mm2
  1018. //     z3 = MULTIPLY(z3, - FIX_1_961570560);
  1019. //     z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
  1020. //     z4 = MULTIPLY(z4, - FIX_0_390180644);
  1021. movq qwScratch6, mm6
  1022. movq mm1, mm2
  1023. pmaddwd mm3, Const_0xFIX_1_961570560 //z32, z30
  1024. movq mm7, mm5
  1025. movq mm6, Const_FFFF
  1026. paddw mm2, mm5 //z3 + z4
  1027. pmaddwd mm1, Const_FIX_1_961570560x0 //z33, z31
  1028. movq mm0, mm2
  1029. pmaddwd mm7, Const_FIX_0_390180644x0 //z43, z41
  1030. //!!!!!! Negate the results
  1031. pxor mm3, mm6 //invert result
  1032. pmaddwd mm5, Const_0xFIX_0_390180644 //z42, z40
  1033. pmaddwd mm2, Const_0xFIX_1_175875602 //z52, z50
  1034.   pxor mm1, mm6 //invert result
  1035. pmaddwd mm0, Const_FIX_1_175875602x0 //z53, z51
  1036. //!!!!!! Negate the results
  1037. pxor mm7, mm6 //invert result
  1038. paddd mm3, Const_1 // 2's complement
  1039. pxor mm5, mm6 //invert result
  1040. //     z3 += z5//
  1041. paddd mm1, Const_1 // 2's complement
  1042. paddd mm3, mm2 //z3_even
  1043. paddd mm5, Const_1 // 2's complement
  1044. paddd mm1, mm0 //z3_odd
  1045. //     z4 += z5;
  1046. paddd mm7, Const_1 // 2's complement
  1047. paddd mm5, mm2
  1048. paddd mm7, mm0
  1049. movq mm2, mm4
  1050. //     tmp4 = MULTIPLY(tmp4, FIX_0_298631336);
  1051. pmaddwd mm4, Const_0xFIX_0_298631336 //T42, T40
  1052. pmaddwd mm2, Const_FIX_0_298631336x0 //T43, T41
  1053. movq qwZ4_even, mm5
  1054. movq qwZ4_odd, mm7
  1055. paddd mm4, mm3
  1056. movq mm6, qwScratch6
  1057. paddd mm2, mm1
  1058. movq qwTmp4_Z3_Even, mm4
  1059. movq mm5, mm6
  1060. //     tmp6 = MULTIPLY(tmp6, FIX_3_072711026);
  1061. pmaddwd mm6, Const_0xFIX_3_072711026 //T62, T60
  1062. pmaddwd mm5, Const_FIX_3_072711026x0 //T63, T61
  1063. movq qwTmp4_Z3_Odd, mm2
  1064. movq mm4, qwZ4_even
  1065. paddd mm6, mm3
  1066. movq mm3, qwScratch5
  1067. paddd mm5, mm1
  1068. movq qwTmp6_Z3_Even, mm6
  1069. movq mm2, mm3
  1070. //     tmp5 = MULTIPLY(tmp5, FIX_2_053119869);
  1071. pmaddwd mm3, Const_0xFIX_2_053119869 //T52, T50
  1072. pmaddwd mm2, Const_FIX_2_053119869x0 //T53, T51
  1073. movq qwTmp6_Z3_Odd, mm5
  1074. movq mm0, qwZ4_odd
  1075. paddd mm3, mm4
  1076. movq mm7, qwScratch7
  1077. paddd mm2, mm0
  1078. movq qwTmp5_Z4_Even, mm3
  1079. movq mm6, mm7
  1080. //     tmp7 = MULTIPLY(tmp7, FIX_1_501321110);
  1081. pmaddwd mm7, Const_0xFIX_1_501321110 //T72, T70
  1082. pmaddwd mm6, Const_FIX_1_501321110x0 //T73, T71
  1083. movq mm3, qwZ1
  1084. movq qwTmp5_Z4_Odd, mm2
  1085. paddd mm7, mm4
  1086. movq mm5, Const_FFFF
  1087. movq mm4, mm3
  1088. //     z1 = MULTIPLY(z1, - FIX_0_899976223);
  1089. pmaddwd mm3, Const_0xFIX_0_899976223 //z12, z10
  1090.   paddd mm6, mm0
  1091. pmaddwd mm4, Const_FIX_0_899976223x0 //z13, z11
  1092. movq mm2, qwTmp4_Z3_Odd
  1093. //!!!!!! Negate the results
  1094. pxor mm3, mm5 //invert result
  1095. paddd mm3, Const_1 // 2's complement
  1096. pxor mm4, mm5 //invert result
  1097. paddd mm4, Const_1 // 2's complement
  1098. paddd mm7, mm3 //tmp7 + z1 + z4 EVEN
  1099. //     dataptr[DATASIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,
  1100. //    CONST_BITS+PASS1_BITS);
  1101. paddd mm7, Const_16384 //rounding adj
  1102. paddd mm6, mm4 //tmp7 + z1 + z4 ODD
  1103. paddd mm6, Const_16384 //rounding adj
  1104. psrad mm7, 15 // descale it |  |R2|  |R0|
  1105. movq mm0, qwTmp4_Z3_Even
  1106. psrad mm6, 15 // descale it |  |R3|  |R1|
  1107. paddd mm0, mm3 //tmp4 + z1 + z3 EVEN
  1108. movq mm5, mm7
  1109. movq mm3, qwTemp0 //restore 
  1110. punpckldq mm7, mm6 //|  |R1|  |R0|
  1111. paddd mm0, Const_16384 //rounding adj
  1112. paddd mm2, mm4 //tmp4 + z1 + z3 ODD
  1113. movq [edi][DATASIZE*0], mm3 //store 
  1114. punpckhdq mm5, mm6 //|  |R3|  |R2|
  1115. //     dataptr[DATASIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,
  1116. //    CONST_BITS+PASS1_BITS);
  1117. paddd mm2, Const_16384 //rounding adj
  1118. psrad mm0, 15 // descale it |  |R2|  |R0|
  1119. movq mm6, qwZ2
  1120. psrad mm2, 15 // descale it |  |R3|  |R1|
  1121. movq [edi][DATASIZE*1+8], mm5 //store
  1122. movq mm4, mm6
  1123. //     z2 = MULTIPLY(z2, - FIX_2_562915447);
  1124. pmaddwd mm6, Const_0xFIX_2_562915447 //z22, z20
  1125. movq mm5, mm0
  1126. pmaddwd mm4, Const_FIX_2_562915447x0 //z23, z21
  1127. punpckldq mm0, mm2 //|  |R1|  |R0|
  1128. movq mm3, Const_FFFF
  1129. punpckhdq mm5, mm2 //|  |R3|  |R2|
  1130. movq [edi][DATASIZE*1], mm7 //store
  1131. //!!!!!! Negate the results
  1132. pxor mm6, mm3 //invert result
  1133. movq mm1, Const_1
  1134. pxor mm4, mm3 //invert result
  1135. movq mm7, qwTmp6_Z3_Even
  1136. paddd mm6, mm1 // 2's complement
  1137. movq mm2, qwTmp6_Z3_Odd
  1138. paddd mm4, mm1 // 2's complement
  1139. //     dataptr[DATASIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,
  1140. //    CONST_BITS+PASS1_BITS);
  1141. movq [edi][DATASIZE*7], mm0 //store
  1142. paddd mm7, mm6 //tmp6 + z2 + z3 EVEN
  1143. movq mm1, Const_16384
  1144. paddd mm2, mm4 //tmp6 + z2 + z3 ODD
  1145. movq mm3, qwTemp2 //restore 
  1146. paddd mm7, mm1 //rounding adj
  1147. movq [edi][DATASIZE*7+8], mm5 //store
  1148. paddd mm2, mm1 //rounding adj
  1149. movq [edi][DATASIZE*2], mm3 //store 
  1150. psrad mm7, 15 // descale it |  |R2|  |R0|
  1151.   movq mm0, qwTemp4 //restore 
  1152. psrad mm2, 15 // descale it |  |R3|  |R1|
  1153. movq mm3, qwTmp5_Z4_Even
  1154. movq mm5, mm7
  1155. movq [edi][DATASIZE*4], mm0 //store 
  1156. paddd mm3, mm6 //tmp5 + z2 + z4 EVEN
  1157. movq mm6, qwTmp5_Z4_Odd
  1158. punpckldq mm7, mm2 //|  |R1|  |R0|
  1159. punpckhdq mm5, mm2 //|  |R3|  |R2|
  1160. paddd mm6, mm4 //tmp5 + z2 + z4 ODD
  1161. movq [edi][DATASIZE*3], mm7 //store
  1162. paddd mm3, mm1 //rounding adj
  1163. //     dataptr[DATASIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,
  1164. //    CONST_BITS+PASS1_BITS);
  1165. movq mm0, qwTemp6 //restore 
  1166. paddd mm6, mm1 //rounding adj
  1167. movq [edi][DATASIZE*3+8], mm5 //store
  1168. psrad mm3, 15 // descale it |  |R2|  |R0|
  1169. movq [edi][DATASIZE*6], mm0 //store 
  1170. psrad mm6, 15 // descale it |  |R3|  |R1|
  1171. movq mm7, [edi][DATASIZE*0+16]
  1172. movq mm5, mm3
  1173. paddw mm7, [edi][DATASIZE*7+16]
  1174. punpckldq mm3, mm6 //|  |R1|  |R0|
  1175. movq mm1, [edi][DATASIZE*1+16]
  1176. punpckhdq mm5, mm6 //|  |R3|  |R2|
  1177. paddw mm1, [edi][DATASIZE*6+16]
  1178. movq mm4, mm7
  1179. //******************************************************************************
  1180. // This completes 4x8 dct locations.  Copy to do other 4x8.
  1181. //******************************************************************************
  1182. movq mm6, [edi][DATASIZE*3+16]
  1183. paddw mm6, [edi][DATASIZE*4+16]
  1184. movq mm2, [edi][DATASIZE*2+16]
  1185. psubw mm4, mm6 //tmp13
  1186. paddw mm2, [edi][DATASIZE*5+16]
  1187. paddw mm7, mm6 //tmp10
  1188. movq [edi][DATASIZE*5], mm3 //store
  1189. movq mm6, mm1
  1190.   movq [edi][DATASIZE*5+8], mm5 //store
  1191. paddw mm1, mm2 //tmp11
  1192. psubw mm6, mm2 //tmp12
  1193. movq mm3, mm7
  1194. //    dataptr[DATASIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
  1195. //    dataptr[DATASIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
  1196. paddw mm7, mm1 //tmp10 + tmp11
  1197. paddw mm7, Const_2 // round  add 2 to each element
  1198. psubw mm3, mm1 //tmp10 - tmp11
  1199. paddw mm3, Const_2 // round  add 2 to each element
  1200. psraw mm7, 2 // descale it
  1201. // unpack word to dword sign extended
  1202. movq mm5, mm7
  1203. punpcklwd mm7, mm7
  1204. psrad mm7, 16 // even results store in Temp0
  1205. punpckhwd mm5, mm5
  1206. psrad mm5, 16 // odd results store in array
  1207. movq mm1, mm6 //copy tmp12
  1208. movq qwTemp0, mm7 //store 
  1209. psraw mm3, 2 // descale it
  1210. movq [edi][DATASIZE*0+24], mm5
  1211. movq mm5, mm3
  1212. punpcklwd mm3, mm3
  1213. paddw mm1, mm4 //tmp12 + tmp13
  1214. psrad mm3, 16 // even results store in Temp4
  1215. movq mm2, mm1 //copy
  1216. // z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
  1217. pmaddwd mm1, Const_0xFIX_0_541196100 //| z12 | z10 |
  1218. punpckhwd mm5, mm5
  1219. pmaddwd mm2, Const_FIX_0_541196100x0 //| z13 | z11 |
  1220. movq mm7, mm4
  1221. // dataptr[DATASIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
  1222. //    CONST_BITS+PASS1_BITS);
  1223. pmaddwd mm4, Const_FIX_0_765366865x0 //| r3 | r1 |
  1224. psrad mm5, 16 // odd results store in array
  1225. pmaddwd mm7, Const_0xFIX_0_765366865 //| r2 | r0 |
  1226. movq mm0, mm6
  1227. // dataptr[DATASIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
  1228. //    CONST_BITS+PASS1_BITS);
  1229. pmaddwd mm6, Const_0xFIX_1_847759065 //| r2 | r0 |
  1230. movq qwTemp4, mm3 //store
  1231. paddd mm4, mm2
  1232. paddd mm4, Const_16384
  1233. paddd mm7, mm1 // add z1
  1234. paddd mm7, Const_16384
  1235. psrad mm4, 15 // descale it |  |R3|  |R1|
  1236. movq [edi][DATASIZE*4+24], mm5
  1237. psrad mm7, 15 // descale it |  |R2|  |R0|
  1238. pmaddwd mm0, Const_FIX_1_847759065x0 //| r3 | r1 |
  1239. movq mm5, mm7
  1240. //!!!!!! Negate result
  1241. movq mm3, Const_1
  1242. punpckldq mm7, mm4 //|  |R1|  |R0|
  1243. pxor mm6, Const_FFFF //invert result
  1244. punpckhdq mm5, mm4 //|  |R3|  |R2|
  1245. movq qwTemp2, mm7 //store
  1246. paddd mm6, mm3 // 2's complement
  1247. pxor mm0, Const_FFFF //invert result
  1248. paddd mm6, mm1 // add z1
  1249. movq [edi][DATASIZE*2+24], mm5 //write out 2nd half in unused memory
  1250. paddd mm0, mm3 // 2's complement
  1251. movq mm3, Const_16384
  1252. paddd mm0, mm2
  1253. movq mm7, [edi][DATASIZE*0+16]
  1254. paddd mm6, mm3
  1255. movq mm4, [edi][DATASIZE*3+16]
  1256. paddd mm0, mm3
  1257. psubw mm7, [edi][DATASIZE*7+16]
  1258. psrad mm6, 15 // descale it |  |R2|  |R0|
  1259. psubw mm4, [edi][DATASIZE*4+16]
  1260. psrad mm0, 15 // descale it |  |R3|  |R1|
  1261. movq mm3, [edi][DATASIZE*2+16]
  1262. movq mm5, mm6
  1263. psubw mm3, [edi][DATASIZE*5+16]
  1264. punpckldq mm6, mm0 //|  |R1|  |R0|
  1265. punpckhdq mm5, mm0 //|  |R3|  |R2|
  1266. movq mm0, mm4
  1267. movq qwTemp6, mm6 //store
  1268. movq mm2, mm4
  1269. // tmp4 = dataptr[3] - dataptr[4];
  1270. // z1 = tmp4 + tmp7;
  1271. movq mm6, [edi][DATASIZE*1+16]
  1272. paddw mm0, mm7 //z1
  1273. movq [edi][DATASIZE*6+24], mm5 //write out 2nd half in unused memory
  1274. movq mm1, mm3
  1275. psubw mm6, [edi][DATASIZE*6+16]
  1276. movq mm5, mm3
  1277. movq qwZ1, mm0 //store
  1278. paddw mm5, mm7 //z4
  1279. movq qwScratch7, mm7
  1280. paddw mm1, mm6 //z2
  1281. movq qwScratch5, mm3
  1282. paddw mm2, mm6 //z3
  1283. movq qwZ2, mm1
  1284. movq mm3, mm2
  1285. //     z3 = MULTIPLY(z3, - FIX_1_961570560);
  1286. //     z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
  1287. //     z4 = MULTIPLY(z4, - FIX_0_390180644);
  1288. movq qwScratch6, mm6
  1289. movq mm1, mm2
  1290. pmaddwd mm3, Const_0xFIX_1_961570560 //z32, z30
  1291. movq mm7, mm5
  1292. movq mm6, Const_FFFF
  1293. paddw mm2, mm5 //z3 + z4
  1294. pmaddwd mm1, Const_FIX_1_961570560x0 //z33, z31
  1295. movq mm0, mm2
  1296. pmaddwd mm7, Const_FIX_0_390180644x0 //z43, z41
  1297. //!!!!!! Negate the results
  1298. pxor mm3, mm6 //invert result
  1299. pmaddwd mm5, Const_0xFIX_0_390180644 //z42, z40
  1300. pmaddwd mm2, Const_0xFIX_1_175875602 //z52, z50
  1301.   pxor mm1, mm6 //invert result
  1302. pmaddwd mm0, Const_FIX_1_175875602x0 //z53, z51
  1303. //!!!!!! Negate the results
  1304. pxor mm7, mm6 //invert result
  1305. paddd mm3, Const_1 // 2's complement
  1306. pxor mm5, mm6 //invert result
  1307. //     z3 += z5;
  1308. paddd mm1, Const_1 // 2's complement
  1309. paddd mm3, mm2 //z3_even
  1310. paddd mm5, Const_1 // 2's complement
  1311. paddd mm1, mm0 //z3_odd
  1312. //     z4 += z5;
  1313. paddd mm7, Const_1 // 2's complement
  1314. paddd mm5, mm2
  1315. paddd mm7, mm0
  1316. movq mm2, mm4
  1317. //     tmp4 = MULTIPLY(tmp4, FIX_0_298631336);
  1318. pmaddwd mm4, Const_0xFIX_0_298631336 //T42, T40
  1319. pmaddwd mm2, Const_FIX_0_298631336x0 //T43, T41
  1320. movq qwZ4_even, mm5
  1321. movq qwZ4_odd, mm7
  1322. paddd mm4, mm3
  1323. movq mm6, qwScratch6
  1324. paddd mm2, mm1
  1325. movq qwTmp4_Z3_Even, mm4
  1326. movq mm5, mm6
  1327. //     tmp6 = MULTIPLY(tmp6, FIX_3_072711026);
  1328. pmaddwd mm6, Const_0xFIX_3_072711026 //T62, T60
  1329. pmaddwd mm5, Const_FIX_3_072711026x0 //T63, T61
  1330. movq qwTmp4_Z3_Odd, mm2
  1331. movq mm4, qwZ4_even
  1332. paddd mm6, mm3
  1333. movq mm3, qwScratch5
  1334. paddd mm5, mm1
  1335. movq qwTmp6_Z3_Even, mm6
  1336. movq mm2, mm3
  1337. //     tmp5 = MULTIPLY(tmp5, FIX_2_053119869);
  1338. pmaddwd mm3, Const_0xFIX_2_053119869 //T52, T50
  1339. pmaddwd mm2, Const_FIX_2_053119869x0 //T53, T51
  1340. movq qwTmp6_Z3_Odd, mm5
  1341. movq mm0, qwZ4_odd
  1342. paddd mm3, mm4
  1343. movq mm7, qwScratch7
  1344. paddd mm2, mm0
  1345. movq qwTmp5_Z4_Even, mm3
  1346. movq mm6, mm7
  1347. //     tmp7 = MULTIPLY(tmp7, FIX_1_501321110);
  1348. pmaddwd mm7, Const_0xFIX_1_501321110 //T72, T70
  1349. pmaddwd mm6, Const_FIX_1_501321110x0 //T73, T71
  1350. movq mm3, qwZ1
  1351. movq qwTmp5_Z4_Odd, mm2
  1352. paddd mm7, mm4
  1353. movq mm5, Const_FFFF
  1354. movq mm4, mm3
  1355. //     z1 = MULTIPLY(z1, - FIX_0_899976223);
  1356. pmaddwd mm3, Const_0xFIX_0_899976223 //z12, z10
  1357.   paddd mm6, mm0
  1358. pmaddwd mm4, Const_FIX_0_899976223x0 //z13, z11
  1359. movq mm2, qwTmp4_Z3_Odd
  1360. //!!!!!! Negate the results
  1361. pxor mm3, mm5 //invert result
  1362. paddd mm3, Const_1 // 2's complement
  1363. pxor mm4, mm5 //invert result
  1364. paddd mm4, Const_1 // 2's complement
  1365. paddd mm7, mm3 //tmp7 + z1 + z4 EVEN
  1366. //     dataptr[DATASIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,
  1367. //    CONST_BITS+PASS1_BITS);
  1368. paddd mm7, Const_16384 //rounding adj
  1369. paddd mm6, mm4 //tmp7 + z1 + z4 ODD
  1370. paddd mm6, Const_16384 //rounding adj
  1371. psrad mm7, 15 // descale it |  |R2|  |R0|
  1372. movq mm0, qwTmp4_Z3_Even
  1373. psrad mm6, 15 // descale it |  |R3|  |R1|
  1374. paddd mm0, mm3 //tmp4 + z1 + z3 EVEN
  1375. movq mm5, mm7
  1376. movq mm3, qwTemp0 //restore 
  1377. punpckldq mm7, mm6 //|  |R1|  |R0|
  1378. paddd mm0, Const_16384 //rounding adj
  1379. paddd mm2, mm4 //tmp4 + z1 + z3 ODD
  1380. movq [edi][DATASIZE*0+16], mm3 //store 
  1381. punpckhdq mm5, mm6 //|  |R3|  |R2|
  1382. //     dataptr[DATASIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,
  1383. //    CONST_BITS+PASS1_BITS);
  1384. paddd mm2, Const_16384 //rounding adj
  1385. psrad mm0, 15 // descale it |  |R2|  |R0|
  1386. movq mm6, qwZ2
  1387. psrad mm2, 15 // descale it |  |R3|  |R1|
  1388. movq [edi][DATASIZE*1+24], mm5 //store
  1389. movq mm4, mm6
  1390. //     z2 = MULTIPLY(z2, - FIX_2_562915447);
  1391. pmaddwd mm6, Const_0xFIX_2_562915447 //z22, z20
  1392. movq mm5, mm0
  1393. pmaddwd mm4, Const_FIX_2_562915447x0 //z23, z21
  1394. punpckldq mm0, mm2 //|  |R1|  |R0|
  1395. movq mm3, Const_FFFF
  1396. punpckhdq mm5, mm2 //|  |R3|  |R2|
  1397. movq [edi][DATASIZE*1+16], mm7 //store
  1398. //!!!!!! Negate the results
  1399. pxor mm6, mm3 //invert result
  1400. movq mm1, Const_1
  1401. pxor mm4, mm3 //invert result
  1402. movq mm7, qwTmp6_Z3_Even
  1403. paddd mm6, mm1 // 2's complement
  1404. movq mm2, qwTmp6_Z3_Odd
  1405. paddd mm4, mm1 // 2's complement
  1406. //     dataptr[DATASIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,
  1407. //    CONST_BITS+PASS1_BITS);
  1408. movq [edi][DATASIZE*7+16], mm0 //store
  1409. paddd mm7, mm6 //tmp6 + z2 + z3 EVEN
  1410. movq mm1, Const_16384
  1411. paddd mm2, mm4 //tmp6 + z2 + z3 ODD
  1412. movq mm3, qwTemp2 //restore 
  1413. paddd mm7, mm1 //rounding adj
  1414. movq [edi][DATASIZE*7+24], mm5 //store
  1415. paddd mm2, mm1 //rounding adj
  1416. movq [edi][DATASIZE*2+16], mm3 //store 
  1417. psrad mm7, 15 // descale it |  |R2|  |R0|
  1418. movq mm3, qwTmp5_Z4_Even
  1419. psrad mm2, 15 // descale it |  |R3|  |R1|
  1420. movq mm5, mm7
  1421. paddd mm3, mm6 //tmp5 + z2 + z4 EVEN
  1422. movq mm6, qwTmp5_Z4_Odd
  1423. punpckldq mm7, mm2 //|  |R1|  |R0|
  1424. punpckhdq mm5, mm2 //|  |R3|  |R2|
  1425. paddd mm6, mm4 //tmp5 + z2 + z4 ODD
  1426. movq [edi][DATASIZE*3+16], mm7 //store
  1427. paddd mm3, mm1 //rounding adj
  1428. //     dataptr[DATASIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,
  1429. //    CONST_BITS+PASS1_BITS);
  1430.   movq mm7, qwTemp4 //restore 
  1431. paddd mm6, mm1 //rounding adj
  1432. movq [edi][DATASIZE*3+24], mm5 //store
  1433. psrad mm3, 15 // descale it |  |R2|  |R0|
  1434. movq [edi][DATASIZE*4+16], mm7 //store 
  1435. psrad mm6, 15 // descale it |  |R3|  |R1|
  1436. movq mm7, qwTemp6 //restore 
  1437. movq mm5, mm3
  1438. punpckldq mm3, mm6 //|  |R1|  |R0|
  1439. movq [edi][DATASIZE*6+16], mm7 //store 
  1440. punpckhdq mm5, mm6 //|  |R3|  |R2|
  1441. movq [edi][DATASIZE*5+16], mm3 //store
  1442.   movq [edi][DATASIZE*5+24], mm5 //store
  1443. //******************************************************************************
  1444. // This completes all 8x8 dct locations for the column case.
  1445. //******************************************************************************
  1446. emms
  1447. }
  1448. }
  1449. #endif /* DCT_ISLOW_SUPPORTED */