[svn] / trunk / xvidcore / src / image / x86_asm / interpolate8x8_3dn.asm Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/image/x86_asm/interpolate8x8_3dn.asm

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

revision 262, Sun Jul 7 09:45:40 2002 UTC revision 1793, 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  ; *     3dnow 8x8 block-based halfpel interpolation  ; *  - 3dnow 8x8 block-based halfpel interpolation -
5    ; *
6    ; *  Copyright(C) 2001 Peter Ross <pross@xvid.org>
7    ; *               2002 Michael Militzer <isibaar@xvid.org>
8    ; *               2002 Pascal Massimino <skal@planet-d.net>
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 15  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
 ; *  
 ; *************************************************************************/  
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
23  ; *  ; *
24  ; * 06.07.2002  applied Skal's XMM changes to the 3dnow code (Isibaar)  ; ****************************************************************************/
 ; * 04.02.2002  additional 3dnow optimizations (Isibaar)  
 ; *     22.12.2001      inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
 ; *  
 ; *************************************************************************/  
   
25    
26  bits 32  BITS 32
27    
28  %macro cglobal 1  %macro cglobal 1
29          %ifdef PREFIX          %ifdef PREFIX
30                    %ifdef MARK_FUNCS
31                            global _%1:function %1.endfunc-%1
32                            %define %1 _%1:function %1.endfunc-%1
33                            %define ENDFUNC .endfunc
34                    %else
35                  global _%1                  global _%1
36                  %define %1 _%1                  %define %1 _%1
37                            %define ENDFUNC
38                    %endif
39            %else
40                    %ifdef MARK_FUNCS
41                            global %1:function %1.endfunc-%1
42                            %define ENDFUNC .endfunc
43          %else          %else
44                  global %1                  global %1
45                            %define ENDFUNC
46                    %endif
47          %endif          %endif
48  %endmacro  %endmacro
49    
50  section .data  ;=============================================================================
51    ; Read Only data
52    ;=============================================================================
53    
54    %ifdef FORMAT_COFF
55    SECTION .rodata
56    %else
57    SECTION .rodata align=16
58    %endif
59    
60  align 16  ALIGN 16
61    mmx_one:
 mmx_one  
