[svn] / trunk / xvidcore / src / bitstream / x86_asm / cbp_mmx.asm Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/bitstream/x86_asm/cbp_mmx.asm

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

revision 126, Wed Apr 17 10:54:19 2002 UTC revision 1642, Sat Sep 24 03:10:37 2005 UTC
# Line 1  Line 1 
1  ;/**************************************************************************  ;/****************************************************************************
2  ; *  ; *
3  ; *     XVID MPEG-4 VIDEO CODEC  ; *     XVID MPEG-4 VIDEO CODEC
4  ; *     mmx cbp calc  ; *  - MMX CBP computation -
5  ; *  ; *
6  ; *     This program is an implementation of a part of one or more MPEG-4  ; *  Copyright (C) 2005      Carlo Bramini <carlo.bramix@libero.it>
7  ; *     Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  ; *                2001-2003 Peter Ross <pross@xvid.org>
8  ; *     to use this software module in hardware or software products are  ; *                2002-2003 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: cbp_mmx.asm,v 1.14 2005-09-24 03:10:37 suxen_drol Exp $
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
 ; *  
 ; * 17.04.2002  sse2 stuff  
 ; * 22.03.2002      0.01          ; Min Chen <chenm001@163.com>  
 ; *                               ; use 386 cpu's 'BTS' to replace 'cbp |= 1 << (edx-1)'  
 ; *     24.11.2001      inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
25  ; *  ; *
26  ; *************************************************************************/  ; ***************************************************************************/
27    
28    BITS 32
29    
30  bits 32  ;=============================================================================
31    ; Macros
32  section .data  ;=============================================================================
33    
34  %macro cglobal 1  %macro cglobal 1
35  %ifdef PREFIX  %ifdef PREFIX
36                    %ifdef MARK_FUNCS
37                            global _%1:function %1.endfunc-%1
38                            %define %1 _%1:function %1.endfunc-%1
39                    %else
40  global _%1  global _%1
41  %define %1 _%1  %define %1 _%1
42                    %endif
43            %else
44                    %ifdef MARK_FUNCS
45                            global %1:function %1.endfunc-%1
46  %else  %else
47  global %1  global %1
48  %endif  %endif
49            %endif
50  %endmacro  %endmacro
51    
52  align 16  ;=============================================================================
53    ; Local data
54  ignore_dc       dw              0, -1, -1, -1, -1, -1, -1, -1  ;=============================================================================
55    
56    %ifdef FORMAT_COFF
57    SECTION .rodata
58    %else
59    SECTION .rodata align=16
60    %endif
61    
62  section .text  ALIGN 16
63    
64    mult_mask:
65      db 0x10,0x20,0x04,0x08,0x01,0x02,0x00,0x00
66    ignore_dc:
67      dw 0, -1, -1, -1
68    
69    ;=============================================================================
70    ; Code
71    ;=============================================================================
72    
73  ;===========================================================================  SECTION .text
 ;  
 ; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]);  
 ;  
 ;===========================================================================  
74    
 align 16  
75  cglobal calc_cbp_mmx  cglobal calc_cbp_mmx
 calc_cbp_mmx  
                                 push    ebx  
                                 push    ecx  
                                 push    edx  
                                 push    esi  
   
                 mov     esi, [esp + 16 + 4]              ; coeff  
                                 movq    mm7, [ignore_dc]  
   
                                 xor             eax, eax                ; cbp = 0  
                                 mov             edx, 6  
 .loop  
                 movq    mm0, [esi]  
                                 pand    mm0, mm7  
                 movq    mm1, [esi+8]  
   
                 por     mm0, [esi+16]  
                 por     mm1, [esi+24]  
76    
77                  por     mm0, [esi+32]  ;-----------------------------------------------------------------------------
78                  por     mm1, [esi+40]  ; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]);
79    ;-----------------------------------------------------------------------------
                 por     mm0, [esi+48]  
                 por     mm1, [esi+56]  
   
                 por     mm0, [esi+64]  
                 por     mm1, [esi+72]  
