[svn] / trunk / xvidcore / src / motion / x86_asm / sad_sse2.asm Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/motion/x86_asm/sad_sse2.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1795 - (view) (download)

1 : edgomez 1382 ;/****************************************************************************
2 : Isibaar 262 ; *
3 : edgomez 1382 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - SSE2 optimized SAD operators -
5 : Isibaar 262 ; *
6 : edgomez 1382 ; * Copyright(C) 2003 Pascal Massimino <skal@planet-d.net>
7 : Isibaar 262 ; *
8 :     ; *
9 : edgomez 1382 ; * This program is free software; you can redistribute it and/or modify it
10 :     ; * under the terms of the GNU General Public License as published by
11 :     ; * the Free Software Foundation; either version 2 of the License, or
12 :     ; * (at your option) any later version.
13 : Isibaar 262 ; *
14 : edgomez 1382 ; * This program is distributed in the hope that it will be useful,
15 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 :     ; * GNU General Public License for more details.
18 : Isibaar 262 ; *
19 : edgomez 1382 ; * You should have received a copy of the GNU General Public License
20 :     ; * along with this program; if not, write to the Free Software
21 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : Isibaar 262 ; *
23 : Isibaar 1795 ; * $Id: sad_sse2.asm,v 1.16 2008-11-26 01:04:34 Isibaar Exp $
24 : edgomez 652 ; *
25 : edgomez 1382 ; ***************************************************************************/
26 : Isibaar 262
27 : Isibaar 1795 %include "nasm.inc"
28 : Isibaar 262
29 : edgomez 1382 ;=============================================================================
30 :     ; Read only data
31 :     ;=============================================================================
32 : Isibaar 262
33 : Isibaar 1795 DATA
34 : Isibaar 262
35 : Isibaar 1795 ALIGN SECTION_ALIGN
36 : Isibaar 262 zero times 4 dd 0
37 :    
38 : edgomez 1382 ;=============================================================================
39 :     ; Code
40 :     ;=============================================================================
41 : Isibaar 262
42 : Isibaar 1795 SECTION .rotext align=SECTION_ALIGN
43 : edgomez 1382
44 : Isibaar 262 cglobal sad16_sse2
45 :     cglobal dev16_sse2
46 :    
47 : Isibaar 1764 cglobal sad16_sse3
48 :     cglobal dev16_sse3
49 :    
50 : edgomez 1382 ;-----------------------------------------------------------------------------
51 :     ; uint32_t sad16_sse2 (const uint8_t * const cur, <- assumed aligned!
52 :     ; const uint8_t * const ref,
53 :     ; const uint32_t stride,
54 :     ; const uint32_t /*ignored*/);
55 :     ;-----------------------------------------------------------------------------
56 : Isibaar 262
57 :    
58 : Isibaar 1764 %macro SAD_16x16_SSE2 1
59 : Isibaar 1795 %1 xmm0, [TMP1]
60 :     %1 xmm1, [TMP1+TMP0]
61 :     lea TMP1,[TMP1+2*TMP0]
62 :     movdqa xmm2, [_EAX]
63 :     movdqa xmm3, [_EAX+TMP0]
64 :     lea _EAX,[_EAX+2*TMP0]
65 : edgomez 1382 psadbw xmm0, xmm2
66 :     paddusw xmm6,xmm0
67 :     psadbw xmm1, xmm3
68 :     paddusw xmm6,xmm1
69 : Isibaar 262 %endmacro
70 :    
71 : Isibaar 1764 %macro SAD16_SSE2_SSE3 1
72 : Isibaar 1795 mov _EAX, prm1 ; cur (assumed aligned)
73 :     mov TMP1, prm2 ; ref
74 :     mov TMP0, prm3 ; stride
75 : Isibaar 262
76 : edgomez 1382 pxor xmm6, xmm6 ; accum
77 : Isibaar 262
78 : Isibaar 1764 SAD_16x16_SSE2 %1
79 :     SAD_16x16_SSE2 %1
80 :     SAD_16x16_SSE2 %1
81 :     SAD_16x16_SSE2 %1
82 :     SAD_16x16_SSE2 %1
83 :     SAD_16x16_SSE2 %1
84 :     SAD_16x16_SSE2 %1
85 :     SAD_16x16_SSE2 %1
86 : Isibaar 262
87 : edgomez 1382 pshufd xmm5, xmm6, 00000010b
88 :     paddusw xmm6, xmm5
89 :     pextrw eax, xmm6, 0
90 :     ret
91 : Isibaar 1764 %endmacro
92 :    
93 : Isibaar 1795 ALIGN SECTION_ALIGN
94 : Isibaar 1764 sad16_sse2:
95 :     SAD16_SSE2_SSE3 movdqu
96 : Isibaar 1793 ENDFUNC
97 : Isibaar 262
98 :    
99 : Isibaar 1795 ALIGN SECTION_ALIGN
100 : Isibaar 1764 sad16_sse3:
101 :     SAD16_SSE2_SSE3 lddqu
102 : Isibaar 1793 ENDFUNC
103 : Isibaar 1764
104 :    
105 : edgomez 1382 ;-----------------------------------------------------------------------------
106 :     ; uint32_t dev16_sse2(const uint8_t * const cur, const uint32_t stride);
107 :     ;-----------------------------------------------------------------------------
108 : Isibaar 262
109 : Isibaar 1795 %macro MEAN_16x16_SSE2 1 ; _EAX: src, TMP0:stride, mm7: zero or mean => mm6: result
110 :     %1 xmm0, [_EAX]
111 :     %1 xmm1, [_EAX+TMP0]
112 :     lea _EAX, [_EAX+2*TMP0] ; + 2*stride
113 : edgomez 1382 psadbw xmm0, xmm7
114 :     paddusw xmm6, xmm0
115 :     psadbw xmm1, xmm7
116 :     paddusw xmm6, xmm1
117 : Isibaar 262 %endmacro
118 :    
119 :    
120 : Isibaar 1764 %macro MEAN16_SSE2_SSE3 1
121 : Isibaar 1795 mov _EAX, prm1 ; src
122 :     mov TMP0, prm2 ; stride
123 : Isibaar 262
124 : edgomez 1382 pxor xmm6, xmm6 ; accum
125 :     pxor xmm7, xmm7 ; zero
126 : Isibaar 262
127 : Isibaar 1764 MEAN_16x16_SSE2 %1
128 :     MEAN_16x16_SSE2 %1
129 :     MEAN_16x16_SSE2 %1
130 :     MEAN_16x16_SSE2 %1
131 : Isibaar 262
132 : Isibaar 1764 MEAN_16x16_SSE2 %1
133 :     MEAN_16x16_SSE2 %1
134 :     MEAN_16x16_SSE2 %1
135 :     MEAN_16x16_SSE2 %1
136 : Isibaar 262
137 : Isibaar 1795 mov _EAX, prm1 ; src again
138 : Isibaar 262
139 : edgomez 1382 pshufd xmm7, xmm6, 10b
140 :     paddusw xmm7, xmm6
141 :     pxor xmm6, xmm6 ; zero accum
142 :     psrlw xmm7, 8 ; => Mean
143 :     pshuflw xmm7, xmm7, 0 ; replicate Mean
144 :     packuswb xmm7, xmm7
145 :     pshufd xmm7, xmm7, 00000000b
146 : Isibaar 262
147 : Isibaar 1764 MEAN_16x16_SSE2 %1
148 :     MEAN_16x16_SSE2 %1
149 :     MEAN_16x16_SSE2 %1
150 :     MEAN_16x16_SSE2 %1
151 : Isibaar 262
152 : Isibaar 1764 MEAN_16x16_SSE2 %1
153 :     MEAN_16x16_SSE2 %1
154 :     MEAN_16x16_SSE2 %1
155 :     MEAN_16x16_SSE2 %1
156 : Isibaar 262
157 : edgomez 1382 pshufd xmm7, xmm6, 10b
158 :     paddusw xmm7, xmm6
159 :     pextrw eax, xmm7, 0
160 :     ret
161 : Isibaar 1764 %endmacro
162 :    
163 : Isibaar 1795 ALIGN SECTION_ALIGN
164 : Isibaar 1764 dev16_sse2:
165 :     MEAN16_SSE2_SSE3 movdqu
166 : Isibaar 1793 ENDFUNC
167 : edgomez 1540
168 : Isibaar 1795 ALIGN SECTION_ALIGN
169 : Isibaar 1764 dev16_sse3:
170 :     MEAN16_SSE2_SSE3 lddqu
171 : Isibaar 1793 ENDFUNC
172 : Isibaar 1790
173 :    
174 :     %ifidn __OUTPUT_FORMAT__,elf
175 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
176 :     %endif
177 :    

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