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

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

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