[cvs] / xvidcore / src / utils / x86_asm / mem_transfer_mmx.asm Repository:
ViewVC logotype

Diff of /xvidcore/src/utils/x86_asm/mem_transfer_mmx.asm

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

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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.19

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