Parent Directory
|
Revision Log
Revision 1104 - (view) (download)
1 : | chl | 460 | ;/***************************************************************************** |
2 : | ; * | ||
3 : | ; * XVID MPEG-4 VIDEO CODEC | ||
4 : | ; * mmx version - inverse discrete cosine transformation | ||
5 : | ; * | ||
6 : | ; * Initial version provided by Intel at AppNote AP-922 | ||
7 : | ; * Copyright (C) 1999 Intel Corporation, | ||
8 : | ; * | ||
9 : | ; * Modifications | ||
10 : | ; * Copyright (c) 2000-2001 Peter Gubanov <peter@elecard.net.ru> | ||
11 : | ; * Copyright (c) 2000 Michel Lespinasse <walken@zoy.org> | ||
12 : | ; * | ||
13 : | ; * ported to NASM and some minor changes | ||
14 : | ; * Copyright (C) 2001 Peter Ross <pross@xvid.org> | ||
15 : | ; * | ||
16 : | edgomez | 649 | ; * This file is part of XviD, a free MPEG-4 video encoder/decoder |
17 : | chl | 460 | ; * |
18 : | edgomez | 649 | ; * XviD is free software; you can redistribute it and/or modify it |
19 : | ; * under the terms of the GNU General Public License as published by | ||
20 : | chl | 460 | ; * the Free Software Foundation; either version 2 of the License, or |
21 : | ; * (at your option) any later version. | ||
22 : | ; * | ||
23 : | ; * This program is distributed in the hope that it will be useful, | ||
24 : | ; * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
25 : | ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
26 : | ; * GNU General Public License for more details. | ||
27 : | ; * | ||
28 : | ; * You should have received a copy of the GNU General Public License | ||
29 : | ; * along with this program; if not, write to the Free Software | ||
30 : | ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
31 : | ; * | ||
32 : | edgomez | 649 | ; * Under section 8 of the GNU General Public License, the copyright |
33 : | ; * holders of XVID explicitly forbid distribution in the following | ||
34 : | ; * countries: | ||
35 : | ; * | ||
36 : | ; * - Japan | ||
37 : | ; * - United States of America | ||
38 : | ; * | ||
39 : | ; * Linking XviD statically or dynamically with other modules is making a | ||
40 : | ; * combined work based on XviD. Thus, the terms and conditions of the | ||
41 : | ; * GNU General Public License cover the whole combination. | ||
42 : | ; * | ||
43 : | ; * As a special exception, the copyright holders of XviD give you | ||
44 : | ; * permission to link XviD with independent modules that communicate with | ||
45 : | ; * XviD solely through the VFW1.1 and DShow interfaces, regardless of the | ||
46 : | ; * license terms of these independent modules, and to copy and distribute | ||
47 : | ; * the resulting combined work under terms of your choice, provided that | ||
48 : | ; * every copy of the combined work is accompanied by a complete copy of | ||
49 : | ; * the source code of XviD (the version of XviD used to produce the | ||
50 : | ; * combined work), being distributed under the terms of the GNU General | ||
51 : | ; * Public License plus this exception. An independent module is a module | ||
52 : | ; * which is not derived from or based on XviD. | ||
53 : | ; * | ||
54 : | ; * Note that people who make modified versions of XviD are not obligated | ||
55 : | ; * to grant this special exception for their modified versions; it is | ||
56 : | ; * their choice whether to do so. The GNU General Public License gives | ||
57 : | ; * permission to release a modified version without this exception; this | ||
58 : | ; * exception also makes it possible to release a modified version which | ||
59 : | ; * carries forward this exception. | ||
60 : | ; * | ||
61 : | ; * $Id: idct_mmx.asm,v 1.5 2002-11-16 23:51:58 edgomez Exp $ | ||
62 : | ; * | ||
63 : | chl | 460 | ; *************************************************************************/ |
64 : | |||
65 : | Isibaar | 3 | ;============================================================================= |
66 : | ; | ||
67 : | ; These examples contain code fragments for first stage iDCT 8x8 | ||
68 : | ; (for rows) and first stage DCT 8x8 (for columns) | ||
69 : | ; | ||
70 : | ;============================================================================= | ||
71 : | |||
72 : | bits 32 | ||
73 : | |||
74 : | %macro cglobal 1 | ||
75 : | %ifdef PREFIX | ||
76 : | global _%1 | ||
77 : | %define %1 _%1 | ||
78 : | %else | ||
79 : | global %1 | ||
80 : | %endif | ||
81 : | %endmacro | ||
82 : | |||
83 : | %define BITS_INV_ACC 5 ; 4 or 5 for IEEE | ||
84 : | %define SHIFT_INV_ROW 16 - BITS_INV_ACC | ||
85 : | %define SHIFT_INV_COL 1 + BITS_INV_ACC | ||
86 : | %define RND_INV_ROW 1024 * (6 - BITS_INV_ACC) ; 1 << (SHIFT_INV_ROW-1) | ||
87 : | %define RND_INV_COL 16 * (BITS_INV_ACC - 3) ; 1 << (SHIFT_INV_COL-1) | ||
88 : | %define RND_INV_CORR RND_INV_COL - 1 ; correction -1.0 and round | ||
89 : | |||
90 : | %define BITS_FRW_ACC 3 ; 2 or 3 for accuracy | ||
91 : | %define SHIFT_FRW_COL BITS_FRW_ACC | ||
92 : | %define SHIFT_FRW_ROW BITS_FRW_ACC + 17 | ||
93 : | %define RND_FRW_ROW 262144 * (BITS_FRW_ACC - 1) ; 1 << (SHIFT_FRW_ROW-1) | ||
94 : | |||
95 : | suxen_drol | 207 | %ifdef FORMAT_COFF |
96 : | section .data data | ||
97 : | %else | ||
98 : | Isibaar | 154 | section .data data align=16 |
99 : | suxen_drol | 207 | %endif |
100 : | Isibaar | 3 | |
101 : | align 16 | ||
102 : | |||
103 : | one_corr dw 1, 1, 1, 1 | ||
104 : | round_inv_row dd RND_INV_ROW, RND_INV_ROW | ||
105 : | round_inv_col dw RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL | ||
106 : | round_inv_corr dw RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR | ||
107 : | round_frw_row dd RND_FRW_ROW, RND_FRW_ROW | ||
108 : | tg_1_16 dw 13036, 13036, 13036, 13036 ; tg * (2<<16) + 0.5 | ||
109 : | tg_2_16 dw 27146, 27146, 27146, 27146 ; tg * (2<<16) + 0.5 | ||
110 : | tg_3_16 dw -21746, -21746, -21746, -21746 ; tg * (2<<16) + 0.5 | ||
111 : | cos_4_16 dw -19195, -19195, -19195, -19195 ; cos * (2<<16) + 0.5 | ||
112 : | ocos_4_16 dw 23170, 23170, 23170, 23170 ; cos * (2<<15) + 0.5 | ||
113 : | |||
114 : | otg_3_16 dw 21895, 21895, 21895, 21895 ; tg * (2<<16) + 0.5 | ||
115 : | |||
116 : | %if SHIFT_INV_ROW == 12 ; assume SHIFT_INV_ROW == 12 | ||
117 : | rounder_0 dd 65536, 65536 | ||
118 : | rounder_4 dd 0, 0 | ||
119 : | rounder_1 dd 7195, 7195 | ||
120 : | rounder_7 dd 1024, 1024 | ||
121 : | rounder_2 dd 4520, 4520 | ||
122 : | rounder_6 dd 1024, 1024 | ||
123 : | rounder_3 dd 2407, 2407 | ||
124 : | rounder_5 dd 240, 240 | ||
125 : | |||
126 : | %elif SHIFT_INV_ROW == 11 ; assume SHIFT_INV_ROW == 11 | ||
127 : | rounder_0 dd 65536, 65536 | ||
128 : | rounder_4 dd 0, 0 | ||
129 : | rounder_1 dd 3597, 3597 | ||
130 : | rounder_7 dd 512, 512 | ||
131 : | rounder_2 dd 2260, 2260 | ||
132 : | rounder_6 dd 512, 512 | ||
133 : | rounder_3 dd 1203, 1203 | ||
134 : | rounder_5 dd 120, 120 | ||
135 : | %else | ||
136 : | |||
137 : | %error invalid _SHIFT_INV_ROW_ | ||
138 : | |||
139 : | %endif | ||
140 : | |||
141 : | ;============================================================================= | ||
142 : | ; | ||
143 : | ; The first stage iDCT 8x8 - inverse DCTs of rows | ||
144 : | ; | ||
145 : | ;----------------------------------------------------------------------------- | ||
146 : | ; The 8-point inverse DCT direct algorithm | ||
147 : | ;----------------------------------------------------------------------------- | ||
148 : | ; | ||
149 : | ; static const short w[32] = { | ||
150 : | ; FIX(cos_4_16), FIX(cos_2_16), FIX(cos_4_16), FIX(cos_6_16), | ||
151 : | ; FIX(cos_4_16), FIX(cos_6_16), -FIX(cos_4_16), -FIX(cos_2_16), | ||
152 : | ; FIX(cos_4_16), -FIX(cos_6_16), -FIX(cos_4_16), FIX(cos_2_16), | ||
153 : | ; FIX(cos_4_16), -FIX(cos_2_16), FIX(cos_4_16), -FIX(cos_6_16), | ||
154 : | ; FIX(cos_1_16), FIX(cos_3_16), FIX(cos_5_16), FIX(cos_7_16), | ||
155 : | ; FIX(cos_3_16), -FIX(cos_7_16), -FIX(cos_1_16), -FIX(cos_5_16), | ||
156 : | ; FIX(cos_5_16), -FIX(cos_1_16), FIX(cos_7_16), FIX(cos_3_16), | ||
157 : | ; FIX(cos_7_16), -FIX(cos_5_16), FIX(cos_3_16), -FIX(cos_1_16) }; | ||
158 : | ; | ||
159 : | ; #define DCT_8_INV_ROW(x, y) | ||
160 : | ; { | ||
161 : | ; int a0, a1, a2, a3, b0, b1, b2, b3; | ||
162 : | ; | ||
163 : | ; a0 =x[0]*w[0]+x[2]*w[1]+x[4]*w[2]+x[6]*w[3]; | ||
164 : | ; a1 =x[0]*w[4]+x[2]*w[5]+x[4]*w[6]+x[6]*w[7]; | ||
165 : | ; a2 = x[0] * w[ 8] + x[2] * w[ 9] + x[4] * w[10] + x[6] * w[11]; | ||
166 : | ; a3 = x[0] * w[12] + x[2] * w[13] + x[4] * w[14] + x[6] * w[15]; | ||
167 : | ; b0 = x[1] * w[16] + x[3] * w[17] + x[5] * w[18] + x[7] * w[19]; | ||
168 : | ; b1 = x[1] * w[20] + x[3] * w[21] + x[5] * w[22] + x[7] * w[23]; | ||
169 : | ; b2 = x[1] * w[24] + x[3] * w[25] + x[5] * w[26] + x[7] * w[27]; | ||
170 : | ; b3 = x[1] * w[28] + x[3] * w[29] + x[5] * w[30] + x[7] * w[31]; | ||
171 : | ; | ||
172 : | ; y[0] = SHIFT_ROUND ( a0 + b0 ); | ||
173 : | ; y[1] = SHIFT_ROUND ( a1 + b1 ); | ||
174 : | ; y[2] = SHIFT_ROUND ( a2 + b2 ); | ||
175 : | ; y[3] = SHIFT_ROUND ( a3 + b3 ); | ||
176 : | ; y[4] = SHIFT_ROUND ( a3 - b3 ); | ||
177 : | ; y[5] = SHIFT_ROUND ( a2 - b2 ); | ||
178 : | ; y[6] = SHIFT_ROUND ( a1 - b1 ); | ||
179 : | ; y[7] = SHIFT_ROUND ( a0 - b0 ); | ||
180 : | ; } | ||
181 : | ; | ||
182 : | ;----------------------------------------------------------------------------- | ||
183 : | ; | ||
184 : | ; In this implementation the outputs of the iDCT-1D are multiplied | ||
185 : | ; for rows 0,4 - by cos_4_16, | ||
186 : | ; for rows 1,7 - by cos_1_16, | ||
187 : | ; for rows 2,6 - by cos_2_16, | ||
188 : | ; for rows 3,5 - by cos_3_16 | ||
189 : | ; and are shifted to the left for better accuracy | ||
190 : | ; | ||
191 : | ; For the constants used, | ||
192 : | ; FIX(float_const) = (short) (float_const * (1<<15) + 0.5) | ||
193 : | ; | ||
194 : | ;============================================================================= | ||
195 : | |||
196 : | ;============================================================================= | ||
197 : | ; MMX code | ||
198 : | ;============================================================================= | ||
199 : | |||
200 : | ; Table for rows 0,4 - constants are multiplied by cos_4_16 | ||
201 : | |||
202 : | tab_i_04 dw 16384, 16384, 16384, -16384 ; movq-> w06 w04 w02 w00 | ||
203 : | dw 21407, 8867, 8867, -21407 ; w07 w05 w03 w01 | ||
204 : | dw 16384, -16384, 16384, 16384 ; w14 w12 w10 w08 | ||
205 : | dw -8867, 21407, -21407, -8867 ; w15 w13 w11 w09 | ||
206 : | dw 22725, 12873, 19266, -22725 ; w22 w20 w18 w16 | ||
207 : | dw 19266, 4520, -4520, -12873 ; w23 w21 w19 w17 | ||
208 : | dw 12873, 4520, 4520, 19266 ; w30 w28 w26 w24 | ||
209 : | dw -22725, 19266, -12873, -22725 ; w31 w29 w27 w25 | ||
210 : | |||
211 : | ; Table for rows 1,7 - constants are multiplied by cos_1_16 | ||
212 : | |||
213 : | tab_i_17 dw 22725, 22725, 22725, -22725 ; movq-> w06 w04 w02 w00 | ||
214 : | dw 29692, 12299, 12299, -29692 ; w07 w05 w03 w01 | ||
215 : | dw 22725, -22725, 22725, 22725 ; w14 w12 w10 w08 | ||
216 : | dw -12299, 29692, -29692, -12299 ; w15 w13 w11 w09 | ||
217 : | dw 31521, 17855, 26722, -31521 ; w22 w20 w18 w16 | ||
218 : | dw 26722, 6270, -6270, -17855 ; w23 w21 w19 w17 | ||
219 : | dw 17855, 6270, 6270, 26722 ; w30 w28 w26 w24 | ||
220 : | dw -31521, 26722, -17855, -31521 ; w31 w29 w27 w25 | ||
221 : | |||
222 : | ; Table for rows 2,6 - constants are multiplied by cos_2_16 | ||
223 : | |||
224 : | tab_i_26 dw 21407, 21407, 21407, -21407 ; movq-> w06 w04 w02 w00 | ||
225 : | dw 27969, 11585, 11585, -27969 ; w07 w05 w03 w01 | ||
226 : | dw 21407, -21407, 21407, 21407 ; w14 w12 w10 w08 | ||
227 : | dw -11585, 27969, -27969, -11585 ; w15 w13 w11 w09 | ||
228 : | dw 29692, 16819, 25172, -29692 ; w22 w20 w18 w16 | ||
229 : | dw 25172, 5906, -5906, -16819 ; w23 w21 w19 w17 | ||
230 : | dw 16819, 5906, 5906, 25172 ; w30 w28 w26 w24 | ||
231 : | dw -29692, 25172, -16819, -29692 ; w31 w29 w27 w25 | ||
232 : | |||
233 : | ; Table for rows 3,5 - constants are multiplied by cos_3_16 | ||
234 : | |||
235 : | tab_i_35 dw 19266, 19266, 19266, -19266 ; movq-> w06 w04 w02 w00 | ||
236 : | dw 25172, 10426, 10426, -25172 ; w07 w05 w03 w01 | ||
237 : | dw 19266, -19266, 19266, 19266 ; w14 w12 w10 w08 | ||
238 : | dw -10426, 25172, -25172, -10426 ; w15 w13 w11 w09 | ||
239 : | dw 26722, 15137, 22654, -26722 ; w22 w20 w18 w16 | ||
240 : | dw 22654, 5315, -5315, -15137 ; w23 w21 w19 w17 | ||
241 : | dw 15137, 5315, 5315, 22654 ; w30 w28 w26 w24 | ||
242 : | dw -26722, 22654, -15137, -26722 ; w31 w29 w27 w25 | ||
243 : | |||
244 : | ;----------------------------------------------------------------------------- | ||
245 : | |||
246 : | ; | ||
247 : | ; DCT_8_INV_ROW_1 INP, OUT, TABLE, ROUNDER | ||
248 : | ; | ||
249 : | |||
250 : | %macro DCT_8_INV_ROW_1 4 | ||
251 : | |||
252 : | movq mm0, [%1] ; 0 ; x3 x2 x1 x0 | ||
253 : | |||
254 : | movq mm1, [%1+8] ; 1 ; x7 x6 x5 x4 | ||
255 : | movq mm2, mm0 ; 2 ; x3 x2 x1 x0 | ||
256 : | |||
257 : | movq mm3, [%3] ; 3 ; w06 w04 w02 w00 | ||
258 : | punpcklwd mm0, mm1 ; x5 x1 x4 x0 | ||
259 : | |||
260 : | movq mm5, mm0 ; 5 ; x5 x1 x4 x0 | ||
261 : | punpckldq mm0, mm0 ; x4 x0 x4 x0 | ||
262 : | |||
263 : | movq mm4, [%3+8] ; 4 ; w07 w05 w03 w01 | ||
264 : | punpckhwd mm2, mm1 ; 1 ; x7 x3 x6 x2 | ||
265 : | |||
266 : | pmaddwd mm3, mm0 ; x4*w06+x0*w04 x4*w02+x0*w00 | ||
267 : | movq mm6, mm2 ; 6 ; x7 x3 x6 x2 | ||
268 : | |||
269 : | movq mm1, [%3+32] ; 1 ; w22 w20 w18 w16 | ||
270 : | punpckldq mm2, mm2 ; x6 x2 x6 x2 | ||
271 : | |||
272 : | pmaddwd mm4, mm2 ; x6*w07+x2*w05 x6*w03+x2*w01 | ||
273 : | punpckhdq mm5, mm5 ; x5 x1 x5 x1 | ||
274 : | |||
275 : | pmaddwd mm0, [%3+16] ; x4*w14+x0*w12 x4*w10+x0*w08 | ||
276 : | punpckhdq mm6, mm6 ; x7 x3 x7 x3 | ||
277 : | |||
278 : | movq mm7, [%3+40] ; 7 ; w23 w21 w19 w17 | ||
279 : | pmaddwd mm1, mm5 ; x5*w22+x1*w20 x5*w18+x1*w16 | ||
280 : | |||
281 : | paddd mm3, [%4] ; +%4 | ||
282 : | pmaddwd mm7, mm6 ; x7*w23+x3*w21 x7*w19+x3*w17 | ||
283 : | |||
284 : | pmaddwd mm2, [%3+24] ; x6*w15+x2*w13 x6*w11+x2*w09 | ||
285 : | paddd mm3, mm4 ; 4 ; a1=sum(even1) a0=sum(even0) | ||
286 : | |||
287 : | pmaddwd mm5, [%3+48] ; x5*w30+x1*w28 x5*w26+x1*w24 | ||
288 : | movq mm4, mm3 ; 4 ; a1 a0 | ||
289 : | |||
290 : | pmaddwd mm6, [%3+56] ; x7*w31+x3*w29 x7*w27+x3*w25 | ||
291 : | paddd mm1, mm7 ; 7 ; b1=sum(odd1) b0=sum(odd0) | ||
292 : | |||
293 : | paddd mm0, [%4] ; +%4 | ||
294 : | psubd mm3, mm1 ; a1-b1 a0-b0 | ||
295 : | |||
296 : | psrad mm3, SHIFT_INV_ROW ; y6=a1-b1 y7=a0-b0 | ||
297 : | paddd mm1, mm4 ; 4 ; a1+b1 a0+b0 | ||
298 : | |||
299 : | paddd mm0, mm2 ; 2 ; a3=sum(even3) a2=sum(even2) | ||
300 : | psrad mm1, SHIFT_INV_ROW ; y1=a1+b1 y0=a0+b0 | ||
301 : | |||
302 : | paddd mm5, mm6 ; 6 ; b3=sum(odd3) b2=sum(odd2) | ||
303 : | movq mm4, mm0 ; 4 ; a3 a2 | ||
304 : | |||
305 : | paddd mm0, mm5 ; a3+b3 a2+b2 | ||
306 : | psubd mm4, mm5 ; 5 ; a3-b3 a2-b2 | ||
307 : | |||
308 : | psrad mm0, SHIFT_INV_ROW ; y3=a3+b3 y2=a2+b2 | ||
309 : | psrad mm4, SHIFT_INV_ROW ; y4=a3-b3 y5=a2-b2 | ||
310 : | |||
311 : | packssdw mm1, mm0 ; 0 ; y3 y2 y1 y0 | ||
312 : | packssdw mm4, mm3 ; 3 ; y6 y7 y4 y5 | ||
313 : | |||
314 : | movq mm7, mm4 ; 7 ; y6 y7 y4 y5 | ||
315 : | psrld mm4, 16 ; 0 y6 0 y4 | ||
316 : | |||
317 : | pslld mm7, 16 ; y7 0 y5 0 | ||
318 : | movq [%2], mm1 ; 1 ; save y3 y2 y1 y0 | ||
319 : | |||
320 : | por mm7, mm4 ; 4 ; y7 y6 y5 y4 | ||
321 : | movq [%2+8], mm7 ; 7 ; save y7 y6 y5 y4 | ||
322 : | %endmacro | ||
323 : | |||
324 : | |||
325 : | |||
326 : | |||
327 : | ;============================================================================= | ||
328 : | ; code for Pentium III | ||
329 : | ;============================================================================= | ||
330 : | |||
331 : | ; %3 for rows 0,4 - constants are multiplied by cos_4_16 | ||
332 : | |||
333 : | tab_i_04_sse dw 16384, 21407, 16384, 8867 ; movq-> w05 w04 w01 w00 | ||
334 : | dw 16384, 8867, -16384, -21407 ; w07 w06 w03 w02 | ||
335 : | dw 16384, -8867, 16384, -21407 ; w13 w12 w09 w08 | ||
336 : | dw -16384, 21407, 16384, -8867 ; w15 w14 w11 w10 | ||
337 : | dw 22725, 19266, 19266, -4520 ; w21 w20 w17 w16 | ||
338 : | dw 12873, 4520, -22725, -12873 ; w23 w22 w19 w18 | ||
339 : | dw 12873, -22725, 4520, -12873 ; w29 w28 w25 w24 | ||
340 : | dw 4520, 19266, 19266, -22725 ; w31 w30 w27 w26 | ||
341 : | |||
342 : | ; %3 for rows 1,7 - constants are multiplied by cos_1_16 | ||
343 : | |||
344 : | tab_i_17_sse dw 22725, 29692, 22725, 12299 ; movq-> w05 w04 w01 w00 | ||
345 : | dw 22725, 12299, -22725, -29692 ; w07 w06 w03 w02 | ||
346 : | dw 22725, -12299, 22725, -29692 ; w13 w12 w09 w08 | ||
347 : | dw -22725, 29692, 22725, -12299 ; w15 w14 w11 w10 | ||
348 : | dw 31521, 26722, 26722, -6270 ; w21 w20 w17 w16 | ||
349 : | dw 17855, 6270, -31521, -17855 ; w23 w22 w19 w18 | ||
350 : | dw 17855, -31521, 6270, -17855 ; w29 w28 w25 w24 | ||
351 : | dw 6270, 26722, 26722, -31521 ; w31 w30 w27 w26 | ||
352 : | |||
353 : | ; %3 for rows 2,6 - constants are multiplied by cos_2_16 | ||
354 : | |||
355 : | tab_i_26_sse dw 21407, 27969, 21407, 11585 ; movq-> w05 w04 w01 w00 | ||
356 : | dw 21407, 11585, -21407, -27969 ; w07 w06 w03 w02 | ||
357 : | dw 21407, -11585, 21407, -27969 ; w13 w12 w09 w08 | ||
358 : | dw -21407, 27969, 21407, -11585 ; w15 w14 w11 w10 | ||
359 : | dw 29692, 25172, 25172, -5906 ; w21 w20 w17 w16 | ||
360 : | dw 16819, 5906, -29692, -16819 ; w23 w22 w19 w18 | ||
361 : | dw 16819, -29692, 5906, -16819 ; w29 w28 w25 w24 | ||
362 : | dw 5906, 25172, 25172, -29692 ; w31 w30 w27 w26 | ||
363 : | |||
364 : | ; %3 for rows 3,5 - constants are multiplied by cos_3_16 | ||
365 : | |||
366 : | tab_i_35_sse dw 19266, 25172, 19266, 10426 ; movq-> w05 w04 w01 w00 | ||
367 : | dw 19266, 10426, -19266, -25172 ; w07 w06 w03 w02 | ||
368 : | dw 19266, -10426, 19266, -25172 ; w13 w12 w09 w08 | ||
369 : | dw -19266, 25172, 19266, -10426 ; w15 w14 w11 w10 | ||
370 : | dw 26722, 22654, 22654, -5315 ; w21 w20 w17 w16 | ||
371 : | dw 15137, 5315, -26722, -15137 ; w23 w22 w19 w18 | ||
372 : | dw 15137, -26722, 5315, -15137 ; w29 w28 w25 w24 | ||
373 : | dw 5315, 22654, 22654, -26722 ; w31 w30 w27 w26 | ||
374 : | |||
375 : | ;----------------------------------------------------------------------------- | ||
376 : | |||
377 : | ; | ||
378 : | ; DCT_8_INV_ROW_1_sse INP, OUT, TABLE, ROUNDER | ||
379 : | ; | ||
380 : | |||
381 : | %macro DCT_8_INV_ROW_1_sse 4 | ||
382 : | |||
383 : | movq mm0, [%1] ; 0 ; x3 x2 x1 x0 | ||
384 : | |||
385 : | movq mm1, [%1+8] ; 1 ; x7 x6 x5 x4 | ||
386 : | movq mm2, mm0 ; 2 ; x3 x2 x1 x0 | ||
387 : | |||
388 : | movq mm3, [%3] ; 3 ; w05 w04 w01 w00 | ||
389 : | pshufw mm0, mm0, 10001000b ; x2 x0 x2 x0 | ||
390 : | |||
391 : | movq mm4, [%3+8] ; 4 ; w07 w06 w03 w02 | ||
392 : | movq mm5, mm1 ; 5 ; x7 x6 x5 x4 | ||
393 : | pmaddwd mm3, mm0 ; x2*w05+x0*w04 x2*w01+x0*w00 | ||
394 : | |||
395 : | movq mm6, [%3+32] ; 6 ; w21 w20 w17 w16 | ||
396 : | pshufw mm1, mm1, 10001000b ; x6 x4 x6 x4 | ||
397 : | pmaddwd mm4, mm1 ; x6*w07+x4*w06 x6*w03+x4*w02 | ||
398 : | |||
399 : | movq mm7, [%3+40] ; 7 ; w23 w22 w19 w18 | ||
400 : | pshufw mm2, mm2, 11011101b ; x3 x1 x3 x1 | ||
401 : | pmaddwd mm6, mm2 ; x3*w21+x1*w20 x3*w17+x1*w16 | ||
402 : | |||
403 : | pshufw mm5, mm5, 11011101b ; x7 x5 x7 x5 | ||
404 : | pmaddwd mm7, mm5 ; x7*w23+x5*w22 x7*w19+x5*w18 | ||
405 : | |||
406 : | paddd mm3, [%4] ; +%4 | ||
407 : | |||
408 : | pmaddwd mm0, [%3+16] ; x2*w13+x0*w12 x2*w09+x0*w08 | ||
409 : | paddd mm3, mm4 ; 4 ; a1=sum(even1) a0=sum(even0) | ||
410 : | |||
411 : | pmaddwd mm1, [%3+24] ; x6*w15+x4*w14 x6*w11+x4*w10 | ||
412 : | movq mm4, mm3 ; 4 ; a1 a0 | ||
413 : | |||
414 : | pmaddwd mm2, [%3+48] ; x3*w29+x1*w28 x3*w25+x1*w24 | ||
415 : | paddd mm6, mm7 ; 7 ; b1=sum(odd1) b0=sum(odd0) | ||
416 : | |||
417 : | pmaddwd mm5, [%3+56] ; x7*w31+x5*w30 x7*w27+x5*w26 | ||
418 : | paddd mm3, mm6 ; a1+b1 a0+b0 | ||
419 : | |||
420 : | paddd mm0, [%4] ; +%4 | ||
421 : | psrad mm3, SHIFT_INV_ROW ; y1=a1+b1 y0=a0+b0 | ||
422 : | |||
423 : | paddd mm0, mm1 ; 1 ; a3=sum(even3) a2=sum(even2) | ||
424 : | psubd mm4, mm6 ; 6 ; a1-b1 a0-b0 | ||
425 : | |||
426 : | movq mm7, mm0 ; 7 ; a3 a2 | ||
427 : | paddd mm2, mm5 ; 5 ; b3=sum(odd3) b2=sum(odd2) | ||
428 : | |||
429 : | paddd mm0, mm2 ; a3+b3 a2+b2 | ||
430 : | psrad mm4, SHIFT_INV_ROW ; y6=a1-b1 y7=a0-b0 | ||
431 : | |||
432 : | psubd mm7, mm2 ; 2 ; a3-b3 a2-b2 | ||
433 : | psrad mm0, SHIFT_INV_ROW ; y3=a3+b3 y2=a2+b2 | ||
434 : | |||
435 : | psrad mm7, SHIFT_INV_ROW ; y4=a3-b3 y5=a2-b2 | ||
436 : | |||
437 : | packssdw mm3, mm0 ; 0 ; y3 y2 y1 y0 | ||
438 : | |||
439 : | packssdw mm7, mm4 ; 4 ; y6 y7 y4 y5 | ||
440 : | |||
441 : | movq [%2], mm3 ; 3 ; save y3 y2 y1 y0 | ||
442 : | pshufw mm7, mm7, 10110001b ; y7 y6 y5 y4 | ||
443 : | |||
444 : | movq [%2+8], mm7 ; 7 ; save y7 y6 y5 y4 | ||
445 : | |||
446 : | %endmacro | ||
447 : | |||
448 : | |||
449 : | ;============================================================================= | ||
450 : | ; | ||
451 : | ;============================================================================= | ||
452 : | |||
453 : | ;============================================================================= | ||
454 : | ; | ||
455 : | ; The first stage DCT 8x8 - forward DCTs of columns | ||
456 : | ; | ||
457 : | ; The %2puts are multiplied | ||
458 : | ; for rows 0,4 - on cos_4_16, | ||
459 : | ; for rows 1,7 - on cos_1_16, | ||
460 : | ; for rows 2,6 - on cos_2_16, | ||
461 : | ; for rows 3,5 - on cos_3_16 | ||
462 : | ; and are shifted to the left for rise of accuracy | ||
463 : | ; | ||
464 : | ;----------------------------------------------------------------------------- | ||
465 : | ; | ||
466 : | ; The 8-point scaled forward DCT algorithm (26a8m) | ||
467 : | ; | ||
468 : | ;----------------------------------------------------------------------------- | ||
469 : | ; | ||
470 : | ; #define DCT_8_FRW_COL(x, y) | ||
471 : | ;{ | ||
472 : | ; short t0, t1, t2, t3, t4, t5, t6, t7; | ||
473 : | ; short tp03, tm03, tp12, tm12, tp65, tm65; | ||
474 : | ; short tp465, tm465, tp765, tm765; | ||
475 : | ; | ||
476 : | ; t0 = LEFT_SHIFT ( x[0] + x[7] ); | ||
477 : | ; t1 = LEFT_SHIFT ( x[1] + x[6] ); | ||
478 : | ; t2 = LEFT_SHIFT ( x[2] + x[5] ); | ||
479 : | ; t3 = LEFT_SHIFT ( x[3] + x[4] ); | ||
480 : | ; t4 = LEFT_SHIFT ( x[3] - x[4] ); | ||
481 : | ; t5 = LEFT_SHIFT ( x[2] - x[5] ); | ||
482 : | ; t6 = LEFT_SHIFT ( x[1] - x[6] ); | ||
483 : | ; t7 = LEFT_SHIFT ( x[0] - x[7] ); | ||
484 : | ; | ||
485 : | ; tp03 = t0 + t3; | ||
486 : | ; tm03 = t0 - t3; | ||
487 : | ; tp12 = t1 + t2; | ||
488 : | ; tm12 = t1 - t2; | ||
489 : | ; | ||
490 : | ; y[0] = tp03 + tp12; | ||
491 : | ; y[4] = tp03 - tp12; | ||
492 : | ; | ||
493 : | ; y[2] = tm03 + tm12 * tg_2_16; | ||
494 : | ; y[6] = tm03 * tg_2_16 - tm12; | ||
495 : | ; | ||
496 : | ; tp65 =(t6 +t5 )*cos_4_16; | ||
497 : | ; tm65 =(t6 -t5 )*cos_4_16; | ||
498 : | ; | ||
499 : | ; tp765 = t7 + tp65; | ||
500 : | ; tm765 = t7 - tp65; | ||
501 : | ; tp465 = t4 + tm65; | ||
502 : | ; tm465 = t4 - tm65; | ||
503 : | ; | ||
504 : | ; y[1] = tp765 + tp465 * tg_1_16; | ||
505 : | ; y[7] = tp765 * tg_1_16 - tp465; | ||
506 : | ; y[5] = tm765 * tg_3_16 + tm465; | ||
507 : | ; y[3] = tm765 - tm465 * tg_3_16; | ||
508 : | ;} | ||
509 : | ; | ||
510 : | ;============================================================================= | ||
511 : | |||
512 : | |||
513 : | ; | ||
514 : | ; DCT_8_FRW_COL_4 INP, OUT | ||
515 : | ; | ||
516 : | |||
517 : | %macro DCT_8_FRW_COL_4 2 | ||
518 : | |||
519 : | LOCAL x0, x1, x2, x3, x4, x5, x6, x7 | ||
520 : | LOCAL y0, y1, y2, y3, y4, y5, y6, y7 | ||
521 : | x0 equ [%1 + 0*16] | ||
522 : | x1 equ [%1 + 1*16] | ||
523 : | x2 equ [%1 + 2*16] | ||
524 : | x3 equ [%1 + 3*16] | ||
525 : | x4 equ [%1 + 4*16] | ||
526 : | x5 equ [%1 + 5*16] | ||
527 : | x6 equ [%1 + 6*16] | ||
528 : | x7 equ [%1 + 7*16] | ||
529 : | y0 equ [%2 + 0*16] | ||
530 : | y1 equ [%2 + 1*16] | ||
531 : | y2 equ [%2 + 2*16] | ||
532 : | y3 equ [%2 + 3*16] | ||
533 : | y4 equ [%2 + 4*16] | ||
534 : | y5 equ [%2 + 5*16] | ||
535 : | y6 equ [%2 + 6*16] | ||
536 : | y7 equ [%2 + 7*16] | ||
537 : | movq mm0, x1 ; 0 ; x1 | ||
538 : | movq mm1, x6 ; 1 ; x6 | ||
539 : | movq mm2, mm0 ; 2 ; x1 | ||
540 : | movq mm3, x2 ; 3 ; x2 | ||
541 : | paddsw mm0, mm1 ; t1 = x[1] + x[6] | ||
542 : | movq mm4, x5 ; 4 ; x5 | ||
543 : | psllw mm0, SHIFT_FRW_COL ; t1 | ||
544 : | movq mm5, x0 ; 5 ; x0 | ||
545 : | paddsw mm4, mm3 ; t2 = x[2] + x[5] | ||
546 : | paddsw mm5, x7 ; t0 = x[0] + x[7] | ||
547 : | psllw mm4, SHIFT_FRW_COL ; t2 | ||
548 : | movq mm6, mm0 ; 6 ; t1 | ||
549 : | psubsw mm2, mm1 ; 1 ; t6 = x[1] - x[6] | ||
550 : | movq mm1, [tg_2_16] ; 1 ; tg_2_16 | ||
551 : | psubsw mm0, mm4 ; tm12 = t1 - t2 | ||
552 : | movq mm7, x3 ; 7 ; x3 | ||
553 : | pmulhw mm1, mm0 ; tm12*tg_2_16 | ||
554 : | paddsw mm7, x4 ; t3 = x[3] + x[4] | ||
555 : | psllw mm5, SHIFT_FRW_COL ; t0 | ||
556 : | paddsw mm6, mm4 ; 4 ; tp12 = t1 + t2 | ||
557 : | psllw mm7, SHIFT_FRW_COL ; t3 | ||
558 : | movq mm4, mm5 ; 4 ; t0 | ||
559 : | psubsw mm5, mm7 ; tm03 = t0 - t3 | ||
560 : | paddsw mm1, mm5 ; y2 = tm03 + tm12*tg_2_16 | ||
561 : | paddsw mm4, mm7 ; 7 ; tp03 = t0 + t3 | ||
562 : | por mm1, [one_corr] ; correction y2 +0.5 | ||
563 : | psllw mm2, SHIFT_FRW_COL+1 ; t6 | ||
564 : | pmulhw mm5, [tg_2_16] ; tm03*tg_2_16 | ||
565 : | movq mm7, mm4 ; 7 ; tp03 | ||
566 : | psubsw mm3, x5 ; t5 = x[2] - x[5] | ||
567 : | psubsw mm4, mm6 ; y4 = tp03 - tp12 | ||
568 : | movq y2, mm1 ; 1 ; save y2 | ||
569 : | paddsw mm7, mm6 ; 6 ; y0 = tp03 + tp12 | ||
570 : | movq mm1, x3 ; 1 ; x3 | ||
571 : | psllw mm3, SHIFT_FRW_COL+1 ; t5 | ||
572 : | psubsw mm1, x4 ; t4 = x[3] - x[4] | ||
573 : | movq mm6, mm2 ; 6 ; t6 | ||
574 : | movq y4, mm4 ; 4 ; save y4 | ||
575 : | paddsw mm2, mm3 ; t6 + t5 | ||
576 : | pmulhw mm2, [ocos_4_16] ; tp65 = (t6 + t5)*cos_4_16 | ||
577 : | psubsw mm6, mm3 ; 3 ; t6 - t5 | ||
578 : | pmulhw mm6, [ocos_4_16] ; tm65 = (t6 - t5)*cos_4_16 | ||
579 : | psubsw mm5, mm0 ; 0 ; y6 = tm03*tg_2_16 - tm12 | ||
580 : | por mm5, [one_corr] ; correction y6 +0.5 | ||
581 : | psllw mm1, SHIFT_FRW_COL ; t4 | ||
582 : | por mm2, [one_corr] ; correction tp65 +0.5 | ||
583 : | movq mm4, mm1 ; 4 ; t4 | ||
584 : | movq mm3, x0 ; 3 ; x0 | ||
585 : | paddsw mm1, mm6 ; tp465 = t4 + tm65 | ||
586 : | psubsw mm3, x7 ; t7 = x[0] - x[7] | ||
587 : | psubsw mm4, mm6 ; 6 ; tm465 = t4 - tm65 | ||
588 : | movq mm0, [tg_1_16] ; 0 ; tg_1_16 | ||
589 : | psllw mm3, SHIFT_FRW_COL ; t7 | ||
590 : | movq mm6, [tg_3_16] ; 6 ; tg_3_16 | ||
591 : | pmulhw mm0, mm1 ; tp465*tg_1_16 | ||
592 : | movq y0, mm7 ; 7 ; save y0 | ||
593 : | pmulhw mm6, mm4 ; tm465*tg_3_16 | ||
594 : | movq y6, mm5 ; 5 ; save y6 | ||
595 : | movq mm7, mm3 ; 7 ; t7 | ||
596 : | movq mm5, [tg_3_16] ; 5 ; tg_3_16 | ||
597 : | psubsw mm7, mm2 ; tm765 = t7 - tp65 | ||
598 : | paddsw mm3, mm2 ; 2 ; tp765 = t7 + tp65 | ||
599 : | pmulhw mm5, mm7 ; tm765*tg_3_16 | ||
600 : | paddsw mm0, mm3 ; y1 = tp765 + tp465*tg_1_16 | ||
601 : | paddsw mm6, mm4 ; tm465*tg_3_16 | ||
602 : | pmulhw mm3, [tg_1_16] ; tp765*tg_1_16 | ||
603 : | por mm0, [one_corr] ; correction y1 +0.5 | ||
604 : | paddsw mm5, mm7 ; tm765*tg_3_16 | ||
605 : | psubsw mm7, mm6 ; 6 ; y3 = tm765 - tm465*tg_3_16 | ||
606 : | movq y1, mm0 ; 0 ; save y1 | ||
607 : | paddsw mm5, mm4 ; 4 ; y5 = tm765*tg_3_16 + tm465 | ||
608 : | movq y3, mm7 ; 7 ; save y3 | ||
609 : | psubsw mm3, mm1 ; 1 ; y7 = tp765*tg_1_16 - tp465 | ||
610 : | movq y5, mm5 ; 5 ; save y5 | ||
611 : | movq y7, mm3 ; 3 ; save y7 | ||
612 : | %endmacro | ||
613 : | |||
614 : | |||
615 : | ; | ||
616 : | ; DCT_8_INV_COL_4 INP,OUT | ||
617 : | ; | ||
618 : | |||
619 : | %macro DCT_8_INV_COL_4 2 | ||
620 : | movq mm0, [tg_3_16] | ||
621 : | |||
622 : | movq mm3, [%1+16*3] | ||
623 : | movq mm1, mm0 ; tg_3_16 | ||
624 : | |||
625 : | movq mm5, [%1+16*5] | ||
626 : | pmulhw mm0, mm3 ; x3*(tg_3_16-1) | ||
627 : | |||
628 : | movq mm4, [tg_1_16] | ||
629 : | pmulhw mm1, mm5 ; x5*(tg_3_16-1) | ||
630 : | |||
631 : | movq mm7, [%1+16*7] | ||
632 : | movq mm2, mm4 ; tg_1_16 | ||
633 : | |||
634 : | movq mm6, [%1+16*1] | ||
635 : | pmulhw mm4, mm7 ; x7*tg_1_16 | ||
636 : | |||
637 : | paddsw mm0, mm3 ; x3*tg_3_16 | ||
638 : | pmulhw mm2, mm6 ; x1*tg_1_16 | ||
639 : | |||
640 : | paddsw mm1, mm3 ; x3+x5*(tg_3_16-1) | ||
641 : | psubsw mm0, mm5 ; x3*tg_3_16-x5 = tm35 | ||
642 : | |||
643 : | movq mm3, [ocos_4_16] | ||
644 : | paddsw mm1, mm5 ; x3+x5*tg_3_16 = tp35 | ||
645 : | |||
646 : | paddsw mm4, mm6 ; x1+tg_1_16*x7 = tp17 | ||
647 : | psubsw mm2, mm7 ; x1*tg_1_16-x7 = tm17 | ||
648 : | |||
649 : | movq mm5, mm4 ; tp17 | ||
650 : | movq mm6, mm2 ; tm17 | ||
651 : | |||
652 : | paddsw mm5, mm1 ; tp17+tp35 = b0 | ||
653 : | psubsw mm6, mm0 ; tm17-tm35 = b3 | ||
654 : | |||
655 : | psubsw mm4, mm1 ; tp17-tp35 = t1 | ||
656 : | paddsw mm2, mm0 ; tm17+tm35 = t2 | ||
657 : | |||
658 : | movq mm7, [tg_2_16] | ||
659 : | movq mm1, mm4 ; t1 | ||
660 : | |||
661 : | ; movq [SCRATCH+0], mm5 ; save b0 | ||
662 : | movq [%2+3*16], mm5 ; save b0 | ||
663 : | paddsw mm1, mm2 ; t1+t2 | ||
664 : | |||
665 : | ; movq [SCRATCH+8], mm6 ; save b3 | ||
666 : | movq [%2+5*16], mm6 ; save b3 | ||
667 : | psubsw mm4, mm2 ; t1-t2 | ||
668 : | |||
669 : | movq mm5, [%1+2*16] | ||
670 : | movq mm0, mm7 ; tg_2_16 | ||
671 : | |||
672 : | movq mm6, [%1+6*16] | ||
673 : | pmulhw mm0, mm5 ; x2*tg_2_16 | ||
674 : | |||
675 : | pmulhw mm7, mm6 ; x6*tg_2_16 | ||
676 : | ; slot | ||
677 : | pmulhw mm1, mm3 ; ocos_4_16*(t1+t2) = b1/2 | ||
678 : | ; slot | ||
679 : | movq mm2, [%1+0*16] | ||
680 : | pmulhw mm4, mm3 ; ocos_4_16*(t1-t2) = b2/2 | ||
681 : | |||
682 : | psubsw mm0, mm6 ; t2*tg_2_16-x6 = tm26 | ||
683 : | movq mm3, mm2 ; x0 | ||
684 : | |||
685 : | movq mm6, [%1+4*16] | ||
686 : | paddsw mm7, mm5 ; x2+x6*tg_2_16 = tp26 | ||
687 : | |||
688 : | paddsw mm2, mm6 ; x0+x4 = tp04 | ||
689 : | psubsw mm3, mm6 ; x0-x4 = tm04 | ||
690 : | |||
691 : | movq mm5, mm2 ; tp04 | ||
692 : | movq mm6, mm3 ; tm04 | ||
693 : | |||
694 : | psubsw mm2, mm7 ; tp04-tp26 = a3 | ||
695 : | paddsw mm3, mm0 ; tm04+tm26 = a1 | ||
696 : | |||
697 : | paddsw mm1, mm1 ; b1 | ||
698 : | paddsw mm4, mm4 ; b2 | ||
699 : | |||
700 : | paddsw mm5, mm7 ; tp04+tp26 = a0 | ||
701 : | psubsw mm6, mm0 ; tm04-tm26 = a2 | ||
702 : | |||
703 : | movq mm7, mm3 ; a1 | ||
704 : | movq mm0, mm6 ; a2 | ||
705 : | |||
706 : | paddsw mm3, mm1 ; a1+b1 | ||
707 : | paddsw mm6, mm4 ; a2+b2 | ||
708 : | |||
709 : | psraw mm3, SHIFT_INV_COL ; dst1 | ||
710 : | psubsw mm7, mm1 ; a1-b1 | ||
711 : | |||
712 : | psraw mm6, SHIFT_INV_COL ; dst2 | ||
713 : | psubsw mm0, mm4 ; a2-b2 | ||
714 : | |||
715 : | ; movq mm1, [SCRATCH+0] ; load b0 | ||
716 : | movq mm1, [%2+3*16] ; load b0 | ||
717 : | psraw mm7, SHIFT_INV_COL ; dst6 | ||
718 : | |||
719 : | movq mm4, mm5 ; a0 | ||
720 : | psraw mm0, SHIFT_INV_COL ; dst5 | ||
721 : | |||
722 : | movq [%2+1*16], mm3 | ||
723 : | paddsw mm5, mm1 ; a0+b0 | ||
724 : | |||
725 : | movq [%2+2*16], mm6 | ||
726 : | psubsw mm4, mm1 ; a0-b0 | ||
727 : | |||
728 : | ; movq mm3, [SCRATCH+8] ; load b3 | ||
729 : | movq mm3, [%2+5*16] ; load b3 | ||
730 : | psraw mm5, SHIFT_INV_COL ; dst0 | ||
731 : | |||
732 : | movq mm6, mm2 ; a3 | ||
733 : | psraw mm4, SHIFT_INV_COL ; dst7 | ||
734 : | |||
735 : | movq [%2+5*16], mm0 | ||
736 : | paddsw mm2, mm3 ; a3+b3 | ||
737 : | |||
738 : | movq [%2+6*16], mm7 | ||
739 : | psubsw mm6, mm3 ; a3-b3 | ||
740 : | |||
741 : | movq [%2+0*16], mm5 | ||
742 : | psraw mm2, SHIFT_INV_COL ; dst3 | ||
743 : | |||
744 : | movq [%2+7*16], mm4 | ||
745 : | psraw mm6, SHIFT_INV_COL ; dst4 | ||
746 : | |||
747 : | movq [%2+3*16], mm2 | ||
748 : | |||
749 : | movq [%2+4*16], mm6 | ||
750 : | %endmacro | ||
751 : | |||
752 : | |||
753 : | |||
754 : | section .text | ||
755 : | |||
756 : | ;============================================================================= | ||
757 : | ; | ||
758 : | ; void idct_mmx (short * const src_result); | ||
759 : | ; | ||
760 : | ;============================================================================= | ||
761 : | |||
762 : | align 16 | ||
763 : | cglobal idct_mmx | ||
764 : | idct_mmx | ||
765 : | mov eax, dword [esp + 4] | ||
766 : | |||
767 : | DCT_8_INV_ROW_1 eax+0, eax+0, tab_i_04, rounder_0 | ||
768 : | DCT_8_INV_ROW_1 eax+16, eax+16, tab_i_17, rounder_1 | ||
769 : | DCT_8_INV_ROW_1 eax+32, eax+32, tab_i_26, rounder_2 | ||
770 : | DCT_8_INV_ROW_1 eax+48, eax+48, tab_i_35, rounder_3 | ||
771 : | DCT_8_INV_ROW_1 eax+64, eax+64, tab_i_04, rounder_4 | ||
772 : | DCT_8_INV_ROW_1 eax+80, eax+80, tab_i_35, rounder_5 | ||
773 : | DCT_8_INV_ROW_1 eax+96, eax+96, tab_i_26, rounder_6 | ||
774 : | DCT_8_INV_ROW_1 eax+112, eax+112, tab_i_17, rounder_7 | ||
775 : | |||
776 : | DCT_8_INV_COL_4 eax+0,eax+0 | ||
777 : | DCT_8_INV_COL_4 eax+8,eax+8 | ||
778 : | |||
779 : | ret | ||
780 : | |||
781 : | |||
782 : | |||
783 : | ;============================================================================= | ||
784 : | ; | ||
785 : | ; void idct_sse (short * const src_result); | ||
786 : | ; | ||
787 : | ;============================================================================= | ||
788 : | |||
789 : | align 16 | ||
790 : | cglobal idct_xmm | ||
791 : | idct_xmm | ||
792 : | mov eax, dword [esp + 4] | ||
793 : | |||
794 : | DCT_8_INV_ROW_1_sse eax+0, eax+0, tab_i_04_sse, rounder_0 | ||
795 : | DCT_8_INV_ROW_1_sse eax+16, eax+16, tab_i_17_sse, rounder_1 | ||
796 : | DCT_8_INV_ROW_1_sse eax+32, eax+32, tab_i_26_sse, rounder_2 | ||
797 : | DCT_8_INV_ROW_1_sse eax+48, eax+48, tab_i_35_sse, rounder_3 | ||
798 : | DCT_8_INV_ROW_1_sse eax+64, eax+64, tab_i_04_sse, rounder_4 | ||
799 : | DCT_8_INV_ROW_1_sse eax+80, eax+80, tab_i_35_sse, rounder_5 | ||
800 : | DCT_8_INV_ROW_1_sse eax+96, eax+96, tab_i_26_sse, rounder_6 | ||
801 : | DCT_8_INV_ROW_1_sse eax+112, eax+112, tab_i_17_sse, rounder_7 | ||
802 : | |||
803 : | DCT_8_INV_COL_4 eax+0, eax+0 | ||
804 : | DCT_8_INV_COL_4 eax+8, eax+8 | ||
805 : | |||
806 : | Isibaar | 154 | ret |
807 : | |||
808 : | ;============================================================================= | ||
809 : | ; The code below this line is for SSE2-equipped processors | ||
810 : | ; By Dmitry Rozhdestvensky | ||
811 : | ;============================================================================= | ||
812 : | |||
813 : | section .data | ||
814 : | |||
815 : | align 16 | ||
816 : | |||
817 : | tab_i_04_s2 dw 16384, 21407, 16384, 8867 ; movq-> w05 w04 w01 w00 | ||
818 : | dw 16384, -8867, 16384, -21407 ; w13 w12 w09 w08 | ||
819 : | dw 16384, 8867, -16384, -21407 ; w07 w06 w03 w02 | ||
820 : | dw -16384, 21407, 16384, -8867 ; w15 w14 w11 w10 | ||
821 : | dw 22725, 19266, 19266, -4520 ; w21 w20 w17 w16 | ||
822 : | dw 12873, -22725, 4520, -12873 ; w29 w28 w25 w24 | ||
823 : | dw 12873, 4520, -22725, -12873 ; w23 w22 w19 w18 | ||
824 : | dw 4520, 19266, 19266, -22725 ; w31 w30 w27 w26 | ||
825 : | |||
826 : | ; Table for rows 1,7 - constants are multiplied by cos_1_16 | ||
827 : | |||
828 : | tab_i_17_s2 dw 22725, 29692, 22725, 12299 ; movq-> w05 w04 w01 w00 | ||
829 : | dw 22725, -12299, 22725, -29692 ; w13 w12 w09 w08 | ||
830 : | dw 22725, 12299, -22725, -29692 ; w07 w06 w03 w02 | ||
831 : | dw -22725, 29692, 22725, -12299 ; w15 w14 w11 w10 | ||
832 : | dw 31521, 26722, 26722, -6270 ; w21 w20 w17 w16 | ||
833 : | dw 17855, -31521, 6270, -17855 ; w29 w28 w25 w24 | ||
834 : | dw 17855, 6270, -31521, -17855 ; w23 w22 w19 w18 | ||
835 : | dw 6270, 26722, 26722, -31521 ; w31 w30 w27 w26 | ||
836 : | |||
837 : | ; Table for rows 2,6 - constants are multiplied by cos_2_16 | ||
838 : | |||
839 : | tab_i_26_s2 dw 21407, 27969, 21407, 11585 ; movq-> w05 w04 w01 w00 | ||
840 : | dw 21407, -11585, 21407, -27969 ; w13 w12 w09 w08 | ||
841 : | dw 21407, 11585, -21407, -27969 ; w07 w06 w03 w02 | ||
842 : | dw -21407, 27969, 21407, -11585 ; w15 w14 w11 w10 | ||
843 : | dw 29692, 25172, 25172, -5906 ; w21 w20 w17 w16 | ||
844 : | dw 16819, -29692, 5906, -16819 ; w29 w28 w25 w24 | ||
845 : | dw 16819, 5906, -29692, -16819 ; w23 w22 w19 w18 | ||
846 : | dw 5906, 25172, 25172, -29692 ; w31 w30 w27 w26 | ||
847 : | |||
848 : | ; Table for rows 3,5 - constants are multiplied by cos_3_16 | ||
849 : | |||
850 : | tab_i_35_s2 dw 19266, 25172, 19266, 10426 ; movq-> w05 w04 w01 w00 | ||
851 : | dw 19266, -10426, 19266, -25172 ; w13 w12 w09 w08 | ||
852 : | dw 19266, 10426, -19266, -25172 ; w07 w06 w03 w02 | ||
853 : | dw -19266, 25172, 19266, -10426 ; w15 w14 w11 w10 | ||
854 : | dw 26722, 22654, 22654, -5315 ; w21 w20 w17 w16 | ||
855 : | dw 15137, -26722, 5315, -15137 ; w29 w28 w25 w24 | ||
856 : | dw 15137, 5315, -26722, -15137 ; w23 w22 w19 w18 | ||
857 : | dw 5315, 22654, 22654, -26722 ; w31 w30 w27 w26 | ||
858 : | |||
859 : | %if SHIFT_INV_ROW == 12 ; assume SHIFT_INV_ROW == 12 | ||
860 : | rounder_2_0 dd 65536, 65536 | ||
861 : | dd 65536, 65536 | ||
862 : | rounder_2_4 dd 0, 0 | ||
863 : | dd 0, 0 | ||
864 : | rounder_2_1 dd 7195, 7195 | ||
865 : | dd 7195, 7195 | ||
866 : | rounder_2_7 dd 1024, 1024 | ||
867 : | dd 1024, 1024 | ||
868 : | rounder_2_2 dd 4520, 4520 | ||
869 : | dd 4520, 4520 | ||
870 : | rounder_2_6 dd 1024, 1024 | ||
871 : | dd 1024, 1024 | ||
872 : | rounder_2_3 dd 2407, 2407 | ||
873 : | dd 2407, 2407 | ||
874 : | rounder_2_5 dd 240, 240 | ||
875 : | dd 240, 240 | ||
876 : | |||
877 : | %elif SHIFT_INV_ROW == 11 ; assume SHIFT_INV_ROW == 11 | ||
878 : | rounder_2_0 dd 65536, 65536 | ||
879 : | dd 65536, 65536 | ||
880 : | rounder_2_4 dd 0, 0 | ||
881 : | dd 0, 0 | ||
882 : | rounder_2_1 dd 3597, 3597 | ||
883 : | dd 3597, 3597 | ||
884 : | rounder_2_7 dd 512, 512 | ||
885 : | dd 512, 512 | ||
886 : | rounder_2_2 dd 2260, 2260 | ||
887 : | dd 2260, 2260 | ||
888 : | rounder_2_6 dd 512, 512 | ||
889 : | dd 512, 512 | ||
890 : | rounder_2_3 dd 1203, 1203 | ||
891 : | dd 1203, 1203 | ||
892 : | rounder_2_5 dd 120, 120 | ||
893 : | dd 120, 120 | ||
894 : | %else | ||
895 : | |||
896 : | %error invalid _SHIFT_INV_ROW_ | ||
897 : | |||
898 : | %endif | ||
899 : | |||
900 : | tg_1_16_2 dw 13036, 13036, 13036, 13036 ; tg * (2<<16) + 0.5 | ||
901 : | dw 13036, 13036, 13036, 13036 | ||
902 : | tg_2_16_2 dw 27146, 27146, 27146, 27146 ; tg * (2<<16) + 0.5 | ||
903 : | dw 27146, 27146, 27146, 27146 | ||
904 : | tg_3_16_2 dw -21746, -21746, -21746, -21746 ; tg * (2<<16) + 0.5 | ||
905 : | dw -21746, -21746, -21746, -21746 | ||
906 : | ocos_4_16_2 dw 23170, 23170, 23170, 23170 ; cos * (2<<15) + 0.5 | ||
907 : | dw 23170, 23170, 23170, 23170 | ||
908 : | |||
909 : | %macro DCT_8_INV_ROW_1_sse2 4 | ||
910 : | |||
911 : | pshufhw xmm1,[%1],11011000b ;x 75643210 | ||
912 : | pshuflw xmm1,xmm1,11011000b ;x 75643120 | ||
913 : | pshufd xmm0,xmm1,00000000b ;x 20202020 | ||
914 : | pmaddwd xmm0,[%3] ;w 13 12 9 8 5410 | ||
915 : | ;a 3210 first part | ||
916 : | |||
917 : | pshufd xmm2,xmm1,10101010b ;x 64646464 | ||
918 : | pmaddwd xmm2,[%3+16] ;w 15 14 11 10 7632 | ||
919 : | ;a 3210 second part | ||
920 : | |||
921 : | paddd xmm2,xmm0 ;a 3210 ready | ||
922 : | paddd xmm2,[%4] ;must be 4 dwords long, not 2 as for sse1 | ||
923 : | movdqa xmm5,xmm2 | ||
924 : | |||
925 : | pshufd xmm3,xmm1,01010101b ;x 31313131 | ||
926 : | pmaddwd xmm3,[%3+32] ;w 29 28 25 24 21 20 17 16 | ||
927 : | ;b 3210 first part | ||
928 : | |||
929 : | pshufd xmm4,xmm1,11111111b ;x 75757575 | ||
930 : | pmaddwd xmm4,[%3+48] ;w 31 30 27 26 23 22 19 18 | ||
931 : | ;b 3210 second part | ||
932 : | paddd xmm3,xmm4 ;b 3210 ready | ||
933 : | |||
934 : | paddd xmm2,xmm3 ;will be y 3210 | ||
935 : | psubd xmm5,xmm3 ;will be y 4567 | ||
936 : | psrad xmm2,SHIFT_INV_ROW | ||
937 : | psrad xmm5,SHIFT_INV_ROW | ||
938 : | packssdw xmm2,xmm5 ;y 45673210 | ||
939 : | pshufhw xmm6,xmm2,00011011b ;y 76543210 | ||
940 : | movdqa [%2],xmm6 | ||
941 : | |||
942 : | %endmacro | ||
943 : | |||
944 : | %macro DCT_8_INV_COL_4_sse2 2 | ||
945 : | |||
946 : | movdqa xmm0,[%1+16*0] ;x0 (all columns) | ||
947 : | movdqa xmm2,[%1+16*4] ;x4 | ||
948 : | movdqa xmm1,xmm0 | ||
949 : | |||
950 : | movdqa xmm4,[%1+16*2] ;x2 | ||
951 : | movdqa xmm5,[%1+16*6] ;x6 | ||
952 : | movdqa xmm6,[tg_2_16_2] | ||
953 : | movdqa xmm7,xmm6 | ||
954 : | |||
955 : | paddsw xmm0,xmm2 ;u04=x0+x4 | ||
956 : | psubsw xmm1,xmm2 ;v04=x0-x4 | ||
957 : | movdqa xmm3,xmm0 | ||
958 : | movdqa xmm2,xmm1 | ||
959 : | |||
960 : | pmulhw xmm6,xmm4 | ||
961 : | pmulhw xmm7,xmm5 | ||
962 : | psubsw xmm6,xmm5 ;v26=x2*T2-x6 | ||
963 : | paddsw xmm7,xmm4 ;u26=x6*T2+x2 | ||
964 : | |||
965 : | paddsw xmm1,xmm6 ;a1=v04+v26 | ||
966 : | paddsw xmm0,xmm7 ;a0=u04+u26 | ||
967 : | psubsw xmm2,xmm6 ;a2=v04-v26 | ||
968 : | psubsw xmm3,xmm7 ;a3=u04-u26 | ||
969 : | |||
970 : | movdqa [%2+16*0],xmm0 ;store a3-a0 to | ||
971 : | movdqa [%2+16*6],xmm1 ;free registers | ||
972 : | movdqa [%2+16*2],xmm2 | ||
973 : | movdqa [%2+16*4],xmm3 | ||
974 : | |||
975 : | movdqa xmm0,[%1+16*1] ;x1 | ||
976 : | movdqa xmm1,[%1+16*7] ;x7 | ||
977 : | movdqa xmm2,[tg_1_16_2] | ||
978 : | movdqa xmm3,xmm2 | ||
979 : | |||
980 : | movdqa xmm4,[%1+16*3] ;x3 | ||
981 : | movdqa xmm5,[%1+16*5] ;x5 | ||
982 : | movdqa xmm6,[tg_3_16_2] | ||
983 : | movdqa xmm7,xmm6 | ||
984 : | |||
985 : | pmulhw xmm2,xmm0 | ||
986 : | pmulhw xmm3,xmm1 | ||
987 : | psubsw xmm2,xmm1 ;v17=x1*T1-x7 | ||
988 : | paddsw xmm3,xmm0 ;u17=x7*T1+x1 | ||
989 : | movdqa xmm0,xmm3 ;u17 | ||
990 : | movdqa xmm1,xmm2 ;v17 | ||
991 : | |||
992 : | pmulhw xmm6,xmm4 ;x3*(t3-1) | ||
993 : | pmulhw xmm7,xmm5 ;x5*(t3-1) | ||
994 : | paddsw xmm6,xmm4 | ||
995 : | paddsw xmm7,xmm5 | ||
996 : | psubsw xmm6,xmm5 ;v35=x3*T3-x5 | ||
997 : | paddsw xmm7,xmm4 ;u35=x5*T3+x3 | ||
998 : | |||
999 : | movdqa xmm4,[ocos_4_16_2] | ||
1000 : | |||
1001 : | paddsw xmm0,xmm7 ;b0=u17+u35 | ||
1002 : | psubsw xmm1,xmm6 ;b3=v17-v35 | ||
1003 : | psubsw xmm3,xmm7 ;u12=u17-v35 | ||
1004 : | paddsw xmm2,xmm6 ;v12=v17+v35 | ||
1005 : | |||
1006 : | movdqa xmm5,xmm3 | ||
1007 : | paddsw xmm3,xmm2 ;tb1 | ||
1008 : | psubsw xmm5,xmm2 ;tb2 | ||
1009 : | pmulhw xmm5,xmm4 | ||
1010 : | pmulhw xmm4,xmm3 | ||
1011 : | paddsw xmm5,xmm5 | ||
1012 : | paddsw xmm4,xmm4 | ||
1013 : | |||
1014 : | movdqa xmm6,[%2+16*0] ;a0 | ||
1015 : | movdqa xmm7,xmm6 | ||
1016 : | movdqa xmm2,[%2+16*4] ;a3 | ||
1017 : | movdqa xmm3,xmm2 | ||
1018 : | |||
1019 : | paddsw xmm6,xmm0 | ||
1020 : | psubsw xmm7,xmm0 | ||
1021 : | psraw xmm6,SHIFT_INV_COL ;y0=a0+b0 | ||
1022 : | psraw xmm7,SHIFT_INV_COL ;y7=a0-b0 | ||
1023 : | movdqa [%2+16*0],xmm6 | ||
1024 : | movdqa [%2+16*7],xmm7 | ||
1025 : | |||
1026 : | paddsw xmm2,xmm1 | ||
1027 : | psubsw xmm3,xmm1 | ||
1028 : | psraw xmm2,SHIFT_INV_COL ;y3=a3+b3 | ||
1029 : | psraw xmm3,SHIFT_INV_COL ;y4=a3-b3 | ||
1030 : | movdqa [%2+16*3],xmm2 | ||
1031 : | movdqa [%2+16*4],xmm3 | ||
1032 : | |||
1033 : | movdqa xmm0,[%2+16*6] ;a1 | ||
1034 : | movdqa xmm1,xmm0 | ||
1035 : | movdqa xmm6,[%2+16*2] ;a2 | ||
1036 : | movdqa xmm7,xmm6 | ||
1037 : | |||
1038 : | |||
1039 : | paddsw xmm0,xmm4 | ||
1040 : | psubsw xmm1,xmm4 | ||
1041 : | psraw xmm0,SHIFT_INV_COL ;y1=a1+b1 | ||
1042 : | psraw xmm1,SHIFT_INV_COL ;y6=a1-b1 | ||
1043 : | movdqa [%2+16*1],xmm0 | ||
1044 : | movdqa [%2+16*6],xmm1 | ||
1045 : | |||
1046 : | paddsw xmm6,xmm5 | ||
1047 : | psubsw xmm7,xmm5 | ||
1048 : | psraw xmm6,SHIFT_INV_COL ;y2=a2+b2 | ||
1049 : | psraw xmm7,SHIFT_INV_COL ;y5=a2-b2 | ||
1050 : | movdqa [%2+16*2],xmm6 | ||
1051 : | movdqa [%2+16*5],xmm7 | ||
1052 : | |||
1053 : | %endmacro | ||
1054 : | |||
1055 : | section .text | ||
1056 : | |||
1057 : | align 16 | ||
1058 : | cglobal idct_sse2 | ||
1059 : | idct_sse2 | ||
1060 : | |||
1061 : | mov eax, dword [esp + 4] | ||
1062 : | |||
1063 : | DCT_8_INV_ROW_1_sse2 eax+0, eax+0, tab_i_04_s2, rounder_2_0 | ||
1064 : | DCT_8_INV_ROW_1_sse2 eax+16, eax+16, tab_i_17_s2, rounder_2_1 | ||
1065 : | DCT_8_INV_ROW_1_sse2 eax+32, eax+32, tab_i_26_s2, rounder_2_2 | ||
1066 : | DCT_8_INV_ROW_1_sse2 eax+48, eax+48, tab_i_35_s2, rounder_2_3 | ||
1067 : | DCT_8_INV_ROW_1_sse2 eax+64, eax+64, tab_i_04_s2, rounder_2_4 | ||
1068 : | DCT_8_INV_ROW_1_sse2 eax+80, eax+80, tab_i_35_s2, rounder_2_5 | ||
1069 : | DCT_8_INV_ROW_1_sse2 eax+96, eax+96, tab_i_26_s2, rounder_2_6 | ||
1070 : | DCT_8_INV_ROW_1_sse2 eax+112, eax+112, tab_i_17_s2, rounder_2_7 | ||
1071 : | |||
1072 : | DCT_8_INV_COL_4_sse2 eax, eax | ||
1073 : | ;DCT_8_INV_COL_4 eax+8, eax+8 | ||
1074 : | |||
1075 : | ret |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |