32 |
; * |
; * |
33 |
; * History: |
; * History: |
34 |
; * |
; * |
35 |
|
; * 04.06.2002 speed enhancement (unroll+overlap). -Skal- |
36 |
|
; * + added transfer_8to16sub2_mmx/xmm |
37 |
; * 07.01.2002 merge functions from compensate_mmx; rename functions |
; * 07.01.2002 merge functions from compensate_mmx; rename functions |
38 |
; * 07.11.2001 initial version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
; * 07.11.2001 initial version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
39 |
; * |
; * |
54 |
|
|
55 |
section .text |
section .text |
56 |
|
|
57 |
|
cglobal transfer_8to16copy_mmx |
58 |
|
cglobal transfer_8to16copy_mmx |
59 |
|
cglobal transfer_16to8copy_mmx |
60 |
|
cglobal transfer_8to16sub_mmx |
61 |
|
cglobal transfer_8to16sub2_mmx |
62 |
|
cglobal transfer_8to16sub2_xmm |
63 |
|
cglobal transfer_16to8add_mmx |
64 |
|
cglobal transfer8x8_copy_mmx |
65 |
|
|
66 |
;=========================================================================== |
;=========================================================================== |
67 |
; |
; |
71 |
; |
; |
72 |
;=========================================================================== |
;=========================================================================== |
73 |
|
|
74 |
align 16 |
%macro COPY_8_TO_16 1 |
75 |
cglobal transfer_8to16copy_mmx |
movq mm0, [eax] |
76 |
transfer_8to16copy_mmx |
movq mm1, [eax+edx] |
77 |
|
movq mm2, mm0 |
78 |
push esi |
movq mm3, mm1 |
79 |
push edi |
punpcklbw mm0, mm7 |
80 |
|
movq [ecx+%1*32], mm0 |
81 |
mov edi, [esp + 8 + 4] ; dst |
punpcklbw mm1, mm7 |
82 |
mov esi, [esp + 8 + 8] ; src |
movq [ecx+%1*32+16], mm1 |
83 |
mov ecx, [esp + 8 + 12] ; stride |
punpckhbw mm2, mm7 |
84 |
|
punpckhbw mm3, mm7 |
85 |
pxor mm7, mm7 ; mm7 = zero |
lea eax,[eax+2*edx] |
86 |
|
movq [ecx+%1*32+8], mm2 |
87 |
mov eax, 8 |
movq [ecx+%1*32+24], mm3 |
88 |
|
%endmacro |
|
.loop |
|
|
movq mm0, [esi] |
|
|
movq mm1, mm0 |
|
|
punpcklbw mm0, mm7 ; mm01 = unpack([src]) |
|
|
punpckhbw mm1, mm7 |
|
|
|
|
|
movq [edi], mm0 ; [dst] = mm01 |
|
|
movq [edi + 8], mm1 |
|
89 |
|
|
90 |
add edi, 16 |
align 16 |
91 |
add esi, ecx |
transfer_8to16copy_mmx: |
|
dec eax |
|
|
jnz .loop |
|
92 |
|
|
93 |
pop edi |
mov ecx, [esp+ 4] ; Dst |
94 |
pop esi |
mov eax, [esp+ 8] ; Src |
95 |
|
mov edx, [esp+12] ; Stride |
96 |
|
pxor mm7,mm7 |
97 |
|
|
98 |
|
COPY_8_TO_16 0 |
99 |
|
COPY_8_TO_16 1 |
100 |
|
COPY_8_TO_16 2 |
101 |
|
COPY_8_TO_16 3 |
102 |
ret |
ret |
103 |
|
|
|
|
|
|
|
|
104 |
;=========================================================================== |
;=========================================================================== |
105 |
; |
; |
106 |
; void transfer_16to8copy_mmx(uint8_t * const dst, |
; void transfer_16to8copy_mmx(uint8_t * const dst, |
109 |
; |
; |
110 |
;=========================================================================== |
;=========================================================================== |
111 |
|
|
112 |
align 16 |
%macro COPY_16_TO_8 1 |
113 |
cglobal transfer_16to8copy_mmx |
movq mm0, [eax+%1*32] |
114 |
transfer_16to8copy_mmx |
movq mm1, [eax+%1*32+8] |
115 |
|
packuswb mm0, mm1 |
116 |
push esi |
movq [ecx], mm0 |
117 |
push edi |
movq mm2, [eax+%1*32+16] |
118 |
|
movq mm3, [eax+%1*32+24] |
119 |
mov edi, [esp + 8 + 4] ; dst |
packuswb mm2, mm3 |
120 |
mov esi, [esp + 8 + 8] ; src |
movq [ecx+edx], mm2 |
121 |
mov ecx, [esp + 8 + 12] ; stride |
%endmacro |
|
|
|
|
mov eax, 8 |
|
|
|
|
|
.loop |
|
|
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 |
|
122 |
|
|
123 |
pop edi |
align 16 |
124 |
pop esi |
transfer_16to8copy_mmx: |
125 |
|
|
126 |
|
mov ecx, [esp+ 4] ; Dst |
127 |
|
mov eax, [esp+ 8] ; Src |
128 |
|
mov edx, [esp+12] ; Stride |
129 |
|
|
130 |
|
COPY_16_TO_8 0 |
131 |
|
lea ecx,[ecx+2*edx] |
132 |
|
COPY_16_TO_8 1 |
133 |
|
lea ecx,[ecx+2*edx] |
134 |
|
COPY_16_TO_8 2 |
135 |
|
lea ecx,[ecx+2*edx] |
136 |
|
COPY_16_TO_8 3 |
137 |
ret |
ret |
138 |
|
|
|
|
|
139 |
;=========================================================================== |
;=========================================================================== |
140 |
; |
; |
141 |
; void transfer_8to16sub_mmx(int16_t * const dct, |
; void transfer_8to16sub_mmx(int16_t * const dct, |
156 |
; * |
; * |
157 |
; *************************************************************************/ |
; *************************************************************************/ |
158 |
|
|
159 |
align 16 |
%macro COPY_8_TO_16_SUB 1 |
160 |
cglobal transfer_8to16sub_mmx |
movq mm0, [eax] ; cur |
161 |
transfer_8to16sub_mmx |
movq mm2, [eax+edx] |
|
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 |
|
|
|
|
|
pxor mm7, mm7 ; mm7 = zero |
|
|
|
|
|
movq mm0, [edx] ; mm01 = [cur] |
|
162 |
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] |
|
163 |
movq mm3, mm2 |
movq mm3, mm2 |
164 |
|
|
|
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 |
|
|
|
|
165 |
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 |
|
|
|
|
166 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
167 |
|
movq mm4, [ebx] ; ref |
168 |
|
punpckhbw mm1, mm7 |
169 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
170 |
|
movq mm5, [ebx+edx] ; ref |
171 |
|
|
172 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
173 |
|
movq [eax], mm4 |
174 |
movq mm2, mm6 |
movq [eax+edx], mm5 |
175 |
|
punpcklbw mm4, mm7 |
|
punpcklbw mm2, mm7 |
|
176 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
177 |
|
psubsw mm0, mm4 |
178 |
|
psubsw mm1, mm6 |
179 |
|
movq mm6, mm5 |
180 |
|
punpcklbw mm5, mm7 |
181 |
|
punpckhbw mm6, mm7 |
182 |
|
psubsw mm2, mm5 |
183 |
|
lea eax,[eax+2*edx] |
184 |
|
psubsw mm3, mm6 |
185 |
|
lea ebx,[ebx+2*edx] |
186 |
|
|
187 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
188 |
|
movq [ecx+%1*32+ 8], mm1 |
189 |
|
movq [ecx+%1*32+16], mm2 |
190 |
|
movq [ecx+%1*32+24], mm3 |
191 |
|
%endmacro |
192 |
|
|
193 |
psubsw mm1, mm3 |
align 16 |
194 |
|
transfer_8to16sub_mmx: |
195 |
psubsw mm4, mm2 |
mov ecx, [esp + 4] ; Dst |
196 |
psubsw mm5, mm6 |
mov eax, [esp + 8] ; Cur |
197 |
|
push ebx |
198 |
|
mov ebx, [esp+4+12] ; Ref |
199 |
|
mov edx, [esp+4+16] ; Stride |
200 |
|
pxor mm7, mm7 |
201 |
|
|
202 |
movq [edi + 32], mm0 ; dct[] = mm01 |
COPY_8_TO_16_SUB 0 |
203 |
movq [edi + 40], mm1 |
COPY_8_TO_16_SUB 1 |
204 |
movq [edi + 48], mm4 |
COPY_8_TO_16_SUB 2 |
205 |
movq [edi + 56], mm5 |
COPY_8_TO_16_SUB 3 |
|
|
|
|
add edx, ecx |
|
|
add esi, ecx |
|
|
add eax, ecx |
|
|
add ebx, ecx |
|
206 |
|
|
207 |
movq mm0, [edx] ; mm01 = [cur] |
pop ebx |
208 |
movq mm1, mm0 |
ret |
209 |
|
|
210 |
punpcklbw mm0, mm7 |
;=========================================================================== |
211 |
punpckhbw mm1, mm7 |
; |
212 |
|
; void transfer_8to16sub2_mmx(int16_t * const dct, |
213 |
|
; uint8_t * const cur, |
214 |
|
; const uint8_t * ref1, |
215 |
|
; const uint8_t * ref2, |
216 |
|
; const uint32_t stride) |
217 |
|
; |
218 |
|
;=========================================================================== |
219 |
|
|
220 |
movq mm4, [eax] |
%macro COPY_8_TO_16_SUB2_MMX 1 |
221 |
movq mm5, mm4 |
movq mm0, [eax] ; cur |
222 |
|
movq mm2, [eax+edx] |
223 |
|
|
224 |
|
; mm4 <- (ref1+ref2+1) / 2 |
225 |
|
movq mm4, [ebx] ; ref1 |
226 |
|
movq mm1, [esi] ; ref2 |
227 |
|
movq mm6, mm4 |
228 |
|
movq mm3, mm1 |
229 |
punpcklbw mm4, mm7 |
punpcklbw mm4, mm7 |
230 |
punpckhbw mm5, mm7 |
punpcklbw mm1, mm7 |
231 |
|
punpckhbw mm6, mm7 |
|
movq mm2, [esi] ; mm23 = [ref] |
|
|
movq mm3, mm2 |
|
|
|
|
|
movq mm6, [ebx] |
|
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
|
punpcklbw mm2, mm7 |
|
232 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
233 |
|
paddusw mm4, mm1 |
234 |
psubsw mm0, mm2 ; mm01 -= mm23 |
paddusw mm6, mm3 |
235 |
|
psrlw mm4,1 |
236 |
movq mm2, mm6 |
psrlw mm6,1 |
237 |
|
packuswb mm4, mm6 |
238 |
punpcklbw mm2, mm7 |
|
239 |
|
; mm5 <- (ref1+ref2+1) / 2 |
240 |
|
movq mm5, [ebx+edx] ; ref1 |
241 |
|
movq mm1, [esi+edx] ; ref2 |
242 |
|
movq mm6, mm5 |
243 |
|
movq mm3, mm1 |
244 |
|
punpcklbw mm5, mm7 |
245 |
|
punpcklbw mm1, mm7 |
246 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
247 |
|
punpckhbw mm3, mm7 |
248 |
|
paddusw mm5, mm1 |
249 |
|
paddusw mm6, mm3 |
250 |
|
lea esi,[esi+2*edx] |
251 |
|
psrlw mm5,1 |
252 |
|
psrlw mm6,1 |
253 |
|
packuswb mm5, mm6 |
254 |
|
|
|
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 |
|
255 |
|
|
|
movq mm0, [edx] ; mm01 = [cur] |
|
256 |
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] |
|
257 |
movq mm3, mm2 |
movq mm3, mm2 |
258 |
|
punpcklbw mm0, mm7 |
|
movq mm6, [ebx] |
|
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
259 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
260 |
|
punpckhbw mm1, mm7 |
261 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
262 |
|
|
263 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
264 |
|
punpcklbw mm4, mm7 |
|
movq mm2, mm6 |
|
|
|
|
|
punpcklbw mm2, mm7 |
|
265 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
266 |
|
psubsw mm0, mm4 |
267 |
|
psubsw mm1, mm6 |
268 |
|
movq mm6, mm5 |
269 |
|
punpcklbw mm5, mm7 |
270 |
|
punpckhbw mm6, mm7 |
271 |
|
psubsw mm2, mm5 |
272 |
|
lea eax,[eax+2*edx] |
273 |
|
psubsw mm3, mm6 |
274 |
|
lea ebx,[ebx+2*edx] |
275 |
|
|
276 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
277 |
|
movq [ecx+%1*32+ 8], mm1 |
278 |
|
movq [ecx+%1*32+16], mm2 |
279 |
|
movq [ecx+%1*32+24], mm3 |
280 |
|
%endmacro |
281 |
|
|
282 |
psubsw mm1, mm3 |
align 16 |
283 |
|
transfer_8to16sub2_mmx: |
284 |
psubsw mm4, mm2 |
mov ecx, [esp + 4] ; Dst |
285 |
psubsw mm5, mm6 |
mov eax, [esp + 8] ; Cur |
286 |
|
push ebx |
287 |
|
mov ebx, [esp+4+12] ; Ref1 |
288 |
|
push esi |
289 |
|
mov esi, [esp+8+16] ; Ref2 |
290 |
|
mov edx, [esp+8+20] ; Stride |
291 |
|
pxor mm7, mm7 |
292 |
|
|
293 |
movq [edi + 96], mm0 ; dct[] = mm01 |
COPY_8_TO_16_SUB2_MMX 0 |
294 |
movq [edi + 104], mm1 |
COPY_8_TO_16_SUB2_MMX 1 |
295 |
movq [edi + 112], mm4 |
COPY_8_TO_16_SUB2_MMX 2 |
296 |
movq [edi + 120], mm5 |
COPY_8_TO_16_SUB2_MMX 3 |
297 |
|
|
|
pop ebx |
|
|
pop edi |
|
298 |
pop esi |
pop esi |
299 |
|
pop ebx |
300 |
ret |
ret |
301 |
|
|
|
|
|
302 |
;=========================================================================== |
;=========================================================================== |
303 |
; |
; |
304 |
; void transfer_8to16sub2_xmm(int16_t * const dct, |
; void transfer_8to16sub2_xmm(int16_t * const dct, |
305 |
; uint8_t * const cur, |
; uint8_t * const cur, |
306 |
; const uint8_t * ref1, |
; const uint8_t * ref1, |
307 |
; const uint8_t * ref2, |
; const uint8_t * ref2, |
308 |
; const uint32_t stride); |
; const uint32_t stride) |
309 |
; |
; |
310 |
;=========================================================================== |
;=========================================================================== |
311 |
|
|
312 |
align 16 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
313 |
cglobal transfer_8to16sub2_xmm |
movq mm0, [eax] ; cur |
314 |
transfer_8to16sub2_xmm |
movq mm2, [eax+edx] |
315 |
|
movq mm1, mm0 |
316 |
push edi |
movq mm3, mm2 |
|
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 |
|
|
|
|
|
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 + 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 |
|
317 |
|
|
318 |
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
punpcklbw mm0, mm7 |
319 |
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
punpcklbw mm2, mm7 |
320 |
|
movq mm4, [ebx] ; ref1 |
321 |
|
pavgb mm4, [esi] ; ref2 |
322 |
|
punpckhbw mm1, mm7 |
323 |
|
punpckhbw mm3, mm7 |
324 |
|
movq mm5, [ebx+edx] ; ref |
325 |
|
pavgb mm5, [esi+edx] ; ref2 |
326 |
|
|
327 |
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
movq mm6, mm4 |
328 |
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
punpcklbw mm4, mm7 |
329 |
|
punpckhbw mm6, mm7 |
330 |
|
psubsw mm0, mm4 |
331 |
|
psubsw mm1, mm6 |
332 |
|
lea esi,[esi+2*edx] |
333 |
|
movq mm6, mm5 |
334 |
|
punpcklbw mm5, mm7 |
335 |
|
punpckhbw mm6, mm7 |
336 |
|
psubsw mm2, mm5 |
337 |
|
lea eax,[eax+2*edx] |
338 |
|
psubsw mm3, mm6 |
339 |
|
lea ebx,[ebx+2*edx] |
340 |
|
|
341 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
342 |
|
movq [ecx+%1*32+ 8], mm1 |
343 |
|
movq [ecx+%1*32+16], mm2 |
344 |
|
movq [ecx+%1*32+24], mm3 |
345 |
|
%endmacro |
346 |
|
|
347 |
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
align 16 |
348 |
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
transfer_8to16sub2_xmm: |
349 |
|
mov ecx, [esp + 4] ; Dst |
350 |
|
mov eax, [esp + 8] ; Cur |
351 |
|
push ebx |
352 |
|
mov ebx, [esp+4+12] ; Ref1 |
353 |
|
push esi |
354 |
|
mov esi, [esp+8+16] ; Ref2 |
355 |
|
mov edx, [esp+8+20] ; Stride |
356 |
|
pxor mm7, mm7 |
357 |
|
|
358 |
; Exit |
COPY_8_TO_16_SUB2_SSE 0 |
359 |
|
COPY_8_TO_16_SUB2_SSE 1 |
360 |
|
COPY_8_TO_16_SUB2_SSE 2 |
361 |
|
COPY_8_TO_16_SUB2_SSE 3 |
362 |
|
|
|
pop ebx |
|
363 |
pop esi |
pop esi |
364 |
pop edi |
pop ebx |
|
|
|
365 |
ret |
ret |
366 |
|
|
367 |
;=========================================================================== |
;=========================================================================== |
372 |
; |
; |
373 |
;=========================================================================== |
;=========================================================================== |
374 |
|
|
375 |
align 16 |
%macro COPY_16_TO_8_ADD 1 |
376 |
cglobal transfer_16to8add_mmx |
movq mm0, [ecx] |
377 |
transfer_16to8add_mmx |
movq mm2, [ecx+edx] |
|
|
|
|
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 |
|
|
|
|
|
mov eax, 8 |
|
|
|
|
|
.loop |
|
|
movq mm0, [edi] |
|
378 |
movq mm1, mm0 |
movq mm1, mm0 |
379 |
punpcklbw mm0, mm7 ; mm23 = unpack([dst]) |
movq mm3, mm2 |
380 |
|
punpcklbw mm0, mm7 |
381 |
|
punpcklbw mm2, mm7 |
382 |
punpckhbw mm1, mm7 |
punpckhbw mm1, mm7 |
383 |
|
punpckhbw mm3, mm7 |
384 |
|
paddsw mm0, [eax+%1*32+ 0] |
385 |
|
paddsw mm1, [eax+%1*32+ 8] |
386 |
|
paddsw mm2, [eax+%1*32+16] |
387 |
|
paddsw mm3, [eax+%1*32+24] |
388 |
|
packuswb mm0, mm1 |
389 |
|
movq [ecx], mm0 |
390 |
|
packuswb mm2, mm3 |
391 |
|
movq [ecx+edx], mm2 |
392 |
|
%endmacro |
393 |
|
|
|
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 |
|
394 |
|
|
395 |
pop edi |
align 16 |
396 |
pop esi |
transfer_16to8add_mmx: |
397 |
|
mov ecx, [esp+ 4] ; Dst |
398 |
|
mov eax, [esp+ 8] ; Src |
399 |
|
mov edx, [esp+12] ; Stride |
400 |
|
pxor mm7, mm7 |
401 |
|
|
402 |
|
COPY_16_TO_8_ADD 0 |
403 |
|
lea ecx,[ecx+2*edx] |
404 |
|
COPY_16_TO_8_ADD 1 |
405 |
|
lea ecx,[ecx+2*edx] |
406 |
|
COPY_16_TO_8_ADD 2 |
407 |
|
lea ecx,[ecx+2*edx] |
408 |
|
COPY_16_TO_8_ADD 3 |
409 |
ret |
ret |
410 |
|
|
|
|
|
411 |
;=========================================================================== |
;=========================================================================== |
412 |
; |
; |
413 |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
417 |
; |
; |
418 |
;=========================================================================== |
;=========================================================================== |
419 |
|
|
420 |
align 16 |
%macro COPY_8_TO_8 0 |
421 |
cglobal transfer8x8_copy_mmx |
movq mm0, [eax] |
422 |
transfer8x8_copy_mmx |
movq mm1, [eax+edx] |
423 |
push esi |
movq [ecx], mm0 |
424 |
push edi |
lea eax,[eax+2*edx] |
425 |
|
movq [ecx+edx], mm1 |
426 |
mov edi, [esp + 8 + 4] ; dst [out] |
%endmacro |
|
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 |
|
|
|
|
|
pop edi |
|
|
pop esi |
|
427 |
|
|
428 |
|
align 16 |
429 |
|
transfer8x8_copy_mmx: |
430 |
|
mov ecx, [esp+ 4] ; Dst |
431 |
|
mov eax, [esp+ 8] ; Src |
432 |
|
mov edx, [esp+12] ; Stride |
433 |
|
|
434 |
|
COPY_8_TO_8 |
435 |
|
lea ecx,[ecx+2*edx] |
436 |
|
COPY_8_TO_8 |
437 |
|
lea ecx,[ecx+2*edx] |
438 |
|
COPY_8_TO_8 |
439 |
|
lea ecx,[ecx+2*edx] |
440 |
|
COPY_8_TO_8 |
441 |
ret |
ret |