62  times 8 db 1  times 8 db 1
63    
64  section .text  ;=============================================================================
65    ; Code
66    ;=============================================================================
67    
68    SECTION .text
69    
70  cglobal interpolate8x8_halfpel_h_3dn  cglobal interpolate8x8_halfpel_h_3dn
71  cglobal interpolate8x8_halfpel_v_3dn  cglobal interpolate8x8_halfpel_v_3dn
72  cglobal interpolate8x8_halfpel_hv_3dn  cglobal interpolate8x8_halfpel_hv_3dn
73    
74    cglobal interpolate8x4_halfpel_h_3dn
75    cglobal interpolate8x4_halfpel_v_3dn
76    cglobal interpolate8x4_halfpel_hv_3dn
77    
78  ;===========================================================================  ;-----------------------------------------------------------------------------
79  ;  ;
80  ; void interpolate8x8_halfpel_h_3dn(uint8_t * const dst,  ; void interpolate8x8_halfpel_h_3dn(uint8_t * const dst,
81  ;                                               const uint8_t * const src,  ;                                               const uint8_t * const src,
82  ;                                               const uint32_t stride,  ;                                               const uint32_t stride,
83  ;                                               const uint32_t rounding);  ;                                               const uint32_t rounding);
84  ;  ;
85  ;===========================================================================  ;-----------------------------------------------------------------------------
86    
87  %macro COPY_H_3DN_RND0 0  %macro COPY_H_3DN_RND0 0
88    movq mm0,  [eax]    movq mm0,  [eax]
# Line 95  Line 114 
114    movq [ecx+edx], mm1    movq [ecx+edx], mm1
115  %endmacro  %endmacro
116    
117  align 16  ALIGN 16
118  interpolate8x8_halfpel_h_3dn:  interpolate8x8_halfpel_h_3dn:
119    
120    mov eax, [esp+16] ; rounding    mov eax, [esp+16] ; rounding
# Line 115  Line 134 
134    COPY_H_3DN_RND0    COPY_H_3DN_RND0
135    ret    ret
136    
137  .rounding1  .rounding1:
138     ; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1     ; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1
139    movq mm7, [mmx_one]    movq mm7, [mmx_one]
140    COPY_H_3DN_RND1    COPY_H_3DN_RND1
# Line 126  Line 145 
145    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
146    COPY_H_3DN_RND1    COPY_H_3DN_RND1
147    ret    ret
148    ENDFUNC
149    
150    
151  ;===========================================================================  ;-----------------------------------------------------------------------------
152  ;  ;
153  ; void interpolate8x8_halfpel_v_3dn(uint8_t * const dst,  ; void interpolate8x8_halfpel_v_3dn(uint8_t * const dst,
154  ;                                               const uint8_t * const src,  ;                                               const uint8_t * const src,
155  ;                                               const uint32_t stride,  ;                                               const uint32_t stride,
156  ;                                               const uint32_t rounding);  ;                                               const uint32_t rounding);
157  ;  ;
158  ;===========================================================================  ;-----------------------------------------------------------------------------
159    
160  %macro COPY_V_3DN_RND0 0  %macro COPY_V_3DN_RND0 0
161    movq mm0,  [eax]    movq mm0,  [eax]
# Line 166  Line 186 
186    movq [ecx+edx], mm1    movq [ecx+edx], mm1
187  %endmacro  %endmacro
188    
189  align 16  ALIGN 16
190  interpolate8x8_halfpel_v_3dn:  interpolate8x8_halfpel_v_3dn:
191    
192    mov eax, [esp+16] ; rounding    mov eax, [esp+16] ; rounding
# Line 188  Line 208 
208    COPY_V_3DN_RND0    COPY_V_3DN_RND0
209    ret    ret
210    
211  .rounding1  .rounding1:
212     ; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1     ; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1
213    movq mm7, [mmx_one]    movq mm7, [mmx_one]
214    movq mm2, [eax]   ; loop invariant    movq mm2, [eax]   ; loop invariant
# Line 202  Line 222 
222    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
223    COPY_V_3DN_RND1    COPY_V_3DN_RND1
224    ret    ret
225    ENDFUNC
226    
227    
228  ;===========================================================================  ;-----------------------------------------------------------------------------
229  ;  ;
230  ; void interpolate8x8_halfpel_hv_3dn(uint8_t * const dst,  ; void interpolate8x8_halfpel_hv_3dn(uint8_t * const dst,
231  ;                                               const uint8_t * const src,  ;                                               const uint8_t * const src,
# Line 212  Line 233 
233  ;                                               const uint32_t rounding);  ;                                               const uint32_t rounding);
234  ;  ;
235  ;  ;
236  ;===========================================================================  ;-----------------------------------------------------------------------------
237    
238  ; The trick is to correct the result of 'pavgusb' with some combination of the  ; The trick is to correct the result of 'pavgusb' with some combination of the
239  ; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgusb' (s and t).  ; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgusb' (s and t).
# Line 304  Line 325 
325      movq [ecx], mm0      movq [ecx], mm0
326  %endmacro  %endmacro
327    
328  align 16  ALIGN 16
329  interpolate8x8_halfpel_hv_3dn  interpolate8x8_halfpel_hv_3dn:
330    mov eax, [esp+16] ; rounding    mov eax, [esp+16] ; rounding
331    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
332    test eax,eax    test eax,eax
# Line 332  Line 353 
353    COPY_HV_3DN_RND0    COPY_HV_3DN_RND0
354    ret    ret
355    
356  .rounding1  .rounding1:
357      COPY_HV_3DN_RND1
358      add ecx, edx
359    COPY_HV_3DN_RND1    COPY_HV_3DN_RND1
360    add ecx, edx    add ecx, edx
361    COPY_HV_3DN_RND1    COPY_HV_3DN_RND1
362    add ecx, edx    add ecx, edx
363    COPY_HV_3DN_RND1    COPY_HV_3DN_RND1
364      ret
365    ENDFUNC
366    
367    ;-----------------------------------------------------------------------------
368    ;
369    ; void interpolate8x4_halfpel_h_3dn(uint8_t * const dst,
370    ;                       const uint8_t * const src,
371    ;                       const uint32_t stride,
372    ;                       const uint32_t rounding);
373    ;
374    ;-----------------------------------------------------------------------------
375    
376    ALIGN 16
377    interpolate8x4_halfpel_h_3dn:
378    
379      mov eax, [esp+16] ; rounding
380      mov ecx, [esp+ 4] ; Dst
381      test eax, eax
382      mov eax, [esp+ 8] ; Src
383      mov edx, [esp+12] ; stride
384    
385      jnz near .rounding1
386    
387      COPY_H_3DN_RND0
388      lea ecx, [ecx+2*edx]
389      COPY_H_3DN_RND0
390      ret
391    
392    .rounding1:
393      ; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1
394      movq mm7, [mmx_one]
395      COPY_H_3DN_RND1
396      lea ecx, [ecx+2*edx]
397      COPY_H_3DN_RND1
398      ret
399    ENDFUNC
400    
401    
402    ;-----------------------------------------------------------------------------
403    ;
404    ; void interpolate8x4_halfpel_v_3dn(uint8_t * const dst,
405    ;                       const uint8_t * const src,
406    ;                       const uint32_t stride,
407    ;                       const uint32_t rounding);
408    ;
409    ;-----------------------------------------------------------------------------
410    
411    ALIGN 16
412    interpolate8x4_halfpel_v_3dn:
413    
414      mov eax, [esp+16] ; rounding
415      mov ecx, [esp+ 4] ; Dst
416      test eax,eax
417      mov eax, [esp+ 8] ; Src
418      mov edx, [esp+12] ; stride
419    
420        ; we process 2 line at a time
421    
422      jnz near .rounding1
423    
424      COPY_V_3DN_RND0
425      lea ecx, [ecx+2*edx]
426      COPY_V_3DN_RND0
427      ret
428    
429    .rounding1:
430     ; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1
431      movq mm7, [mmx_one]
432      movq mm2, [eax]       ; loop invariant
433      add eax, edx
434    
435      COPY_V_3DN_RND1
436      lea ecx, [ecx+2*edx]
437      COPY_V_3DN_RND1
438      ret
439    ENDFUNC
440    
441    
442    ;-----------------------------------------------------------------------------
443    ;
444    ; void interpolate8x4_halfpel_hv_3dn(uint8_t * const dst,
445    ;                       const uint8_t * const src,
446    ;                       const uint32_t stride,
447    ;                       const uint32_t rounding);
448    ;
449    ;
450    ;-----------------------------------------------------------------------------
451    
452    ; The trick is to correct the result of 'pavgusb' with some combination of the
453    ; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgusb' (s and t).
454    ; The boolean relations are:
455    ;   (i+j+k+l+3)/4 = (s+t+1)/2 - (ij&kl)&st
456    ;   (i+j+k+l+2)/4 = (s+t+1)/2 - (ij|kl)&st
457    ;   (i+j+k+l+1)/4 = (s+t+1)/2 - (ij&kl)|st
458    ;   (i+j+k+l+0)/4 = (s+t+1)/2 - (ij|kl)|st
459    ; with  s=(i+j+1)/2, t=(k+l+1)/2, ij = i^j, kl = k^l, st = s^t.
460    
461    ALIGN 16
462    interpolate8x4_halfpel_hv_3dn:
463      mov eax, [esp+16] ; rounding
464      mov ecx, [esp+ 4] ; Dst
465      test eax, eax
466      mov eax, [esp+ 8] ; Src
467      mov edx, [esp+12] ; stride
468    
469      movq mm7, [mmx_one]
470    
471        ; loop invariants: mm2=(i+j+1)/2  and  mm3= i^j
472      movq mm2, [eax]
473      movq mm3, [eax+1]
474      movq mm6, mm2
475      pavgusb mm2, mm3
476      pxor mm3, mm6     ; mm2/mm3 ready
477    
478      jnz near .rounding1
479    
480      COPY_HV_3DN_RND0
481      add ecx, edx
482      COPY_HV_3DN_RND0
483      ret
484    
485    .rounding1:
486      COPY_HV_3DN_RND1
487    add ecx, edx    add ecx, edx
488    COPY_HV_3DN_RND1    COPY_HV_3DN_RND1
489    ret    ret
490    ENDFUNC
491    
492    
493    %ifidn __OUTPUT_FORMAT__,elf
494    section ".note.GNU-stack" noalloc noexec nowrite progbits
495    %endif
496    

Legend:
Removed from v.262  
changed lines
  Added in v.1793

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