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: mem_transfer_mmx.asm,v 1.14 2004-08-22 11:46:10 edgomez Exp $ |
|
|
|
|
;/************************************************************************** |
|
|
; * |
|
|
; * History: |
|
25 |
; * |
; * |
26 |
; * 07.01.2002 merge functions from compensate_mmx; rename functions |
; ***************************************************************************/ |
|
; * 07.11.2001 initial version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
|
; * |
|
|
; *************************************************************************/ |
|
|
|
|
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 |
34 |
|
%define %1 _%1:function |
35 |
|
%else |
36 |
global _%1 |
global _%1 |
37 |
%define %1 _%1 |
%define %1 _%1 |
38 |
|
%endif |
39 |
|
%else |
40 |
|
%ifdef MARK_FUNCS |
41 |
|
global %1:function |
42 |
%else |
%else |
43 |
global %1 |
global %1 |
44 |
%endif |
%endif |
45 |
|
%endif |
46 |
%endmacro |
%endmacro |
47 |
|
|
48 |
|
;============================================================================= |
49 |
|
; Read only data |
50 |
|
;============================================================================= |
51 |
|
|
52 |
section .text |
%ifdef FORMAT_COFF |
53 |
|
SECTION .rodata |
54 |
|
%else |
55 |
|
SECTION .rodata align=16 |
56 |
|
%endif |
57 |
|
|
58 |
|
ALIGN 16 |
59 |
|
mmx_one: |
60 |
|
dw 1, 1, 1, 1 |
61 |
|
|
62 |
|
;============================================================================= |
63 |
|
; Code |
64 |
|
;============================================================================= |
65 |
|
|
66 |
|
SECTION .text |
67 |
|
|
68 |
|
cglobal transfer_8to16copy_mmx |
69 |
|
cglobal transfer_16to8copy_mmx |
70 |
|
cglobal transfer_8to16sub_mmx |
71 |
|
cglobal transfer_8to16subro_mmx |
72 |
|
cglobal transfer_8to16sub2_mmx |
73 |
|
cglobal transfer_8to16sub2_xmm |
74 |
|
cglobal transfer_16to8add_mmx |
75 |
|
cglobal transfer8x8_copy_mmx |
76 |
|
|
77 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
78 |
; |
; |
79 |
; void transfer_8to16copy_mmx(int16_t * const dst, |
; void transfer_8to16copy_mmx(int16_t * const dst, |
80 |
; const uint8_t * const src, |
; const uint8_t * const src, |
81 |
; uint32_t stride); |
; uint32_t stride); |
82 |
; |
; |
83 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
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 |
|
84 |
|
|
85 |
mov eax, 8 |
%macro COPY_8_TO_16 1 |
86 |
|
movq mm0, [eax] |
87 |
.loop |
movq mm1, [eax+edx] |
88 |
movq mm0, [esi] |
movq mm2, mm0 |
89 |
movq mm1, mm0 |
movq mm3, mm1 |
90 |
punpcklbw mm0, mm7 ; mm01 = unpack([src]) |
punpcklbw mm0, mm7 |
91 |
punpckhbw mm1, mm7 |
movq [ecx+%1*32], mm0 |
92 |
|
punpcklbw mm1, mm7 |
93 |
movq [edi], mm0 ; [dst] = mm01 |
movq [ecx+%1*32+16], mm1 |
94 |
movq [edi + 8], mm1 |
punpckhbw mm2, mm7 |
95 |
|
punpckhbw mm3, mm7 |
96 |
|
lea eax, [eax+2*edx] |
97 |
|
movq [ecx+%1*32+8], mm2 |
98 |
|
movq [ecx+%1*32+24], mm3 |
99 |
|
%endmacro |
100 |
|
|
101 |
add edi, 16 |
ALIGN 16 |
102 |
add esi, ecx |
transfer_8to16copy_mmx: |
|
dec eax |
|
|
jnz .loop |
|
103 |
|
|
104 |
pop edi |
mov ecx, [esp+ 4] ; Dst |
105 |
pop esi |
mov eax, [esp+ 8] ; Src |
106 |
|
mov edx, [esp+12] ; Stride |
107 |
|
pxor mm7, mm7 |
108 |
|
|
109 |
|
COPY_8_TO_16 0 |
110 |
|
COPY_8_TO_16 1 |
111 |
|
COPY_8_TO_16 2 |
112 |
|
COPY_8_TO_16 3 |
113 |
ret |
ret |
114 |
|
|
115 |
|
;----------------------------------------------------------------------------- |
|
|
|
|
;=========================================================================== |
|
116 |
; |
; |
117 |
; void transfer_16to8copy_mmx(uint8_t * const dst, |
; void transfer_16to8copy_mmx(uint8_t * const dst, |
118 |
; const int16_t * const src, |
; const int16_t * const src, |
119 |
; uint32_t stride); |
; uint32_t stride); |
120 |
; |
; |
121 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
align 16 |
|
|
cglobal transfer_16to8copy_mmx |
|
|
transfer_16to8copy_mmx |
|
|
|
|
|
push esi |
|
|
push edi |
|
|
|
|
|
mov edi, [esp + 8 + 4] ; dst |
|
|
mov esi, [esp + 8 + 8] ; src |
|
|
mov ecx, [esp + 8 + 12] ; stride |
|
122 |
|
|
123 |
mov eax, 8 |
%macro COPY_16_TO_8 1 |
124 |
|
movq mm0, [eax+%1*32] |
125 |
.loop |
movq mm1, [eax+%1*32+8] |
126 |
movq mm0, [esi] |
packuswb mm0, mm1 |
127 |
packuswb mm0, [esi + 8] ; mm0 = pack([src]) |
movq [ecx], mm0 |
128 |
|
movq mm2, [eax+%1*32+16] |
129 |
movq [edi], mm0 ; [dst] = mm0 |
movq mm3, [eax+%1*32+24] |
130 |
|
packuswb mm2, mm3 |
131 |
add esi, 16 |
movq [ecx+edx], mm2 |
132 |
add edi, ecx |
%endmacro |
|
dec eax |
|
|
jnz .loop |
|
133 |
|
|
134 |
pop edi |
ALIGN 16 |
135 |
pop esi |
transfer_16to8copy_mmx: |
136 |
|
|
137 |
|
mov ecx, [esp+ 4] ; Dst |
138 |
|
mov eax, [esp+ 8] ; Src |
139 |
|
mov edx, [esp+12] ; Stride |
140 |
|
|
141 |
|
COPY_16_TO_8 0 |
142 |
|
lea ecx,[ecx+2*edx] |
143 |
|
COPY_16_TO_8 1 |
144 |
|
lea ecx,[ecx+2*edx] |
145 |
|
COPY_16_TO_8 2 |
146 |
|
lea ecx,[ecx+2*edx] |
147 |
|
COPY_16_TO_8 3 |
148 |
ret |
ret |
149 |
|
|
150 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
151 |
; |
; |
152 |
; void transfer_8to16sub_mmx(int16_t * const dct, |
; void transfer_8to16sub_mmx(int16_t * const dct, |
153 |
; uint8_t * const cur, |
; uint8_t * const cur, |
154 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
155 |
; const uint32_t stride); |
; const uint32_t stride); |
156 |
; |
; |
157 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
;/************************************************************************** |
|
|
; * |
|
|
; * 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> |
|
|
; * |
|
|
; *************************************************************************/ |
|
|
|
|
|
align 16 |
|
|
cglobal transfer_8to16sub_mmx |
|
|
transfer_8to16sub_mmx |
|
|
push esi |
|
|
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 |
|
158 |
|
|
159 |
pxor mm7, mm7 ; mm7 = zero |
; when second argument == 1, reference (ebx) block is to current (eax) |
160 |
|
%macro COPY_8_TO_16_SUB 2 |
161 |
movq mm0, [edx] ; mm01 = [cur] |
movq mm0, [eax] ; cur |
162 |
|
movq mm2, [eax+edx] |
163 |
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] |
|
164 |
movq mm3, mm2 |
movq mm3, mm2 |
165 |
|
|
|
movq mm6, [ebx] |
|
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
|
punpcklbw mm2, mm7 |
|
|
punpckhbw mm3, mm7 |
|
|
|
|
|
psubsw mm0, mm2 ; mm01 -= mm23 |
|
|
|
|
|
movq mm2, mm6 |
|
|
|
|
|
punpcklbw mm2, mm7 |
|
|
punpckhbw mm6, mm7 |
|
|
|
|
|
psubsw mm1, mm3 |
|
|
|
|
|
psubsw mm4, mm2 |
|
|
psubsw mm5, mm6 |
|
|
|
|
|
movq [edi], mm0 ; dct[] = mm01 |
|
|
movq [edi + 8], mm1 |
|
|
movq [edi + 16], mm4 |
|
|
movq [edi + 24], mm5 |
|
|
|
|
|
add edx, ecx |
|
|
add esi, ecx |
|
|
add eax, ecx |
|
|
add ebx, ecx |
|
|
|
|
|
movq mm0, [edx] ; mm01 = [cur] |
|
|
movq mm1, mm0 |
|
|
|
|
166 |
punpcklbw mm0, mm7 |
punpcklbw mm0, mm7 |
|
punpckhbw mm1, mm7 |
|
|
|
|
|
movq mm4, [eax] |
|
|
movq mm5, mm4 |
|
|
|
|
|
punpcklbw mm4, mm7 |
|
|
punpckhbw mm5, mm7 |
|
|
|
|
|
movq mm2, [esi] ; mm23 = [ref] |
|
|
movq mm3, mm2 |
|
|
|
|
|
movq mm6, [ebx] |
|
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
167 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
168 |
|
movq mm4, [ebx] ; ref |
169 |
|
punpckhbw mm1, mm7 |
170 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
171 |
|
movq mm5, [ebx+edx] ; ref |
172 |
|
|
173 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
174 |
|
%if %2 == 1 |
175 |
movq mm2, mm6 |
movq [eax], mm4 |
176 |
|
movq [eax+edx], mm5 |
177 |
punpcklbw mm2, mm7 |
%endif |
178 |
|
punpcklbw mm4, mm7 |
179 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
180 |
|
psubsw mm0, mm4 |
181 |
|
psubsw mm1, mm6 |
182 |
|
movq mm6, mm5 |
183 |
|
punpcklbw mm5, mm7 |
184 |
|
punpckhbw mm6, mm7 |
185 |
|
psubsw mm2, mm5 |
186 |
|
lea eax, [eax+2*edx] |
187 |
|
psubsw mm3, mm6 |
188 |
|
lea ebx,[ebx+2*edx] |
189 |
|
|
190 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
191 |
|
movq [ecx+%1*32+ 8], mm1 |
192 |
|
movq [ecx+%1*32+16], mm2 |
193 |
|
movq [ecx+%1*32+24], mm3 |
194 |
|
%endmacro |
195 |
|
|
196 |
psubsw mm1, mm3 |
ALIGN 16 |
197 |
|
transfer_8to16sub_mmx: |
198 |
psubsw mm4, mm2 |
mov ecx, [esp + 4] ; Dst |
199 |
psubsw mm5, mm6 |
mov eax, [esp + 8] ; Cur |
200 |
|
push ebx |
201 |
|
mov ebx, [esp+4+12] ; Ref |
202 |
|
mov edx, [esp+4+16] ; Stride |
203 |
|
pxor mm7, mm7 |
204 |
|
|
205 |
movq [edi + 32], mm0 ; dct[] = mm01 |
COPY_8_TO_16_SUB 0, 1 |
206 |
movq [edi + 40], mm1 |
COPY_8_TO_16_SUB 1, 1 |
207 |
movq [edi + 48], mm4 |
COPY_8_TO_16_SUB 2, 1 |
208 |
movq [edi + 56], mm5 |
COPY_8_TO_16_SUB 3, 1 |
|
|
|
|
add edx, ecx |
|
|
add esi, ecx |
|
|
add eax, ecx |
|
|
add ebx, ecx |
|
209 |
|
|
210 |
movq mm0, [edx] ; mm01 = [cur] |
pop ebx |
211 |
movq mm1, mm0 |
ret |
212 |
|
|
|
punpcklbw mm0, mm7 |
|
|
punpckhbw mm1, mm7 |
|
213 |
|
|
214 |
movq mm4, [eax] |
ALIGN 16 |
215 |
movq mm5, mm4 |
transfer_8to16subro_mmx: |
216 |
|
mov ecx, [esp + 4] ; Dst |
217 |
|
mov eax, [esp + 8] ; Cur |
218 |
|
push ebx |
219 |
|
mov ebx, [esp+4+12] ; Ref |
220 |
|
mov edx, [esp+4+16] ; Stride |
221 |
|
pxor mm7, mm7 |
222 |
|
|
223 |
punpcklbw mm4, mm7 |
COPY_8_TO_16_SUB 0, 0 |
224 |
punpckhbw mm5, mm7 |
COPY_8_TO_16_SUB 1, 0 |
225 |
|
COPY_8_TO_16_SUB 2, 0 |
226 |
|
COPY_8_TO_16_SUB 3, 0 |
227 |
|
|
228 |
movq mm2, [esi] ; mm23 = [ref] |
pop ebx |
229 |
movq mm3, mm2 |
ret |
230 |
|
|
|
movq mm6, [ebx] |
|
231 |
|
|
232 |
movq [edx], mm2 ; [cur] = [ref] |
;----------------------------------------------------------------------------- |
233 |
movq [eax], mm6 |
; |
234 |
|
; void transfer_8to16sub2_mmx(int16_t * const dct, |
235 |
|
; uint8_t * const cur, |
236 |
|
; const uint8_t * ref1, |
237 |
|
; const uint8_t * ref2, |
238 |
|
; const uint32_t stride) |
239 |
|
; |
240 |
|
;----------------------------------------------------------------------------- |
241 |
|
|
242 |
punpcklbw mm2, mm7 |
%macro COPY_8_TO_16_SUB2_MMX 1 |
243 |
|
movq mm0, [eax] ; cur |
244 |
|
movq mm2, [eax+edx] |
245 |
|
|
246 |
|
; mm4 <- (ref1+ref2+1) / 2 |
247 |
|
movq mm4, [ebx] ; ref1 |
248 |
|
movq mm1, [esi] ; ref2 |
249 |
|
movq mm6, mm4 |
250 |
|
movq mm3, mm1 |
251 |
|
punpcklbw mm4, mm7 |
252 |
|
punpcklbw mm1, mm7 |
253 |
|
punpckhbw mm6, mm7 |
254 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
255 |
|
paddusw mm4, mm1 |
256 |
psubsw mm0, mm2 ; mm01 -= mm23 |
paddusw mm6, mm3 |
257 |
|
paddusw mm4, [mmx_one] |
258 |
movq mm2, mm6 |
paddusw mm6, [mmx_one] |
259 |
|
psrlw mm4, 1 |
260 |
punpcklbw mm2, mm7 |
psrlw mm6, 1 |
261 |
|
packuswb mm4, mm6 |
262 |
|
movq [eax], mm4 |
263 |
|
|
264 |
|
; mm5 <- (ref1+ref2+1) / 2 |
265 |
|
movq mm5, [ebx+edx] ; ref1 |
266 |
|
movq mm1, [esi+edx] ; ref2 |
267 |
|
movq mm6, mm5 |
268 |
|
movq mm3, mm1 |
269 |
|
punpcklbw mm5, mm7 |
270 |
|
punpcklbw mm1, mm7 |
271 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
272 |
|
punpckhbw mm3, mm7 |
273 |
|
paddusw mm5, mm1 |
274 |
|
paddusw mm6, mm3 |
275 |
|
paddusw mm5, [mmx_one] |
276 |
|
paddusw mm6, [mmx_one] |
277 |
|
lea esi, [esi+2*edx] |
278 |
|
psrlw mm5, 1 |
279 |
|
psrlw mm6, 1 |
280 |
|
packuswb mm5, mm6 |
281 |
|
movq [eax+edx], mm5 |
282 |
|
|
|
psubsw mm1, mm3 |
|
|
|
|
|
psubsw mm4, mm2 |
|
|
psubsw mm5, mm6 |
|
|
|
|
|
movq [edi + 64], mm0 ; dct[] = mm01 |
|
|
movq [edi + 72], mm1 |
|
|
movq [edi + 80], mm4 |
|
|
movq [edi + 88], mm5 |
|
|
|
|
|
add edx, ecx |
|
|
add esi, ecx |
|
|
add eax, ecx |
|
|
add ebx, ecx |
|
|
|
|
|
movq mm0, [edx] ; mm01 = [cur] |
|
283 |
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] |
|
284 |
movq mm3, mm2 |
movq mm3, mm2 |
285 |
|
punpcklbw mm0, mm7 |
|
movq mm6, [ebx] |
|
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
286 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
287 |
|
punpckhbw mm1, mm7 |
288 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
289 |
|
|
290 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
291 |
|
punpcklbw mm4, mm7 |
|
movq mm2, mm6 |
|
|
|
|
|
punpcklbw mm2, mm7 |
|
292 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
293 |
|
psubsw mm0, mm4 |
294 |
|
psubsw mm1, mm6 |
295 |
|
movq mm6, mm5 |
296 |
|
punpcklbw mm5, mm7 |
297 |
|
punpckhbw mm6, mm7 |
298 |
|
psubsw mm2, mm5 |
299 |
|
lea eax, [eax+2*edx] |
300 |
|
psubsw mm3, mm6 |
301 |
|
lea ebx, [ebx+2*edx] |
302 |
|
|
303 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
304 |
|
movq [ecx+%1*32+ 8], mm1 |
305 |
|
movq [ecx+%1*32+16], mm2 |
306 |
|
movq [ecx+%1*32+24], mm3 |
307 |
|
%endmacro |
308 |
|
|
309 |
psubsw mm1, mm3 |
ALIGN 16 |
310 |
|
transfer_8to16sub2_mmx: |
311 |
psubsw mm4, mm2 |
mov ecx, [esp + 4] ; Dst |
312 |
psubsw mm5, mm6 |
mov eax, [esp + 8] ; Cur |
313 |
|
push ebx |
314 |
|
mov ebx, [esp+4+12] ; Ref1 |
315 |
|
push esi |
316 |
|
mov esi, [esp+8+16] ; Ref2 |
317 |
|
mov edx, [esp+8+20] ; Stride |
318 |
|
pxor mm7, mm7 |
319 |
|
|
320 |
movq [edi + 96], mm0 ; dct[] = mm01 |
COPY_8_TO_16_SUB2_MMX 0 |
321 |
movq [edi + 104], mm1 |
COPY_8_TO_16_SUB2_MMX 1 |
322 |
movq [edi + 112], mm4 |
COPY_8_TO_16_SUB2_MMX 2 |
323 |
movq [edi + 120], mm5 |
COPY_8_TO_16_SUB2_MMX 3 |
324 |
|
|
|
pop ebx |
|
|
pop edi |
|
325 |
pop esi |
pop esi |
326 |
|
pop ebx |
327 |
ret |
ret |
328 |
|
|
329 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
330 |
; |
; |
331 |
; void transfer_8to16sub2_xmm(int16_t * const dct, |
; void transfer_8to16sub2_xmm(int16_t * const dct, |
332 |
; uint8_t * const cur, |
; uint8_t * const cur, |
333 |
; const uint8_t * ref1, |
; const uint8_t * ref1, |
334 |
; const uint8_t * ref2, |
; const uint8_t * ref2, |
335 |
; const uint32_t stride); |
; const uint32_t stride) |
336 |
; |
; |
337 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
align 16 |
|
|
cglobal transfer_8to16sub2_xmm |
|
|
transfer_8to16sub2_xmm |
|
|
|
|
|
push edi |
|
|
push esi |
|
|
push ebx |
|
|
|
|
|
mov edi, [esp + 12 + 4] ; edi = &dct |
|
|
mov esi, [esp + 12 + 8] ; esi = &cur |
|
|
mov ebx, [esp + 12 + 12] ; ebx = &ref1 |
|
|
mov edx, [esp + 12 + 16] ; edx = &ref2 |
|
|
mov eax, [esp + 12 + 20] ; eax = stride |
|
|
|
|
|
pxor mm7, mm7 ; mm7 = 0 |
|
|
shl eax, 1 ; eax = stride<<1 |
|
|
|
|
|
; Row processing |
|
|
; One row at a time |
|
|
movq mm0, [esi + 0] ; mm0 = cur row |
|
|
movq mm2, [ebx + 0] ; mm2 = ref1 row |
|
|
movq mm3, [edx + 0] ; mm3 = ref2 row |
|
|
movq mm1, mm0 ; mm1 = cur row |
|
|
|
|
|
pavgb mm2, mm3 ; mm2 = (ref1 + ref2 + 1)/2 (== avg) |
|
|
punpcklbw mm0, mm7 ; mm0 = cur(3-0) <-> 16bit |
|
|
|
|
|
movq mm3,mm2 ; mm3 = avg |
|
|
punpckhbw mm1, mm7 ; mm1 = cur(7-4) <-> 16bit |
|
|
|
|
|
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
|
|
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
|
|
|
|
|
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
|
|
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
|
|
|
|
|
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
|
|
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
|
|
|
|
|
; Increment all pointers |
|
|
add edi, eax ; edi = &(next dct row) |
|
|
|
|
|
; Row processing |
|
|
; One row at a time |
|
|
movq mm0, [esi + 8] ; mm0 = cur row |
|
|
movq mm2, [ebx + 8] ; mm2 = ref1 row |
|
|
movq mm3, [edx + 8] ; mm3 = ref2 row |
|
|
movq mm1, mm0 ; mm1 = cur row |
|
|
|
|
|
pavgb mm2, mm3 ; mm2 = (ref1 + ref2 + 1)/2 (== avg) |
|
|
punpcklbw mm0, mm7 ; mm0 = cur(3-0) <-> 16bit |
|
|
|
|
|
movq mm3,mm2 ; mm3 = avg |
|
|
punpckhbw mm1, mm7 ; mm1 = cur(7-4) <-> 16bit |
|
|
|
|
|
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
|
|
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
|
|
|
|
|
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
|
|
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
|
|
|
|
|
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
|
|
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
|
|
|
|
|
; Increment all pointers |
|
|
add edi, eax ; edi = &(next dct row) |
|
|
|
|
|
; Row processing |
|
|
; One row at a time |
|
|
movq mm0, [esi + 16] ; mm0 = cur row |
|
|
movq mm2, [ebx + 16] ; mm2 = ref1 row |
|
|
movq mm3, [edx + 16] ; mm3 = ref2 row |
|
|
movq mm1, mm0 ; mm1 = cur row |
|
|
|
|
|
pavgb mm2, mm3 ; mm2 = (ref1 + ref2 + 1)/2 (== avg) |
|
|
punpcklbw mm0, mm7 ; mm0 = cur(3-0) <-> 16bit |
|
|
|
|
|
movq mm3,mm2 ; mm3 = avg |
|
|
punpckhbw mm1, mm7 ; mm1 = cur(7-4) <-> 16bit |
|
|
|
|
|
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
|
|
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
|
|
|
|
|
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
|
|
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
|
|
|
|
|
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
|
|
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
|
|
|
|
|
; Increment all pointers |
|
|
add edi, eax ; edi = &(next dct row) |
|
|
|
|
|
; Row processing |
|
|
; One row at a time |
|
|
movq mm0, [esi + 24] ; mm0 = cur row |
|
|
movq mm2, [ebx + 24] ; mm2 = ref1 row |
|
|
movq mm3, [edx + 24] ; mm3 = ref2 row |
|
|
movq mm1, mm0 ; mm1 = cur row |
|
|
|
|
|
pavgb mm2, mm3 ; mm2 = (ref1 + ref2 + 1)/2 (== avg) |
|
|
punpcklbw mm0, mm7 ; mm0 = cur(3-0) <-> 16bit |
|
|
|
|
|
movq mm3,mm2 ; mm3 = avg |
|
|
punpckhbw mm1, mm7 ; mm1 = cur(7-4) <-> 16bit |
|
|
|
|
|
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
|
|
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
|
|
|
|
|
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
|
|
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
|
|
|
|
|
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
|
|
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
|
|
|
|
|
; Increment all pointers |
|
|
add edi, eax ; edi = &(next dct row) |
|
|
|
|
|
; Row processing |
|
|
; One row at a time |
|
|
movq mm0, [esi + 32] ; mm0 = cur row |
|
|
movq mm2, [ebx + 32] ; mm2 = ref1 row |
|
|
movq mm3, [edx + 32] ; mm3 = ref2 row |
|
|
movq mm1, mm0 ; mm1 = cur row |
|
338 |
|
|
339 |
pavgb mm2, mm3 ; mm2 = (ref1 + ref2 + 1)/2 (== avg) |
%macro COPY_8_TO_16_SUB2_SSE 1 |
340 |
punpcklbw mm0, mm7 ; mm0 = cur(3-0) <-> 16bit |
movq mm0, [eax] ; cur |
341 |
|
movq mm2, [eax+edx] |
342 |
movq mm3,mm2 ; mm3 = avg |
movq mm1, mm0 |
343 |
punpckhbw mm1, mm7 ; mm1 = cur(7-4) <-> 16bit |
movq mm3, mm2 |
|
|
|
|
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
|
|
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
|
|
|
|
|
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
|
|
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
|
|
|
|
|
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
|
|
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
|
|
|
|
|
; Increment all pointers |
|
|
add edi, eax ; edi = &(next dct row) |
|
|
|
|
|
; Row processing |
|
|
; One row at a time |
|
|
movq mm0, [esi + 40] ; mm0 = cur row |
|
|
movq mm2, [ebx + 40] ; mm2 = ref1 row |
|
|
movq mm3, [edx + 40] ; mm3 = ref2 row |
|
|
movq mm1, mm0 ; mm1 = cur row |
|
|
|
|
|
pavgb mm2, mm3 ; mm2 = (ref1 + ref2 + 1)/2 (== avg) |
|
|
punpcklbw mm0, mm7 ; mm0 = cur(3-0) <-> 16bit |
|
|
|
|
|
movq mm3,mm2 ; mm3 = avg |
|
|
punpckhbw mm1, mm7 ; mm1 = cur(7-4) <-> 16bit |
|
|
|
|
|
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
|
|
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
|
|
|
|
|
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
|
|
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
|
|
|
|
|
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
|
|
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
|
|
|
|
|
; Increment all pointers |
|
|
add edi, eax ; edi = &(next dct row) |
|
|
|
|
|
; Row processing |
|
|
; One row at a time |
|
|
movq mm0, [esi + 48] ; mm0 = cur row |
|
|
movq mm2, [ebx + 48] ; mm2 = ref1 row |
|
|
movq mm3, [edx + 48] ; mm3 = ref2 row |
|
|
movq mm1, mm0 ; mm1 = cur row |
|
|
|
|
|
pavgb mm2, mm3 ; mm2 = (ref1 + ref2 + 1)/2 (== avg) |
|
|
punpcklbw mm0, mm7 ; mm0 = cur(3-0) <-> 16bit |
|
|
|
|
|
movq mm3,mm2 ; mm3 = avg |
|
|
punpckhbw mm1, mm7 ; mm1 = cur(7-4) <-> 16bit |
|
|
|
|
|
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
|
|
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
|
|
|
|
|
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
|
|
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
|
|
|
|
|
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
|
|
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
|
|
|
|
|
; Increment all pointers |
|
|
add edi, eax ; edi = &(next dct row) |
|
|
|
|
|
; Row processing |
|
|
; One row at a time |
|
|
movq mm0, [esi + 56] ; mm0 = cur row |
|
|
movq mm2, [ebx + 56] ; mm2 = ref1 row |
|
|
movq mm3, [edx + 56] ; mm3 = ref2 row |
|
|
movq mm1, mm0 ; mm1 = cur row |
|
|
|
|
|
pavgb mm2, mm3 ; mm2 = (ref1 + ref2 + 1)/2 (== avg) |
|
|
punpcklbw mm0, mm7 ; mm0 = cur(3-0) <-> 16bit |
|
|
|
|
|
movq mm3,mm2 ; mm3 = avg |
|
|
punpckhbw mm1, mm7 ; mm1 = cur(7-4) <-> 16bit |
|
344 |
|
|
345 |
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
punpcklbw mm0, mm7 |
346 |
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
punpcklbw mm2, mm7 |
347 |
|
movq mm4, [ebx] ; ref1 |
348 |
|
pavgb mm4, [esi] ; ref2 |
349 |
|
movq [eax], mm4 |
350 |
|
punpckhbw mm1, mm7 |
351 |
|
punpckhbw mm3, mm7 |
352 |
|
movq mm5, [ebx+edx] ; ref |
353 |
|
pavgb mm5, [esi+edx] ; ref2 |
354 |
|
movq [eax+edx], mm5 |
355 |
|
|
356 |
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
movq mm6, mm4 |
357 |
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
punpcklbw mm4, mm7 |
358 |
|
punpckhbw mm6, mm7 |
359 |
|
psubsw mm0, mm4 |
360 |
|
psubsw mm1, mm6 |
361 |
|
lea esi, [esi+2*edx] |
362 |
|
movq mm6, mm5 |
363 |
|
punpcklbw mm5, mm7 |
364 |
|
punpckhbw mm6, mm7 |
365 |
|
psubsw mm2, mm5 |
366 |
|
lea eax, [eax+2*edx] |
367 |
|
psubsw mm3, mm6 |
368 |
|
lea ebx, [ebx+2*edx] |
369 |
|
|
370 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
371 |
|
movq [ecx+%1*32+ 8], mm1 |
372 |
|
movq [ecx+%1*32+16], mm2 |
373 |
|
movq [ecx+%1*32+24], mm3 |
374 |
|
%endmacro |
375 |
|
|
376 |
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
ALIGN 16 |
377 |
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
transfer_8to16sub2_xmm: |
378 |
|
mov ecx, [esp + 4] ; Dst |
379 |
|
mov eax, [esp + 8] ; Cur |
380 |
|
push ebx |
381 |
|
mov ebx, [esp+4+12] ; Ref1 |
382 |
|
push esi |
383 |
|
mov esi, [esp+8+16] ; Ref2 |
384 |
|
mov edx, [esp+8+20] ; Stride |
385 |
|
pxor mm7, mm7 |
386 |
|
|
387 |
; Exit |
COPY_8_TO_16_SUB2_SSE 0 |
388 |
|
COPY_8_TO_16_SUB2_SSE 1 |
389 |
|
COPY_8_TO_16_SUB2_SSE 2 |
390 |
|
COPY_8_TO_16_SUB2_SSE 3 |
391 |
|
|
|
pop ebx |
|
392 |
pop esi |
pop esi |
393 |
pop edi |
pop ebx |
|
|
|
394 |
ret |
ret |
395 |
|
|
396 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
397 |
; |
; |
398 |
; void transfer_16to8add_mmx(uint8_t * const dst, |
; void transfer_16to8add_mmx(uint8_t * const dst, |
399 |
; const int16_t * const src, |
; const int16_t * const src, |
400 |
; uint32_t stride); |
; uint32_t stride); |
401 |
; |
; |
402 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
align 16 |
|
|
cglobal transfer_16to8add_mmx |
|
|
transfer_16to8add_mmx |
|
403 |
|
|
404 |
push esi |
%macro COPY_16_TO_8_ADD 1 |
405 |
push edi |
movq mm0, [ecx] |
406 |
|
movq mm2, [ecx+edx] |
|
mov edi, [esp + 8 + 4] ; dst |
|
|
mov esi, [esp + 8 + 8] ; src |
|
|
mov ecx, [esp + 8 + 12] ; stride |
|
|
|
|
|
pxor mm7, mm7 |
|
|
|
|
|
mov eax, 8 |
|
|
|
|
|
.loop |
|
|
movq mm0, [edi] |
|
407 |
movq mm1, mm0 |
movq mm1, mm0 |
408 |
punpcklbw mm0, mm7 ; mm23 = unpack([dst]) |
movq mm3, mm2 |
409 |
|
punpcklbw mm0, mm7 |
410 |
|
punpcklbw mm2, mm7 |
411 |
punpckhbw mm1, mm7 |
punpckhbw mm1, mm7 |
412 |
|
punpckhbw mm3, mm7 |
413 |
|
paddsw mm0, [eax+%1*32+ 0] |
414 |
|
paddsw mm1, [eax+%1*32+ 8] |
415 |
|
paddsw mm2, [eax+%1*32+16] |
416 |
|
paddsw mm3, [eax+%1*32+24] |
417 |
|
packuswb mm0, mm1 |
418 |
|
movq [ecx], mm0 |
419 |
|
packuswb mm2, mm3 |
420 |
|
movq [ecx+edx], mm2 |
421 |
|
%endmacro |
422 |
|
|
|
movq mm2, [esi] ; mm01 = [src] |
|
|
movq mm3, [esi + 8] |
|
|
|
|
|
paddsw mm0, mm2 ; mm01 += mm23 |
|
|
paddsw mm1, mm3 |
|
|
|
|
|
packuswb mm0, mm1 ; [dst] = pack(mm01) |
|
|
movq [edi], mm0 |
|
|
|
|
|
add esi, 16 |
|
|
add edi, ecx |
|
|
dec eax |
|
|
jnz .loop |
|
423 |
|
|
424 |
pop edi |
ALIGN 16 |
425 |
pop esi |
transfer_16to8add_mmx: |
426 |
|
mov ecx, [esp+ 4] ; Dst |
427 |
|
mov eax, [esp+ 8] ; Src |
428 |
|
mov edx, [esp+12] ; Stride |
429 |
|
pxor mm7, mm7 |
430 |
|
|
431 |
|
COPY_16_TO_8_ADD 0 |
432 |
|
lea ecx,[ecx+2*edx] |
433 |
|
COPY_16_TO_8_ADD 1 |
434 |
|
lea ecx,[ecx+2*edx] |
435 |
|
COPY_16_TO_8_ADD 2 |
436 |
|
lea ecx,[ecx+2*edx] |
437 |
|
COPY_16_TO_8_ADD 3 |
438 |
ret |
ret |
439 |
|
|
440 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
441 |
; |
; |
442 |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
443 |
; const uint8_t * const src, |
; const uint8_t * const src, |
444 |
; const uint32_t stride); |
; const uint32_t stride); |
445 |
; |
; |
446 |
; |
; |
447 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
align 16 |
|
|
cglobal transfer8x8_copy_mmx |
|
|
transfer8x8_copy_mmx |
|
|
push esi |
|
|
push edi |
|
448 |
|
|
449 |
mov edi, [esp + 8 + 4] ; dst [out] |
%macro COPY_8_TO_8 0 |
450 |
mov esi, [esp + 8 + 8] ; src [in] |
movq mm0, [eax] |
451 |
mov eax, [esp + 8 + 12] ; stride [in] |
movq mm1, [eax+edx] |
452 |
|
movq [ecx], mm0 |
453 |
movq mm0, [esi] |
lea eax, [eax+2*edx] |
454 |
movq mm1, [esi+eax] |
movq [ecx+edx], mm1 |
455 |
movq [edi], mm0 |
%endmacro |
|
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 |
|
|
|
|
|
pop edi |
|
|
pop esi |
|
456 |
|
|
457 |
|
ALIGN 16 |
458 |
|
transfer8x8_copy_mmx: |
459 |
|
mov ecx, [esp+ 4] ; Dst |
460 |
|
mov eax, [esp+ 8] ; Src |
461 |
|
mov edx, [esp+12] ; Stride |
462 |
|
|
463 |
|
COPY_8_TO_8 |
464 |
|
lea ecx,[ecx+2*edx] |
465 |
|
COPY_8_TO_8 |
466 |
|
lea ecx,[ecx+2*edx] |
467 |
|
COPY_8_TO_8 |
468 |
|
lea ecx,[ecx+2*edx] |
469 |
|
COPY_8_TO_8 |
470 |
ret |
ret |