80    
81                  por     mm0, [esi+80]  %macro      MAKE_LOAD         1
82                  por     mm1, [esi+88]    por mm0, [eax-128*1+%1*8]
83      por mm1, [eax+128*0+%1*8]
84      por mm2, [eax+128*1+%1*8]
85      por mm3, [eax+128*2+%1*8]
86      por mm4, [eax+128*3+%1*8]
87      por mm5, [eax+128*4+%1*8]
88    %endmacro
89    
90                  por     mm0, [esi+96]  ALIGN 16
91                  por     mm1, [esi+104]  calc_cbp_mmx:
92      mov eax, [esp + 4]            ; coeff
93    
94                  por     mm0, [esi+112]    movq mm7, [ignore_dc]
95                  por     mm1, [esi+120]    pxor mm6, mm6                ; used only for comparing
96      movq mm0, [eax+128*0]
97      movq mm1, [eax+128*1]
98      movq mm2, [eax+128*2]
99      movq mm3, [eax+128*3]
100      movq mm4, [eax+128*4]
101      movq mm5, [eax+128*5]
102      add eax, 8+128
103      pand mm0, mm7
104      pand mm1, mm7
105      pand mm2, mm7
106      pand mm3, mm7
107      pand mm4, mm7
108      pand mm5, mm7
109    
110      MAKE_LOAD 0
111      MAKE_LOAD 1
112      MAKE_LOAD 2
113      MAKE_LOAD 3
114      MAKE_LOAD 4
115      MAKE_LOAD 5
116      MAKE_LOAD 6
117      MAKE_LOAD 7
118      MAKE_LOAD 8
119      MAKE_LOAD 9
120      MAKE_LOAD 10
121      MAKE_LOAD 11
122      MAKE_LOAD 12
123      MAKE_LOAD 13
124      MAKE_LOAD 14
125    
126      movq mm7, [mult_mask]
127      packssdw mm0, mm1
128      packssdw mm2, mm3
129      packssdw mm4, mm5
130      packssdw mm0, mm2
131      packssdw mm4, mm6
132      pcmpeqw mm0, mm6
133      pcmpeqw mm4, mm6
134      pcmpeqw mm0, mm6
135      pcmpeqw mm4, mm6
136      psrlw mm0, 15
137      psrlw mm4, 15
138      packuswb mm0, mm4
139      pmaddwd mm0, mm7
140    
                 por     mm0, mm1  
141                  movq    mm1, mm0                  movq    mm1, mm0
142                  psrlq   mm1, 32                  psrlq   mm1, 32
143                  por     mm0, mm1    paddusb mm0, mm1
                                 movd    ebx, mm0  
   
                                 add             esi, 128  
   
                                 or              ebx, ebx  
                                 jz              .iterate  
   
                                 ; cbp |= 1 << (edx-1)  
   
                                 ; Change by Chenm001 <chenm001@163.com>  
                                 ;mov             ecx, edx  
                                 ;dec             ecx  
                                 ;mov             ebx, 1  
                                 ;shl             ebx, cl  
                                 ;or              eax, ebx  
                                 lea             ebx,[edx-1]  
                                 bts             eax,ebx  
   
 .iterate                dec     edx  
                                 jnz             .loop  
   
                                 pop     esi  
                                 pop     edx  
                                 pop     ecx  
                                 pop     ebx  
