[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 655, Sun Nov 17 00:57:58 2002 UTC
# Line 3  Line 3 
3  ; *     XVID MPEG-4 VIDEO CODEC  ; *     XVID MPEG-4 VIDEO CODEC
4  ; *     mmx cbp calc  ; *     mmx cbp calc
5  ; *  ; *
6  ; *     This program is an implementation of a part of one or more MPEG-4  ; *  This file is part of XviD, a free MPEG-4 video encoder/decoder
 ; *     Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  
 ; *     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.  
7  ; *  ; *
8  ; *     This program is free software; you can redistribute it and/or modify  ; *  XviD is free software; you can redistribute it and/or modify it
9  ; *     it under the terms of the GNU General Public License as published by  ; *  under the terms of the GNU General Public License as published by
10  ; *     the Free Software Foundation; either version 2 of the License, or  ; *     the Free Software Foundation; either version 2 of the License, or
11  ; *     (at your option) any later version.  ; *     (at your option) any later version.
12  ; *  ; *
# Line 24  Line 17 
17  ; *  ; *
18  ; *     You should have received a copy of the GNU General Public License  ; *     You should have received a copy of the GNU General Public License
19  ; *     along with this program; if not, write to the Free Software  ; *     along with this program; if not, write to the Free Software
20  ; *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  ; *  ; *
22  ; *************************************************************************/  ; *  Under section 8 of the GNU General Public License, the copyright
23    ; *  holders of XVID explicitly forbid distribution in the following
24  ;/**************************************************************************  ; *  countries:
25    ; *
26    ; *    - Japan
27    ; *    - United States of America
28    ; *
29    ; *  Linking XviD statically or dynamically with other modules is making a
30    ; *  combined work based on XviD.  Thus, the terms and conditions of the
31    ; *  GNU General Public License cover the whole combination.
32    ; *
33    ; *  As a special exception, the copyright holders of XviD give you
34    ; *  permission to link XviD with independent modules that communicate with
35    ; *  XviD solely through the VFW1.1 and DShow interfaces, regardless of the
36    ; *  license terms of these independent modules, and to copy and distribute
37    ; *  the resulting combined work under terms of your choice, provided that
38    ; *  every copy of the combined work is accompanied by a complete copy of
39    ; *  the source code of XviD (the version of XviD used to produce the
40    ; *  combined work), being distributed under the terms of the GNU General
41    ; *  Public License plus this exception.  An independent module is a module
42    ; *  which is not derived from or based on XviD.
43    ; *
44    ; *  Note that people who make modified versions of XviD are not obligated
45    ; *  to grant this special exception for their modified versions; it is
46    ; *  their choice whether to do so.  The GNU General Public License gives
47    ; *  permission to release a modified version without this exception; this
48    ; *  exception also makes it possible to release a modified version which
49    ; *  carries forward this exception.
50  ; *  ; *
51  ; *     History:  ; * $Id: cbp_mmx.asm,v 1.7 2002-11-17 00:57:57 edgomez Exp $
 ; *  
 ; * 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>  
52  ; *  ; *
53  ; *************************************************************************/  ; *************************************************************************/
54    
   
55  bits 32  bits 32
56    
57  section .data  section .data
# Line 57  Line 69 
69    
70  ignore_dc       dw              0, -1, -1, -1, -1, -1, -1, -1  ignore_dc       dw              0, -1, -1, -1, -1, -1, -1, -1
71    
   
72  section .text  section .text
73    
74    cglobal calc_cbp_mmx
75    
76  ;===========================================================================  ;===========================================================================
77  ;  ;
# Line 68  Line 80 
80  ;===========================================================================  ;===========================================================================
81    
82  align 16  align 16
83  cglobal calc_cbp_mmx  calc_cbp_mmx:
 calc_cbp_mmx  
84                                  push    ebx                                  push    ebx
                                 push    ecx  
                                 push    edx  
85                                  push    esi                                  push    esi
86    
87                  mov     esi, [esp + 16 + 4]              ; coeff    mov       esi, [esp + 8 + 4]  ; coeff
88      xor           eax, eax                        ; cbp = 0
89      mov           edx, (1 << 5)
90    
91                                  movq    mm7, [ignore_dc]                                  movq    mm7, [ignore_dc]
92    
                                 xor             eax, eax                ; cbp = 0  
                                 mov             edx, 6  
93  .loop  .loop
94                  movq    mm0, [esi]                  movq    mm0, [esi]
                                 pand    mm0, mm7  
95                  movq    mm1, [esi+8]                  movq    mm1, [esi+8]
96      pand          mm0, mm7
97    
98                  por     mm0, [esi+16]                  por     mm0, [esi+16]
99                  por     mm1, [esi+24]                  por     mm1, [esi+24]
# Line 109  Line 119 
119                  por     mm0, mm1                  por     mm0, mm1
120                  movq    mm1, mm0                  movq    mm1, mm0
121                  psrlq   mm1, 32                  psrlq   mm1, 32
122      lea           esi, [esi + 128]
123    
124                  por     mm0, mm1                  por     mm0, mm1
125                                  movd    ebx, mm0                                  movd    ebx, mm0
126    
127                                  add             esi, 128    test          ebx, ebx
128      jz            .next
129                                  or              ebx, ebx    or            eax, edx     ; cbp |= 1 << (5-i)
130                                  jz              .iterate  
131    .next
132                                  ; cbp |= 1 << (edx-1)    shr           edx,1
133      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  
134    
135                                  pop     esi                                  pop     esi
                                 pop     edx  
                                 pop     ecx  
136                                  pop     ebx                                  pop     ebx
137    
138                                  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  
                                 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.655

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