Parent Directory | Revision Log
Revision 1.4 - (view) (download)
1 : | edgomez | 1.3 | ;/**************************************************************************** |
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$ | ||
23 : | ; * | ||
24 : | ; ***************************************************************************/ | ||
25 : | edgomez | 1.2 | |
26 : | BITS 32 | ||
27 : | |||
28 : | edgomez | 1.3 | %macro cglobal 1 |
29 : | edgomez | 1.4 | %ifdef PREFIX |
30 : | %ifdef MARK_FUNCS | ||
31 : | global _%1:function | ||
32 : | %define %1 _%1:function | ||
33 : | %else | ||
34 : | global _%1 | ||
35 : | %define %1 _%1 | ||
36 : | %endif | ||
37 : | edgomez | 1.2 | %else |
38 : | edgomez | 1.4 | %ifdef MARK_FUNCS |
39 : | global %1:function | ||
40 : | %else | ||
41 : | global %1 | ||
42 : | %endif | ||
43 : | edgomez | 1.2 | %endif |
44 : | %endmacro | ||
45 : | |||
46 : | edgomez | 1.3 | ;============================================================================= |
47 : | ; Helper macros | ||
48 : | ;============================================================================= | ||
49 : | edgomez | 1.2 | |
50 : | ;------------------------------------------------------------------------------ | ||
51 : | ; PLANE_COPY ( DST, DST_DIF, SRC, SRC_DIF, WIDTH, HEIGHT, OPT ) | ||
52 : | ; DST dst buffer | ||
53 : | ; DST_DIF dst stride difference (e.g. stride - width) | ||
54 : | ; SRC src destination buffer | ||
55 : | ; SRC_DIF src stride difference (e.g. stride - width) | ||
56 : | ; WIDTH width | ||
57 : | ; HEIGHT height | ||
58 : | ; OPT 0=plain mmx, 1=xmm | ||
59 : | ;------------------------------------------------------------------------------ | ||
60 : | edgomez | 1.3 | |
61 : | edgomez | 1.2 | %macro PLANE_COPY 7 |
62 : | %define DST %1 | ||
63 : | %define DST_DIF %2 | ||
64 : | %define SRC %3 | ||
65 : | %define SRC_DIF %4 | ||
66 : | %define WIDTH %5 | ||
67 : | %define HEIGHT %6 | ||
68 : | %define OPT %7 | ||
69 : | |||
70 : | edgomez | 1.3 | mov eax, WIDTH |
71 : | mov ebp, HEIGHT ; $ebp$ = height | ||
72 : | mov esi, SRC | ||
73 : | mov edi, DST | ||
74 : | |||
75 : | mov ebx, eax | ||
76 : | shr eax, 6 ; $eax$ = width / 64 | ||
77 : | and ebx, 63 ; remainder = width % 64 | ||
78 : | mov edx, ebx | ||
79 : | shr ebx, 4 ; $ebx$ = remainder / 16 | ||
80 : | and edx, 15 ; $edx$ = remainder % 16 | ||
81 : | edgomez | 1.2 | |
82 : | %%loop64_start | ||
83 : | edgomez | 1.3 | or eax, eax |
84 : | jz %%loop16_start | ||
85 : | mov ecx, eax ; width64 | ||
86 : | edgomez | 1.2 | %%loop64: |
87 : | edgomez | 1.3 | %if OPT == 1 ; xmm |
88 : | prefetchnta [esi + 64] ; non temporal prefetch | ||
89 : | prefetchnta [esi + 96] | ||
90 : | edgomez | 1.2 | %endif |
91 : | edgomez | 1.3 | movq mm1, [esi] ; read from src |
92 : | movq mm2, [esi + 8] | ||
93 : | movq mm3, [esi + 16] | ||
94 : | movq mm4, [esi + 24] | ||
95 : | movq mm5, [esi + 32] | ||
96 : | movq mm6, [esi + 40] | ||
97 : | movq mm7, [esi + 48] | ||
98 : | movq mm0, [esi + 56] | ||
99 : | |||
100 : | %if OPT == 0 ; plain mmx | ||
101 : | movq [edi], mm1 ; write to y_out | ||
102 : | movq [edi + 8], mm2 | ||
103 : | movq [edi + 16], mm3 | ||
104 : | movq [edi + 24], mm4 | ||
105 : | movq [edi + 32], mm5 | ||
106 : | movq [edi + 40], mm6 | ||
107 : | movq [edi + 48], mm7 | ||
108 : | movq [edi + 56], mm0 | ||
109 : | edgomez | 1.2 | %else |
110 : | edgomez | 1.3 | movntq [edi], mm1 ; write to y_out |
111 : | movntq [edi + 8], mm2 | ||
112 : | movntq [edi + 16], mm3 | ||
113 : | movntq [edi + 24], mm4 | ||
114 : | movntq [edi + 32], mm5 | ||
115 : | movntq [edi + 40], mm6 | ||
116 : | movntq [edi + 48], mm7 | ||
117 : | movntq [edi + 56], mm0 | ||
118 : | edgomez | 1.2 | %endif |
119 : | |||
120 : | edgomez | 1.3 | add esi, 64 |
121 : | add edi, 64 | ||
122 : | dec ecx | ||
123 : | jnz %%loop64 | ||
124 : | edgomez | 1.2 | |
125 : | |||
126 : | %%loop16_start | ||
127 : | edgomez | 1.3 | or ebx, ebx |
128 : | jz %%loop1_start | ||
129 : | mov ecx, ebx ; width16 | ||
130 : | edgomez | 1.2 | %%loop16: |
131 : | edgomez | 1.3 | movq mm1, [esi] |
132 : | movq mm2, [esi + 8] | ||
133 : | %if OPT == 0 ; plain mmx | ||
134 : | movq [edi], mm1 | ||
135 : | movq [edi + 8], mm2 | ||
136 : | edgomez | 1.2 | %else |
137 : | edgomez | 1.3 | movntq [edi], mm1 |
138 : | movntq [edi + 8], mm2 | ||
139 : | edgomez | 1.2 | %endif |
140 : | |||
141 : | edgomez | 1.3 | add esi, 16 |
142 : | add edi, 16 | ||
143 : | dec ecx | ||
144 : | jnz %%loop16 | ||
145 : | edgomez | 1.2 | |
146 : | |||
147 : | %%loop1_start | ||
148 : | edgomez | 1.3 | mov ecx, edx |
149 : | rep movsb | ||
150 : | edgomez | 1.2 | |
151 : | edgomez | 1.3 | add esi, SRC_DIF |
152 : | add edi, DST_DIF | ||
153 : | dec ebp | ||
154 : | jnz near %%loop64_start | ||
155 : | edgomez | 1.2 | %endmacro |
156 : | |||
157 : | ;------------------------------------------------------------------------------ | ||
158 : | ; MAKE_YV12_TO_YV12( NAME, OPT ) | ||
159 : | ; NAME function name | ||
160 : | ; OPT 0=plain mmx, 1=xmm | ||
161 : | ; | ||
162 : | edgomez | 1.3 | ; yv12_to_yv12_mmx(uint8_t * y_dst, uint8_t * u_dst, uint8_t * v_dst, |
163 : | edgomez | 1.2 | ; int y_dst_stride, int uv_dst_stride, |
164 : | edgomez | 1.3 | ; uint8_t * y_src, uint8_t * u_src, uint8_t * v_src, |
165 : | edgomez | 1.2 | ; int y_src_stride, int uv_src_stride, |
166 : | ; int width, int height, int vflip) | ||
167 : | ;------------------------------------------------------------------------------ | ||
168 : | %macro MAKE_YV12_TO_YV12 2 | ||
169 : | %define NAME %1 | ||
170 : | %define OPT %2 | ||
171 : | edgomez | 1.3 | ALIGN 16 |
172 : | edgomez | 1.2 | cglobal NAME |
173 : | edgomez | 1.3 | NAME: |
174 : | edgomez | 1.2 | %define pushsize 16 |
175 : | %define localsize 24 | ||
176 : | |||
177 : | %define vflip esp + localsize + pushsize + 52 | ||
178 : | %define height esp + localsize + pushsize + 48 | ||
179 : | %define width esp + localsize + pushsize + 44 | ||
180 : | %define uv_src_stride esp + localsize + pushsize + 40 | ||
181 : | %define y_src_stride esp + localsize + pushsize + 36 | ||
182 : | %define v_src esp + localsize + pushsize + 32 | ||
183 : | %define u_src esp + localsize + pushsize + 28 | ||
184 : | %define y_src esp + localsize + pushsize + 24 | ||
185 : | %define uv_dst_stride esp + localsize + pushsize + 20 | ||
186 : | %define y_dst_stride esp + localsize + pushsize + 16 | ||
187 : | %define v_dst esp + localsize + pushsize + 12 | ||
188 : | %define u_dst esp + localsize + pushsize + 8 | ||
189 : | %define y_dst esp + localsize + pushsize + 4 | ||
190 : | %define _ip esp + localsize + pushsize + 0 | ||
191 : | |||
192 : | edgomez | 1.3 | push ebx ; esp + localsize + 16 |
193 : | push esi ; esp + localsize + 8 | ||
194 : | push edi ; esp + localsize + 4 | ||
195 : | push ebp ; esp + localsize + 0 | ||
196 : | edgomez | 1.2 | |
197 : | %define width2 esp + localsize - 4 | ||
198 : | %define height2 esp + localsize - 8 | ||
199 : | %define y_src_dif esp + localsize - 12 | ||
200 : | %define y_dst_dif esp + localsize - 16 | ||
201 : | %define uv_src_dif esp + localsize - 20 | ||
202 : | %define uv_dst_dif esp + localsize - 24 | ||
203 : | |||
204 : | edgomez | 1.3 | sub esp, localsize |
205 : | edgomez | 1.2 | |
206 : | edgomez | 1.3 | mov eax, [width] |
207 : | mov ebx, [height] | ||
208 : | shr eax, 1 ; calculate widht/2, heigh/2 | ||
209 : | shr ebx, 1 | ||
210 : | mov [width2], eax | ||
211 : | mov [height2], ebx | ||
212 : | |||
213 : | mov ebp, [vflip] | ||
214 : | or ebp, ebp | ||
215 : | jz near .dont_flip | ||
216 : | edgomez | 1.2 | |
217 : | ; flipping support | ||
218 : | edgomez | 1.3 | mov eax, [height] |
219 : | mov esi, [y_src] | ||
220 : | mov edx, [y_src_stride] | ||
221 : | push edx | ||
222 : | mul edx | ||
223 : | pop edx | ||
224 : | add esi, eax ; y_src += (height-1) * y_src_stride | ||
225 : | neg edx | ||
226 : | mov [y_src], esi | ||
227 : | mov [y_src_stride], edx ; y_src_stride = -y_src_stride | ||
228 : | |||
229 : | mov eax, [height2] | ||
230 : | mov esi, [u_src] | ||
231 : | mov edi, [v_src] | ||
232 : | mov edx, [uv_src_stride] | ||
233 : | sub eax, 1 ; ebp = height2 - 1 | ||
234 : | push edx | ||
235 : | mul edx | ||
236 : | pop edx | ||
237 : | add esi, eax ; u_src += (height2-1) * uv_src_stride | ||
238 : | add edi, eax ; v_src += (height2-1) * uv_src_stride | ||
239 : | neg edx | ||
240 : | mov [u_src], esi | ||
241 : | mov [v_src], edi | ||
242 : | mov [uv_src_stride], edx ; uv_src_stride = -uv_src_stride | ||
243 : | edgomez | 1.2 | |
244 : | .dont_flip | ||
245 : | |||
246 : | edgomez | 1.3 | mov eax, [y_src_stride] |
247 : | mov ebx, [y_dst_stride] | ||
248 : | mov ecx, [uv_src_stride] | ||
249 : | mov edx, [uv_dst_stride] | ||
250 : | sub eax, [width] | ||
251 : | sub ebx, [width] | ||
252 : | sub ecx, [width2] | ||
253 : | sub edx, [width2] | ||
254 : | mov [y_src_dif], eax ; y_src_dif = y_src_stride - width | ||
255 : | mov [y_dst_dif], ebx ; y_dst_dif = y_dst_stride - width | ||
256 : | mov [uv_src_dif], ecx ; uv_src_dif = uv_src_stride - width2 | ||
257 : | mov [uv_dst_dif], edx ; uv_dst_dif = uv_dst_stride - width2 | ||
258 : | |||
259 : | PLANE_COPY [y_dst], [y_dst_dif], [y_src], [y_src_dif], [width], [height], OPT | ||
260 : | PLANE_COPY [u_dst], [uv_dst_dif], [u_src], [uv_src_dif], [width2], [height2], OPT | ||
261 : | PLANE_COPY [v_dst], [uv_dst_dif], [v_src], [uv_src_dif], [width2], [height2], OPT | ||
262 : | |||
263 : | add esp, localsize | ||
264 : | pop ebp | ||
265 : | pop edi | ||
266 : | pop esi | ||
267 : | pop ebx | ||
268 : | edgomez | 1.2 | |
269 : | edgomez | 1.3 | ret |
270 : | edgomez | 1.2 | %endmacro |
271 : | |||
272 : | edgomez | 1.3 | ;============================================================================= |
273 : | ; Code | ||
274 : | ;============================================================================= | ||
275 : | |||
276 : | SECTION .text | ||
277 : | edgomez | 1.2 | |
278 : | MAKE_YV12_TO_YV12 yv12_to_yv12_mmx, 0 | ||
279 : | edgomez | 1.3 | |
280 : | edgomez | 1.2 | MAKE_YV12_TO_YV12 yv12_to_yv12_xmm, 1 |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |