Mercurial > libavcodec.hg
annotate x86/dsputil_mmx.c @ 11589:fa81ba4670ea libavcodec
Print an error and skip PS when PS is found but explicitly found but
signaled to be absent.
author | alexc |
---|---|
date | Thu, 08 Apr 2010 06:27:35 +0000 |
parents | 2a4dc3c0b012 |
children | f7281af560fe |
rev | line source |
---|---|
8430 | 1 /* |
2 * MMX optimized DSP utils | |
8629
04423b2f6e0b
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
8596
diff
changeset
|
3 * Copyright (c) 2000, 2001 Fabrice Bellard |
8430 | 4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> |
5 * | |
6 * This file is part of FFmpeg. | |
7 * | |
8 * FFmpeg is free software; you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public | |
10 * License as published by the Free Software Foundation; either | |
11 * version 2.1 of the License, or (at your option) any later version. | |
12 * | |
13 * FFmpeg is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with FFmpeg; if not, write to the Free Software | |
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
21 * | |
22 * MMX optimization by Nick Kurshev <nickols_k@mail.ru> | |
23 */ | |
24 | |
25 #include "libavutil/x86_cpu.h" | |
26 #include "libavcodec/dsputil.h" | |
11499 | 27 #include "libavcodec/h264dsp.h" |
8430 | 28 #include "libavcodec/mpegvideo.h" |
29 #include "libavcodec/simple_idct.h" | |
30 #include "dsputil_mmx.h" | |
31 #include "vp3dsp_mmx.h" | |
32 #include "vp3dsp_sse2.h" | |
8817 | 33 #include "vp6dsp_mmx.h" |
8818 | 34 #include "vp6dsp_sse2.h" |
8430 | 35 #include "idct_xvid.h" |
36 | |
37 //#undef NDEBUG | |
38 //#include <assert.h> | |
39 | |
40 int mm_flags; /* multimedia extension flags */ | |
41 | |
42 /* pixel operations */ | |
11369 | 43 DECLARE_ALIGNED(8, const uint64_t, ff_bone) = 0x0101010101010101ULL; |
44 DECLARE_ALIGNED(8, const uint64_t, ff_wtwo) = 0x0002000200020002ULL; | |
8430 | 45 |
11369 | 46 DECLARE_ALIGNED(16, const uint64_t, ff_pdw_80000000)[2] = |
8430 | 47 {0x8000000080000000ULL, 0x8000000080000000ULL}; |
48 | |
11369 | 49 DECLARE_ALIGNED(8, const uint64_t, ff_pw_3 ) = 0x0003000300030003ULL; |
50 DECLARE_ALIGNED(8, const uint64_t, ff_pw_4 ) = 0x0004000400040004ULL; | |
51 DECLARE_ALIGNED(16, const xmm_reg, ff_pw_5 ) = {0x0005000500050005ULL, 0x0005000500050005ULL}; | |
52 DECLARE_ALIGNED(16, const xmm_reg, ff_pw_8 ) = {0x0008000800080008ULL, 0x0008000800080008ULL}; | |
53 DECLARE_ALIGNED(8, const uint64_t, ff_pw_15 ) = 0x000F000F000F000FULL; | |
54 DECLARE_ALIGNED(16, const xmm_reg, ff_pw_16 ) = {0x0010001000100010ULL, 0x0010001000100010ULL}; | |
55 DECLARE_ALIGNED(8, const uint64_t, ff_pw_20 ) = 0x0014001400140014ULL; | |
56 DECLARE_ALIGNED(16, const xmm_reg, ff_pw_28 ) = {0x001C001C001C001CULL, 0x001C001C001C001CULL}; | |
57 DECLARE_ALIGNED(16, const xmm_reg, ff_pw_32 ) = {0x0020002000200020ULL, 0x0020002000200020ULL}; | |
58 DECLARE_ALIGNED(8, const uint64_t, ff_pw_42 ) = 0x002A002A002A002AULL; | |
59 DECLARE_ALIGNED(16, const xmm_reg, ff_pw_64 ) = {0x0040004000400040ULL, 0x0040004000400040ULL}; | |
60 DECLARE_ALIGNED(8, const uint64_t, ff_pw_96 ) = 0x0060006000600060ULL; | |
61 DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL; | |
62 DECLARE_ALIGNED(8, const uint64_t, ff_pw_255) = 0x00ff00ff00ff00ffULL; | |
8430 | 63 |
11369 | 64 DECLARE_ALIGNED(8, const uint64_t, ff_pb_1 ) = 0x0101010101010101ULL; |
65 DECLARE_ALIGNED(8, const uint64_t, ff_pb_3 ) = 0x0303030303030303ULL; | |
66 DECLARE_ALIGNED(8, const uint64_t, ff_pb_7 ) = 0x0707070707070707ULL; | |
67 DECLARE_ALIGNED(8, const uint64_t, ff_pb_1F ) = 0x1F1F1F1F1F1F1F1FULL; | |
68 DECLARE_ALIGNED(8, const uint64_t, ff_pb_3F ) = 0x3F3F3F3F3F3F3F3FULL; | |
69 DECLARE_ALIGNED(8, const uint64_t, ff_pb_81 ) = 0x8181818181818181ULL; | |
70 DECLARE_ALIGNED(8, const uint64_t, ff_pb_A1 ) = 0xA1A1A1A1A1A1A1A1ULL; | |
71 DECLARE_ALIGNED(8, const uint64_t, ff_pb_FC ) = 0xFCFCFCFCFCFCFCFCULL; | |
8430 | 72 |
11369 | 73 DECLARE_ALIGNED(16, const double, ff_pd_1)[2] = { 1.0, 1.0 }; |
74 DECLARE_ALIGNED(16, const double, ff_pd_2)[2] = { 2.0, 2.0 }; | |
8430 | 75 |
76 #define JUMPALIGN() __asm__ volatile (ASMALIGN(3)::) | |
77 #define MOVQ_ZERO(regd) __asm__ volatile ("pxor %%" #regd ", %%" #regd ::) | |
78 | |
79 #define MOVQ_BFE(regd) \ | |
80 __asm__ volatile ( \ | |
81 "pcmpeqd %%" #regd ", %%" #regd " \n\t"\ | |
82 "paddb %%" #regd ", %%" #regd " \n\t" ::) | |
83 | |
84 #ifndef PIC | |
85 #define MOVQ_BONE(regd) __asm__ volatile ("movq %0, %%" #regd " \n\t" ::"m"(ff_bone)) | |
86 #define MOVQ_WTWO(regd) __asm__ volatile ("movq %0, %%" #regd " \n\t" ::"m"(ff_wtwo)) | |
87 #else | |
88 // for shared library it's better to use this way for accessing constants | |
89 // pcmpeqd -> -1 | |
90 #define MOVQ_BONE(regd) \ | |
91 __asm__ volatile ( \ | |
92 "pcmpeqd %%" #regd ", %%" #regd " \n\t" \ | |
93 "psrlw $15, %%" #regd " \n\t" \ | |
94 "packuswb %%" #regd ", %%" #regd " \n\t" ::) | |
95 | |
96 #define MOVQ_WTWO(regd) \ | |
97 __asm__ volatile ( \ | |
98 "pcmpeqd %%" #regd ", %%" #regd " \n\t" \ | |
99 "psrlw $15, %%" #regd " \n\t" \ | |
100 "psllw $1, %%" #regd " \n\t"::) | |
101 | |
102 #endif | |
103 | |
104 // using regr as temporary and for the output result | |
105 // first argument is unmodifed and second is trashed | |
106 // regfe is supposed to contain 0xfefefefefefefefe | |
107 #define PAVGB_MMX_NO_RND(rega, regb, regr, regfe) \ | |
108 "movq " #rega ", " #regr " \n\t"\ | |
109 "pand " #regb ", " #regr " \n\t"\ | |
110 "pxor " #rega ", " #regb " \n\t"\ | |
111 "pand " #regfe "," #regb " \n\t"\ | |
112 "psrlq $1, " #regb " \n\t"\ | |
113 "paddb " #regb ", " #regr " \n\t" | |
114 | |
115 #define PAVGB_MMX(rega, regb, regr, regfe) \ | |
116 "movq " #rega ", " #regr " \n\t"\ | |
117 "por " #regb ", " #regr " \n\t"\ | |
118 "pxor " #rega ", " #regb " \n\t"\ | |
119 "pand " #regfe "," #regb " \n\t"\ | |
120 "psrlq $1, " #regb " \n\t"\ | |
121 "psubb " #regb ", " #regr " \n\t" | |
122 | |
123 // mm6 is supposed to contain 0xfefefefefefefefe | |
124 #define PAVGBP_MMX_NO_RND(rega, regb, regr, regc, regd, regp) \ | |
125 "movq " #rega ", " #regr " \n\t"\ | |
126 "movq " #regc ", " #regp " \n\t"\ | |
127 "pand " #regb ", " #regr " \n\t"\ | |
128 "pand " #regd ", " #regp " \n\t"\ | |
129 "pxor " #rega ", " #regb " \n\t"\ | |
130 "pxor " #regc ", " #regd " \n\t"\ | |
131 "pand %%mm6, " #regb " \n\t"\ | |
132 "pand %%mm6, " #regd " \n\t"\ | |
133 "psrlq $1, " #regb " \n\t"\ | |
134 "psrlq $1, " #regd " \n\t"\ | |
135 "paddb " #regb ", " #regr " \n\t"\ | |
136 "paddb " #regd ", " #regp " \n\t" | |
137 | |
138 #define PAVGBP_MMX(rega, regb, regr, regc, regd, regp) \ | |
139 "movq " #rega ", " #regr " \n\t"\ | |
140 "movq " #regc ", " #regp " \n\t"\ | |
141 "por " #regb ", " #regr " \n\t"\ | |
142 "por " #regd ", " #regp " \n\t"\ | |
143 "pxor " #rega ", " #regb " \n\t"\ | |
144 "pxor " #regc ", " #regd " \n\t"\ | |
145 "pand %%mm6, " #regb " \n\t"\ | |
146 "pand %%mm6, " #regd " \n\t"\ | |
147 "psrlq $1, " #regd " \n\t"\ | |
148 "psrlq $1, " #regb " \n\t"\ | |
149 "psubb " #regb ", " #regr " \n\t"\ | |
150 "psubb " #regd ", " #regp " \n\t" | |
151 | |
152 /***********************************/ | |
153 /* MMX no rounding */ | |
154 #define DEF(x, y) x ## _no_rnd_ ## y ##_mmx | |
155 #define SET_RND MOVQ_WONE | |
156 #define PAVGBP(a, b, c, d, e, f) PAVGBP_MMX_NO_RND(a, b, c, d, e, f) | |
157 #define PAVGB(a, b, c, e) PAVGB_MMX_NO_RND(a, b, c, e) | |
9445
41245484dc0b
avg_ pixel functions need to use (dst+pix+1)>>1 to average with existing
conrad
parents:
9441
diff
changeset
|
158 #define OP_AVG(a, b, c, e) PAVGB_MMX(a, b, c, e) |
8430 | 159 |
160 #include "dsputil_mmx_rnd_template.c" | |
161 | |
162 #undef DEF | |
163 #undef SET_RND | |
164 #undef PAVGBP | |
165 #undef PAVGB | |
166 /***********************************/ | |
167 /* MMX rounding */ | |
168 | |
169 #define DEF(x, y) x ## _ ## y ##_mmx | |
170 #define SET_RND MOVQ_WTWO | |
171 #define PAVGBP(a, b, c, d, e, f) PAVGBP_MMX(a, b, c, d, e, f) | |
172 #define PAVGB(a, b, c, e) PAVGB_MMX(a, b, c, e) | |
173 | |
174 #include "dsputil_mmx_rnd_template.c" | |
175 | |
176 #undef DEF | |
177 #undef SET_RND | |
178 #undef PAVGBP | |
179 #undef PAVGB | |
9445
41245484dc0b
avg_ pixel functions need to use (dst+pix+1)>>1 to average with existing
conrad
parents:
9441
diff
changeset
|
180 #undef OP_AVG |
8430 | 181 |
182 /***********************************/ | |
183 /* 3Dnow specific */ | |
184 | |
185 #define DEF(x) x ## _3dnow | |
186 #define PAVGB "pavgusb" | |
9445
41245484dc0b
avg_ pixel functions need to use (dst+pix+1)>>1 to average with existing
conrad
parents:
9441
diff
changeset
|
187 #define OP_AVG PAVGB |
8430 | 188 |
189 #include "dsputil_mmx_avg_template.c" | |
190 | |
191 #undef DEF | |
192 #undef PAVGB | |
9445
41245484dc0b
avg_ pixel functions need to use (dst+pix+1)>>1 to average with existing
conrad
parents:
9441
diff
changeset
|
193 #undef OP_AVG |
8430 | 194 |
195 /***********************************/ | |
196 /* MMX2 specific */ | |
197 | |
198 #define DEF(x) x ## _mmx2 | |
199 | |
200 /* Introduced only in MMX2 set */ | |
201 #define PAVGB "pavgb" | |
9445
41245484dc0b
avg_ pixel functions need to use (dst+pix+1)>>1 to average with existing
conrad
parents:
9441
diff
changeset
|
202 #define OP_AVG PAVGB |
8430 | 203 |
204 #include "dsputil_mmx_avg_template.c" | |
205 | |
206 #undef DEF | |
207 #undef PAVGB | |
9445
41245484dc0b
avg_ pixel functions need to use (dst+pix+1)>>1 to average with existing
conrad
parents:
9441
diff
changeset
|
208 #undef OP_AVG |
8430 | 209 |
210 #define put_no_rnd_pixels16_mmx put_pixels16_mmx | |
211 #define put_no_rnd_pixels8_mmx put_pixels8_mmx | |
212 #define put_pixels16_mmx2 put_pixels16_mmx | |
213 #define put_pixels8_mmx2 put_pixels8_mmx | |
214 #define put_pixels4_mmx2 put_pixels4_mmx | |
215 #define put_no_rnd_pixels16_mmx2 put_no_rnd_pixels16_mmx | |
216 #define put_no_rnd_pixels8_mmx2 put_no_rnd_pixels8_mmx | |
217 #define put_pixels16_3dnow put_pixels16_mmx | |
218 #define put_pixels8_3dnow put_pixels8_mmx | |
219 #define put_pixels4_3dnow put_pixels4_mmx | |
220 #define put_no_rnd_pixels16_3dnow put_no_rnd_pixels16_mmx | |
221 #define put_no_rnd_pixels8_3dnow put_no_rnd_pixels8_mmx | |
222 | |
223 /***********************************/ | |
224 /* standard MMX */ | |
225 | |
226 void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size) | |
227 { | |
228 const DCTELEM *p; | |
229 uint8_t *pix; | |
230 | |
231 /* read the pixels */ | |
232 p = block; | |
233 pix = pixels; | |
234 /* unrolled loop */ | |
235 __asm__ volatile( | |
236 "movq %3, %%mm0 \n\t" | |
237 "movq 8%3, %%mm1 \n\t" | |
238 "movq 16%3, %%mm2 \n\t" | |
239 "movq 24%3, %%mm3 \n\t" | |
240 "movq 32%3, %%mm4 \n\t" | |
241 "movq 40%3, %%mm5 \n\t" | |
242 "movq 48%3, %%mm6 \n\t" | |
243 "movq 56%3, %%mm7 \n\t" | |
244 "packuswb %%mm1, %%mm0 \n\t" | |
245 "packuswb %%mm3, %%mm2 \n\t" | |
246 "packuswb %%mm5, %%mm4 \n\t" | |
247 "packuswb %%mm7, %%mm6 \n\t" | |
248 "movq %%mm0, (%0) \n\t" | |
249 "movq %%mm2, (%0, %1) \n\t" | |
250 "movq %%mm4, (%0, %1, 2) \n\t" | |
251 "movq %%mm6, (%0, %2) \n\t" | |
252 ::"r" (pix), "r" ((x86_reg)line_size), "r" ((x86_reg)line_size*3), "m"(*p) | |
253 :"memory"); | |
254 pix += line_size*4; | |
255 p += 32; | |
256 | |
257 // if here would be an exact copy of the code above | |
258 // compiler would generate some very strange code | |
259 // thus using "r" | |
260 __asm__ volatile( | |
261 "movq (%3), %%mm0 \n\t" | |
262 "movq 8(%3), %%mm1 \n\t" | |
263 "movq 16(%3), %%mm2 \n\t" | |
264 "movq 24(%3), %%mm3 \n\t" | |
265 "movq 32(%3), %%mm4 \n\t" | |
266 "movq 40(%3), %%mm5 \n\t" | |
267 "movq 48(%3), %%mm6 \n\t" | |
268 "movq 56(%3), %%mm7 \n\t" | |
269 "packuswb %%mm1, %%mm0 \n\t" | |
270 "packuswb %%mm3, %%mm2 \n\t" | |
271 "packuswb %%mm5, %%mm4 \n\t" | |
272 "packuswb %%mm7, %%mm6 \n\t" | |
273 "movq %%mm0, (%0) \n\t" | |
274 "movq %%mm2, (%0, %1) \n\t" | |
275 "movq %%mm4, (%0, %1, 2) \n\t" | |
276 "movq %%mm6, (%0, %2) \n\t" | |
277 ::"r" (pix), "r" ((x86_reg)line_size), "r" ((x86_reg)line_size*3), "r"(p) | |
278 :"memory"); | |
279 } | |
280 | |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10766
diff
changeset
|
281 DECLARE_ASM_CONST(8, uint8_t, ff_vector128)[8] = |
8430 | 282 { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; |
283 | |
9337
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
284 #define put_signed_pixels_clamped_mmx_half(off) \ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
285 "movq "#off"(%2), %%mm1 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
286 "movq 16+"#off"(%2), %%mm2 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
287 "movq 32+"#off"(%2), %%mm3 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
288 "movq 48+"#off"(%2), %%mm4 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
289 "packsswb 8+"#off"(%2), %%mm1 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
290 "packsswb 24+"#off"(%2), %%mm2 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
291 "packsswb 40+"#off"(%2), %%mm3 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
292 "packsswb 56+"#off"(%2), %%mm4 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
293 "paddb %%mm0, %%mm1 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
294 "paddb %%mm0, %%mm2 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
295 "paddb %%mm0, %%mm3 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
296 "paddb %%mm0, %%mm4 \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
297 "movq %%mm1, (%0) \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
298 "movq %%mm2, (%0, %3) \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
299 "movq %%mm3, (%0, %3, 2) \n\t"\ |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
300 "movq %%mm4, (%0, %1) \n\t" |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
301 |
8430 | 302 void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size) |
303 { | |
9337
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
304 x86_reg line_skip = line_size; |
9341
06532529c428
Mark line_skip3 asm argument as output-only instead of using av_uninit.
reimar
parents:
9340
diff
changeset
|
305 x86_reg line_skip3; |
8430 | 306 |
9337
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
307 __asm__ volatile ( |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
308 "movq "MANGLE(ff_vector128)", %%mm0 \n\t" |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
309 "lea (%3, %3, 2), %1 \n\t" |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
310 put_signed_pixels_clamped_mmx_half(0) |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
311 "lea (%0, %3, 4), %0 \n\t" |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
312 put_signed_pixels_clamped_mmx_half(64) |
9341
06532529c428
Mark line_skip3 asm argument as output-only instead of using av_uninit.
reimar
parents:
9340
diff
changeset
|
313 :"+&r" (pixels), "=&r" (line_skip3) |
9337
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
314 :"r" (block), "r"(line_skip) |
a0d54042ea37
Rewrite put_signed_pixels_clamped_mmx() to eliminate mmx.h from dsputil_mmx.c.
alexc
parents:
8818
diff
changeset
|
315 :"memory"); |
8430 | 316 } |
317 | |
318 void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size) | |
319 { | |
320 const DCTELEM *p; | |
321 uint8_t *pix; | |
322 int i; | |
323 | |
324 /* read the pixels */ | |
325 p = block; | |
326 pix = pixels; | |
327 MOVQ_ZERO(mm7); | |
328 i = 4; | |
329 do { | |
330 __asm__ volatile( | |
331 "movq (%2), %%mm0 \n\t" | |
332 "movq 8(%2), %%mm1 \n\t" | |
333 "movq 16(%2), %%mm2 \n\t" | |
334 "movq 24(%2), %%mm3 \n\t" | |
335 "movq %0, %%mm4 \n\t" | |
336 "movq %1, %%mm6 \n\t" | |
337 "movq %%mm4, %%mm5 \n\t" | |
338 "punpcklbw %%mm7, %%mm4 \n\t" | |
339 "punpckhbw %%mm7, %%mm5 \n\t" | |
340 "paddsw %%mm4, %%mm0 \n\t" | |
341 "paddsw %%mm5, %%mm1 \n\t" | |
342 "movq %%mm6, %%mm5 \n\t" | |
343 "punpcklbw %%mm7, %%mm6 \n\t" | |
344 "punpckhbw %%mm7, %%mm5 \n\t" | |
345 "paddsw %%mm6, %%mm2 \n\t" | |
346 "paddsw %%mm5, %%mm3 \n\t" | |
347 "packuswb %%mm1, %%mm0 \n\t" | |
348 "packuswb %%mm3, %%mm2 \n\t" | |
349 "movq %%mm0, %0 \n\t" | |
350 "movq %%mm2, %1 \n\t" | |
351 :"+m"(*pix), "+m"(*(pix+line_size)) | |
352 :"r"(p) | |
353 :"memory"); | |
354 pix += line_size*2; | |
355 p += 16; | |
356 } while (--i); | |
357 } | |
358 | |
359 static void put_pixels4_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h) | |
360 { | |
361 __asm__ volatile( | |
362 "lea (%3, %3), %%"REG_a" \n\t" | |
363 ASMALIGN(3) | |
364 "1: \n\t" | |
365 "movd (%1), %%mm0 \n\t" | |
366 "movd (%1, %3), %%mm1 \n\t" | |
367 "movd %%mm0, (%2) \n\t" | |
368 "movd %%mm1, (%2, %3) \n\t" | |
369 "add %%"REG_a", %1 \n\t" | |
370 "add %%"REG_a", %2 \n\t" | |
371 "movd (%1), %%mm0 \n\t" | |
372 "movd (%1, %3), %%mm1 \n\t" | |
373 "movd %%mm0, (%2) \n\t" | |
374 "movd %%mm1, (%2, %3) \n\t" | |
375 "add %%"REG_a", %1 \n\t" | |
376 "add %%"REG_a", %2 \n\t" | |
377 "subl $4, %0 \n\t" | |
378 "jnz 1b \n\t" | |
379 : "+g"(h), "+r" (pixels), "+r" (block) | |
380 : "r"((x86_reg)line_size) | |
381 : "%"REG_a, "memory" | |
382 ); | |
383 } | |
384 | |
385 static void put_pixels8_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h) | |
386 { | |
387 __asm__ volatile( | |
388 "lea (%3, %3), %%"REG_a" \n\t" | |
389 ASMALIGN(3) | |
390 "1: \n\t" | |
391 "movq (%1), %%mm0 \n\t" | |
392 "movq (%1, %3), %%mm1 \n\t" | |
393 "movq %%mm0, (%2) \n\t" | |
394 "movq %%mm1, (%2, %3) \n\t" | |
395 "add %%"REG_a", %1 \n\t" | |
396 "add %%"REG_a", %2 \n\t" | |
397 "movq (%1), %%mm0 \n\t" | |
398 "movq (%1, %3), %%mm1 \n\t" | |
399 "movq %%mm0, (%2) \n\t" | |
400 "movq %%mm1, (%2, %3) \n\t" | |
401 "add %%"REG_a", %1 \n\t" | |
402 "add %%"REG_a", %2 \n\t" | |
403 "subl $4, %0 \n\t" | |
404 "jnz 1b \n\t" | |
405 : "+g"(h), "+r" (pixels), "+r" (block) | |
406 : "r"((x86_reg)line_size) | |
407 : "%"REG_a, "memory" | |
408 ); | |
409 } | |
410 | |
411 static void put_pixels16_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h) | |
412 { | |
413 __asm__ volatile( | |
414 "lea (%3, %3), %%"REG_a" \n\t" | |
415 ASMALIGN(3) | |
416 "1: \n\t" | |
417 "movq (%1), %%mm0 \n\t" | |
418 "movq 8(%1), %%mm4 \n\t" | |
419 "movq (%1, %3), %%mm1 \n\t" | |
420 "movq 8(%1, %3), %%mm5 \n\t" | |
421 "movq %%mm0, (%2) \n\t" | |
422 "movq %%mm4, 8(%2) \n\t" | |
423 "movq %%mm1, (%2, %3) \n\t" | |
424 "movq %%mm5, 8(%2, %3) \n\t" | |
425 "add %%"REG_a", %1 \n\t" | |
426 "add %%"REG_a", %2 \n\t" | |
427 "movq (%1), %%mm0 \n\t" | |
428 "movq 8(%1), %%mm4 \n\t" | |
429 "movq (%1, %3), %%mm1 \n\t" | |
430 "movq 8(%1, %3), %%mm5 \n\t" | |
431 "movq %%mm0, (%2) \n\t" | |
432 "movq %%mm4, 8(%2) \n\t" | |
433 "movq %%mm1, (%2, %3) \n\t" | |
434 "movq %%mm5, 8(%2, %3) \n\t" | |
435 "add %%"REG_a", %1 \n\t" | |
436 "add %%"REG_a", %2 \n\t" | |
437 "subl $4, %0 \n\t" | |
438 "jnz 1b \n\t" | |
439 : "+g"(h), "+r" (pixels), "+r" (block) | |
440 : "r"((x86_reg)line_size) | |
441 : "%"REG_a, "memory" | |
442 ); | |
443 } | |
444 | |
445 static void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) | |
446 { | |
447 __asm__ volatile( | |
448 "1: \n\t" | |
449 "movdqu (%1), %%xmm0 \n\t" | |
450 "movdqu (%1,%3), %%xmm1 \n\t" | |
451 "movdqu (%1,%3,2), %%xmm2 \n\t" | |
452 "movdqu (%1,%4), %%xmm3 \n\t" | |
453 "movdqa %%xmm0, (%2) \n\t" | |
454 "movdqa %%xmm1, (%2,%3) \n\t" | |
455 "movdqa %%xmm2, (%2,%3,2) \n\t" | |
456 "movdqa %%xmm3, (%2,%4) \n\t" | |
457 "subl $4, %0 \n\t" | |
458 "lea (%1,%3,4), %1 \n\t" | |
459 "lea (%2,%3,4), %2 \n\t" | |
460 "jnz 1b \n\t" | |
461 : "+g"(h), "+r" (pixels), "+r" (block) | |
462 : "r"((x86_reg)line_size), "r"((x86_reg)3L*line_size) | |
463 : "memory" | |
464 ); | |
465 } | |
466 | |
467 static void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, int line_size, int h) | |
468 { | |
469 __asm__ volatile( | |
470 "1: \n\t" | |
471 "movdqu (%1), %%xmm0 \n\t" | |
472 "movdqu (%1,%3), %%xmm1 \n\t" | |
473 "movdqu (%1,%3,2), %%xmm2 \n\t" | |
474 "movdqu (%1,%4), %%xmm3 \n\t" | |
475 "pavgb (%2), %%xmm0 \n\t" | |
476 "pavgb (%2,%3), %%xmm1 \n\t" | |
477 "pavgb (%2,%3,2), %%xmm2 \n\t" | |
478 "pavgb (%2,%4), %%xmm3 \n\t" | |
479 "movdqa %%xmm0, (%2) \n\t" | |
480 "movdqa %%xmm1, (%2,%3) \n\t" | |
481 "movdqa %%xmm2, (%2,%3,2) \n\t" | |
482 "movdqa %%xmm3, (%2,%4) \n\t" | |
483 "subl $4, %0 \n\t" | |
484 "lea (%1,%3,4), %1 \n\t" | |
485 "lea (%2,%3,4), %2 \n\t" | |
486 "jnz 1b \n\t" | |
487 : "+g"(h), "+r" (pixels), "+r" (block) | |
488 : "r"((x86_reg)line_size), "r"((x86_reg)3L*line_size) | |
489 : "memory" | |
490 ); | |
491 } | |
492 | |
493 #define CLEAR_BLOCKS(name,n) \ | |
494 static void name(DCTELEM *blocks)\ | |
495 {\ | |
496 __asm__ volatile(\ | |
497 "pxor %%mm7, %%mm7 \n\t"\ | |
498 "mov %1, %%"REG_a" \n\t"\ | |
499 "1: \n\t"\ | |
500 "movq %%mm7, (%0, %%"REG_a") \n\t"\ | |
501 "movq %%mm7, 8(%0, %%"REG_a") \n\t"\ | |
502 "movq %%mm7, 16(%0, %%"REG_a") \n\t"\ | |
503 "movq %%mm7, 24(%0, %%"REG_a") \n\t"\ | |
504 "add $32, %%"REG_a" \n\t"\ | |
505 " js 1b \n\t"\ | |
506 : : "r" (((uint8_t *)blocks)+128*n),\ | |
507 "i" (-128*n)\ | |
508 : "%"REG_a\ | |
509 );\ | |
510 } | |
511 CLEAR_BLOCKS(clear_blocks_mmx, 6) | |
512 CLEAR_BLOCKS(clear_block_mmx, 1) | |
513 | |
514 static void clear_block_sse(DCTELEM *block) | |
515 { | |
516 __asm__ volatile( | |
517 "xorps %%xmm0, %%xmm0 \n" | |
518 "movaps %%xmm0, (%0) \n" | |
519 "movaps %%xmm0, 16(%0) \n" | |
520 "movaps %%xmm0, 32(%0) \n" | |
521 "movaps %%xmm0, 48(%0) \n" | |
522 "movaps %%xmm0, 64(%0) \n" | |
523 "movaps %%xmm0, 80(%0) \n" | |
524 "movaps %%xmm0, 96(%0) \n" | |
525 "movaps %%xmm0, 112(%0) \n" | |
526 :: "r"(block) | |
527 : "memory" | |
528 ); | |
529 } | |
530 | |
9861 | 531 static void clear_blocks_sse(DCTELEM *blocks) |
532 {\ | |
533 __asm__ volatile( | |
534 "xorps %%xmm0, %%xmm0 \n" | |
535 "mov %1, %%"REG_a" \n" | |
536 "1: \n" | |
537 "movaps %%xmm0, (%0, %%"REG_a") \n" | |
538 "movaps %%xmm0, 16(%0, %%"REG_a") \n" | |
539 "movaps %%xmm0, 32(%0, %%"REG_a") \n" | |
540 "movaps %%xmm0, 48(%0, %%"REG_a") \n" | |
541 "movaps %%xmm0, 64(%0, %%"REG_a") \n" | |
542 "movaps %%xmm0, 80(%0, %%"REG_a") \n" | |
543 "movaps %%xmm0, 96(%0, %%"REG_a") \n" | |
544 "movaps %%xmm0, 112(%0, %%"REG_a") \n" | |
545 "add $128, %%"REG_a" \n" | |
546 " js 1b \n" | |
547 : : "r" (((uint8_t *)blocks)+128*6), | |
548 "i" (-128*6) | |
549 : "%"REG_a | |
550 ); | |
551 } | |
552 | |
8430 | 553 static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w){ |
554 x86_reg i=0; | |
555 __asm__ volatile( | |
556 "jmp 2f \n\t" | |
557 "1: \n\t" | |
558 "movq (%1, %0), %%mm0 \n\t" | |
559 "movq (%2, %0), %%mm1 \n\t" | |
560 "paddb %%mm0, %%mm1 \n\t" | |
561 "movq %%mm1, (%2, %0) \n\t" | |
562 "movq 8(%1, %0), %%mm0 \n\t" | |
563 "movq 8(%2, %0), %%mm1 \n\t" | |
564 "paddb %%mm0, %%mm1 \n\t" | |
565 "movq %%mm1, 8(%2, %0) \n\t" | |
566 "add $16, %0 \n\t" | |
567 "2: \n\t" | |
568 "cmp %3, %0 \n\t" | |
569 " js 1b \n\t" | |
570 : "+r" (i) | |
571 : "r"(src), "r"(dst), "r"((x86_reg)w-15) | |
572 ); | |
573 for(; i<w; i++) | |
574 dst[i+0] += src[i+0]; | |
575 } | |
576 | |
577 static void add_bytes_l2_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ | |
578 x86_reg i=0; | |
579 __asm__ volatile( | |
580 "jmp 2f \n\t" | |
581 "1: \n\t" | |
582 "movq (%2, %0), %%mm0 \n\t" | |
583 "movq 8(%2, %0), %%mm1 \n\t" | |
584 "paddb (%3, %0), %%mm0 \n\t" | |
585 "paddb 8(%3, %0), %%mm1 \n\t" | |
586 "movq %%mm0, (%1, %0) \n\t" | |
587 "movq %%mm1, 8(%1, %0) \n\t" | |
588 "add $16, %0 \n\t" | |
589 "2: \n\t" | |
590 "cmp %4, %0 \n\t" | |
591 " js 1b \n\t" | |
592 : "+r" (i) | |
593 : "r"(dst), "r"(src1), "r"(src2), "r"((x86_reg)w-15) | |
594 ); | |
595 for(; i<w; i++) | |
596 dst[i] = src1[i] + src2[i]; | |
597 } | |
598 | |
8798
a5c8210814d7
Add check whether the compiler/assembler supports 10 or more operands.
diego
parents:
8760
diff
changeset
|
599 #if HAVE_7REGS && HAVE_TEN_OPERANDS |
10431 | 600 static void add_hfyu_median_prediction_cmov(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top) { |
8760 | 601 x86_reg w2 = -w; |
602 x86_reg x; | |
603 int l = *left & 0xff; | |
604 int tl = *left_top & 0xff; | |
605 int t; | |
606 __asm__ volatile( | |
607 "mov %7, %3 \n" | |
608 "1: \n" | |
609 "movzx (%3,%4), %2 \n" | |
610 "mov %2, %k3 \n" | |
611 "sub %b1, %b3 \n" | |
612 "add %b0, %b3 \n" | |
613 "mov %2, %1 \n" | |
614 "cmp %0, %2 \n" | |
615 "cmovg %0, %2 \n" | |
616 "cmovg %1, %0 \n" | |
617 "cmp %k3, %0 \n" | |
618 "cmovg %k3, %0 \n" | |
619 "mov %7, %3 \n" | |
620 "cmp %2, %0 \n" | |
621 "cmovl %2, %0 \n" | |
622 "add (%6,%4), %b0 \n" | |
623 "mov %b0, (%5,%4) \n" | |
624 "inc %4 \n" | |
625 "jl 1b \n" | |
626 :"+&q"(l), "+&q"(tl), "=&r"(t), "=&q"(x), "+&r"(w2) | |
627 :"r"(dst+w), "r"(diff+w), "rm"(top+w) | |
628 ); | |
629 *left = l; | |
630 *left_top = tl; | |
631 } | |
632 #endif | |
633 | |
8430 | 634 #define H263_LOOP_FILTER \ |
635 "pxor %%mm7, %%mm7 \n\t"\ | |
636 "movq %0, %%mm0 \n\t"\ | |
637 "movq %0, %%mm1 \n\t"\ | |
638 "movq %3, %%mm2 \n\t"\ | |
639 "movq %3, %%mm3 \n\t"\ | |
640 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
641 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
642 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
643 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
644 "psubw %%mm2, %%mm0 \n\t"\ | |
645 "psubw %%mm3, %%mm1 \n\t"\ | |
646 "movq %1, %%mm2 \n\t"\ | |
647 "movq %1, %%mm3 \n\t"\ | |
648 "movq %2, %%mm4 \n\t"\ | |
649 "movq %2, %%mm5 \n\t"\ | |
650 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
651 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
652 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
653 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
654 "psubw %%mm2, %%mm4 \n\t"\ | |
655 "psubw %%mm3, %%mm5 \n\t"\ | |
656 "psllw $2, %%mm4 \n\t"\ | |
657 "psllw $2, %%mm5 \n\t"\ | |
658 "paddw %%mm0, %%mm4 \n\t"\ | |
659 "paddw %%mm1, %%mm5 \n\t"\ | |
660 "pxor %%mm6, %%mm6 \n\t"\ | |
661 "pcmpgtw %%mm4, %%mm6 \n\t"\ | |
662 "pcmpgtw %%mm5, %%mm7 \n\t"\ | |
663 "pxor %%mm6, %%mm4 \n\t"\ | |
664 "pxor %%mm7, %%mm5 \n\t"\ | |
665 "psubw %%mm6, %%mm4 \n\t"\ | |
666 "psubw %%mm7, %%mm5 \n\t"\ | |
667 "psrlw $3, %%mm4 \n\t"\ | |
668 "psrlw $3, %%mm5 \n\t"\ | |
669 "packuswb %%mm5, %%mm4 \n\t"\ | |
670 "packsswb %%mm7, %%mm6 \n\t"\ | |
671 "pxor %%mm7, %%mm7 \n\t"\ | |
672 "movd %4, %%mm2 \n\t"\ | |
673 "punpcklbw %%mm2, %%mm2 \n\t"\ | |
674 "punpcklbw %%mm2, %%mm2 \n\t"\ | |
675 "punpcklbw %%mm2, %%mm2 \n\t"\ | |
676 "psubusb %%mm4, %%mm2 \n\t"\ | |
677 "movq %%mm2, %%mm3 \n\t"\ | |
678 "psubusb %%mm4, %%mm3 \n\t"\ | |
679 "psubb %%mm3, %%mm2 \n\t"\ | |
680 "movq %1, %%mm3 \n\t"\ | |
681 "movq %2, %%mm4 \n\t"\ | |
682 "pxor %%mm6, %%mm3 \n\t"\ | |
683 "pxor %%mm6, %%mm4 \n\t"\ | |
684 "paddusb %%mm2, %%mm3 \n\t"\ | |
685 "psubusb %%mm2, %%mm4 \n\t"\ | |
686 "pxor %%mm6, %%mm3 \n\t"\ | |
687 "pxor %%mm6, %%mm4 \n\t"\ | |
688 "paddusb %%mm2, %%mm2 \n\t"\ | |
689 "packsswb %%mm1, %%mm0 \n\t"\ | |
690 "pcmpgtb %%mm0, %%mm7 \n\t"\ | |
691 "pxor %%mm7, %%mm0 \n\t"\ | |
692 "psubb %%mm7, %%mm0 \n\t"\ | |
693 "movq %%mm0, %%mm1 \n\t"\ | |
694 "psubusb %%mm2, %%mm0 \n\t"\ | |
695 "psubb %%mm0, %%mm1 \n\t"\ | |
696 "pand %5, %%mm1 \n\t"\ | |
697 "psrlw $2, %%mm1 \n\t"\ | |
698 "pxor %%mm7, %%mm1 \n\t"\ | |
699 "psubb %%mm7, %%mm1 \n\t"\ | |
700 "movq %0, %%mm5 \n\t"\ | |
701 "movq %3, %%mm6 \n\t"\ | |
702 "psubb %%mm1, %%mm5 \n\t"\ | |
703 "paddb %%mm1, %%mm6 \n\t" | |
704 | |
705 static void h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale){ | |
10749
5cca4b6c459d
Get rid of pointless CONFIG_ANY_H263 preprocessor definition.
diego
parents:
10645
diff
changeset
|
706 if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { |
8430 | 707 const int strength= ff_h263_loop_filter_strength[qscale]; |
708 | |
709 __asm__ volatile( | |
710 | |
711 H263_LOOP_FILTER | |
712 | |
713 "movq %%mm3, %1 \n\t" | |
714 "movq %%mm4, %2 \n\t" | |
715 "movq %%mm5, %0 \n\t" | |
716 "movq %%mm6, %3 \n\t" | |
717 : "+m" (*(uint64_t*)(src - 2*stride)), | |
718 "+m" (*(uint64_t*)(src - 1*stride)), | |
719 "+m" (*(uint64_t*)(src + 0*stride)), | |
720 "+m" (*(uint64_t*)(src + 1*stride)) | |
721 : "g" (2*strength), "m"(ff_pb_FC) | |
722 ); | |
723 } | |
724 } | |
725 | |
726 static inline void transpose4x4(uint8_t *dst, uint8_t *src, int dst_stride, int src_stride){ | |
727 __asm__ volatile( //FIXME could save 1 instruction if done as 8x4 ... | |
728 "movd %4, %%mm0 \n\t" | |
729 "movd %5, %%mm1 \n\t" | |
730 "movd %6, %%mm2 \n\t" | |
731 "movd %7, %%mm3 \n\t" | |
732 "punpcklbw %%mm1, %%mm0 \n\t" | |
733 "punpcklbw %%mm3, %%mm2 \n\t" | |
734 "movq %%mm0, %%mm1 \n\t" | |
735 "punpcklwd %%mm2, %%mm0 \n\t" | |
736 "punpckhwd %%mm2, %%mm1 \n\t" | |
737 "movd %%mm0, %0 \n\t" | |
738 "punpckhdq %%mm0, %%mm0 \n\t" | |
739 "movd %%mm0, %1 \n\t" | |
740 "movd %%mm1, %2 \n\t" | |
741 "punpckhdq %%mm1, %%mm1 \n\t" | |
742 "movd %%mm1, %3 \n\t" | |
743 | |
744 : "=m" (*(uint32_t*)(dst + 0*dst_stride)), | |
745 "=m" (*(uint32_t*)(dst + 1*dst_stride)), | |
746 "=m" (*(uint32_t*)(dst + 2*dst_stride)), | |
747 "=m" (*(uint32_t*)(dst + 3*dst_stride)) | |
748 : "m" (*(uint32_t*)(src + 0*src_stride)), | |
749 "m" (*(uint32_t*)(src + 1*src_stride)), | |
750 "m" (*(uint32_t*)(src + 2*src_stride)), | |
751 "m" (*(uint32_t*)(src + 3*src_stride)) | |
752 ); | |
753 } | |
754 | |
755 static void h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale){ | |
10749
5cca4b6c459d
Get rid of pointless CONFIG_ANY_H263 preprocessor definition.
diego
parents:
10645
diff
changeset
|
756 if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { |
8430 | 757 const int strength= ff_h263_loop_filter_strength[qscale]; |
10961
34a65026fa06
Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents:
10766
diff
changeset
|
758 DECLARE_ALIGNED(8, uint64_t, temp)[4]; |
8430 | 759 uint8_t *btemp= (uint8_t*)temp; |
760 | |
761 src -= 2; | |
762 | |
763 transpose4x4(btemp , src , 8, stride); | |
764 transpose4x4(btemp+4, src + 4*stride, 8, stride); | |
765 __asm__ volatile( | |
766 H263_LOOP_FILTER // 5 3 4 6 | |
767 | |
768 : "+m" (temp[0]), | |
769 "+m" (temp[1]), | |
770 "+m" (temp[2]), | |
771 "+m" (temp[3]) | |
772 : "g" (2*strength), "m"(ff_pb_FC) | |
773 ); | |
774 | |
775 __asm__ volatile( | |
776 "movq %%mm5, %%mm1 \n\t" | |
777 "movq %%mm4, %%mm0 \n\t" | |
778 "punpcklbw %%mm3, %%mm5 \n\t" | |
779 "punpcklbw %%mm6, %%mm4 \n\t" | |
780 "punpckhbw %%mm3, %%mm1 \n\t" | |
781 "punpckhbw %%mm6, %%mm0 \n\t" | |
782 "movq %%mm5, %%mm3 \n\t" | |
783 "movq %%mm1, %%mm6 \n\t" | |
784 "punpcklwd %%mm4, %%mm5 \n\t" | |
785 "punpcklwd %%mm0, %%mm1 \n\t" | |
786 "punpckhwd %%mm4, %%mm3 \n\t" | |
787 "punpckhwd %%mm0, %%mm6 \n\t" | |
788 "movd %%mm5, (%0) \n\t" | |
789 "punpckhdq %%mm5, %%mm5 \n\t" | |
790 "movd %%mm5, (%0,%2) \n\t" | |
791 "movd %%mm3, (%0,%2,2) \n\t" | |
792 "punpckhdq %%mm3, %%mm3 \n\t" | |
793 "movd %%mm3, (%0,%3) \n\t" | |
794 "movd %%mm1, (%1) \n\t" | |
795 "punpckhdq %%mm1, %%mm1 \n\t" | |
796 "movd %%mm1, (%1,%2) \n\t" | |
797 "movd %%mm6, (%1,%2,2) \n\t" | |
798 "punpckhdq %%mm6, %%mm6 \n\t" | |
799 "movd %%mm6, (%1,%3) \n\t" | |
800 :: "r" (src), | |
801 "r" (src + 4*stride), | |
802 "r" ((x86_reg) stride ), | |
803 "r" ((x86_reg)(3*stride)) | |
804 ); | |
805 } | |
806 } | |
807 | |
808 /* draw the edges of width 'w' of an image of size width, height | |
809 this mmx version can only handle w==8 || w==16 */ | |
810 static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w) | |
811 { | |
812 uint8_t *ptr, *last_line; | |
813 int i; | |
814 | |
815 last_line = buf + (height - 1) * wrap; | |
816 /* left and right */ | |
817 ptr = buf; | |
818 if(w==8) | |
819 { | |
820 __asm__ volatile( | |
821 "1: \n\t" | |
822 "movd (%0), %%mm0 \n\t" | |
823 "punpcklbw %%mm0, %%mm0 \n\t" | |
824 "punpcklwd %%mm0, %%mm0 \n\t" | |
825 "punpckldq %%mm0, %%mm0 \n\t" | |
826 "movq %%mm0, -8(%0) \n\t" | |
827 "movq -8(%0, %2), %%mm1 \n\t" | |
828 "punpckhbw %%mm1, %%mm1 \n\t" | |
829 "punpckhwd %%mm1, %%mm1 \n\t" | |
830 "punpckhdq %%mm1, %%mm1 \n\t" | |
831 "movq %%mm1, (%0, %2) \n\t" | |
832 "add %1, %0 \n\t" | |
833 "cmp %3, %0 \n\t" | |
834 " jb 1b \n\t" | |
835 : "+r" (ptr) | |
836 : "r" ((x86_reg)wrap), "r" ((x86_reg)width), "r" (ptr + wrap*height) | |
837 ); | |
838 } | |
839 else | |
840 { | |
841 __asm__ volatile( | |
842 "1: \n\t" | |
843 "movd (%0), %%mm0 \n\t" | |
844 "punpcklbw %%mm0, %%mm0 \n\t" | |
845 "punpcklwd %%mm0, %%mm0 \n\t" | |
846 "punpckldq %%mm0, %%mm0 \n\t" | |
847 "movq %%mm0, -8(%0) \n\t" | |
848 "movq %%mm0, -16(%0) \n\t" | |
849 "movq -8(%0, %2), %%mm1 \n\t" | |
850 "punpckhbw %%mm1, %%mm1 \n\t" | |
851 "punpckhwd %%mm1, %%mm1 \n\t" | |
852 "punpckhdq %%mm1, %%mm1 \n\t" | |
853 "movq %%mm1, (%0, %2) \n\t" | |
854 "movq %%mm1, 8(%0, %2) \n\t" | |
855 "add %1, %0 \n\t" | |
856 "cmp %3, %0 \n\t" | |
857 " jb 1b \n\t" | |
858 : "+r" (ptr) | |
859 : "r" ((x86_reg)wrap), "r" ((x86_reg)width), "r" (ptr + wrap*height) | |
860 ); | |
861 } | |
862 | |
863 for(i=0;i<w;i+=4) { | |
864 /* top and bottom (and hopefully also the corners) */ | |
865 ptr= buf - (i + 1) * wrap - w; | |
866 __asm__ volatile( | |
867 "1: \n\t" | |
868 "movq (%1, %0), %%mm0 \n\t" | |
869 "movq %%mm0, (%0) \n\t" | |
870 "movq %%mm0, (%0, %2) \n\t" | |
871 "movq %%mm0, (%0, %2, 2) \n\t" | |
872 "movq %%mm0, (%0, %3) \n\t" | |
873 "add $8, %0 \n\t" | |
874 "cmp %4, %0 \n\t" | |
875 " jb 1b \n\t" | |
876 : "+r" (ptr) | |
877 : "r" ((x86_reg)buf - (x86_reg)ptr - w), "r" ((x86_reg)-wrap), "r" ((x86_reg)-wrap*3), "r" (ptr+width+2*w) | |
878 ); | |
879 ptr= last_line + (i + 1) * wrap - w; | |
880 __asm__ volatile( | |
881 "1: \n\t" | |
882 "movq (%1, %0), %%mm0 \n\t" | |
883 "movq %%mm0, (%0) \n\t" | |
884 "movq %%mm0, (%0, %2) \n\t" | |
885 "movq %%mm0, (%0, %2, 2) \n\t" | |
886 "movq %%mm0, (%0, %3) \n\t" | |
887 "add $8, %0 \n\t" | |
888 "cmp %4, %0 \n\t" | |
889 " jb 1b \n\t" | |
890 : "+r" (ptr) | |
891 : "r" ((x86_reg)last_line - (x86_reg)ptr - w), "r" ((x86_reg)wrap), "r" ((x86_reg)wrap*3), "r" (ptr+width+2*w) | |
892 ); | |
893 } | |
894 } | |
895 | |
896 #define PAETH(cpu, abs3)\ | |
897 static void add_png_paeth_prediction_##cpu(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp)\ | |
898 {\ | |
899 x86_reg i = -bpp;\ | |
900 x86_reg end = w-3;\ | |
901 __asm__ volatile(\ | |
902 "pxor %%mm7, %%mm7 \n"\ | |
903 "movd (%1,%0), %%mm0 \n"\ | |
904 "movd (%2,%0), %%mm1 \n"\ | |
905 "punpcklbw %%mm7, %%mm0 \n"\ | |
906 "punpcklbw %%mm7, %%mm1 \n"\ | |
907 "add %4, %0 \n"\ | |
908 "1: \n"\ | |
909 "movq %%mm1, %%mm2 \n"\ | |
910 "movd (%2,%0), %%mm1 \n"\ | |
911 "movq %%mm2, %%mm3 \n"\ | |
912 "punpcklbw %%mm7, %%mm1 \n"\ | |
913 "movq %%mm2, %%mm4 \n"\ | |
914 "psubw %%mm1, %%mm3 \n"\ | |
915 "psubw %%mm0, %%mm4 \n"\ | |
916 "movq %%mm3, %%mm5 \n"\ | |
917 "paddw %%mm4, %%mm5 \n"\ | |
918 abs3\ | |
919 "movq %%mm4, %%mm6 \n"\ | |
920 "pminsw %%mm5, %%mm6 \n"\ | |
921 "pcmpgtw %%mm6, %%mm3 \n"\ | |
922 "pcmpgtw %%mm5, %%mm4 \n"\ | |
923 "movq %%mm4, %%mm6 \n"\ | |
924 "pand %%mm3, %%mm4 \n"\ | |
925 "pandn %%mm3, %%mm6 \n"\ | |
926 "pandn %%mm0, %%mm3 \n"\ | |
927 "movd (%3,%0), %%mm0 \n"\ | |
928 "pand %%mm1, %%mm6 \n"\ | |
929 "pand %%mm4, %%mm2 \n"\ | |
930 "punpcklbw %%mm7, %%mm0 \n"\ | |
931 "movq %6, %%mm5 \n"\ | |
932 "paddw %%mm6, %%mm0 \n"\ | |
933 "paddw %%mm2, %%mm3 \n"\ | |
934 "paddw %%mm3, %%mm0 \n"\ | |
935 "pand %%mm5, %%mm0 \n"\ | |
936 "movq %%mm0, %%mm3 \n"\ | |
937 "packuswb %%mm3, %%mm3 \n"\ | |
938 "movd %%mm3, (%1,%0) \n"\ | |
939 "add %4, %0 \n"\ | |
940 "cmp %5, %0 \n"\ | |
941 "jle 1b \n"\ | |
942 :"+r"(i)\ | |
943 :"r"(dst), "r"(top), "r"(src), "r"((x86_reg)bpp), "g"(end),\ | |
944 "m"(ff_pw_255)\ | |
945 :"memory"\ | |
946 );\ | |
947 } | |
948 | |
949 #define ABS3_MMX2\ | |
950 "psubw %%mm5, %%mm7 \n"\ | |
951 "pmaxsw %%mm7, %%mm5 \n"\ | |
952 "pxor %%mm6, %%mm6 \n"\ | |
953 "pxor %%mm7, %%mm7 \n"\ | |
954 "psubw %%mm3, %%mm6 \n"\ | |
955 "psubw %%mm4, %%mm7 \n"\ | |
956 "pmaxsw %%mm6, %%mm3 \n"\ | |
957 "pmaxsw %%mm7, %%mm4 \n"\ | |
958 "pxor %%mm7, %%mm7 \n" | |
959 | |
960 #define ABS3_SSSE3\ | |
961 "pabsw %%mm3, %%mm3 \n"\ | |
962 "pabsw %%mm4, %%mm4 \n"\ | |
963 "pabsw %%mm5, %%mm5 \n" | |
964 | |
965 PAETH(mmx2, ABS3_MMX2) | |
8590 | 966 #if HAVE_SSSE3 |
8430 | 967 PAETH(ssse3, ABS3_SSSE3) |
968 #endif | |
969 | |
970 #define QPEL_V_LOW(m3,m4,m5,m6, pw_20, pw_3, rnd, in0, in1, in2, in7, out, OP)\ | |
971 "paddw " #m4 ", " #m3 " \n\t" /* x1 */\ | |
972 "movq "MANGLE(ff_pw_20)", %%mm4 \n\t" /* 20 */\ | |
973 "pmullw " #m3 ", %%mm4 \n\t" /* 20x1 */\ | |
974 "movq "#in7", " #m3 " \n\t" /* d */\ | |
975 "movq "#in0", %%mm5 \n\t" /* D */\ | |
976 "paddw " #m3 ", %%mm5 \n\t" /* x4 */\ | |
977 "psubw %%mm5, %%mm4 \n\t" /* 20x1 - x4 */\ | |
978 "movq "#in1", %%mm5 \n\t" /* C */\ | |
979 "movq "#in2", %%mm6 \n\t" /* B */\ | |
980 "paddw " #m6 ", %%mm5 \n\t" /* x3 */\ | |
981 "paddw " #m5 ", %%mm6 \n\t" /* x2 */\ | |
982 "paddw %%mm6, %%mm6 \n\t" /* 2x2 */\ | |
983 "psubw %%mm6, %%mm5 \n\t" /* -2x2 + x3 */\ | |
984 "pmullw "MANGLE(ff_pw_3)", %%mm5 \n\t" /* -6x2 + 3x3 */\ | |
985 "paddw " #rnd ", %%mm4 \n\t" /* x2 */\ | |
986 "paddw %%mm4, %%mm5 \n\t" /* 20x1 - 6x2 + 3x3 - x4 */\ | |
987 "psraw $5, %%mm5 \n\t"\ | |
988 "packuswb %%mm5, %%mm5 \n\t"\ | |
989 OP(%%mm5, out, %%mm7, d) | |
990 | |
991 #define QPEL_BASE(OPNAME, ROUNDER, RND, OP_MMX2, OP_3DNOW)\ | |
992 static void OPNAME ## mpeg4_qpel16_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
993 uint64_t temp;\ | |
994 \ | |
995 __asm__ volatile(\ | |
996 "pxor %%mm7, %%mm7 \n\t"\ | |
997 "1: \n\t"\ | |
998 "movq (%0), %%mm0 \n\t" /* ABCDEFGH */\ | |
999 "movq %%mm0, %%mm1 \n\t" /* ABCDEFGH */\ | |
1000 "movq %%mm0, %%mm2 \n\t" /* ABCDEFGH */\ | |
1001 "punpcklbw %%mm7, %%mm0 \n\t" /* 0A0B0C0D */\ | |
1002 "punpckhbw %%mm7, %%mm1 \n\t" /* 0E0F0G0H */\ | |
1003 "pshufw $0x90, %%mm0, %%mm5 \n\t" /* 0A0A0B0C */\ | |
1004 "pshufw $0x41, %%mm0, %%mm6 \n\t" /* 0B0A0A0B */\ | |
1005 "movq %%mm2, %%mm3 \n\t" /* ABCDEFGH */\ | |
1006 "movq %%mm2, %%mm4 \n\t" /* ABCDEFGH */\ | |
1007 "psllq $8, %%mm2 \n\t" /* 0ABCDEFG */\ | |
1008 "psllq $16, %%mm3 \n\t" /* 00ABCDEF */\ | |
1009 "psllq $24, %%mm4 \n\t" /* 000ABCDE */\ | |
1010 "punpckhbw %%mm7, %%mm2 \n\t" /* 0D0E0F0G */\ | |
1011 "punpckhbw %%mm7, %%mm3 \n\t" /* 0C0D0E0F */\ | |
1012 "punpckhbw %%mm7, %%mm4 \n\t" /* 0B0C0D0E */\ | |
1013 "paddw %%mm3, %%mm5 \n\t" /* b */\ | |
1014 "paddw %%mm2, %%mm6 \n\t" /* c */\ | |
1015 "paddw %%mm5, %%mm5 \n\t" /* 2b */\ | |
1016 "psubw %%mm5, %%mm6 \n\t" /* c - 2b */\ | |
1017 "pshufw $0x06, %%mm0, %%mm5 \n\t" /* 0C0B0A0A */\ | |
1018 "pmullw "MANGLE(ff_pw_3)", %%mm6 \n\t" /* 3c - 6b */\ | |
1019 "paddw %%mm4, %%mm0 \n\t" /* a */\ | |
1020 "paddw %%mm1, %%mm5 \n\t" /* d */\ | |
1021 "pmullw "MANGLE(ff_pw_20)", %%mm0 \n\t" /* 20a */\ | |
1022 "psubw %%mm5, %%mm0 \n\t" /* 20a - d */\ | |
1023 "paddw %6, %%mm6 \n\t"\ | |
1024 "paddw %%mm6, %%mm0 \n\t" /* 20a - 6b + 3c - d */\ | |
1025 "psraw $5, %%mm0 \n\t"\ | |
1026 "movq %%mm0, %5 \n\t"\ | |
1027 /* mm1=EFGH, mm2=DEFG, mm3=CDEF, mm4=BCDE, mm7=0 */\ | |
1028 \ | |
1029 "movq 5(%0), %%mm0 \n\t" /* FGHIJKLM */\ | |
1030 "movq %%mm0, %%mm5 \n\t" /* FGHIJKLM */\ | |
1031 "movq %%mm0, %%mm6 \n\t" /* FGHIJKLM */\ | |
1032 "psrlq $8, %%mm0 \n\t" /* GHIJKLM0 */\ | |
1033 "psrlq $16, %%mm5 \n\t" /* HIJKLM00 */\ | |
1034 "punpcklbw %%mm7, %%mm0 \n\t" /* 0G0H0I0J */\ | |
1035 "punpcklbw %%mm7, %%mm5 \n\t" /* 0H0I0J0K */\ | |
1036 "paddw %%mm0, %%mm2 \n\t" /* b */\ | |
1037 "paddw %%mm5, %%mm3 \n\t" /* c */\ | |
1038 "paddw %%mm2, %%mm2 \n\t" /* 2b */\ | |
1039 "psubw %%mm2, %%mm3 \n\t" /* c - 2b */\ | |
1040 "movq %%mm6, %%mm2 \n\t" /* FGHIJKLM */\ | |
1041 "psrlq $24, %%mm6 \n\t" /* IJKLM000 */\ | |
1042 "punpcklbw %%mm7, %%mm2 \n\t" /* 0F0G0H0I */\ | |
1043 "punpcklbw %%mm7, %%mm6 \n\t" /* 0I0J0K0L */\ | |
1044 "pmullw "MANGLE(ff_pw_3)", %%mm3 \n\t" /* 3c - 6b */\ | |
1045 "paddw %%mm2, %%mm1 \n\t" /* a */\ | |
1046 "paddw %%mm6, %%mm4 \n\t" /* d */\ | |
1047 "pmullw "MANGLE(ff_pw_20)", %%mm1 \n\t" /* 20a */\ | |
1048 "psubw %%mm4, %%mm3 \n\t" /* - 6b +3c - d */\ | |
1049 "paddw %6, %%mm1 \n\t"\ | |
1050 "paddw %%mm1, %%mm3 \n\t" /* 20a - 6b +3c - d */\ | |
1051 "psraw $5, %%mm3 \n\t"\ | |
1052 "movq %5, %%mm1 \n\t"\ | |
1053 "packuswb %%mm3, %%mm1 \n\t"\ | |
1054 OP_MMX2(%%mm1, (%1),%%mm4, q)\ | |
1055 /* mm0= GHIJ, mm2=FGHI, mm5=HIJK, mm6=IJKL, mm7=0 */\ | |
1056 \ | |
1057 "movq 9(%0), %%mm1 \n\t" /* JKLMNOPQ */\ | |
1058 "movq %%mm1, %%mm4 \n\t" /* JKLMNOPQ */\ | |
1059 "movq %%mm1, %%mm3 \n\t" /* JKLMNOPQ */\ | |
1060 "psrlq $8, %%mm1 \n\t" /* KLMNOPQ0 */\ | |
1061 "psrlq $16, %%mm4 \n\t" /* LMNOPQ00 */\ | |
1062 "punpcklbw %%mm7, %%mm1 \n\t" /* 0K0L0M0N */\ | |
1063 "punpcklbw %%mm7, %%mm4 \n\t" /* 0L0M0N0O */\ | |
1064 "paddw %%mm1, %%mm5 \n\t" /* b */\ | |
1065 "paddw %%mm4, %%mm0 \n\t" /* c */\ | |
1066 "paddw %%mm5, %%mm5 \n\t" /* 2b */\ | |
1067 "psubw %%mm5, %%mm0 \n\t" /* c - 2b */\ | |
1068 "movq %%mm3, %%mm5 \n\t" /* JKLMNOPQ */\ | |
1069 "psrlq $24, %%mm3 \n\t" /* MNOPQ000 */\ | |
1070 "pmullw "MANGLE(ff_pw_3)", %%mm0 \n\t" /* 3c - 6b */\ | |
1071 "punpcklbw %%mm7, %%mm3 \n\t" /* 0M0N0O0P */\ | |
1072 "paddw %%mm3, %%mm2 \n\t" /* d */\ | |
1073 "psubw %%mm2, %%mm0 \n\t" /* -6b + 3c - d */\ | |
1074 "movq %%mm5, %%mm2 \n\t" /* JKLMNOPQ */\ | |
1075 "punpcklbw %%mm7, %%mm2 \n\t" /* 0J0K0L0M */\ | |
1076 "punpckhbw %%mm7, %%mm5 \n\t" /* 0N0O0P0Q */\ | |
1077 "paddw %%mm2, %%mm6 \n\t" /* a */\ | |
1078 "pmullw "MANGLE(ff_pw_20)", %%mm6 \n\t" /* 20a */\ | |
1079 "paddw %6, %%mm0 \n\t"\ | |
1080 "paddw %%mm6, %%mm0 \n\t" /* 20a - 6b + 3c - d */\ | |
1081 "psraw $5, %%mm0 \n\t"\ | |
1082 /* mm1=KLMN, mm2=JKLM, mm3=MNOP, mm4=LMNO, mm5=NOPQ mm7=0 */\ | |
1083 \ | |
1084 "paddw %%mm5, %%mm3 \n\t" /* a */\ | |
1085 "pshufw $0xF9, %%mm5, %%mm6 \n\t" /* 0O0P0Q0Q */\ | |
1086 "paddw %%mm4, %%mm6 \n\t" /* b */\ | |
1087 "pshufw $0xBE, %%mm5, %%mm4 \n\t" /* 0P0Q0Q0P */\ | |
1088 "pshufw $0x6F, %%mm5, %%mm5 \n\t" /* 0Q0Q0P0O */\ | |
1089 "paddw %%mm1, %%mm4 \n\t" /* c */\ | |
1090 "paddw %%mm2, %%mm5 \n\t" /* d */\ | |
1091 "paddw %%mm6, %%mm6 \n\t" /* 2b */\ | |
1092 "psubw %%mm6, %%mm4 \n\t" /* c - 2b */\ | |
1093 "pmullw "MANGLE(ff_pw_20)", %%mm3 \n\t" /* 20a */\ | |
1094 "pmullw "MANGLE(ff_pw_3)", %%mm4 \n\t" /* 3c - 6b */\ | |
1095 "psubw %%mm5, %%mm3 \n\t" /* -6b + 3c - d */\ | |
1096 "paddw %6, %%mm4 \n\t"\ | |
1097 "paddw %%mm3, %%mm4 \n\t" /* 20a - 6b + 3c - d */\ | |
1098 "psraw $5, %%mm4 \n\t"\ | |
1099 "packuswb %%mm4, %%mm0 \n\t"\ | |
1100 OP_MMX2(%%mm0, 8(%1), %%mm4, q)\ | |
1101 \ | |
1102 "add %3, %0 \n\t"\ | |
1103 "add %4, %1 \n\t"\ | |
1104 "decl %2 \n\t"\ | |
1105 " jnz 1b \n\t"\ | |
1106 : "+a"(src), "+c"(dst), "+D"(h)\ | |
1107 : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(temp), "m"(ROUNDER)\ | |
1108 : "memory"\ | |
1109 );\ | |
1110 }\ | |
1111 \ | |
1112 static void OPNAME ## mpeg4_qpel16_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
1113 int i;\ | |
1114 int16_t temp[16];\ | |
1115 /* quick HACK, XXX FIXME MUST be optimized */\ | |
1116 for(i=0; i<h; i++)\ | |
1117 {\ | |
1118 temp[ 0]= (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]);\ | |
1119 temp[ 1]= (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]);\ | |
1120 temp[ 2]= (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]);\ | |
1121 temp[ 3]= (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]);\ | |
1122 temp[ 4]= (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]);\ | |
1123 temp[ 5]= (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]);\ | |
1124 temp[ 6]= (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]);\ | |
1125 temp[ 7]= (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]);\ | |
1126 temp[ 8]= (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]);\ | |
1127 temp[ 9]= (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]);\ | |
1128 temp[10]= (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]);\ | |
1129 temp[11]= (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]);\ | |
1130 temp[12]= (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]);\ | |
1131 temp[13]= (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]);\ | |
1132 temp[14]= (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]);\ | |
1133 temp[15]= (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]);\ | |
1134 __asm__ volatile(\ | |
1135 "movq (%0), %%mm0 \n\t"\ | |
1136 "movq 8(%0), %%mm1 \n\t"\ | |
1137 "paddw %2, %%mm0 \n\t"\ | |
1138 "paddw %2, %%mm1 \n\t"\ | |
1139 "psraw $5, %%mm0 \n\t"\ | |
1140 "psraw $5, %%mm1 \n\t"\ | |
1141 "packuswb %%mm1, %%mm0 \n\t"\ | |
1142 OP_3DNOW(%%mm0, (%1), %%mm1, q)\ | |
1143 "movq 16(%0), %%mm0 \n\t"\ | |
1144 "movq 24(%0), %%mm1 \n\t"\ | |
1145 "paddw %2, %%mm0 \n\t"\ | |
1146 "paddw %2, %%mm1 \n\t"\ | |
1147 "psraw $5, %%mm0 \n\t"\ | |
1148 "psraw $5, %%mm1 \n\t"\ | |
1149 "packuswb %%mm1, %%mm0 \n\t"\ | |
1150 OP_3DNOW(%%mm0, 8(%1), %%mm1, q)\ | |
1151 :: "r"(temp), "r"(dst), "m"(ROUNDER)\ | |
1152 : "memory"\ | |
1153 );\ | |
1154 dst+=dstStride;\ | |
1155 src+=srcStride;\ | |
1156 }\ | |
1157 }\ | |
1158 \ | |
1159 static void OPNAME ## mpeg4_qpel8_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
1160 __asm__ volatile(\ | |
1161 "pxor %%mm7, %%mm7 \n\t"\ | |
1162 "1: \n\t"\ | |
1163 "movq (%0), %%mm0 \n\t" /* ABCDEFGH */\ | |
1164 "movq %%mm0, %%mm1 \n\t" /* ABCDEFGH */\ | |
1165 "movq %%mm0, %%mm2 \n\t" /* ABCDEFGH */\ | |
1166 "punpcklbw %%mm7, %%mm0 \n\t" /* 0A0B0C0D */\ | |
1167 "punpckhbw %%mm7, %%mm1 \n\t" /* 0E0F0G0H */\ | |
1168 "pshufw $0x90, %%mm0, %%mm5 \n\t" /* 0A0A0B0C */\ | |
1169 "pshufw $0x41, %%mm0, %%mm6 \n\t" /* 0B0A0A0B */\ | |
1170 "movq %%mm2, %%mm3 \n\t" /* ABCDEFGH */\ | |
1171 "movq %%mm2, %%mm4 \n\t" /* ABCDEFGH */\ | |
1172 "psllq $8, %%mm2 \n\t" /* 0ABCDEFG */\ | |
1173 "psllq $16, %%mm3 \n\t" /* 00ABCDEF */\ | |
1174 "psllq $24, %%mm4 \n\t" /* 000ABCDE */\ | |
1175 "punpckhbw %%mm7, %%mm2 \n\t" /* 0D0E0F0G */\ | |
1176 "punpckhbw %%mm7, %%mm3 \n\t" /* 0C0D0E0F */\ | |
1177 "punpckhbw %%mm7, %%mm4 \n\t" /* 0B0C0D0E */\ | |
1178 "paddw %%mm3, %%mm5 \n\t" /* b */\ | |
1179 "paddw %%mm2, %%mm6 \n\t" /* c */\ | |
1180 "paddw %%mm5, %%mm5 \n\t" /* 2b */\ | |
1181 "psubw %%mm5, %%mm6 \n\t" /* c - 2b */\ | |
1182 "pshufw $0x06, %%mm0, %%mm5 \n\t" /* 0C0B0A0A */\ | |
1183 "pmullw "MANGLE(ff_pw_3)", %%mm6 \n\t" /* 3c - 6b */\ | |
1184 "paddw %%mm4, %%mm0 \n\t" /* a */\ | |
1185 "paddw %%mm1, %%mm5 \n\t" /* d */\ | |
1186 "pmullw "MANGLE(ff_pw_20)", %%mm0 \n\t" /* 20a */\ | |
1187 "psubw %%mm5, %%mm0 \n\t" /* 20a - d */\ | |
1188 "paddw %5, %%mm6 \n\t"\ | |
1189 "paddw %%mm6, %%mm0 \n\t" /* 20a - 6b + 3c - d */\ | |
1190 "psraw $5, %%mm0 \n\t"\ | |
1191 /* mm1=EFGH, mm2=DEFG, mm3=CDEF, mm4=BCDE, mm7=0 */\ | |
1192 \ | |
1193 "movd 5(%0), %%mm5 \n\t" /* FGHI */\ | |
1194 "punpcklbw %%mm7, %%mm5 \n\t" /* 0F0G0H0I */\ | |
1195 "pshufw $0xF9, %%mm5, %%mm6 \n\t" /* 0G0H0I0I */\ | |
1196 "paddw %%mm5, %%mm1 \n\t" /* a */\ | |
1197 "paddw %%mm6, %%mm2 \n\t" /* b */\ | |
1198 "pshufw $0xBE, %%mm5, %%mm6 \n\t" /* 0H0I0I0H */\ | |
1199 "pshufw $0x6F, %%mm5, %%mm5 \n\t" /* 0I0I0H0G */\ | |
1200 "paddw %%mm6, %%mm3 \n\t" /* c */\ | |
1201 "paddw %%mm5, %%mm4 \n\t" /* d */\ | |
1202 "paddw %%mm2, %%mm2 \n\t" /* 2b */\ | |
1203 "psubw %%mm2, %%mm3 \n\t" /* c - 2b */\ | |
1204 "pmullw "MANGLE(ff_pw_20)", %%mm1 \n\t" /* 20a */\ | |
1205 "pmullw "MANGLE(ff_pw_3)", %%mm3 \n\t" /* 3c - 6b */\ | |
1206 "psubw %%mm4, %%mm3 \n\t" /* -6b + 3c - d */\ | |
1207 "paddw %5, %%mm1 \n\t"\ | |
1208 "paddw %%mm1, %%mm3 \n\t" /* 20a - 6b + 3c - d */\ | |
1209 "psraw $5, %%mm3 \n\t"\ | |
1210 "packuswb %%mm3, %%mm0 \n\t"\ | |
1211 OP_MMX2(%%mm0, (%1), %%mm4, q)\ | |
1212 \ | |
1213 "add %3, %0 \n\t"\ | |
1214 "add %4, %1 \n\t"\ | |
1215 "decl %2 \n\t"\ | |
1216 " jnz 1b \n\t"\ | |
1217 : "+a"(src), "+c"(dst), "+d"(h)\ | |
1218 : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(ROUNDER)\ | |
1219 : "memory"\ | |
1220 );\ | |
1221 }\ | |
1222 \ | |
1223 static void OPNAME ## mpeg4_qpel8_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | |
1224 int i;\ | |
1225 int16_t temp[8];\ | |
1226 /* quick HACK, XXX FIXME MUST be optimized */\ | |
1227 for(i=0; i<h; i++)\ | |
1228 {\ | |
1229 temp[ 0]= (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]);\ | |
1230 temp[ 1]= (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]);\ | |
1231 temp[ 2]= (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]);\ | |
1232 temp[ 3]= (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]);\ | |
1233 temp[ 4]= (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]);\ | |
1234 temp[ 5]= (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 8]);\ | |
1235 temp[ 6]= (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 8])*3 - (src[ 3]+src[ 7]);\ | |
1236 temp[ 7]= (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 8])*6 + (src[ 5]+src[ 7])*3 - (src[ 4]+src[ 6]);\ | |
1237 __asm__ volatile(\ | |
1238 "movq (%0), %%mm0 \n\t"\ | |
1239 "movq 8(%0), %%mm1 \n\t"\ | |
1240 "paddw %2, %%mm0 \n\t"\ | |
1241 "paddw %2, %%mm1 \n\t"\ | |
1242 "psraw $5, %%mm0 \n\t"\ | |
1243 "psraw $5, %%mm1 \n\t"\ | |
1244 "packuswb %%mm1, %%mm0 \n\t"\ | |
1245 OP_3DNOW(%%mm0, (%1), %%mm1, q)\ | |
1246 :: "r"(temp), "r"(dst), "m"(ROUNDER)\ | |
1247 :"memory"\ | |
1248 );\ | |
1249 dst+=dstStride;\ | |
1250 src+=srcStride;\ | |
1251 }\ | |
1252 } | |
1253 | |
1254 #define QPEL_OP(OPNAME, ROUNDER, RND, OP, MMX)\ | |
1255 \ | |
1256 static void OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1257 uint64_t temp[17*4];\ | |
1258 uint64_t *temp_ptr= temp;\ | |
1259 int count= 17;\ | |
1260 \ | |
1261 /*FIXME unroll */\ | |
1262 __asm__ volatile(\ | |
1263 "pxor %%mm7, %%mm7 \n\t"\ | |
1264 "1: \n\t"\ | |
1265 "movq (%0), %%mm0 \n\t"\ | |
1266 "movq (%0), %%mm1 \n\t"\ | |
1267 "movq 8(%0), %%mm2 \n\t"\ | |
1268 "movq 8(%0), %%mm3 \n\t"\ | |
1269 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1270 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
1271 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1272 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
1273 "movq %%mm0, (%1) \n\t"\ | |
1274 "movq %%mm1, 17*8(%1) \n\t"\ | |
1275 "movq %%mm2, 2*17*8(%1) \n\t"\ | |
1276 "movq %%mm3, 3*17*8(%1) \n\t"\ | |
1277 "add $8, %1 \n\t"\ | |
1278 "add %3, %0 \n\t"\ | |
1279 "decl %2 \n\t"\ | |
1280 " jnz 1b \n\t"\ | |
1281 : "+r" (src), "+r" (temp_ptr), "+r"(count)\ | |
1282 : "r" ((x86_reg)srcStride)\ | |
1283 : "memory"\ | |
1284 );\ | |
1285 \ | |
1286 temp_ptr= temp;\ | |
1287 count=4;\ | |
1288 \ | |
1289 /*FIXME reorder for speed */\ | |
1290 __asm__ volatile(\ | |
1291 /*"pxor %%mm7, %%mm7 \n\t"*/\ | |
1292 "1: \n\t"\ | |
1293 "movq (%0), %%mm0 \n\t"\ | |
1294 "movq 8(%0), %%mm1 \n\t"\ | |
1295 "movq 16(%0), %%mm2 \n\t"\ | |
1296 "movq 24(%0), %%mm3 \n\t"\ | |
1297 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 16(%0), 8(%0), (%0), 32(%0), (%1), OP)\ | |
1298 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 8(%0), (%0), (%0), 40(%0), (%1, %3), OP)\ | |
1299 "add %4, %1 \n\t"\ | |
1300 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, (%0), (%0), 8(%0), 48(%0), (%1), OP)\ | |
1301 \ | |
1302 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, (%0), 8(%0), 16(%0), 56(%0), (%1, %3), OP)\ | |
1303 "add %4, %1 \n\t"\ | |
1304 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 8(%0), 16(%0), 24(%0), 64(%0), (%1), OP)\ | |
1305 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 16(%0), 24(%0), 32(%0), 72(%0), (%1, %3), OP)\ | |
1306 "add %4, %1 \n\t"\ | |
1307 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 24(%0), 32(%0), 40(%0), 80(%0), (%1), OP)\ | |
1308 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 32(%0), 40(%0), 48(%0), 88(%0), (%1, %3), OP)\ | |
1309 "add %4, %1 \n\t"\ | |
1310 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 40(%0), 48(%0), 56(%0), 96(%0), (%1), OP)\ | |
1311 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 48(%0), 56(%0), 64(%0),104(%0), (%1, %3), OP)\ | |
1312 "add %4, %1 \n\t"\ | |
1313 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 56(%0), 64(%0), 72(%0),112(%0), (%1), OP)\ | |
1314 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 64(%0), 72(%0), 80(%0),120(%0), (%1, %3), OP)\ | |
1315 "add %4, %1 \n\t"\ | |
1316 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 72(%0), 80(%0), 88(%0),128(%0), (%1), OP)\ | |
1317 \ | |
1318 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 80(%0), 88(%0), 96(%0),128(%0), (%1, %3), OP)\ | |
1319 "add %4, %1 \n\t" \ | |
1320 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 88(%0), 96(%0),104(%0),120(%0), (%1), OP)\ | |
1321 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 96(%0),104(%0),112(%0),112(%0), (%1, %3), OP)\ | |
1322 \ | |
1323 "add $136, %0 \n\t"\ | |
1324 "add %6, %1 \n\t"\ | |
1325 "decl %2 \n\t"\ | |
1326 " jnz 1b \n\t"\ | |
1327 \ | |
1328 : "+r"(temp_ptr), "+r"(dst), "+g"(count)\ | |
1329 : "r"((x86_reg)dstStride), "r"(2*(x86_reg)dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(ROUNDER), "g"(4-14*(x86_reg)dstStride)\ | |
1330 :"memory"\ | |
1331 );\ | |
1332 }\ | |
1333 \ | |
1334 static void OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1335 uint64_t temp[9*2];\ | |
1336 uint64_t *temp_ptr= temp;\ | |
1337 int count= 9;\ | |
1338 \ | |
1339 /*FIXME unroll */\ | |
1340 __asm__ volatile(\ | |
1341 "pxor %%mm7, %%mm7 \n\t"\ | |
1342 "1: \n\t"\ | |
1343 "movq (%0), %%mm0 \n\t"\ | |
1344 "movq (%0), %%mm1 \n\t"\ | |
1345 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1346 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
1347 "movq %%mm0, (%1) \n\t"\ | |
1348 "movq %%mm1, 9*8(%1) \n\t"\ | |
1349 "add $8, %1 \n\t"\ | |
1350 "add %3, %0 \n\t"\ | |
1351 "decl %2 \n\t"\ | |
1352 " jnz 1b \n\t"\ | |
1353 : "+r" (src), "+r" (temp_ptr), "+r"(count)\ | |
1354 : "r" ((x86_reg)srcStride)\ | |
1355 : "memory"\ | |
1356 );\ | |
1357 \ | |
1358 temp_ptr= temp;\ | |
1359 count=2;\ | |
1360 \ | |
1361 /*FIXME reorder for speed */\ | |
1362 __asm__ volatile(\ | |
1363 /*"pxor %%mm7, %%mm7 \n\t"*/\ | |
1364 "1: \n\t"\ | |
1365 "movq (%0), %%mm0 \n\t"\ | |
1366 "movq 8(%0), %%mm1 \n\t"\ | |
1367 "movq 16(%0), %%mm2 \n\t"\ | |
1368 "movq 24(%0), %%mm3 \n\t"\ | |
1369 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 16(%0), 8(%0), (%0), 32(%0), (%1), OP)\ | |
1370 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 8(%0), (%0), (%0), 40(%0), (%1, %3), OP)\ | |
1371 "add %4, %1 \n\t"\ | |
1372 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, (%0), (%0), 8(%0), 48(%0), (%1), OP)\ | |
1373 \ | |
1374 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, (%0), 8(%0), 16(%0), 56(%0), (%1, %3), OP)\ | |
1375 "add %4, %1 \n\t"\ | |
1376 QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 8(%0), 16(%0), 24(%0), 64(%0), (%1), OP)\ | |
1377 \ | |
1378 QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 16(%0), 24(%0), 32(%0), 64(%0), (%1, %3), OP)\ | |
1379 "add %4, %1 \n\t"\ | |
1380 QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 24(%0), 32(%0), 40(%0), 56(%0), (%1), OP)\ | |
1381 QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 32(%0), 40(%0), 48(%0), 48(%0), (%1, %3), OP)\ | |
1382 \ | |
1383 "add $72, %0 \n\t"\ | |
1384 "add %6, %1 \n\t"\ | |
1385 "decl %2 \n\t"\ | |
1386 " jnz 1b \n\t"\ | |
1387 \ | |
1388 : "+r"(temp_ptr), "+r"(dst), "+g"(count)\ | |
1389 : "r"((x86_reg)dstStride), "r"(2*(x86_reg)dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(ROUNDER), "g"(4-6*(x86_reg)dstStride)\ | |
1390 : "memory"\ | |
1391 );\ | |
1392 }\ | |
1393 \ | |
1394 static void OPNAME ## qpel8_mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\ | |
1395 OPNAME ## pixels8_ ## MMX(dst, src, stride, 8);\ | |
1396 }\ | |
1397 \ | |
1398 static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1399 uint64_t temp[8];\ | |
1400 uint8_t * const half= (uint8_t*)temp;\ | |
1401 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, stride, 8);\ | |
1402 OPNAME ## pixels8_l2_ ## MMX(dst, src, half, stride, stride, 8);\ | |
1403 }\ | |
1404 \ | |
1405 static void OPNAME ## qpel8_mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1406 OPNAME ## mpeg4_qpel8_h_lowpass_ ## MMX(dst, src, stride, stride, 8);\ | |
1407 }\ | |
1408 \ | |
1409 static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1410 uint64_t temp[8];\ | |
1411 uint8_t * const half= (uint8_t*)temp;\ | |
1412 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, stride, 8);\ | |
1413 OPNAME ## pixels8_l2_ ## MMX(dst, src+1, half, stride, stride, 8);\ | |
1414 }\ | |
1415 \ | |
1416 static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1417 uint64_t temp[8];\ | |
1418 uint8_t * const half= (uint8_t*)temp;\ | |
1419 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, 8, stride);\ | |
1420 OPNAME ## pixels8_l2_ ## MMX(dst, src, half, stride, stride, 8);\ | |
1421 }\ | |
1422 \ | |
1423 static void OPNAME ## qpel8_mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1424 OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, src, stride, stride);\ | |
1425 }\ | |
1426 \ | |
1427 static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1428 uint64_t temp[8];\ | |
1429 uint8_t * const half= (uint8_t*)temp;\ | |
1430 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, 8, stride);\ | |
1431 OPNAME ## pixels8_l2_ ## MMX(dst, src+stride, half, stride, stride, 8);\ | |
1432 }\ | |
1433 static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1434 uint64_t half[8 + 9];\ | |
1435 uint8_t * const halfH= ((uint8_t*)half) + 64;\ | |
1436 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1437 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1438 put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9);\ | |
1439 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\ | |
1440 OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, stride, 8, 8);\ | |
1441 }\ | |
1442 static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1443 uint64_t half[8 + 9];\ | |
1444 uint8_t * const halfH= ((uint8_t*)half) + 64;\ | |
1445 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1446 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1447 put ## RND ## pixels8_l2_ ## MMX(halfH, src+1, halfH, 8, stride, 9);\ | |
1448 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\ | |
1449 OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, stride, 8, 8);\ | |
1450 }\ | |
1451 static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1452 uint64_t half[8 + 9];\ | |
1453 uint8_t * const halfH= ((uint8_t*)half) + 64;\ | |
1454 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1455 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1456 put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9);\ | |
1457 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\ | |
1458 OPNAME ## pixels8_l2_ ## MMX(dst, halfH+8, halfHV, stride, 8, 8);\ | |
1459 }\ | |
1460 static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1461 uint64_t half[8 + 9];\ | |
1462 uint8_t * const halfH= ((uint8_t*)half) + 64;\ | |
1463 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1464 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1465 put ## RND ## pixels8_l2_ ## MMX(halfH, src+1, halfH, 8, stride, 9);\ | |
1466 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\ | |
1467 OPNAME ## pixels8_l2_ ## MMX(dst, halfH+8, halfHV, stride, 8, 8);\ | |
1468 }\ | |
1469 static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1470 uint64_t half[8 + 9];\ | |
1471 uint8_t * const halfH= ((uint8_t*)half) + 64;\ | |
1472 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1473 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1474 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\ | |
1475 OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, stride, 8, 8);\ | |
1476 }\ | |
1477 static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1478 uint64_t half[8 + 9];\ | |
1479 uint8_t * const halfH= ((uint8_t*)half) + 64;\ | |
1480 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1481 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1482 put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\ | |
1483 OPNAME ## pixels8_l2_ ## MMX(dst, halfH+8, halfHV, stride, 8, 8);\ | |
1484 }\ | |
1485 static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1486 uint64_t half[8 + 9];\ | |
1487 uint8_t * const halfH= ((uint8_t*)half);\ | |
1488 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1489 put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9);\ | |
1490 OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\ | |
1491 }\ | |
1492 static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1493 uint64_t half[8 + 9];\ | |
1494 uint8_t * const halfH= ((uint8_t*)half);\ | |
1495 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1496 put ## RND ## pixels8_l2_ ## MMX(halfH, src+1, halfH, 8, stride, 9);\ | |
1497 OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\ | |
1498 }\ | |
1499 static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1500 uint64_t half[9];\ | |
1501 uint8_t * const halfH= ((uint8_t*)half);\ | |
1502 put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\ | |
1503 OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\ | |
1504 }\ | |
1505 static void OPNAME ## qpel16_mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\ | |
1506 OPNAME ## pixels16_ ## MMX(dst, src, stride, 16);\ | |
1507 }\ | |
1508 \ | |
1509 static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1510 uint64_t temp[32];\ | |
1511 uint8_t * const half= (uint8_t*)temp;\ | |
1512 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, stride, 16);\ | |
1513 OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride, stride, 16);\ | |
1514 }\ | |
1515 \ | |
1516 static void OPNAME ## qpel16_mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1517 OPNAME ## mpeg4_qpel16_h_lowpass_ ## MMX(dst, src, stride, stride, 16);\ | |
1518 }\ | |
1519 \ | |
1520 static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1521 uint64_t temp[32];\ | |
1522 uint8_t * const half= (uint8_t*)temp;\ | |
1523 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, stride, 16);\ | |
1524 OPNAME ## pixels16_l2_ ## MMX(dst, src+1, half, stride, stride, 16);\ | |
1525 }\ | |
1526 \ | |
1527 static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1528 uint64_t temp[32];\ | |
1529 uint8_t * const half= (uint8_t*)temp;\ | |
1530 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, stride);\ | |
1531 OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride, stride, 16);\ | |
1532 }\ | |
1533 \ | |
1534 static void OPNAME ## qpel16_mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1535 OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, src, stride, stride);\ | |
1536 }\ | |
1537 \ | |
1538 static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1539 uint64_t temp[32];\ | |
1540 uint8_t * const half= (uint8_t*)temp;\ | |
1541 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, stride);\ | |
1542 OPNAME ## pixels16_l2_ ## MMX(dst, src+stride, half, stride, stride, 16);\ | |
1543 }\ | |
1544 static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1545 uint64_t half[16*2 + 17*2];\ | |
1546 uint8_t * const halfH= ((uint8_t*)half) + 256;\ | |
1547 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1548 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1549 put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, stride, 17);\ | |
1550 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\ | |
1551 OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, stride, 16, 16);\ | |
1552 }\ | |
1553 static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1554 uint64_t half[16*2 + 17*2];\ | |
1555 uint8_t * const halfH= ((uint8_t*)half) + 256;\ | |
1556 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1557 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1558 put ## RND ## pixels16_l2_ ## MMX(halfH, src+1, halfH, 16, stride, 17);\ | |
1559 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\ | |
1560 OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, stride, 16, 16);\ | |
1561 }\ | |
1562 static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1563 uint64_t half[16*2 + 17*2];\ | |
1564 uint8_t * const halfH= ((uint8_t*)half) + 256;\ | |
1565 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1566 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1567 put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, stride, 17);\ | |
1568 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\ | |
1569 OPNAME ## pixels16_l2_ ## MMX(dst, halfH+16, halfHV, stride, 16, 16);\ | |
1570 }\ | |
1571 static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1572 uint64_t half[16*2 + 17*2];\ | |
1573 uint8_t * const halfH= ((uint8_t*)half) + 256;\ | |
1574 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1575 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1576 put ## RND ## pixels16_l2_ ## MMX(halfH, src+1, halfH, 16, stride, 17);\ | |
1577 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\ | |
1578 OPNAME ## pixels16_l2_ ## MMX(dst, halfH+16, halfHV, stride, 16, 16);\ | |
1579 }\ | |
1580 static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1581 uint64_t half[16*2 + 17*2];\ | |
1582 uint8_t * const halfH= ((uint8_t*)half) + 256;\ | |
1583 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1584 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1585 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\ | |
1586 OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, stride, 16, 16);\ | |
1587 }\ | |
1588 static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1589 uint64_t half[16*2 + 17*2];\ | |
1590 uint8_t * const halfH= ((uint8_t*)half) + 256;\ | |
1591 uint8_t * const halfHV= ((uint8_t*)half);\ | |
1592 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1593 put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\ | |
1594 OPNAME ## pixels16_l2_ ## MMX(dst, halfH+16, halfHV, stride, 16, 16);\ | |
1595 }\ | |
1596 static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1597 uint64_t half[17*2];\ | |
1598 uint8_t * const halfH= ((uint8_t*)half);\ | |
1599 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1600 put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, stride, 17);\ | |
1601 OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\ | |
1602 }\ | |
1603 static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1604 uint64_t half[17*2];\ | |
1605 uint8_t * const halfH= ((uint8_t*)half);\ | |
1606 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1607 put ## RND ## pixels16_l2_ ## MMX(halfH, src+1, halfH, 16, stride, 17);\ | |
1608 OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\ | |
1609 }\ | |
1610 static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1611 uint64_t half[17*2];\ | |
1612 uint8_t * const halfH= ((uint8_t*)half);\ | |
1613 put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\ | |
1614 OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\ | |
1615 } | |
1616 | |
1617 #define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b " \n\t" | |
1618 #define AVG_3DNOW_OP(a,b,temp, size) \ | |
1619 "mov" #size " " #b ", " #temp " \n\t"\ | |
1620 "pavgusb " #temp ", " #a " \n\t"\ | |
1621 "mov" #size " " #a ", " #b " \n\t" | |
1622 #define AVG_MMX2_OP(a,b,temp, size) \ | |
1623 "mov" #size " " #b ", " #temp " \n\t"\ | |
1624 "pavgb " #temp ", " #a " \n\t"\ | |
1625 "mov" #size " " #a ", " #b " \n\t" | |
1626 | |
1627 QPEL_BASE(put_ , ff_pw_16, _ , PUT_OP, PUT_OP) | |
1628 QPEL_BASE(avg_ , ff_pw_16, _ , AVG_MMX2_OP, AVG_3DNOW_OP) | |
1629 QPEL_BASE(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, PUT_OP) | |
1630 QPEL_OP(put_ , ff_pw_16, _ , PUT_OP, 3dnow) | |
1631 QPEL_OP(avg_ , ff_pw_16, _ , AVG_3DNOW_OP, 3dnow) | |
1632 QPEL_OP(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, 3dnow) | |
1633 QPEL_OP(put_ , ff_pw_16, _ , PUT_OP, mmx2) | |
1634 QPEL_OP(avg_ , ff_pw_16, _ , AVG_MMX2_OP, mmx2) | |
1635 QPEL_OP(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, mmx2) | |
1636 | |
1637 /***********************************/ | |
1638 /* bilinear qpel: not compliant to any spec, only for -lavdopts fast */ | |
1639 | |
1640 #define QPEL_2TAP_XY(OPNAME, SIZE, MMX, XY, HPEL)\ | |
1641 static void OPNAME ## 2tap_qpel ## SIZE ## _mc ## XY ## _ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1642 OPNAME ## pixels ## SIZE ## HPEL(dst, src, stride, SIZE);\ | |
1643 } | |
1644 #define QPEL_2TAP_L3(OPNAME, SIZE, MMX, XY, S0, S1, S2)\ | |
1645 static void OPNAME ## 2tap_qpel ## SIZE ## _mc ## XY ## _ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1646 OPNAME ## 2tap_qpel ## SIZE ## _l3_ ## MMX(dst, src+S0, stride, SIZE, S1, S2);\ | |
1647 } | |
1648 | |
1649 #define QPEL_2TAP(OPNAME, SIZE, MMX)\ | |
1650 QPEL_2TAP_XY(OPNAME, SIZE, MMX, 20, _x2_ ## MMX)\ | |
1651 QPEL_2TAP_XY(OPNAME, SIZE, MMX, 02, _y2_ ## MMX)\ | |
1652 QPEL_2TAP_XY(OPNAME, SIZE, MMX, 22, _xy2_mmx)\ | |
1653 static const qpel_mc_func OPNAME ## 2tap_qpel ## SIZE ## _mc00_ ## MMX =\ | |
1654 OPNAME ## qpel ## SIZE ## _mc00_ ## MMX;\ | |
1655 static const qpel_mc_func OPNAME ## 2tap_qpel ## SIZE ## _mc21_ ## MMX =\ | |
1656 OPNAME ## 2tap_qpel ## SIZE ## _mc20_ ## MMX;\ | |
1657 static const qpel_mc_func OPNAME ## 2tap_qpel ## SIZE ## _mc12_ ## MMX =\ | |
1658 OPNAME ## 2tap_qpel ## SIZE ## _mc02_ ## MMX;\ | |
1659 static void OPNAME ## 2tap_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1660 OPNAME ## pixels ## SIZE ## _y2_ ## MMX(dst, src+1, stride, SIZE);\ | |
1661 }\ | |
1662 static void OPNAME ## 2tap_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1663 OPNAME ## pixels ## SIZE ## _x2_ ## MMX(dst, src+stride, stride, SIZE);\ | |
1664 }\ | |
1665 QPEL_2TAP_L3(OPNAME, SIZE, MMX, 10, 0, 1, 0)\ | |
1666 QPEL_2TAP_L3(OPNAME, SIZE, MMX, 30, 1, -1, 0)\ | |
1667 QPEL_2TAP_L3(OPNAME, SIZE, MMX, 01, 0, stride, 0)\ | |
1668 QPEL_2TAP_L3(OPNAME, SIZE, MMX, 03, stride, -stride, 0)\ | |
1669 QPEL_2TAP_L3(OPNAME, SIZE, MMX, 11, 0, stride, 1)\ | |
1670 QPEL_2TAP_L3(OPNAME, SIZE, MMX, 31, 1, stride, -1)\ | |
1671 QPEL_2TAP_L3(OPNAME, SIZE, MMX, 13, stride, -stride, 1)\ | |
1672 QPEL_2TAP_L3(OPNAME, SIZE, MMX, 33, stride+1, -stride, -1)\ | |
1673 | |
1674 QPEL_2TAP(put_, 16, mmx2) | |
1675 QPEL_2TAP(avg_, 16, mmx2) | |
1676 QPEL_2TAP(put_, 8, mmx2) | |
1677 QPEL_2TAP(avg_, 8, mmx2) | |
1678 QPEL_2TAP(put_, 16, 3dnow) | |
1679 QPEL_2TAP(avg_, 16, 3dnow) | |
1680 QPEL_2TAP(put_, 8, 3dnow) | |
1681 QPEL_2TAP(avg_, 8, 3dnow) | |
1682 | |
1683 | |
1684 #if 0 | |
8527
f8bf438c6000
Add missing 'void' keyword to parameterless function declarations.
diego
parents:
8519
diff
changeset
|
1685 static void just_return(void) { return; } |
8430 | 1686 #endif |
1687 | |
1688 static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, | |
1689 int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height){ | |
1690 const int w = 8; | |
1691 const int ix = ox>>(16+shift); | |
1692 const int iy = oy>>(16+shift); | |
1693 const int oxs = ox>>4; | |
1694 const int oys = oy>>4; | |
1695 const int dxxs = dxx>>4; | |
1696 const int dxys = dxy>>4; | |
1697 const int dyxs = dyx>>4; | |
1698 const int dyys = dyy>>4; | |
1699 const uint16_t r4[4] = {r,r,r,r}; | |
1700 const uint16_t dxy4[4] = {dxys,dxys,dxys,dxys}; | |
1701 const uint16_t dyy4[4] = {dyys,dyys,dyys,dyys}; | |
1702 const uint64_t shift2 = 2*shift; | |
1703 uint8_t edge_buf[(h+1)*stride]; | |
1704 int x, y; | |
1705 | |
1706 const int dxw = (dxx-(1<<(16+shift)))*(w-1); | |
1707 const int dyh = (dyy-(1<<(16+shift)))*(h-1); | |
1708 const int dxh = dxy*(h-1); | |
1709 const int dyw = dyx*(w-1); | |
1710 if( // non-constant fullpel offset (3% of blocks) | |
1711 ((ox^(ox+dxw)) | (ox^(ox+dxh)) | (ox^(ox+dxw+dxh)) | | |
1712 (oy^(oy+dyw)) | (oy^(oy+dyh)) | (oy^(oy+dyw+dyh))) >> (16+shift) | |
1713 // uses more than 16 bits of subpel mv (only at huge resolution) | |
1714 || (dxx|dxy|dyx|dyy)&15 ) | |
1715 { | |
1716 //FIXME could still use mmx for some of the rows | |
1717 ff_gmc_c(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r, width, height); | |
1718 return; | |
1719 } | |
1720 | |
1721 src += ix + iy*stride; | |
1722 if( (unsigned)ix >= width-w || | |
1723 (unsigned)iy >= height-h ) | |
1724 { | |
1725 ff_emulated_edge_mc(edge_buf, src, stride, w+1, h+1, ix, iy, width, height); | |
1726 src = edge_buf; | |
1727 } | |
1728 | |
1729 __asm__ volatile( | |
1730 "movd %0, %%mm6 \n\t" | |
1731 "pxor %%mm7, %%mm7 \n\t" | |
1732 "punpcklwd %%mm6, %%mm6 \n\t" | |
1733 "punpcklwd %%mm6, %%mm6 \n\t" | |
1734 :: "r"(1<<shift) | |
1735 ); | |
1736 | |
1737 for(x=0; x<w; x+=4){ | |
1738 uint16_t dx4[4] = { oxs - dxys + dxxs*(x+0), | |
1739 oxs - dxys + dxxs*(x+1), | |
1740 oxs - dxys + dxxs*(x+2), | |
1741 oxs - dxys + dxxs*(x+3) }; | |
1742 uint16_t dy4[4] = { oys - dyys + dyxs*(x+0), | |
1743 oys - dyys + dyxs*(x+1), | |
1744 oys - dyys + dyxs*(x+2), | |
1745 oys - dyys + dyxs*(x+3) }; | |
1746 | |
1747 for(y=0; y<h; y++){ | |
1748 __asm__ volatile( | |
1749 "movq %0, %%mm4 \n\t" | |
1750 "movq %1, %%mm5 \n\t" | |
1751 "paddw %2, %%mm4 \n\t" | |
1752 "paddw %3, %%mm5 \n\t" | |
1753 "movq %%mm4, %0 \n\t" | |
1754 "movq %%mm5, %1 \n\t" | |
1755 "psrlw $12, %%mm4 \n\t" | |
1756 "psrlw $12, %%mm5 \n\t" | |
1757 : "+m"(*dx4), "+m"(*dy4) | |
1758 : "m"(*dxy4), "m"(*dyy4) | |
1759 ); | |
1760 | |
1761 __asm__ volatile( | |
1762 "movq %%mm6, %%mm2 \n\t" | |
1763 "movq %%mm6, %%mm1 \n\t" | |
1764 "psubw %%mm4, %%mm2 \n\t" | |
1765 "psubw %%mm5, %%mm1 \n\t" | |
1766 "movq %%mm2, %%mm0 \n\t" | |
1767 "movq %%mm4, %%mm3 \n\t" | |
1768 "pmullw %%mm1, %%mm0 \n\t" // (s-dx)*(s-dy) | |
1769 "pmullw %%mm5, %%mm3 \n\t" // dx*dy | |
1770 "pmullw %%mm5, %%mm2 \n\t" // (s-dx)*dy | |
1771 "pmullw %%mm4, %%mm1 \n\t" // dx*(s-dy) | |
1772 | |
1773 "movd %4, %%mm5 \n\t" | |
1774 "movd %3, %%mm4 \n\t" | |
1775 "punpcklbw %%mm7, %%mm5 \n\t" | |
1776 "punpcklbw %%mm7, %%mm4 \n\t" | |
1777 "pmullw %%mm5, %%mm3 \n\t" // src[1,1] * dx*dy | |
1778 "pmullw %%mm4, %%mm2 \n\t" // src[0,1] * (s-dx)*dy | |
1779 | |
1780 "movd %2, %%mm5 \n\t" | |
1781 "movd %1, %%mm4 \n\t" | |
1782 "punpcklbw %%mm7, %%mm5 \n\t" | |
1783 "punpcklbw %%mm7, %%mm4 \n\t" | |
1784 "pmullw %%mm5, %%mm1 \n\t" // src[1,0] * dx*(s-dy) | |
1785 "pmullw %%mm4, %%mm0 \n\t" // src[0,0] * (s-dx)*(s-dy) | |
1786 "paddw %5, %%mm1 \n\t" | |
1787 "paddw %%mm3, %%mm2 \n\t" | |
1788 "paddw %%mm1, %%mm0 \n\t" | |
1789 "paddw %%mm2, %%mm0 \n\t" | |
1790 | |
1791 "psrlw %6, %%mm0 \n\t" | |
1792 "packuswb %%mm0, %%mm0 \n\t" | |
1793 "movd %%mm0, %0 \n\t" | |
1794 | |
1795 : "=m"(dst[x+y*stride]) | |
1796 : "m"(src[0]), "m"(src[1]), | |
1797 "m"(src[stride]), "m"(src[stride+1]), | |
1798 "m"(*r4), "m"(shift2) | |
1799 ); | |
1800 src += stride; | |
1801 } | |
1802 src += 4-h*stride; | |
1803 } | |
1804 } | |
1805 | |
1806 #define PREFETCH(name, op) \ | |
1807 static void name(void *mem, int stride, int h){\ | |
1808 const uint8_t *p= mem;\ | |
1809 do{\ | |
1810 __asm__ volatile(#op" %0" :: "m"(*p));\ | |
1811 p+= stride;\ | |
1812 }while(--h);\ | |
1813 } | |
1814 PREFETCH(prefetch_mmx2, prefetcht0) | |
1815 PREFETCH(prefetch_3dnow, prefetch) | |
1816 #undef PREFETCH | |
1817 | |
1818 #include "h264dsp_mmx.c" | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
1819 #include "rv40dsp_mmx.c" |
8430 | 1820 |
1821 /* CAVS specific */ | |
1822 void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride) { | |
1823 put_pixels8_mmx(dst, src, stride, 8); | |
1824 } | |
1825 void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride) { | |
1826 avg_pixels8_mmx(dst, src, stride, 8); | |
1827 } | |
1828 void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride) { | |
1829 put_pixels16_mmx(dst, src, stride, 16); | |
1830 } | |
1831 void ff_avg_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride) { | |
1832 avg_pixels16_mmx(dst, src, stride, 16); | |
1833 } | |
1834 | |
1835 /* VC1 specific */ | |
1836 void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd) { | |
1837 put_pixels8_mmx(dst, src, stride, 8); | |
1838 } | |
9441 | 1839 void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, int rnd) { |
1840 avg_pixels8_mmx2(dst, src, stride, 8); | |
1841 } | |
8430 | 1842 |
1843 /* XXX: those functions should be suppressed ASAP when all IDCTs are | |
1844 converted */ | |
8590 | 1845 #if CONFIG_GPL |
8430 | 1846 static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size, DCTELEM *block) |
1847 { | |
1848 ff_mmx_idct (block); | |
1849 put_pixels_clamped_mmx(block, dest, line_size); | |
1850 } | |
1851 static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size, DCTELEM *block) | |
1852 { | |
1853 ff_mmx_idct (block); | |
1854 add_pixels_clamped_mmx(block, dest, line_size); | |
1855 } | |
1856 static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size, DCTELEM *block) | |
1857 { | |
1858 ff_mmxext_idct (block); | |
1859 put_pixels_clamped_mmx(block, dest, line_size); | |
1860 } | |
1861 static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *block) | |
1862 { | |
1863 ff_mmxext_idct (block); | |
1864 add_pixels_clamped_mmx(block, dest, line_size); | |
1865 } | |
1866 #endif | |
1867 static void ff_idct_xvid_mmx_put(uint8_t *dest, int line_size, DCTELEM *block) | |
1868 { | |
1869 ff_idct_xvid_mmx (block); | |
1870 put_pixels_clamped_mmx(block, dest, line_size); | |
1871 } | |
1872 static void ff_idct_xvid_mmx_add(uint8_t *dest, int line_size, DCTELEM *block) | |
1873 { | |
1874 ff_idct_xvid_mmx (block); | |
1875 add_pixels_clamped_mmx(block, dest, line_size); | |
1876 } | |
1877 static void ff_idct_xvid_mmx2_put(uint8_t *dest, int line_size, DCTELEM *block) | |
1878 { | |
1879 ff_idct_xvid_mmx2 (block); | |
1880 put_pixels_clamped_mmx(block, dest, line_size); | |
1881 } | |
1882 static void ff_idct_xvid_mmx2_add(uint8_t *dest, int line_size, DCTELEM *block) | |
1883 { | |
1884 ff_idct_xvid_mmx2 (block); | |
1885 add_pixels_clamped_mmx(block, dest, line_size); | |
1886 } | |
1887 | |
1888 static void vorbis_inverse_coupling_3dnow(float *mag, float *ang, int blocksize) | |
1889 { | |
1890 int i; | |
1891 __asm__ volatile("pxor %%mm7, %%mm7":); | |
1892 for(i=0; i<blocksize; i+=2) { | |
1893 __asm__ volatile( | |
1894 "movq %0, %%mm0 \n\t" | |
1895 "movq %1, %%mm1 \n\t" | |
1896 "movq %%mm0, %%mm2 \n\t" | |
1897 "movq %%mm1, %%mm3 \n\t" | |
1898 "pfcmpge %%mm7, %%mm2 \n\t" // m <= 0.0 | |
1899 "pfcmpge %%mm7, %%mm3 \n\t" // a <= 0.0 | |
1900 "pslld $31, %%mm2 \n\t" // keep only the sign bit | |
1901 "pxor %%mm2, %%mm1 \n\t" | |
1902 "movq %%mm3, %%mm4 \n\t" | |
1903 "pand %%mm1, %%mm3 \n\t" | |
1904 "pandn %%mm1, %%mm4 \n\t" | |
1905 "pfadd %%mm0, %%mm3 \n\t" // a = m + ((a<0) & (a ^ sign(m))) | |
1906 "pfsub %%mm4, %%mm0 \n\t" // m = m + ((a>0) & (a ^ sign(m))) | |
1907 "movq %%mm3, %1 \n\t" | |
1908 "movq %%mm0, %0 \n\t" | |
1909 :"+m"(mag[i]), "+m"(ang[i]) | |
1910 ::"memory" | |
1911 ); | |
1912 } | |
1913 __asm__ volatile("femms"); | |
1914 } | |
1915 static void vorbis_inverse_coupling_sse(float *mag, float *ang, int blocksize) | |
1916 { | |
1917 int i; | |
1918 | |
1919 __asm__ volatile( | |
1920 "movaps %0, %%xmm5 \n\t" | |
1921 ::"m"(ff_pdw_80000000[0]) | |
1922 ); | |
1923 for(i=0; i<blocksize; i+=4) { | |
1924 __asm__ volatile( | |
1925 "movaps %0, %%xmm0 \n\t" | |
1926 "movaps %1, %%xmm1 \n\t" | |
1927 "xorps %%xmm2, %%xmm2 \n\t" | |
1928 "xorps %%xmm3, %%xmm3 \n\t" | |
1929 "cmpleps %%xmm0, %%xmm2 \n\t" // m <= 0.0 | |
1930 "cmpleps %%xmm1, %%xmm3 \n\t" // a <= 0.0 | |
1931 "andps %%xmm5, %%xmm2 \n\t" // keep only the sign bit | |
1932 "xorps %%xmm2, %%xmm1 \n\t" | |
1933 "movaps %%xmm3, %%xmm4 \n\t" | |
1934 "andps %%xmm1, %%xmm3 \n\t" | |
1935 "andnps %%xmm1, %%xmm4 \n\t" | |
1936 "addps %%xmm0, %%xmm3 \n\t" // a = m + ((a<0) & (a ^ sign(m))) | |
1937 "subps %%xmm4, %%xmm0 \n\t" // m = m + ((a>0) & (a ^ sign(m))) | |
1938 "movaps %%xmm3, %1 \n\t" | |
1939 "movaps %%xmm0, %0 \n\t" | |
1940 :"+m"(mag[i]), "+m"(ang[i]) | |
1941 ::"memory" | |
1942 ); | |
1943 } | |
1944 } | |
1945 | |
1946 #define IF1(x) x | |
1947 #define IF0(x) | |
1948 | |
1949 #define MIX5(mono,stereo)\ | |
1950 __asm__ volatile(\ | |
1951 "movss 0(%2), %%xmm5 \n"\ | |
1952 "movss 8(%2), %%xmm6 \n"\ | |
1953 "movss 24(%2), %%xmm7 \n"\ | |
1954 "shufps $0, %%xmm5, %%xmm5 \n"\ | |
1955 "shufps $0, %%xmm6, %%xmm6 \n"\ | |
1956 "shufps $0, %%xmm7, %%xmm7 \n"\ | |
1957 "1: \n"\ | |
1958 "movaps (%0,%1), %%xmm0 \n"\ | |
1959 "movaps 0x400(%0,%1), %%xmm1 \n"\ | |
1960 "movaps 0x800(%0,%1), %%xmm2 \n"\ | |
1961 "movaps 0xc00(%0,%1), %%xmm3 \n"\ | |
1962 "movaps 0x1000(%0,%1), %%xmm4 \n"\ | |
1963 "mulps %%xmm5, %%xmm0 \n"\ | |
1964 "mulps %%xmm6, %%xmm1 \n"\ | |
1965 "mulps %%xmm5, %%xmm2 \n"\ | |
1966 "mulps %%xmm7, %%xmm3 \n"\ | |
1967 "mulps %%xmm7, %%xmm4 \n"\ | |
1968 stereo("addps %%xmm1, %%xmm0 \n")\ | |
1969 "addps %%xmm1, %%xmm2 \n"\ | |
1970 "addps %%xmm3, %%xmm0 \n"\ | |
1971 "addps %%xmm4, %%xmm2 \n"\ | |
1972 mono("addps %%xmm2, %%xmm0 \n")\ | |
1973 "movaps %%xmm0, (%0,%1) \n"\ | |
1974 stereo("movaps %%xmm2, 0x400(%0,%1) \n")\ | |
1975 "add $16, %0 \n"\ | |
1976 "jl 1b \n"\ | |
1977 :"+&r"(i)\ | |
1978 :"r"(samples[0]+len), "r"(matrix)\ | |
1979 :"memory"\ | |
1980 ); | |
1981 | |
1982 #define MIX_MISC(stereo)\ | |
1983 __asm__ volatile(\ | |
1984 "1: \n"\ | |
1985 "movaps (%3,%0), %%xmm0 \n"\ | |
1986 stereo("movaps %%xmm0, %%xmm1 \n")\ | |
1987 "mulps %%xmm6, %%xmm0 \n"\ | |
1988 stereo("mulps %%xmm7, %%xmm1 \n")\ | |
1989 "lea 1024(%3,%0), %1 \n"\ | |
1990 "mov %5, %2 \n"\ | |
1991 "2: \n"\ | |
1992 "movaps (%1), %%xmm2 \n"\ | |
1993 stereo("movaps %%xmm2, %%xmm3 \n")\ | |
1994 "mulps (%4,%2), %%xmm2 \n"\ | |
1995 stereo("mulps 16(%4,%2), %%xmm3 \n")\ | |
1996 "addps %%xmm2, %%xmm0 \n"\ | |
1997 stereo("addps %%xmm3, %%xmm1 \n")\ | |
1998 "add $1024, %1 \n"\ | |
1999 "add $32, %2 \n"\ | |
2000 "jl 2b \n"\ | |
2001 "movaps %%xmm0, (%3,%0) \n"\ | |
2002 stereo("movaps %%xmm1, 1024(%3,%0) \n")\ | |
2003 "add $16, %0 \n"\ | |
2004 "jl 1b \n"\ | |
2005 :"+&r"(i), "=&r"(j), "=&r"(k)\ | |
2006 :"r"(samples[0]+len), "r"(matrix_simd+in_ch), "g"((intptr_t)-32*(in_ch-1))\ | |
2007 :"memory"\ | |
2008 ); | |
2009 | |
2010 static void ac3_downmix_sse(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len) | |
2011 { | |
2012 int (*matrix_cmp)[2] = (int(*)[2])matrix; | |
2013 intptr_t i,j,k; | |
2014 | |
2015 i = -len*sizeof(float); | |
2016 if(in_ch == 5 && out_ch == 2 && !(matrix_cmp[0][1]|matrix_cmp[2][0]|matrix_cmp[3][1]|matrix_cmp[4][0]|(matrix_cmp[1][0]^matrix_cmp[1][1])|(matrix_cmp[0][0]^matrix_cmp[2][1]))) { | |
2017 MIX5(IF0,IF1); | |
2018 } else if(in_ch == 5 && out_ch == 1 && matrix_cmp[0][0]==matrix_cmp[2][0] && matrix_cmp[3][0]==matrix_cmp[4][0]) { | |
2019 MIX5(IF1,IF0); | |
2020 } else { | |
11369 | 2021 DECLARE_ALIGNED(16, float, matrix_simd)[in_ch][2][4]; |
8430 | 2022 j = 2*in_ch*sizeof(float); |
2023 __asm__ volatile( | |
2024 "1: \n" | |
2025 "sub $8, %0 \n" | |
2026 "movss (%2,%0), %%xmm6 \n" | |
2027 "movss 4(%2,%0), %%xmm7 \n" | |
2028 "shufps $0, %%xmm6, %%xmm6 \n" | |
2029 "shufps $0, %%xmm7, %%xmm7 \n" | |
2030 "movaps %%xmm6, (%1,%0,4) \n" | |
2031 "movaps %%xmm7, 16(%1,%0,4) \n" | |
2032 "jg 1b \n" | |
2033 :"+&r"(j) | |
2034 :"r"(matrix_simd), "r"(matrix) | |
2035 :"memory" | |
2036 ); | |
2037 if(out_ch == 2) { | |
2038 MIX_MISC(IF1); | |
2039 } else { | |
2040 MIX_MISC(IF0); | |
2041 } | |
2042 } | |
2043 } | |
2044 | |
2045 static void vector_fmul_3dnow(float *dst, const float *src, int len){ | |
2046 x86_reg i = (len-4)*4; | |
2047 __asm__ volatile( | |
2048 "1: \n\t" | |
2049 "movq (%1,%0), %%mm0 \n\t" | |
2050 "movq 8(%1,%0), %%mm1 \n\t" | |
2051 "pfmul (%2,%0), %%mm0 \n\t" | |
2052 "pfmul 8(%2,%0), %%mm1 \n\t" | |
2053 "movq %%mm0, (%1,%0) \n\t" | |
2054 "movq %%mm1, 8(%1,%0) \n\t" | |
2055 "sub $16, %0 \n\t" | |
2056 "jge 1b \n\t" | |
2057 "femms \n\t" | |
2058 :"+r"(i) | |
2059 :"r"(dst), "r"(src) | |
2060 :"memory" | |
2061 ); | |
2062 } | |
2063 static void vector_fmul_sse(float *dst, const float *src, int len){ | |
2064 x86_reg i = (len-8)*4; | |
2065 __asm__ volatile( | |
2066 "1: \n\t" | |
2067 "movaps (%1,%0), %%xmm0 \n\t" | |
2068 "movaps 16(%1,%0), %%xmm1 \n\t" | |
2069 "mulps (%2,%0), %%xmm0 \n\t" | |
2070 "mulps 16(%2,%0), %%xmm1 \n\t" | |
2071 "movaps %%xmm0, (%1,%0) \n\t" | |
2072 "movaps %%xmm1, 16(%1,%0) \n\t" | |
2073 "sub $32, %0 \n\t" | |
2074 "jge 1b \n\t" | |
2075 :"+r"(i) | |
2076 :"r"(dst), "r"(src) | |
2077 :"memory" | |
2078 ); | |
2079 } | |
2080 | |
2081 static void vector_fmul_reverse_3dnow2(float *dst, const float *src0, const float *src1, int len){ | |
2082 x86_reg i = len*4-16; | |
2083 __asm__ volatile( | |
2084 "1: \n\t" | |
2085 "pswapd 8(%1), %%mm0 \n\t" | |
2086 "pswapd (%1), %%mm1 \n\t" | |
2087 "pfmul (%3,%0), %%mm0 \n\t" | |
2088 "pfmul 8(%3,%0), %%mm1 \n\t" | |
2089 "movq %%mm0, (%2,%0) \n\t" | |
2090 "movq %%mm1, 8(%2,%0) \n\t" | |
2091 "add $16, %1 \n\t" | |
2092 "sub $16, %0 \n\t" | |
2093 "jge 1b \n\t" | |
2094 :"+r"(i), "+r"(src1) | |
2095 :"r"(dst), "r"(src0) | |
2096 ); | |
2097 __asm__ volatile("femms"); | |
2098 } | |
2099 static void vector_fmul_reverse_sse(float *dst, const float *src0, const float *src1, int len){ | |
2100 x86_reg i = len*4-32; | |
2101 __asm__ volatile( | |
2102 "1: \n\t" | |
2103 "movaps 16(%1), %%xmm0 \n\t" | |
2104 "movaps (%1), %%xmm1 \n\t" | |
2105 "shufps $0x1b, %%xmm0, %%xmm0 \n\t" | |
2106 "shufps $0x1b, %%xmm1, %%xmm1 \n\t" | |
2107 "mulps (%3,%0), %%xmm0 \n\t" | |
2108 "mulps 16(%3,%0), %%xmm1 \n\t" | |
2109 "movaps %%xmm0, (%2,%0) \n\t" | |
2110 "movaps %%xmm1, 16(%2,%0) \n\t" | |
2111 "add $32, %1 \n\t" | |
2112 "sub $32, %0 \n\t" | |
2113 "jge 1b \n\t" | |
2114 :"+r"(i), "+r"(src1) | |
2115 :"r"(dst), "r"(src0) | |
2116 ); | |
2117 } | |
2118 | |
10300
4d1b9ca628fc
Drop unused args from vector_fmul_add_add, simpify code, and rename
mru
parents:
10107
diff
changeset
|
2119 static void vector_fmul_add_3dnow(float *dst, const float *src0, const float *src1, |
4d1b9ca628fc
Drop unused args from vector_fmul_add_add, simpify code, and rename
mru
parents:
10107
diff
changeset
|
2120 const float *src2, int len){ |
8430 | 2121 x86_reg i = (len-4)*4; |
10301 | 2122 __asm__ volatile( |
2123 "1: \n\t" | |
2124 "movq (%2,%0), %%mm0 \n\t" | |
2125 "movq 8(%2,%0), %%mm1 \n\t" | |
2126 "pfmul (%3,%0), %%mm0 \n\t" | |
2127 "pfmul 8(%3,%0), %%mm1 \n\t" | |
2128 "pfadd (%4,%0), %%mm0 \n\t" | |
2129 "pfadd 8(%4,%0), %%mm1 \n\t" | |
2130 "movq %%mm0, (%1,%0) \n\t" | |
2131 "movq %%mm1, 8(%1,%0) \n\t" | |
2132 "sub $16, %0 \n\t" | |
2133 "jge 1b \n\t" | |
2134 :"+r"(i) | |
2135 :"r"(dst), "r"(src0), "r"(src1), "r"(src2) | |
2136 :"memory" | |
2137 ); | |
8430 | 2138 __asm__ volatile("femms"); |
2139 } | |
10300
4d1b9ca628fc
Drop unused args from vector_fmul_add_add, simpify code, and rename
mru
parents:
10107
diff
changeset
|
2140 static void vector_fmul_add_sse(float *dst, const float *src0, const float *src1, |
4d1b9ca628fc
Drop unused args from vector_fmul_add_add, simpify code, and rename
mru
parents:
10107
diff
changeset
|
2141 const float *src2, int len){ |
8430 | 2142 x86_reg i = (len-8)*4; |
10301 | 2143 __asm__ volatile( |
2144 "1: \n\t" | |
2145 "movaps (%2,%0), %%xmm0 \n\t" | |
2146 "movaps 16(%2,%0), %%xmm1 \n\t" | |
2147 "mulps (%3,%0), %%xmm0 \n\t" | |
2148 "mulps 16(%3,%0), %%xmm1 \n\t" | |
2149 "addps (%4,%0), %%xmm0 \n\t" | |
2150 "addps 16(%4,%0), %%xmm1 \n\t" | |
2151 "movaps %%xmm0, (%1,%0) \n\t" | |
2152 "movaps %%xmm1, 16(%1,%0) \n\t" | |
2153 "sub $32, %0 \n\t" | |
2154 "jge 1b \n\t" | |
2155 :"+r"(i) | |
2156 :"r"(dst), "r"(src0), "r"(src1), "r"(src2) | |
2157 :"memory" | |
2158 ); | |
8430 | 2159 } |
2160 | |
2161 static void vector_fmul_window_3dnow2(float *dst, const float *src0, const float *src1, | |
2162 const float *win, float add_bias, int len){ | |
8590 | 2163 #if HAVE_6REGS |
8430 | 2164 if(add_bias == 0){ |
2165 x86_reg i = -len*4; | |
2166 x86_reg j = len*4-8; | |
2167 __asm__ volatile( | |
2168 "1: \n" | |
2169 "pswapd (%5,%1), %%mm1 \n" | |
2170 "movq (%5,%0), %%mm0 \n" | |
2171 "pswapd (%4,%1), %%mm5 \n" | |
2172 "movq (%3,%0), %%mm4 \n" | |
2173 "movq %%mm0, %%mm2 \n" | |
2174 "movq %%mm1, %%mm3 \n" | |
2175 "pfmul %%mm4, %%mm2 \n" // src0[len+i]*win[len+i] | |
2176 "pfmul %%mm5, %%mm3 \n" // src1[ j]*win[len+j] | |
2177 "pfmul %%mm4, %%mm1 \n" // src0[len+i]*win[len+j] | |
2178 "pfmul %%mm5, %%mm0 \n" // src1[ j]*win[len+i] | |
2179 "pfadd %%mm3, %%mm2 \n" | |
2180 "pfsub %%mm0, %%mm1 \n" | |
2181 "pswapd %%mm2, %%mm2 \n" | |
2182 "movq %%mm1, (%2,%0) \n" | |
2183 "movq %%mm2, (%2,%1) \n" | |
2184 "sub $8, %1 \n" | |
2185 "add $8, %0 \n" | |
2186 "jl 1b \n" | |
2187 "femms \n" | |
2188 :"+r"(i), "+r"(j) | |
2189 :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len) | |
2190 ); | |
2191 }else | |
2192 #endif | |
2193 ff_vector_fmul_window_c(dst, src0, src1, win, add_bias, len); | |
2194 } | |
2195 | |
2196 static void vector_fmul_window_sse(float *dst, const float *src0, const float *src1, | |
2197 const float *win, float add_bias, int len){ | |
8590 | 2198 #if HAVE_6REGS |
8430 | 2199 if(add_bias == 0){ |
2200 x86_reg i = -len*4; | |
2201 x86_reg j = len*4-16; | |
2202 __asm__ volatile( | |
2203 "1: \n" | |
2204 "movaps (%5,%1), %%xmm1 \n" | |
2205 "movaps (%5,%0), %%xmm0 \n" | |
2206 "movaps (%4,%1), %%xmm5 \n" | |
2207 "movaps (%3,%0), %%xmm4 \n" | |
2208 "shufps $0x1b, %%xmm1, %%xmm1 \n" | |
2209 "shufps $0x1b, %%xmm5, %%xmm5 \n" | |
2210 "movaps %%xmm0, %%xmm2 \n" | |
2211 "movaps %%xmm1, %%xmm3 \n" | |
2212 "mulps %%xmm4, %%xmm2 \n" // src0[len+i]*win[len+i] | |
2213 "mulps %%xmm5, %%xmm3 \n" // src1[ j]*win[len+j] | |
2214 "mulps %%xmm4, %%xmm1 \n" // src0[len+i]*win[len+j] | |
2215 "mulps %%xmm5, %%xmm0 \n" // src1[ j]*win[len+i] | |
2216 "addps %%xmm3, %%xmm2 \n" | |
2217 "subps %%xmm0, %%xmm1 \n" | |
2218 "shufps $0x1b, %%xmm2, %%xmm2 \n" | |
2219 "movaps %%xmm1, (%2,%0) \n" | |
2220 "movaps %%xmm2, (%2,%1) \n" | |
2221 "sub $16, %1 \n" | |
2222 "add $16, %0 \n" | |
2223 "jl 1b \n" | |
2224 :"+r"(i), "+r"(j) | |
2225 :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len) | |
2226 ); | |
2227 }else | |
2228 #endif | |
2229 ff_vector_fmul_window_c(dst, src0, src1, win, add_bias, len); | |
2230 } | |
2231 | |
2232 static void int32_to_float_fmul_scalar_sse(float *dst, const int *src, float mul, int len) | |
2233 { | |
2234 x86_reg i = -4*len; | |
2235 __asm__ volatile( | |
2236 "movss %3, %%xmm4 \n" | |
2237 "shufps $0, %%xmm4, %%xmm4 \n" | |
2238 "1: \n" | |
2239 "cvtpi2ps (%2,%0), %%xmm0 \n" | |
2240 "cvtpi2ps 8(%2,%0), %%xmm1 \n" | |
2241 "cvtpi2ps 16(%2,%0), %%xmm2 \n" | |
2242 "cvtpi2ps 24(%2,%0), %%xmm3 \n" | |
2243 "movlhps %%xmm1, %%xmm0 \n" | |
2244 "movlhps %%xmm3, %%xmm2 \n" | |
2245 "mulps %%xmm4, %%xmm0 \n" | |
2246 "mulps %%xmm4, %%xmm2 \n" | |
2247 "movaps %%xmm0, (%1,%0) \n" | |
2248 "movaps %%xmm2, 16(%1,%0) \n" | |
2249 "add $32, %0 \n" | |
2250 "jl 1b \n" | |
2251 :"+r"(i) | |
2252 :"r"(dst+len), "r"(src+len), "m"(mul) | |
2253 ); | |
2254 } | |
2255 | |
2256 static void int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len) | |
2257 { | |
2258 x86_reg i = -4*len; | |
2259 __asm__ volatile( | |
2260 "movss %3, %%xmm4 \n" | |
2261 "shufps $0, %%xmm4, %%xmm4 \n" | |
2262 "1: \n" | |
2263 "cvtdq2ps (%2,%0), %%xmm0 \n" | |
2264 "cvtdq2ps 16(%2,%0), %%xmm1 \n" | |
2265 "mulps %%xmm4, %%xmm0 \n" | |
2266 "mulps %%xmm4, %%xmm1 \n" | |
2267 "movaps %%xmm0, (%1,%0) \n" | |
2268 "movaps %%xmm1, 16(%1,%0) \n" | |
2269 "add $32, %0 \n" | |
2270 "jl 1b \n" | |
2271 :"+r"(i) | |
2272 :"r"(dst+len), "r"(src+len), "m"(mul) | |
2273 ); | |
2274 } | |
2275 | |
10105 | 2276 static void vector_clipf_sse(float *dst, const float *src, float min, float max, |
10104
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2277 int len) |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2278 { |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2279 x86_reg i = (len-16)*4; |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2280 __asm__ volatile( |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2281 "movss %3, %%xmm4 \n" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2282 "movss %4, %%xmm5 \n" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2283 "shufps $0, %%xmm4, %%xmm4 \n" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2284 "shufps $0, %%xmm5, %%xmm5 \n" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2285 "1: \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2286 "movaps (%2,%0), %%xmm0 \n\t" // 3/1 on intel |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2287 "movaps 16(%2,%0), %%xmm1 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2288 "movaps 32(%2,%0), %%xmm2 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2289 "movaps 48(%2,%0), %%xmm3 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2290 "maxps %%xmm4, %%xmm0 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2291 "maxps %%xmm4, %%xmm1 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2292 "maxps %%xmm4, %%xmm2 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2293 "maxps %%xmm4, %%xmm3 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2294 "minps %%xmm5, %%xmm0 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2295 "minps %%xmm5, %%xmm1 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2296 "minps %%xmm5, %%xmm2 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2297 "minps %%xmm5, %%xmm3 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2298 "movaps %%xmm0, (%1,%0) \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2299 "movaps %%xmm1, 16(%1,%0) \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2300 "movaps %%xmm2, 32(%1,%0) \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2301 "movaps %%xmm3, 48(%1,%0) \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2302 "sub $64, %0 \n\t" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2303 "jge 1b \n\t" |
10107
3b61bc6ce377
Mark "i" parameter of vector_clipf_sse() as early-clobber
vitor
parents:
10105
diff
changeset
|
2304 :"+&r"(i) |
10104
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2305 :"r"(dst), "r"(src), "m"(min), "m"(max) |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2306 :"memory" |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2307 ); |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2308 } |
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2309 |
8430 | 2310 static void float_to_int16_3dnow(int16_t *dst, const float *src, long len){ |
2311 x86_reg reglen = len; | |
2312 // not bit-exact: pf2id uses different rounding than C and SSE | |
2313 __asm__ volatile( | |
2314 "add %0 , %0 \n\t" | |
2315 "lea (%2,%0,2) , %2 \n\t" | |
2316 "add %0 , %1 \n\t" | |
2317 "neg %0 \n\t" | |
2318 "1: \n\t" | |
2319 "pf2id (%2,%0,2) , %%mm0 \n\t" | |
2320 "pf2id 8(%2,%0,2) , %%mm1 \n\t" | |
2321 "pf2id 16(%2,%0,2) , %%mm2 \n\t" | |
2322 "pf2id 24(%2,%0,2) , %%mm3 \n\t" | |
2323 "packssdw %%mm1 , %%mm0 \n\t" | |
2324 "packssdw %%mm3 , %%mm2 \n\t" | |
2325 "movq %%mm0 , (%1,%0) \n\t" | |
2326 "movq %%mm2 , 8(%1,%0) \n\t" | |
2327 "add $16 , %0 \n\t" | |
2328 " js 1b \n\t" | |
2329 "femms \n\t" | |
2330 :"+r"(reglen), "+r"(dst), "+r"(src) | |
2331 ); | |
2332 } | |
2333 static void float_to_int16_sse(int16_t *dst, const float *src, long len){ | |
2334 x86_reg reglen = len; | |
2335 __asm__ volatile( | |
2336 "add %0 , %0 \n\t" | |
2337 "lea (%2,%0,2) , %2 \n\t" | |
2338 "add %0 , %1 \n\t" | |
2339 "neg %0 \n\t" | |
2340 "1: \n\t" | |
2341 "cvtps2pi (%2,%0,2) , %%mm0 \n\t" | |
2342 "cvtps2pi 8(%2,%0,2) , %%mm1 \n\t" | |
2343 "cvtps2pi 16(%2,%0,2) , %%mm2 \n\t" | |
2344 "cvtps2pi 24(%2,%0,2) , %%mm3 \n\t" | |
2345 "packssdw %%mm1 , %%mm0 \n\t" | |
2346 "packssdw %%mm3 , %%mm2 \n\t" | |
2347 "movq %%mm0 , (%1,%0) \n\t" | |
2348 "movq %%mm2 , 8(%1,%0) \n\t" | |
2349 "add $16 , %0 \n\t" | |
2350 " js 1b \n\t" | |
2351 "emms \n\t" | |
2352 :"+r"(reglen), "+r"(dst), "+r"(src) | |
2353 ); | |
2354 } | |
2355 | |
2356 static void float_to_int16_sse2(int16_t *dst, const float *src, long len){ | |
2357 x86_reg reglen = len; | |
2358 __asm__ volatile( | |
2359 "add %0 , %0 \n\t" | |
2360 "lea (%2,%0,2) , %2 \n\t" | |
2361 "add %0 , %1 \n\t" | |
2362 "neg %0 \n\t" | |
2363 "1: \n\t" | |
2364 "cvtps2dq (%2,%0,2) , %%xmm0 \n\t" | |
2365 "cvtps2dq 16(%2,%0,2) , %%xmm1 \n\t" | |
2366 "packssdw %%xmm1 , %%xmm0 \n\t" | |
2367 "movdqa %%xmm0 , (%1,%0) \n\t" | |
2368 "add $16 , %0 \n\t" | |
2369 " js 1b \n\t" | |
2370 :"+r"(reglen), "+r"(dst), "+r"(src) | |
2371 ); | |
2372 } | |
2373 | |
2374 void ff_float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len); | |
2375 void ff_float_to_int16_interleave6_3dnow(int16_t *dst, const float **src, int len); | |
2376 void ff_float_to_int16_interleave6_3dn2(int16_t *dst, const float **src, int len); | |
10644 | 2377 int32_t ff_scalarproduct_int16_mmx2(int16_t *v1, int16_t *v2, int order, int shift); |
2378 int32_t ff_scalarproduct_int16_sse2(int16_t *v1, int16_t *v2, int order, int shift); | |
2379 int32_t ff_scalarproduct_and_madd_int16_mmx2(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul); | |
2380 int32_t ff_scalarproduct_and_madd_int16_sse2(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul); | |
2381 int32_t ff_scalarproduct_and_madd_int16_ssse3(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul); | |
10431 | 2382 void ff_add_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top); |
2383 int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src, int w, int left); | |
2384 int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src, int w, int left); | |
8430 | 2385 void ff_x264_deblock_v_luma_sse2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); |
2386 void ff_x264_deblock_h_luma_sse2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); | |
10645 | 2387 void ff_x264_deblock_h_luma_intra_mmxext(uint8_t *pix, int stride, int alpha, int beta); |
2388 void ff_x264_deblock_v_luma_intra_sse2(uint8_t *pix, int stride, int alpha, int beta); | |
2389 void ff_x264_deblock_h_luma_intra_sse2(uint8_t *pix, int stride, int alpha, int beta); | |
2390 | |
2391 #if HAVE_YASM && ARCH_X86_32 | |
8430 | 2392 void ff_x264_deblock_v8_luma_intra_mmxext(uint8_t *pix, int stride, int alpha, int beta); |
2393 static void ff_x264_deblock_v_luma_intra_mmxext(uint8_t *pix, int stride, int alpha, int beta) | |
2394 { | |
2395 ff_x264_deblock_v8_luma_intra_mmxext(pix+0, stride, alpha, beta); | |
2396 ff_x264_deblock_v8_luma_intra_mmxext(pix+8, stride, alpha, beta); | |
2397 } | |
10645 | 2398 #elif !HAVE_YASM |
8430 | 2399 #define ff_float_to_int16_interleave6_sse(a,b,c) float_to_int16_interleave_misc_sse(a,b,c,6) |
2400 #define ff_float_to_int16_interleave6_3dnow(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6) | |
2401 #define ff_float_to_int16_interleave6_3dn2(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6) | |
2402 #endif | |
2403 #define ff_float_to_int16_interleave6_sse2 ff_float_to_int16_interleave6_sse | |
2404 | |
2405 #define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \ | |
2406 /* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\ | |
2407 static av_noinline void float_to_int16_interleave_misc_##cpu(int16_t *dst, const float **src, long len, int channels){\ | |
11369 | 2408 DECLARE_ALIGNED(16, int16_t, tmp)[len];\ |
8430 | 2409 int i,j,c;\ |
2410 for(c=0; c<channels; c++){\ | |
2411 float_to_int16_##cpu(tmp, src[c], len);\ | |
2412 for(i=0, j=c; i<len; i++, j+=channels)\ | |
2413 dst[j] = tmp[i];\ | |
2414 }\ | |
2415 }\ | |
2416 \ | |
2417 static void float_to_int16_interleave_##cpu(int16_t *dst, const float **src, long len, int channels){\ | |
2418 if(channels==1)\ | |
2419 float_to_int16_##cpu(dst, src[0], len);\ | |
2420 else if(channels==2){\ | |
2421 x86_reg reglen = len; \ | |
2422 const float *src0 = src[0];\ | |
2423 const float *src1 = src[1];\ | |
2424 __asm__ volatile(\ | |
2425 "shl $2, %0 \n"\ | |
2426 "add %0, %1 \n"\ | |
2427 "add %0, %2 \n"\ | |
2428 "add %0, %3 \n"\ | |
2429 "neg %0 \n"\ | |
2430 body\ | |
2431 :"+r"(reglen), "+r"(dst), "+r"(src0), "+r"(src1)\ | |
2432 );\ | |
2433 }else if(channels==6){\ | |
2434 ff_float_to_int16_interleave6_##cpu(dst, src, len);\ | |
2435 }else\ | |
2436 float_to_int16_interleave_misc_##cpu(dst, src, len, channels);\ | |
2437 } | |
2438 | |
2439 FLOAT_TO_INT16_INTERLEAVE(3dnow, | |
2440 "1: \n" | |
2441 "pf2id (%2,%0), %%mm0 \n" | |
2442 "pf2id 8(%2,%0), %%mm1 \n" | |
2443 "pf2id (%3,%0), %%mm2 \n" | |
2444 "pf2id 8(%3,%0), %%mm3 \n" | |
2445 "packssdw %%mm1, %%mm0 \n" | |
2446 "packssdw %%mm3, %%mm2 \n" | |
2447 "movq %%mm0, %%mm1 \n" | |
2448 "punpcklwd %%mm2, %%mm0 \n" | |
2449 "punpckhwd %%mm2, %%mm1 \n" | |
2450 "movq %%mm0, (%1,%0)\n" | |
2451 "movq %%mm1, 8(%1,%0)\n" | |
2452 "add $16, %0 \n" | |
2453 "js 1b \n" | |
2454 "femms \n" | |
2455 ) | |
2456 | |
2457 FLOAT_TO_INT16_INTERLEAVE(sse, | |
2458 "1: \n" | |
2459 "cvtps2pi (%2,%0), %%mm0 \n" | |
2460 "cvtps2pi 8(%2,%0), %%mm1 \n" | |
2461 "cvtps2pi (%3,%0), %%mm2 \n" | |
2462 "cvtps2pi 8(%3,%0), %%mm3 \n" | |
2463 "packssdw %%mm1, %%mm0 \n" | |
2464 "packssdw %%mm3, %%mm2 \n" | |
2465 "movq %%mm0, %%mm1 \n" | |
2466 "punpcklwd %%mm2, %%mm0 \n" | |
2467 "punpckhwd %%mm2, %%mm1 \n" | |
2468 "movq %%mm0, (%1,%0)\n" | |
2469 "movq %%mm1, 8(%1,%0)\n" | |
2470 "add $16, %0 \n" | |
2471 "js 1b \n" | |
2472 "emms \n" | |
2473 ) | |
2474 | |
2475 FLOAT_TO_INT16_INTERLEAVE(sse2, | |
2476 "1: \n" | |
2477 "cvtps2dq (%2,%0), %%xmm0 \n" | |
2478 "cvtps2dq (%3,%0), %%xmm1 \n" | |
2479 "packssdw %%xmm1, %%xmm0 \n" | |
2480 "movhlps %%xmm0, %%xmm1 \n" | |
2481 "punpcklwd %%xmm1, %%xmm0 \n" | |
2482 "movdqa %%xmm0, (%1,%0) \n" | |
2483 "add $16, %0 \n" | |
2484 "js 1b \n" | |
2485 ) | |
2486 | |
2487 static void float_to_int16_interleave_3dn2(int16_t *dst, const float **src, long len, int channels){ | |
2488 if(channels==6) | |
2489 ff_float_to_int16_interleave6_3dn2(dst, src, len); | |
2490 else | |
2491 float_to_int16_interleave_3dnow(dst, src, len, channels); | |
2492 } | |
2493 | |
10964 | 2494 float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); |
2495 | |
8430 | 2496 void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) |
2497 { | |
2498 mm_flags = mm_support(); | |
2499 | |
2500 if (avctx->dsp_mask) { | |
2501 if (avctx->dsp_mask & FF_MM_FORCE) | |
2502 mm_flags |= (avctx->dsp_mask & 0xffff); | |
2503 else | |
2504 mm_flags &= ~(avctx->dsp_mask & 0xffff); | |
2505 } | |
2506 | |
2507 #if 0 | |
2508 av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:"); | |
2509 if (mm_flags & FF_MM_MMX) | |
2510 av_log(avctx, AV_LOG_INFO, " mmx"); | |
9342
7f594601d5e9
Rename FF_MM_MMXEXT to FF_MM_MMX2, for both clarity and consistency
stefano
parents:
9341
diff
changeset
|
2511 if (mm_flags & FF_MM_MMX2) |
7f594601d5e9
Rename FF_MM_MMXEXT to FF_MM_MMX2, for both clarity and consistency
stefano
parents:
9341
diff
changeset
|
2512 av_log(avctx, AV_LOG_INFO, " mmx2"); |
8430 | 2513 if (mm_flags & FF_MM_3DNOW) |
2514 av_log(avctx, AV_LOG_INFO, " 3dnow"); | |
2515 if (mm_flags & FF_MM_SSE) | |
2516 av_log(avctx, AV_LOG_INFO, " sse"); | |
2517 if (mm_flags & FF_MM_SSE2) | |
2518 av_log(avctx, AV_LOG_INFO, " sse2"); | |
2519 av_log(avctx, AV_LOG_INFO, "\n"); | |
2520 #endif | |
2521 | |
2522 if (mm_flags & FF_MM_MMX) { | |
2523 const int idct_algo= avctx->idct_algo; | |
2524 | |
2525 if(avctx->lowres==0){ | |
2526 if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){ | |
2527 c->idct_put= ff_simple_idct_put_mmx; | |
2528 c->idct_add= ff_simple_idct_add_mmx; | |
2529 c->idct = ff_simple_idct_mmx; | |
2530 c->idct_permutation_type= FF_SIMPLE_IDCT_PERM; | |
8590 | 2531 #if CONFIG_GPL |
8430 | 2532 }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){ |
9342
7f594601d5e9
Rename FF_MM_MMXEXT to FF_MM_MMX2, for both clarity and consistency
stefano
parents:
9341
diff
changeset
|
2533 if(mm_flags & FF_MM_MMX2){ |
8430 | 2534 c->idct_put= ff_libmpeg2mmx2_idct_put; |
2535 c->idct_add= ff_libmpeg2mmx2_idct_add; | |
2536 c->idct = ff_mmxext_idct; | |
2537 }else{ | |
2538 c->idct_put= ff_libmpeg2mmx_idct_put; | |
2539 c->idct_add= ff_libmpeg2mmx_idct_add; | |
2540 c->idct = ff_mmx_idct; | |
2541 } | |
2542 c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; | |
2543 #endif | |
9975
d6d7e8d4a04d
Do not redundantly check for both CONFIG_THEORA_DECODER and CONFIG_VP3_DECODER.
diego
parents:
9959
diff
changeset
|
2544 }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER) && |
8430 | 2545 idct_algo==FF_IDCT_VP3){ |
2546 if(mm_flags & FF_MM_SSE2){ | |
2547 c->idct_put= ff_vp3_idct_put_sse2; | |
2548 c->idct_add= ff_vp3_idct_add_sse2; | |
2549 c->idct = ff_vp3_idct_sse2; | |
2550 c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM; | |
2551 }else{ | |
2552 c->idct_put= ff_vp3_idct_put_mmx; | |
2553 c->idct_add= ff_vp3_idct_add_mmx; | |
2554 c->idct = ff_vp3_idct_mmx; | |
2555 c->idct_permutation_type= FF_PARTTRANS_IDCT_PERM; | |
2556 } | |
2557 }else if(idct_algo==FF_IDCT_CAVS){ | |
2558 c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM; | |
2559 }else if(idct_algo==FF_IDCT_XVIDMMX){ | |
2560 if(mm_flags & FF_MM_SSE2){ | |
2561 c->idct_put= ff_idct_xvid_sse2_put; | |
2562 c->idct_add= ff_idct_xvid_sse2_add; | |
2563 c->idct = ff_idct_xvid_sse2; | |
2564 c->idct_permutation_type= FF_SSE2_IDCT_PERM; | |
9342
7f594601d5e9
Rename FF_MM_MMXEXT to FF_MM_MMX2, for both clarity and consistency
stefano
parents:
9341
diff
changeset
|
2565 }else if(mm_flags & FF_MM_MMX2){ |
8430 | 2566 c->idct_put= ff_idct_xvid_mmx2_put; |
2567 c->idct_add= ff_idct_xvid_mmx2_add; | |
2568 c->idct = ff_idct_xvid_mmx2; | |
2569 }else{ | |
2570 c->idct_put= ff_idct_xvid_mmx_put; | |
2571 c->idct_add= ff_idct_xvid_mmx_add; | |
2572 c->idct = ff_idct_xvid_mmx; | |
2573 } | |
2574 } | |
2575 } | |
2576 | |
2577 c->put_pixels_clamped = put_pixels_clamped_mmx; | |
2578 c->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx; | |
2579 c->add_pixels_clamped = add_pixels_clamped_mmx; | |
2580 c->clear_block = clear_block_mmx; | |
2581 c->clear_blocks = clear_blocks_mmx; | |
10766
78c2be62260a
Fix XvMC. XvMCCreateBlocks() may not allocate 16-byte aligned blocks,
gb
parents:
10749
diff
changeset
|
2582 if ((mm_flags & FF_MM_SSE) && |
78c2be62260a
Fix XvMC. XvMCCreateBlocks() may not allocate 16-byte aligned blocks,
gb
parents:
10749
diff
changeset
|
2583 !(CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)){ |
78c2be62260a
Fix XvMC. XvMCCreateBlocks() may not allocate 16-byte aligned blocks,
gb
parents:
10749
diff
changeset
|
2584 /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */ |
9861 | 2585 c->clear_block = clear_block_sse; |
2586 c->clear_blocks = clear_blocks_sse; | |
2587 } | |
8430 | 2588 |
2589 #define SET_HPEL_FUNCS(PFX, IDX, SIZE, CPU) \ | |
2590 c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## SIZE ## _ ## CPU; \ | |
2591 c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## SIZE ## _x2_ ## CPU; \ | |
2592 c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \ | |
2593 c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU | |
2594 | |
2595 SET_HPEL_FUNCS(put, 0, 16, mmx); | |
2596 SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx); | |
2597 SET_HPEL_FUNCS(avg, 0, 16, mmx); | |
2598 SET_HPEL_FUNCS(avg_no_rnd, 0, 16, mmx); | |
2599 SET_HPEL_FUNCS(put, 1, 8, mmx); | |
2600 SET_HPEL_FUNCS(put_no_rnd, 1, 8, mmx); | |
2601 SET_HPEL_FUNCS(avg, 1, 8, mmx); | |
2602 SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx); | |
2603 | |
2604 c->gmc= gmc_mmx; | |
2605 | |
2606 c->add_bytes= add_bytes_mmx; | |
2607 c->add_bytes_l2= add_bytes_l2_mmx; | |
2608 | |
2609 c->draw_edges = draw_edges_mmx; | |
2610 | |
10749
5cca4b6c459d
Get rid of pointless CONFIG_ANY_H263 preprocessor definition.
diego
parents:
10645
diff
changeset
|
2611 if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { |
8430 | 2612 c->h263_v_loop_filter= h263_v_loop_filter_mmx; |
2613 c->h263_h_loop_filter= h263_h_loop_filter_mmx; | |
2614 } | |
2615 c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_rnd; | |
2616 c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx; | |
9439
ef3a7b711cc0
Rename put_no_rnd_h264_chroma* to reflect its usage in VC1 only
conrad
parents:
9342
diff
changeset
|
2617 c->put_no_rnd_vc1_chroma_pixels_tab[0]= put_vc1_chroma_mc8_mmx_nornd; |
8430 | 2618 |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2619 c->put_rv40_chroma_pixels_tab[0]= put_rv40_chroma_mc8_mmx; |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2620 c->put_rv40_chroma_pixels_tab[1]= put_rv40_chroma_mc4_mmx; |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2621 |
8817 | 2622 if (CONFIG_VP6_DECODER) { |
2623 c->vp6_filter_diag4 = ff_vp6_filter_diag4_mmx; | |
2624 } | |
2625 | |
9342
7f594601d5e9
Rename FF_MM_MMXEXT to FF_MM_MMX2, for both clarity and consistency
stefano
parents:
9341
diff
changeset
|
2626 if (mm_flags & FF_MM_MMX2) { |
8430 | 2627 c->prefetch = prefetch_mmx2; |
2628 | |
2629 c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2; | |
2630 c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2; | |
2631 | |
2632 c->avg_pixels_tab[0][0] = avg_pixels16_mmx2; | |
2633 c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2; | |
2634 c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2; | |
2635 | |
2636 c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2; | |
2637 c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2; | |
2638 | |
2639 c->avg_pixels_tab[1][0] = avg_pixels8_mmx2; | |
2640 c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2; | |
2641 c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2; | |
2642 | |
2643 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ | |
2644 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2; | |
2645 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2; | |
2646 c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2; | |
2647 c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2; | |
2648 c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2; | |
2649 c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2; | |
2650 | |
9975
d6d7e8d4a04d
Do not redundantly check for both CONFIG_THEORA_DECODER and CONFIG_VP3_DECODER.
diego
parents:
9959
diff
changeset
|
2651 if (CONFIG_VP3_DECODER) { |
8430 | 2652 c->vp3_v_loop_filter= ff_vp3_v_loop_filter_mmx2; |
2653 c->vp3_h_loop_filter= ff_vp3_h_loop_filter_mmx2; | |
2654 } | |
2655 } | |
2656 | |
2657 #define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU) \ | |
2658 c->PFX ## _pixels_tab[IDX][ 0] = PFX ## SIZE ## _mc00_ ## CPU; \ | |
2659 c->PFX ## _pixels_tab[IDX][ 1] = PFX ## SIZE ## _mc10_ ## CPU; \ | |
2660 c->PFX ## _pixels_tab[IDX][ 2] = PFX ## SIZE ## _mc20_ ## CPU; \ | |
2661 c->PFX ## _pixels_tab[IDX][ 3] = PFX ## SIZE ## _mc30_ ## CPU; \ | |
2662 c->PFX ## _pixels_tab[IDX][ 4] = PFX ## SIZE ## _mc01_ ## CPU; \ | |
2663 c->PFX ## _pixels_tab[IDX][ 5] = PFX ## SIZE ## _mc11_ ## CPU; \ | |
2664 c->PFX ## _pixels_tab[IDX][ 6] = PFX ## SIZE ## _mc21_ ## CPU; \ | |
2665 c->PFX ## _pixels_tab[IDX][ 7] = PFX ## SIZE ## _mc31_ ## CPU; \ | |
2666 c->PFX ## _pixels_tab[IDX][ 8] = PFX ## SIZE ## _mc02_ ## CPU; \ | |
2667 c->PFX ## _pixels_tab[IDX][ 9] = PFX ## SIZE ## _mc12_ ## CPU; \ | |
2668 c->PFX ## _pixels_tab[IDX][10] = PFX ## SIZE ## _mc22_ ## CPU; \ | |
2669 c->PFX ## _pixels_tab[IDX][11] = PFX ## SIZE ## _mc32_ ## CPU; \ | |
2670 c->PFX ## _pixels_tab[IDX][12] = PFX ## SIZE ## _mc03_ ## CPU; \ | |
2671 c->PFX ## _pixels_tab[IDX][13] = PFX ## SIZE ## _mc13_ ## CPU; \ | |
2672 c->PFX ## _pixels_tab[IDX][14] = PFX ## SIZE ## _mc23_ ## CPU; \ | |
2673 c->PFX ## _pixels_tab[IDX][15] = PFX ## SIZE ## _mc33_ ## CPU | |
2674 | |
2675 SET_QPEL_FUNCS(put_qpel, 0, 16, mmx2); | |
2676 SET_QPEL_FUNCS(put_qpel, 1, 8, mmx2); | |
2677 SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmx2); | |
2678 SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmx2); | |
2679 SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2); | |
2680 SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2); | |
2681 | |
2682 SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2); | |
2683 SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2); | |
2684 SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2); | |
2685 SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmx2); | |
2686 SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmx2); | |
2687 SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmx2); | |
2688 | |
2689 SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, mmx2); | |
2690 SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, mmx2); | |
2691 SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2); | |
2692 SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2); | |
2693 | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2694 c->avg_rv40_chroma_pixels_tab[0]= avg_rv40_chroma_mc8_mmx2; |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2695 c->avg_rv40_chroma_pixels_tab[1]= avg_rv40_chroma_mc4_mmx2; |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2696 |
9440 | 2697 c->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_vc1_chroma_mc8_mmx2_nornd; |
2698 | |
8430 | 2699 c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2_rnd; |
2700 c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2; | |
2701 c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2; | |
2702 c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2; | |
2703 | |
8760 | 2704 #if HAVE_YASM |
2705 c->add_hfyu_median_prediction = ff_add_hfyu_median_prediction_mmx2; | |
2706 #endif | |
8798
a5c8210814d7
Add check whether the compiler/assembler supports 10 or more operands.
diego
parents:
8760
diff
changeset
|
2707 #if HAVE_7REGS && HAVE_TEN_OPERANDS |
8760 | 2708 if( mm_flags&FF_MM_3DNOW ) |
2709 c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov; | |
2710 #endif | |
2711 | |
8596
68e959302527
replace all occurrence of ENABLE_ by the corresponding CONFIG_, HAVE_ or ARCH_
aurel
parents:
8590
diff
changeset
|
2712 if (CONFIG_CAVS_DECODER) |
8430 | 2713 ff_cavsdsp_init_mmx2(c, avctx); |
2714 | |
9995
3141f69e3905
Do not check for both CONFIG_VC1_DECODER and CONFIG_WMV3_DECODER,
diego
parents:
9975
diff
changeset
|
2715 if (CONFIG_VC1_DECODER) |
8430 | 2716 ff_vc1dsp_init_mmx(c, avctx); |
2717 | |
2718 c->add_png_paeth_prediction= add_png_paeth_prediction_mmx2; | |
2719 } else if (mm_flags & FF_MM_3DNOW) { | |
2720 c->prefetch = prefetch_3dnow; | |
2721 | |
2722 c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow; | |
2723 c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow; | |
2724 | |
2725 c->avg_pixels_tab[0][0] = avg_pixels16_3dnow; | |
2726 c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow; | |
2727 c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow; | |
2728 | |
2729 c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow; | |
2730 c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow; | |
2731 | |
2732 c->avg_pixels_tab[1][0] = avg_pixels8_3dnow; | |
2733 c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow; | |
2734 c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow; | |
2735 | |
2736 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ | |
2737 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow; | |
2738 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow; | |
2739 c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow; | |
2740 c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow; | |
2741 c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow; | |
2742 c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow; | |
2743 } | |
2744 | |
2745 SET_QPEL_FUNCS(put_qpel, 0, 16, 3dnow); | |
2746 SET_QPEL_FUNCS(put_qpel, 1, 8, 3dnow); | |
2747 SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, 3dnow); | |
2748 SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, 3dnow); | |
2749 SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow); | |
2750 SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow); | |
2751 | |
2752 SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow); | |
2753 SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow); | |
2754 SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow); | |
2755 SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 3dnow); | |
2756 SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 3dnow); | |
2757 SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 3dnow); | |
2758 | |
2759 SET_QPEL_FUNCS(put_2tap_qpel, 0, 16, 3dnow); | |
2760 SET_QPEL_FUNCS(put_2tap_qpel, 1, 8, 3dnow); | |
2761 SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow); | |
2762 SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow); | |
2763 | |
2764 c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow_rnd; | |
2765 c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow; | |
2766 | |
8519
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2767 c->avg_rv40_chroma_pixels_tab[0]= avg_rv40_chroma_mc8_3dnow; |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2768 c->avg_rv40_chroma_pixels_tab[1]= avg_rv40_chroma_mc4_3dnow; |
cc64e1343397
Use H264 MMX chroma functions to accelerate RV40 decoding.
cehoyos
parents:
8510
diff
changeset
|
2769 |
8596
68e959302527
replace all occurrence of ENABLE_ by the corresponding CONFIG_, HAVE_ or ARCH_
aurel
parents:
8590
diff
changeset
|
2770 if (CONFIG_CAVS_DECODER) |
8430 | 2771 ff_cavsdsp_init_3dnow(c, avctx); |
2772 } | |
2773 | |
2774 | |
2775 #define H264_QPEL_FUNCS(x, y, CPU)\ | |
2776 c->put_h264_qpel_pixels_tab[0][x+y*4] = put_h264_qpel16_mc##x##y##_##CPU;\ | |
2777 c->put_h264_qpel_pixels_tab[1][x+y*4] = put_h264_qpel8_mc##x##y##_##CPU;\ | |
2778 c->avg_h264_qpel_pixels_tab[0][x+y*4] = avg_h264_qpel16_mc##x##y##_##CPU;\ | |
2779 c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU; | |
2780 if((mm_flags & FF_MM_SSE2) && !(mm_flags & FF_MM_3DNOW)){ | |
2781 // these functions are slower than mmx on AMD, but faster on Intel | |
2782 c->put_pixels_tab[0][0] = put_pixels16_sse2; | |
2783 c->avg_pixels_tab[0][0] = avg_pixels16_sse2; | |
2784 H264_QPEL_FUNCS(0, 0, sse2); | |
2785 } | |
2786 if(mm_flags & FF_MM_SSE2){ | |
2787 H264_QPEL_FUNCS(0, 1, sse2); | |
2788 H264_QPEL_FUNCS(0, 2, sse2); | |
2789 H264_QPEL_FUNCS(0, 3, sse2); | |
2790 H264_QPEL_FUNCS(1, 1, sse2); | |
2791 H264_QPEL_FUNCS(1, 2, sse2); | |
2792 H264_QPEL_FUNCS(1, 3, sse2); | |
2793 H264_QPEL_FUNCS(2, 1, sse2); | |
2794 H264_QPEL_FUNCS(2, 2, sse2); | |
2795 H264_QPEL_FUNCS(2, 3, sse2); | |
2796 H264_QPEL_FUNCS(3, 1, sse2); | |
2797 H264_QPEL_FUNCS(3, 2, sse2); | |
2798 H264_QPEL_FUNCS(3, 3, sse2); | |
8818 | 2799 |
2800 if (CONFIG_VP6_DECODER) { | |
2801 c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2; | |
2802 } | |
8430 | 2803 } |
8590 | 2804 #if HAVE_SSSE3 |
8430 | 2805 if(mm_flags & FF_MM_SSSE3){ |
2806 H264_QPEL_FUNCS(1, 0, ssse3); | |
2807 H264_QPEL_FUNCS(1, 1, ssse3); | |
2808 H264_QPEL_FUNCS(1, 2, ssse3); | |
2809 H264_QPEL_FUNCS(1, 3, ssse3); | |
2810 H264_QPEL_FUNCS(2, 0, ssse3); | |
2811 H264_QPEL_FUNCS(2, 1, ssse3); | |
2812 H264_QPEL_FUNCS(2, 2, ssse3); | |
2813 H264_QPEL_FUNCS(2, 3, ssse3); | |
2814 H264_QPEL_FUNCS(3, 0, ssse3); | |
2815 H264_QPEL_FUNCS(3, 1, ssse3); | |
2816 H264_QPEL_FUNCS(3, 2, ssse3); | |
2817 H264_QPEL_FUNCS(3, 3, ssse3); | |
9439
ef3a7b711cc0
Rename put_no_rnd_h264_chroma* to reflect its usage in VC1 only
conrad
parents:
9342
diff
changeset
|
2818 c->put_no_rnd_vc1_chroma_pixels_tab[0]= put_vc1_chroma_mc8_ssse3_nornd; |
9440 | 2819 c->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_vc1_chroma_mc8_ssse3_nornd; |
8430 | 2820 c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_rnd; |
2821 c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_ssse3_rnd; | |
2822 c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_ssse3; | |
2823 c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_ssse3; | |
2824 c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3; | |
10430 | 2825 #if HAVE_YASM |
2826 c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_ssse3; | |
2827 if (mm_flags & FF_MM_SSE4) // not really sse4, just slow on Conroe | |
2828 c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_sse4; | |
2829 #endif | |
8430 | 2830 } |
2831 #endif | |
2832 | |
2833 if(mm_flags & FF_MM_3DNOW){ | |
2834 c->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow; | |
2835 c->vector_fmul = vector_fmul_3dnow; | |
2836 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ | |
2837 c->float_to_int16 = float_to_int16_3dnow; | |
2838 c->float_to_int16_interleave = float_to_int16_interleave_3dnow; | |
2839 } | |
2840 } | |
2841 if(mm_flags & FF_MM_3DNOWEXT){ | |
2842 c->vector_fmul_reverse = vector_fmul_reverse_3dnow2; | |
2843 c->vector_fmul_window = vector_fmul_window_3dnow2; | |
2844 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ | |
2845 c->float_to_int16_interleave = float_to_int16_interleave_3dn2; | |
2846 } | |
2847 } | |
10633 | 2848 if(mm_flags & FF_MM_MMX2){ |
2849 #if HAVE_YASM | |
2850 c->scalarproduct_int16 = ff_scalarproduct_int16_mmx2; | |
10644 | 2851 c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_mmx2; |
10633 | 2852 #endif |
2853 } | |
8430 | 2854 if(mm_flags & FF_MM_SSE){ |
2855 c->vorbis_inverse_coupling = vorbis_inverse_coupling_sse; | |
2856 c->ac3_downmix = ac3_downmix_sse; | |
2857 c->vector_fmul = vector_fmul_sse; | |
2858 c->vector_fmul_reverse = vector_fmul_reverse_sse; | |
10300
4d1b9ca628fc
Drop unused args from vector_fmul_add_add, simpify code, and rename
mru
parents:
10107
diff
changeset
|
2859 c->vector_fmul_add = vector_fmul_add_sse; |
8430 | 2860 c->vector_fmul_window = vector_fmul_window_sse; |
2861 c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse; | |
10104
0fa3d21b317e
SSE optimized vector_clipf(). 10% faster TwinVQ decoding.
vitor
parents:
9995
diff
changeset
|
2862 c->vector_clipf = vector_clipf_sse; |
8430 | 2863 c->float_to_int16 = float_to_int16_sse; |
2864 c->float_to_int16_interleave = float_to_int16_interleave_sse; | |
10964 | 2865 #if HAVE_YASM |
2866 c->scalarproduct_float = ff_scalarproduct_float_sse; | |
2867 #endif | |
8430 | 2868 } |
2869 if(mm_flags & FF_MM_3DNOW) | |
10300
4d1b9ca628fc
Drop unused args from vector_fmul_add_add, simpify code, and rename
mru
parents:
10107
diff
changeset
|
2870 c->vector_fmul_add = vector_fmul_add_3dnow; // faster than sse |
8430 | 2871 if(mm_flags & FF_MM_SSE2){ |
2872 c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2; | |
2873 c->float_to_int16 = float_to_int16_sse2; | |
2874 c->float_to_int16_interleave = float_to_int16_interleave_sse2; | |
10633 | 2875 #if HAVE_YASM |
2876 c->scalarproduct_int16 = ff_scalarproduct_int16_sse2; | |
10644 | 2877 c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_sse2; |
10633 | 2878 #endif |
8430 | 2879 } |
10644 | 2880 if((mm_flags & FF_MM_SSSE3) && !(mm_flags & (FF_MM_SSE42|FF_MM_3DNOW)) && HAVE_YASM) // cachesplit |
2881 c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_ssse3; | |
8430 | 2882 } |
2883 | |
8596
68e959302527
replace all occurrence of ENABLE_ by the corresponding CONFIG_, HAVE_ or ARCH_
aurel
parents:
8590
diff
changeset
|
2884 if (CONFIG_ENCODERS) |
8430 | 2885 dsputilenc_init_mmx(c, avctx); |
2886 | |
2887 #if 0 | |
2888 // for speed testing | |
2889 get_pixels = just_return; | |
2890 put_pixels_clamped = just_return; | |
2891 add_pixels_clamped = just_return; | |
2892 | |
2893 pix_abs16x16 = just_return; | |
2894 pix_abs16x16_x2 = just_return; | |
2895 pix_abs16x16_y2 = just_return; | |
2896 pix_abs16x16_xy2 = just_return; | |
2897 | |
2898 put_pixels_tab[0] = just_return; | |
2899 put_pixels_tab[1] = just_return; | |
2900 put_pixels_tab[2] = just_return; | |
2901 put_pixels_tab[3] = just_return; | |
2902 | |
2903 put_no_rnd_pixels_tab[0] = just_return; | |
2904 put_no_rnd_pixels_tab[1] = just_return; | |
2905 put_no_rnd_pixels_tab[2] = just_return; | |
2906 put_no_rnd_pixels_tab[3] = just_return; | |
2907 | |
2908 avg_pixels_tab[0] = just_return; | |
2909 avg_pixels_tab[1] = just_return; | |
2910 avg_pixels_tab[2] = just_return; | |
2911 avg_pixels_tab[3] = just_return; | |
2912 | |
2913 avg_no_rnd_pixels_tab[0] = just_return; | |
2914 avg_no_rnd_pixels_tab[1] = just_return; | |
2915 avg_no_rnd_pixels_tab[2] = just_return; | |
2916 avg_no_rnd_pixels_tab[3] = just_return; | |
2917 | |
2918 //av_fdct = just_return; | |
2919 //ff_idct = just_return; | |
2920 #endif | |
2921 } | |
11499 | 2922 |
2923 #if CONFIG_H264DSP | |
2924 void ff_h264dsp_init_x86(H264DSPContext *c) | |
2925 { | |
2926 mm_flags = mm_support(); | |
2927 | |
2928 if (mm_flags & FF_MM_MMX) { | |
2929 c->h264_idct_dc_add= | |
2930 c->h264_idct_add= ff_h264_idct_add_mmx; | |
2931 c->h264_idct8_dc_add= | |
2932 c->h264_idct8_add= ff_h264_idct8_add_mmx; | |
2933 | |
2934 c->h264_idct_add16 = ff_h264_idct_add16_mmx; | |
2935 c->h264_idct8_add4 = ff_h264_idct8_add4_mmx; | |
2936 c->h264_idct_add8 = ff_h264_idct_add8_mmx; | |
2937 c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx; | |
2938 | |
2939 if (mm_flags & FF_MM_MMX2) { | |
2940 c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2; | |
2941 c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2; | |
2942 c->h264_idct_add16 = ff_h264_idct_add16_mmx2; | |
2943 c->h264_idct8_add4 = ff_h264_idct8_add4_mmx2; | |
2944 c->h264_idct_add8 = ff_h264_idct_add8_mmx2; | |
2945 c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx2; | |
2946 | |
2947 c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2; | |
2948 c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2; | |
2949 c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2; | |
2950 c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2; | |
2951 c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2; | |
2952 c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2; | |
2953 c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2; | |
2954 | |
2955 c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2; | |
2956 c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2; | |
2957 c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2; | |
2958 c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2; | |
2959 c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2; | |
2960 c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2; | |
2961 c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2; | |
2962 c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2; | |
2963 | |
2964 c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2; | |
2965 c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2; | |
2966 c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2; | |
2967 c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2; | |
2968 c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2; | |
2969 c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2; | |
2970 c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2; | |
2971 c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2; | |
2972 } | |
2973 if(mm_flags & FF_MM_SSE2){ | |
2974 c->h264_idct8_add = ff_h264_idct8_add_sse2; | |
2975 c->h264_idct8_add4= ff_h264_idct8_add4_sse2; | |
2976 } | |
2977 | |
2978 #if CONFIG_GPL && HAVE_YASM | |
2979 if (mm_flags & FF_MM_MMX2){ | |
2980 #if ARCH_X86_32 | |
2981 c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_mmxext; | |
2982 c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_mmxext; | |
2983 #endif | |
2984 if( mm_flags&FF_MM_SSE2 ){ | |
2985 #if ARCH_X86_64 || !defined(__ICC) || __ICC > 1110 | |
2986 c->h264_v_loop_filter_luma = ff_x264_deblock_v_luma_sse2; | |
2987 c->h264_h_loop_filter_luma = ff_x264_deblock_h_luma_sse2; | |
2988 c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_sse2; | |
2989 c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_sse2; | |
2990 #endif | |
2991 c->h264_idct_add16 = ff_h264_idct_add16_sse2; | |
2992 c->h264_idct_add8 = ff_h264_idct_add8_sse2; | |
2993 c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2; | |
2994 } | |
2995 } | |
2996 #endif | |
2997 } | |
2998 } | |
2999 #endif /* CONFIG_H264DSP */ |