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

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

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