[svn] / trunk / xvidcore / src / image / x86_asm / gmc_mmx.asm Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/image/x86_asm/gmc_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1790 - (view) (download)

1 : Skal 1709 ;/*****************************************************************************
2 :     ; *
3 :     ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - GMC core functions -
5 :     ; * Copyright(C) 2006 Pascal Massimino <skal@planet-d.net>
6 :     ; *
7 :     ; * This file is part of XviD, a free MPEG-4 video encoder/decoder
8 :     ; *
9 :     ; * XviD 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 1790 ; * $Id: gmc_mmx.asm,v 1.3 2008-08-19 09:06:48 Isibaar Exp $
24 : Skal 1709 ; *
25 :     ; *************************************************************************/
26 :    
27 :     ;/**************************************************************************
28 :     ; *
29 :     ; * History:
30 :     ; *
31 :     ; * Jun 14 2006: initial version (during Germany/Poland match;)
32 :     ; *
33 :     ; *************************************************************************/
34 :    
35 :     bits 32
36 :    
37 :     %macro cglobal 1
38 :     %ifdef PREFIX
39 :     %ifdef MARK_FUNCS
40 :     global _%1:function %1.endfunc-%1
41 :     %define %1 _%1:function %1.endfunc-%1
42 :     %else
43 :     global _%1
44 :     %define %1 _%1
45 :     %endif
46 :     %else
47 :     %ifdef MARK_FUNCS
48 :     global %1:function %1.endfunc-%1
49 :     %else
50 :     global %1
51 :     %endif
52 :     %endif
53 :     %endmacro
54 :    
55 :     ;//////////////////////////////////////////////////////////////////////
56 :    
57 :     cglobal xvid_GMC_Core_Lin_8_mmx
58 :     cglobal xvid_GMC_Core_Lin_8_sse2
59 :    
60 :     ;//////////////////////////////////////////////////////////////////////
61 :    
62 :     %ifdef FORMAT_COFF
63 :     SECTION .rodata
64 :     %else
65 :     SECTION .rodata align=16
66 :     %endif
67 :    
68 :     align 16
69 :     Cst16:
70 :     times 8 dw 16
71 :    
72 :     SECTION .text
73 :    
74 :     ;//////////////////////////////////////////////////////////////////////
75 :     ;// mmx version
76 :    
77 :     %macro GMC_4_SSE 2 ; %1: i %2: out reg (mm5 or mm6)
78 :    
79 :     pcmpeqw mm0, mm0
80 :     movq mm1, [eax+2*(%1) ] ; u0 | u1 | u2 | u3
81 :     psrlw mm0, 12 ; mask 0x000f
82 :     movq mm2, [eax+2*(%1)+2*16] ; v0 | v1 | v2 | v3
83 :    
84 :     pand mm1, mm0 ; u0
85 :     pand mm2, mm0 ; v0
86 :    
87 :     movq mm0, [Cst16]
88 :     movq mm3, mm1 ; u | ...
89 :     movq mm4, mm0
90 :     pmullw mm3, mm2 ; u.v
91 :     psubw mm0, mm1 ; 16-u
92 :     psubw mm4, mm2 ; 16-v
93 :     pmullw mm2, mm0 ; (16-u).v
94 :     pmullw mm0, mm4 ; (16-u).(16-v)
95 :     pmullw mm1, mm4 ; u .(16-v)
96 :    
97 :     movd mm4, [ecx+edx +%1] ; src2
98 :     movd %2, [ecx+edx+1+%1] ; src3
99 :     punpcklbw mm4, mm7
100 :     punpcklbw %2, mm7
101 :     pmullw mm2, mm4
102 :     pmullw mm3, %2
103 :    
104 :     movd mm4, [ecx +%1] ; src0
105 :     movd %2, [ecx +1+%1] ; src1
106 :     punpcklbw mm4, mm7
107 :     punpcklbw %2, mm7
108 :     pmullw mm4, mm0
109 :     pmullw %2, mm1
110 :    
111 :     paddw mm2, mm3
112 :     paddw %2, mm4
113 :    
114 :     paddw %2, mm2
115 :     %endmacro
116 :    
117 :     align 16
118 :     xvid_GMC_Core_Lin_8_mmx:
119 :     mov eax, [esp + 8] ; Offsets
120 :     mov ecx, [esp +12] ; Src0
121 :     mov edx, [esp +16] ; BpS
122 :    
123 :     pxor mm7, mm7
124 :    
125 :     GMC_4_SSE 0, mm5
126 :     GMC_4_SSE 4, mm6
127 :    
128 :     ; pshufw mm4, [esp +20], 01010101b ; Rounder (bits [16..31])
129 :     movd mm4, [esp+20] ; Rounder (bits [16..31])
130 :     mov eax, [esp + 4] ; Dst
131 :     punpcklwd mm4, mm4
132 :     punpckhdq mm4, mm4
133 :    
134 :     paddw mm5, mm4
135 :     paddw mm6, mm4
136 :     psrlw mm5, 8
137 :     psrlw mm6, 8
138 :     packuswb mm5, mm6
139 :     movq [eax], mm5
140 :    
141 :     ret
142 :     .endfunc
143 :    
144 :     ;//////////////////////////////////////////////////////////////////////
145 :     ;// SSE2 version
146 :    
147 :     %macro GMC_8_SSE2 0
148 :    
149 :     pcmpeqw xmm0, xmm0
150 :     movdqa xmm1, [eax ] ; u...
151 :     psrlw xmm0, 12 ; mask = 0x000f
152 :     movdqa xmm2, [eax+2*16] ; v...
153 :     pand xmm1, xmm0
154 :     pand xmm2, xmm0
155 :    
156 :     movdqa xmm0, [Cst16]
157 :     movdqa xmm3, xmm1 ; u | ...
158 :     movdqa xmm4, xmm0
159 :     pmullw xmm3, xmm2 ; u.v
160 :     psubw xmm0, xmm1 ; 16-u
161 :     psubw xmm4, xmm2 ; 16-v
162 :     pmullw xmm2, xmm0 ; (16-u).v
163 :     pmullw xmm0, xmm4 ; (16-u).(16-v)
164 :     pmullw xmm1, xmm4 ; u .(16-v)
165 :    
166 :     movq xmm4, [ecx+edx ] ; src2
167 :     movq xmm5, [ecx+edx+1] ; src3
168 :     punpcklbw xmm4, xmm7
169 :     punpcklbw xmm5, xmm7
170 :     pmullw xmm2, xmm4
171 :     pmullw xmm3, xmm5
172 :    
173 :     movq xmm4, [ecx ] ; src0
174 :     movq xmm5, [ecx +1] ; src1
175 :     punpcklbw xmm4, xmm7
176 :     punpcklbw xmm5, xmm7
177 :     pmullw xmm4, xmm0
178 :     pmullw xmm5, xmm1
179 :    
180 :     paddw xmm2, xmm3
181 :     paddw xmm5, xmm4
182 :    
183 :     paddw xmm5, xmm2
184 :     %endmacro
185 :    
186 :     align 16
187 :     xvid_GMC_Core_Lin_8_sse2:
188 :     mov eax, [esp + 8] ; Offsets
189 :     mov ecx, [esp +12] ; Src0
190 :     mov edx, [esp +16] ; BpS
191 :    
192 :     pxor xmm7, xmm7
193 :    
194 :     GMC_8_SSE2
195 :    
196 : Skal 1756 movd xmm4, [esp +20]
197 :     pshuflw xmm4, xmm4, 01010101b ; Rounder (bits [16..31])
198 : Skal 1709 punpckldq xmm4, xmm4
199 :     mov eax, [esp + 4] ; Dst
200 :    
201 :     paddw xmm5, xmm4
202 :     psrlw xmm5, 8
203 :     packuswb xmm5, xmm5
204 :     movq [eax], xmm5
205 :    
206 :     ret
207 :     .endfunc
208 :    
209 :     ;//////////////////////////////////////////////////////////////////////
210 : Isibaar 1790
211 :     %ifidn __OUTPUT_FORMAT__,elf
212 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
213 :     %endif

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