[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 1424, Mon Apr 12 15:49:56 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>
9  ; *     advised that its use may infringe existing patents or copyrights, and  ; *                2004 Jean-Marc Bastide <jmtest@voila.fr>
 ; *     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.  
10  ; *  ; *
11  ; *     This program is free software; you can redistribute it and/or modify  ; *     This program is free software; you can redistribute it and/or modify
12  ; *     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 20 
20  ; *  ; *
21  ; *     You should have received a copy of the GNU General Public License  ; *     You should have received a copy of the GNU General Public License
22  ; *     along with this program; if not, write to the Free Software  ; *     along with this program; if not, write to the Free Software
23  ; *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
24  ; *  ; *
25  ; *************************************************************************/  ; * $Id: mem_transfer_mmx.asm,v 1.11 2004-04-12 15:49:56 edgomez Exp $
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
26  ; *  ; *
27  ; * 07.01.2002  merge functions from compensate_mmx; rename functions  ; ***************************************************************************/
 ; *     07.11.2001      initial version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
 ; *  
 ; *************************************************************************/  
   
28    
29  bits 32  BITS 32
30    
31  %macro cglobal 1  %macro cglobal 1
32          %ifdef PREFIX          %ifdef PREFIX
# Line 49  Line 37 
37          %endif          %endif
38  %endmacro  %endmacro
39    
40    ;=============================================================================
41    ; Read only data
42    ;=============================================================================
43    
44  section .text  %ifdef FORMAT_COFF
45    SECTION .rodata data
46    %else
47    SECTION .rodata data align=16
48    %endif
49    
50    ALIGN 16
51    mmx_one:
52            dw 1, 1, 1, 1
53    
54    ;=============================================================================
55    ; Code
56    ;=============================================================================
57    
58  ;===========================================================================  SECTION .text
59    
60    cglobal transfer_8to16copy_mmx
61    cglobal transfer_16to8copy_mmx
62    cglobal transfer_8to16sub_mmx
63    cglobal transfer_8to16subro_mmx
64    cglobal transfer_8to16sub2_mmx
65    cglobal transfer_8to16sub2_xmm
66    cglobal transfer_16to8add_mmx
67    cglobal transfer8x8_copy_mmx
68    
69    ;-----------------------------------------------------------------------------
70  ;  ;
71  ; void transfer_8to16copy_mmx(int16_t * const dst,  ; void transfer_8to16copy_mmx(int16_t * const dst,
72  ;                                                       const uint8_t * const src,  ;                                                       const uint8_t * const src,
73  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
74  ;  ;
75  ;===========================================================================  ;-----------------------------------------------------------------------------
76    
77  align 16  %macro COPY_8_TO_16 1
78  cglobal transfer_8to16copy_mmx    movq mm0, [eax]
79  transfer_8to16copy_mmx    movq mm1, [eax+edx]
80      movq mm2, mm0
81                  push    esi    movq mm3, mm1
82                  push    edi    punpcklbw mm0, mm7
83      movq [ecx+%1*32], mm0
84                  mov     edi, [esp + 8 + 4]              ; dst    punpcklbw mm1, mm7
85                  mov     esi, [esp + 8 + 8]              ; src    movq [ecx+%1*32+16], mm1
86                  mov ecx, [esp + 8 + 12]         ; stride    punpckhbw mm2, mm7
87      punpckhbw mm3, mm7
88                  pxor mm7, mm7                           ; mm7 = zero    lea eax, [eax+2*edx]
89      movq [ecx+%1*32+8], mm2
90                  mov eax, 8    movq [ecx+%1*32+24], mm3
91    %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  
92    
93                  add edi, 16  ALIGN 16
94                  add esi, ecx  transfer_8to16copy_mmx:
                 dec eax  
                 jnz .loop  
95    
96                  pop edi    mov ecx, [esp+ 4] ; Dst
97                  pop esi    mov eax, [esp+ 8] ; Src
98      mov edx, [esp+12] ; Stride
99      pxor mm7, mm7
100    
101      COPY_8_TO_16 0
102      COPY_8_TO_16 1
103      COPY_8_TO_16 2
104      COPY_8_TO_16 3
105                  ret                  ret
106    
107    ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
108  ;  ;
109  ; void transfer_16to8copy_mmx(uint8_t * const dst,  ; void transfer_16to8copy_mmx(uint8_t * const dst,
110  ;                                                       const int16_t * const src,  ;                                                       const int16_t * const src,
111  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
112  ;  ;
113  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 cglobal transfer_16to8copy_mmx  
 transfer_16to8copy_mmx  
   
                 push    esi  
                 push    edi  
   
                 mov     edi, [esp + 8 + 4]              ; dst  
                 mov     esi, [esp + 8 + 8]              ; src  
                 mov ecx, [esp + 8 + 12]         ; stride  
   
                 mov eax, 8  
114    
115  .loop  %macro COPY_16_TO_8 1
116                  movq mm0, [esi]    movq mm0, [eax+%1*32]
117                  packuswb mm0, [esi + 8]         ; mm0 = pack([src])    movq mm1, [eax+%1*32+8]
118      packuswb mm0, mm1
119                  movq [edi], mm0                         ; [dst] = mm0    movq [ecx], mm0
120      movq mm2, [eax+%1*32+16]
121                  add esi, 16    movq mm3, [eax+%1*32+24]
122                  add edi, ecx    packuswb mm2, mm3
123                  dec eax    movq [ecx+edx], mm2
124                  jnz .loop  %endmacro
125    
126                  pop edi  ALIGN 16
127                  pop esi  transfer_16to8copy_mmx:
128    
129      mov ecx, [esp+ 4] ; Dst
130      mov eax, [esp+ 8] ; Src
131      mov edx, [esp+12] ; Stride
132    
133      COPY_16_TO_8 0
134      lea ecx,[ecx+2*edx]
135      COPY_16_TO_8 1
136      lea ecx,[ecx+2*edx]
137      COPY_16_TO_8 2
138      lea ecx,[ecx+2*edx]
139      COPY_16_TO_8 3
140                  ret                  ret
141    
142    ;-----------------------------------------------------------------------------
 ;===========================================================================  
143  ;  ;
144  ; void transfer_8to16sub_mmx(int16_t * const dct,  ; void transfer_8to16sub_mmx(int16_t * const dct,
145  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
146  ;                               const uint8_t * const ref,  ;                               const uint8_t * const ref,
147  ;                               const uint32_t stride);  ;                               const uint32_t stride);
148  ;  ;
149  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;/**************************************************************************  
 ; *  
 ; *     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>  
 ; *  
 ; *************************************************************************/  
150    
151  align 16  ; when second argument == 1, reference (ebx) block is to current (eax)
152  cglobal transfer_8to16sub_mmx  %macro COPY_8_TO_16_SUB 2
153  transfer_8to16sub_mmx    movq mm0, [eax]      ; cur
154                  push    esi    movq mm2, [eax+edx]
155                  push    edi  
156                  push    ebx    movq mm4, [ebx]      ; ref
157      movq mm5, [ebx+edx]  ; ref
158                  mov     edi, [esp + 12 + 4]             ; dct [out]  
159                  mov     edx, [esp + 12 + 8]             ; cur [in/out]  %if %2 == 1
160                  mov     esi, [esp + 12 + 12]            ; ref [in]    movq [eax], mm4
161                  mov ecx, [esp + 12 + 16]                ; stride [in]    movq [eax+edx], mm5
162    %endif
                 mov eax, edx                            ; cur -> eax  
                 mov ebx, esi                            ; ref -> ebx  
                 add eax, ecx                            ; cur + stride  
                 add ebx, ecx                            ; ref + stride  
163    
164                  shl ecx, 1    lea eax, [eax+2*edx]
165    
166                  pxor mm7, mm7                   ; mm7 = zero    psubsb mm0,mm4
167      psubsb mm2,mm5
168      lea ebx,[ebx+2*edx]
169    
                 movq mm0, [edx]                 ; mm01 = [cur]  
170                  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]  
171                  movq mm3, mm2                  movq mm3, mm2
   
                 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  
   
172                  punpcklbw mm0, mm7                  punpcklbw mm0, mm7
173                  punpckhbw mm1, 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  
   
174                  punpcklbw mm2, mm7                  punpcklbw mm2, mm7
175                  punpckhbw mm3, mm7                  punpckhbw mm3, mm7
176    
177                  psubsw mm0, mm2                 ; mm01 -= mm23    movq [ecx+%1*32+ 0], mm0 ; dst
178      movq [ecx+%1*32+ 8], mm1
179                  movq mm2, mm6    movq [ecx+%1*32+16], mm2
180      movq [ecx+%1*32+24], mm3
181                  punpcklbw mm2, mm7  %endmacro
                 punpckhbw mm6, mm7  
   
                 psubsw mm1, mm3  
   
                 psubsw mm4, mm2  
                 psubsw mm5, mm6  
   
                 movq [edi + 32], mm0                    ; dct[] = mm01  
                 movq [edi + 40], mm1  
                 movq [edi + 48], mm4  
                 movq [edi + 56], mm5  
   
                 add edx, ecx  
                 add esi, ecx  
                 add eax, ecx  
                 add ebx, ecx  
   
                 movq mm0, [edx]                 ; mm01 = [cur]  
                 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]  
                 movq mm3, mm2  
   
                 movq mm6, [ebx]  
182    
183                  movq [edx], mm2                 ; [cur] = [ref]  ALIGN 16
184                  movq [eax], mm6  transfer_8to16sub_mmx:
185      mov ecx, [esp  + 4] ; Dst
186      mov eax, [esp  + 8] ; Cur
187      push ebx
188      mov ebx, [esp+4+12] ; Ref
189      mov edx, [esp+4+16] ; Stride
190      pxor mm7, mm7
191    
192                  punpcklbw mm2, mm7    COPY_8_TO_16_SUB 0, 1
193                  punpckhbw mm3, mm7    COPY_8_TO_16_SUB 1, 1
194      COPY_8_TO_16_SUB 2, 1
195      COPY_8_TO_16_SUB 3, 1
196    
197                  psubsw mm0, mm2                 ; mm01 -= mm23    pop ebx
198      ret
199    
                 movq mm2, mm6  
200    
201                  punpcklbw mm2, mm7  ALIGN 16
202                  punpckhbw mm6, mm7  transfer_8to16subro_mmx:
203      mov ecx, [esp  + 4] ; Dst
204      mov eax, [esp  + 8] ; Cur
205      push ebx
206      mov ebx, [esp+4+12] ; Ref
207      mov edx, [esp+4+16] ; Stride
208      pxor mm7, mm7
209    
210                  psubsw mm1, mm3    COPY_8_TO_16_SUB 0, 0
211      COPY_8_TO_16_SUB 1, 0
212      COPY_8_TO_16_SUB 2, 0
213      COPY_8_TO_16_SUB 3, 0
214    
215                  psubsw mm4, mm2    pop ebx
216                  psubsw mm5, mm6    ret
217    
                 movq [edi + 64], mm0                    ; dct[] = mm01  
                 movq [edi + 72], mm1  
                 movq [edi + 80], mm4  
                 movq [edi + 88], mm5  
218    
219                  add edx, ecx  ;-----------------------------------------------------------------------------
220                  add esi, ecx  ;
221                  add eax, ecx  ; void transfer_8to16sub2_mmx(int16_t * const dct,
222                  add ebx, ecx  ;                               uint8_t * const cur,
223    ;                               const uint8_t * ref1,
224    ;                               const uint8_t * ref2,
225    ;                               const uint32_t stride)
226    ;
227    ;-----------------------------------------------------------------------------
228    
229                  movq mm0, [edx]                 ; mm01 = [cur]  %macro COPY_8_TO_16_SUB2_MMX 1
230      movq mm0, [eax]      ; cur
231      movq mm2, [eax+edx]
232    
233      ; mm4 <- (ref1+ref2+1) / 2
234      ;(a+b+1)/2 = (a|b)-((a^b)>>1)
235      movq mm4, [ebx]      ; ref1
236      movq mm1, [esi]      ; ref2
237      movq mm3, mm4
238      pxor mm3,mm1
239      por mm4,mm1
240      pandn mm3,mm6
241      psrlq mm3,1
242      psubb mm4,mm3
243      movq [eax],mm4
244    
245      ; mm5 <- (ref1+ref2+1) / 2
246      movq mm5, [ebx+edx]  ; ref1
247      movq mm1, [esi+edx]  ; ref2
248      movq mm3, mm5
249      pxor mm3,mm1
250      por mm5,mm1
251      pandn mm3,mm6
252      psrlq mm3,1
253      psubb mm5,mm3
254      movq [eax+edx],mm5
255    
256      psubsb mm0,mm4
257      psubsb mm2,mm5
258      lea esi, [esi+2*edx]
259                  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]  
260                  movq mm3, mm2                  movq mm3, mm2
261      lea eax, [eax+2*edx]
262                  movq mm6, [ebx]    punpcklbw mm0,mm7
   
                 movq [edx], mm2                 ; [cur] = [ref]  
                 movq [eax], mm6  
   
263                  punpcklbw mm2, mm7                  punpcklbw mm2, mm7
264      lea ebx, [ebx+2*edx]
265      punpckhbw mm1,mm7
266                  punpckhbw mm3, mm7                  punpckhbw mm3, mm7
267    
268                  psubsw mm0, mm2                 ; mm01 -= mm23    movq [ecx+%1*32+ 0], mm0 ; dst
269      movq [ecx+%1*32+ 8], mm1
270                  movq mm2, mm6    movq [ecx+%1*32+16], mm2
271      movq [ecx+%1*32+24], mm3
272                  punpcklbw mm2, mm7  %endmacro
                 punpckhbw mm6, mm7  
   
                 psubsw mm1, mm3  
273    
274                  psubsw mm4, mm2  ALIGN 16
275                  psubsw mm5, mm6  transfer_8to16sub2_mmx:
276      mov ecx, [esp  + 4] ; Dst
277      mov eax, [esp  + 8] ; Cur
278      push ebx
279      mov ebx, [esp+4+12] ; Ref1
280      push esi
281      mov esi, [esp+8+16] ; Ref2
282      mov edx, [esp+8+20] ; Stride
283      pxor mm6,mm6
284      pcmpeqb mm5,mm5
285      pxor mm7, mm7
286      psubb mm6, mm5; mm6=1
287    
288                  movq [edi + 96], mm0                    ; dct[] = mm01    COPY_8_TO_16_SUB2_MMX 0
289                  movq [edi + 104], mm1    COPY_8_TO_16_SUB2_MMX 1
290                  movq [edi + 112], mm4    COPY_8_TO_16_SUB2_MMX 2
291                  movq [edi + 120], mm5    COPY_8_TO_16_SUB2_MMX 3
292    
                 pop ebx  
                 pop edi  
293                  pop esi                  pop esi
294      pop ebx
295                  ret                  ret
296    
297    ;-----------------------------------------------------------------------------
 ;===========================================================================  
298  ;  ;
299  ; void transfer_8to16sub2_xmm(int16_t * const dct,  ; void transfer_8to16sub2_xmm(int16_t * const dct,
300  ;                                                         uint8_t * const cur,  ;                                                         uint8_t * const cur,
301  ;                                                         const uint8_t * ref1,  ;                                                         const uint8_t * ref1,
302  ;                                                         const uint8_t * ref2,  ;                                                         const uint8_t * ref2,
303  ;                                                         const uint32_t stride);  ;                               const uint32_t stride)
304  ;  ;
305  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 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  
306    
307                  psubw mm0, mm2          ; mm0 = cur(3-0) - avg(3-0)  %macro COPY_8_TO_16_SUB2_SSE 1
308                  psubw mm1, mm3          ; mm1 = cur(7-4) - avg(7-4)    movq mm0, [eax]      ; cur
309      movq mm2, [eax+edx]
310    
311                  movq [edi + 0], mm0 ; dct(3-0) = mm0    movq mm4, [ebx]     ; ref1
312                  movq [edi + 8], mm1 ; dct(7-4) = mm1    pavgb mm4, [esi]     ; ref2
313    
314                  ; Increment all pointers    movq mm5, [ebx+edx] ; ref
315                  add edi, eax    ; edi = &(next dct row)    pavgb mm5, [esi+edx] ; ref2
316    
317                  ; Row processing    movq [eax], mm4
318                  ; One row at a time    movq [eax+edx], mm5
                 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  
319    
320                  pavgb mm2, mm3          ; mm2 = (ref1 + ref2 + 1)/2 (== avg)    psubsb mm0,mm4
321                  punpcklbw mm0, mm7      ; mm0 = cur(3-0) <-> 16bit    psubsb mm2,mm5
322      lea esi, [esi+2*edx]
323                  movq mm3,mm2            ; mm3 = avg    movq mm1,mm0
324                  punpckhbw mm1, mm7      ; mm1 = cur(7-4) <-> 16bit    movq mm3,mm2
325      lea eax, [eax+2*edx]
326                  punpcklbw mm2, mm7      ; mm2 = avg(3-0) <-> 16bit    punpcklbw mm0,mm7
327                  punpckhbw mm3, mm7      ; mm3 = avg(7-4) <-> 16bit    punpcklbw mm2,mm7
328      lea ebx, [ebx+2*edx]
329                  psubw mm0, mm2          ; mm0 = cur(3-0) - avg(3-0)    punpckhbw mm1,mm7
330                  psubw mm1, mm3          ; mm1 = cur(7-4) - avg(7-4)    punpckhbw mm3,mm7
   
                 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  
   
                 punpcklbw mm2, mm7      ; mm2 = avg(3-0) <-> 16bit  
                 punpckhbw mm3, mm7      ; mm3 = avg(7-4) <-> 16bit  
331    
332                  psubw mm0, mm2          ; mm0 = cur(3-0) - avg(3-0)    movq [ecx+%1*32+ 0], mm0 ; dst
333                  psubw mm1, mm3          ; mm1 = cur(7-4) - avg(7-4)    movq [ecx+%1*32+ 8], mm1
334      movq [ecx+%1*32+16], mm2
335      movq [ecx+%1*32+24], mm3
336    %endmacro
337    
338                  movq [edi + 0], mm0 ; dct(3-0) = mm0  ALIGN 16
339                  movq [edi + 8], mm1 ; dct(7-4) = mm1  transfer_8to16sub2_xmm:
340      mov ecx, [esp  + 4] ; Dst
341      mov eax, [esp  + 8] ; Cur
342      push ebx
343      mov ebx, [esp+4+12] ; Ref1
344      push esi
345      mov esi, [esp+8+16] ; Ref2
346      mov edx, [esp+8+20] ; Stride
347      pxor mm7, mm7
348    
349                  ; Exit    COPY_8_TO_16_SUB2_SSE 0
350      COPY_8_TO_16_SUB2_SSE 1
351      COPY_8_TO_16_SUB2_SSE 2
352      COPY_8_TO_16_SUB2_SSE 3
353    
                 pop ebx  
354                  pop esi                  pop esi
355                  pop edi    pop ebx
   
356                  ret                  ret
357    
358  ;===========================================================================  ;-----------------------------------------------------------------------------
359  ;  ;
360  ; void transfer_16to8add_mmx(uint8_t * const dst,  ; void transfer_16to8add_mmx(uint8_t * const dst,
361  ;                                               const int16_t * const src,  ;                                               const int16_t * const src,
362  ;                                               uint32_t stride);  ;                                               uint32_t stride);
363  ;  ;
364  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 cglobal transfer_16to8add_mmx  
 transfer_16to8add_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  
365    
366                  mov eax, 8  %macro COPY_16_TO_8_ADD 1
367      movq mm0, [eax+%1*32+ 0] ;src
368      packuswb mm0,[eax+%1*32+8]
369      movq mm1, [eax+%1*32+ 16]
370      packuswb mm1,[eax+%1*32+24]
371    
372      paddusb mm0,[ecx]
373      paddusb mm1,[ecx+edx]
374      movq [ecx],mm0
375      movq [ecx+edx],mm1
376    
377  .loop  %endmacro
                 movq mm0, [edi]  
                 movq mm1, mm0  
                 punpcklbw mm0, mm7              ; mm23 = unpack([dst])  
                 punpckhbw mm1, mm7  
   
                 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  
378    
                 pop edi  
                 pop esi  
379    
380    ALIGN 16
381    transfer_16to8add_mmx:
382      mov ecx, [esp+ 4] ; Dst
383      mov eax, [esp+ 8] ; Src
384      mov edx, [esp+12] ; Stride
385     ; pxor mm7, mm7
386    
387      COPY_16_TO_8_ADD 0
388      lea ecx,[ecx+2*edx]
389      COPY_16_TO_8_ADD 1
390      lea ecx,[ecx+2*edx]
391      COPY_16_TO_8_ADD 2
392      lea ecx,[ecx+2*edx]
393      COPY_16_TO_8_ADD 3
394                  ret                  ret
395    
396    ;-----------------------------------------------------------------------------
 ;===========================================================================  
397  ;  ;
398  ; void transfer8x8_copy_mmx(uint8_t * const dst,  ; void transfer8x8_copy_mmx(uint8_t * const dst,
399  ;                                       const uint8_t * const src,  ;                                       const uint8_t * const src,
400  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
401  ;  ;
402  ;  ;
403  ;===========================================================================  ;-----------------------------------------------------------------------------
404    
405  align 16  ALIGN 16
406  cglobal transfer8x8_copy_mmx  transfer8x8_copy_mmx:
 transfer8x8_copy_mmx  
                 push    esi  
                 push    edi  
407    
408                  mov     edi, [esp + 8 + 4]              ; dst [out]    mov eax, [esp+ 8] ; Src
409                  mov     esi, [esp + 8 + 8]              ; src [in]    mov ecx, [esp+ 4] ; Dst
410                  mov eax, [esp + 8 + 12]         ; stride [in]    mov edx, [esp+12] ; Stride
411    
412                  movq mm0, [esi]    movq mm0,[eax]
413                  movq mm1, [esi+eax]    lea eax,[eax+edx]
414                  movq [edi], mm0    movq mm1,[eax]
415                  movq [edi+eax], mm1    lea eax,[eax+edx]
416      movq mm2,[eax]
417                  add esi, eax    lea eax,[eax+edx]
418                  add edi, eax    movq mm3,[eax]
419                  add esi, eax    lea eax,[eax+edx]
420                  add edi, eax    movq mm4,[eax]
421      lea eax,[eax+edx]
422                  movq mm0, [esi]    movq mm5,[eax]
423                  movq mm1, [esi+eax]    lea eax,[eax+edx]
424                  movq [edi], mm0    movq mm6,[eax]
425                  movq [edi+eax], mm1    lea eax,[eax+edx]
426      movq mm7,[eax]
427                  add esi, eax  
428                  add edi, eax    movq [ecx],mm0
429                  add esi, eax    lea ecx,[ecx+edx]
430                  add edi, eax    movq [ecx],mm1
431      lea ecx,[ecx+edx]
432                  movq mm0, [esi]    movq [ecx],mm2
433                  movq mm1, [esi+eax]    lea ecx,[ecx+edx]
434                  movq [edi], mm0    movq [ecx],mm3
435                  movq [edi+eax], mm1    lea ecx,[ecx+edx]
436      movq [ecx],mm4
437                  add esi, eax    lea ecx,[ecx+edx]
438                  add edi, eax    movq [ecx],mm5
439                  add esi, eax    lea ecx,[ecx+edx]
440                  add edi, eax    movq [ecx],mm6
441      lea ecx,[ecx+edx]
442                  movq mm0, [esi]    movq [ecx],mm7
                 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  
443    
444                  ret                  ret

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

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