[cvs] / xvidcore / src / dct / x86_64_asm / idct_mmx.asm Repository:
ViewVC logotype

Annotation of /xvidcore/src/dct/x86_64_asm/idct_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (view) (download)

1 : edgomez 1.1 ;/****************************************************************************
2 :     ; *
3 :     ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - MMX and XMM forward discrete cosine transform -
5 :     ; *
6 :     ; * Copyright(C) 2001 Peter Ross <pross@xvid.org>
7 :     ; * 2004 Andre Werthmann <wertmann@aei.mpg.de>
8 :     ; *
9 :     ; * This program is free software; you can redistribute it and/or modify it
10 :     ; * under the terms of the GNU General Public License as published by
11 :     ; * the Free Software Foundation; either version 2 of the License, or
12 :     ; * (at your option) any later version.
13 :     ; *
14 :     ; * This program is distributed in the hope that it will be useful,
15 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 :     ; * GNU General Public License for more details.
18 :     ; *
19 :     ; * You should have received a copy of the GNU General Public License
20 :     ; * along with this program; if not, write to the Free Software
21 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 :     ; *
23 : Isibaar 1.4 ; * $Id: idct_mmx.asm,v 1.3 2008/11/11 20:46:24 Isibaar Exp $
24 : edgomez 1.1 ; *
25 :     ; ***************************************************************************/
26 :    
27 :     ; ****************************************************************************
28 :     ;
29 :     ; Originally provided by Intel at AP-922
30 :     ; http://developer.intel.com/vtune/cbts/strmsimd/922down.htm
31 :     ; (See more app notes at http://developer.intel.com/vtune/cbts/strmsimd/appnotes.htm)
32 :     ; but in a limited edition.
33 :     ; New macro implements a column part for precise iDCT
34 :     ; The routine precision now satisfies IEEE standard 1180-1990.
35 :     ;
36 :     ; Copyright(C) 2000-2001 Peter Gubanov <peter@elecard.net.ru>
37 :     ; Rounding trick Copyright(C) 2000 Michel Lespinasse <walken@zoy.org>
38 :     ;
39 :     ; http://www.elecard.com/peter/idct.html
40 :     ; http://www.linuxvideo.org/mpeg2dec/
41 :     ;
42 :     ; ***************************************************************************/
43 :     ;
44 :     ; These examples contain code fragments for first stage iDCT 8x8
45 :     ; (for rows) and first stage DCT 8x8 (for columns)
46 :     ;
47 :    
48 :     BITS 64
49 :    
50 :     ;=============================================================================
51 :     ; Macros and other preprocessor constants
52 :     ;=============================================================================
53 :    
54 :     %macro cglobal 1
55 :     %ifdef PREFIX
56 :     %ifdef MARK_FUNCS
57 :     global _%1:function %1.endfunc-%1
58 :     %define %1 _%1:function %1.endfunc-%1
59 : Isibaar 1.3 %define ENDFUNC .endfunc
60 : edgomez 1.1 %else
61 :     global _%1
62 :     %define %1 _%1
63 : Isibaar 1.3 %define ENDFUNC
64 : edgomez 1.1 %endif
65 :     %else
66 :     %ifdef MARK_FUNCS
67 :     global %1:function %1.endfunc-%1
68 : Isibaar 1.3 %define ENDFUNC .endfunc
69 : edgomez 1.1 %else
70 :     global %1
71 : Isibaar 1.3 %define ENDFUNC
72 : edgomez 1.1 %endif
73 :     %endif
74 :     %endmacro
75 :    
76 :     %define BITS_INV_ACC 5 ; 4 or 5 for IEEE
77 :     %define SHIFT_INV_ROW 16 - BITS_INV_ACC
78 :     %define SHIFT_INV_COL 1 + BITS_INV_ACC
79 :     %define RND_INV_ROW 1024 * (6 - BITS_INV_ACC) ; 1 << (SHIFT_INV_ROW-1)
80 :     %define RND_INV_COL 16 * (BITS_INV_ACC - 3) ; 1 << (SHIFT_INV_COL-1)
81 :     %define RND_INV_CORR RND_INV_COL - 1 ; correction -1.0 and round
82 :    
83 :     %define BITS_FRW_ACC 3 ; 2 or 3 for accuracy
84 :     %define SHIFT_FRW_COL BITS_FRW_ACC
85 :     %define SHIFT_FRW_ROW BITS_FRW_ACC + 17
86 :     %define RND_FRW_ROW 262144*(BITS_FRW_ACC - 1) ; 1 << (SHIFT_FRW_ROW-1)
87 :    
88 :     ;=============================================================================
89 :     ; Local Data (Read Only)
90 :     ;=============================================================================
91 :    
92 :     %ifdef FORMAT_COFF
93 :     SECTION .rodata
94 :     %else
95 :     SECTION .rodata align=16
96 :     %endif
97 :    
98 :     ;-----------------------------------------------------------------------------
99 :     ; Various memory constants (trigonometric values or rounding values)
100 :     ;-----------------------------------------------------------------------------
101 :    
102 :     ALIGN 16
103 :     one_corr:
104 :     dw 1, 1, 1, 1
105 :     round_inv_row:
106 :     dd RND_INV_ROW, RND_INV_ROW
107 :     round_inv_col:
108 :     dw RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL
109 :     round_inv_corr:
110 :     dw RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR
111 :     round_frw_row:
112 :     dd RND_FRW_ROW, RND_FRW_ROW
113 :     tg_1_16:
114 :     dw 13036, 13036, 13036, 13036 ; tg * (2<<16) + 0.5
115 :     tg_2_16:
116 :     dw 27146, 27146, 27146, 27146 ; tg * (2<<16) + 0.5
117 :     tg_3_16:
118 :     dw -21746, -21746, -21746, -21746 ; tg * (2<<16) + 0.5
119 :     cos_4_16:
120 :     dw -19195, -19195, -19195, -19195 ; cos * (2<<16) + 0.5
121 :     ocos_4_16:
122 :     dw 23170, 23170, 23170, 23170 ; cos * (2<<15) + 0.5
123 :     otg_3_16:
124 :     dw 21895, 21895, 21895, 21895 ; tg * (2<<16) + 0.5
125 :    
126 :     %if SHIFT_INV_ROW == 12 ; assume SHIFT_INV_ROW == 12
127 :     rounder_0:
128 :     dd 65536, 65536
129 :     rounder_4:
130 :     dd 0, 0
131 :     rounder_1:
132 :     dd 7195, 7195
133 :     rounder_7
134 :     dd 1024, 1024
135 :     rounder_2:
136 :     dd 4520, 4520
137 :     rounder_6:
138 :     dd 1024, 1024
139 :     rounder_3:
140 :     dd 2407, 2407
141 :     rounder_5:
142 :     dd 240, 240
143 :    
144 :     %elif SHIFT_INV_ROW == 11 ; assume SHIFT_INV_ROW == 11
145 :     rounder_0:
146 :     dd 65536, 65536
147 :     rounder_4:
148 :     dd 0, 0
149 :     rounder_1:
150 :     dd 3597, 3597
151 :     rounder_7:
152 :     dd 512, 512
153 :     rounder_2:
154 :     dd 2260, 2260
155 :     rounder_6:
156 :     dd 512, 512
157 :     rounder_3:
158 :     dd 1203, 1203
159 :     rounder_5:
160 :     dd 120, 120
161 :     %else
162 :    
163 :     %error invalid SHIFT_INV_ROW
164 :    
165 :     %endif
166 :    
167 :     ;-----------------------------------------------------------------------------
168 :     ;
169 :     ; The first stage iDCT 8x8 - inverse DCTs of rows
170 :     ;
171 :     ;-----------------------------------------------------------------------------
172 :     ; The 8-point inverse DCT direct algorithm
173 :     ;-----------------------------------------------------------------------------
174 :     ;
175 :     ; static const short w[32] = {
176 :     ; FIX(cos_4_16), FIX(cos_2_16), FIX(cos_4_16), FIX(cos_6_16),
177 :     ; FIX(cos_4_16), FIX(cos_6_16), -FIX(cos_4_16), -FIX(cos_2_16),
178 :     ; FIX(cos_4_16), -FIX(cos_6_16), -FIX(cos_4_16), FIX(cos_2_16),
179 :     ; FIX(cos_4_16), -FIX(cos_2_16), FIX(cos_4_16), -FIX(cos_6_16),
180 :     ; FIX(cos_1_16), FIX(cos_3_16), FIX(cos_5_16), FIX(cos_7_16),
181 :     ; FIX(cos_3_16), -FIX(cos_7_16), -FIX(cos_1_16), -FIX(cos_5_16),
182 :     ; FIX(cos_5_16), -FIX(cos_1_16), FIX(cos_7_16), FIX(cos_3_16),
183 :     ; FIX(cos_7_16), -FIX(cos_5_16), FIX(cos_3_16), -FIX(cos_1_16) };
184 :     ;
185 :     ; #define DCT_8_INV_ROW(x, y)
186 :     ; {
187 :     ; int a0, a1, a2, a3, b0, b1, b2, b3;
188 :     ;
189 :     ; a0 =x[0]*w[0]+x[2]*w[1]+x[4]*w[2]+x[6]*w[3];
190 :     ; a1 =x[0]*w[4]+x[2]*w[5]+x[4]*w[6]+x[6]*w[7];
191 :     ; a2 = x[0] * w[ 8] + x[2] * w[ 9] + x[4] * w[10] + x[6] * w[11];
192 :     ; a3 = x[0] * w[12] + x[2] * w[13] + x[4] * w[14] + x[6] * w[15];
193 :     ; b0 = x[1] * w[16] + x[3] * w[17] + x[5] * w[18] + x[7] * w[19];
194 :     ; b1 = x[1] * w[20] + x[3] * w[21] + x[5] * w[22] + x[7] * w[23];
195 :     ; b2 = x[1] * w[24] + x[3] * w[25] + x[5] * w[26] + x[7] * w[27];
196 :     ; b3 = x[1] * w[28] + x[3] * w[29] + x[5] * w[30] + x[7] * w[31];
197 :     ;
198 :     ; y[0] = SHIFT_ROUND ( a0 + b0 );
199 :     ; y[1] = SHIFT_ROUND ( a1 + b1 );
200 :     ; y[2] = SHIFT_ROUND ( a2 + b2 );
201 :     ; y[3] = SHIFT_ROUND ( a3 + b3 );
202 :     ; y[4] = SHIFT_ROUND ( a3 - b3 );
203 :     ; y[5] = SHIFT_ROUND ( a2 - b2 );
204 :     ; y[6] = SHIFT_ROUND ( a1 - b1 );
205 :     ; y[7] = SHIFT_ROUND ( a0 - b0 );
206 :     ; }
207 :     ;
208 :     ;-----------------------------------------------------------------------------
209 :     ;
210 :     ; In this implementation the outputs of the iDCT-1D are multiplied
211 :     ; for rows 0,4 - by cos_4_16,
212 :     ; for rows 1,7 - by cos_1_16,
213 :     ; for rows 2,6 - by cos_2_16,
214 :     ; for rows 3,5 - by cos_3_16
215 :     ; and are shifted to the left for better accuracy
216 :     ;
217 :     ; For the constants used,
218 :     ; FIX(float_const) = (short) (float_const * (1<<15) + 0.5)
219 :     ;
220 :     ;-----------------------------------------------------------------------------
221 :    
222 :     ;-----------------------------------------------------------------------------
223 :     ; Tables for xmm processors
224 :     ;-----------------------------------------------------------------------------
225 :    
226 :     ; %3 for rows 0,4 - constants are multiplied by cos_4_16
227 :     tab_i_04_xmm:
228 :     dw 16384, 21407, 16384, 8867 ; movq-> w05 w04 w01 w00
229 :     dw 16384, 8867, -16384, -21407 ; w07 w06 w03 w02
230 :     dw 16384, -8867, 16384, -21407 ; w13 w12 w09 w08
231 :     dw -16384, 21407, 16384, -8867 ; w15 w14 w11 w10
232 :     dw 22725, 19266, 19266, -4520 ; w21 w20 w17 w16
233 :     dw 12873, 4520, -22725, -12873 ; w23 w22 w19 w18
234 :     dw 12873, -22725, 4520, -12873 ; w29 w28 w25 w24
235 :     dw 4520, 19266, 19266, -22725 ; w31 w30 w27 w26
236 :    
237 :     ; %3 for rows 1,7 - constants are multiplied by cos_1_16
238 :     tab_i_17_xmm:
239 :     dw 22725, 29692, 22725, 12299 ; movq-> w05 w04 w01 w00
240 :     dw 22725, 12299, -22725, -29692 ; w07 w06 w03 w02
241 :     dw 22725, -12299, 22725, -29692 ; w13 w12 w09 w08
242 :     dw -22725, 29692, 22725, -12299 ; w15 w14 w11 w10
243 :     dw 31521, 26722, 26722, -6270 ; w21 w20 w17 w16
244 :     dw 17855, 6270, -31521, -17855 ; w23 w22 w19 w18
245 :     dw 17855, -31521, 6270, -17855 ; w29 w28 w25 w24
246 :     dw 6270, 26722, 26722, -31521 ; w31 w30 w27 w26
247 :    
248 :     ; %3 for rows 2,6 - constants are multiplied by cos_2_16
249 :     tab_i_26_xmm:
250 :     dw 21407, 27969, 21407, 11585 ; movq-> w05 w04 w01 w00
251 :     dw 21407, 11585, -21407, -27969 ; w07 w06 w03 w02
252 :     dw 21407, -11585, 21407, -27969 ; w13 w12 w09 w08
253 :     dw -21407, 27969, 21407, -11585 ; w15 w14 w11 w10
254 :     dw 29692, 25172, 25172, -5906 ; w21 w20 w17 w16
255 :     dw 16819, 5906, -29692, -16819 ; w23 w22 w19 w18
256 :     dw 16819, -29692, 5906, -16819 ; w29 w28 w25 w24
257 :     dw 5906, 25172, 25172, -29692 ; w31 w30 w27 w26
258 :    
259 :     ; %3 for rows 3,5 - constants are multiplied by cos_3_16
260 :     tab_i_35_xmm:
261 :     dw 19266, 25172, 19266, 10426 ; movq-> w05 w04 w01 w00
262 :     dw 19266, 10426, -19266, -25172 ; w07 w06 w03 w02
263 :     dw 19266, -10426, 19266, -25172 ; w13 w12 w09 w08
264 :     dw -19266, 25172, 19266, -10426 ; w15 w14 w11 w10
265 :     dw 26722, 22654, 22654, -5315 ; w21 w20 w17 w16
266 :     dw 15137, 5315, -26722, -15137 ; w23 w22 w19 w18
267 :     dw 15137, -26722, 5315, -15137 ; w29 w28 w25 w24
268 :     dw 5315, 22654, 22654, -26722 ; w31 w30 w27 w26
269 :    
270 :     ;=============================================================================
271 :     ; Helper macros for the code
272 :     ;=============================================================================
273 :    
274 :     ;-----------------------------------------------------------------------------
275 :     ; DCT_8_INV_ROW_XMM INP, OUT, TABLE, ROUNDER
276 :     ;-----------------------------------------------------------------------------
277 :    
278 :     %macro DCT_8_INV_ROW_XMM 4
279 :     movq mm0, [%1] ; 0 ; x3 x2 x1 x0
280 :     movq mm1, [%1+8] ; 1 ; x7 x6 x5 x4
281 :     movq mm2, mm0 ; 2 ; x3 x2 x1 x0
282 :     movq mm3, [%3] ; 3 ; w05 w04 w01 w00
283 :     pshufw mm0, mm0, 10001000b ; x2 x0 x2 x0
284 :     movq mm4, [%3+8] ; 4 ; w07 w06 w03 w02
285 :     movq mm5, mm1 ; 5 ; x7 x6 x5 x4
286 :     pmaddwd mm3, mm0 ; x2*w05+x0*w04 x2*w01+x0*w00
287 :     movq mm6, [%3+32] ; 6 ; w21 w20 w17 w16
288 :     pshufw mm1, mm1, 10001000b ; x6 x4 x6 x4
289 :     pmaddwd mm4, mm1 ; x6*w07+x4*w06 x6*w03+x4*w02
290 :     movq mm7, [%3+40] ; 7 ; w23 w22 w19 w18
291 :     pshufw mm2, mm2, 11011101b ; x3 x1 x3 x1
292 :     pmaddwd mm6, mm2 ; x3*w21+x1*w20 x3*w17+x1*w16
293 :     pshufw mm5, mm5, 11011101b ; x7 x5 x7 x5
294 :     pmaddwd mm7, mm5 ; x7*w23+x5*w22 x7*w19+x5*w18
295 :     paddd mm3, [%4] ; +%4
296 :     pmaddwd mm0, [%3+16] ; x2*w13+x0*w12 x2*w09+x0*w08
297 :     paddd mm3, mm4 ; 4 ; a1=sum(even1) a0=sum(even0)
298 :     pmaddwd mm1, [%3+24] ; x6*w15+x4*w14 x6*w11+x4*w10
299 :     movq mm4, mm3 ; 4 ; a1 a0
300 :     pmaddwd mm2, [%3+48] ; x3*w29+x1*w28 x3*w25+x1*w24
301 :     paddd mm6, mm7 ; 7 ; b1=sum(odd1) b0=sum(odd0)
302 :     pmaddwd mm5, [%3+56] ; x7*w31+x5*w30 x7*w27+x5*w26
303 :     paddd mm3, mm6 ; a1+b1 a0+b0
304 :     paddd mm0, [%4] ; +%4
305 :     psrad mm3, SHIFT_INV_ROW ; y1=a1+b1 y0=a0+b0
306 :     paddd mm0, mm1 ; 1 ; a3=sum(even3) a2=sum(even2)
307 :     psubd mm4, mm6 ; 6 ; a1-b1 a0-b0
308 :     movq mm7, mm0 ; 7 ; a3 a2
309 :     paddd mm2, mm5 ; 5 ; b3=sum(odd3) b2=sum(odd2)
310 :     paddd mm0, mm2 ; a3+b3 a2+b2
311 :     psrad mm4, SHIFT_INV_ROW ; y6=a1-b1 y7=a0-b0
312 :     psubd mm7, mm2 ; 2 ; a3-b3 a2-b2
313 :     psrad mm0, SHIFT_INV_ROW ; y3=a3+b3 y2=a2+b2
314 :     psrad mm7, SHIFT_INV_ROW ; y4=a3-b3 y5=a2-b2
315 :     packssdw mm3, mm0 ; 0 ; y3 y2 y1 y0
316 :     packssdw mm7, mm4 ; 4 ; y6 y7 y4 y5
317 :     movq [%2], mm3 ; 3 ; save y3 y2 y1 y0
318 :     pshufw mm7, mm7, 10110001b ; y7 y6 y5 y4
319 :     movq [%2+8], mm7 ; 7 ; save y7 y6 y5 y4
320 :     %endmacro
321 :    
322 :     ;-----------------------------------------------------------------------------
323 :     ;
324 :     ; The first stage DCT 8x8 - forward DCTs of columns
325 :     ;
326 :     ; The %2puts are multiplied
327 :     ; for rows 0,4 - on cos_4_16,
328 :     ; for rows 1,7 - on cos_1_16,
329 :     ; for rows 2,6 - on cos_2_16,
330 :     ; for rows 3,5 - on cos_3_16
331 :     ; and are shifted to the left for rise of accuracy
332 :     ;
333 :     ;-----------------------------------------------------------------------------
334 :     ;
335 :     ; The 8-point scaled forward DCT algorithm (26a8m)
336 :     ;
337 :     ;-----------------------------------------------------------------------------
338 :     ;
339 :     ; #define DCT_8_FRW_COL(x, y)
340 :     ;{
341 :     ; short t0, t1, t2, t3, t4, t5, t6, t7;
342 :     ; short tp03, tm03, tp12, tm12, tp65, tm65;
343 :     ; short tp465, tm465, tp765, tm765;
344 :     ;
345 :     ; t0 = LEFT_SHIFT ( x[0] + x[7] );
346 :     ; t1 = LEFT_SHIFT ( x[1] + x[6] );
347 :     ; t2 = LEFT_SHIFT ( x[2] + x[5] );
348 :     ; t3 = LEFT_SHIFT ( x[3] + x[4] );
349 :     ; t4 = LEFT_SHIFT ( x[3] - x[4] );
350 :     ; t5 = LEFT_SHIFT ( x[2] - x[5] );
351 :     ; t6 = LEFT_SHIFT ( x[1] - x[6] );
352 :     ; t7 = LEFT_SHIFT ( x[0] - x[7] );
353 :     ;
354 :     ; tp03 = t0 + t3;
355 :     ; tm03 = t0 - t3;
356 :     ; tp12 = t1 + t2;
357 :     ; tm12 = t1 - t2;
358 :     ;
359 :     ; y[0] = tp03 + tp12;
360 :     ; y[4] = tp03 - tp12;
361 :     ;
362 :     ; y[2] = tm03 + tm12 * tg_2_16;
363 :     ; y[6] = tm03 * tg_2_16 - tm12;
364 :     ;
365 :     ; tp65 =(t6 +t5 )*cos_4_16;
366 :     ; tm65 =(t6 -t5 )*cos_4_16;
367 :     ;
368 :     ; tp765 = t7 + tp65;
369 :     ; tm765 = t7 - tp65;
370 :     ; tp465 = t4 + tm65;
371 :     ; tm465 = t4 - tm65;
372 :     ;
373 :     ; y[1] = tp765 + tp465 * tg_1_16;
374 :     ; y[7] = tp765 * tg_1_16 - tp465;
375 :     ; y[5] = tm765 * tg_3_16 + tm465;
376 :     ; y[3] = tm765 - tm465 * tg_3_16;
377 :     ;}
378 :     ;
379 :     ;-----------------------------------------------------------------------------
380 :    
381 :     ;-----------------------------------------------------------------------------
382 :     ; DCT_8_INV_COL_4 INP,OUT
383 :     ;-----------------------------------------------------------------------------
384 :    
385 :     %macro DCT_8_INV_COL 2
386 :     movq mm0, [tg_3_16 wrt rip]
387 :     movq mm3, [%1+16*3]
388 :     movq mm1, mm0 ; tg_3_16
389 :     movq mm5, [%1+16*5]
390 :     pmulhw mm0, mm3 ; x3*(tg_3_16-1)
391 :     movq mm4, [tg_1_16 wrt rip]
392 :     pmulhw mm1, mm5 ; x5*(tg_3_16-1)
393 :     movq mm7, [%1+16*7]
394 :     movq mm2, mm4 ; tg_1_16
395 :     movq mm6, [%1+16*1]
396 :     pmulhw mm4, mm7 ; x7*tg_1_16
397 :     paddsw mm0, mm3 ; x3*tg_3_16
398 :     pmulhw mm2, mm6 ; x1*tg_1_16
399 :     paddsw mm1, mm3 ; x3+x5*(tg_3_16-1)
400 :     psubsw mm0, mm5 ; x3*tg_3_16-x5 = tm35
401 :     movq mm3, [ocos_4_16 wrt rip]
402 :     paddsw mm1, mm5 ; x3+x5*tg_3_16 = tp35
403 :     paddsw mm4, mm6 ; x1+tg_1_16*x7 = tp17
404 :     psubsw mm2, mm7 ; x1*tg_1_16-x7 = tm17
405 :     movq mm5, mm4 ; tp17
406 :     movq mm6, mm2 ; tm17
407 :     paddsw mm5, mm1 ; tp17+tp35 = b0
408 :     psubsw mm6, mm0 ; tm17-tm35 = b3
409 :     psubsw mm4, mm1 ; tp17-tp35 = t1
410 :     paddsw mm2, mm0 ; tm17+tm35 = t2
411 :     movq mm7, [tg_2_16 wrt rip]
412 :     movq mm1, mm4 ; t1
413 :     movq [%2+3*16], mm5 ; save b0
414 :     paddsw mm1, mm2 ; t1+t2
415 :     movq [%2+5*16], mm6 ; save b3
416 :     psubsw mm4, mm2 ; t1-t2
417 :     movq mm5, [%1+2*16]
418 :     movq mm0, mm7 ; tg_2_16
419 :     movq mm6, [%1+6*16]
420 :     pmulhw mm0, mm5 ; x2*tg_2_16
421 :     pmulhw mm7, mm6 ; x6*tg_2_16
422 :     ; slot
423 :     pmulhw mm1, mm3 ; ocos_4_16*(t1+t2) = b1/2
424 :     ; slot
425 :     movq mm2, [%1+0*16]
426 :     pmulhw mm4, mm3 ; ocos_4_16*(t1-t2) = b2/2
427 :     psubsw mm0, mm6 ; t2*tg_2_16-x6 = tm26
428 :     movq mm3, mm2 ; x0
429 :     movq mm6, [%1+4*16]
430 :     paddsw mm7, mm5 ; x2+x6*tg_2_16 = tp26
431 :     paddsw mm2, mm6 ; x0+x4 = tp04
432 :     psubsw mm3, mm6 ; x0-x4 = tm04
433 :     movq mm5, mm2 ; tp04
434 :     movq mm6, mm3 ; tm04
435 :     psubsw mm2, mm7 ; tp04-tp26 = a3
436 :     paddsw mm3, mm0 ; tm04+tm26 = a1
437 :     paddsw mm1, mm1 ; b1
438 :     paddsw mm4, mm4 ; b2
439 :     paddsw mm5, mm7 ; tp04+tp26 = a0
440 :     psubsw mm6, mm0 ; tm04-tm26 = a2
441 :     movq mm7, mm3 ; a1
442 :     movq mm0, mm6 ; a2
443 :     paddsw mm3, mm1 ; a1+b1
444 :     paddsw mm6, mm4 ; a2+b2
445 :     psraw mm3, SHIFT_INV_COL ; dst1
446 :     psubsw mm7, mm1 ; a1-b1
447 :     psraw mm6, SHIFT_INV_COL ; dst2
448 :     psubsw mm0, mm4 ; a2-b2
449 :     movq mm1, [%2+3*16] ; load b0
450 :     psraw mm7, SHIFT_INV_COL ; dst6
451 :     movq mm4, mm5 ; a0
452 :     psraw mm0, SHIFT_INV_COL ; dst5
453 :     movq [%2+1*16], mm3
454 :     paddsw mm5, mm1 ; a0+b0
455 :     movq [%2+2*16], mm6
456 :     psubsw mm4, mm1 ; a0-b0
457 :     movq mm3, [%2+5*16] ; load b3
458 :     psraw mm5, SHIFT_INV_COL ; dst0
459 :     movq mm6, mm2 ; a3
460 :     psraw mm4, SHIFT_INV_COL ; dst7
461 :     movq [%2+5*16], mm0
462 :     paddsw mm2, mm3 ; a3+b3
463 :     movq [%2+6*16], mm7
464 :     psubsw mm6, mm3 ; a3-b3
465 :     movq [%2+0*16], mm5
466 :     psraw mm2, SHIFT_INV_COL ; dst3
467 :     movq [%2+7*16], mm4
468 :     psraw mm6, SHIFT_INV_COL ; dst4
469 :     movq [%2+3*16], mm2
470 :     movq [%2+4*16], mm6
471 :     %endmacro
472 :    
473 :     ;=============================================================================
474 :     ; Code
475 :     ;=============================================================================
476 :    
477 :     SECTION .text align=16
478 :    
479 :     cglobal idct_x86_64
480 :    
481 :     ;-----------------------------------------------------------------------------
482 :     ; void idct_xmm(uint16_t block[64]);
483 :     ;-----------------------------------------------------------------------------
484 :    
485 :     ALIGN 16
486 :     idct_x86_64:
487 :     mov rax, rdi ; block[]
488 :    
489 :     ;; Process each row
490 :     lea rsi, [tab_i_04_xmm wrt rip]
491 :     lea rdi, [rounder_0 wrt rip]
492 :     DCT_8_INV_ROW_XMM rax+0*16, rax+0*16, rsi, rdi
493 :    
494 :     lea rsi, [tab_i_17_xmm wrt rip]
495 :     lea rdi, [rounder_1 wrt rip]
496 :     DCT_8_INV_ROW_XMM rax+1*16, rax+1*16, rsi, rdi
497 :    
498 :     lea rsi, [tab_i_26_xmm wrt rip]
499 :     lea rdi, [rounder_2 wrt rip]
500 :     DCT_8_INV_ROW_XMM rax+2*16, rax+2*16, rsi, rdi
501 :    
502 :     lea rsi, [tab_i_35_xmm wrt rip]
503 :     lea rdi, [rounder_3 wrt rip]
504 :     DCT_8_INV_ROW_XMM rax+3*16, rax+3*16, rsi, rdi
505 :    
506 :     lea rsi, [tab_i_04_xmm wrt rip]
507 :     lea rdi, [rounder_4 wrt rip]
508 :     DCT_8_INV_ROW_XMM rax+4*16, rax+4*16, rsi, rdi
509 :    
510 :     lea rsi, [tab_i_35_xmm wrt rip]
511 :     lea rdi, [rounder_5 wrt rip]
512 :     DCT_8_INV_ROW_XMM rax+5*16, rax+5*16, rsi, rdi
513 :    
514 :     lea rsi, [tab_i_26_xmm wrt rip]
515 :     lea rdi, [rounder_6 wrt rip]
516 :     DCT_8_INV_ROW_XMM rax+6*16, rax+6*16, rsi, rdi
517 :    
518 :     lea rsi, [tab_i_17_xmm wrt rip]
519 :     lea rdi, [rounder_7 wrt rip]
520 :     DCT_8_INV_ROW_XMM rax+7*16, rax+7*16, rsi, rdi
521 :    
522 :    
523 :     ;; Process the columns (4 at a time)
524 :     DCT_8_INV_COL rax+0, rax+0
525 :     DCT_8_INV_COL rax+8, rax+8
526 :    
527 :     ret
528 : Isibaar 1.3 ENDFUNC
529 : edgomez 1.1
530 : Isibaar 1.2
531 :     %ifidn __OUTPUT_FORMAT__,elf
532 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
533 :     %endif
534 :    

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4