Mercurial > libavcodec.hg
annotate i386/motion_est_mmx.c @ 4141:b03f19bc1698 libavcodec
Update comment
author | kostya |
---|---|
date | Sun, 05 Nov 2006 04:59:38 +0000 |
parents | c8c591fe26f8 |
children | fbac0859753d |
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" | |
78 "movq (%2, %%"REG_a"), %%mm2 \n\t" | |
79 "psadbw %%mm2, %%mm0 \n\t" | |
80 "add %3, %%"REG_a" \n\t" | |
81 "movq (%1, %%"REG_a"), %%mm1 \n\t" | |
82 "movq (%2, %%"REG_a"), %%mm3 \n\t" | |
83 "psadbw %%mm1, %%mm3 \n\t" | |
84 "paddw %%mm3, %%mm0 \n\t" | |
85 "paddw %%mm0, %%mm6 \n\t" | |
86 "add %3, %%"REG_a" \n\t" | |
87 " js 1b \n\t" | |
294 | 88 : "+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
|
89 : "r" (blk1 - len), "r" (blk2 - len), "r" ((long)stride) |
294 | 90 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
91 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
92 |
1064 | 93 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
|
94 { |
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
|
95 long len= -(stride*h); |
294 | 96 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
97 ASMALIGN(4) |
2979 | 98 "1: \n\t" |
99 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
100 "movq (%2, %%"REG_a"), %%mm2 \n\t" | |
101 "pavgb %%mm2, %%mm0 \n\t" | |
102 "movq (%3, %%"REG_a"), %%mm2 \n\t" | |
103 "psadbw %%mm2, %%mm0 \n\t" | |
104 "add %4, %%"REG_a" \n\t" | |
105 "movq (%1, %%"REG_a"), %%mm1 \n\t" | |
106 "movq (%2, %%"REG_a"), %%mm3 \n\t" | |
107 "pavgb %%mm1, %%mm3 \n\t" | |
108 "movq (%3, %%"REG_a"), %%mm1 \n\t" | |
109 "psadbw %%mm1, %%mm3 \n\t" | |
110 "paddw %%mm3, %%mm0 \n\t" | |
111 "paddw %%mm0, %%mm6 \n\t" | |
112 "add %4, %%"REG_a" \n\t" | |
113 " js 1b \n\t" | |
294 | 114 : "+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
|
115 : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((long)stride) |
294 | 116 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
117 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
118 |
1064 | 119 static inline void sad8_4_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h) |
294 | 120 { //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
|
121 long len= -(stride*h); |
294 | 122 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
123 ASMALIGN(4) |
2979 | 124 "movq "MANGLE(bone)", %%mm5 \n\t" |
125 "1: \n\t" | |
126 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
127 "movq (%2, %%"REG_a"), %%mm2 \n\t" | |
128 "movq 1(%1, %%"REG_a"), %%mm1 \n\t" | |
129 "movq 1(%2, %%"REG_a"), %%mm3 \n\t" | |
130 "pavgb %%mm2, %%mm0 \n\t" | |
131 "pavgb %%mm1, %%mm3 \n\t" | |
132 "psubusb %%mm5, %%mm3 \n\t" | |
133 "pavgb %%mm3, %%mm0 \n\t" | |
134 "movq (%3, %%"REG_a"), %%mm2 \n\t" | |
135 "psadbw %%mm2, %%mm0 \n\t" | |
136 "add %4, %%"REG_a" \n\t" | |
137 "movq (%1, %%"REG_a"), %%mm1 \n\t" | |
138 "movq (%2, %%"REG_a"), %%mm3 \n\t" | |
139 "movq 1(%1, %%"REG_a"), %%mm2 \n\t" | |
140 "movq 1(%2, %%"REG_a"), %%mm4 \n\t" | |
141 "pavgb %%mm3, %%mm1 \n\t" | |
142 "pavgb %%mm4, %%mm2 \n\t" | |
143 "psubusb %%mm5, %%mm2 \n\t" | |
144 "pavgb %%mm1, %%mm2 \n\t" | |
145 "movq (%3, %%"REG_a"), %%mm1 \n\t" | |
146 "psadbw %%mm1, %%mm2 \n\t" | |
147 "paddw %%mm2, %%mm0 \n\t" | |
148 "paddw %%mm0, %%mm6 \n\t" | |
149 "add %4, %%"REG_a" \n\t" | |
150 " js 1b \n\t" | |
294 | 151 : "+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
|
152 : "r" (blk1 - len), "r" (blk1 - len + stride), "r" (blk2 - len), "r" ((long)stride) |
294 | 153 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
154 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
155 |
1064 | 156 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
|
157 { |
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
|
158 long len= -(stride*h); |
294 | 159 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
160 ASMALIGN(4) |
2979 | 161 "1: \n\t" |
162 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
163 "movq (%2, %%"REG_a"), %%mm1 \n\t" | |
164 "movq (%1, %%"REG_a"), %%mm2 \n\t" | |
165 "movq (%2, %%"REG_a"), %%mm3 \n\t" | |
166 "punpcklbw %%mm7, %%mm0 \n\t" | |
167 "punpcklbw %%mm7, %%mm1 \n\t" | |
168 "punpckhbw %%mm7, %%mm2 \n\t" | |
169 "punpckhbw %%mm7, %%mm3 \n\t" | |
170 "paddw %%mm0, %%mm1 \n\t" | |
171 "paddw %%mm2, %%mm3 \n\t" | |
172 "movq (%3, %%"REG_a"), %%mm4 \n\t" | |
173 "movq (%3, %%"REG_a"), %%mm2 \n\t" | |
174 "paddw %%mm5, %%mm1 \n\t" | |
175 "paddw %%mm5, %%mm3 \n\t" | |
176 "psrlw $1, %%mm1 \n\t" | |
177 "psrlw $1, %%mm3 \n\t" | |
178 "packuswb %%mm3, %%mm1 \n\t" | |
179 "psubusb %%mm1, %%mm4 \n\t" | |
180 "psubusb %%mm2, %%mm1 \n\t" | |
181 "por %%mm4, %%mm1 \n\t" | |
182 "movq %%mm1, %%mm0 \n\t" | |
183 "punpcklbw %%mm7, %%mm0 \n\t" | |
184 "punpckhbw %%mm7, %%mm1 \n\t" | |
185 "paddw %%mm1, %%mm0 \n\t" | |
186 "paddw %%mm0, %%mm6 \n\t" | |
187 "add %4, %%"REG_a" \n\t" | |
188 " js 1b \n\t" | |
294 | 189 : "+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
|
190 : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((long)stride) |
294 | 191 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
192 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
193 |
1064 | 194 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
|
195 { |
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
|
196 long len= -(stride*h); |
294 | 197 asm volatile( |
3576
f7125bf10892
Support for MacIntel, last part: balign directives
gpoirier
parents:
3398
diff
changeset
|
198 ASMALIGN(4) |
2979 | 199 "1: \n\t" |
200 "movq (%1, %%"REG_a"), %%mm0 \n\t" | |
201 "movq (%2, %%"REG_a"), %%mm1 \n\t" | |
202 "movq %%mm0, %%mm4 \n\t" | |
203 "movq %%mm1, %%mm2 \n\t" | |
204 "punpcklbw %%mm7, %%mm0 \n\t" | |
205 "punpcklbw %%mm7, %%mm1 \n\t" | |
206 "punpckhbw %%mm7, %%mm4 \n\t" | |
207 "punpckhbw %%mm7, %%mm2 \n\t" | |
208 "paddw %%mm1, %%mm0 \n\t" | |
209 "paddw %%mm2, %%mm4 \n\t" | |
210 "movq 1(%1, %%"REG_a"), %%mm2 \n\t" | |
211 "movq 1(%2, %%"REG_a"), %%mm3 \n\t" | |
212 "movq %%mm2, %%mm1 \n\t" | |
213 "punpcklbw %%mm7, %%mm2 \n\t" | |
214 "punpckhbw %%mm7, %%mm1 \n\t" | |
215 "paddw %%mm0, %%mm2 \n\t" | |
216 "paddw %%mm4, %%mm1 \n\t" | |
217 "movq %%mm3, %%mm4 \n\t" | |
218 "punpcklbw %%mm7, %%mm3 \n\t" | |
219 "punpckhbw %%mm7, %%mm4 \n\t" | |
220 "paddw %%mm3, %%mm2 \n\t" | |
221 "paddw %%mm4, %%mm1 \n\t" | |
222 "movq (%3, %%"REG_a"), %%mm3 \n\t" | |
223 "movq (%3, %%"REG_a"), %%mm4 \n\t" | |
224 "paddw %%mm5, %%mm2 \n\t" | |
225 "paddw %%mm5, %%mm1 \n\t" | |
226 "psrlw $2, %%mm2 \n\t" | |
227 "psrlw $2, %%mm1 \n\t" | |
228 "packuswb %%mm1, %%mm2 \n\t" | |
229 "psubusb %%mm2, %%mm3 \n\t" | |
230 "psubusb %%mm4, %%mm2 \n\t" | |
231 "por %%mm3, %%mm2 \n\t" | |
232 "movq %%mm2, %%mm0 \n\t" | |
233 "punpcklbw %%mm7, %%mm0 \n\t" | |
234 "punpckhbw %%mm7, %%mm2 \n\t" | |
235 "paddw %%mm2, %%mm0 \n\t" | |
236 "paddw %%mm0, %%mm6 \n\t" | |
237 "add %4, %%"REG_a" \n\t" | |
238 " js 1b \n\t" | |
294 | 239 : "+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
|
240 : "r" (blk1 - len), "r" (blk1 -len + stride), "r" (blk2 - len), "r" ((long)stride) |
294 | 241 ); |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
242 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
243 |
1057 | 244 static inline int sum_mmx(void) |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
245 { |
294 | 246 int ret; |
247 asm volatile( | |
2979 | 248 "movq %%mm6, %%mm0 \n\t" |
249 "psrlq $32, %%mm6 \n\t" | |
250 "paddw %%mm0, %%mm6 \n\t" | |
251 "movq %%mm6, %%mm0 \n\t" | |
252 "psrlq $16, %%mm6 \n\t" | |
253 "paddw %%mm0, %%mm6 \n\t" | |
254 "movd %%mm6, %0 \n\t" | |
294 | 255 : "=r" (ret) |
256 ); | |
257 return ret&0xFFFF; | |
258 } | |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
259 |
1057 | 260 static inline int sum_mmx2(void) |
294 | 261 { |
262 int ret; | |
263 asm volatile( | |
2979 | 264 "movd %%mm6, %0 \n\t" |
294 | 265 : "=r" (ret) |
266 ); | |
267 return ret; | |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
268 } |
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
269 |
900 | 270 |
294 | 271 #define PIX_SAD(suf)\ |
1708 | 272 static int sad8_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ |
273 {\ | |
274 assert(h==8);\ | |
2979 | 275 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
276 "pxor %%mm6, %%mm6 \n\t":);\ | |
1708 | 277 \ |
278 sad8_1_ ## suf(blk1, blk2, stride, 8);\ | |
279 \ | |
280 return sum_ ## suf();\ | |
281 }\ | |
282 static int sad8_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ | |
283 {\ | |
284 assert(h==8);\ | |
2979 | 285 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
286 "pxor %%mm6, %%mm6 \n\t"\ | |
287 "movq %0, %%mm5 \n\t"\ | |
1708 | 288 :: "m"(round_tab[1]) \ |
289 );\ | |
290 \ | |
291 sad8_2_ ## suf(blk1, blk1+1, blk2, stride, 8);\ | |
292 \ | |
293 return sum_ ## suf();\ | |
294 }\ | |
295 \ | |
296 static int sad8_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ | |
297 {\ | |
298 assert(h==8);\ | |
2979 | 299 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
300 "pxor %%mm6, %%mm6 \n\t"\ | |
301 "movq %0, %%mm5 \n\t"\ | |
1708 | 302 :: "m"(round_tab[1]) \ |
303 );\ | |
304 \ | |
305 sad8_2_ ## suf(blk1, blk1+stride, blk2, stride, 8);\ | |
306 \ | |
307 return sum_ ## suf();\ | |
308 }\ | |
309 \ | |
310 static int sad8_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ | |
311 {\ | |
312 assert(h==8);\ | |
2979 | 313 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
314 "pxor %%mm6, %%mm6 \n\t"\ | |
315 "movq %0, %%mm5 \n\t"\ | |
1708 | 316 :: "m"(round_tab[2]) \ |
317 );\ | |
318 \ | |
319 sad8_4_ ## suf(blk1, blk2, stride, 8);\ | |
320 \ | |
321 return sum_ ## suf();\ | |
322 }\ | |
323 \ | |
324 static int sad16_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ | |
294 | 325 {\ |
2979 | 326 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
327 "pxor %%mm6, %%mm6 \n\t":);\ | |
294 | 328 \ |
1708 | 329 sad8_1_ ## suf(blk1 , blk2 , stride, h);\ |
330 sad8_1_ ## suf(blk1+8, blk2+8, stride, h);\ | |
294 | 331 \ |
332 return sum_ ## suf();\ | |
333 }\ | |
1708 | 334 static int sad16_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ |
294 | 335 {\ |
2979 | 336 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
337 "pxor %%mm6, %%mm6 \n\t"\ | |
338 "movq %0, %%mm5 \n\t"\ | |
294 | 339 :: "m"(round_tab[1]) \ |
340 );\ | |
341 \ | |
1708 | 342 sad8_2_ ## suf(blk1 , blk1+1, blk2 , stride, h);\ |
343 sad8_2_ ## suf(blk1+8, blk1+9, blk2+8, stride, h);\ | |
294 | 344 \ |
345 return sum_ ## suf();\ | |
346 }\ | |
1708 | 347 static int sad16_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ |
294 | 348 {\ |
2979 | 349 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
350 "pxor %%mm6, %%mm6 \n\t"\ | |
351 "movq %0, %%mm5 \n\t"\ | |
294 | 352 :: "m"(round_tab[1]) \ |
353 );\ | |
354 \ | |
1708 | 355 sad8_2_ ## suf(blk1 , blk1+stride, blk2 , stride, h);\ |
356 sad8_2_ ## suf(blk1+8, blk1+stride+8,blk2+8, stride, h);\ | |
294 | 357 \ |
358 return sum_ ## suf();\ | |
359 }\ | |
1708 | 360 static int sad16_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\ |
294 | 361 {\ |
2979 | 362 asm volatile("pxor %%mm7, %%mm7 \n\t"\ |
363 "pxor %%mm6, %%mm6 \n\t"\ | |
364 "movq %0, %%mm5 \n\t"\ | |
294 | 365 :: "m"(round_tab[2]) \ |
366 );\ | |
367 \ | |
1708 | 368 sad8_4_ ## suf(blk1 , blk2 , stride, h);\ |
369 sad8_4_ ## suf(blk1+8, blk2+8, stride, h);\ | |
294 | 370 \ |
371 return sum_ ## suf();\ | |
372 }\ | |
72
3049d6d452a3
suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff
changeset
|
373 |
294 | 374 PIX_SAD(mmx) |
375 PIX_SAD(mmx2) | |
1057 | 376 |
1092 | 377 void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx) |
1057 | 378 { |
379 if (mm_flags & MM_MMX) { | |
1708 | 380 c->pix_abs[0][0] = sad16_mmx; |
381 c->pix_abs[0][1] = sad16_x2_mmx; | |
382 c->pix_abs[0][2] = sad16_y2_mmx; | |
383 c->pix_abs[0][3] = sad16_xy2_mmx; | |
384 c->pix_abs[1][0] = sad8_mmx; | |
385 c->pix_abs[1][1] = sad8_x2_mmx; | |
386 c->pix_abs[1][2] = sad8_y2_mmx; | |
387 c->pix_abs[1][3] = sad8_xy2_mmx; | |
1057 | 388 |
2979 | 389 c->sad[0]= sad16_mmx; |
1708 | 390 c->sad[1]= sad8_mmx; |
1057 | 391 } |
392 if (mm_flags & MM_MMXEXT) { | |
2979 | 393 c->pix_abs[0][0] = sad16_mmx2; |
394 c->pix_abs[1][0] = sad8_mmx2; | |
1057 | 395 |
2979 | 396 c->sad[0]= sad16_mmx2; |
397 c->sad[1]= sad8_mmx2; | |
2967 | 398 |
1092 | 399 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ |
1708 | 400 c->pix_abs[0][1] = sad16_x2_mmx2; |
401 c->pix_abs[0][2] = sad16_y2_mmx2; | |
402 c->pix_abs[0][3] = sad16_xy2_mmx2; | |
403 c->pix_abs[1][1] = sad8_x2_mmx2; | |
404 c->pix_abs[1][2] = sad8_y2_mmx2; | |
405 c->pix_abs[1][3] = sad8_xy2_mmx2; | |
1092 | 406 } |
1057 | 407 } |
408 } |