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

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

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