[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 135, Wed Apr 24 12:21:43 2002 UTC revision 1844, Thu Dec 4 14:41:50 2008 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.18 2008-12-04 14:41:50 Isibaar Exp $
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
25  ; *  ; *
26  ; * 24.04.2002  had to use sse2's movdqu instead of movdqa (???)  ; ***************************************************************************/
 ; * 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>  
 ; *  
 ; *************************************************************************/  
27    
28    ;=============================================================================
29    ; Macros
30    ;=============================================================================
31    
32  bits 32  %include "nasm.inc"
33    
34  section .data  ;=============================================================================
35    ; Local data
36    ;=============================================================================
37    
38  %macro cglobal 1  DATA
 %ifdef PREFIX  
 global _%1  
 %define %1 _%1  
 %else  
 global %1  
 %endif  
 %endmacro  
39    
40  align 16  ALIGN SECTION_ALIGN
41    
42  ignore_dc       dw              0, -1, -1, -1, -1, -1, -1, -1  mult_mask:
43      db 0x10,0x20,0x04,0x08,0x01,0x02,0x00,0x00
44    ignore_dc:
45      dw 0, -1, -1, -1
46    
47    ;=============================================================================
48    ; Code
49    ;=============================================================================
50    
51  section .text  TEXT
52    
53    cglobal calc_cbp_mmx
54    
55  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;  
56  ; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]);  ; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]);
57  ;  ;-----------------------------------------------------------------------------
 ;===========================================================================  
58    
59  align 16  %macro      MAKE_LOAD         2
60  cglobal calc_cbp_mmx    por mm0, [%2-128*1+%1*8]
61  calc_cbp_mmx    por mm1, [%2+128*0+%1*8]
62                                  push    ebx    por mm2, [%2+128*1+%1*8]
63                                  push    ecx    por mm3, [%2+128*2+%1*8]
64                                  push    edx    por mm4, [%2+128*3+%1*8]
65                                  push    esi    por mm5, [%2+128*4+%1*8]
66    %endmacro
67    
68                  mov     esi, [esp + 16 + 4]              ; coeff  ALIGN SECTION_ALIGN
69                                  movq    mm7, [ignore_dc]  calc_cbp_mmx:
70      mov _EAX, prm1            ; coeff
71    
72                                  xor             eax, eax                ; cbp = 0    movq mm7, [ignore_dc]
73                                  mov             edx, 6    pxor mm6, mm6                ; used only for comparing
74  .loop    movq mm0, [_EAX+128*0]
75                  movq    mm0, [esi]    movq mm1, [_EAX+128*1]
76      movq mm2, [_EAX+128*2]
77      movq mm3, [_EAX+128*3]
78      movq mm4, [_EAX+128*4]
79      movq mm5, [_EAX+128*5]
80      add _EAX, 8+128
81                                  pand    mm0, mm7                                  pand    mm0, mm7
82                  movq    mm1, [esi+8]    pand mm1, mm7
83      pand mm2, mm7
84                  por     mm0, [esi+16]    pand mm3, mm7
85                  por     mm1, [esi+24]    pand mm4, mm7
86      pand mm5, mm7
87                  por     mm0, [esi+32]  
88                  por     mm1, [esi+40]    MAKE_LOAD 0, _EAX
89      MAKE_LOAD 1, _EAX
90                  por     mm0, [esi+48]    MAKE_LOAD 2, _EAX
91                  por     mm1, [esi+56]    MAKE_LOAD 3, _EAX
92      MAKE_LOAD 4, _EAX
93      MAKE_LOAD 5, _EAX
94      MAKE_LOAD 6, _EAX
95      MAKE_LOAD 7, _EAX
96      MAKE_LOAD 8, _EAX
97      MAKE_LOAD 9, _EAX
98      MAKE_LOAD 10, _EAX
99      MAKE_LOAD 11, _EAX
100      MAKE_LOAD 12, _EAX
101      MAKE_LOAD 13, _EAX
102      MAKE_LOAD 14, _EAX
103    
104      movq mm7, [mult_mask]
105      packssdw mm0, mm1
106      packssdw mm2, mm3
107      packssdw mm4, mm5
108      packssdw mm0, mm2
109      packssdw mm4, mm6
110      pcmpeqw mm0, mm6
111      pcmpeqw mm4, mm6
112      pcmpeqw mm0, mm6
113      pcmpeqw mm4, mm6
114      psrlw mm0, 15
115      psrlw mm4, 15
116      packuswb mm0, mm4
117      pmaddwd mm0, mm7
118    
                 por     mm0, [esi+64]  
                 por     mm1, [esi+72]  
   
                 por     mm0, [esi+80]  
                 por     mm1, [esi+88]  
   
                 por     mm0, [esi+96]  
                 por     mm1, [esi+104]  
   
                 por     mm0, [esi+112]  
                 por     mm1, [esi+120]  
   
                 por     mm0, mm1  
119                  movq    mm1, mm0                  movq    mm1, mm0
120                  psrlq   mm1, 32                  psrlq   mm1, 32
121                  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  
122    
123      movd eax, mm0
124      shr _EAX, 8
125      and _EAX, 0x3F
126                                  ret                                  ret
127    ENDFUNC
128    
129    
130    %ifidn __OUTPUT_FORMAT__,elf
131    section ".note.GNU-stack" noalloc noexec nowrite progbits
132    %endif
133    
 ;===========================================================================  
 ;  
 ; 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  
                                 movdqu  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.135  
changed lines
  Added in v.1844

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