32 |
; * |
; * |
33 |
; * History: |
; * History: |
34 |
; * |
; * |
35 |
; * 24.04.2002 had to use sse2's movdqu instead of movdqa (???) |
; * 14.06.2002 some further tweaks by -Skal- |
|
; * 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)' |
|
36 |
; * 24.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
; * 24.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
37 |
; * |
; * |
38 |
; *************************************************************************/ |
; *************************************************************************/ |
55 |
|
|
56 |
ignore_dc dw 0, -1, -1, -1, -1, -1, -1, -1 |
ignore_dc dw 0, -1, -1, -1, -1, -1, -1, -1 |
57 |
|
|
|
|
|
58 |
section .text |
section .text |
59 |
|
|
60 |
|
cglobal calc_cbp_mmx |
61 |
|
|
62 |
;=========================================================================== |
;=========================================================================== |
63 |
; |
; |
66 |
;=========================================================================== |
;=========================================================================== |
67 |
|
|
68 |
align 16 |
align 16 |
69 |
cglobal calc_cbp_mmx |
calc_cbp_mmx: |
|
calc_cbp_mmx |
|
70 |
push ebx |
push ebx |
|
push ecx |
|
|
push edx |
|
71 |
push esi |
push esi |
72 |
|
|
73 |
mov esi, [esp + 16 + 4] ; coeff |
mov esi, [esp + 8 + 4] ; coeff |
74 |
|
xor eax, eax ; cbp = 0 |
75 |
|
mov edx, (1 << 5) |
76 |
|
|
77 |
movq mm7, [ignore_dc] |
movq mm7, [ignore_dc] |
78 |
|
|
|
xor eax, eax ; cbp = 0 |
|
|
mov edx, 6 |
|
79 |
.loop |
.loop |
80 |
movq mm0, [esi] |
movq mm0, [esi] |
|
pand mm0, mm7 |
|
81 |
movq mm1, [esi+8] |
movq mm1, [esi+8] |
82 |
|
pand mm0, mm7 |
83 |
|
|
84 |
por mm0, [esi+16] |
por mm0, [esi+16] |
85 |
por mm1, [esi+24] |
por mm1, [esi+24] |
105 |
por mm0, mm1 |
por mm0, mm1 |
106 |
movq mm1, mm0 |
movq mm1, mm0 |
107 |
psrlq mm1, 32 |
psrlq mm1, 32 |
108 |
|
lea esi, [esi + 128] |
109 |
|
|
110 |
por mm0, mm1 |
por mm0, mm1 |
111 |
movd ebx, mm0 |
movd ebx, mm0 |
112 |
|
|
113 |
add esi, 128 |
test ebx, ebx |
114 |
|
jz .next |
115 |
or ebx, ebx |
or eax, edx ; cbp |= 1 << (5-i) |
116 |
jz .iterate |
|
117 |
|
.next |
118 |
; cbp |= 1 << (edx-1) |
shr edx,1 |
119 |
|
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 |
|
120 |
|
|
121 |
pop esi |
pop esi |
|
pop edx |
|
|
pop ecx |
|
122 |
pop ebx |
pop ebx |
123 |
|
|
124 |
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 |
|