[svn] / branches / dev-api-4 / xvidcore / src / utils / x86_asm / mem_transfer_mmx.asm Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/utils/x86_asm/mem_transfer_mmx.asm

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

trunk/xvidcore/src/utils/x86_asm/mem_transfer_mmx.asm revision 216, Sun Jun 16 17:25:18 2002 UTC branches/dev-api-4/xvidcore/src/utils/x86_asm/mem_transfer_mmx.asm revision 1192, Tue Oct 28 22:23:03 2003 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.9.2.1 2003-10-28 22:23:03 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    ; Code
41    ;=============================================================================
42    
43  section .text  SECTION .text
44    
45    cglobal transfer_8to16copy_mmx
46    cglobal transfer_16to8copy_mmx
47    cglobal transfer_8to16sub_mmx
48    cglobal transfer_8to16subro_mmx
49    cglobal transfer_8to16sub2_mmx
50    cglobal transfer_8to16sub2_xmm
51    cglobal transfer_16to8add_mmx
52    cglobal transfer8x8_copy_mmx
53    
54  ;===========================================================================  ;-----------------------------------------------------------------------------
55  ;  ;
56  ; void transfer_8to16copy_mmx(int16_t * const dst,  ; void transfer_8to16copy_mmx(int16_t * const dst,
57  ;                                                       const uint8_t * const src,  ;                                                       const uint8_t * const src,
58  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
59  ;  ;
60  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 cglobal transfer_8to16copy_mmx  
 transfer_8to16copy_mmx  
   
                 push    esi  
                 push    edi  
   
                 mov     edi, [esp + 8 + 4]              ; dst  
                 mov     esi, [esp + 8 + 8]              ; src  
                 mov ecx, [esp + 8 + 12]         ; stride  
   
                 pxor mm7, mm7                           ; mm7 = zero  
61    
62                  mov eax, 8  %macro COPY_8_TO_16 1
63      movq mm0, [eax]
64  .loop    movq mm1, [eax+edx]
65                  movq mm0, [esi]    movq mm2, mm0
66                  movq mm1, mm0    movq mm3, mm1
67                  punpcklbw mm0, mm7              ; mm01 = unpack([src])    punpcklbw mm0, mm7
68                  punpckhbw mm1, mm7    movq [ecx+%1*32], mm0
69      punpcklbw mm1, mm7
70                  movq [edi], mm0                 ; [dst] = mm01    movq [ecx+%1*32+16], mm1
71                  movq [edi + 8], mm1    punpckhbw mm2, mm7
72      punpckhbw mm3, mm7
73      lea eax, [eax+2*edx]
74      movq [ecx+%1*32+8], mm2
75      movq [ecx+%1*32+24], mm3
76    %endmacro
77    
78                  add edi, 16  ALIGN 16
79                  add esi, ecx  transfer_8to16copy_mmx:
                 dec eax  
                 jnz .loop  
80    
81                  pop edi    mov ecx, [esp+ 4] ; Dst
82                  pop esi    mov eax, [esp+ 8] ; Src
83      mov edx, [esp+12] ; Stride
84      pxor mm7, mm7
85    
86      COPY_8_TO_16 0
87      COPY_8_TO_16 1
88      COPY_8_TO_16 2
89      COPY_8_TO_16 3
90                  ret                  ret
91    
92    ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
93  ;  ;
94  ; void transfer_16to8copy_mmx(uint8_t * const dst,  ; void transfer_16to8copy_mmx(uint8_t * const dst,
95  ;                                                       const int16_t * const src,  ;                                                       const int16_t * const src,
96  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
97  ;  ;
98  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 cglobal transfer_16to8copy_mmx  
 transfer_16to8copy_mmx  
   
                 push    esi  
                 push    edi  
99    
100                  mov     edi, [esp + 8 + 4]              ; dst  %macro COPY_16_TO_8 1
101                  mov     esi, [esp + 8 + 8]              ; src    movq mm0, [eax+%1*32]
102                  mov ecx, [esp + 8 + 12]         ; stride    movq mm1, [eax+%1*32+8]
103      packuswb mm0, mm1
104                  mov eax, 8    movq [ecx], mm0
105      movq mm2, [eax+%1*32+16]
106  .loop    movq mm3, [eax+%1*32+24]
107                  movq mm0, [esi]    packuswb mm2, mm3
108                  packuswb mm0, [esi + 8]         ; mm0 = pack([src])    movq [ecx+edx], mm2
109    %endmacro
                 movq [edi], mm0                         ; [dst] = mm0  
   
                 add esi, 16  
                 add edi, ecx  
                 dec eax  
                 jnz .loop  
110    
111                  pop edi  ALIGN 16
112                  pop esi  transfer_16to8copy_mmx:
113    
114      mov ecx, [esp+ 4] ; Dst
115      mov eax, [esp+ 8] ; Src
116      mov edx, [esp+12] ; Stride
117    
118      COPY_16_TO_8 0
119      lea ecx,[ecx+2*edx]
120      COPY_16_TO_8 1
121      lea ecx,[ecx+2*edx]
122      COPY_16_TO_8 2
123      lea ecx,[ecx+2*edx]
124      COPY_16_TO_8 3
125                  ret                  ret
126    
127    ;-----------------------------------------------------------------------------
 ;===========================================================================  
128  ;  ;
129  ; void transfer_8to16sub_mmx(int16_t * const dct,  ; void transfer_8to16sub_mmx(int16_t * const dct,
130  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
131  ;                               const uint8_t * const ref,  ;                               const uint8_t * const ref,
132  ;                               const uint32_t stride);  ;                               const uint32_t stride);
133  ;  ;
134  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;/**************************************************************************  
 ; *  
 ; *     History:  
 ; *  
 ; * 27.12.2001  renamed from 'compensate' to 'transfer_8to16sub'  
 ; * 02.12.2001  loop unrolled, code runs 10% faster now (Isibaar)  
 ; * 30.11.2001  16 pixels are processed per iteration (Isibaar)  
 ; * 30.11.2001  .text missing  
 ; *     06.11.2001      inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
 ; *  
 ; *************************************************************************/  
   
 align 16  
 cglobal transfer_8to16sub_mmx  
 transfer_8to16sub_mmx  
                 push    esi  
                 push    edi  
                 push    ebx  
   
                 mov     edi, [esp + 12 + 4]             ; dct [out]  
                 mov     edx, [esp + 12 + 8]             ; cur [in/out]  
                 mov     esi, [esp + 12 + 12]            ; ref [in]  
                 mov ecx, [esp + 12 + 16]                ; stride [in]  
135    
136                  mov eax, edx                            ; cur -> eax  ; when second argument == 1, reference (ebx) block is to current (eax)
137                  mov ebx, esi                            ; ref -> ebx  %macro COPY_8_TO_16_SUB 2
138                  add eax, ecx                            ; cur + stride    movq mm0, [eax]      ; cur
139                  add ebx, ecx                            ; ref + stride    movq mm2, [eax+edx]
   
                 shl ecx, 1  
   
                 pxor mm7, mm7                   ; mm7 = zero  
   
                 movq mm0, [edx]                 ; mm01 = [cur]  
140                  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]  
141                  movq mm3, mm2                  movq mm3, mm2
142    
                 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  
   
143                  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  
   
144                  punpcklbw mm2, mm7                  punpcklbw mm2, mm7
145      movq mm4, [ebx]      ; ref
146      punpckhbw mm1, mm7
147                  punpckhbw mm3, mm7                  punpckhbw mm3, mm7
148      movq mm5, [ebx+edx]  ; ref
149    
150                  psubsw mm0, mm2                 ; mm01 -= mm23    movq mm6, mm4
151    %if %2 == 1
152                  movq mm2, mm6    movq [eax], mm4
153      movq [eax+edx], mm5
154                  punpcklbw mm2, mm7  %endif
155      punpcklbw mm4, mm7
156                  punpckhbw mm6, mm7                  punpckhbw mm6, mm7
157      psubsw mm0, mm4
158      psubsw mm1, mm6
159      movq mm6, mm5
160      punpcklbw mm5, mm7
161      punpckhbw mm6, mm7
162      psubsw mm2, mm5
163      lea eax, [eax+2*edx]
164      psubsw mm3, mm6
165      lea ebx,[ebx+2*edx]
166    
167      movq [ecx+%1*32+ 0], mm0 ; dst
168      movq [ecx+%1*32+ 8], mm1
169      movq [ecx+%1*32+16], mm2
170      movq [ecx+%1*32+24], mm3
171    %endmacro
172    
173                  psubsw mm1, mm3  ALIGN 16
174    transfer_8to16sub_mmx:
175                  psubsw mm4, mm2    mov ecx, [esp  + 4] ; Dst
176                  psubsw mm5, mm6    mov eax, [esp  + 8] ; Cur
177      push ebx
178      mov ebx, [esp+4+12] ; Ref
179      mov edx, [esp+4+16] ; Stride
180      pxor mm7, mm7
181    
182                  movq [edi + 32], mm0                    ; dct[] = mm01    COPY_8_TO_16_SUB 0, 1
183                  movq [edi + 40], mm1    COPY_8_TO_16_SUB 1, 1
184                  movq [edi + 48], mm4    COPY_8_TO_16_SUB 2, 1
185                  movq [edi + 56], mm5    COPY_8_TO_16_SUB 3, 1
   
                 add edx, ecx  
                 add esi, ecx  
                 add eax, ecx  
                 add ebx, ecx  
186    
187                  movq mm0, [edx]                 ; mm01 = [cur]    pop ebx
188                  movq mm1, mm0    ret
189    
                 punpcklbw mm0, mm7  
                 punpckhbw mm1, mm7  
190    
191                  movq mm4, [eax]  ALIGN 16
192                  movq mm5, mm4  transfer_8to16subro_mmx:
193      mov ecx, [esp  + 4] ; Dst
194      mov eax, [esp  + 8] ; Cur
195      push ebx
196      mov ebx, [esp+4+12] ; Ref
197      mov edx, [esp+4+16] ; Stride
198      pxor mm7, mm7
199    
200                  punpcklbw mm4, mm7    COPY_8_TO_16_SUB 0, 0
201                  punpckhbw mm5, mm7    COPY_8_TO_16_SUB 1, 0
202      COPY_8_TO_16_SUB 2, 0
203      COPY_8_TO_16_SUB 3, 0
204    
205                  movq mm2, [esi]                 ; mm23 = [ref]    pop ebx
206                  movq mm3, mm2    ret
207    
                 movq mm6, [ebx]  
208    
209                  movq [edx], mm2                 ; [cur] = [ref]  ;-----------------------------------------------------------------------------
210                  movq [eax], mm6  ;
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                  punpcklbw mm2, mm7  %macro COPY_8_TO_16_SUB2_MMX 1
220      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
229      punpcklbw mm1, mm7
230      punpckhbw mm6, 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  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 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  
   
                 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  
310    
311                  psubw mm0, mm2          ; mm0 = cur(3-0) - avg(3-0)  %macro COPY_8_TO_16_SUB2_SSE 1
312                  psubw mm1, mm3          ; mm1 = cur(7-4) - avg(7-4)    movq mm0, [eax]      ; cur
313      movq mm2, [eax+edx]
314                  movq [edi + 0], mm0 ; dct(3-0) = mm0    movq mm1, mm0
315                  movq [edi + 8], mm1 ; dct(7-4) = mm1    movq mm3, mm2
   
                 ; 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  ;===========================================================================  ;-----------------------------------------------------------------------------
367  ;  ;
368  ; void transfer_16to8add_mmx(uint8_t * const dst,  ; void transfer_16to8add_mmx(uint8_t * const dst,
369  ;                                               const int16_t * const src,  ;                                               const int16_t * const src,
370  ;                                               uint32_t stride);  ;                                               uint32_t stride);
371  ;  ;
372  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 cglobal transfer_16to8add_mmx  
 transfer_16to8add_mmx  
373    
374                  push    esi  %macro COPY_16_TO_8_ADD 1
375                  push    edi    movq mm0, [ecx]
376      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]  
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,
413  ;                                       const uint8_t * const src,  ;                                       const uint8_t * const src,
414  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
415  ;  ;
416  ;  ;
417  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 cglobal transfer8x8_copy_mmx  
 transfer8x8_copy_mmx  
                 push    esi  
                 push    edi  
418    
419                  mov     edi, [esp + 8 + 4]              ; dst [out]  %macro COPY_8_TO_8 0
420                  mov     esi, [esp + 8 + 8]              ; src [in]    movq mm0, [eax]
421                  mov eax, [esp + 8 + 12]         ; stride [in]    movq mm1, [eax+edx]
422      movq [ecx], mm0
423                  movq mm0, [esi]    lea eax, [eax+2*edx]
424                  movq mm1, [esi+eax]    movq [ecx+edx], mm1
425                  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  
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.1192

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