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 |
; * |
; * |
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 $ |
|
; * |
|
|
; * 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 |
65 |
%endif |
%endif |
66 |
%endmacro |
%endmacro |
67 |
|
|
68 |
ignore_dc dw 0, -1, -1, -1 |
align 16 |
69 |
|
|
70 |
|
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 |
; |
; |
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] |
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 |