[svn] / branches / dev-api-4 / xvidcore / src / image / x86_asm / colorspace_yuv_mmx.asm Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/src/image/x86_asm/colorspace_yuv_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1192 - (view) (download)

1 : edgomez 1192 ;/****************************************************************************
2 :     ; *
3 :     ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - MMX and XMM YV12->YV12 conversion -
5 :     ; *
6 :     ; * Copyright(C) 2001 Michael Militzer <isibaar@xvid.org>
7 :     ; *
8 :     ; * This program is free software; you can redistribute it and/or modify it
9 :     ; * under the terms of the GNU General Public License as published by
10 :     ; * the Free Software Foundation; either version 2 of the License, or
11 :     ; * (at your option) any later version.
12 :     ; *
13 :     ; * This program is distributed in the hope that it will be useful,
14 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 :     ; * GNU General Public License for more details.
17 :     ; *
18 :     ; * You should have received a copy of the GNU General Public License
19 :     ; * along with this program; if not, write to the Free Software
20 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 :     ; *
22 :     ; * $Id: colorspace_yuv_mmx.asm,v 1.2.2.1 2003-10-28 22:23:03 edgomez Exp $
23 :     ; *
24 :     ; ***************************************************************************/
25 : edgomez 851
26 :     BITS 32
27 :    
28 : edgomez 1192 %macro cglobal 1
29 : edgomez 851 %ifdef PREFIX
30 : edgomez 1192 global _%1
31 : edgomez 851 %define %1 _%1
32 :     %else
33 :     global %1
34 :     %endif
35 :     %endmacro
36 :    
37 : edgomez 1192 ;=============================================================================
38 :     ; Helper macros
39 :     ;=============================================================================
40 : edgomez 851
41 :     ;------------------------------------------------------------------------------
42 :     ; PLANE_COPY ( DST, DST_DIF, SRC, SRC_DIF, WIDTH, HEIGHT, OPT )
43 :     ; DST dst buffer
44 :     ; DST_DIF dst stride difference (e.g. stride - width)
45 :     ; SRC src destination buffer
46 :     ; SRC_DIF src stride difference (e.g. stride - width)
47 :     ; WIDTH width
48 :     ; HEIGHT height
49 :     ; OPT 0=plain mmx, 1=xmm
50 :     ;------------------------------------------------------------------------------
51 : edgomez 1192
52 : edgomez 851 %macro PLANE_COPY 7
53 :     %define DST %1
54 :     %define DST_DIF %2
55 :     %define SRC %3
56 :     %define SRC_DIF %4
57 :     %define WIDTH %5
58 :     %define HEIGHT %6
59 :     %define OPT %7
60 :    
61 : edgomez 1192 mov eax, WIDTH
62 :     mov ebp, HEIGHT ; $ebp$ = height
63 :     mov esi, SRC
64 :     mov edi, DST
65 : edgomez 851
66 : edgomez 1192 mov ebx, eax
67 :     shr eax, 6 ; $eax$ = width / 64
68 :     and ebx, 63 ; remainder = width % 64
69 :     mov edx, ebx
70 :     shr ebx, 4 ; $ebx$ = remainder / 16
71 :     and edx, 15 ; $edx$ = remainder % 16
72 : edgomez 851
73 :     %%loop64_start
74 : edgomez 1192 or eax, eax
75 :     jz %%loop16_start
76 :     mov ecx, eax ; width64
77 : edgomez 851 %%loop64:
78 : edgomez 1192 %if OPT == 1 ; xmm
79 :     prefetchnta [esi + 64] ; non temporal prefetch
80 :     prefetchnta [esi + 96]
81 : edgomez 851 %endif
82 : edgomez 1192 movq mm1, [esi] ; read from src
83 :     movq mm2, [esi + 8]
84 :     movq mm3, [esi + 16]
85 :     movq mm4, [esi + 24]
86 :     movq mm5, [esi + 32]
87 :     movq mm6, [esi + 40]
88 :     movq mm7, [esi + 48]
89 :     movq mm0, [esi + 56]
90 : edgomez 851
91 : edgomez 1192 %if OPT == 0 ; plain mmx
92 :     movq [edi], mm1 ; write to y_out
93 :     movq [edi + 8], mm2
94 :     movq [edi + 16], mm3
95 :     movq [edi + 24], mm4
96 :     movq [edi + 32], mm5
97 :     movq [edi + 40], mm6
98 :     movq [edi + 48], mm7
99 :     movq [edi + 56], mm0
100 : edgomez 851 %else
101 : edgomez 1192 movntq [edi], mm1 ; write to y_out
102 :     movntq [edi + 8], mm2
103 :     movntq [edi + 16], mm3
104 :     movntq [edi + 24], mm4
105 :     movntq [edi + 32], mm5
106 :     movntq [edi + 40], mm6
107 :     movntq [edi + 48], mm7
108 :     movntq [edi + 56], mm0
109 : edgomez 851 %endif
110 :    
111 : edgomez 1192 add esi, 64
112 :     add edi, 64
113 :     dec ecx
114 :     jnz %%loop64
115 : edgomez 851
116 :    
117 :     %%loop16_start
118 : edgomez 1192 or ebx, ebx
119 :     jz %%loop1_start
120 :     mov ecx, ebx ; width16
121 : edgomez 851 %%loop16:
122 : edgomez 1192 movq mm1, [esi]
123 :     movq mm2, [esi + 8]
124 :     %if OPT == 0 ; plain mmx
125 :     movq [edi], mm1
126 :     movq [edi + 8], mm2
127 : edgomez 851 %else
128 : edgomez 1192 movntq [edi], mm1
129 :     movntq [edi + 8], mm2
130 : edgomez 851 %endif
131 :    
132 : edgomez 1192 add esi, 16
133 :     add edi, 16
134 :     dec ecx
135 :     jnz %%loop16
136 : edgomez 851
137 :    
138 :     %%loop1_start
139 : edgomez 1192 mov ecx, edx
140 :     rep movsb
141 : edgomez 851
142 : edgomez 1192 add esi, SRC_DIF
143 :     add edi, DST_DIF
144 :     dec ebp
145 :     jnz near %%loop64_start
146 : edgomez 851 %endmacro
147 :    
148 :     ;------------------------------------------------------------------------------
149 :     ; MAKE_YV12_TO_YV12( NAME, OPT )
150 :     ; NAME function name
151 :     ; OPT 0=plain mmx, 1=xmm
152 :     ;
153 : edgomez 1192 ; yv12_to_yv12_mmx(uint8_t * y_dst, uint8_t * u_dst, uint8_t * v_dst,
154 : edgomez 851 ; int y_dst_stride, int uv_dst_stride,
155 : edgomez 1192 ; uint8_t * y_src, uint8_t * u_src, uint8_t * v_src,
156 : edgomez 851 ; int y_src_stride, int uv_src_stride,
157 :     ; int width, int height, int vflip)
158 :     ;------------------------------------------------------------------------------
159 :     %macro MAKE_YV12_TO_YV12 2
160 :     %define NAME %1
161 :     %define OPT %2
162 : edgomez 1192 ALIGN 16
163 : edgomez 851 cglobal NAME
164 : edgomez 1192 NAME:
165 : edgomez 851 %define pushsize 16
166 :     %define localsize 24
167 :    
168 :     %define vflip esp + localsize + pushsize + 52
169 :     %define height esp + localsize + pushsize + 48
170 :     %define width esp + localsize + pushsize + 44
171 :     %define uv_src_stride esp + localsize + pushsize + 40
172 :     %define y_src_stride esp + localsize + pushsize + 36
173 :     %define v_src esp + localsize + pushsize + 32
174 :     %define u_src esp + localsize + pushsize + 28
175 :     %define y_src esp + localsize + pushsize + 24
176 :     %define uv_dst_stride esp + localsize + pushsize + 20
177 :     %define y_dst_stride esp + localsize + pushsize + 16
178 :     %define v_dst esp + localsize + pushsize + 12
179 :     %define u_dst esp + localsize + pushsize + 8
180 :     %define y_dst esp + localsize + pushsize + 4
181 :     %define _ip esp + localsize + pushsize + 0
182 :    
183 : edgomez 1192 push ebx ; esp + localsize + 16
184 :     push esi ; esp + localsize + 8
185 :     push edi ; esp + localsize + 4
186 :     push ebp ; esp + localsize + 0
187 : edgomez 851
188 :     %define width2 esp + localsize - 4
189 :     %define height2 esp + localsize - 8
190 :     %define y_src_dif esp + localsize - 12
191 :     %define y_dst_dif esp + localsize - 16
192 :     %define uv_src_dif esp + localsize - 20
193 :     %define uv_dst_dif esp + localsize - 24
194 :    
195 : edgomez 1192 sub esp, localsize
196 : edgomez 851
197 : edgomez 1192 mov eax, [width]
198 :     mov ebx, [height]
199 :     shr eax, 1 ; calculate widht/2, heigh/2
200 :     shr ebx, 1
201 :     mov [width2], eax
202 :     mov [height2], ebx
203 : edgomez 851
204 : edgomez 1192 mov ebp, [vflip]
205 :     or ebp, ebp
206 :     jz near .dont_flip
207 : edgomez 851
208 :     ; flipping support
209 : edgomez 1192 mov eax, [height]
210 :     mov esi, [y_src]
211 :     mov edx, [y_src_stride]
212 :     push edx
213 :     mul edx
214 :     pop edx
215 :     add esi, eax ; y_src += (height-1) * y_src_stride
216 :     neg edx
217 :     mov [y_src], esi
218 :     mov [y_src_stride], edx ; y_src_stride = -y_src_stride
219 : edgomez 851
220 : edgomez 1192 mov eax, [height2]
221 :     mov esi, [u_src]
222 :     mov edi, [v_src]
223 :     mov edx, [uv_src_stride]
224 :     sub eax, 1 ; ebp = height2 - 1
225 :     push edx
226 :     mul edx
227 :     pop edx
228 :     add esi, eax ; u_src += (height2-1) * uv_src_stride
229 :     add edi, eax ; v_src += (height2-1) * uv_src_stride
230 :     neg edx
231 :     mov [u_src], esi
232 :     mov [v_src], edi
233 :     mov [uv_src_stride], edx ; uv_src_stride = -uv_src_stride
234 : edgomez 851
235 :     .dont_flip
236 :    
237 : edgomez 1192 mov eax, [y_src_stride]
238 :     mov ebx, [y_dst_stride]
239 :     mov ecx, [uv_src_stride]
240 :     mov edx, [uv_dst_stride]
241 :     sub eax, [width]
242 :     sub ebx, [width]
243 :     sub ecx, [width2]
244 :     sub edx, [width2]
245 :     mov [y_src_dif], eax ; y_src_dif = y_src_stride - width
246 :     mov [y_dst_dif], ebx ; y_dst_dif = y_dst_stride - width
247 :     mov [uv_src_dif], ecx ; uv_src_dif = uv_src_stride - width2
248 :     mov [uv_dst_dif], edx ; uv_dst_dif = uv_dst_stride - width2
249 : edgomez 851
250 : edgomez 1192 PLANE_COPY [y_dst], [y_dst_dif], [y_src], [y_src_dif], [width], [height], OPT
251 :     PLANE_COPY [u_dst], [uv_dst_dif], [u_src], [uv_src_dif], [width2], [height2], OPT
252 :     PLANE_COPY [v_dst], [uv_dst_dif], [v_src], [uv_src_dif], [width2], [height2], OPT
253 : edgomez 851
254 : edgomez 1192 add esp, localsize
255 :     pop ebp
256 :     pop edi
257 :     pop esi
258 :     pop ebx
259 : edgomez 851
260 : edgomez 1192 ret
261 : edgomez 851 %endmacro
262 :    
263 : edgomez 1192 ;=============================================================================
264 :     ; Code
265 :     ;=============================================================================
266 : edgomez 851
267 : edgomez 1192 SECTION .text
268 :    
269 : edgomez 851 MAKE_YV12_TO_YV12 yv12_to_yv12_mmx, 0
270 : edgomez 1192
271 : edgomez 851 MAKE_YV12_TO_YV12 yv12_to_yv12_xmm, 1

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