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_16to8copy_mmx |
59 |
|
cglobal transfer_8to16sub_mmx |
60 |
|
cglobal transfer_8to16subro_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 |
; when second argument == 1, reference (ebx) block is to current (eax) |
160 |
cglobal transfer_8to16sub_mmx |
%macro COPY_8_TO_16_SUB 2 |
161 |
transfer_8to16sub_mmx |
movq mm0, [eax] ; cur |
162 |
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] |
|
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 |
180 |
|
psubsw mm0, mm4 |
181 |
|
psubsw mm1, mm6 |
182 |
|
movq mm6, mm5 |
183 |
|
punpcklbw mm5, mm7 |
184 |
punpckhbw mm6, mm7 |
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 |
|
mov ecx, [esp + 4] ; Dst |
199 |
|
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 |
psubsw mm4, mm2 |
COPY_8_TO_16_SUB 0, 1 |
206 |
psubsw mm5, mm6 |
COPY_8_TO_16_SUB 1, 1 |
207 |
|
COPY_8_TO_16_SUB 2, 1 |
208 |
|
COPY_8_TO_16_SUB 3, 1 |
209 |
|
|
210 |
movq [edi + 32], mm0 ; dct[] = mm01 |
pop ebx |
211 |
movq [edi + 40], mm1 |
ret |
|
movq [edi + 48], mm4 |
|
|
movq [edi + 56], mm5 |
|
|
|
|
|
add edx, ecx |
|
|
add esi, ecx |
|
|
add eax, ecx |
|
|
add ebx, ecx |
|
212 |
|
|
|
movq mm0, [edx] ; mm01 = [cur] |
|
|
movq mm1, mm0 |
|
213 |
|
|
214 |
punpcklbw mm0, mm7 |
align 16 |
215 |
punpckhbw mm1, mm7 |
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 |
movq mm4, [eax] |
COPY_8_TO_16_SUB 0, 0 |
224 |
movq mm5, mm4 |
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 |
punpcklbw mm4, mm7 |
pop ebx |
229 |
punpckhbw mm5, mm7 |
ret |
230 |
|
|
|
movq mm2, [esi] ; mm23 = [ref] |
|
|
movq mm3, mm2 |
|
231 |
|
|
232 |
movq mm6, [ebx] |
;=========================================================================== |
233 |
|
; |
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 |
movq [edx], mm2 ; [cur] = [ref] |
%macro COPY_8_TO_16_SUB2_MMX 1 |
243 |
movq [eax], mm6 |
movq mm0, [eax] ; cur |
244 |
|
movq mm2, [eax+edx] |
245 |
|
|
246 |
punpcklbw mm2, mm7 |
; 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 |
|
psrlw mm4,1 |
258 |
movq mm2, mm6 |
psrlw mm6,1 |
259 |
|
packuswb mm4, mm6 |
260 |
punpcklbw mm2, mm7 |
|
261 |
|
; mm5 <- (ref1+ref2+1) / 2 |
262 |
|
movq mm5, [ebx+edx] ; ref1 |
263 |
|
movq mm1, [esi+edx] ; ref2 |
264 |
|
movq mm6, mm5 |
265 |
|
movq mm3, mm1 |
266 |
|
punpcklbw mm5, mm7 |
267 |
|
punpcklbw mm1, mm7 |
268 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
269 |
|
punpckhbw mm3, mm7 |
270 |
|
paddusw mm5, mm1 |
271 |
|
paddusw mm6, mm3 |
272 |
|
lea esi,[esi+2*edx] |
273 |
|
psrlw mm5,1 |
274 |
|
psrlw mm6,1 |
275 |
|
packuswb mm5, mm6 |
276 |
|
|
|
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 |
|
277 |
|
|
|
movq mm0, [edx] ; mm01 = [cur] |
|
278 |
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] |
|
279 |
movq mm3, mm2 |
movq mm3, mm2 |
280 |
|
punpcklbw mm0, mm7 |
|
movq mm6, [ebx] |
|
|
|
|
|
movq [edx], mm2 ; [cur] = [ref] |
|
|
movq [eax], mm6 |
|
|
|
|
281 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
282 |
|
punpckhbw mm1, mm7 |
283 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
284 |
|
|
285 |
psubsw mm0, mm2 ; mm01 -= mm23 |
movq mm6, mm4 |
286 |
|
punpcklbw mm4, mm7 |
|
movq mm2, mm6 |
|
|
|
|
|
punpcklbw mm2, mm7 |
|
287 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
288 |
|
psubsw mm0, mm4 |
289 |
|
psubsw mm1, mm6 |
290 |
|
movq mm6, mm5 |
291 |
|
punpcklbw mm5, mm7 |
292 |
|
punpckhbw mm6, mm7 |
293 |
|
psubsw mm2, mm5 |
294 |
|
lea eax,[eax+2*edx] |
295 |
|
psubsw mm3, mm6 |
296 |
|
lea ebx,[ebx+2*edx] |
297 |
|
|
298 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
299 |
|
movq [ecx+%1*32+ 8], mm1 |
300 |
|
movq [ecx+%1*32+16], mm2 |
301 |
|
movq [ecx+%1*32+24], mm3 |
302 |
|
%endmacro |
303 |
|
|
304 |
psubsw mm1, mm3 |
align 16 |
305 |
|
transfer_8to16sub2_mmx: |
306 |
psubsw mm4, mm2 |
mov ecx, [esp + 4] ; Dst |
307 |
psubsw mm5, mm6 |
mov eax, [esp + 8] ; Cur |
308 |
|
push ebx |
309 |
|
mov ebx, [esp+4+12] ; Ref1 |
310 |
|
push esi |
311 |
|
mov esi, [esp+8+16] ; Ref2 |
312 |
|
mov edx, [esp+8+20] ; Stride |
313 |
|
pxor mm7, mm7 |
314 |
|
|
315 |
movq [edi + 96], mm0 ; dct[] = mm01 |
COPY_8_TO_16_SUB2_MMX 0 |
316 |
movq [edi + 104], mm1 |
COPY_8_TO_16_SUB2_MMX 1 |
317 |
movq [edi + 112], mm4 |
COPY_8_TO_16_SUB2_MMX 2 |
318 |
movq [edi + 120], mm5 |
COPY_8_TO_16_SUB2_MMX 3 |
319 |
|
|
|
pop ebx |
|
|
pop edi |
|
320 |
pop esi |
pop esi |
321 |
|
pop ebx |
322 |
ret |
ret |
323 |
|
|
|
|
|
324 |
;=========================================================================== |
;=========================================================================== |
325 |
; |
; |
326 |
; void transfer_8to16sub2_xmm(int16_t * const dct, |
; void transfer_8to16sub2_xmm(int16_t * const dct, |
327 |
; uint8_t * const cur, |
; uint8_t * const cur, |
328 |
; const uint8_t * ref1, |
; const uint8_t * ref1, |
329 |
; const uint8_t * ref2, |
; const uint8_t * ref2, |
330 |
; const uint32_t stride); |
; const uint32_t stride) |
331 |
; |
; |
332 |
;=========================================================================== |
;=========================================================================== |
333 |
|
|
334 |
align 16 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
335 |
cglobal transfer_8to16sub2_xmm |
movq mm0, [eax] ; cur |
336 |
transfer_8to16sub2_xmm |
movq mm2, [eax+edx] |
337 |
|
movq mm1, mm0 |
338 |
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 |
|
339 |
|
|
340 |
punpcklbw mm2, mm7 ; mm2 = avg(3-0) <-> 16bit |
punpcklbw mm0, mm7 |
341 |
punpckhbw mm3, mm7 ; mm3 = avg(7-4) <-> 16bit |
punpcklbw mm2, mm7 |
342 |
|
movq mm4, [ebx] ; ref1 |
343 |
|
pavgb mm4, [esi] ; ref2 |
344 |
|
punpckhbw mm1, mm7 |
345 |
|
punpckhbw mm3, mm7 |
346 |
|
movq mm5, [ebx+edx] ; ref |
347 |
|
pavgb mm5, [esi+edx] ; ref2 |
348 |
|
|
349 |
psubw mm0, mm2 ; mm0 = cur(3-0) - avg(3-0) |
movq mm6, mm4 |
350 |
psubw mm1, mm3 ; mm1 = cur(7-4) - avg(7-4) |
punpcklbw mm4, mm7 |
351 |
|
punpckhbw mm6, mm7 |
352 |
|
psubsw mm0, mm4 |
353 |
|
psubsw mm1, mm6 |
354 |
|
lea esi,[esi+2*edx] |
355 |
|
movq mm6, mm5 |
356 |
|
punpcklbw mm5, mm7 |
357 |
|
punpckhbw mm6, mm7 |
358 |
|
psubsw mm2, mm5 |
359 |
|
lea eax,[eax+2*edx] |
360 |
|
psubsw mm3, mm6 |
361 |
|
lea ebx,[ebx+2*edx] |
362 |
|
|
363 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
364 |
|
movq [ecx+%1*32+ 8], mm1 |
365 |
|
movq [ecx+%1*32+16], mm2 |
366 |
|
movq [ecx+%1*32+24], mm3 |
367 |
|
%endmacro |
368 |
|
|
369 |
movq [edi + 0], mm0 ; dct(3-0) = mm0 |
align 16 |
370 |
movq [edi + 8], mm1 ; dct(7-4) = mm1 |
transfer_8to16sub2_xmm: |
371 |
|
mov ecx, [esp + 4] ; Dst |
372 |
|
mov eax, [esp + 8] ; Cur |
373 |
|
push ebx |
374 |
|
mov ebx, [esp+4+12] ; Ref1 |
375 |
|
push esi |
376 |
|
mov esi, [esp+8+16] ; Ref2 |
377 |
|
mov edx, [esp+8+20] ; Stride |
378 |
|
pxor mm7, mm7 |
379 |
|
|
380 |
; Exit |
COPY_8_TO_16_SUB2_SSE 0 |
381 |
|
COPY_8_TO_16_SUB2_SSE 1 |
382 |
|
COPY_8_TO_16_SUB2_SSE 2 |
383 |
|
COPY_8_TO_16_SUB2_SSE 3 |
384 |
|
|
|
pop ebx |
|
385 |
pop esi |
pop esi |
386 |
pop edi |
pop ebx |
|
|
|
387 |
ret |
ret |
388 |
|
|
389 |
;=========================================================================== |
;=========================================================================== |
394 |
; |
; |
395 |
;=========================================================================== |
;=========================================================================== |
396 |
|
|
397 |
align 16 |
%macro COPY_16_TO_8_ADD 1 |
398 |
cglobal transfer_16to8add_mmx |
movq mm0, [ecx] |
399 |
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] |
|
400 |
movq mm1, mm0 |
movq mm1, mm0 |
401 |
punpcklbw mm0, mm7 ; mm23 = unpack([dst]) |
movq mm3, mm2 |
402 |
|
punpcklbw mm0, mm7 |
403 |
|
punpcklbw mm2, mm7 |
404 |
punpckhbw mm1, mm7 |
punpckhbw mm1, mm7 |
405 |
|
punpckhbw mm3, mm7 |
406 |
|
paddsw mm0, [eax+%1*32+ 0] |
407 |
|
paddsw mm1, [eax+%1*32+ 8] |
408 |
|
paddsw mm2, [eax+%1*32+16] |
409 |
|
paddsw mm3, [eax+%1*32+24] |
410 |
|
packuswb mm0, mm1 |
411 |
|
movq [ecx], mm0 |
412 |
|
packuswb mm2, mm3 |
413 |
|
movq [ecx+edx], mm2 |
414 |
|
%endmacro |
415 |
|
|
|
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 |
|
416 |
|
|
417 |
pop edi |
align 16 |
418 |
pop esi |
transfer_16to8add_mmx: |
419 |
|
mov ecx, [esp+ 4] ; Dst |
420 |
|
mov eax, [esp+ 8] ; Src |
421 |
|
mov edx, [esp+12] ; Stride |
422 |
|
pxor mm7, mm7 |
423 |
|
|
424 |
|
COPY_16_TO_8_ADD 0 |
425 |
|
lea ecx,[ecx+2*edx] |
426 |
|
COPY_16_TO_8_ADD 1 |
427 |
|
lea ecx,[ecx+2*edx] |
428 |
|
COPY_16_TO_8_ADD 2 |
429 |
|
lea ecx,[ecx+2*edx] |
430 |
|
COPY_16_TO_8_ADD 3 |
431 |
ret |
ret |
432 |
|
|
|
|
|
433 |
;=========================================================================== |
;=========================================================================== |
434 |
; |
; |
435 |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
439 |
; |
; |
440 |
;=========================================================================== |
;=========================================================================== |
441 |
|
|
442 |
align 16 |
%macro COPY_8_TO_8 0 |
443 |
cglobal transfer8x8_copy_mmx |
movq mm0, [eax] |
444 |
transfer8x8_copy_mmx |
movq mm1, [eax+edx] |
445 |
push esi |
movq [ecx], mm0 |
446 |
push edi |
lea eax,[eax+2*edx] |
447 |
|
movq [ecx+edx], mm1 |
448 |
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 |
|
|
|
|
|
add esi, eax |
|
|
add edi, eax |
|
|
add esi, eax |
|
|
add edi, eax |
|
|
|
|
|
pop edi |
|
|
pop esi |
|
449 |
|
|
450 |
|
align 16 |
451 |
|
transfer8x8_copy_mmx: |
452 |
|
mov ecx, [esp+ 4] ; Dst |
453 |
|
mov eax, [esp+ 8] ; Src |
454 |
|
mov edx, [esp+12] ; Stride |
455 |
|
|
456 |
|
COPY_8_TO_8 |
457 |
|
lea ecx,[ecx+2*edx] |
458 |
|
COPY_8_TO_8 |
459 |
|
lea ecx,[ecx+2*edx] |
460 |
|
COPY_8_TO_8 |
461 |
|
lea ecx,[ecx+2*edx] |
462 |
|
COPY_8_TO_8 |
463 |
ret |
ret |