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

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

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

revision 1.4, Wed Apr 24 12:21:43 2002 UTC revision 1.8.2.1, Tue Oct 28 22:23:03 2003 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) 2001-2003 Peter Ross <pross@xvid.org>
7  ; *     Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  ; *                2002-2003 Pascal Massimino <skal@planet-d.net>
 ; *     to use this software module in hardware or software products are  
 ; *     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.  
8  ; *  ; *
9  ; *     This program is free software; you can redistribute it and/or modify  ; *     This program is free software; you can redistribute it and/or modify
10  ; *     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 18 
18  ; *  ; *
19  ; *     You should have received a copy of the GNU General Public License  ; *     You should have received a copy of the GNU General Public License
20  ; *     along with this program; if not, write to the Free Software  ; *     along with this program; if not, write to the Free Software
21  ; *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22  ; *  ; *
23  ; *************************************************************************/  ; * $Id$
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
24  ; *  ; *
25  ; * 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>  
 ; *  
 ; *************************************************************************/  
   
26    
27  bits 32  BITS 32
28    
29  section .data  ;=============================================================================
30    ; Macros
31    ;=============================================================================
32    
33  %macro cglobal 1  %macro cglobal 1
34  %ifdef PREFIX  %ifdef PREFIX
# Line 54  Line 39 
39  %endif  %endif
40  %endmacro  %endmacro
41    
42  align 16  ;=============================================================================
43    ; Local data
44    ;=============================================================================
45    
46  ignore_dc       dw              0, -1, -1, -1, -1, -1, -1, -1  SECTION .rodata
47    
48    ALIGN 16
49    
50  section .text  ignore_dc:
51            dw 0, -1, -1, -1, -1, -1, -1, -1
52    
53    ;=============================================================================
54    ; Code
55    ;=============================================================================
56    
57  ;===========================================================================  SECTION .text
 ;  
 ; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]);  
 ;  
 ;===========================================================================  
58    
 align 16  
59  cglobal calc_cbp_mmx  cglobal calc_cbp_mmx
60  calc_cbp_mmx  
61    ;-----------------------------------------------------------------------------
62    ; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]);
63    ;-----------------------------------------------------------------------------
64    
65    ALIGN 16
66    calc_cbp_mmx:
67                                  push    ebx                                  push    ebx
                                 push    ecx  
                                 push    edx  
68                                  push    esi                                  push    esi
69    
70                  mov     esi, [esp + 16 + 4]              ; coeff    mov esi, [esp + 8 + 4]        ; coeff
71      xor eax, eax                  ; cbp = 0
72      mov edx, (1 << 5)
73    
74                                  movq    mm7, [ignore_dc]                                  movq    mm7, [ignore_dc]
75    
                                 xor             eax, eax                ; cbp = 0  
                                 mov             edx, 6  
76  .loop  .loop
77                  movq    mm0, [esi]                  movq    mm0, [esi]
                                 pand    mm0, mm7  
78                  movq    mm1, [esi+8]                  movq    mm1, [esi+8]
79      pand mm0, mm7
80    
81                  por     mm0, [esi+16]                  por     mm0, [esi+16]
82                  por     mm1, [esi+24]                  por     mm1, [esi+24]
# Line 110  Line 102 
102                  por     mm0, mm1                  por     mm0, mm1
103                  movq    mm1, mm0                  movq    mm1, mm0
104                  psrlq   mm1, 32                  psrlq   mm1, 32
105      lea esi, [esi + 128]
106    
107                  por     mm0, mm1                  por     mm0, mm1
108                                  movd    ebx, mm0                                  movd    ebx, mm0
109    
110                                  add             esi, 128    test ebx, ebx
111      jz .next
112                                  or              ebx, ebx    or eax, edx     ; cbp |= 1 << (5-i)
113                                  jz              .iterate  
114    .next
115                                  ; cbp |= 1 << (edx-1)    shr edx,1
116      jnc .loop
                                 ; 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  
117    
118                                  pop     esi                                  pop     esi
                                 pop     edx  
                                 pop     ecx  
119                                  pop     ebx                                  pop     ebx
120    
121                                  ret                                  ret
   
   
   
 ;===========================================================================  
 ;  
 ; 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.1.4  
changed lines
  Added in v.1.8.2.1

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