[svn] / trunk / xvidcore / src / utils / x86_asm / mem_transfer_mmx.asm Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/utils/x86_asm/mem_transfer_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.216  
changed lines
  Added in v.499

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4