144    
145      movd eax, mm0
146      shr eax, 8
147      and eax, 0x3F
148                                  ret                                  ret
149    .endfunc
150    
   
   
 ;===========================================================================  
 ;  
 ; uint32_t calc_cbp_sse2(const int16_t coeff[6][64]);  
 ;  
 ; not enabled - slower than mmx?  
 ;  
 ;===========================================================================  
   
 align 16  
 cglobal calc_cbp_sse2  
 calc_cbp_sse2  
                                 push    esi  
   
                                 mov     esi, [esp + 4 + 4]              ; coeff  
                                 movdqa  xmm7, [ignore_dc]               ; mask to ignore dc value  
   
                                 xor             eax, eax                                ; cbp = 0  
                                 pxor    xmm6, xmm6                              ; zeroes to help psadbw  
   
 .first                  movdqa  xmm0, [esi]  
                                 pand    xmm0, xmm7  
                                 movdqa  xmm1, [esi+16]  
   
                                 por             xmm0, [esi+32]  
                                 por             xmm1, [esi+48]  
                                 por             xmm0, [esi+64]  
                                 por             xmm1, [esi+80]  
                                 por             xmm0, [esi+96]  
                                 por             xmm1, [esi+112]  
   
                                 por             xmm0, xmm1                              ; xmm0 = xmm1 = 128 bits worth of info  
                                 psadbw  xmm0, xmm6                              ; contains 2 dwords with sums  
                                 movhlps xmm1, xmm0                              ; move high dword from xmm0 to low xmm1  
                                 por             xmm0, xmm1                              ; combine  
                                 movd    ecx, xmm0                               ; if ecx set, values were found  
   
                                 add             esi, 128  
   
                                 or              ecx, ecx  
                                 jz              .second  
   
                                 bts             eax, 5  
   
 .second                 movdqa  xmm0, [esi]  
                                 pand    xmm0, xmm7  
                                 movdqa  xmm1, [esi+16]  
   
                                 por             xmm0, [esi+32]  
                                 por             xmm1, [esi+48]  
                                 por             xmm0, [esi+64]  
                                 por             xmm1, [esi+80]  
                                 por             xmm0, [esi+96]  
                                 por             xmm1, [esi+112]  
   
                                 por             xmm0, xmm1  
                                 psadbw  xmm0, xmm6  
                                 movhlps xmm1, xmm0  
                                 por             xmm0, xmm1  
                                 movd    ecx, xmm0  
   
                                 add             esi, 128  
   
                                 or              ecx, ecx  
                                 jz              .third  
   
                                 bts             eax, 4  
   
 .third                  movdqa  xmm0, [esi]  
                                 pand    xmm0, xmm7  
                                 movdqa  xmm1, [esi+16]  
   
                                 por             xmm0, [esi+32]  
                                 por             xmm1, [esi+48]  
                                 por             xmm0, [esi+64]  
                                 por             xmm1, [esi+80]  
                                 por             xmm0, [esi+96]  
                                 por             xmm1, [esi+112]  
   
                                 por             xmm0, xmm1  
                                 psadbw  xmm0, xmm6  
                                 movhlps xmm1, xmm0  
                                 por             xmm0, xmm1  
                                 movd    ecx, xmm0  
   
                                 add             esi, 128  
   
                                 or              ecx, ecx  
                                 jz              .fourth  
   
                                 bts             eax, 3  
   
 .fourth                 movdqa  xmm0, [esi]  
                                 pand    xmm0, xmm7  
                                 movdqa  xmm1, [esi+16]  
   
                                 por             xmm0, [esi+32]  
                                 por             xmm1, [esi+48]  
                                 por             xmm0, [esi+64]  
                                 por             xmm1, [esi+80]  
                                 por             xmm0, [esi+96]  
                                 por             xmm1, [esi+112]  
   
                                 por             xmm0, xmm1  
                                 psadbw  xmm0, xmm6  
                                 movhlps xmm1, xmm0  
                                 por             xmm0, xmm1  
                                 movd    ecx, xmm0  
   
                                 add             esi, 128  
   
                                 or              ecx, ecx  
                                 jz              .fifth  
   
                                 bts             eax, 2  
   
 .fifth                  movdqa  xmm0, [esi]  
                                 pand    xmm0, xmm7  
                                 movdqa  xmm1, [esi+16]  
   
                                 por             xmm0, [esi+32]  
                                 por             xmm1, [esi+48]  
                                 por             xmm0, [esi+64]  
                                 por             xmm1, [esi+80]  
                                 por             xmm0, [esi+96]  
                                 por             xmm1, [esi+112]  
   
                                 por             xmm0, xmm1  
                                 psadbw  xmm0, xmm6  
                                 movhlps xmm1, xmm0  
                                 por             xmm0, xmm1  
                                 movd    ecx, xmm0  
   
                                 add             esi, 128  
   
                                 or              ecx, ecx  
                                 jz              .sixth  
   
                                 bts             eax, 1  
   
 .sixth                  movdqa  xmm0, [esi]  
                                 pand    xmm0, xmm7  
                                 movdqa  xmm1, [esi+16]  
   
                                 por             xmm0, [esi+32]  
                                 por             xmm1, [esi+48]  
                                 por             xmm0, [esi+64]  
                                 por             xmm1, [esi+80]  
                                 por             xmm0, [esi+96]  
                                 por             xmm1, [esi+112]  
   
                                 por             xmm0, xmm1  
                                 psadbw  xmm0, xmm6  
                                 movhlps xmm1, xmm0  
                                 por             xmm0, xmm1  
                                 movd    ecx, xmm0  
   
                                 or              ecx, ecx  
                                 jz              .end  
   
                                 bts             eax, 0  
   
 .end                    pop     esi  
   
                                 ret  

Legend:
Removed from v.126  
changed lines
  Added in v.1642

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