[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 1790, Tue Aug 19 09:06:48 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                    %else
34                  global _%1                  global _%1
35                  %define %1 _%1                  %define %1 _%1
36                    %endif
37            %else
38                    %ifdef MARK_FUNCS
39                            global %1:function %1.endfunc-%1
40          %else          %else
41                  global %1                  global %1
42          %endif          %endif
43            %endif
44  %endmacro  %endmacro
45    
46  section .data  ;=============================================================================
47    ; Read Only data
48    ;=============================================================================
49    
50    %ifdef FORMAT_COFF
51    SECTION .rodata
52    %else
53    SECTION .rodata align=16
54    %endif
55    
56  align 16  ALIGN 16
57    mmx_one:
 mmx_one  
58  times 8 db 1  times 8 db 1
59    
60  section .text  ;=============================================================================
61    ; Code
62    ;=============================================================================
63    
64    SECTION .text
65    
66  cglobal interpolate8x8_halfpel_h_3dn  cglobal interpolate8x8_halfpel_h_3dn
67  cglobal interpolate8x8_halfpel_v_3dn  cglobal interpolate8x8_halfpel_v_3dn
68  cglobal interpolate8x8_halfpel_hv_3dn  cglobal interpolate8x8_halfpel_hv_3dn
69    
70    cglobal interpolate8x4_halfpel_h_3dn
71    cglobal interpolate8x4_halfpel_v_3dn
72    cglobal interpolate8x4_halfpel_hv_3dn
73    
74  ;===========================================================================  ;-----------------------------------------------------------------------------
75  ;  ;
76  ; void interpolate8x8_halfpel_h_3dn(uint8_t * const dst,  ; void interpolate8x8_halfpel_h_3dn(uint8_t * const dst,
77  ;                                               const uint8_t * const src,  ;                                               const uint8_t * const src,
78  ;                                               const uint32_t stride,  ;                                               const uint32_t stride,
79  ;                                               const uint32_t rounding);  ;                                               const uint32_t rounding);
80  ;  ;
81  ;===========================================================================  ;-----------------------------------------------------------------------------
82    
83  %macro COPY_H_3DN_RND0 0  %macro COPY_H_3DN_RND0 0
84    movq mm0,  [eax]    movq mm0,  [eax]
# Line 95  Line 110 
110    movq [ecx+edx], mm1    movq [ecx+edx], mm1
111  %endmacro  %endmacro
112    
113  align 16  ALIGN 16
114  interpolate8x8_halfpel_h_3dn:  interpolate8x8_halfpel_h_3dn:
115    
116    mov eax, [esp+16] ; rounding    mov eax, [esp+16] ; rounding
# Line 126  Line 141 
141    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
142    COPY_H_3DN_RND1    COPY_H_3DN_RND1
143    ret    ret
144    .endfunc
145    
146    
147  ;===========================================================================  ;-----------------------------------------------------------------------------
148  ;  ;
149  ; void interpolate8x8_halfpel_v_3dn(uint8_t * const dst,  ; void interpolate8x8_halfpel_v_3dn(uint8_t * const dst,
150  ;                                               const uint8_t * const src,  ;                                               const uint8_t * const src,
151  ;                                               const uint32_t stride,  ;                                               const uint32_t stride,
152  ;                                               const uint32_t rounding);  ;                                               const uint32_t rounding);
153  ;  ;
154  ;===========================================================================  ;-----------------------------------------------------------------------------
155    
156  %macro COPY_V_3DN_RND0 0  %macro COPY_V_3DN_RND0 0
157    movq mm0,  [eax]    movq mm0,  [eax]
# Line 166  Line 182 
182    movq [ecx+edx], mm1    movq [ecx+edx], mm1
183  %endmacro  %endmacro
184    
185  align 16  ALIGN 16
186  interpolate8x8_halfpel_v_3dn:  interpolate8x8_halfpel_v_3dn:
187    
188    mov eax, [esp+16] ; rounding    mov eax, [esp+16] ; rounding
# Line 202  Line 218 
218    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
219    COPY_V_3DN_RND1    COPY_V_3DN_RND1
220    ret    ret
221    .endfunc
222    
223    
224  ;===========================================================================  ;-----------------------------------------------------------------------------
225  ;  ;
226  ; void interpolate8x8_halfpel_hv_3dn(uint8_t * const dst,  ; void interpolate8x8_halfpel_hv_3dn(uint8_t * const dst,
227  ;                                               const uint8_t * const src,  ;                                               const uint8_t * const src,
# Line 212  Line 229 
229  ;                                               const uint32_t rounding);  ;                                               const uint32_t rounding);
230  ;  ;
231  ;  ;
232  ;===========================================================================  ;-----------------------------------------------------------------------------
233    
234  ; 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
235  ; 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 321 
321      movq [ecx], mm0      movq [ecx], mm0
322  %endmacro  %endmacro
323    
324  align 16  ALIGN 16
325  interpolate8x8_halfpel_hv_3dn  interpolate8x8_halfpel_hv_3dn
326    mov eax, [esp+16] ; rounding    mov eax, [esp+16] ; rounding
327    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
# Line 341  Line 358 
358    add ecx, edx    add ecx, edx
359    COPY_HV_3DN_RND1    COPY_HV_3DN_RND1
360    ret    ret
361    .endfunc
362    
363    ;-----------------------------------------------------------------------------
364    ;
365    ; void interpolate8x4_halfpel_h_3dn(uint8_t * const dst,
366    ;                       const uint8_t * const src,
367    ;                       const uint32_t stride,
368    ;                       const uint32_t rounding);
369    ;
370    ;-----------------------------------------------------------------------------
371    
372    ALIGN 16
373    interpolate8x4_halfpel_h_3dn:
374    
375      mov eax, [esp+16] ; rounding
376      mov ecx, [esp+ 4] ; Dst
377      test eax, eax
378      mov eax, [esp+ 8] ; Src
379      mov edx, [esp+12] ; stride
380    
381      jnz near .rounding1
382    
383      COPY_H_3DN_RND0
384      lea ecx, [ecx+2*edx]
385      COPY_H_3DN_RND0
386      ret
387    
388    .rounding1
389      ; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1
390      movq mm7, [mmx_one]
391      COPY_H_3DN_RND1
392      lea ecx, [ecx+2*edx]
393      COPY_H_3DN_RND1
394      ret
395    .endfunc
396    
397    
398    ;-----------------------------------------------------------------------------
399    ;
400    ; void interpolate8x4_halfpel_v_3dn(uint8_t * const dst,
401    ;                       const uint8_t * const src,
402    ;                       const uint32_t stride,
403    ;                       const uint32_t rounding);
404    ;
405    ;-----------------------------------------------------------------------------
406    
407    ALIGN 16
408    interpolate8x4_halfpel_v_3dn:
409    
410      mov eax, [esp+16] ; rounding
411      mov ecx, [esp+ 4] ; Dst
412      test eax,eax
413      mov eax, [esp+ 8] ; Src
414      mov edx, [esp+12] ; stride
415    
416        ; we process 2 line at a time
417    
418      jnz near .rounding1
419    
420      COPY_V_3DN_RND0
421      lea ecx, [ecx+2*edx]
422      COPY_V_3DN_RND0
423      ret
424    
425    .rounding1
426     ; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1
427      movq mm7, [mmx_one]
428      movq mm2, [eax]       ; loop invariant
429      add eax, edx
430    
431      COPY_V_3DN_RND1
432      lea ecx, [ecx+2*edx]
433      COPY_V_3DN_RND1
434      ret
435    .endfunc
436    
437    
438    ;-----------------------------------------------------------------------------
439    ;
440    ; void interpolate8x4_halfpel_hv_3dn(uint8_t * const dst,
441    ;                       const uint8_t * const src,
442    ;                       const uint32_t stride,
443    ;                       const uint32_t rounding);
444    ;
445    ;
446    ;-----------------------------------------------------------------------------
447    
448    ; The trick is to correct the result of 'pavgusb' with some combination of the
449    ; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgusb' (s and t).
450    ; The boolean relations are:
451    ;   (i+j+k+l+3)/4 = (s+t+1)/2 - (ij&kl)&st
452    ;   (i+j+k+l+2)/4 = (s+t+1)/2 - (ij|kl)&st
453    ;   (i+j+k+l+1)/4 = (s+t+1)/2 - (ij&kl)|st
454    ;   (i+j+k+l+0)/4 = (s+t+1)/2 - (ij|kl)|st
455    ; with  s=(i+j+1)/2, t=(k+l+1)/2, ij = i^j, kl = k^l, st = s^t.
456    
457    ALIGN 16
458    interpolate8x4_halfpel_hv_3dn
459      mov eax, [esp+16] ; rounding
460      mov ecx, [esp+ 4] ; Dst
461      test eax, eax
462      mov eax, [esp+ 8] ; Src
463      mov edx, [esp+12] ; stride
464    
465      movq mm7, [mmx_one]
466    
467        ; loop invariants: mm2=(i+j+1)/2  and  mm3= i^j
468      movq mm2, [eax]
469      movq mm3, [eax+1]
470      movq mm6, mm2
471      pavgusb mm2, mm3
472      pxor mm3, mm6     ; mm2/mm3 ready
473    
474      jnz near .rounding1
475    
476      COPY_HV_3DN_RND0
477      add ecx, edx
478      COPY_HV_3DN_RND0
479      ret
480    
481    .rounding1
482      COPY_HV_3DN_RND1
483      add ecx, edx
484      COPY_HV_3DN_RND1
485      ret
486    .endfunc
487    
488    
489    %ifidn __OUTPUT_FORMAT__,elf
490    section ".note.GNU-stack" noalloc noexec nowrite progbits
491    %endif
492    

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

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