Mercurial > libavcodec.hg
annotate i386/motion_est_mmx.c @ 4974:a2e489e40ea3 libavcodec
tweak mmx2 sad.
6% faster on core2 and k8, no change on p4.
author | lorenm |
---|---|
date | Thu, 10 May 2007 22:24:19 +0000 |
parents | bbe0bc387a19 |
children | 800a543a2513 |
rev | line source |
---|---|
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
1 /* |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
2 * MMX optimized motion estimation |
429 | 3 * Copyright (c) 2001 Fabrice Bellard. |
1739
07a484280a82
copyright year update of the files i touched and remembered, things look annoyingly unmaintained otherwise
michael
parents:
1708
diff
changeset
|
4 * Copyright (c) 2002-2004 Michael Niedermayer |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
5 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3576
diff
changeset
|
6 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3576
diff
changeset
|
7 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3576
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
429 | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3576
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
12 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3576
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Lesser General Public License for more details. | |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
17 * |
429 | 18 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3576
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
21 * |
294 | 22 * mostly by Michael Niedermayer <michaelni@gmx.at> |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
23 */ |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
24 #include "../dsputil.h" |
3398
e0927bc44a10
Move REG_* macros from libavcodec/i386/mmx.h to libavutil/x86_cpu.h
lucabe
parents:
3036
diff
changeset
|
25 #include "x86_cpu.h" |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
26 |
1064 | 27 static const __attribute__ ((aligned(8))) uint64_t round_tab[3]={ |
1569
1f8d1e1173d8
Fixes GCC 3.3.2 warnings patch by (Panagiotis Issaris <takis at lumumba dot luc dot ac dot be>)
michael
parents:
1455
diff
changeset
|
28 0x0000000000000000ULL, |
1f8d1e1173d8
Fixes GCC 3.3.2 warnings patch by (Panagiotis Issaris <takis at lumumba dot luc dot ac dot be>)
michael
parents:
1455
diff
changeset
|
29 0x0001000100010001ULL, |
1f8d1e1173d8
Fixes GCC 3.3.2 warnings patch by (Panagiotis Issaris <takis at lumumba dot luc dot ac dot be>)
michael
parents:
1455
diff
changeset
|
30 0x0002000200020002ULL, |
294 | 31 }; |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
32 |
1845
3054613980a8
attribute used patch by (mitya at school dot ioffe dot ru (Dmitry Baryshkov))
michael
parents:
1739
diff
changeset
|
33 static attribute_used __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL; |
330 | 34 |
1708 | 35 static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h) |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
36 { |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
37 long len= -(stride*h); |
294 | 38 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
39 ASMALIGN(4) |
2979 | 40 "1: \n\t" |
41 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
42 "movq (%2, %%"REG_a"), %%mm2 \n\t" | |
43 "movq (%2, %%"REG_a"), %%mm4 \n\t" | |
44 "add %3, %%"REG_a" \n\t" | |
45 "psubusb %%mm0, %%mm2 \n\t" | |
46 "psubusb %%mm4, %%mm0 \n\t" | |
47 "movq (%1, %%"REG_a"), %%mm1 \n\t" | |
48 "movq (%2, %%"REG_a"), %%mm3 \n\t" | |
49 "movq (%2, %%"REG_a"), %%mm5 \n\t" | |
50 "psubusb %%mm1, %%mm3 \n\t" | |
51 "psubusb %%mm5, %%mm1 \n\t" | |
52 "por %%mm2, %%mm0 \n\t" | |
53 "por %%mm1, %%mm3 \n\t" | |
54 "movq %%mm0, %%mm1 \n\t" | |
55 "movq %%mm3, %%mm2 \n\t" | |
56 "punpcklbw %%mm7, %%mm0 \n\t" | |
57 "punpckhbw %%mm7, %%mm1 \n\t" | |
58 "punpcklbw %%mm7, %%mm3 \n\t" | |
59 "punpckhbw %%mm7, %%mm2 \n\t" | |
60 "paddw %%mm1, %%mm0 \n\t" | |
61 "paddw %%mm3, %%mm2 \n\t" | |
62 "paddw %%mm2, %%mm0 \n\t" | |
63 "paddw %%mm0, %%mm6 \n\t" | |
64 "add %3, %%"REG_a" \n\t" | |
65 " js 1b \n\t" | |
294 | 66 : "+a" (len) |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
67 : "r" (blk1 - len), "r" (blk2 - len), "r" ((long)stride) |
294 | 68 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
69 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
70 |
1708 | 71 static inline void sad8_1_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h) |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
72 { |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
73 long len= -(stride*h); |
294 | 74 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
75 ASMALIGN(4) |
2979 | 76 "1: \n\t" |
77 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
4974 | 78 "psadbw (%2, %%"REG_a"), %%mm0 \n\t" |
2979 | 79 "add %3, %%"REG_a" \n\t" |
80 "movq (%1, %%"REG_a"), %%mm1 \n\t" | |
4974 | 81 "psadbw (%2, %%"REG_a"), %%mm1 \n\t" |
82 "paddw %%mm1, %%mm0 \n\t" | |
2979 | 83 "paddw %%mm0, %%mm6 \n\t" |
84 "add %3, %%"REG_a" \n\t" | |
85 " js 1b \n\t" | |
294 | 86 : "+a" (len) |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
87 : "r" (blk1 - len), "r" (blk2 - len), "r" ((long)stride) |
294 | 88 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
89 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
90 |
1064 | 91 static inline void sad8_2_mmx2(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h) |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
92 { |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
93 long len= -(stride*h); |
294 | 94 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
95 ASMALIGN(4) |
2979 | 96 "1: \n\t" |
97 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
4974 | 98 "pavgb (%2, %%"REG_a"), %%mm0 \n\t" |
99 "psadbw (%3, %%"REG_a"), %%mm0 \n\t" | |
2979 | 100 "add %4, %%"REG_a" \n\t" |
101 "movq (%1, %%"REG_a"), %%mm1 \n\t" | |
4974 | 102 "pavgb (%2, %%"REG_a"), %%mm1 \n\t" |
103 "psadbw (%3, %%"REG_a"), %%mm1 \n\t" | |
104 "paddw %%mm1, %%mm0 \n\t" | |
2979 | 105 "paddw %%mm0, %%mm6 \n\t" |
106 "add %4, %%"REG_a" \n\t" | |
107 " js 1b \n\t" | |
294 | 108 : "+a" (len) |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
109 : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((long)stride) |
294 | 110 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
111 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
112 |
1064 | 113 static inline void sad8_4_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h) |
294 | 114 { //FIXME reuse src |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
115 long len= -(stride*h); |
294 | 116 asm volatile( |
4974 | 117 "movq "MANGLE(bone)", %%mm5 \n\t" |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
118 ASMALIGN(4) |
2979 | 119 "1: \n\t" |
120 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
121 "movq 1(%1, %%"REG_a"), %%mm1 \n\t" | |
4974 | 122 "pavgb (%2, %%"REG_a"), %%mm0 \n\t" |
123 "pavgb 1(%2, %%"REG_a"), %%mm1 \n\t" | |
124 "psubusb %%mm5, %%mm1 \n\t" | |
125 "pavgb %%mm1, %%mm0 \n\t" | |
126 "psadbw (%3, %%"REG_a"), %%mm0 \n\t" | |
2979 | 127 "add %4, %%"REG_a" \n\t" |
4974 | 128 "movq (%1, %%"REG_a"), %%mm2 \n\t" |
129 "movq 1(%1, %%"REG_a"), %%mm3 \n\t" | |
130 "pavgb (%2, %%"REG_a"), %%mm2 \n\t" | |
131 "pavgb 1(%2, %%"REG_a"), %%mm3 \n\t" | |
132 "psubusb %%mm5, %%mm3 \n\t" | |
133 "pavgb %%mm3, %%mm2 \n\t" | |
134 "psadbw (%3, %%"REG_a"), %%mm2 \n\t" | |
2979 | 135 "paddw %%mm2, %%mm0 \n\t" |
136 "paddw %%mm0, %%mm6 \n\t" | |
137 "add %4, %%"REG_a" \n\t" | |
138 " js 1b \n\t" | |
294 | 139 : "+a" (len) |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
140 : "r" (blk1 - len), "r" (blk1 - len + stride), "r" (blk2 - len), "r" ((long)stride) |
294 | 141 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
142 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
143 |
1064 | 144 static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h) |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
145 { |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
146 long len= -(stride*h); |
294 | 147 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
148 ASMALIGN(4) |
2979 | 149 "1: \n\t" |
150 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
151 "movq (%2, %%"REG_a"), %%mm1 \n\t" | |
152 "movq (%1, %%"REG_a"), %%mm2 \n\t" | |
153 "movq (%2, %%"REG_a"), %%mm3 \n\t" | |
154 "punpcklbw %%mm7, %%mm0 \n\t" | |
155 "punpcklbw %%mm7, %%mm1 \n\t" | |
156 "punpckhbw %%mm7, %%mm2 \n\t" | |
157 "punpckhbw %%mm7, %%mm3 \n\t" | |
158 "paddw %%mm0, %%mm1 \n\t" | |
159 "paddw %%mm2, %%mm3 \n\t" | |
160 "movq (%3, %%"REG_a"), %%mm4 \n\t" | |
161 "movq (%3, %%"REG_a"), %%mm2 \n\t" | |
162 "paddw %%mm5, %%mm1 \n\t" | |
163 "paddw %%mm5, %%mm3 \n\t" | |
164 "psrlw $1, %%mm1 \n\t" | |
165 "psrlw $1, %%mm3 \n\t" | |
166 "packuswb %%mm3, %%mm1 \n\t" | |
167 "psubusb %%mm1, %%mm4 \n\t" | |
168 "psubusb %%mm2, %%mm1 \n\t" | |
169 "por %%mm4, %%mm1 \n\t" | |
170 "movq %%mm1, %%mm0 \n\t" | |
171 "punpcklbw %%mm7, %%mm0 \n\t" | |
172 "punpckhbw %%mm7, %%mm1 \n\t" | |
173 "paddw %%mm1, %%mm0 \n\t" | |
174 "paddw %%mm0, %%mm6 \n\t" | |
175 "add %4, %%"REG_a" \n\t" | |
176 " js 1b \n\t" | |
294 | 177 : "+a" (len) |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
178 : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((long)stride) |
294 | 179 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
180 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
181 |
1064 | 182 static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h) |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
183 { |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
184 long len= -(stride*h); |
294 | 185 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
186 ASMALIGN(4) |
2979 | 187 "1: \n\t" |
188 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
189 "movq (%2, %%"REG_a"), %%mm1 \n\t" | |
190 "movq %%mm0, %%mm4 \n\t" | |
191 "movq %%mm1, %%mm2 \n\t" | |
192 "punpcklbw %%mm7, %%mm0 \n\t" | |
193 "punpcklbw %%mm7, %%mm1 \n\t" | |
194 "punpckhbw %%mm7, %%mm4 \n\t" | |
195 "punpckhbw %%mm7, %%mm2 \n\t" | |
196 "paddw %%mm1, %%mm0 \n\t" | |
197 "paddw %%mm2, %%mm4 \n\t" | |
198 "movq 1(%1, %%"REG_a"), %%mm2 \n\t" | |
199 "movq 1(%2, %%"REG_a"), %%mm3 \n\t" | |
200 "movq %%mm2, %%mm1 \n\t" | |
201 "punpcklbw %%mm7, %%mm2 \n\t" | |
202 "punpckhbw %%mm7, %%mm1 \n\t" | |
203 "paddw %%mm0, %%mm2 \n\t" | |
204 "paddw %%mm4, %%mm1 \n\t" | |
205 "movq %%mm3, %%mm4 \n\t" | |
206 "punpcklbw %%mm7, %%mm3 \n\t" | |
207 "punpckhbw %%mm7, %%mm4 \n\t" | |
208 "paddw %%mm3, %%mm2 \n\t" | |
209 "paddw %%mm4, %%mm1 \n\t" | |
210 "movq (%3, %%"REG_a"), %%mm3 \n\t" | |
211 "movq (%3, %%"REG_a"), %%mm4 \n\t" | |
212 "paddw %%mm5, %%mm2 \n\t" | |
213 "paddw %%mm5, %%mm1 \n\t" | |
214 "psrlw $2, %%mm2 \n\t" | |
215 "psrlw $2, %%mm1 \n\t" | |
216 "packuswb %%mm1, %%mm2 \n\t" | |
217 "psubusb %%mm2, %%mm3 \n\t" | |
218 "psubusb %%mm4, %%mm2 \n\t" | |
219 "por %%mm3, %%mm2 \n\t" | |
220 "movq %%mm2, %%mm0 \n\t" | |
221 "punpcklbw %%mm7, %%mm0 \n\t" | |
222 "punpckhbw %%mm7, %%mm2 \n\t" | |
223 "paddw %%mm2, %%mm0 \n\t" | |
224 "paddw %%mm0, %%mm6 \n\t" | |
225 "add %4, %%"REG_a" \n\t" | |
226 " js 1b \n\t" | |
294 | 227 : "+a" (len) |
2293
15cfba1b97b5
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents:
1845
diff
changeset
|
228 : "r" (blk1 - len), "r" (blk1 -len + stride), "r" (blk2 - len), "r" ((long)stride) |
294 | 229 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
230 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
231 |
1057 | 232 static inline int sum_mmx(void) |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
233 { |
294 | 234 int ret; |
235 asm volatile( | |
2979 | 236 "movq %%mm6, %%mm0 \n\t" |
237 "psrlq $32, %%mm6 \n\t" | |
238 "paddw %%mm0, %%mm6 \n\t" | |
239 "movq %%mm6, %%mm0 \n\t" | |
240 "psrlq $16, %%mm6 \n\t" | |
241 "paddw %%mm0, %%mm6 \n\t" | |
242 "movd %%mm6, %0 \n\t" | |
294 | 243 : "=r" (ret) |
244 ); | |
245 return ret&0xFFFF; | |
246 } | |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
247 |
1057 | 248 static inline int sum_mmx2(void) |
294 | 249 { |
250 int ret; | |
251 asm volatile( | |
2979 | 252 "movd %%mm6, %0 \n\t" |
294 | 253 : "=r" (ret) |
254 ); | |
255 return ret; | |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
256 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
257 |
900 | 258 |
294 | 259 #define PIX_SAD(suf)\ |
1708 | 260 static int sad8_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ |
261 {\ | |
262 assert(h==8);\ | |
2979 | 263 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
264 "pxor %%mm6, %%mm6 \n\t":);\ | |
1708 | 265 \ |
266 sad8_1_ ## suf(blk1, blk2, stride, 8);\ | |
267 \ | |
268 return sum_ ## suf();\ | |
269 }\ | |
270 static int sad8_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ | |
271 {\ | |
272 assert(h==8);\ | |
2979 | 273 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
274 "pxor %%mm6, %%mm6 \n\t"\ | |
275 "movq %0, %%mm5 \n\t"\ | |
1708 | 276 :: "m"(round_tab[1]) \ |
277 );\ | |
278 \ | |
279 sad8_2_ ## suf(blk1, blk1+1, blk2, stride, 8);\ | |
280 \ | |
281 return sum_ ## suf();\ | |
282 }\ | |
283 \ | |
284 static int sad8_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ | |
285 {\ | |
286 assert(h==8);\ | |
2979 | 287 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
288 "pxor %%mm6, %%mm6 \n\t"\ | |
289 "movq %0, %%mm5 \n\t"\ | |
1708 | 290 :: "m"(round_tab[1]) \ |
291 );\ | |
292 \ | |
293 sad8_2_ ## suf(blk1, blk1+stride, blk2, stride, 8);\ | |
294 \ | |
295 return sum_ ## suf();\ | |
296 }\ | |
297 \ | |
298 static int sad8_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ | |
299 {\ | |
300 assert(h==8);\ | |
2979 | 301 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
302 "pxor %%mm6, %%mm6 \n\t"\ | |
303 "movq %0, %%mm5 \n\t"\ | |
1708 | 304 :: "m"(round_tab[2]) \ |
305 );\ | |
306 \ | |
307 sad8_4_ ## suf(blk1, blk2, stride, 8);\ | |
308 \ | |
309 return sum_ ## suf();\ | |
310 }\ | |
311 \ | |
312 static int sad16_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ | |
294 | 313 {\ |
2979 | 314 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
315 "pxor %%mm6, %%mm6 \n\t":);\ | |
294 | 316 \ |
1708 | 317 sad8_1_ ## suf(blk1 , blk2 , stride, h);\ |
318 sad8_1_ ## suf(blk1+8, blk2+8, stride, h);\ | |
294 | 319 \ |
320 return sum_ ## suf();\ | |
321 }\ | |
1708 | 322 static int sad16_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ |
294 | 323 {\ |
2979 | 324 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
325 "pxor %%mm6, %%mm6 \n\t"\ | |
326 "movq %0, %%mm5 \n\t"\ | |
294 | 327 :: "m"(round_tab[1]) \ |
328 );\ | |
329 \ | |
1708 | 330 sad8_2_ ## suf(blk1 , blk1+1, blk2 , stride, h);\ |
331 sad8_2_ ## suf(blk1+8, blk1+9, blk2+8, stride, h);\ | |
294 | 332 \ |
333 return sum_ ## suf();\ | |
334 }\ | |
1708 | 335 static int sad16_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ |
294 | 336 {\ |
2979 | 337 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
338 "pxor %%mm6, %%mm6 \n\t"\ | |
339 "movq %0, %%mm5 \n\t"\ | |
294 | 340 :: "m"(round_tab[1]) \ |
341 );\ | |
342 \ | |
1708 | 343 sad8_2_ ## suf(blk1 , blk1+stride, blk2 , stride, h);\ |
344 sad8_2_ ## suf(blk1+8, blk1+stride+8,blk2+8, stride, h);\ | |
294 | 345 \ |
346 return sum_ ## suf();\ | |
347 }\ | |
1708 | 348 static int sad16_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ |
294 | 349 {\ |
2979 | 350 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
351 "pxor %%mm6, %%mm6 \n\t"\ | |
352 "movq %0, %%mm5 \n\t"\ | |
294 | 353 :: "m"(round_tab[2]) \ |
354 );\ | |
355 \ | |
1708 | 356 sad8_4_ ## suf(blk1 , blk2 , stride, h);\ |
357 sad8_4_ ## suf(blk1+8, blk2+8, stride, h);\ | |
294 | 358 \ |
359 return sum_ ## suf();\ | |
360 }\ | |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
361 |
294 | 362 PIX_SAD(mmx) |
363 PIX_SAD(mmx2) | |
1057 | 364 |
1092 | 365 void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx) |
1057 | 366 { |
4197 | 367 if (mm_flags & MM_MMX) { |
1708 | 368 c->pix_abs[0][0] = sad16_mmx; |
369 c->pix_abs[0][1] = sad16_x2_mmx; | |
370 c->pix_abs[0][2] = sad16_y2_mmx; | |
371 c->pix_abs[0][3] = sad16_xy2_mmx; | |
372 c->pix_abs[1][0] = sad8_mmx; | |
373 c->pix_abs[1][1] = sad8_x2_mmx; | |
374 c->pix_abs[1][2] = sad8_y2_mmx; | |
375 c->pix_abs[1][3] = sad8_xy2_mmx; | |
1057 | 376 |
2979 | 377 c->sad[0]= sad16_mmx; |
1708 | 378 c->sad[1]= sad8_mmx; |
1057 | 379 } |
4197 | 380 if (mm_flags & MM_MMXEXT) { |
2979 | 381 c->pix_abs[0][0] = sad16_mmx2; |
382 c->pix_abs[1][0] = sad8_mmx2; | |
1057 | 383 |
2979 | 384 c->sad[0]= sad16_mmx2; |
385 c->sad[1]= sad8_mmx2; | |
2967 | 386 |
1092 | 387 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ |
1708 | 388 c->pix_abs[0][1] = sad16_x2_mmx2; |
389 c->pix_abs[0][2] = sad16_y2_mmx2; | |
390 c->pix_abs[0][3] = sad16_xy2_mmx2; | |
391 c->pix_abs[1][1] = sad8_x2_mmx2; | |
392 c->pix_abs[1][2] = sad8_y2_mmx2; | |
393 c->pix_abs[1][3] = sad8_xy2_mmx2; | |
1092 | 394 } |
1057 | 395 } |
396 } |