[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 1583, Sun Dec 19 13:16:50 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.16 2004-12-19 13:16:50 syskin Exp $
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
 ; *  
 ; * 07.01.2002  merge functions from compensate_mmx; rename functions  
 ; *     07.11.2001      initial version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
25  ; *  ; *
26  ; *************************************************************************/  ; ***************************************************************************/
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_8to16sub2ro_xmm
75    cglobal transfer_16to8add_mmx
76    cglobal transfer8x8_copy_mmx
77    
78    ;-----------------------------------------------------------------------------
79  ;  ;
80  ; void transfer_8to16copy_mmx(int16_t * const dst,  ; void transfer_8to16copy_mmx(int16_t * const dst,
81  ;                                                       const uint8_t * const src,  ;                                                       const uint8_t * const src,
82  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
83  ;  ;
84  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 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  
   
                 mov eax, 8  
85    
86  .loop  %macro COPY_8_TO_16 1
87                  movq mm0, [esi]    movq mm0, [eax]
88                  movq mm1, mm0    movq mm1, [eax+edx]
89                  punpcklbw mm0, mm7              ; mm01 = unpack([src])    movq mm2, mm0
90                  punpckhbw mm1, mm7    movq mm3, mm1
91      punpcklbw mm0, mm7
92                  movq [edi], mm0                 ; [dst] = mm01    movq [ecx+%1*32], mm0
93                  movq [edi + 8], mm1    punpcklbw mm1, mm7
94      movq [ecx+%1*32+16], mm1
95      punpckhbw mm2, mm7
96      punpckhbw mm3, mm7
97      lea eax, [eax+2*edx]
98      movq [ecx+%1*32+8], mm2
99      movq [ecx+%1*32+24], mm3
100    %endmacro
101    
102                  add edi, 16  ALIGN 16
103                  add esi, ecx  transfer_8to16copy_mmx:
                 dec eax  
                 jnz .loop  
104    
105                  pop edi    mov ecx, [esp+ 4] ; Dst
106                  pop esi    mov eax, [esp+ 8] ; Src
107      mov edx, [esp+12] ; Stride
108      pxor mm7, mm7
109    
110      COPY_8_TO_16 0
111      COPY_8_TO_16 1
112      COPY_8_TO_16 2
113      COPY_8_TO_16 3
114                  ret                  ret
115    .endfunc
116    
117    ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
118  ;  ;
119  ; void transfer_16to8copy_mmx(uint8_t * const dst,  ; void transfer_16to8copy_mmx(uint8_t * const dst,
120  ;                                                       const int16_t * const src,  ;                                                       const int16_t * const src,
121  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
122  ;  ;
123  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 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  
   
 .loop  
                 movq mm0, [esi]  
                 packuswb mm0, [esi + 8]         ; mm0 = pack([src])  
124    
125                  movq [edi], mm0                         ; [dst] = mm0  %macro COPY_16_TO_8 1
126      movq mm0, [eax+%1*32]
127                  add esi, 16    movq mm1, [eax+%1*32+8]
128                  add edi, ecx    packuswb mm0, mm1
129                  dec eax    movq [ecx], mm0
130                  jnz .loop    movq mm2, [eax+%1*32+16]
131      movq mm3, [eax+%1*32+24]
132      packuswb mm2, mm3
133      movq [ecx+edx], mm2
134    %endmacro
135    
136                  pop edi  ALIGN 16
137                  pop esi  transfer_16to8copy_mmx:
138    
139      mov ecx, [esp+ 4] ; Dst
140      mov eax, [esp+ 8] ; Src
141      mov edx, [esp+12] ; Stride
142    
143      COPY_16_TO_8 0
144      lea ecx,[ecx+2*edx]
145      COPY_16_TO_8 1
146      lea ecx,[ecx+2*edx]
147      COPY_16_TO_8 2
148      lea ecx,[ecx+2*edx]
149      COPY_16_TO_8 3
150                  ret                  ret
151    .endfunc
152    
153    ;-----------------------------------------------------------------------------
 ;===========================================================================  
154  ;  ;
155  ; void transfer_8to16sub_mmx(int16_t * const dct,  ; void transfer_8to16sub_mmx(int16_t * const dct,
156  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
157  ;                               const uint8_t * const ref,  ;                               const uint8_t * const ref,
158  ;                               const uint32_t stride);  ;                               const uint32_t stride);
159  ;  ;
160  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;/**************************************************************************  
 ; *  
 ; *     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>  
 ; *  
 ; *************************************************************************/  
161    
162  align 16  ; when second argument == 1, reference (ebx) block is to current (eax)
163  cglobal transfer_8to16sub_mmx  %macro COPY_8_TO_16_SUB 2
164  transfer_8to16sub_mmx    movq mm0, [eax]      ; cur
165                  push    esi    movq mm2, [eax+edx]
                 push    edi  
                 push    ebx  
   
                 mov     edi, [esp + 12 + 4]             ; dct [out]  
                 mov     edx, [esp + 12 + 8]             ; cur [in/out]  
                 mov     esi, [esp + 12 + 12]            ; ref [in]  
                 mov ecx, [esp + 12 + 16]                ; stride [in]  
   
                 mov eax, edx                            ; cur -> eax  
                 mov ebx, esi                            ; ref -> ebx  
                 add eax, ecx                            ; cur + stride  
                 add ebx, ecx                            ; ref + stride  
   
                 shl ecx, 1  
   
                 pxor mm7, mm7                   ; mm7 = zero  
   
                 movq mm0, [edx]                 ; mm01 = [cur]  
166                  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]  
167                  movq mm3, mm2                  movq mm3, mm2
168    
169                  movq mm6, [ebx]    punpcklbw mm0, mm7
   
                 movq [edx], mm2                 ; [cur] = [ref]  
                 movq [eax], mm6  
   
170                  punpcklbw mm2, mm7                  punpcklbw mm2, mm7
171      movq mm4, [ebx]      ; ref
172      punpckhbw mm1, mm7
173                  punpckhbw mm3, mm7                  punpckhbw mm3, mm7
174      movq mm5, [ebx+edx]  ; ref
175    
176                  psubsw mm0, mm2                 ; mm01 -= mm23    movq mm6, mm4
177    %if %2 == 1
178                  movq mm2, mm6    movq [eax], mm4
179      movq [eax+edx], mm5
180                  punpcklbw mm2, mm7  %endif
181      punpcklbw mm4, mm7
182                  punpckhbw mm6, mm7                  punpckhbw mm6, mm7
183      psubsw mm0, mm4
184      psubsw mm1, mm6
185      movq mm6, mm5
186      punpcklbw mm5, mm7
187      punpckhbw mm6, mm7
188      psubsw mm2, mm5
189      lea eax, [eax+2*edx]
190      psubsw mm3, mm6
191      lea ebx,[ebx+2*edx]
192    
193      movq [ecx+%1*32+ 0], mm0 ; dst
194      movq [ecx+%1*32+ 8], mm1
195      movq [ecx+%1*32+16], mm2
196      movq [ecx+%1*32+24], mm3
197    %endmacro
198    
199                  psubsw mm1, mm3  ALIGN 16
200    transfer_8to16sub_mmx:
201                  psubsw mm4, mm2    mov ecx, [esp  + 4] ; Dst
202                  psubsw mm5, mm6    mov eax, [esp  + 8] ; Cur
203      push ebx
204      mov ebx, [esp+4+12] ; Ref
205      mov edx, [esp+4+16] ; Stride
206      pxor mm7, mm7
207    
208                  movq [edi], mm0                 ; dct[] = mm01    COPY_8_TO_16_SUB 0, 1
209                  movq [edi + 8], mm1    COPY_8_TO_16_SUB 1, 1
210                  movq [edi + 16], mm4    COPY_8_TO_16_SUB 2, 1
211                  movq [edi + 24], mm5    COPY_8_TO_16_SUB 3, 1
   
                 add edx, ecx  
                 add esi, ecx  
                 add eax, ecx  
                 add ebx, ecx  
212    
213                  movq mm0, [edx]                 ; mm01 = [cur]    pop ebx
214                  movq mm1, mm0    ret
215    .endfunc
216    
                 punpcklbw mm0, mm7  
                 punpckhbw mm1, mm7  
217    
218                  movq mm4, [eax]  ALIGN 16
219                  movq mm5, mm4  transfer_8to16subro_mmx:
220      mov ecx, [esp  + 4] ; Dst
221      mov eax, [esp  + 8] ; Cur
222      push ebx
223      mov ebx, [esp+4+12] ; Ref
224      mov edx, [esp+4+16] ; Stride
225      pxor mm7, mm7
226    
227                  punpcklbw mm4, mm7    COPY_8_TO_16_SUB 0, 0
228                  punpckhbw mm5, mm7    COPY_8_TO_16_SUB 1, 0
229      COPY_8_TO_16_SUB 2, 0
230      COPY_8_TO_16_SUB 3, 0
231    
232                  movq mm2, [esi]                 ; mm23 = [ref]    pop ebx
233                  movq mm3, mm2    ret
234    .endfunc
235    
                 movq mm6, [ebx]  
236    
237                  movq [edx], mm2                 ; [cur] = [ref]  ;-----------------------------------------------------------------------------
238                  movq [eax], mm6  ;
239    ; void transfer_8to16sub2_mmx(int16_t * const dct,
240    ;                               uint8_t * const cur,
241    ;                               const uint8_t * ref1,
242    ;                               const uint8_t * ref2,
243    ;                               const uint32_t stride)
244    ;
245    ;-----------------------------------------------------------------------------
246    
247                  punpcklbw mm2, mm7  %macro COPY_8_TO_16_SUB2_MMX 1
248      movq mm0, [eax]      ; cur
249      movq mm2, [eax+edx]
250    
251      ; mm4 <- (ref1+ref2+1) / 2
252      movq mm4, [ebx]      ; ref1
253      movq mm1, [esi]      ; ref2
254      movq mm6, mm4
255      movq mm3, mm1
256      punpcklbw mm4, mm7
257      punpcklbw mm1, mm7
258      punpckhbw mm6, mm7
259                  punpckhbw mm3, mm7                  punpckhbw mm3, mm7
260      paddusw mm4, mm1
261                  psubsw mm0, mm2                 ; mm01 -= mm23    paddusw mm6, mm3
262      paddusw mm4, [mmx_one]
263                  movq mm2, mm6    paddusw mm6, [mmx_one]
264      psrlw mm4, 1
265                  punpcklbw mm2, mm7    psrlw mm6, 1
266      packuswb mm4, mm6
267      movq [eax], mm4
268    
269        ; mm5 <- (ref1+ref2+1) / 2
270      movq mm5, [ebx+edx]  ; ref1
271      movq mm1, [esi+edx]  ; ref2
272      movq mm6, mm5
273      movq mm3, mm1
274      punpcklbw mm5, mm7
275      punpcklbw mm1, mm7
276                  punpckhbw mm6, mm7                  punpckhbw mm6, mm7
277      punpckhbw mm3, mm7
278      paddusw mm5, mm1
279      paddusw mm6, mm3
280      paddusw mm5, [mmx_one]
281      paddusw mm6, [mmx_one]
282      lea esi, [esi+2*edx]
283      psrlw mm5, 1
284      psrlw mm6, 1
285      packuswb mm5, mm6
286      movq [eax+edx], mm5
287    
                 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]  
288                  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]  
289                  movq mm3, mm2                  movq mm3, mm2
290      punpcklbw mm0, mm7
                 movq mm6, [ebx]  
   
                 movq [edx], mm2                 ; [cur] = [ref]  
                 movq [eax], mm6  
   
291                  punpcklbw mm2, mm7                  punpcklbw mm2, mm7
292      punpckhbw mm1, mm7
293                  punpckhbw mm3, mm7                  punpckhbw mm3, mm7
294    
295                  psubsw mm0, mm2                 ; mm01 -= mm23    movq mm6, mm4
296      punpcklbw mm4, mm7
                 movq mm2, mm6  
   
                 punpcklbw mm2, mm7  
297                  punpckhbw mm6, mm7                  punpckhbw mm6, mm7
298      psubsw mm0, mm4
299      psubsw mm1, mm6
300      movq mm6, mm5
301      punpcklbw mm5, mm7
302      punpckhbw mm6, mm7
303      psubsw mm2, mm5
304      lea eax, [eax+2*edx]
305      psubsw mm3, mm6
306      lea ebx, [ebx+2*edx]
307    
308      movq [ecx+%1*32+ 0], mm0 ; dst
309      movq [ecx+%1*32+ 8], mm1
310      movq [ecx+%1*32+16], mm2
311      movq [ecx+%1*32+24], mm3
312    %endmacro
313    
314                  psubsw mm1, mm3  ALIGN 16
315    transfer_8to16sub2_mmx:
316                  psubsw mm4, mm2    mov ecx, [esp  + 4] ; Dst
317                  psubsw mm5, mm6    mov eax, [esp  + 8] ; Cur
318      push ebx
319                  movq [edi + 64], mm0                    ; dct[] = mm01    mov ebx, [esp+4+12] ; Ref1
320                  movq [edi + 72], mm1    push esi
321                  movq [edi + 80], mm4    mov esi, [esp+8+16] ; Ref2
322                  movq [edi + 88], mm5    mov edx, [esp+8+20] ; Stride
323      pxor mm7, mm7
                 add edx, ecx  
                 add esi, ecx  
                 add eax, ecx  
                 add ebx, ecx  
   
                 movq mm0, [edx]                 ; mm01 = [cur]  
                 movq mm1, mm0  
324    
325                  punpcklbw mm0, mm7    COPY_8_TO_16_SUB2_MMX 0
326                  punpckhbw mm1, mm7    COPY_8_TO_16_SUB2_MMX 1
327      COPY_8_TO_16_SUB2_MMX 2
328      COPY_8_TO_16_SUB2_MMX 3
329    
330                  movq mm4, [eax]    pop esi
331                  movq mm5, mm4    pop ebx
332      ret
333    .endfunc
334    
335                  punpcklbw mm4, mm7  ;-----------------------------------------------------------------------------
336                  punpckhbw mm5, mm7  ;
337    ; void transfer_8to16sub2_xmm(int16_t * const dct,
338    ;                               uint8_t * const cur,
339    ;                               const uint8_t * ref1,
340    ;                               const uint8_t * ref2,
341    ;                               const uint32_t stride)
342    ;
343    ;-----------------------------------------------------------------------------
344    
345                  movq mm2, [esi]                 ; mm23 = [ref]  %macro COPY_8_TO_16_SUB2_SSE 1
346      movq mm0, [eax]      ; cur
347      movq mm2, [eax+edx]
348      movq mm1, mm0
349                  movq mm3, mm2                  movq mm3, mm2
350    
351                  movq mm6, [ebx]    punpcklbw mm0, mm7
   
                 movq [edx], mm2                 ; [cur] = [ref]  
                 movq [eax], mm6  
   
352                  punpcklbw mm2, mm7                  punpcklbw mm2, mm7
353      movq mm4, [ebx]     ; ref1
354      pavgb mm4, [esi]     ; ref2
355      movq [eax], mm4
356      punpckhbw mm1, mm7
357                  punpckhbw mm3, mm7                  punpckhbw mm3, mm7
358      movq mm5, [ebx+edx] ; ref
359      pavgb mm5, [esi+edx] ; ref2
360      movq [eax+edx], mm5
361    
362                  psubsw mm0, mm2                 ; mm01 -= mm23    movq mm6, mm4
363      punpcklbw mm4, mm7
                 movq mm2, mm6  
   
                 punpcklbw mm2, mm7  
364                  punpckhbw mm6, mm7                  punpckhbw mm6, mm7
365      psubsw mm0, mm4
366      psubsw mm1, mm6
367      lea esi, [esi+2*edx]
368      movq mm6, mm5
369      punpcklbw mm5, mm7
370      punpckhbw mm6, mm7
371      psubsw mm2, mm5
372      lea eax, [eax+2*edx]
373      psubsw mm3, mm6
374      lea ebx, [ebx+2*edx]
375    
376      movq [ecx+%1*32+ 0], mm0 ; dst
377      movq [ecx+%1*32+ 8], mm1
378      movq [ecx+%1*32+16], mm2
379      movq [ecx+%1*32+24], mm3
380    %endmacro
381    
382                  psubsw mm1, mm3  ALIGN 16
383    transfer_8to16sub2_xmm:
384                  psubsw mm4, mm2    mov ecx, [esp  + 4] ; Dst
385                  psubsw mm5, mm6    mov eax, [esp  + 8] ; Cur
386      push ebx
387      mov ebx, [esp+4+12] ; Ref1
388      push esi
389      mov esi, [esp+8+16] ; Ref2
390      mov edx, [esp+8+20] ; Stride
391      pxor mm7, mm7
392    
393                  movq [edi + 96], mm0                    ; dct[] = mm01    COPY_8_TO_16_SUB2_SSE 0
394                  movq [edi + 104], mm1    COPY_8_TO_16_SUB2_SSE 1
395                  movq [edi + 112], mm4    COPY_8_TO_16_SUB2_SSE 2
396                  movq [edi + 120], mm5    COPY_8_TO_16_SUB2_SSE 3
397    
                 pop ebx  
                 pop edi  
398                  pop esi                  pop esi
399      pop ebx
400                  ret                  ret
401    .endfunc
402    
403    
404  ;===========================================================================  ;-----------------------------------------------------------------------------
405  ;  ;
406  ; void transfer_8to16sub2_xmm(int16_t * const dct,  ; void transfer_8to16sub2ro_xmm(int16_t * const dct,
407  ;                                                         uint8_t * const cur,  ;                               const uint8_t * const cur,
408  ;                                                         const uint8_t * ref1,  ;                                                         const uint8_t * ref1,
409  ;                                                         const uint8_t * ref2,  ;                                                         const uint8_t * ref2,
410  ;                                                         const uint32_t stride);  ;                               const uint32_t stride)
411  ;  ;
412  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 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)  
413    
414                  ; Row processing  %macro COPY_8_TO_16_SUB2RO_SSE 1
415                  ; One row at a time    movq mm0, [eax]      ; cur
416                  movq mm0, [esi + 32] ; mm0 = cur row    movq mm2, [eax+edx]
417                  movq mm2, [ebx + 32]    ; mm2 = ref1 row    movq mm1, mm0
418                  movq mm3, [edx + 32]    ; mm3 = ref2 row    movq mm3, mm2
                 movq mm1, mm0   ; mm1 = cur row  
   
                 pavgb mm2, mm3          ; mm2 = (ref1 + ref2 + 1)/2 (== avg)  
                 punpcklbw mm0, mm7      ; mm0 = cur(3-0) <-> 16bit  
   
                 movq mm3,mm2            ; mm3 = avg  
                 punpckhbw mm1, mm7      ; mm1 = cur(7-4) <-> 16bit  
   
                 punpcklbw mm2, mm7      ; mm2 = avg(3-0) <-> 16bit  
                 punpckhbw mm3, mm7      ; mm3 = avg(7-4) <-> 16bit  
   
                 psubw mm0, mm2          ; mm0 = cur(3-0) - avg(3-0)  
                 psubw mm1, mm3          ; mm1 = cur(7-4) - avg(7-4)  
   
                 movq [edi + 0], mm0 ; dct(3-0) = mm0  
                 movq [edi + 8], mm1 ; dct(7-4) = mm1  
   
                 ; Increment all pointers  
                 add edi, eax    ; edi = &(next dct row)  
   
                 ; Row processing  
                 ; One row at a time  
                 movq mm0, [esi + 40] ; mm0 = cur row  
                 movq mm2, [ebx + 40]    ; mm2 = ref1 row  
                 movq mm3, [edx + 40]    ; mm3 = ref2 row  
                 movq mm1, mm0   ; mm1 = cur row  
   
                 pavgb mm2, mm3          ; mm2 = (ref1 + ref2 + 1)/2 (== avg)  
                 punpcklbw mm0, mm7      ; mm0 = cur(3-0) <-> 16bit  
   
                 movq mm3,mm2            ; mm3 = avg  
                 punpckhbw mm1, mm7      ; mm1 = cur(7-4) <-> 16bit  
   
                 punpcklbw mm2, mm7      ; mm2 = avg(3-0) <-> 16bit  
                 punpckhbw mm3, mm7      ; mm3 = avg(7-4) <-> 16bit  
   
                 psubw mm0, mm2          ; mm0 = cur(3-0) - avg(3-0)  
                 psubw mm1, mm3          ; mm1 = cur(7-4) - avg(7-4)  
   
                 movq [edi + 0], mm0 ; dct(3-0) = mm0  
                 movq [edi + 8], mm1 ; dct(7-4) = mm1  
   
                 ; Increment all pointers  
                 add edi, eax    ; edi = &(next dct row)  
   
                 ; Row processing  
                 ; One row at a time  
                 movq mm0, [esi + 48] ; mm0 = cur row  
                 movq mm2, [ebx + 48]    ; mm2 = ref1 row  
                 movq mm3, [edx + 48]    ; mm3 = ref2 row  
                 movq mm1, mm0   ; mm1 = cur row  
   
                 pavgb mm2, mm3          ; mm2 = (ref1 + ref2 + 1)/2 (== avg)  
                 punpcklbw mm0, mm7      ; mm0 = cur(3-0) <-> 16bit  
   
                 movq mm3,mm2            ; mm3 = avg  
                 punpckhbw mm1, mm7      ; mm1 = cur(7-4) <-> 16bit  
   
                 punpcklbw mm2, mm7      ; mm2 = avg(3-0) <-> 16bit  
                 punpckhbw mm3, mm7      ; mm3 = avg(7-4) <-> 16bit  
   
                 psubw mm0, mm2          ; mm0 = cur(3-0) - avg(3-0)  
                 psubw mm1, mm3          ; mm1 = cur(7-4) - avg(7-4)  
   
                 movq [edi + 0], mm0 ; dct(3-0) = mm0  
                 movq [edi + 8], mm1 ; dct(7-4) = mm1  
   
                 ; Increment all pointers  
                 add edi, eax    ; edi = &(next dct row)  
   
                 ; Row processing  
                 ; One row at a time  
                 movq mm0, [esi + 56] ; mm0 = cur row  
                 movq mm2, [ebx + 56]    ; mm2 = ref1 row  
                 movq mm3, [edx + 56]    ; mm3 = ref2 row  
                 movq mm1, mm0   ; mm1 = cur row  
   
                 pavgb mm2, mm3          ; mm2 = (ref1 + ref2 + 1)/2 (== avg)  
                 punpcklbw mm0, mm7      ; mm0 = cur(3-0) <-> 16bit  
   
                 movq mm3,mm2            ; mm3 = avg  
                 punpckhbw mm1, mm7      ; mm1 = cur(7-4) <-> 16bit  
419    
420                  punpcklbw mm2, mm7      ; mm2 = avg(3-0) <-> 16bit    punpcklbw mm0, mm7
421                  punpckhbw mm3, mm7      ; mm3 = avg(7-4) <-> 16bit    punpcklbw mm2, mm7
422      movq mm4, [ebx]     ; ref1
423      pavgb mm4, [esi]     ; ref2
424      punpckhbw mm1, mm7
425      punpckhbw mm3, mm7
426      movq mm5, [ebx+edx] ; ref
427      pavgb mm5, [esi+edx] ; ref2
428    
429                  psubw mm0, mm2          ; mm0 = cur(3-0) - avg(3-0)    movq mm6, mm4
430                  psubw mm1, mm3          ; mm1 = cur(7-4) - avg(7-4)    punpcklbw mm4, mm7
431      punpckhbw mm6, mm7
432      psubsw mm0, mm4
433      psubsw mm1, mm6
434      lea esi, [esi+2*edx]
435      movq mm6, mm5
436      punpcklbw mm5, mm7
437      punpckhbw mm6, mm7
438      psubsw mm2, mm5
439      lea eax, [eax+2*edx]
440      psubsw mm3, mm6
441      lea ebx, [ebx+2*edx]
442    
443      movq [ecx+%1*32+ 0], mm0 ; dst
444      movq [ecx+%1*32+ 8], mm1
445      movq [ecx+%1*32+16], mm2
446      movq [ecx+%1*32+24], mm3
447    %endmacro
448    
449                  movq [edi + 0], mm0 ; dct(3-0) = mm0  ALIGN 16
450                  movq [edi + 8], mm1 ; dct(7-4) = mm1  transfer_8to16sub2ro_xmm:
451      pxor mm7, mm7
452      mov ecx, [esp  + 4] ; Dst
453      mov eax, [esp  + 8] ; Cur
454      push ebx
455      mov ebx, [esp+4+12] ; Ref1
456      push esi
457      mov esi, [esp+8+16] ; Ref2
458      mov edx, [esp+8+20] ; Stride
459    
460                  ; Exit    COPY_8_TO_16_SUB2RO_SSE 0
461      COPY_8_TO_16_SUB2RO_SSE 1
462      COPY_8_TO_16_SUB2RO_SSE 2
463      COPY_8_TO_16_SUB2RO_SSE 3
464    
                 pop ebx  
465                  pop esi                  pop esi
466                  pop edi    pop ebx
   
467                  ret                  ret
468    .endfunc
469    
470    
471  ;===========================================================================  ;-----------------------------------------------------------------------------
472  ;  ;
473  ; void transfer_16to8add_mmx(uint8_t * const dst,  ; void transfer_16to8add_mmx(uint8_t * const dst,
474  ;                                               const int16_t * const src,  ;                                               const int16_t * const src,
475  ;                                               uint32_t stride);  ;                                               uint32_t stride);
476  ;  ;
477  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 cglobal transfer_16to8add_mmx  
 transfer_16to8add_mmx  
478    
479                  push    esi  %macro COPY_16_TO_8_ADD 1
480                  push    edi    movq mm0, [ecx]
481      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]  
482                  movq mm1, mm0                  movq mm1, mm0
483                  punpcklbw mm0, mm7              ; mm23 = unpack([dst])    movq mm3, mm2
484      punpcklbw mm0, mm7
485      punpcklbw mm2, mm7
486                  punpckhbw mm1, mm7                  punpckhbw mm1, mm7
487      punpckhbw mm3, mm7
488      paddsw mm0, [eax+%1*32+ 0]
489      paddsw mm1, [eax+%1*32+ 8]
490      paddsw mm2, [eax+%1*32+16]
491      paddsw mm3, [eax+%1*32+24]
492      packuswb mm0, mm1
493      movq [ecx], mm0
494      packuswb mm2, mm3
495      movq [ecx+edx], mm2
496    %endmacro
497    
                 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  
498    
499                  pop edi  ALIGN 16
500                  pop esi  transfer_16to8add_mmx:
501      mov ecx, [esp+ 4] ; Dst
502      mov eax, [esp+ 8] ; Src
503      mov edx, [esp+12] ; Stride
504      pxor mm7, mm7
505    
506      COPY_16_TO_8_ADD 0
507      lea ecx,[ecx+2*edx]
508      COPY_16_TO_8_ADD 1
509      lea ecx,[ecx+2*edx]
510      COPY_16_TO_8_ADD 2
511      lea ecx,[ecx+2*edx]
512      COPY_16_TO_8_ADD 3
513                  ret                  ret
514    .endfunc
515    
516    ;-----------------------------------------------------------------------------
 ;===========================================================================  
517  ;  ;
518  ; void transfer8x8_copy_mmx(uint8_t * const dst,  ; void transfer8x8_copy_mmx(uint8_t * const dst,
519  ;                                       const uint8_t * const src,  ;                                       const uint8_t * const src,
520  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
521  ;  ;
522  ;  ;
523  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 align 16  
 cglobal transfer8x8_copy_mmx  
 transfer8x8_copy_mmx  
                 push    esi  
                 push    edi  
524    
525                  mov     edi, [esp + 8 + 4]              ; dst [out]  %macro COPY_8_TO_8 0
526                  mov     esi, [esp + 8 + 8]              ; src [in]    movq mm0, [eax]
527                  mov eax, [esp + 8 + 12]         ; stride [in]    movq mm1, [eax+edx]
528      movq [ecx], mm0
529                  movq mm0, [esi]    lea eax, [eax+2*edx]
530                  movq mm1, [esi+eax]    movq [ecx+edx], mm1
531                  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  
532    
533    ALIGN 16
534    transfer8x8_copy_mmx:
535      mov ecx, [esp+ 4] ; Dst
536      mov eax, [esp+ 8] ; Src
537      mov edx, [esp+12] ; Stride
538    
539      COPY_8_TO_8
540      lea ecx,[ecx+2*edx]
541      COPY_8_TO_8
542      lea ecx,[ecx+2*edx]
543      COPY_8_TO_8
544      lea ecx,[ecx+2*edx]
545      COPY_8_TO_8
546                  ret                  ret
547    .endfunc
548    

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

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