1 |
;/************************************************************************** |
;/**************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * sse2 cbp calc |
; * - SSE2 CBP computation - |
5 |
; * |
; * |
6 |
; * This program is an implementation of a part of one or more MPEG-4 |
; * Copyright (C) 2002 Daniel Smith <danielsmith@astroboymail.com> |
7 |
; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
; * 2002 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 |
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: cbp_sse2.asm,v 1.10 2008-11-26 01:04:34 Isibaar Exp $ |
|
|
|
|
;/************************************************************************** |
|
|
; * |
|
|
; * History: |
|
24 |
; * |
; * |
25 |
; * 14.06.2002 cleanup -Skal- |
; ***************************************************************************/ |
|
; * 24.04.2002 had to use sse2's movdqu instead of movdqa (???) |
|
|
; * 17.04.2002 initial version (c) 2002 Daniel Smith |
|
|
; * |
|
|
; *************************************************************************/ |
|
|
|
|
|
|
|
|
bits 32 |
|
|
|
|
|
section .data |
|
|
|
|
|
%macro cglobal 1 |
|
|
%ifdef PREFIX |
|
|
global _%1 |
|
|
%define %1 _%1 |
|
|
%else |
|
|
global %1 |
|
|
%endif |
|
|
%endmacro |
|
26 |
|
|
27 |
align 16 |
;============================================================================= |
28 |
|
; Macros |
29 |
|
;============================================================================= |
30 |
|
|
31 |
ignore_dc dw 0, -1, -1, -1, -1, -1, -1, -1 |
%include "nasm.inc" |
32 |
|
|
33 |
section .text |
%macro LOOP_SSE2 2 |
34 |
|
movdqa xmm0, [%2+(%1)*128] |
|
cglobal calc_cbp_sse2 |
|
|
|
|
|
;=========================================================================== |
|
|
; |
|
|
; uint32_t calc_cbp_sse2(const int16_t coeff[6][64]); |
|
|
; |
|
|
; not enabled - slower than mmx? |
|
|
; |
|
|
;=========================================================================== |
|
|
|
|
|
%macro LOOP_SSE2 1 |
|
|
movdqa xmm0, [edx+(%1)*128] |
|
35 |
pand xmm0, xmm7 |
pand xmm0, xmm7 |
36 |
movdqa xmm1, [edx+(%1)*128+16] |
movdqa xmm1, [%2+(%1)*128+16] |
37 |
|
|
38 |
por xmm0, [edx+(%1)*128+32] |
por xmm0, [%2+(%1)*128+32] |
39 |
por xmm1, [edx+(%1)*128+48] |
por xmm1, [%2+(%1)*128+48] |
40 |
por xmm0, [edx+(%1)*128+64] |
por xmm0, [%2+(%1)*128+64] |
41 |
por xmm1, [edx+(%1)*128+80] |
por xmm1, [%2+(%1)*128+80] |
42 |
por xmm0, [edx+(%1)*128+96] |
por xmm0, [%2+(%1)*128+96] |
43 |
por xmm1, [edx+(%1)*128+112] |
por xmm1, [%2+(%1)*128+112] |
44 |
|
|
45 |
por xmm0, xmm1 ; xmm0 = xmm1 = 128 bits worth of info |
por xmm0, xmm1 ; xmm0 = xmm1 = 128 bits worth of info |
46 |
psadbw xmm0, xmm6 ; contains 2 dwords with sums |
psadbw xmm0, xmm6 ; contains 2 dwords with sums |
47 |
movhlps xmm1, xmm0 ; move high dword from xmm0 to low xmm1 |
movhlps xmm1, xmm0 ; move high dword from xmm0 to low xmm1 |
48 |
por xmm0, xmm1 ; combine |
por xmm0, xmm1 ; combine |
49 |
movd ecx, xmm0 ; if ecx set, values were found |
movd ecx, xmm0 ; if ecx set, values were found |
50 |
test ecx, ecx |
test _ECX, _ECX |
51 |
%endmacro |
%endmacro |
52 |
|
|
53 |
align 16 |
;============================================================================= |
54 |
|
; Data (Read Only) |
55 |
|
;============================================================================= |
56 |
|
|
57 |
|
DATA |
58 |
|
|
59 |
|
ALIGN SECTION_ALIGN |
60 |
|
ignore_dc: |
61 |
|
dw 0, -1, -1, -1, -1, -1, -1, -1 |
62 |
|
|
63 |
|
;============================================================================= |
64 |
|
; Code |
65 |
|
;============================================================================= |
66 |
|
|
67 |
|
SECTION .rotext align=SECTION_ALIGN |
68 |
|
|
69 |
|
;----------------------------------------------------------------------------- |
70 |
|
; uint32_t calc_cbp_sse2(const int16_t coeff[6*64]); |
71 |
|
;----------------------------------------------------------------------------- |
72 |
|
|
73 |
|
ALIGN SECTION_ALIGN |
74 |
|
cglobal calc_cbp_sse2 |
75 |
calc_cbp_sse2: |
calc_cbp_sse2: |
76 |
mov edx, [esp+4] ; coeff[] |
mov _EDX, prm1 ; coeff[] |
77 |
xor eax, eax ; cbp = 0 |
xor _EAX, _EAX ; cbp = 0 |
78 |
|
|
79 |
movdqu xmm7, [ignore_dc] ; mask to ignore dc value |
movdqu xmm7, [ignore_dc] ; mask to ignore dc value |
80 |
pxor xmm6, xmm6 ; zero |
pxor xmm6, xmm6 ; zero |
81 |
|
|
82 |
LOOP_SSE2 0 |
LOOP_SSE2 0, _EDX |
|
test ecx, ecx |
|
83 |
jz .blk2 |
jz .blk2 |
84 |
or eax, (1<<5) |
or _EAX, (1<<5) |
85 |
.blk2 |
|
86 |
LOOP_SSE2 1 |
.blk2: |
87 |
test ecx, ecx |
LOOP_SSE2 1, _EDX |
88 |
jz .blk3 |
jz .blk3 |
89 |
or eax, (1<<4) |
or _EAX, (1<<4) |
90 |
.blk3 |
|
91 |
LOOP_SSE2 2 |
.blk3: |
92 |
test ecx, ecx |
LOOP_SSE2 2, _EDX |
93 |
jz .blk4 |
jz .blk4 |
94 |
or eax, (1<<3) |
or _EAX, (1<<3) |
95 |
.blk4 |
|
96 |
LOOP_SSE2 3 |
.blk4: |
97 |
test ecx, ecx |
LOOP_SSE2 3, _EDX |
98 |
jz .blk5 |
jz .blk5 |
99 |
or eax, (1<<2) |
or _EAX, (1<<2) |
100 |
.blk5 |
|
101 |
LOOP_SSE2 4 |
.blk5: |
102 |
test ecx, ecx |
LOOP_SSE2 4, _EDX |
103 |
jz .blk6 |
jz .blk6 |
104 |
or eax, (1<<1) |
or _EAX, (1<<1) |
105 |
.blk6 |
|
106 |
LOOP_SSE2 5 |
.blk6: |
107 |
test ecx, ecx |
LOOP_SSE2 5, _EDX |
108 |
jz .finished |
jz .finished |
109 |
or eax, (1<<0) |
or _EAX, (1<<0) |
|
.finished |
|
110 |
|
|
111 |
|
.finished: |
112 |
ret |
ret |
113 |
|
ENDFUNC |
114 |
|
|
115 |
|
|
116 |
|
%ifidn __OUTPUT_FORMAT__,elf |
117 |
|
section ".note.GNU-stack" noalloc noexec nowrite progbits |
118 |
|
%endif |
119 |
|
|