1 |
;/************************************************************************** |
;/**************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * mmx 8bit<->16bit transfers |
; * - 8<->16 bit transfer functions - |
5 |
; * |
; * |
6 |
; * This program is an implementation of a part of one or more MPEG-4 |
; * Copyright (C) 2001 Peter Ross <pross@xvid.org> |
7 |
; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
; * 2001 Michael Militzer <isibaar@xvid.org> |
8 |
; * to use this software module in hardware or software products are |
; * 2002 Pascal Massimino <skal@planet-d.net> |
|
; * advised that its use may infringe existing patents or copyrights, and |
|
|
; * any such use would be at such party's own risk. The original |
|
|
; * developer of this software module and his/her company, and subsequent |
|
|
; * editors and their companies, will have no liability for use of this |
|
|
; * software or modifications or derivatives thereof. |
|
9 |
; * |
; * |
10 |
; * This program is free software; you can redistribute it and/or modify |
; * This program is free software; you can redistribute it and/or modify |
11 |
; * it under the terms of the GNU General Public License as published by |
; * it under the terms of the GNU General Public License as published by |
19 |
; * |
; * |
20 |
; * You should have received a copy of the GNU General Public License |
; * You should have received a copy of the GNU General Public License |
21 |
; * along with this program; if not, write to the Free Software |
; * along with this program; if not, write to the Free Software |
22 |
; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
; * |
; * |
24 |
; *************************************************************************/ |
; * $Id$ |
|
|
|
|
;/************************************************************************** |
|
|
; * |
|
|
; * History: |
|
|
; * |
|
|
; * 07.01.2002 merge functions from compensate_mmx; rename functions |
|
|
; * 07.11.2001 initial version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
25 |
; * |
; * |
26 |
; *************************************************************************/ |
; ***************************************************************************/ |
27 |
|
|
28 |
|
BITS 32 |
|
bits 32 |
|
29 |
|
|
30 |
%macro cglobal 1 |
%macro cglobal 1 |
31 |
%ifdef PREFIX |
%ifdef PREFIX |
32 |
|
%ifdef MARK_FUNCS |
33 |
|
global _%1:function %1.endfunc-%1 |
34 |
|
%define %1 _%1:function %1.endfunc-%1 |
35 |
|
%define ENDFUNC .endfunc |
36 |
|
%else |
37 |
global _%1 |
global _%1 |
38 |
%define %1 _%1 |
%define %1 _%1 |
39 |
|
%define ENDFUNC |
40 |
|
%endif |
41 |
|
%else |
42 |
|
%ifdef MARK_FUNCS |
43 |
|
global %1:function %1.endfunc-%1 |
44 |
|
%define ENDFUNC .endfunc |
45 |
%else |
%else |
46 |
global %1 |
global %1 |
47 |
|
%define ENDFUNC |
48 |
|
%endif |
49 |
%endif |
%endif |
50 |
%endmacro |
%endmacro |
51 |
|
|
52 |
|
;============================================================================= |
53 |
|
; Read only data |
54 |
|
;============================================================================= |
55 |
|
|
56 |
|
%ifdef FORMAT_COFF |
57 |
|
SECTION .rodata |
58 |
|
%else |
59 |
|
SECTION .rodata align=16 |
60 |
|
%endif |
61 |
|
|
62 |
|
ALIGN 16 |
63 |
|
mmx_one: |
64 |
|
dw 1, 1, 1, 1 |
65 |
|
|
66 |
|
;============================================================================= |
67 |
|
; Code |
68 |
|
;============================================================================= |
69 |
|
|
70 |
section .text |
SECTION .text |
71 |
|
|
72 |
|
cglobal transfer_8to16copy_mmx |
73 |
|
cglobal transfer_16to8copy_mmx |
74 |
|
cglobal transfer_8to16sub_mmx |
75 |
|
cglobal transfer_8to16subro_mmx |
76 |
|
cglobal transfer_8to16sub2_mmx |
77 |
|
cglobal transfer_8to16sub2_xmm |
78 |
|
cglobal transfer_8to16sub2ro_xmm |
79 |
|
cglobal transfer_16to8add_mmx |
80 |
|
cglobal transfer8x8_copy_mmx |
81 |
|
cglobal transfer8x4_copy_mmx |
82 |
|
|
83 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
84 |
; |
; |
85 |
; void transfer_8to16copy_mmx(int16_t * const dst, |
; void transfer_8to16copy_mmx(int16_t * const dst, |
86 |
; const uint8_t * const src, |
; const uint8_t * const src, |
87 |
; uint32_t stride); |
; uint32_t stride); |
88 |
; |
; |
89 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
align 16 |
|
|
cglobal transfer_8to16copy_mmx |
|
|
transfer_8to16copy_mmx |
|
|
|
|
|
push esi |
|
|
push edi |
|
|
|
|
|
mov edi, [esp + 8 + 4] ; dst |
|
|
mov esi, [esp + 8 + 8] ; src |
|
|
mov ecx, [esp + 8 + 12] ; stride |
|
|
|
|
|
pxor mm7, mm7 ; mm7 = zero |
|
|
|
|
|
mov eax, 8 |
|
90 |
|
|
91 |
.loop |
%macro COPY_8_TO_16 1 |
92 |
movq mm0, [esi] |
movq mm0, [eax] |
93 |
movq mm1, mm0 |
movq mm1, [eax+edx] |
94 |
punpcklbw mm0, mm7 ; mm01 = unpack([src]) |
movq mm2, mm0 |
95 |
punpckhbw mm1, mm7 |
movq mm3, mm1 |
96 |
|
punpcklbw mm0, mm7 |
97 |
movq [edi], mm0 ; [dst] = mm01 |
movq [ecx+%1*32], mm0 |
98 |
movq [edi + 8], mm1 |
punpcklbw mm1, mm7 |
99 |
|
movq [ecx+%1*32+16], mm1 |
100 |
|
punpckhbw mm2, mm7 |
101 |
|
punpckhbw mm3, mm7 |
102 |
|
lea eax, [eax+2*edx] |
103 |
|
movq [ecx+%1*32+8], mm2 |
104 |
|
movq [ecx+%1*32+24], mm3 |
105 |
|
%endmacro |
106 |
|
|
107 |
add edi, 16 |
ALIGN 16 |
108 |
add esi, ecx |
transfer_8to16copy_mmx: |
|
dec eax |
|
|
jnz .loop |
|
109 |
|
|
110 |
pop edi |
mov ecx, [esp+ 4] ; Dst |
111 |
pop esi |
mov eax, [esp+ 8] ; Src |
112 |
|
mov edx, [esp+12] ; Stride |
113 |
|
pxor mm7, mm7 |
114 |
|
|
115 |
|
COPY_8_TO_16 0 |
116 |
|
COPY_8_TO_16 1 |
117 |
|
COPY_8_TO_16 2 |
118 |
|
COPY_8_TO_16 3 |
119 |
ret |
ret |
120 |
|
ENDFUNC |
121 |
|
|
122 |
|
;----------------------------------------------------------------------------- |
|
|
|
|
;=========================================================================== |
|
123 |
; |
; |
124 |
; void transfer_16to8copy_mmx(uint8_t * const dst, |
; void transfer_16to8copy_mmx(uint8_t * const dst, |
125 |
; const int16_t * const src, |
; const int16_t * const src, |
126 |
; uint32_t stride); |
; uint32_t stride); |
127 |
; |
; |
128 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
align 16 |
|
|
cglobal transfer_16to8copy_mmx |
|
|
transfer_16to8copy_mmx |
|
129 |
|
|
130 |
push esi |
%macro COPY_16_TO_8 1 |
131 |
push edi |
movq mm0, [eax+%1*32] |
132 |
|
movq mm1, [eax+%1*32+8] |
133 |
mov edi, [esp + 8 + 4] ; dst |
packuswb mm0, mm1 |
134 |
mov esi, [esp + 8 + 8] ; src |
movq [ecx], mm0 |
135 |
mov ecx, [esp + 8 + 12] ; stride |
movq mm2, [eax+%1*32+16] |
136 |
|
movq mm3, [eax+%1*32+24] |
137 |
mov eax, 8 |
packuswb mm2, mm3 |
138 |
|
movq [ecx+edx], mm2 |
139 |
.loop |
%endmacro |
|
movq mm0, [esi] |
|
|
packuswb mm0, [esi + 8] ; mm0 = pack([src]) |
|
|
|
|
|
movq [edi], mm0 ; [dst] = mm0 |
|
|
|
|
|
add esi, 16 |
|
|
add edi, ecx |
|
|
dec eax |
|
|
jnz .loop |
|
140 |
|
|
141 |
pop edi |
ALIGN 16 |
142 |
pop esi |
transfer_16to8copy_mmx: |
143 |
|
|
144 |
|
mov ecx, [esp+ 4] ; Dst |
145 |
|
mov eax, [esp+ 8] ; Src |
146 |
|
mov edx, [esp+12] ; Stride |
147 |
|
|
148 |
|
COPY_16_TO_8 0 |
149 |
|
lea ecx,[ecx+2*edx] |
150 |
|
COPY_16_TO_8 1 |
151 |
|
lea ecx,[ecx+2*edx] |
152 |
|
COPY_16_TO_8 2 |
153 |
|
lea ecx,[ecx+2*edx] |
154 |
|
COPY_16_TO_8 3 |
155 |
ret |
ret |
156 |
|
ENDFUNC |
157 |
|
|
158 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
159 |
; |
; |
160 |
; void transfer_8to16sub_mmx(int16_t * const dct, |
; void transfer_8to16sub_mmx(int16_t * const dct, |
161 |
; uint8_t * const cur, |
; uint8_t * const cur, |
162 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
163 |
; const uint32_t stride); |
; const uint32_t stride); |
164 |
; |
; |
165 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
;/************************************************************************** |
|
|
; * |
|
|
; * History: |
|
|
; * |
|
|
; * 27.12.2001 renamed from 'compensate' to 'transfer_8to16sub' |
|
|
; * 02.12.2001 loop unrolled, code runs 10% faster now (Isibaar) |
|
|
; * 30.11.2001 16 pixels are processed per iteration (Isibaar) |
|
|
; * 30.11.2001 .text missing |
|
|
; * 06.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
|
; * |
|
|
; *************************************************************************/ |
|
166 |
|
|
167 |
align 16 |
; when second argument == 1, reference (ebx) block is to current (eax) |
168 |
cglobal transfer_8to16sub_mmx |
%macro COPY_8_TO_16_SUB 2 |
169 |
transfer_8to16sub_mmx |
movq mm0, [eax] ; cur |
170 |
push esi |
movq mm2, [eax+edx] |
|
push edi |
|
|
push ebx |
|
|
|
|
|
mov edi, [esp + 12 + 4] ; dct [out] |
|
|
mov edx, [esp + 12 + 8] ; cur [in/out] |
|
|
mov esi, [esp + 12 + 12] ; ref [in] |
|
|
mov ecx, [esp + 12 + 16] ; stride [in] |
|
|
|
|
|
mov eax, edx ; cur -> eax |
|
|
mov ebx, esi ; ref -> ebx |
|
|
add eax, ecx ; cur + stride |
|
|
add ebx, ecx ; ref + stride |
|
|
|
|
|
shl ecx, 1 |
|
|
|
|
|
pxor mm7, mm7 ; mm7 = zero |
|
|
|
|
|
movq mm0, [edx] ; mm01 = [cur] |
|
171 |
movq mm1, mm0 |
movq mm1, mm0 |
|
|
|
|
punpcklbw mm0, mm7 |
|
|
punpckhbw mm1, mm7 |
|
|
|
|
|
movq mm4, [eax] |
|
|
movq mm5, mm4 |
|
|
|
|
|
punpcklbw mm4, mm7 |
|
|
punpckhbw mm5, mm7 |
|
|
|
|
|
movq mm2, [esi] ; mm23 = [ref] |
|
172 |
movq mm3, mm2 |
movq mm3, mm2 |
173 |
|
|
174 |
movq mm6, [ebx] |
punpcklbw mm0, mm7 |
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
175 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
176 |
|
movq mm4, [ebx] ; ref |
177 |
|
punpckhbw mm1, mm7 |
178 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
179 |
|
movq mm5, [ebx+edx] ; ref |
180 |
|
|
181 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
182 |
|
%if %2 == 1 |
183 |
|
movq [eax], mm4 |
184 |
|
movq [eax+edx], mm5 |
185 |
|
%endif |
186 |
|
punpcklbw mm4, mm7 |
187 |
|
punpckhbw mm6, mm7 |
188 |
|
psubsw mm0, mm4 |
189 |
|
psubsw mm1, mm6 |
190 |
|
movq mm6, mm5 |
191 |
|
punpcklbw mm5, mm7 |
192 |
|
punpckhbw mm6, mm7 |
193 |
|
psubsw mm2, mm5 |
194 |
|
lea eax, [eax+2*edx] |
195 |
|
psubsw mm3, mm6 |
196 |
|
lea ebx,[ebx+2*edx] |
197 |
|
|
198 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
199 |
|
movq [ecx+%1*32+ 8], mm1 |
200 |
|
movq [ecx+%1*32+16], mm2 |
201 |
|
movq [ecx+%1*32+24], mm3 |
202 |
|
%endmacro |
203 |
|
|
204 |
movq mm2, mm6 |
ALIGN 16 |
205 |
|
transfer_8to16sub_mmx: |
206 |
|
mov ecx, [esp + 4] ; Dst |
207 |
|
mov eax, [esp + 8] ; Cur |
208 |
|
push ebx |
209 |
|
mov ebx, [esp+4+12] ; Ref |
210 |
|
mov edx, [esp+4+16] ; Stride |
211 |
|
pxor mm7, mm7 |
212 |
|
|
213 |
punpcklbw mm2, mm7 |
COPY_8_TO_16_SUB 0, 1 |
214 |
punpckhbw mm6, mm7 |
COPY_8_TO_16_SUB 1, 1 |
215 |
|
COPY_8_TO_16_SUB 2, 1 |
216 |
|
COPY_8_TO_16_SUB 3, 1 |
217 |
|
|
218 |
psubsw mm1, mm3 |
pop ebx |
219 |
|
ret |
220 |
|
ENDFUNC |
221 |
|
|
|
psubsw mm4, mm2 |
|
|
psubsw mm5, mm6 |
|
222 |
|
|
223 |
movq [edi], mm0 ; dct[] = mm01 |
ALIGN 16 |
224 |
movq [edi + 8], mm1 |
transfer_8to16subro_mmx: |
225 |
movq [edi + 16], mm4 |
mov ecx, [esp + 4] ; Dst |
226 |
movq [edi + 24], mm5 |
mov eax, [esp + 8] ; Cur |
227 |
|
push ebx |
228 |
add edx, ecx |
mov ebx, [esp+4+12] ; Ref |
229 |
add esi, ecx |
mov edx, [esp+4+16] ; Stride |
230 |
add eax, ecx |
pxor mm7, mm7 |
|
add ebx, ecx |
|
231 |
|
|
232 |
movq mm0, [edx] ; mm01 = [cur] |
COPY_8_TO_16_SUB 0, 0 |
233 |
movq mm1, mm0 |
COPY_8_TO_16_SUB 1, 0 |
234 |
|
COPY_8_TO_16_SUB 2, 0 |
235 |
|
COPY_8_TO_16_SUB 3, 0 |
236 |
|
|
237 |
punpcklbw mm0, mm7 |
pop ebx |
238 |
punpckhbw mm1, mm7 |
ret |
239 |
|
ENDFUNC |
240 |
|
|
|
movq mm4, [eax] |
|
|
movq mm5, mm4 |
|
241 |
|
|
242 |
|
;----------------------------------------------------------------------------- |
243 |
|
; |
244 |
|
; void transfer_8to16sub2_mmx(int16_t * const dct, |
245 |
|
; uint8_t * const cur, |
246 |
|
; const uint8_t * ref1, |
247 |
|
; const uint8_t * ref2, |
248 |
|
; const uint32_t stride) |
249 |
|
; |
250 |
|
;----------------------------------------------------------------------------- |
251 |
|
|
252 |
|
%macro COPY_8_TO_16_SUB2_MMX 1 |
253 |
|
movq mm0, [eax] ; cur |
254 |
|
movq mm2, [eax+edx] |
255 |
|
|
256 |
|
; mm4 <- (ref1+ref2+1) / 2 |
257 |
|
movq mm4, [ebx] ; ref1 |
258 |
|
movq mm1, [esi] ; ref2 |
259 |
|
movq mm6, mm4 |
260 |
|
movq mm3, mm1 |
261 |
punpcklbw mm4, mm7 |
punpcklbw mm4, mm7 |
262 |
punpckhbw mm5, mm7 |
punpcklbw mm1, mm7 |
263 |
|
punpckhbw mm6, mm7 |
264 |
|
punpckhbw mm3, mm7 |
265 |
|
paddusw mm4, mm1 |
266 |
|
paddusw mm6, mm3 |
267 |
|
paddusw mm4, [mmx_one] |
268 |
|
paddusw mm6, [mmx_one] |
269 |
|
psrlw mm4, 1 |
270 |
|
psrlw mm6, 1 |
271 |
|
packuswb mm4, mm6 |
272 |
|
movq [eax], mm4 |
273 |
|
|
274 |
|
; mm5 <- (ref1+ref2+1) / 2 |
275 |
|
movq mm5, [ebx+edx] ; ref1 |
276 |
|
movq mm1, [esi+edx] ; ref2 |
277 |
|
movq mm6, mm5 |
278 |
|
movq mm3, mm1 |
279 |
|
punpcklbw mm5, mm7 |
280 |
|
punpcklbw mm1, mm7 |
281 |
|
punpckhbw mm6, mm7 |
282 |
|
punpckhbw mm3, mm7 |
283 |
|
paddusw mm5, mm1 |
284 |
|
paddusw mm6, mm3 |
285 |
|
paddusw mm5, [mmx_one] |
286 |
|
paddusw mm6, [mmx_one] |
287 |
|
lea esi, [esi+2*edx] |
288 |
|
psrlw mm5, 1 |
289 |
|
psrlw mm6, 1 |
290 |
|
packuswb mm5, mm6 |
291 |
|
movq [eax+edx], mm5 |
292 |
|
|
293 |
movq mm2, [esi] ; mm23 = [ref] |
movq mm1, mm0 |
294 |
movq mm3, mm2 |
movq mm3, mm2 |
295 |
|
punpcklbw mm0, mm7 |
|
movq mm6, [ebx] |
|
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
296 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
297 |
|
punpckhbw mm1, mm7 |
298 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
299 |
|
|
300 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
301 |
|
punpcklbw mm4, mm7 |
302 |
movq mm2, mm6 |
punpckhbw mm6, mm7 |
303 |
|
psubsw mm0, mm4 |
304 |
punpcklbw mm2, mm7 |
psubsw mm1, mm6 |
305 |
|
movq mm6, mm5 |
306 |
|
punpcklbw mm5, mm7 |
307 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
308 |
|
psubsw mm2, mm5 |
309 |
|
lea eax, [eax+2*edx] |
310 |
|
psubsw mm3, mm6 |
311 |
|
lea ebx, [ebx+2*edx] |
312 |
|
|
313 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
314 |
|
movq [ecx+%1*32+ 8], mm1 |
315 |
|
movq [ecx+%1*32+16], mm2 |
316 |
|
movq [ecx+%1*32+24], mm3 |
317 |
|
%endmacro |
318 |
|
|
319 |
psubsw mm1, mm3 |
ALIGN 16 |
320 |
|
transfer_8to16sub2_mmx: |
321 |
|
mov ecx, [esp + 4] ; Dst |
322 |
|
mov eax, [esp + 8] ; Cur |
323 |
|
push ebx |
324 |
|
mov ebx, [esp+4+12] ; Ref1 |
325 |
|
push esi |
326 |
|
mov esi, [esp+8+16] ; Ref2 |
327 |
|
mov edx, [esp+8+20] ; Stride |
328 |
|
pxor mm7, mm7 |
329 |
|
|
330 |
psubsw mm4, mm2 |
COPY_8_TO_16_SUB2_MMX 0 |
331 |
psubsw mm5, mm6 |
COPY_8_TO_16_SUB2_MMX 1 |
332 |
|
COPY_8_TO_16_SUB2_MMX 2 |
333 |
|
COPY_8_TO_16_SUB2_MMX 3 |
334 |
|
|
335 |
movq [edi + 32], mm0 ; dct[] = mm01 |
pop esi |
336 |
movq [edi + 40], mm1 |
pop ebx |
337 |
movq [edi + 48], mm4 |
ret |
338 |
movq [edi + 56], mm5 |
ENDFUNC |
|
|
|
|
add edx, ecx |
|
|
add esi, ecx |
|
|
add eax, ecx |
|
|
add ebx, ecx |
|
339 |
|
|
340 |
movq mm0, [edx] ; mm01 = [cur] |
;----------------------------------------------------------------------------- |
341 |
|
; |
342 |
|
; void transfer_8to16sub2_xmm(int16_t * const dct, |
343 |
|
; uint8_t * const cur, |
344 |
|
; const uint8_t * ref1, |
345 |
|
; const uint8_t * ref2, |
346 |
|
; const uint32_t stride) |
347 |
|
; |
348 |
|
;----------------------------------------------------------------------------- |
349 |
|
|
350 |
|
%macro COPY_8_TO_16_SUB2_SSE 1 |
351 |
|
movq mm0, [eax] ; cur |
352 |
|
movq mm2, [eax+edx] |
353 |
movq mm1, mm0 |
movq mm1, mm0 |
|
|
|
|
punpcklbw mm0, mm7 |
|
|
punpckhbw mm1, mm7 |
|
|
|
|
|
movq mm4, [eax] |
|
|
movq mm5, mm4 |
|
|
|
|
|
punpcklbw mm4, mm7 |
|
|
punpckhbw mm5, mm7 |
|
|
|
|
|
movq mm2, [esi] ; mm23 = [ref] |
|
354 |
movq mm3, mm2 |
movq mm3, mm2 |
355 |
|
|
356 |
movq mm6, [ebx] |
punpcklbw mm0, mm7 |
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
357 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
358 |
|
movq mm4, [ebx] ; ref1 |
359 |
|
pavgb mm4, [esi] ; ref2 |
360 |
|
movq [eax], mm4 |
361 |
|
punpckhbw mm1, mm7 |
362 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
363 |
|
movq mm5, [ebx+edx] ; ref |
364 |
|
pavgb mm5, [esi+edx] ; ref2 |
365 |
|
movq [eax+edx], mm5 |
366 |
|
|
367 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
368 |
|
punpcklbw mm4, mm7 |
|
movq mm2, mm6 |
|
|
|
|
|
punpcklbw mm2, mm7 |
|
369 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
370 |
|
psubsw mm0, mm4 |
371 |
|
psubsw mm1, mm6 |
372 |
|
lea esi, [esi+2*edx] |
373 |
|
movq mm6, mm5 |
374 |
|
punpcklbw mm5, mm7 |
375 |
|
punpckhbw mm6, mm7 |
376 |
|
psubsw mm2, mm5 |
377 |
|
lea eax, [eax+2*edx] |
378 |
|
psubsw mm3, mm6 |
379 |
|
lea ebx, [ebx+2*edx] |
380 |
|
|
381 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
382 |
|
movq [ecx+%1*32+ 8], mm1 |
383 |
|
movq [ecx+%1*32+16], mm2 |
384 |
|
movq [ecx+%1*32+24], mm3 |
385 |
|
%endmacro |
386 |
|
|
387 |
psubsw mm1, mm3 |
ALIGN 16 |
388 |
|
transfer_8to16sub2_xmm: |
389 |
psubsw mm4, mm2 |
mov ecx, [esp + 4] ; Dst |
390 |
psubsw mm5, mm6 |
mov eax, [esp + 8] ; Cur |
391 |
|
push ebx |
392 |
movq [edi + 64], mm0 ; dct[] = mm01 |
mov ebx, [esp+4+12] ; Ref1 |
393 |
movq [edi + 72], mm1 |
push esi |
394 |
movq [edi + 80], mm4 |
mov esi, [esp+8+16] ; Ref2 |
395 |
movq [edi + 88], mm5 |
mov edx, [esp+8+20] ; Stride |
396 |
|
pxor mm7, mm7 |
|
add edx, ecx |
|
|
add esi, ecx |
|
|
add eax, ecx |
|
|
add ebx, ecx |
|
397 |
|
|
398 |
movq mm0, [edx] ; mm01 = [cur] |
COPY_8_TO_16_SUB2_SSE 0 |
399 |
movq mm1, mm0 |
COPY_8_TO_16_SUB2_SSE 1 |
400 |
|
COPY_8_TO_16_SUB2_SSE 2 |
401 |
|
COPY_8_TO_16_SUB2_SSE 3 |
402 |
|
|
403 |
punpcklbw mm0, mm7 |
pop esi |
404 |
punpckhbw mm1, mm7 |
pop ebx |
405 |
|
ret |
406 |
|
ENDFUNC |
407 |
|
|
|
movq mm4, [eax] |
|
|
movq mm5, mm4 |
|
408 |
|
|
409 |
punpcklbw mm4, mm7 |
;----------------------------------------------------------------------------- |
410 |
punpckhbw mm5, mm7 |
; |
411 |
|
; void transfer_8to16sub2ro_xmm(int16_t * const dct, |
412 |
|
; const uint8_t * const cur, |
413 |
|
; const uint8_t * ref1, |
414 |
|
; const uint8_t * ref2, |
415 |
|
; const uint32_t stride) |
416 |
|
; |
417 |
|
;----------------------------------------------------------------------------- |
418 |
|
|
419 |
movq mm2, [esi] ; mm23 = [ref] |
%macro COPY_8_TO_16_SUB2RO_SSE 1 |
420 |
|
movq mm0, [eax] ; cur |
421 |
|
movq mm2, [eax+edx] |
422 |
|
movq mm1, mm0 |
423 |
movq mm3, mm2 |
movq mm3, mm2 |
424 |
|
|
425 |
movq mm6, [ebx] |
punpcklbw mm0, mm7 |
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
426 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
427 |
|
movq mm4, [ebx] ; ref1 |
428 |
|
pavgb mm4, [esi] ; ref2 |
429 |
|
punpckhbw mm1, mm7 |
430 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
431 |
|
movq mm5, [ebx+edx] ; ref |
432 |
|
pavgb mm5, [esi+edx] ; ref2 |
433 |
|
|
434 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
435 |
|
punpcklbw mm4, mm7 |
|
movq mm2, mm6 |
|
|
|
|
|
punpcklbw mm2, mm7 |
|
436 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
437 |
|
psubsw mm0, mm4 |
438 |
|
psubsw mm1, mm6 |
439 |
|
lea esi, [esi+2*edx] |
440 |
|
movq mm6, mm5 |
441 |
|
punpcklbw mm5, mm7 |
442 |
|
punpckhbw mm6, mm7 |
443 |
|
psubsw mm2, mm5 |
444 |
|
lea eax, [eax+2*edx] |
445 |
|
psubsw mm3, mm6 |
446 |
|
lea ebx, [ebx+2*edx] |
447 |
|
|
448 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
449 |
|
movq [ecx+%1*32+ 8], mm1 |
450 |
|
movq [ecx+%1*32+16], mm2 |
451 |
|
movq [ecx+%1*32+24], mm3 |
452 |
|
%endmacro |
453 |
|
|
454 |
psubsw mm1, mm3 |
ALIGN 16 |
455 |
|
transfer_8to16sub2ro_xmm: |
456 |
psubsw mm4, mm2 |
pxor mm7, mm7 |
457 |
psubsw mm5, mm6 |
mov ecx, [esp + 4] ; Dst |
458 |
|
mov eax, [esp + 8] ; Cur |
459 |
|
push ebx |
460 |
|
mov ebx, [esp+4+12] ; Ref1 |
461 |
|
push esi |
462 |
|
mov esi, [esp+8+16] ; Ref2 |
463 |
|
mov edx, [esp+8+20] ; Stride |
464 |
|
|
465 |
movq [edi + 96], mm0 ; dct[] = mm01 |
COPY_8_TO_16_SUB2RO_SSE 0 |
466 |
movq [edi + 104], mm1 |
COPY_8_TO_16_SUB2RO_SSE 1 |
467 |
movq [edi + 112], mm4 |
COPY_8_TO_16_SUB2RO_SSE 2 |
468 |
movq [edi + 120], mm5 |
COPY_8_TO_16_SUB2RO_SSE 3 |
469 |
|
|
|
pop ebx |
|
|
pop edi |
|
470 |
pop esi |
pop esi |
471 |
|
pop ebx |
472 |
ret |
ret |
473 |
|
ENDFUNC |
474 |
|
|
475 |
|
|
476 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
477 |
; |
; |
478 |
; void transfer_16to8add_mmx(uint8_t * const dst, |
; void transfer_16to8add_mmx(uint8_t * const dst, |
479 |
; const int16_t * const src, |
; const int16_t * const src, |
480 |
; uint32_t stride); |
; uint32_t stride); |
481 |
; |
; |
482 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
align 16 |
|
|
cglobal transfer_16to8add_mmx |
|
|
transfer_16to8add_mmx |
|
|
|
|
|
push esi |
|
|
push edi |
|
|
|
|
|
mov edi, [esp + 8 + 4] ; dst |
|
|
mov esi, [esp + 8 + 8] ; src |
|
|
mov ecx, [esp + 8 + 12] ; stride |
|
|
|
|
|
pxor mm7, mm7 |
|
483 |
|
|
484 |
mov eax, 8 |
%macro COPY_16_TO_8_ADD 1 |
485 |
|
movq mm0, [ecx] |
486 |
.loop |
movq mm2, [ecx+edx] |
|
movq mm0, [edi] |
|
487 |
movq mm1, mm0 |
movq mm1, mm0 |
488 |
punpcklbw mm0, mm7 ; mm23 = unpack([dst]) |
movq mm3, mm2 |
489 |
|
punpcklbw mm0, mm7 |
490 |
|
punpcklbw mm2, mm7 |
491 |
punpckhbw mm1, mm7 |
punpckhbw mm1, mm7 |
492 |
|
punpckhbw mm3, mm7 |
493 |
|
paddsw mm0, [eax+%1*32+ 0] |
494 |
|
paddsw mm1, [eax+%1*32+ 8] |
495 |
|
paddsw mm2, [eax+%1*32+16] |
496 |
|
paddsw mm3, [eax+%1*32+24] |
497 |
|
packuswb mm0, mm1 |
498 |
|
movq [ecx], mm0 |
499 |
|
packuswb mm2, mm3 |
500 |
|
movq [ecx+edx], mm2 |
501 |
|
%endmacro |
502 |
|
|
|
movq mm2, [esi] ; mm01 = [src] |
|
|
movq mm3, [esi + 8] |
|
503 |
|
|
504 |
paddsw mm0, mm2 ; mm01 += mm23 |
ALIGN 16 |
505 |
paddsw mm1, mm3 |
transfer_16to8add_mmx: |
506 |
|
mov ecx, [esp+ 4] ; Dst |
507 |
|
mov eax, [esp+ 8] ; Src |
508 |
|
mov edx, [esp+12] ; Stride |
509 |
|
pxor mm7, mm7 |
510 |
|
|
511 |
packuswb mm0, mm1 ; [dst] = pack(mm01) |
COPY_16_TO_8_ADD 0 |
512 |
movq [edi], mm0 |
lea ecx,[ecx+2*edx] |
513 |
|
COPY_16_TO_8_ADD 1 |
514 |
|
lea ecx,[ecx+2*edx] |
515 |
|
COPY_16_TO_8_ADD 2 |
516 |
|
lea ecx,[ecx+2*edx] |
517 |
|
COPY_16_TO_8_ADD 3 |
518 |
|
ret |
519 |
|
ENDFUNC |
520 |
|
|
521 |
add esi, 16 |
;----------------------------------------------------------------------------- |
522 |
add edi, ecx |
; |
523 |
dec eax |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
524 |
jnz .loop |
; const uint8_t * const src, |
525 |
|
; const uint32_t stride); |
526 |
|
; |
527 |
|
; |
528 |
|
;----------------------------------------------------------------------------- |
529 |
|
|
530 |
pop edi |
%macro COPY_8_TO_8 0 |
531 |
pop esi |
movq mm0, [eax] |
532 |
|
movq mm1, [eax+edx] |
533 |
|
movq [ecx], mm0 |
534 |
|
lea eax, [eax+2*edx] |
535 |
|
movq [ecx+edx], mm1 |
536 |
|
%endmacro |
537 |
|
|
538 |
|
ALIGN 16 |
539 |
|
transfer8x8_copy_mmx: |
540 |
|
mov ecx, [esp+ 4] ; Dst |
541 |
|
mov eax, [esp+ 8] ; Src |
542 |
|
mov edx, [esp+12] ; Stride |
543 |
|
|
544 |
|
COPY_8_TO_8 |
545 |
|
lea ecx,[ecx+2*edx] |
546 |
|
COPY_8_TO_8 |
547 |
|
lea ecx,[ecx+2*edx] |
548 |
|
COPY_8_TO_8 |
549 |
|
lea ecx,[ecx+2*edx] |
550 |
|
COPY_8_TO_8 |
551 |
ret |
ret |
552 |
|
ENDFUNC |
553 |
|
|
554 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
555 |
; |
; |
556 |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
; void transfer8x4_copy_mmx(uint8_t * const dst, |
557 |
; const uint8_t * const src, |
; const uint8_t * const src, |
558 |
; const uint32_t stride); |
; const uint32_t stride); |
559 |
; |
; |
560 |
; |
; |
561 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
562 |
|
|
563 |
align 16 |
ALIGN 16 |
564 |
cglobal transfer8x8_copy_mmx |
transfer8x4_copy_mmx: |
565 |
transfer8x8_copy_mmx |
mov ecx, [esp+ 4] ; Dst |
566 |
push esi |
mov eax, [esp+ 8] ; Src |
567 |
push edi |
mov edx, [esp+12] ; Stride |
568 |
|
|
569 |
|
COPY_8_TO_8 |
570 |
|
lea ecx,[ecx+2*edx] |
571 |
|
COPY_8_TO_8 |
572 |
|
ret |
573 |
|
ENDFUNC |
574 |
|
|
|
mov edi, [esp + 8 + 4] ; dst [out] |
|
|
mov esi, [esp + 8 + 8] ; src [in] |
|
|
mov eax, [esp + 8 + 12] ; stride [in] |
|
|
|
|
|
movq mm0, [esi] |
|
|
movq mm1, [esi+eax] |
|
|
movq [edi], mm0 |
|
|
movq [edi+eax], mm1 |
|
|
|
|
|
add esi, eax |
|
|
add edi, eax |
|
|
add esi, eax |
|
|
add edi, eax |
|
|
|
|
|
movq mm0, [esi] |
|
|
movq mm1, [esi+eax] |
|
|
movq [edi], mm0 |
|
|
movq [edi+eax], mm1 |
|
|
|
|
|
add esi, eax |
|
|
add edi, eax |
|
|
add esi, eax |
|
|
add edi, eax |
|
|
|
|
|
movq mm0, [esi] |
|
|
movq mm1, [esi+eax] |
|
|
movq [edi], mm0 |
|
|
movq [edi+eax], mm1 |
|
|
|
|
|
add esi, eax |
|
|
add edi, eax |
|
|
add esi, eax |
|
|
add edi, eax |
|
|
|
|
|
movq mm0, [esi] |
|
|
movq mm1, [esi+eax] |
|
|
movq [edi], mm0 |
|
|
movq [edi+eax], mm1 |
|
|
|
|
|
add esi, eax |
|
|
add edi, eax |
|
|
add esi, eax |
|
|
add edi, eax |
|
575 |
|
|
576 |
pop edi |
%ifidn __OUTPUT_FORMAT__,elf |
577 |
pop esi |
section ".note.GNU-stack" noalloc noexec nowrite progbits |
578 |
|
%endif |
579 |
|
|
|
ret |
|