2 * Copyright (C) 2004 the ffmpeg project
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * SSE2-optimized functions cribbed from the original VP3 source code.
24 #include "../dsputil.h"
27 static unsigned short __align16 SSE2_dequant_const[] =
29 0,65535,65535,0,0,0,0,0, // 0x0000 0000 0000 0000 0000 FFFF FFFF 0000
30 0,0,0,0,65535,65535,0,0, // 0x0000 0000 FFFF FFFF 0000 0000 0000 0000
31 65535,65535,65535,0,0,0,0,0,// 0x0000 0000 0000 0000 0000 FFFF FFFF FFFF
32 0,0,0,65535,0,0,0,0, // 0x0000 0000 0000 0000 FFFF 0000 0000 0000
33 0,0,0,65535,65535,0,0,0, // 0x0000 0000 0000 FFFF FFFF 0000 0000 0000
34 65535,0,0,0,0,65535,0,0, // 0x0000 0000 FFFF 0000 0000 0000 0000 FFFF
35 0,0,65535,65535, 0,0,0,0 // 0x0000 0000 0000 0000 FFFF FFFF 0000 0000
38 static unsigned int __align16 eight_data[] =
46 static unsigned short __align16 SSE2_idct_data[7 * 8] =
48 64277,64277,64277,64277,64277,64277,64277,64277,
49 60547,60547,60547,60547,60547,60547,60547,60547,
50 54491,54491,54491,54491,54491,54491,54491,54491,
51 46341,46341,46341,46341,46341,46341,46341,46341,
52 36410,36410,36410,36410,36410,36410,36410,36410,
53 25080,25080,25080,25080,25080,25080,25080,25080,
54 12785,12785,12785,12785,12785,12785,12785,12785
58 #define SSE2_Column_IDCT() { \
60 movdqu_m2r(*I(3), xmm2); /* xmm2 = i3 */ \
61 movdqu_m2r(*C(3), xmm6); /* xmm6 = c3 */ \
63 movdqu_r2r(xmm2, xmm4); /* xmm4 = i3 */ \
64 movdqu_m2r(*I(5), xmm7); /* xmm7 = i5 */ \
66 pmulhw_r2r(xmm6, xmm4); /* xmm4 = c3 * i3 - i3 */ \
67 movdqu_m2r(*C(5), xmm1); /* xmm1 = c5 */ \
69 pmulhw_r2r(xmm7, xmm6); /* xmm6 = c3 * i5 - i5 */ \
70 movdqu_r2r(xmm1, xmm5); /* xmm5 = c5 */ \
72 pmulhw_r2r(xmm2, xmm1); /* xmm1 = c5 * i3 - i3 */ \
73 movdqu_m2r(*I(1), xmm3); /* xmm3 = i1 */ \
75 pmulhw_r2r(xmm7, xmm5); /* xmm5 = c5 * i5 - i5 */ \
76 movdqu_m2r(*C(1), xmm0); /* xmm0 = c1 */ \
78 /* all registers are in use */ \
80 paddw_r2r(xmm2, xmm4); /* xmm4 = c3 * i3 */ \
81 paddw_r2r(xmm7, xmm6); /* xmm6 = c3 * i5 */ \
83 paddw_r2r(xmm1, xmm2); /* xmm2 = c5 * i3 */ \
84 movdqu_m2r(*I(7), xmm1); /* xmm1 = i7 */ \
86 paddw_r2r(xmm5, xmm7); /* xmm7 = c5 * i5 */ \
87 movdqu_r2r(xmm0, xmm5); /* xmm5 = c1 */ \
89 pmulhw_r2r(xmm3, xmm0); /* xmm0 = c1 * i1 - i1 */ \
90 paddsw_r2r(xmm7, xmm4); /* xmm4 = c3 * i3 + c5 * i5 = C */ \
92 pmulhw_r2r(xmm1, xmm5); /* xmm5 = c1 * i7 - i7 */ \
93 movdqu_m2r(*C(7), xmm7); /* xmm7 = c7 */ \
95 psubsw_r2r(xmm2, xmm6); /* xmm6 = c3 * i5 - c5 * i3 = D */ \
96 paddw_r2r(xmm3, xmm0); /* xmm0 = c1 * i1 */ \
98 pmulhw_r2r(xmm7, xmm3); /* xmm3 = c7 * i1 */ \
99 movdqu_m2r(*I(2), xmm2); /* xmm2 = i2 */ \
101 pmulhw_r2r(xmm1, xmm7); /* xmm7 = c7 * i7 */ \
102 paddw_r2r(xmm1, xmm5); /* xmm5 = c1 * i7 */ \
104 movdqu_r2r(xmm2, xmm1); /* xmm1 = i2 */ \
105 pmulhw_m2r(*C(2), xmm2); /* xmm2 = i2 * c2 -i2 */ \
107 psubsw_r2r(xmm5, xmm3); /* xmm3 = c7 * i1 - c1 * i7 = B */ \
108 movdqu_m2r(*I(6), xmm5); /* xmm5 = i6 */ \
110 paddsw_r2r(xmm7, xmm0); /* xmm0 = c1 * i1 + c7 * i7 = A */ \
111 movdqu_r2r(xmm5, xmm7); /* xmm7 = i6 */ \
113 psubsw_r2r(xmm4, xmm0); /* xmm0 = A - C */ \
114 pmulhw_m2r(*C(2), xmm5); /* xmm5 = c2 * i6 - i6 */ \
116 paddw_r2r(xmm1, xmm2); /* xmm2 = i2 * c2 */ \
117 pmulhw_m2r(*C(6), xmm1); /* xmm1 = c6 * i2 */ \
119 paddsw_r2r(xmm4, xmm4); /* xmm4 = C + C */ \
120 paddsw_r2r(xmm0, xmm4); /* xmm4 = A + C = C. */ \
122 psubsw_r2r(xmm6, xmm3); /* xmm3 = B - D */ \
123 paddw_r2r(xmm7, xmm5); /* xmm5 = c2 * i6 */ \
125 paddsw_r2r(xmm6, xmm6); /* xmm6 = D + D */ \
126 pmulhw_m2r(*C(6), xmm7); /* xmm7 = c6 * i6 */ \
128 paddsw_r2r(xmm3, xmm6); /* xmm6 = B + D = D. */ \
129 movdqu_r2m(xmm4, *I(1)); /* Save C. at I(1) */ \
131 psubsw_r2r(xmm5, xmm1); /* xmm1 = c6 * i2 - c2 * i6 = H */ \
132 movdqu_m2r(*C(4), xmm4); /* xmm4 = c4 */ \
134 movdqu_r2r(xmm3, xmm5); /* xmm5 = B - D */ \
135 pmulhw_r2r(xmm4, xmm3); /* xmm3 = ( c4 -1 ) * ( B - D ) */ \
137 paddsw_r2r(xmm2, xmm7); /* xmm7 = c2 * i2 + c6 * i6 = G */ \
138 movdqu_r2m(xmm6, *I(2)); /* Save D. at I(2) */ \
140 movdqu_r2r(xmm0, xmm2); /* xmm2 = A - C */ \
141 movdqu_m2r(*I(0), xmm6); /* xmm6 = i0 */ \
143 pmulhw_r2r(xmm4, xmm0); /* xmm0 = ( c4 - 1 ) * ( A - C ) = A. */ \
144 paddw_r2r(xmm3, xmm5); /* xmm5 = c4 * ( B - D ) = B. */ \
146 movdqu_m2r(*I(4), xmm3); /* xmm3 = i4 */ \
147 psubsw_r2r(xmm1, xmm5); /* xmm5 = B. - H = B.. */ \
149 paddw_r2r(xmm0, xmm2); /* xmm2 = c4 * ( A - C) = A. */ \
150 psubsw_r2r(xmm3, xmm6); /* xmm6 = i0 - i4 */ \
152 movdqu_r2r(xmm6, xmm0); /* xmm0 = i0 - i4 */ \
153 pmulhw_r2r(xmm4, xmm6); /* xmm6 = (c4 - 1) * (i0 - i4) = F */ \
155 paddsw_r2r(xmm3, xmm3); /* xmm3 = i4 + i4 */ \
156 paddsw_r2r(xmm1, xmm1); /* xmm1 = H + H */ \
158 paddsw_r2r(xmm0, xmm3); /* xmm3 = i0 + i4 */ \
159 paddsw_r2r(xmm5, xmm1); /* xmm1 = B. + H = H. */ \
161 pmulhw_r2r(xmm3, xmm4); /* xmm4 = ( c4 - 1 ) * ( i0 + i4 ) */ \
162 paddw_r2r(xmm0, xmm6); /* xmm6 = c4 * ( i0 - i4 ) */ \
164 psubsw_r2r(xmm2, xmm6); /* xmm6 = F - A. = F. */ \
165 paddsw_r2r(xmm2, xmm2); /* xmm2 = A. + A. */ \
167 movdqu_m2r(*I(1), xmm0); /* Load C. from I(1) */ \
168 paddsw_r2r(xmm6, xmm2); /* xmm2 = F + A. = A.. */ \
170 paddw_r2r(xmm3, xmm4); /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \
171 psubsw_r2r(xmm1, xmm2); /* xmm2 = A.. - H. = R2 */ \
173 paddsw_m2r(*Eight, xmm2); /* Adjust R2 and R1 before shifting */ \
174 paddsw_r2r(xmm1, xmm1); /* xmm1 = H. + H. */ \
176 paddsw_r2r(xmm2, xmm1); /* xmm1 = A.. + H. = R1 */ \
177 psraw_i2r(4, xmm2); /* xmm2 = op2 */ \
179 psubsw_r2r(xmm7, xmm4); /* xmm4 = E - G = E. */ \
180 psraw_i2r(4, xmm1); /* xmm1 = op1 */ \
182 movdqu_m2r(*I(2), xmm3); /* Load D. from I(2) */ \
183 paddsw_r2r(xmm7, xmm7); /* xmm7 = G + G */ \
185 movdqu_r2m(xmm2, *O(2)); /* Write out op2 */ \
186 paddsw_r2r(xmm4, xmm7); /* xmm7 = E + G = G. */ \
188 movdqu_r2m(xmm1, *O(1)); /* Write out op1 */ \
189 psubsw_r2r(xmm3, xmm4); /* xmm4 = E. - D. = R4 */ \
191 paddsw_m2r(*Eight, xmm4); /* Adjust R4 and R3 before shifting */ \
192 paddsw_r2r(xmm3, xmm3); /* xmm3 = D. + D. */ \
194 paddsw_r2r(xmm4, xmm3); /* xmm3 = E. + D. = R3 */ \
195 psraw_i2r(4, xmm4); /* xmm4 = op4 */ \
197 psubsw_r2r(xmm5, xmm6); /* xmm6 = F. - B..= R6 */ \
198 psraw_i2r(4, xmm3); /* xmm3 = op3 */ \
200 paddsw_m2r(*Eight, xmm6); /* Adjust R6 and R5 before shifting */ \
201 paddsw_r2r(xmm5, xmm5); /* xmm5 = B.. + B.. */ \
203 paddsw_r2r(xmm6, xmm5); /* xmm5 = F. + B.. = R5 */ \
204 psraw_i2r(4, xmm6); /* xmm6 = op6 */ \
206 movdqu_r2m(xmm4, *O(4)); /* Write out op4 */ \
207 psraw_i2r(4, xmm5); /* xmm5 = op5 */ \
209 movdqu_r2m(xmm3, *O(3)); /* Write out op3 */ \
210 psubsw_r2r(xmm0, xmm7); /* xmm7 = G. - C. = R7 */ \
212 paddsw_m2r(*Eight, xmm7); /* Adjust R7 and R0 before shifting */ \
213 paddsw_r2r(xmm0, xmm0); /* xmm0 = C. + C. */ \
215 paddsw_r2r(xmm7, xmm0); /* xmm0 = G. + C. */ \
216 psraw_i2r(4, xmm7); /* xmm7 = op7 */ \
218 movdqu_r2m(xmm6, *O(6)); /* Write out op6 */ \
219 psraw_i2r(4, xmm0); /* xmm0 = op0 */ \
221 movdqu_r2m(xmm5, *O(5)); /* Write out op5 */ \
222 movdqu_r2m(xmm7, *O(7)); /* Write out op7 */ \
224 movdqu_r2m(xmm0, *O(0)); /* Write out op0 */ \
226 } /* End of SSE2_Column_IDCT macro */
229 #define SSE2_Row_IDCT() { \
231 movdqu_m2r(*I(3), xmm2); /* xmm2 = i3 */ \
232 movdqu_m2r(*C(3), xmm6); /* xmm6 = c3 */ \
234 movdqu_r2r(xmm2, xmm4); /* xmm4 = i3 */ \
235 movdqu_m2r(*I(5), xmm7); /* xmm7 = i5 */ \
237 pmulhw_r2r(xmm6, xmm4); /* xmm4 = c3 * i3 - i3 */ \
238 movdqu_m2r(*C(5), xmm1); /* xmm1 = c5 */ \
240 pmulhw_r2r(xmm7, xmm6); /* xmm6 = c3 * i5 - i5 */ \
241 movdqu_r2r(xmm1, xmm5); /* xmm5 = c5 */ \
243 pmulhw_r2r(xmm2, xmm1); /* xmm1 = c5 * i3 - i3 */ \
244 movdqu_m2r(*I(1), xmm3); /* xmm3 = i1 */ \
246 pmulhw_r2r(xmm7, xmm5); /* xmm5 = c5 * i5 - i5 */ \
247 movdqu_m2r(*C(1), xmm0); /* xmm0 = c1 */ \
249 /* all registers are in use */ \
251 paddw_r2r(xmm2, xmm4); /* xmm4 = c3 * i3 */ \
252 paddw_r2r(xmm7, xmm6); /* xmm6 = c3 * i5 */ \
254 paddw_r2r(xmm1, xmm2); /* xmm2 = c5 * i3 */ \
255 movdqu_m2r(*I(7), xmm1); /* xmm1 = i7 */ \
257 paddw_r2r(xmm5, xmm7); /* xmm7 = c5 * i5 */ \
258 movdqu_r2r(xmm0, xmm5); /* xmm5 = c1 */ \
260 pmulhw_r2r(xmm3, xmm0); /* xmm0 = c1 * i1 - i1 */ \
261 paddsw_r2r(xmm7, xmm4); /* xmm4 = c3 * i3 + c5 * i5 = C */ \
263 pmulhw_r2r(xmm1, xmm5); /* xmm5 = c1 * i7 - i7 */ \
264 movdqu_m2r(*C(7), xmm7); /* xmm7 = c7 */ \
266 psubsw_r2r(xmm2, xmm6); /* xmm6 = c3 * i5 - c5 * i3 = D */ \
267 paddw_r2r(xmm3, xmm0); /* xmm0 = c1 * i1 */ \
269 pmulhw_r2r(xmm7, xmm3); /* xmm3 = c7 * i1 */ \
270 movdqu_m2r(*I(2), xmm2); /* xmm2 = i2 */ \
272 pmulhw_r2r(xmm1, xmm7); /* xmm7 = c7 * i7 */ \
273 paddw_r2r(xmm1, xmm5); /* xmm5 = c1 * i7 */ \
275 movdqu_r2r(xmm2, xmm1); /* xmm1 = i2 */ \
276 pmulhw_m2r(*C(2), xmm2); /* xmm2 = i2 * c2 -i2 */ \
278 psubsw_r2r(xmm5, xmm3); /* xmm3 = c7 * i1 - c1 * i7 = B */ \
279 movdqu_m2r(*I(6), xmm5); /* xmm5 = i6 */ \
281 paddsw_r2r(xmm7, xmm0); /* xmm0 = c1 * i1 + c7 * i7 = A */ \
282 movdqu_r2r(xmm5, xmm7); /* xmm7 = i6 */ \
284 psubsw_r2r(xmm4, xmm0); /* xmm0 = A - C */ \
285 pmulhw_m2r(*C(2), xmm5); /* xmm5 = c2 * i6 - i6 */ \
287 paddw_r2r(xmm1, xmm2); /* xmm2 = i2 * c2 */ \
288 pmulhw_m2r(*C(6), xmm1); /* xmm1 = c6 * i2 */ \
290 paddsw_r2r(xmm4, xmm4); /* xmm4 = C + C */ \
291 paddsw_r2r(xmm0, xmm4); /* xmm4 = A + C = C. */ \
293 psubsw_r2r(xmm6, xmm3); /* xmm3 = B - D */ \
294 paddw_r2r(xmm7, xmm5); /* xmm5 = c2 * i6 */ \
296 paddsw_r2r(xmm6, xmm6); /* xmm6 = D + D */ \
297 pmulhw_m2r(*C(6), xmm7); /* xmm7 = c6 * i6 */ \
299 paddsw_r2r(xmm3, xmm6); /* xmm6 = B + D = D. */ \
300 movdqu_r2m(xmm4, *I(1)); /* Save C. at I(1) */ \
302 psubsw_r2r(xmm5, xmm1); /* xmm1 = c6 * i2 - c2 * i6 = H */ \
303 movdqu_m2r(*C(4), xmm4); /* xmm4 = c4 */ \
305 movdqu_r2r(xmm3, xmm5); /* xmm5 = B - D */ \
306 pmulhw_r2r(xmm4, xmm3); /* xmm3 = ( c4 -1 ) * ( B - D ) */ \
308 paddsw_r2r(xmm2, xmm7); /* xmm7 = c2 * i2 + c6 * i6 = G */ \
309 movdqu_r2m(xmm6, *I(2)); /* Save D. at I(2) */ \
311 movdqu_r2r(xmm0, xmm2); /* xmm2 = A - C */ \
312 movdqu_m2r(*I(0), xmm6); /* xmm6 = i0 */ \
314 pmulhw_r2r(xmm4, xmm0); /* xmm0 = ( c4 - 1 ) * ( A - C ) = A. */ \
315 paddw_r2r(xmm3, xmm5); /* xmm5 = c4 * ( B - D ) = B. */ \
317 movdqu_m2r(*I(4), xmm3); /* xmm3 = i4 */ \
318 psubsw_r2r(xmm1, xmm5); /* xmm5 = B. - H = B.. */ \
320 paddw_r2r(xmm0, xmm2); /* xmm2 = c4 * ( A - C) = A. */ \
321 psubsw_r2r(xmm3, xmm6); /* xmm6 = i0 - i4 */ \
323 movdqu_r2r(xmm6, xmm0); /* xmm0 = i0 - i4 */ \
324 pmulhw_r2r(xmm4, xmm6); /* xmm6 = ( c4 - 1 ) * ( i0 - i4 ) = F */ \
326 paddsw_r2r(xmm3, xmm3); /* xmm3 = i4 + i4 */ \
327 paddsw_r2r(xmm1, xmm1); /* xmm1 = H + H */ \
329 paddsw_r2r(xmm0, xmm3); /* xmm3 = i0 + i4 */ \
330 paddsw_r2r(xmm5, xmm1); /* xmm1 = B. + H = H. */ \
332 pmulhw_r2r(xmm3, xmm4); /* xmm4 = ( c4 - 1 ) * ( i0 + i4 ) */ \
333 paddw_r2r(xmm0, xmm6); /* xmm6 = c4 * ( i0 - i4 ) */ \
335 psubsw_r2r(xmm2, xmm6); /* xmm6 = F - A. = F. */ \
336 paddsw_r2r(xmm2, xmm2); /* xmm2 = A. + A. */ \
338 movdqu_m2r(*I(1), xmm0); /* Load C. from I(1) */ \
339 paddsw_r2r(xmm6, xmm2); /* xmm2 = F + A. = A.. */ \
341 paddw_r2r(xmm3, xmm4); /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \
342 psubsw_r2r(xmm1, xmm2); /* xmm2 = A.. - H. = R2 */ \
344 paddsw_r2r(xmm1, xmm1); /* xmm1 = H. + H. */ \
345 paddsw_r2r(xmm2, xmm1); /* xmm1 = A.. + H. = R1 */ \
347 psubsw_r2r(xmm7, xmm4); /* xmm4 = E - G = E. */ \
349 movdqu_m2r(*I(2), xmm3); /* Load D. from I(2) */ \
350 paddsw_r2r(xmm7, xmm7); /* xmm7 = G + G */ \
352 movdqu_r2m(xmm2, *I(2)); /* Write out op2 */ \
353 paddsw_r2r(xmm4, xmm7); /* xmm7 = E + G = G. */ \
355 movdqu_r2m(xmm1, *I(1)); /* Write out op1 */ \
356 psubsw_r2r(xmm3, xmm4); /* xmm4 = E. - D. = R4 */ \
358 paddsw_r2r(xmm3, xmm3); /* xmm3 = D. + D. */ \
360 paddsw_r2r(xmm4, xmm3); /* xmm3 = E. + D. = R3 */ \
362 psubsw_r2r(xmm5, xmm6); /* xmm6 = F. - B..= R6 */ \
364 paddsw_r2r(xmm5, xmm5); /* xmm5 = B.. + B.. */ \
366 paddsw_r2r(xmm6, xmm5); /* xmm5 = F. + B.. = R5 */ \
368 movdqu_r2m(xmm4, *I(4)); /* Write out op4 */ \
370 movdqu_r2m(xmm3, *I(3)); /* Write out op3 */ \
371 psubsw_r2r(xmm0, xmm7); /* xmm7 = G. - C. = R7 */ \
373 paddsw_r2r(xmm0, xmm0); /* xmm0 = C. + C. */ \
375 paddsw_r2r(xmm7, xmm0); /* xmm0 = G. + C. */ \
377 movdqu_r2m(xmm6, *I(6)); /* Write out op6 */ \
379 movdqu_r2m(xmm5, *I(5)); /* Write out op5 */ \
380 movdqu_r2m(xmm7, *I(7)); /* Write out op7 */ \
382 movdqu_r2m(xmm0, *I(0)); /* Write out op0 */ \
384 } /* End of SSE2_Row_IDCT macro */
387 #define SSE2_Transpose() { \
389 movdqu_m2r(*I(4), xmm4); /* xmm4=e7e6e5e4e3e2e1e0 */ \
390 movdqu_m2r(*I(5), xmm0); /* xmm4=f7f6f5f4f3f2f1f0 */ \
392 movdqu_r2r(xmm4, xmm5); /* make a copy */ \
393 punpcklwd_r2r(xmm0, xmm4); /* xmm4=f3e3f2e2f1e1f0e0 */ \
395 punpckhwd_r2r(xmm0, xmm5); /* xmm5=f7e7f6e6f5e5f4e4 */ \
396 movdqu_m2r(*I(6), xmm6); /* xmm6=g7g6g5g4g3g2g1g0 */ \
398 movdqu_m2r(*I(7), xmm0); /* xmm0=h7h6h5h4h3h2h1h0 */ \
399 movdqu_r2r(xmm6, xmm7); /* make a copy */ \
401 punpcklwd_r2r(xmm0, xmm6); /* xmm6=h3g3h3g2h1g1h0g0 */ \
402 punpckhwd_r2r(xmm0, xmm7); /* xmm7=h7g7h6g6h5g5h4g4 */ \
404 movdqu_r2r(xmm4, xmm3); /* make a copy */ \
405 punpckldq_r2r(xmm6, xmm4); /* xmm4=h1g1f1e1h0g0f0e0 */ \
407 punpckhdq_r2r(xmm6, xmm3); /* xmm3=h3g3g3e3h2g2f2e2 */ \
408 movdqu_r2m(xmm3, *I(6)); /* save h3g3g3e3h2g2f2e2 */ \
410 movdqu_r2r(xmm5, xmm6); /* make a copy */ \
411 punpckldq_r2r(xmm7, xmm5); /* xmm5=h5g5f5e5h4g4f4e4 */ \
413 punpckhdq_r2r(xmm7, xmm6); /* xmm6=h7g7f7e7h6g6f6e6 */ \
414 movdqu_m2r(*I(0), xmm0); /* xmm0=a7a6a5a4a3a2a1a0 */ \
416 movdqu_m2r(*I(1), xmm1); /* xmm1=b7b6b5b4b3b2b1b0 */ \
417 movdqu_r2r(xmm0, xmm7); /* make a copy */ \
419 punpcklwd_r2r(xmm1, xmm0); /* xmm0=b3a3b2a2b1a1b0a0 */ \
420 punpckhwd_r2r(xmm1, xmm7); /* xmm7=b7a7b6a6b5a5b4a4 */ \
422 movdqu_m2r(*I(2), xmm2); /* xmm2=c7c6c5c4c3c2c1c0 */ \
423 movdqu_m2r(*I(3), xmm3); /* xmm3=d7d6d5d4d3d2d1d0 */ \
425 movdqu_r2r(xmm2, xmm1); /* make a copy */ \
426 punpcklwd_r2r(xmm3, xmm2); /* xmm2=d3c3d2c2d1c1d0c0 */ \
428 punpckhwd_r2r(xmm3, xmm1); /* xmm1=d7c7d6c6d5c5d4c4 */ \
429 movdqu_r2r(xmm0, xmm3); /* make a copy */ \
431 punpckldq_r2r(xmm2, xmm0); /* xmm0=d1c1b1a1d0c0b0a0 */ \
432 punpckhdq_r2r(xmm2, xmm3); /* xmm3=d3c3b3a3d2c2b2a2 */ \
434 movdqu_r2r(xmm7, xmm2); /* make a copy */ \
435 punpckldq_r2r(xmm1, xmm2); /* xmm2=d5c5b5a5d4c4b4a4 */ \
437 punpckhdq_r2r(xmm1, xmm7); /* xmm7=d7c7b7a7d6c6b6a6 */ \
438 movdqu_r2r(xmm0, xmm1); /* make a copy */ \
440 punpcklqdq_r2r(xmm4, xmm0); /* xmm0=h0g0f0e0d0c0b0a0 */ \
441 punpckhqdq_r2r(xmm4, xmm1); /* xmm1=h1g1g1e1d1c1b1a1 */ \
443 movdqu_r2m(xmm0, *I(0)); /* save I(0) */ \
444 movdqu_r2m(xmm1, *I(1)); /* save I(1) */ \
446 movdqu_m2r(*I(6), xmm0); /* load h3g3g3e3h2g2f2e2 */ \
447 movdqu_r2r(xmm3, xmm1); /* make a copy */ \
449 punpcklqdq_r2r(xmm0, xmm1); /* xmm1=h2g2f2e2d2c2b2a2 */ \
450 punpckhqdq_r2r(xmm0, xmm3); /* xmm3=h3g3f3e3d3c3b3a3 */ \
452 movdqu_r2r(xmm2, xmm4); /* make a copy */ \
453 punpcklqdq_r2r(xmm5, xmm4); /* xmm4=h4g4f4e4d4c4b4a4 */ \
455 punpckhqdq_r2r(xmm5, xmm2); /* xmm2=h5g5f5e5d5c5b5a5 */ \
456 movdqu_r2m(xmm1, *I(2)); /* save I(2) */ \
458 movdqu_r2m(xmm3, *I(3)); /* save I(3) */ \
459 movdqu_r2m(xmm4, *I(4)); /* save I(4) */ \
461 movdqu_r2m(xmm2, *I(5)); /* save I(5) */ \
462 movdqu_r2r(xmm7, xmm5); /* make a copy */ \
464 punpcklqdq_r2r(xmm6, xmm5); /* xmm5=h6g6f6e6d6c6b6a6 */ \
465 punpckhqdq_r2r(xmm6, xmm7); /* xmm7=h7g7f7e7d7c7b7a7 */ \
467 movdqu_r2m(xmm5, *I(6)); /* save I(6) */ \
468 movdqu_r2m(xmm7, *I(7)); /* save I(7) */ \
470 } /* End of Transpose Macro */
473 #define SSE2_Dequantize() { \
474 movdqu_m2r(*(eax), xmm0); \
476 pmullw_m2r(*(ebx), xmm0); /* xmm0 = 07 06 05 04 03 02 01 00 */ \
477 movdqu_m2r(*(eax + 16), xmm1); \
479 pmullw_m2r(*(ebx + 16), xmm1); /* xmm1 = 17 16 15 14 13 12 11 10 */ \
480 pshuflw_r2r(xmm0, xmm3, 0x078); /* xmm3 = 07 06 05 04 01 03 02 00 */ \
482 movdqu_r2r(xmm1, xmm2); /* xmm2 = 17 16 15 14 13 12 11 10 */ \
483 movdqu_m2r(*(ecx), xmm7); /* xmm7 = -- -- -- -- -- FF FF -- */ \
485 movdqu_m2r(*(eax + 32), xmm4); \
486 movdqu_m2r(*(eax + 64), xmm5); \
488 pmullw_m2r(*(ebx + 32), xmm4); /* xmm4 = 27 26 25 24 23 22 21 20 */ \
489 pmullw_m2r(*(ebx + 64), xmm5); /* xmm5 = 47 46 45 44 43 42 41 40 */ \
491 movdqu_m2r(*(ecx + 16), xmm6); /* xmm6 = -- -- FF FF -- -- -- -- */ \
492 pand_r2r(xmm2, xmm7); /* xmm7 = -- -- -- -- -- 12 11 -- */ \
494 pand_r2r(xmm4, xmm6); /* xmm6 = -- -- 25 24 -- -- -- -- */ \
495 pxor_r2r(xmm7, xmm2); /* xmm2 = 17 16 15 14 13 -- -- 10 */ \
497 pxor_r2r(xmm6, xmm4); /* xmm4 = 27 26 -- -- 23 22 21 20 */ \
498 pslldq_i2r(4, xmm7); /* xmm7 = -- -- -- 12 11 -- -- -- */ \
500 pslldq_i2r(2, xmm6); /* xmm6 = -- 25 24 -- -- -- -- -- */ \
501 por_r2r(xmm6, xmm7); /* xmm7 = -- 25 24 12 11 -- -- -- */ \
503 movdqu_m2r(*(ecx + 32), xmm0); /* xmm0 = -- -- -- -- -- FF FF FF */ \
504 movdqu_m2r(*(ecx + 48), xmm6); /* xmm6 = -- -- -- -- FF -- -- -- */ \
506 pand_r2r(xmm3, xmm0); /* xmm0 = -- -- -- -- -- 03 02 00 */ \
507 pand_r2r(xmm5, xmm6); /* xmm6 = -- -- -- -- 43 -- -- -- */ \
509 pxor_r2r(xmm0, xmm3); /* xmm3 = 07 06 05 04 01 -- -- -- */ \
510 pxor_r2r(xmm6, xmm5); /* xmm5 = 47 46 45 44 -- 42 41 40 */ \
512 por_r2r(xmm7, xmm0); /* xmm0 = -- 25 24 12 11 03 02 00 */ \
513 pslldq_i2r(8, xmm6); /* xmm6 = 43 -- -- -- -- -- -- -- */ \
515 por_r2r(xmm6, xmm0); /* xmm0 = 43 25 24 12 11 03 02 00 */ \
518 movdqu_m2r(*(ecx + 64 ), xmm1); /* xmm1 = -- -- -- FF FF -- -- -- */ \
519 pshuflw_r2r(xmm5, xmm5, 0x0B4); /* xmm5 = 47 46 45 44 42 -- 41 40 */ \
521 movdqu_r2r(xmm1, xmm7); /* xmm7 = -- -- -- FF FF -- -- -- */ \
522 movdqu_r2r(xmm1, xmm6); /* xmm6 = -- -- -- FF FF -- -- -- */ \
524 movdqu_r2m(xmm0, *(eax)); /* write 43 25 24 12 11 03 02 00 */ \
525 pshufhw_r2r(xmm4, xmm4, 0x0C2); /* xmm4 = 27 -- -- 26 23 22 21 20 */ \
527 pand_r2r(xmm4, xmm7); /* xmm7 = -- -- -- 26 23 -- -- -- */ \
528 pand_r2r(xmm5, xmm1); /* xmm1 = -- -- -- 44 42 -- -- -- */ \
530 pxor_r2r(xmm7, xmm4); /* xmm4 = 27 -- -- -- -- 22 21 20 */ \
531 pxor_r2r(xmm1, xmm5); /* xmm5 = 47 46 45 -- -- -- 41 40 */ \
533 pshuflw_r2r(xmm2, xmm2, 0x0C6); /* xmm2 = 17 16 15 14 13 10 -- -- */ \
534 movdqu_r2r(xmm6, xmm0); /* xmm0 = -- -- -- FF FF -- -- -- */ \
536 pslldq_i2r(2, xmm7); /* xmm7 = -- -- 26 23 -- -- -- -- */ \
537 pslldq_i2r(6, xmm1); /* xmm1 = 44 42 -- -- -- -- -- -- */ \
539 psrldq_i2r(2, xmm0); /* xmm0 = -- -- -- -- FF FF -- -- */ \
540 pand_r2r(xmm3, xmm6); /* xmm6 = -- -- -- 04 01 -- -- -- */ \
542 pand_r2r(xmm2, xmm0); /* xmm0 = -- -- -- -- 13 10 -- -- */ \
543 pxor_r2r(xmm6, xmm3); /* xmm3 = 07 06 05 -- -- -- -- -- */ \
545 pxor_r2r(xmm0, xmm2); /* xmm2 = 17 16 15 14 -- -- -- -- */ \
546 psrldq_i2r(6, xmm6); /* xmm0 = -- -- -- -- -- -- 04 01 */ \
548 por_r2r(xmm7, xmm1); /* xmm1 = 44 42 26 23 -- -- -- -- */ \
549 por_r2r(xmm6, xmm0); /* xmm1 = -- -- -- -- 13 10 04 01 */ \
551 por_r2r(xmm0, xmm1); /* xmm1 = 44 42 26 23 13 10 04 01 */ \
552 pshuflw_r2r(xmm4, xmm4, 0x093); /* xmm4 = 27 -- -- -- 22 21 20 -- */ \
554 pshufhw_r2r(xmm4, xmm4, 0x093); /* xmm4 = -- -- -- 27 22 21 20 -- */ \
555 movdqu_r2m(xmm1, *(eax + 16)); /* write 44 42 26 23 13 10 04 01 */ \
557 pshufhw_r2r(xmm3, xmm3, 0x0D2); /* xmm3 = 07 05 -- 06 -- -- -- -- */ \
558 movdqu_m2r(*(ecx + 64), xmm0); /* xmm0 = -- -- -- FF FF -- -- -- */ \
560 pand_r2r(xmm3, xmm0); /* xmm0 = -- -- -- 06 -- -- -- -- */ \
561 psrldq_i2r(12, xmm3); /* xmm3 = -- -- -- -- -- -- 07 05 */ \
563 psrldq_i2r(8, xmm0); /* xmm0 = -- -- -- -- -- -- -- 06 */ \
565 movdqu_m2r(*(ecx + 64), xmm6); /* xmm6 = -- -- -- FF FF -- -- -- */ \
566 movdqu_m2r(*(ecx + 96), xmm7); /* xmm7 = -- -- -- -- FF FF -- -- */ \
568 pand_r2r(xmm4, xmm6); /* xmm6 = -- -- -- 27 22 -- -- -- */ \
569 pxor_r2r(xmm6, xmm4); /* xmm4 = -- -- -- -- -- 21 20 -- */ \
571 por_r2r(xmm6, xmm3); /* xmm3 = -- -- -- 27 22 -- 07 05 */ \
572 pand_r2r(xmm4, xmm7); /* xmm7 = -- -- -- -- -- 21 -- -- */ \
574 por_r2r(xmm7, xmm0); /* xmm0 = -- -- -- -- -- 21 -- 06 */ \
575 pxor_r2r(xmm7, xmm4); /* xmm4 = -- -- -- -- -- -- 20 -- */ \
577 movdqu_m2r(*(ecx + 16 ), xmm6); /* xmm6 = -- -- FF FF -- -- -- -- */ \
578 movdqu_m2r(*(ecx + 64 ), xmm1); /* xmm1 = -- -- -- FF FF -- -- -- */ \
580 pand_r2r(xmm2, xmm6); /* xmm6 = -- -- 15 14 -- -- -- -- */ \
581 pand_r2r(xmm6, xmm1); /* xmm1 = -- -- -- 14 -- -- -- -- */ \
583 pxor_r2r(xmm6, xmm2); /* xmm2 = 17 16 -- -- -- -- -- -- */ \
584 pxor_r2r(xmm1, xmm6); /* xmm6 = -- -- 15 -- -- -- -- -- */ \
586 psrldq_i2r(4, xmm1); /* xmm1 = -- -- -- -- -- 14 -- -- */ \
588 psrldq_i2r(8, xmm6); /* xmm6 = -- -- -- -- -- -- 15 -- */ \
589 por_r2r(xmm1, xmm3); /* xmm3 = -- -- -- 27 22 14 07 05 */ \
591 por_r2r(xmm6, xmm0); /* xmm0 = -- -- -- -- -- 21 15 06 */ \
592 pshufhw_r2r(xmm5, xmm5, 0x0E1); /* xmm5 = 47 46 -- 45 -- -- 41 40 */ \
594 movdqu_m2r(*(ecx + 64), xmm1); /* xmm1 = -- -- -- FF FF -- -- -- */ \
595 pshuflw_r2r(xmm5, xmm5, 0x072); /* xmm5 = 47 46 -- 45 41 -- 40 -- */ \
597 movdqu_r2r(xmm1, xmm6); /* xmm6 = -- -- -- FF FF -- -- -- */ \
598 pand_r2r(xmm5, xmm1); /* xmm1 = -- -- -- 45 41 -- -- -- */ \
600 pxor_r2r(xmm1, xmm5); /* xmm5 = 47 46 -- -- -- -- 40 -- */ \
601 pslldq_i2r(4, xmm1); /* xmm1 = -- 45 41 -- -- -- -- -- */ \
603 pshufd_r2r(xmm5, xmm5, 0x09C); /* xmm5 = -- -- -- -- 47 46 40 -- */ \
604 por_r2r(xmm1, xmm3); /* xmm3 = -- 45 41 27 22 14 07 05 */ \
606 movdqu_m2r(*(eax + 96), xmm1); /* xmm1 = 67 66 65 64 63 62 61 60 */ \
607 pmullw_m2r(*(ebx + 96), xmm1); \
609 movdqu_m2r(*(ecx), xmm7); /* xmm7 = -- -- -- -- -- FF FF -- */ \
611 psrldq_i2r(8, xmm6); /* xmm6 = -- -- -- -- -- -- -- FF */ \
612 pand_r2r(xmm5, xmm7); /* xmm7 = -- -- -- -- -- 46 40 -- */ \
614 pand_r2r(xmm1, xmm6); /* xmm6 = -- -- -- -- -- -- -- 60 */ \
615 pxor_r2r(xmm7, xmm5); /* xmm5 = -- -- -- -- 47 -- -- -- */ \
617 pxor_r2r(xmm6, xmm1); /* xmm1 = 67 66 65 64 63 62 61 -- */ \
618 pslldq_i2r(2, xmm5); /* xmm5 = -- -- -- 47 -- -- -- -- */ \
620 pslldq_i2r(14, xmm6); /* xmm6 = 60 -- -- -- -- -- -- -- */ \
621 por_r2r(xmm5, xmm4); /* xmm4 = -- -- -- 47 -- -- 20 -- */ \
623 por_r2r(xmm6, xmm3); /* xmm3 = 60 45 41 27 22 14 07 05 */ \
624 pslldq_i2r(6, xmm7); /* xmm7 = -- -- 46 40 -- -- -- -- */ \
626 movdqu_r2m(xmm3, *(eax+32)); /* write 60 45 41 27 22 14 07 05 */ \
627 por_r2r(xmm7, xmm0); /* xmm0 = -- -- 46 40 -- 21 15 06 */ \
628 /* 0, 1, 2, 4 in use */ \
629 movdqu_m2r(*(eax + 48), xmm3); /* xmm3 = 37 36 35 34 33 32 31 30 */ \
630 movdqu_m2r(*(eax + 80), xmm5); /* xmm5 = 57 56 55 54 53 52 51 50 */ \
632 pmullw_m2r(*(ebx + 48), xmm3); \
633 pmullw_m2r(*(ebx + 80), xmm5); \
635 movdqu_m2r(*(ecx + 64), xmm6); /* xmm6 = -- -- -- FF FF -- -- -- */ \
636 movdqu_m2r(*(ecx + 64), xmm7); /* xmm7 = -- -- -- FF FF -- -- -- */ \
638 psrldq_i2r(8, xmm6); /* xmm6 = -- -- -- -- -- -- -- FF */ \
639 pslldq_i2r(8, xmm7); /* xmm7 = FF -- -- -- -- -- -- -- */ \
641 pand_r2r(xmm3, xmm6); /* xmm6 = -- -- -- -- -- -- -- 30 */ \
642 pand_r2r(xmm5, xmm7); /* xmm7 = 57 -- -- -- -- -- -- -- */ \
644 pxor_r2r(xmm6, xmm3); /* xmm3 = 37 36 35 34 33 32 31 -- */ \
645 pxor_r2r(xmm7, xmm5); /* xmm5 = __ 56 55 54 53 52 51 50 */ \
647 pslldq_i2r(6, xmm6); /* xmm6 = -- -- -- -- 30 -- -- -- */ \
648 psrldq_i2r(2, xmm7); /* xmm7 = -- 57 -- -- -- -- -- -- */ \
650 por_r2r(xmm7, xmm6); /* xmm6 = -- 57 -- -- 30 -- -- -- */ \
651 movdqu_m2r(*(ecx), xmm7); /* xmm7 = -- -- -- -- -- FF FF -- */ \
653 por_r2r(xmm6, xmm0); /* xmm0 = -- 57 46 40 30 21 15 06 */ \
654 psrldq_i2r(2, xmm7); /* xmm7 = -- -- -- -- -- -- FF FF */ \
656 movdqu_r2r(xmm2, xmm6); /* xmm6 = 17 16 -- -- -- -- -- -- */ \
657 pand_r2r(xmm1, xmm7); /* xmm7 = -- -- -- -- -- -- 61 -- */ \
659 pslldq_i2r(2, xmm6); /* xmm6 = 16 -- -- -- -- -- -- -- */ \
660 psrldq_i2r(14, xmm2); /* xmm2 = -- -- -- -- -- -- -- 17 */ \
662 pxor_r2r(xmm7, xmm1); /* xmm1 = 67 66 65 64 63 62 -- -- */ \
663 pslldq_i2r(12, xmm7); /* xmm7 = 61 -- -- -- -- -- -- -- */ \
665 psrldq_i2r(14, xmm6); /* xmm6 = -- -- -- -- -- -- -- 16 */ \
666 por_r2r(xmm6, xmm4); /* xmm4 = -- -- -- 47 -- -- 20 16 */ \
668 por_r2r(xmm7, xmm0); /* xmm0 = 61 57 46 40 30 21 15 06 */ \
669 movdqu_m2r(*(ecx), xmm6); /* xmm6 = -- -- -- -- -- FF FF -- */ \
671 psrldq_i2r(2, xmm6); /* xmm6 = -- -- -- -- -- -- FF FF */ \
672 movdqu_r2m(xmm0, *(eax+48)); /* write 61 57 46 40 30 21 15 06 */ \
673 /* 1, 2, 3, 4, 5 in use */\
674 movdqu_m2r(*(ecx), xmm0); /* xmm0 = -- -- -- -- -- FF FF -- */ \
675 pand_r2r(xmm3, xmm6); /* xmm6 = -- -- -- -- -- -- 31 -- */ \
677 movdqu_r2r(xmm3, xmm7); /* xmm7 = 37 36 35 34 33 32 31 -- */ \
678 pxor_r2r(xmm6, xmm3); /* xmm3 = 37 36 35 34 33 32 -- -- */ \
680 pslldq_i2r(2, xmm3); /* xmm3 = 36 35 34 33 32 -- -- -- */ \
681 pand_r2r(xmm1, xmm0); /* xmm0 = -- -- -- -- -- 62 -- -- */ \
683 psrldq_i2r(14, xmm7); /* xmm7 = -- -- -- -- -- -- -- 37 */ \
684 pxor_r2r(xmm0, xmm1); /* xmm1 = 67 66 65 64 63 -- -- -- */ \
686 por_r2r(xmm7, xmm6); /* xmm6 = -- -- -- -- -- -- 31 37 */ \
687 movdqu_m2r(*(ecx + 64), xmm7); /* xmm7 = -- -- -- FF FF -- -- -- */ \
689 pshuflw_r2r(xmm6, xmm6, 0x01E); /* xmm6 = -- -- -- -- 37 31 -- -- */ \
690 pslldq_i2r(6, xmm7); /* xmm7 = FF FF -- -- -- -- -- -- */ \
692 por_r2r(xmm6, xmm4); /* xmm4 = -- -- -- 47 37 31 20 16 */ \
693 pand_r2r(xmm5, xmm7); /* xmm7 = -- 56 -- -- -- -- -- -- */ \
695 pslldq_i2r(8, xmm0); /* xmm0 = -- 62 -- -- -- -- -- -- */ \
696 pxor_r2r(xmm7, xmm5); /* xmm5 = -- -- 55 54 53 52 51 50 */ \
698 psrldq_i2r(2, xmm7); /* xmm7 = -- -- 56 -- -- -- -- -- */ \
700 pshufhw_r2r(xmm3, xmm3, 0x087); /* xmm3 = 35 33 34 36 32 -- -- -- */ \
701 por_r2r(xmm7, xmm0); /* xmm0 = -- 62 56 -- -- -- -- -- */ \
703 movdqu_m2r(*(eax + 112), xmm7); /* xmm7 = 77 76 75 74 73 72 71 70 */ \
704 pmullw_m2r(*(ebx + 112), xmm7); \
706 movdqu_m2r(*(ecx + 64), xmm6); /* xmm6 = -- -- -- FF FF -- -- -- */ \
707 por_r2r(xmm0, xmm4); /* xmm4 = -- 62 56 47 37 31 20 16 */ \
709 pshuflw_r2r(xmm7, xmm7, 0x0E1); /* xmm7 = 77 76 75 74 73 72 70 71 */ \
710 psrldq_i2r(8, xmm6); /* xmm6 = -- -- -- -- -- -- -- FF */ \
712 movdqu_m2r(*(ecx + 64), xmm0); /* xmm0 = -- -- -- FF FF -- -- -- */ \
713 pand_r2r(xmm7, xmm6); /* xmm6 = -- -- -- -- -- -- -- 71 */ \
715 pand_r2r(xmm3, xmm0); /* xmm0 = -- -- -- 36 32 -- -- -- */ \
716 pxor_r2r(xmm6, xmm7); /* xmm7 = 77 76 75 74 73 72 70 -- */ \
718 pxor_r2r(xmm0, xmm3); /* xmm3 = 35 33 34 -- -- -- -- -- */ \
719 pslldq_i2r(14, xmm6); /* xmm6 = 71 -- -- -- -- -- -- -- */ \
721 psrldq_i2r(4, xmm0); /* xmm0 = -- -- -- -- -- 36 32 -- */ \
722 por_r2r(xmm6, xmm4); /* xmm4 = 71 62 56 47 37 31 20 16 */ \
724 por_r2r(xmm0, xmm2); /* xmm2 = -- -- -- -- -- 36 32 17 */ \
725 movdqu_r2m(xmm4, *(eax + 64)); /* write 71 62 56 47 37 31 20 16 */ \
726 /* 1, 2, 3, 5, 7 in use */ \
727 movdqu_m2r(*(ecx + 80), xmm6); /* xmm6 = -- -- FF -- -- -- -- FF */ \
728 pshufhw_r2r(xmm7, xmm7, 0x0D2); /* xmm7 = 77 75 74 76 73 72 70 __ */ \
730 movdqu_m2r(*(ecx), xmm4); /* xmm4 = -- -- -- -- -- FF FF -- */ \
731 movdqu_m2r(*(ecx+48), xmm0); /* xmm0 = -- -- -- -- FF -- -- -- */ \
733 pand_r2r(xmm5, xmm6); /* xmm6 = -- -- 55 -- -- -- -- 50 */ \
734 pand_r2r(xmm7, xmm4); /* xmm4 = -- -- -- -- -- 72 70 -- */ \
736 pand_r2r(xmm1, xmm0); /* xmm0 = -- -- -- -- 63 -- -- -- */ \
737 pxor_r2r(xmm6, xmm5); /* xmm5 = -- -- -- 54 53 52 51 -- */ \
739 pxor_r2r(xmm4, xmm7); /* xmm7 = 77 75 74 76 73 -- -- -- */ \
740 pxor_r2r(xmm0, xmm1); /* xmm1 = 67 66 65 64 -- -- -- -- */ \
742 pshuflw_r2r(xmm6, xmm6, 0x02B); /* xmm6 = -- -- 55 -- 50 -- -- -- */ \
743 pslldq_i2r(10, xmm4); /* xmm4 = 72 20 -- -- -- -- -- -- */ \
745 pshufhw_r2r(xmm6, xmm6, 0x0B1); /* xmm6 = -- -- -- 55 50 -- -- -- */ \
746 pslldq_i2r(4, xmm0); /* xmm0 = -- -- 63 -- -- -- -- -- */ \
748 por_r2r(xmm4, xmm6); /* xmm6 = 72 70 -- 55 50 -- -- -- */ \
749 por_r2r(xmm0, xmm2); /* xmm2 = -- -- 63 -- -- 36 32 17 */ \
751 por_r2r(xmm6, xmm2); /* xmm2 = 72 70 64 55 50 36 32 17 */ \
752 pshufhw_r2r(xmm1, xmm1, 0x0C9); /* xmm1 = 67 64 66 65 -- -- -- -- */ \
754 movdqu_r2r(xmm3, xmm6); /* xmm6 = 35 33 34 -- -- -- -- -- */ \
755 movdqu_r2m(xmm2, *(eax+80)); /* write 72 70 64 55 50 36 32 17 */ \
757 psrldq_i2r(12, xmm6); /* xmm6 = -- -- -- -- -- -- 35 33 */ \
758 pslldq_i2r(4, xmm3); /* xmm3 = 34 -- -- -- -- -- -- -- */ \
760 pshuflw_r2r(xmm5, xmm5, 0x04E); /* xmm5 = -- -- -- 54 51 -- 53 52 */ \
761 movdqu_r2r(xmm7, xmm4); /* xmm4 = 77 75 74 76 73 -- -- -- */ \
763 movdqu_r2r(xmm5, xmm2); /* xmm2 = -- -- -- 54 51 -- 53 52 */ \
764 psrldq_i2r(10, xmm7); /* xmm7 = -- -- -- -- -- 77 75 74 */ \
766 pslldq_i2r(6, xmm4); /* xmm4 = 76 73 -- -- -- -- -- -- */ \
767 pslldq_i2r(12, xmm2); /* xmm2 = 53 52 -- -- -- -- -- -- */ \
769 movdqu_r2r(xmm1, xmm0); /* xmm0 = 67 64 66 65 -- -- -- -- */ \
770 psrldq_i2r(12, xmm1); /* xmm1 = -- -- -- -- -- -- 67 64 */ \
772 psrldq_i2r(6, xmm5); /* xmm5 = -- -- -- -- -- -- 54 51 */ \
773 psrldq_i2r(14, xmm3); /* xmm3 = -- -- -- -- -- -- -- 34 */ \
775 pslldq_i2r(10, xmm7); /* xmm7 = 77 75 74 -- -- -- -- -- */ \
776 por_r2r(xmm6, xmm4); /* xmm4 = 76 73 -- -- -- -- 35 33 */ \
778 psrldq_i2r(10, xmm2); /* xmm2 = -- -- -- -- -- 53 52 -- */ \
779 pslldq_i2r(4, xmm0); /* xmm0 = 66 65 -- -- -- -- -- -- */ \
781 pslldq_i2r(8, xmm1); /* xmm1 = -- -- 67 64 -- -- -- -- */ \
782 por_r2r(xmm7, xmm3); /* xmm3 = 77 75 74 -- -- -- -- 34 */ \
784 psrldq_i2r(6, xmm0); /* xmm0 = -- -- -- 66 65 -- -- -- */ \
785 pslldq_i2r(4, xmm5); /* xmm5 = -- -- -- -- 54 51 -- -- */ \
787 por_r2r(xmm1, xmm4); /* xmm4 = 76 73 67 64 -- -- 35 33 */ \
788 por_r2r(xmm2, xmm3); /* xmm3 = 77 75 74 -- -- 53 52 34 */ \
790 por_r2r(xmm5, xmm4); /* xmm4 = 76 73 67 64 54 51 35 33 */ \
791 por_r2r(xmm0, xmm3); /* xmm3 = 77 75 74 66 65 53 52 34 */ \
793 movdqu_r2m(xmm4, *(eax+96)); /* write 76 73 67 64 54 51 35 33 */ \
794 movdqu_r2m(xmm3, *(eax+112)); /* write 77 75 74 66 65 53 52 34 */ \
796 } /* end of SSE2_Dequantize Macro */
799 void vp3_dsp_init_sse2(void)
805 static void vp3_idct_sse2(int16_t *input_data, int16_t *dequant_matrix,
806 int16_t *output_data)
808 unsigned char *input_bytes = (unsigned char *)input_data;
809 unsigned char *dequant_matrix_bytes = (unsigned char *)dequant_matrix;
810 unsigned char *dequant_const_bytes = (unsigned char *)SSE2_dequant_const;
811 unsigned char *output_data_bytes = (unsigned char *)output_data;
812 unsigned char *idct_data_bytes = (unsigned char *)SSE2_idct_data;
813 unsigned char *Eight = (unsigned char *)eight_data;
815 #define eax input_bytes
816 #define ebx dequant_matrix_bytes
817 #define ecx dequant_const_bytes
818 #define edx idct_data_bytes
820 #define I(i) (eax + 16 * i)
821 #define O(i) (ebx + 16 * i)
822 #define C(i) (edx + 16 * (i-1))
827 #define ebx output_data_bytes
837 void vp3_idct_put_sse2(int16_t *input_data, int16_t *dequant_matrix,
838 int coeff_count, uint8_t *dest, int stride)
840 int16_t transformed_data[64];
844 vp3_idct_sse2(input_data, dequant_matrix, transformed_data);
846 /* place in final output */
847 op = transformed_data;
848 for (i = 0; i < 8; i++) {
849 for (j = 0; j < 8; j++) {
855 *dest = (uint8_t)(*op + 128);
859 dest += (stride - 8);
864 void vp3_idct_add_sse2(int16_t *input_data, int16_t *dequant_matrix,
865 int coeff_count, uint8_t *dest, int stride)
867 int16_t transformed_data[64];
872 vp3_idct_sse2(input_data, dequant_matrix, transformed_data);
874 /* place in final output */
875 op = transformed_data;
876 for (i = 0; i < 8; i++) {
877 for (j = 0; j < 8; j++) {
878 sample = *dest + *op;
881 else if (sample > 255)
884 *dest = (uint8_t)(sample & 0xFF);
888 dest += (stride - 8);