1 |
;/************************************************************************** |
;/**************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * mmx cbp calc |
; * - MMX CBP computation - |
5 |
; * |
; * |
6 |
; * This file is part of XviD, a free MPEG-4 video encoder/decoder |
; * Copyright (C) 2005 Carlo Bramini <carlo.bramix@libero.it> |
7 |
|
; * 2001-2003 Peter Ross <pross@xvid.org> |
8 |
|
; * 2002-2003 Pascal Massimino <skal@planet-d.net> |
9 |
; * |
; * |
10 |
; * XviD is free software; you can redistribute it and/or modify it |
; * This program is free software ; you can redistribute it and/or modify |
11 |
; * 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 |
12 |
; * the Free Software Foundation; either version 2 of the License, or |
; * the Free Software Foundation; either version 2 of the License, or |
13 |
; * (at your option) any later version. |
; * (at your option) any later version. |
14 |
; * |
; * |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
; * |
; * |
24 |
; * Under section 8 of the GNU General Public License, the copyright |
; * $Id: cbp_mmx.asm,v 1.16 2008-11-11 20:46:24 Isibaar Exp $ |
|
; * holders of XVID explicitly forbid distribution in the following |
|
|
; * countries: |
|
|
; * |
|
|
; * - Japan |
|
|
; * - United States of America |
|
|
; * |
|
|
; * Linking XviD statically or dynamically with other modules is making a |
|
|
; * combined work based on XviD. Thus, the terms and conditions of the |
|
|
; * GNU General Public License cover the whole combination. |
|
|
; * |
|
|
; * As a special exception, the copyright holders of XviD give you |
|
|
; * permission to link XviD with independent modules that communicate with |
|
|
; * XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
|
|
; * license terms of these independent modules, and to copy and distribute |
|
|
; * the resulting combined work under terms of your choice, provided that |
|
|
; * every copy of the combined work is accompanied by a complete copy of |
|
|
; * the source code of XviD (the version of XviD used to produce the |
|
|
; * combined work), being distributed under the terms of the GNU General |
|
|
; * Public License plus this exception. An independent module is a module |
|
|
; * which is not derived from or based on XviD. |
|
|
; * |
|
|
; * Note that people who make modified versions of XviD are not obligated |
|
|
; * to grant this special exception for their modified versions; it is |
|
|
; * their choice whether to do so. The GNU General Public License gives |
|
|
; * permission to release a modified version without this exception; this |
|
|
; * exception also makes it possible to release a modified version which |
|
|
; * carries forward this exception. |
|
25 |
; * |
; * |
26 |
; * $Id: cbp_mmx.asm,v 1.7 2002-11-17 00:57:57 edgomez Exp $ |
; ***************************************************************************/ |
|
; * |
|
|
; *************************************************************************/ |
|
27 |
|
|
28 |
bits 32 |
BITS 32 |
29 |
|
|
30 |
section .data |
;============================================================================= |
31 |
|
; Macros |
32 |
|
;============================================================================= |
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 |
|
%define ENDFUNC .endfunc |
40 |
|
%else |
41 |
global _%1 |
global _%1 |
42 |
%define %1 _%1 |
%define %1 _%1 |
43 |
|
%define ENDFUNC |
44 |
|
%endif |
45 |
|
%else |
46 |
|
%ifdef MARK_FUNCS |
47 |
|
global %1:function %1.endfunc-%1 |
48 |
|
%define ENDFUNC .endfunc |
49 |
%else |
%else |
50 |
global %1 |
global %1 |
51 |
|
%define ENDFUNC |
52 |
|
%endif |
53 |
%endif |
%endif |
54 |
%endmacro |
%endmacro |
55 |
|
|
56 |
align 16 |
;============================================================================= |
57 |
|
; Local data |
58 |
|
;============================================================================= |
59 |
|
|
60 |
|
%ifdef FORMAT_COFF |
61 |
|
SECTION .rodata |
62 |
|
%else |
63 |
|
SECTION .rodata align=16 |
64 |
|
%endif |
65 |
|
|
66 |
|
ALIGN 16 |
67 |
|
|
68 |
ignore_dc dw 0, -1, -1, -1, -1, -1, -1, -1 |
mult_mask: |
69 |
|
db 0x10,0x20,0x04,0x08,0x01,0x02,0x00,0x00 |
70 |
|
ignore_dc: |
71 |
|
dw 0, -1, -1, -1 |
72 |
|
|
73 |
|
;============================================================================= |
74 |
|
; Code |
75 |
|
;============================================================================= |
76 |
|
|
77 |
section .text |
SECTION .text |
78 |
|
|
79 |
cglobal calc_cbp_mmx |
cglobal calc_cbp_mmx |
80 |
|
|
81 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
; |
|
82 |
; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]); |
; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]); |
83 |
; |
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
84 |
|
|
85 |
align 16 |
%macro MAKE_LOAD 1 |
86 |
calc_cbp_mmx: |
por mm0, [eax-128*1+%1*8] |
87 |
push ebx |
por mm1, [eax+128*0+%1*8] |
88 |
push esi |
por mm2, [eax+128*1+%1*8] |
89 |
|
por mm3, [eax+128*2+%1*8] |
90 |
|
por mm4, [eax+128*3+%1*8] |
91 |
|
por mm5, [eax+128*4+%1*8] |
92 |
|
%endmacro |
93 |
|
|
94 |
mov esi, [esp + 8 + 4] ; coeff |
ALIGN 16 |
95 |
xor eax, eax ; cbp = 0 |
calc_cbp_mmx: |
96 |
mov edx, (1 << 5) |
mov eax, [esp + 4] ; coeff |
97 |
|
|
98 |
movq mm7, [ignore_dc] |
movq mm7, [ignore_dc] |
99 |
|
pxor mm6, mm6 ; used only for comparing |
100 |
.loop |
movq mm0, [eax+128*0] |
101 |
movq mm0, [esi] |
movq mm1, [eax+128*1] |
102 |
movq mm1, [esi+8] |
movq mm2, [eax+128*2] |
103 |
|
movq mm3, [eax+128*3] |
104 |
|
movq mm4, [eax+128*4] |
105 |
|
movq mm5, [eax+128*5] |
106 |
|
add eax, 8+128 |
107 |
pand mm0, mm7 |
pand mm0, mm7 |
108 |
|
pand mm1, mm7 |
109 |
|
pand mm2, mm7 |
110 |
|
pand mm3, mm7 |
111 |
|
pand mm4, mm7 |
112 |
|
pand mm5, mm7 |
113 |
|
|
114 |
|
MAKE_LOAD 0 |
115 |
|
MAKE_LOAD 1 |
116 |
|
MAKE_LOAD 2 |
117 |
|
MAKE_LOAD 3 |
118 |
|
MAKE_LOAD 4 |
119 |
|
MAKE_LOAD 5 |
120 |
|
MAKE_LOAD 6 |
121 |
|
MAKE_LOAD 7 |
122 |
|
MAKE_LOAD 8 |
123 |
|
MAKE_LOAD 9 |
124 |
|
MAKE_LOAD 10 |
125 |
|
MAKE_LOAD 11 |
126 |
|
MAKE_LOAD 12 |
127 |
|
MAKE_LOAD 13 |
128 |
|
MAKE_LOAD 14 |
129 |
|
|
130 |
|
movq mm7, [mult_mask] |
131 |
|
packssdw mm0, mm1 |
132 |
|
packssdw mm2, mm3 |
133 |
|
packssdw mm4, mm5 |
134 |
|
packssdw mm0, mm2 |
135 |
|
packssdw mm4, mm6 |
136 |
|
pcmpeqw mm0, mm6 |
137 |
|
pcmpeqw mm4, mm6 |
138 |
|
pcmpeqw mm0, mm6 |
139 |
|
pcmpeqw mm4, mm6 |
140 |
|
psrlw mm0, 15 |
141 |
|
psrlw mm4, 15 |
142 |
|
packuswb mm0, mm4 |
143 |
|
pmaddwd mm0, mm7 |
144 |
|
|
|
por mm0, [esi+16] |
|
|
por mm1, [esi+24] |
|
|
|
|
|
por mm0, [esi+32] |
|
|
por mm1, [esi+40] |
|
|
|
|
|
por mm0, [esi+48] |
|
|
por mm1, [esi+56] |
|
|
|
|
|
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 |
|
145 |
movq mm1, mm0 |
movq mm1, mm0 |
146 |
psrlq mm1, 32 |
psrlq mm1, 32 |
147 |
lea esi, [esi + 128] |
paddusb mm0, mm1 |
|
|
|
|
por mm0, mm1 |
|
|
movd ebx, mm0 |
|
148 |
|
|
149 |
test ebx, ebx |
movd eax, mm0 |
150 |
jz .next |
shr eax, 8 |
151 |
or eax, edx ; cbp |= 1 << (5-i) |
and eax, 0x3F |
152 |
|
ret |
153 |
|
ENDFUNC |
154 |
|
|
|
.next |
|
|
shr edx,1 |
|
|
jnc .loop |
|
155 |
|
|
156 |
pop esi |
%ifidn __OUTPUT_FORMAT__,elf |
157 |
pop ebx |
section ".note.GNU-stack" noalloc noexec nowrite progbits |
158 |
|
%endif |
159 |
|
|
|
ret |
|