Mercurial > libavcodec.hg
annotate i386/h264dsp_mmx.c @ 3677:18b13b923616 libavcodec
VMware Video decoder (fourcc: VMnc)
author | kostya |
---|---|
date | Tue, 05 Sep 2006 04:37:14 +0000 |
parents | 47821be55b6c |
children | c8c591fe26f8 |
rev | line source |
---|---|
2754 | 1 /* |
2 * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt | |
3 * | |
4 * This library is free software; you can redistribute it and/or | |
5 * modify it under the terms of the GNU Lesser General Public | |
6 * License as published by the Free Software Foundation; either | |
7 * version 2 of the License, or (at your option) any later version. | |
8 * | |
9 * This library is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 * Lesser General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU Lesser General Public | |
15 * License along with this library; if not, write to the Free Software | |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
3029
diff
changeset
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2754 | 17 */ |
18 | |
19 | |
20 /***********************************/ | |
21 /* IDCT */ | |
22 | |
23 /* in/out: mma=mma+mmb, mmb=mmb-mma */ | |
24 #define SUMSUB_BA( a, b ) \ | |
25 "paddw "#b", "#a" \n\t"\ | |
26 "paddw "#b", "#b" \n\t"\ | |
27 "psubw "#a", "#b" \n\t" | |
28 | |
29 #define SUMSUB_BADC( a, b, c, d ) \ | |
30 "paddw "#b", "#a" \n\t"\ | |
31 "paddw "#d", "#c" \n\t"\ | |
32 "paddw "#b", "#b" \n\t"\ | |
33 "paddw "#d", "#d" \n\t"\ | |
34 "psubw "#a", "#b" \n\t"\ | |
35 "psubw "#c", "#d" \n\t" | |
36 | |
37 #define SUMSUBD2_AB( a, b, t ) \ | |
38 "movq "#b", "#t" \n\t"\ | |
39 "psraw $1 , "#b" \n\t"\ | |
40 "paddw "#a", "#b" \n\t"\ | |
41 "psraw $1 , "#a" \n\t"\ | |
42 "psubw "#t", "#a" \n\t" | |
43 | |
44 #define IDCT4_1D( s02, s13, d02, d13, t ) \ | |
45 SUMSUB_BA ( s02, d02 )\ | |
46 SUMSUBD2_AB( s13, d13, t )\ | |
47 SUMSUB_BADC( d13, s02, s13, d02 ) | |
48 | |
49 #define TRANSPOSE4(a,b,c,d,t)\ | |
50 SBUTTERFLY(a,b,t,wd) /* a=aebf t=cgdh */\ | |
51 SBUTTERFLY(c,d,b,wd) /* c=imjn b=kolp */\ | |
52 SBUTTERFLY(a,c,d,dq) /* a=aeim d=bfjn */\ | |
53 SBUTTERFLY(t,b,c,dq) /* t=cgko c=dhlp */ | |
54 | |
55 #define STORE_DIFF_4P( p, t, z ) \ | |
56 "psraw $6, "#p" \n\t"\ | |
57 "movd (%0), "#t" \n\t"\ | |
58 "punpcklbw "#z", "#t" \n\t"\ | |
59 "paddsw "#t", "#p" \n\t"\ | |
60 "packuswb "#z", "#p" \n\t"\ | |
61 "movd "#p", (%0) \n\t" | |
62 | |
3173 | 63 static void ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride) |
2754 | 64 { |
65 /* Load dct coeffs */ | |
66 asm volatile( | |
67 "movq (%0), %%mm0 \n\t" | |
68 "movq 8(%0), %%mm1 \n\t" | |
69 "movq 16(%0), %%mm2 \n\t" | |
70 "movq 24(%0), %%mm3 \n\t" | |
71 :: "r"(block) ); | |
72 | |
73 asm volatile( | |
74 /* mm1=s02+s13 mm2=s02-s13 mm4=d02+d13 mm0=d02-d13 */ | |
75 IDCT4_1D( %%mm2, %%mm1, %%mm0, %%mm3, %%mm4 ) | |
76 | |
77 "movq %0, %%mm6 \n\t" | |
78 /* in: 1,4,0,2 out: 1,2,3,0 */ | |
79 TRANSPOSE4( %%mm3, %%mm1, %%mm0, %%mm2, %%mm4 ) | |
80 | |
81 "paddw %%mm6, %%mm3 \n\t" | |
82 | |
83 /* mm2=s02+s13 mm3=s02-s13 mm4=d02+d13 mm1=d02-d13 */ | |
84 IDCT4_1D( %%mm4, %%mm2, %%mm3, %%mm0, %%mm1 ) | |
85 | |
86 "pxor %%mm7, %%mm7 \n\t" | |
87 :: "m"(ff_pw_32)); | |
88 | |
89 asm volatile( | |
90 STORE_DIFF_4P( %%mm0, %%mm1, %%mm7) | |
91 "add %1, %0 \n\t" | |
92 STORE_DIFF_4P( %%mm2, %%mm1, %%mm7) | |
93 "add %1, %0 \n\t" | |
94 STORE_DIFF_4P( %%mm3, %%mm1, %%mm7) | |
95 "add %1, %0 \n\t" | |
96 STORE_DIFF_4P( %%mm4, %%mm1, %%mm7) | |
97 : "+r"(dst) | |
98 : "r" ((long)stride) | |
99 ); | |
100 } | |
101 | |
3174 | 102 static inline void h264_idct8_1d(int16_t *block) |
103 { | |
104 asm volatile( | |
105 "movq 112(%0), %%mm7 \n\t" | |
106 "movq 80(%0), %%mm5 \n\t" | |
107 "movq 48(%0), %%mm3 \n\t" | |
108 "movq 16(%0), %%mm1 \n\t" | |
109 | |
110 "movq %%mm7, %%mm4 \n\t" | |
111 "movq %%mm3, %%mm6 \n\t" | |
112 "movq %%mm5, %%mm0 \n\t" | |
113 "movq %%mm7, %%mm2 \n\t" | |
114 "psraw $1, %%mm4 \n\t" | |
115 "psraw $1, %%mm6 \n\t" | |
116 "psubw %%mm7, %%mm0 \n\t" | |
117 "psubw %%mm6, %%mm2 \n\t" | |
118 "psubw %%mm4, %%mm0 \n\t" | |
119 "psubw %%mm3, %%mm2 \n\t" | |
120 "psubw %%mm3, %%mm0 \n\t" | |
121 "paddw %%mm1, %%mm2 \n\t" | |
122 | |
123 "movq %%mm5, %%mm4 \n\t" | |
124 "movq %%mm1, %%mm6 \n\t" | |
125 "psraw $1, %%mm4 \n\t" | |
126 "psraw $1, %%mm6 \n\t" | |
127 "paddw %%mm5, %%mm4 \n\t" | |
128 "paddw %%mm1, %%mm6 \n\t" | |
129 "paddw %%mm7, %%mm4 \n\t" | |
130 "paddw %%mm5, %%mm6 \n\t" | |
131 "psubw %%mm1, %%mm4 \n\t" | |
132 "paddw %%mm3, %%mm6 \n\t" | |
133 | |
134 "movq %%mm0, %%mm1 \n\t" | |
135 "movq %%mm4, %%mm3 \n\t" | |
136 "movq %%mm2, %%mm5 \n\t" | |
137 "movq %%mm6, %%mm7 \n\t" | |
138 "psraw $2, %%mm6 \n\t" | |
139 "psraw $2, %%mm3 \n\t" | |
140 "psraw $2, %%mm5 \n\t" | |
141 "psraw $2, %%mm0 \n\t" | |
142 "paddw %%mm6, %%mm1 \n\t" | |
143 "paddw %%mm2, %%mm3 \n\t" | |
144 "psubw %%mm4, %%mm5 \n\t" | |
145 "psubw %%mm0, %%mm7 \n\t" | |
146 | |
147 "movq 32(%0), %%mm2 \n\t" | |
148 "movq 96(%0), %%mm6 \n\t" | |
149 "movq %%mm2, %%mm4 \n\t" | |
150 "movq %%mm6, %%mm0 \n\t" | |
151 "psraw $1, %%mm4 \n\t" | |
152 "psraw $1, %%mm6 \n\t" | |
153 "psubw %%mm0, %%mm4 \n\t" | |
154 "paddw %%mm2, %%mm6 \n\t" | |
155 | |
156 "movq (%0), %%mm2 \n\t" | |
157 "movq 64(%0), %%mm0 \n\t" | |
158 SUMSUB_BA( %%mm0, %%mm2 ) | |
159 SUMSUB_BA( %%mm6, %%mm0 ) | |
160 SUMSUB_BA( %%mm4, %%mm2 ) | |
161 SUMSUB_BA( %%mm7, %%mm6 ) | |
162 SUMSUB_BA( %%mm5, %%mm4 ) | |
163 SUMSUB_BA( %%mm3, %%mm2 ) | |
164 SUMSUB_BA( %%mm1, %%mm0 ) | |
165 :: "r"(block) | |
166 ); | |
167 } | |
168 | |
169 static void ff_h264_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride) | |
170 { | |
171 int i; | |
172 int16_t __attribute__ ((aligned(8))) b2[64]; | |
173 | |
174 block[0] += 32; | |
175 | |
176 for(i=0; i<2; i++){ | |
177 uint64_t tmp; | |
178 | |
179 h264_idct8_1d(block+4*i); | |
180 | |
181 asm volatile( | |
182 "movq %%mm7, %0 \n\t" | |
183 TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 ) | |
184 "movq %%mm0, 8(%1) \n\t" | |
185 "movq %%mm6, 24(%1) \n\t" | |
186 "movq %%mm7, 40(%1) \n\t" | |
187 "movq %%mm4, 56(%1) \n\t" | |
188 "movq %0, %%mm7 \n\t" | |
189 TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 ) | |
190 "movq %%mm7, (%1) \n\t" | |
191 "movq %%mm1, 16(%1) \n\t" | |
192 "movq %%mm0, 32(%1) \n\t" | |
193 "movq %%mm3, 48(%1) \n\t" | |
194 : "=m"(tmp) | |
195 : "r"(b2+32*i) | |
196 : "memory" | |
197 ); | |
198 } | |
199 | |
200 for(i=0; i<2; i++){ | |
201 h264_idct8_1d(b2+4*i); | |
202 | |
203 asm volatile( | |
204 "psraw $6, %%mm7 \n\t" | |
205 "psraw $6, %%mm6 \n\t" | |
206 "psraw $6, %%mm5 \n\t" | |
207 "psraw $6, %%mm4 \n\t" | |
208 "psraw $6, %%mm3 \n\t" | |
209 "psraw $6, %%mm2 \n\t" | |
210 "psraw $6, %%mm1 \n\t" | |
211 "psraw $6, %%mm0 \n\t" | |
212 | |
213 "movq %%mm7, (%0) \n\t" | |
214 "movq %%mm5, 16(%0) \n\t" | |
215 "movq %%mm3, 32(%0) \n\t" | |
216 "movq %%mm1, 48(%0) \n\t" | |
217 "movq %%mm0, 64(%0) \n\t" | |
218 "movq %%mm2, 80(%0) \n\t" | |
219 "movq %%mm4, 96(%0) \n\t" | |
220 "movq %%mm6, 112(%0) \n\t" | |
221 :: "r"(b2+4*i) | |
222 : "memory" | |
223 ); | |
224 } | |
225 | |
226 add_pixels_clamped_mmx(b2, dst, stride); | |
227 } | |
228 | |
3173 | 229 static void ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride) |
3105
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
230 { |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
231 int dc = (block[0] + 32) >> 6; |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
232 asm volatile( |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
233 "movd %0, %%mm0 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
234 "pshufw $0, %%mm0, %%mm0 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
235 "pxor %%mm1, %%mm1 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
236 "psubw %%mm0, %%mm1 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
237 "packuswb %%mm0, %%mm0 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
238 "packuswb %%mm1, %%mm1 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
239 ::"r"(dc) |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
240 ); |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
241 asm volatile( |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
242 "movd %0, %%mm2 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
243 "movd %1, %%mm3 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
244 "movd %2, %%mm4 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
245 "movd %3, %%mm5 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
246 "paddusb %%mm0, %%mm2 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
247 "paddusb %%mm0, %%mm3 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
248 "paddusb %%mm0, %%mm4 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
249 "paddusb %%mm0, %%mm5 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
250 "psubusb %%mm1, %%mm2 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
251 "psubusb %%mm1, %%mm3 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
252 "psubusb %%mm1, %%mm4 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
253 "psubusb %%mm1, %%mm5 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
254 "movd %%mm2, %0 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
255 "movd %%mm3, %1 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
256 "movd %%mm4, %2 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
257 "movd %%mm5, %3 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
258 :"+m"(*(uint32_t*)(dst+0*stride)), |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
259 "+m"(*(uint32_t*)(dst+1*stride)), |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
260 "+m"(*(uint32_t*)(dst+2*stride)), |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
261 "+m"(*(uint32_t*)(dst+3*stride)) |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
262 ); |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
263 } |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
264 |
3173 | 265 static void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride) |
3105
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
266 { |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
267 int dc = (block[0] + 32) >> 6; |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
268 int y; |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
269 asm volatile( |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
270 "movd %0, %%mm0 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
271 "pshufw $0, %%mm0, %%mm0 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
272 "pxor %%mm1, %%mm1 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
273 "psubw %%mm0, %%mm1 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
274 "packuswb %%mm0, %%mm0 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
275 "packuswb %%mm1, %%mm1 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
276 ::"r"(dc) |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
277 ); |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
278 for(y=2; y--; dst += 4*stride){ |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
279 asm volatile( |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
280 "movq %0, %%mm2 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
281 "movq %1, %%mm3 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
282 "movq %2, %%mm4 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
283 "movq %3, %%mm5 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
284 "paddusb %%mm0, %%mm2 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
285 "paddusb %%mm0, %%mm3 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
286 "paddusb %%mm0, %%mm4 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
287 "paddusb %%mm0, %%mm5 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
288 "psubusb %%mm1, %%mm2 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
289 "psubusb %%mm1, %%mm3 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
290 "psubusb %%mm1, %%mm4 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
291 "psubusb %%mm1, %%mm5 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
292 "movq %%mm2, %0 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
293 "movq %%mm3, %1 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
294 "movq %%mm4, %2 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
295 "movq %%mm5, %3 \n\t" |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
296 :"+m"(*(uint64_t*)(dst+0*stride)), |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
297 "+m"(*(uint64_t*)(dst+1*stride)), |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
298 "+m"(*(uint64_t*)(dst+2*stride)), |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
299 "+m"(*(uint64_t*)(dst+3*stride)) |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
300 ); |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
301 } |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
302 } |
2d35fb3cb940
h264: special case dc-only idct. ~1% faster overall
lorenm
parents:
3102
diff
changeset
|
303 |
2754 | 304 |
305 /***********************************/ | |
306 /* deblocking */ | |
307 | |
308 // out: o = |x-y|>a | |
309 // clobbers: t | |
310 #define DIFF_GT_MMX(x,y,a,o,t)\ | |
311 "movq "#y", "#t" \n\t"\ | |
312 "movq "#x", "#o" \n\t"\ | |
313 "psubusb "#x", "#t" \n\t"\ | |
314 "psubusb "#y", "#o" \n\t"\ | |
315 "por "#t", "#o" \n\t"\ | |
316 "psubusb "#a", "#o" \n\t" | |
317 | |
318 // in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 | |
319 // out: mm5=beta-1, mm7=mask | |
320 // clobbers: mm4,mm6 | |
321 #define H264_DEBLOCK_MASK(alpha1, beta1) \ | |
322 "pshufw $0, "#alpha1", %%mm4 \n\t"\ | |
323 "pshufw $0, "#beta1 ", %%mm5 \n\t"\ | |
324 "packuswb %%mm4, %%mm4 \n\t"\ | |
325 "packuswb %%mm5, %%mm5 \n\t"\ | |
326 DIFF_GT_MMX(%%mm1, %%mm2, %%mm4, %%mm7, %%mm6) /* |p0-q0| > alpha-1 */\ | |
327 DIFF_GT_MMX(%%mm0, %%mm1, %%mm5, %%mm4, %%mm6) /* |p1-p0| > beta-1 */\ | |
328 "por %%mm4, %%mm7 \n\t"\ | |
329 DIFF_GT_MMX(%%mm3, %%mm2, %%mm5, %%mm4, %%mm6) /* |q1-q0| > beta-1 */\ | |
330 "por %%mm4, %%mm7 \n\t"\ | |
331 "pxor %%mm6, %%mm6 \n\t"\ | |
332 "pcmpeqb %%mm6, %%mm7 \n\t" | |
333 | |
334 // in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask) | |
335 // out: mm1=p0' mm2=q0' | |
336 // clobbers: mm0,3-6 | |
337 #define H264_DEBLOCK_P0_Q0(pb_01, pb_3f)\ | |
338 /* a = q0^p0^((p1-q1)>>2) */\ | |
339 "movq %%mm0, %%mm4 \n\t"\ | |
340 "psubb %%mm3, %%mm4 \n\t"\ | |
341 "psrlw $2, %%mm4 \n\t"\ | |
342 "pxor %%mm1, %%mm4 \n\t"\ | |
343 "pxor %%mm2, %%mm4 \n\t"\ | |
344 /* b = p0^(q1>>2) */\ | |
345 "psrlw $2, %%mm3 \n\t"\ | |
346 "pand "#pb_3f", %%mm3 \n\t"\ | |
347 "movq %%mm1, %%mm5 \n\t"\ | |
348 "pxor %%mm3, %%mm5 \n\t"\ | |
349 /* c = q0^(p1>>2) */\ | |
350 "psrlw $2, %%mm0 \n\t"\ | |
351 "pand "#pb_3f", %%mm0 \n\t"\ | |
352 "movq %%mm2, %%mm6 \n\t"\ | |
353 "pxor %%mm0, %%mm6 \n\t"\ | |
354 /* d = (c^b) & ~(b^a) & 1 */\ | |
355 "pxor %%mm5, %%mm6 \n\t"\ | |
356 "pxor %%mm4, %%mm5 \n\t"\ | |
357 "pandn %%mm6, %%mm5 \n\t"\ | |
358 "pand "#pb_01", %%mm5 \n\t"\ | |
359 /* delta = (avg(q0, p1>>2) + (d&a)) | |
360 * - (avg(p0, q1>>2) + (d&~a)) */\ | |
361 "pavgb %%mm2, %%mm0 \n\t"\ | |
2855
da95623de901
simplify (d&a) and (d&~a) calculation, hint by skal
michael
parents:
2754
diff
changeset
|
362 "pand %%mm5, %%mm4 \n\t"\ |
da95623de901
simplify (d&a) and (d&~a) calculation, hint by skal
michael
parents:
2754
diff
changeset
|
363 "paddusb %%mm4, %%mm0 \n\t"\ |
2754 | 364 "pavgb %%mm1, %%mm3 \n\t"\ |
2855
da95623de901
simplify (d&a) and (d&~a) calculation, hint by skal
michael
parents:
2754
diff
changeset
|
365 "pxor %%mm5, %%mm4 \n\t"\ |
2754 | 366 "paddusb %%mm4, %%mm3 \n\t"\ |
367 /* p0 += clip(delta, -tc0, tc0) | |
368 * q0 -= clip(delta, -tc0, tc0) */\ | |
369 "movq %%mm0, %%mm4 \n\t"\ | |
370 "psubusb %%mm3, %%mm0 \n\t"\ | |
371 "psubusb %%mm4, %%mm3 \n\t"\ | |
372 "pminub %%mm7, %%mm0 \n\t"\ | |
373 "pminub %%mm7, %%mm3 \n\t"\ | |
374 "paddusb %%mm0, %%mm1 \n\t"\ | |
375 "paddusb %%mm3, %%mm2 \n\t"\ | |
376 "psubusb %%mm3, %%mm1 \n\t"\ | |
377 "psubusb %%mm0, %%mm2 \n\t" | |
378 | |
379 // in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask) %8=mm_bone | |
380 // out: (q1addr) = clip( (q2+((p0+q0+1)>>1))>>1, q1-tc0, q1+tc0 ) | |
381 // clobbers: q2, tmp, tc0 | |
382 #define H264_DEBLOCK_Q1(p1, q2, q2addr, q1addr, tc0, tmp)\ | |
383 "movq %%mm1, "#tmp" \n\t"\ | |
384 "pavgb %%mm2, "#tmp" \n\t"\ | |
385 "pavgb "#tmp", "#q2" \n\t" /* avg(p2,avg(p0,q0)) */\ | |
386 "pxor "q2addr", "#tmp" \n\t"\ | |
387 "pand %8, "#tmp" \n\t" /* (p2^avg(p0,q0))&1 */\ | |
388 "psubusb "#tmp", "#q2" \n\t" /* (p2+((p0+q0+1)>>1))>>1 */\ | |
389 "movq "#p1", "#tmp" \n\t"\ | |
390 "psubusb "#tc0", "#tmp" \n\t"\ | |
391 "paddusb "#p1", "#tc0" \n\t"\ | |
392 "pmaxub "#tmp", "#q2" \n\t"\ | |
393 "pminub "#tc0", "#q2" \n\t"\ | |
394 "movq "#q2", "q1addr" \n\t" | |
395 | |
396 static inline void h264_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0) | |
397 { | |
398 uint64_t tmp0; | |
399 uint64_t tc = (uint8_t)tc0[1]*0x01010000 | (uint8_t)tc0[0]*0x0101; | |
400 // with luma, tc0=0 doesn't mean no filtering, so we need a separate input mask | |
401 uint32_t mask[2] = { (tc0[0]>=0)*0xffffffff, (tc0[1]>=0)*0xffffffff }; | |
402 | |
403 asm volatile( | |
404 "movq (%1,%3), %%mm0 \n\t" //p1 | |
405 "movq (%1,%3,2), %%mm1 \n\t" //p0 | |
406 "movq (%2), %%mm2 \n\t" //q0 | |
407 "movq (%2,%3), %%mm3 \n\t" //q1 | |
408 H264_DEBLOCK_MASK(%6, %7) | |
409 "pand %5, %%mm7 \n\t" | |
410 "movq %%mm7, %0 \n\t" | |
411 | |
412 /* filter p1 */ | |
413 "movq (%1), %%mm3 \n\t" //p2 | |
414 DIFF_GT_MMX(%%mm1, %%mm3, %%mm5, %%mm6, %%mm4) // |p2-p0|>beta-1 | |
415 "pandn %%mm7, %%mm6 \n\t" | |
416 "pcmpeqb %%mm7, %%mm6 \n\t" | |
417 "pand %%mm7, %%mm6 \n\t" // mask & |p2-p0|<beta | |
418 "pshufw $80, %4, %%mm4 \n\t" | |
419 "pand %%mm7, %%mm4 \n\t" // mask & tc0 | |
420 "movq %8, %%mm7 \n\t" | |
421 "pand %%mm6, %%mm7 \n\t" // mask & |p2-p0|<beta & 1 | |
422 "pand %%mm4, %%mm6 \n\t" // mask & |p2-p0|<beta & tc0 | |
423 "paddb %%mm4, %%mm7 \n\t" // tc++ | |
424 H264_DEBLOCK_Q1(%%mm0, %%mm3, "(%1)", "(%1,%3)", %%mm6, %%mm4) | |
425 | |
426 /* filter q1 */ | |
427 "movq (%2,%3,2), %%mm4 \n\t" //q2 | |
428 DIFF_GT_MMX(%%mm2, %%mm4, %%mm5, %%mm6, %%mm3) // |q2-q0|>beta-1 | |
429 "pandn %0, %%mm6 \n\t" | |
430 "pcmpeqb %0, %%mm6 \n\t" | |
431 "pand %0, %%mm6 \n\t" | |
432 "pshufw $80, %4, %%mm5 \n\t" | |
433 "pand %%mm6, %%mm5 \n\t" | |
434 "pand %8, %%mm6 \n\t" | |
435 "paddb %%mm6, %%mm7 \n\t" | |
436 "movq (%2,%3), %%mm3 \n\t" | |
437 H264_DEBLOCK_Q1(%%mm3, %%mm4, "(%2,%3,2)", "(%2,%3)", %%mm5, %%mm6) | |
438 | |
439 /* filter p0, q0 */ | |
440 H264_DEBLOCK_P0_Q0(%8, %9) | |
441 "movq %%mm1, (%1,%3,2) \n\t" | |
442 "movq %%mm2, (%2) \n\t" | |
443 | |
444 : "=m"(tmp0) | |
445 : "r"(pix-3*stride), "r"(pix), "r"((long)stride), | |
446 "m"(tc), "m"(*(uint64_t*)mask), "m"(alpha1), "m"(beta1), | |
447 "m"(mm_bone), "m"(ff_pb_3F) | |
448 ); | |
449 } | |
450 | |
451 static void h264_v_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
452 { | |
453 if((tc0[0] & tc0[1]) >= 0) | |
454 h264_loop_filter_luma_mmx2(pix, stride, alpha-1, beta-1, tc0); | |
455 if((tc0[2] & tc0[3]) >= 0) | |
456 h264_loop_filter_luma_mmx2(pix+8, stride, alpha-1, beta-1, tc0+2); | |
457 } | |
458 static void h264_h_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
459 { | |
460 //FIXME: could cut some load/stores by merging transpose with filter | |
461 // also, it only needs to transpose 6x8 | |
462 uint8_t trans[8*8]; | |
463 int i; | |
464 for(i=0; i<2; i++, pix+=8*stride, tc0+=2) { | |
465 if((tc0[0] & tc0[1]) < 0) | |
466 continue; | |
467 transpose4x4(trans, pix-4, 8, stride); | |
468 transpose4x4(trans +4*8, pix, 8, stride); | |
469 transpose4x4(trans+4, pix-4+4*stride, 8, stride); | |
470 transpose4x4(trans+4+4*8, pix +4*stride, 8, stride); | |
471 h264_loop_filter_luma_mmx2(trans+4*8, 8, alpha-1, beta-1, tc0); | |
472 transpose4x4(pix-2, trans +2*8, stride, 8); | |
473 transpose4x4(pix-2+4*stride, trans+4+2*8, stride, 8); | |
474 } | |
475 } | |
476 | |
477 static inline void h264_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0) | |
478 { | |
479 asm volatile( | |
480 "movq (%0), %%mm0 \n\t" //p1 | |
481 "movq (%0,%2), %%mm1 \n\t" //p0 | |
482 "movq (%1), %%mm2 \n\t" //q0 | |
483 "movq (%1,%2), %%mm3 \n\t" //q1 | |
484 H264_DEBLOCK_MASK(%4, %5) | |
485 "movd %3, %%mm6 \n\t" | |
486 "punpcklbw %%mm6, %%mm6 \n\t" | |
487 "pand %%mm6, %%mm7 \n\t" // mm7 = tc&mask | |
488 H264_DEBLOCK_P0_Q0(%6, %7) | |
489 "movq %%mm1, (%0,%2) \n\t" | |
490 "movq %%mm2, (%1) \n\t" | |
491 | |
492 :: "r"(pix-2*stride), "r"(pix), "r"((long)stride), | |
493 "r"(*(uint32_t*)tc0), | |
494 "m"(alpha1), "m"(beta1), "m"(mm_bone), "m"(ff_pb_3F) | |
495 ); | |
496 } | |
497 | |
498 static void h264_v_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
499 { | |
500 h264_loop_filter_chroma_mmx2(pix, stride, alpha-1, beta-1, tc0); | |
501 } | |
502 | |
503 static void h264_h_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
504 { | |
505 //FIXME: could cut some load/stores by merging transpose with filter | |
506 uint8_t trans[8*4]; | |
507 transpose4x4(trans, pix-2, 8, stride); | |
508 transpose4x4(trans+4, pix-2+4*stride, 8, stride); | |
509 h264_loop_filter_chroma_mmx2(trans+2*8, 8, alpha-1, beta-1, tc0); | |
510 transpose4x4(pix-2, trans, stride, 8); | |
511 transpose4x4(pix-2+4*stride, trans+4, stride, 8); | |
512 } | |
513 | |
514 // p0 = (p0 + q1 + 2*p1 + 2) >> 2 | |
515 #define H264_FILTER_CHROMA4(p0, p1, q1, one) \ | |
516 "movq "#p0", %%mm4 \n\t"\ | |
517 "pxor "#q1", %%mm4 \n\t"\ | |
518 "pand "#one", %%mm4 \n\t" /* mm4 = (p0^q1)&1 */\ | |
519 "pavgb "#q1", "#p0" \n\t"\ | |
520 "psubusb %%mm4, "#p0" \n\t"\ | |
521 "pavgb "#p1", "#p0" \n\t" /* dst = avg(p1, avg(p0,q1) - ((p0^q1)&1)) */\ | |
522 | |
523 static inline void h264_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha1, int beta1) | |
524 { | |
525 asm volatile( | |
526 "movq (%0), %%mm0 \n\t" | |
527 "movq (%0,%2), %%mm1 \n\t" | |
528 "movq (%1), %%mm2 \n\t" | |
529 "movq (%1,%2), %%mm3 \n\t" | |
530 H264_DEBLOCK_MASK(%3, %4) | |
531 "movq %%mm1, %%mm5 \n\t" | |
532 "movq %%mm2, %%mm6 \n\t" | |
533 H264_FILTER_CHROMA4(%%mm1, %%mm0, %%mm3, %5) //p0' | |
534 H264_FILTER_CHROMA4(%%mm2, %%mm3, %%mm0, %5) //q0' | |
535 "psubb %%mm5, %%mm1 \n\t" | |
536 "psubb %%mm6, %%mm2 \n\t" | |
537 "pand %%mm7, %%mm1 \n\t" | |
538 "pand %%mm7, %%mm2 \n\t" | |
539 "paddb %%mm5, %%mm1 \n\t" | |
540 "paddb %%mm6, %%mm2 \n\t" | |
541 "movq %%mm1, (%0,%2) \n\t" | |
542 "movq %%mm2, (%1) \n\t" | |
543 :: "r"(pix-2*stride), "r"(pix), "r"((long)stride), | |
544 "m"(alpha1), "m"(beta1), "m"(mm_bone) | |
545 ); | |
546 } | |
547 | |
548 static void h264_v_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta) | |
549 { | |
550 h264_loop_filter_chroma_intra_mmx2(pix, stride, alpha-1, beta-1); | |
551 } | |
552 | |
553 static void h264_h_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta) | |
554 { | |
555 //FIXME: could cut some load/stores by merging transpose with filter | |
556 uint8_t trans[8*4]; | |
557 transpose4x4(trans, pix-2, 8, stride); | |
558 transpose4x4(trans+4, pix-2+4*stride, 8, stride); | |
559 h264_loop_filter_chroma_intra_mmx2(trans+2*8, 8, alpha-1, beta-1); | |
560 transpose4x4(pix-2, trans, stride, 8); | |
561 transpose4x4(pix-2+4*stride, trans+4, stride, 8); | |
562 } | |
563 | |
3645
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
564 static void h264_loop_filter_strength_mmx2( int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2], |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
565 int bidir, int edges, int step, int mask_mv0, int mask_mv1 ) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
566 int dir; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
567 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
568 "pxor %%mm7, %%mm7 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
569 "movq %0, %%mm6 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
570 "movq %1, %%mm5 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
571 "movq %2, %%mm4 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
572 ::"m"(ff_pb_1), "m"(ff_pb_3), "m"(ff_pb_7) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
573 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
574 // could do a special case for dir==0 && edges==1, but it only reduces the |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
575 // average filter time by 1.2% |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
576 for( dir=1; dir>=0; dir-- ) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
577 const int d_idx = dir ? -8 : -1; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
578 const int mask_mv = dir ? mask_mv1 : mask_mv0; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
579 const uint64_t mask_dir = dir ? 0 : 0xffffffffffffffffULL; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
580 int b_idx, edge, l; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
581 for( b_idx=12, edge=0; edge<edges; edge+=step, b_idx+=8*step ) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
582 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
583 "pand %0, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
584 ::"m"(mask_dir) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
585 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
586 if(!(mask_mv & edge)) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
587 asm volatile("pxor %%mm0, %%mm0 \n\t":); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
588 for( l = bidir; l >= 0; l-- ) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
589 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
590 "movd %0, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
591 "punpckldq %1, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
592 "movq %%mm1, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
593 "psrlw $7, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
594 "pand %%mm6, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
595 "por %%mm2, %%mm1 \n\t" // ref_cache with -2 mapped to -1 |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
596 "punpckldq %%mm1, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
597 "pcmpeqb %%mm2, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
598 "paddb %%mm6, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
599 "punpckhbw %%mm7, %%mm1 \n\t" // ref[b] != ref[bn] |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
600 "por %%mm1, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
601 |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
602 "movq %2, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
603 "movq %3, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
604 "psubw %4, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
605 "psubw %5, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
606 "packsswb %%mm2, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
607 "paddb %%mm5, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
608 "pminub %%mm4, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
609 "pcmpeqb %%mm4, %%mm1 \n\t" // abs(mv[b] - mv[bn]) >= limit |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
610 "por %%mm1, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
611 ::"m"(ref[l][b_idx]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
612 "m"(ref[l][b_idx+d_idx]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
613 "m"(mv[l][b_idx][0]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
614 "m"(mv[l][b_idx+2][0]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
615 "m"(mv[l][b_idx+d_idx][0]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
616 "m"(mv[l][b_idx+d_idx+2][0]) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
617 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
618 } |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
619 } |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
620 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
621 "movd %0, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
622 "por %1, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
623 "punpcklbw %%mm7, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
624 "pcmpgtw %%mm7, %%mm1 \n\t" // nnz[b] || nnz[bn] |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
625 ::"m"(nnz[b_idx]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
626 "m"(nnz[b_idx+d_idx]) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
627 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
628 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
629 "pcmpeqw %%mm7, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
630 "pcmpeqw %%mm7, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
631 "psrlw $15, %%mm0 \n\t" // nonzero -> 1 |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
632 "psrlw $14, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
633 "movq %%mm0, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
634 "por %%mm1, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
635 "psrlw $1, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
636 "pandn %%mm2, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
637 "movq %%mm1, %0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
638 :"=m"(*bS[dir][edge]) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
639 ::"memory" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
640 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
641 } |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
642 edges = 4; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
643 step = 1; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
644 } |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
645 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
646 "movq (%0), %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
647 "movq 8(%0), %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
648 "movq 16(%0), %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
649 "movq 24(%0), %%mm3 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
650 TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
651 "movq %%mm0, (%0) \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
652 "movq %%mm3, 8(%0) \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
653 "movq %%mm4, 16(%0) \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
654 "movq %%mm2, 24(%0) \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
655 ::"r"(bS[0]) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
656 :"memory" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
657 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
658 } |
2754 | 659 |
660 /***********************************/ | |
661 /* motion compensation */ | |
662 | |
663 #define QPEL_H264V(A,B,C,D,E,F,OP)\ | |
2979 | 664 "movd (%0), "#F" \n\t"\ |
665 "movq "#C", %%mm6 \n\t"\ | |
666 "paddw "#D", %%mm6 \n\t"\ | |
667 "psllw $2, %%mm6 \n\t"\ | |
668 "psubw "#B", %%mm6 \n\t"\ | |
669 "psubw "#E", %%mm6 \n\t"\ | |
670 "pmullw %4, %%mm6 \n\t"\ | |
671 "add %2, %0 \n\t"\ | |
672 "punpcklbw %%mm7, "#F" \n\t"\ | |
673 "paddw %5, "#A" \n\t"\ | |
674 "paddw "#F", "#A" \n\t"\ | |
675 "paddw "#A", %%mm6 \n\t"\ | |
676 "psraw $5, %%mm6 \n\t"\ | |
677 "packuswb %%mm6, %%mm6 \n\t"\ | |
2754 | 678 OP(%%mm6, (%1), A, d)\ |
2979 | 679 "add %3, %1 \n\t" |
2754 | 680 |
681 #define QPEL_H264HV(A,B,C,D,E,F,OF)\ | |
2979 | 682 "movd (%0), "#F" \n\t"\ |
683 "movq "#C", %%mm6 \n\t"\ | |
684 "paddw "#D", %%mm6 \n\t"\ | |
685 "psllw $2, %%mm6 \n\t"\ | |
686 "psubw "#B", %%mm6 \n\t"\ | |
687 "psubw "#E", %%mm6 \n\t"\ | |
688 "pmullw %3, %%mm6 \n\t"\ | |
689 "add %2, %0 \n\t"\ | |
690 "punpcklbw %%mm7, "#F" \n\t"\ | |
691 "paddw "#F", "#A" \n\t"\ | |
692 "paddw "#A", %%mm6 \n\t"\ | |
693 "movq %%mm6, "#OF"(%1) \n\t" | |
2967 | 694 |
2754 | 695 #define QPEL_H264(OPNAME, OP, MMX)\ |
696 static void OPNAME ## h264_qpel4_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
697 int h=4;\ | |
698 \ | |
699 asm volatile(\ | |
2979 | 700 "pxor %%mm7, %%mm7 \n\t"\ |
701 "movq %5, %%mm4 \n\t"\ | |
702 "movq %6, %%mm5 \n\t"\ | |
703 "1: \n\t"\ | |
704 "movd -1(%0), %%mm1 \n\t"\ | |
705 "movd (%0), %%mm2 \n\t"\ | |
706 "movd 1(%0), %%mm3 \n\t"\ | |
707 "movd 2(%0), %%mm0 \n\t"\ | |
708 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
709 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
710 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
711 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
712 "paddw %%mm0, %%mm1 \n\t"\ | |
713 "paddw %%mm3, %%mm2 \n\t"\ | |
714 "movd -2(%0), %%mm0 \n\t"\ | |
715 "movd 3(%0), %%mm3 \n\t"\ | |
716 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
717 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
718 "paddw %%mm3, %%mm0 \n\t"\ | |
719 "psllw $2, %%mm2 \n\t"\ | |
720 "psubw %%mm1, %%mm2 \n\t"\ | |
721 "pmullw %%mm4, %%mm2 \n\t"\ | |
722 "paddw %%mm5, %%mm0 \n\t"\ | |
723 "paddw %%mm2, %%mm0 \n\t"\ | |
724 "psraw $5, %%mm0 \n\t"\ | |
725 "packuswb %%mm0, %%mm0 \n\t"\ | |
2754 | 726 OP(%%mm0, (%1),%%mm6, d)\ |
2979 | 727 "add %3, %0 \n\t"\ |
728 "add %4, %1 \n\t"\ | |
729 "decl %2 \n\t"\ | |
730 " jnz 1b \n\t"\ | |
2754 | 731 : "+a"(src), "+c"(dst), "+m"(h)\ |
732 : "d"((long)srcStride), "S"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
733 : "memory"\ | |
734 );\ | |
735 }\ | |
3156 | 736 static void OPNAME ## h264_qpel4_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ |
737 int h=4;\ | |
738 asm volatile(\ | |
739 "pxor %%mm7, %%mm7 \n\t"\ | |
3165 | 740 "movq %0, %%mm4 \n\t"\ |
741 "movq %1, %%mm5 \n\t"\ | |
742 :: "m"(ff_pw_5), "m"(ff_pw_16)\ | |
743 );\ | |
744 do{\ | |
745 asm volatile(\ | |
3156 | 746 "movd -1(%0), %%mm1 \n\t"\ |
747 "movd (%0), %%mm2 \n\t"\ | |
748 "movd 1(%0), %%mm3 \n\t"\ | |
749 "movd 2(%0), %%mm0 \n\t"\ | |
750 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
751 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
752 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
753 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
754 "paddw %%mm0, %%mm1 \n\t"\ | |
755 "paddw %%mm3, %%mm2 \n\t"\ | |
756 "movd -2(%0), %%mm0 \n\t"\ | |
757 "movd 3(%0), %%mm3 \n\t"\ | |
758 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
759 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
760 "paddw %%mm3, %%mm0 \n\t"\ | |
761 "psllw $2, %%mm2 \n\t"\ | |
762 "psubw %%mm1, %%mm2 \n\t"\ | |
763 "pmullw %%mm4, %%mm2 \n\t"\ | |
764 "paddw %%mm5, %%mm0 \n\t"\ | |
765 "paddw %%mm2, %%mm0 \n\t"\ | |
766 "movd (%2), %%mm3 \n\t"\ | |
767 "psraw $5, %%mm0 \n\t"\ | |
768 "packuswb %%mm0, %%mm0 \n\t"\ | |
769 PAVGB" %%mm3, %%mm0 \n\t"\ | |
770 OP(%%mm0, (%1),%%mm6, d)\ | |
3165 | 771 "add %4, %0 \n\t"\ |
772 "add %4, %1 \n\t"\ | |
773 "add %3, %2 \n\t"\ | |
774 : "+a"(src), "+c"(dst), "+d"(src2)\ | |
775 : "D"((long)src2Stride), "S"((long)dstStride)\ | |
3156 | 776 : "memory"\ |
777 );\ | |
3165 | 778 }while(--h);\ |
3156 | 779 }\ |
2754 | 780 static void OPNAME ## h264_qpel4_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ |
781 src -= 2*srcStride;\ | |
782 asm volatile(\ | |
2979 | 783 "pxor %%mm7, %%mm7 \n\t"\ |
784 "movd (%0), %%mm0 \n\t"\ | |
785 "add %2, %0 \n\t"\ | |
786 "movd (%0), %%mm1 \n\t"\ | |
787 "add %2, %0 \n\t"\ | |
788 "movd (%0), %%mm2 \n\t"\ | |
789 "add %2, %0 \n\t"\ | |
790 "movd (%0), %%mm3 \n\t"\ | |
791 "add %2, %0 \n\t"\ | |
792 "movd (%0), %%mm4 \n\t"\ | |
793 "add %2, %0 \n\t"\ | |
794 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
795 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
796 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
797 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
798 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
2754 | 799 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ |
800 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
801 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
802 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
803 \ | |
804 : "+a"(src), "+c"(dst)\ | |
805 : "S"((long)srcStride), "D"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
806 : "memory"\ | |
807 );\ | |
808 }\ | |
809 static void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | |
810 int h=4;\ | |
811 int w=3;\ | |
812 src -= 2*srcStride+2;\ | |
813 while(w--){\ | |
814 asm volatile(\ | |
2979 | 815 "pxor %%mm7, %%mm7 \n\t"\ |
816 "movd (%0), %%mm0 \n\t"\ | |
817 "add %2, %0 \n\t"\ | |
818 "movd (%0), %%mm1 \n\t"\ | |
819 "add %2, %0 \n\t"\ | |
820 "movd (%0), %%mm2 \n\t"\ | |
821 "add %2, %0 \n\t"\ | |
822 "movd (%0), %%mm3 \n\t"\ | |
823 "add %2, %0 \n\t"\ | |
824 "movd (%0), %%mm4 \n\t"\ | |
825 "add %2, %0 \n\t"\ | |
826 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
827 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
828 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
829 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
830 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
2754 | 831 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*8*3)\ |
832 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*8*3)\ | |
833 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*8*3)\ | |
834 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*8*3)\ | |
835 \ | |
836 : "+a"(src)\ | |
837 : "c"(tmp), "S"((long)srcStride), "m"(ff_pw_5)\ | |
838 : "memory"\ | |
839 );\ | |
840 tmp += 4;\ | |
841 src += 4 - 9*srcStride;\ | |
842 }\ | |
843 tmp -= 3*4;\ | |
844 asm volatile(\ | |
2979 | 845 "movq %4, %%mm6 \n\t"\ |
846 "1: \n\t"\ | |
847 "movq (%0), %%mm0 \n\t"\ | |
848 "paddw 10(%0), %%mm0 \n\t"\ | |
849 "movq 2(%0), %%mm1 \n\t"\ | |
850 "paddw 8(%0), %%mm1 \n\t"\ | |
851 "movq 4(%0), %%mm2 \n\t"\ | |
852 "paddw 6(%0), %%mm2 \n\t"\ | |
853 "psubw %%mm1, %%mm0 \n\t"/*a-b (abccba)*/\ | |
854 "psraw $2, %%mm0 \n\t"/*(a-b)/4 */\ | |
855 "psubw %%mm1, %%mm0 \n\t"/*(a-b)/4-b */\ | |
856 "paddsw %%mm2, %%mm0 \n\t"\ | |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
857 "psraw $2, %%mm0 \n\t"/*((a-b)/4-b+c)/4 */\ |
2979 | 858 "paddw %%mm6, %%mm2 \n\t"\ |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
859 "paddw %%mm2, %%mm0 \n\t"/*(a-5*b+20*c)/16 +32 */\ |
2979 | 860 "psraw $6, %%mm0 \n\t"\ |
861 "packuswb %%mm0, %%mm0 \n\t"\ | |
2754 | 862 OP(%%mm0, (%1),%%mm7, d)\ |
2979 | 863 "add $24, %0 \n\t"\ |
864 "add %3, %1 \n\t"\ | |
865 "decl %2 \n\t"\ | |
866 " jnz 1b \n\t"\ | |
2754 | 867 : "+a"(tmp), "+c"(dst), "+m"(h)\ |
868 : "S"((long)dstStride), "m"(ff_pw_32)\ | |
869 : "memory"\ | |
870 );\ | |
871 }\ | |
872 \ | |
873 static void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
874 int h=8;\ | |
875 asm volatile(\ | |
2979 | 876 "pxor %%mm7, %%mm7 \n\t"\ |
877 "movq %5, %%mm6 \n\t"\ | |
878 "1: \n\t"\ | |
879 "movq (%0), %%mm0 \n\t"\ | |
880 "movq 1(%0), %%mm2 \n\t"\ | |
881 "movq %%mm0, %%mm1 \n\t"\ | |
882 "movq %%mm2, %%mm3 \n\t"\ | |
883 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
884 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
885 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
886 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
887 "paddw %%mm2, %%mm0 \n\t"\ | |
888 "paddw %%mm3, %%mm1 \n\t"\ | |
889 "psllw $2, %%mm0 \n\t"\ | |
890 "psllw $2, %%mm1 \n\t"\ | |
891 "movq -1(%0), %%mm2 \n\t"\ | |
892 "movq 2(%0), %%mm4 \n\t"\ | |
893 "movq %%mm2, %%mm3 \n\t"\ | |
894 "movq %%mm4, %%mm5 \n\t"\ | |
895 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
896 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
897 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
898 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
899 "paddw %%mm4, %%mm2 \n\t"\ | |
900 "paddw %%mm3, %%mm5 \n\t"\ | |
901 "psubw %%mm2, %%mm0 \n\t"\ | |
902 "psubw %%mm5, %%mm1 \n\t"\ | |
903 "pmullw %%mm6, %%mm0 \n\t"\ | |
904 "pmullw %%mm6, %%mm1 \n\t"\ | |
905 "movd -2(%0), %%mm2 \n\t"\ | |
906 "movd 7(%0), %%mm5 \n\t"\ | |
907 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
908 "punpcklbw %%mm7, %%mm5 \n\t"\ | |
909 "paddw %%mm3, %%mm2 \n\t"\ | |
910 "paddw %%mm5, %%mm4 \n\t"\ | |
911 "movq %6, %%mm5 \n\t"\ | |
912 "paddw %%mm5, %%mm2 \n\t"\ | |
913 "paddw %%mm5, %%mm4 \n\t"\ | |
914 "paddw %%mm2, %%mm0 \n\t"\ | |
915 "paddw %%mm4, %%mm1 \n\t"\ | |
916 "psraw $5, %%mm0 \n\t"\ | |
917 "psraw $5, %%mm1 \n\t"\ | |
918 "packuswb %%mm1, %%mm0 \n\t"\ | |
2754 | 919 OP(%%mm0, (%1),%%mm5, q)\ |
2979 | 920 "add %3, %0 \n\t"\ |
921 "add %4, %1 \n\t"\ | |
922 "decl %2 \n\t"\ | |
923 " jnz 1b \n\t"\ | |
2754 | 924 : "+a"(src), "+c"(dst), "+m"(h)\ |
925 : "d"((long)srcStride), "S"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
926 : "memory"\ | |
927 );\ | |
928 }\ | |
929 \ | |
3156 | 930 static void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ |
931 int h=8;\ | |
932 asm volatile(\ | |
933 "pxor %%mm7, %%mm7 \n\t"\ | |
3165 | 934 "movq %0, %%mm6 \n\t"\ |
935 :: "m"(ff_pw_5)\ | |
936 );\ | |
937 do{\ | |
938 asm volatile(\ | |
3156 | 939 "movq (%0), %%mm0 \n\t"\ |
940 "movq 1(%0), %%mm2 \n\t"\ | |
941 "movq %%mm0, %%mm1 \n\t"\ | |
942 "movq %%mm2, %%mm3 \n\t"\ | |
943 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
944 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
945 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
946 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
947 "paddw %%mm2, %%mm0 \n\t"\ | |
948 "paddw %%mm3, %%mm1 \n\t"\ | |
949 "psllw $2, %%mm0 \n\t"\ | |
950 "psllw $2, %%mm1 \n\t"\ | |
951 "movq -1(%0), %%mm2 \n\t"\ | |
952 "movq 2(%0), %%mm4 \n\t"\ | |
953 "movq %%mm2, %%mm3 \n\t"\ | |
954 "movq %%mm4, %%mm5 \n\t"\ | |
955 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
956 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
957 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
958 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
959 "paddw %%mm4, %%mm2 \n\t"\ | |
960 "paddw %%mm3, %%mm5 \n\t"\ | |
961 "psubw %%mm2, %%mm0 \n\t"\ | |
962 "psubw %%mm5, %%mm1 \n\t"\ | |
963 "pmullw %%mm6, %%mm0 \n\t"\ | |
964 "pmullw %%mm6, %%mm1 \n\t"\ | |
965 "movd -2(%0), %%mm2 \n\t"\ | |
966 "movd 7(%0), %%mm5 \n\t"\ | |
967 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
968 "punpcklbw %%mm7, %%mm5 \n\t"\ | |
969 "paddw %%mm3, %%mm2 \n\t"\ | |
970 "paddw %%mm5, %%mm4 \n\t"\ | |
3165 | 971 "movq %5, %%mm5 \n\t"\ |
3156 | 972 "paddw %%mm5, %%mm2 \n\t"\ |
973 "paddw %%mm5, %%mm4 \n\t"\ | |
974 "paddw %%mm2, %%mm0 \n\t"\ | |
975 "paddw %%mm4, %%mm1 \n\t"\ | |
976 "psraw $5, %%mm0 \n\t"\ | |
977 "psraw $5, %%mm1 \n\t"\ | |
978 "movq (%2), %%mm4 \n\t"\ | |
979 "packuswb %%mm1, %%mm0 \n\t"\ | |
980 PAVGB" %%mm4, %%mm0 \n\t"\ | |
981 OP(%%mm0, (%1),%%mm5, q)\ | |
3165 | 982 "add %4, %0 \n\t"\ |
983 "add %4, %1 \n\t"\ | |
984 "add %3, %2 \n\t"\ | |
985 : "+a"(src), "+c"(dst), "+d"(src2)\ | |
3156 | 986 : "D"((long)src2Stride), "S"((long)dstStride),\ |
3165 | 987 "m"(ff_pw_16)\ |
3156 | 988 : "memory"\ |
989 );\ | |
3165 | 990 }while(--h);\ |
3156 | 991 }\ |
992 \ | |
3094 | 993 static inline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ |
994 int w= 2;\ | |
2754 | 995 src -= 2*srcStride;\ |
996 \ | |
3094 | 997 while(w--){\ |
2754 | 998 asm volatile(\ |
2979 | 999 "pxor %%mm7, %%mm7 \n\t"\ |
1000 "movd (%0), %%mm0 \n\t"\ | |
1001 "add %2, %0 \n\t"\ | |
1002 "movd (%0), %%mm1 \n\t"\ | |
1003 "add %2, %0 \n\t"\ | |
1004 "movd (%0), %%mm2 \n\t"\ | |
1005 "add %2, %0 \n\t"\ | |
1006 "movd (%0), %%mm3 \n\t"\ | |
1007 "add %2, %0 \n\t"\ | |
1008 "movd (%0), %%mm4 \n\t"\ | |
1009 "add %2, %0 \n\t"\ | |
1010 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1011 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1012 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1013 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1014 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
2754 | 1015 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ |
1016 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1017 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1018 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1019 QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\ | |
1020 QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\ | |
1021 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
1022 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1023 \ | |
1024 : "+a"(src), "+c"(dst)\ | |
1025 : "S"((long)srcStride), "D"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1026 : "memory"\ | |
1027 );\ | |
3094 | 1028 if(h==16){\ |
1029 asm volatile(\ | |
1030 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1031 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1032 QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\ | |
1033 QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\ | |
1034 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
1035 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1036 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1037 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1038 \ | |
1039 : "+a"(src), "+c"(dst)\ | |
1040 : "S"((long)srcStride), "D"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1041 : "memory"\ | |
1042 );\ | |
1043 }\ | |
1044 src += 4-(h+5)*srcStride;\ | |
1045 dst += 4-h*dstStride;\ | |
2754 | 1046 }\ |
1047 }\ | |
3093 | 1048 static inline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\ |
1049 int h = size;\ | |
1050 int w = (size+8)>>2;\ | |
2754 | 1051 src -= 2*srcStride+2;\ |
1052 while(w--){\ | |
1053 asm volatile(\ | |
2979 | 1054 "pxor %%mm7, %%mm7 \n\t"\ |
1055 "movd (%0), %%mm0 \n\t"\ | |
1056 "add %2, %0 \n\t"\ | |
1057 "movd (%0), %%mm1 \n\t"\ | |
1058 "add %2, %0 \n\t"\ | |
1059 "movd (%0), %%mm2 \n\t"\ | |
1060 "add %2, %0 \n\t"\ | |
1061 "movd (%0), %%mm3 \n\t"\ | |
1062 "add %2, %0 \n\t"\ | |
1063 "movd (%0), %%mm4 \n\t"\ | |
1064 "add %2, %0 \n\t"\ | |
1065 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1066 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1067 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1068 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1069 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
3093 | 1070 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*48)\ |
1071 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*48)\ | |
1072 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*48)\ | |
1073 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*48)\ | |
1074 QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 4*48)\ | |
1075 QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 5*48)\ | |
1076 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 6*48)\ | |
1077 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 7*48)\ | |
2754 | 1078 : "+a"(src)\ |
1079 : "c"(tmp), "S"((long)srcStride), "m"(ff_pw_5)\ | |
1080 : "memory"\ | |
1081 );\ | |
3093 | 1082 if(size==16){\ |
1083 asm volatile(\ | |
1084 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 8*48)\ | |
1085 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 9*48)\ | |
1086 QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 10*48)\ | |
1087 QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 11*48)\ | |
1088 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 12*48)\ | |
1089 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 13*48)\ | |
1090 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 14*48)\ | |
1091 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\ | |
1092 : "+a"(src)\ | |
1093 : "c"(tmp), "S"((long)srcStride), "m"(ff_pw_5)\ | |
1094 : "memory"\ | |
1095 );\ | |
1096 }\ | |
2754 | 1097 tmp += 4;\ |
3093 | 1098 src += 4 - (size+5)*srcStride;\ |
2754 | 1099 }\ |
3093 | 1100 tmp -= size+8;\ |
1101 w = size>>4;\ | |
1102 do{\ | |
1103 h = size;\ | |
2754 | 1104 asm volatile(\ |
2979 | 1105 "movq %4, %%mm6 \n\t"\ |
1106 "1: \n\t"\ | |
1107 "movq (%0), %%mm0 \n\t"\ | |
1108 "movq 8(%0), %%mm3 \n\t"\ | |
1109 "movq 2(%0), %%mm1 \n\t"\ | |
1110 "movq 10(%0), %%mm4 \n\t"\ | |
1111 "paddw %%mm4, %%mm0 \n\t"\ | |
1112 "paddw %%mm3, %%mm1 \n\t"\ | |
1113 "paddw 18(%0), %%mm3 \n\t"\ | |
1114 "paddw 16(%0), %%mm4 \n\t"\ | |
1115 "movq 4(%0), %%mm2 \n\t"\ | |
1116 "movq 12(%0), %%mm5 \n\t"\ | |
1117 "paddw 6(%0), %%mm2 \n\t"\ | |
1118 "paddw 14(%0), %%mm5 \n\t"\ | |
1119 "psubw %%mm1, %%mm0 \n\t"\ | |
1120 "psubw %%mm4, %%mm3 \n\t"\ | |
1121 "psraw $2, %%mm0 \n\t"\ | |
1122 "psraw $2, %%mm3 \n\t"\ | |
1123 "psubw %%mm1, %%mm0 \n\t"\ | |
1124 "psubw %%mm4, %%mm3 \n\t"\ | |
1125 "paddsw %%mm2, %%mm0 \n\t"\ | |
1126 "paddsw %%mm5, %%mm3 \n\t"\ | |
1127 "psraw $2, %%mm0 \n\t"\ | |
1128 "psraw $2, %%mm3 \n\t"\ | |
1129 "paddw %%mm6, %%mm2 \n\t"\ | |
1130 "paddw %%mm6, %%mm5 \n\t"\ | |
1131 "paddw %%mm2, %%mm0 \n\t"\ | |
1132 "paddw %%mm5, %%mm3 \n\t"\ | |
1133 "psraw $6, %%mm0 \n\t"\ | |
1134 "psraw $6, %%mm3 \n\t"\ | |
1135 "packuswb %%mm3, %%mm0 \n\t"\ | |
2754 | 1136 OP(%%mm0, (%1),%%mm7, q)\ |
3093 | 1137 "add $48, %0 \n\t"\ |
2979 | 1138 "add %3, %1 \n\t"\ |
1139 "decl %2 \n\t"\ | |
1140 " jnz 1b \n\t"\ | |
2754 | 1141 : "+a"(tmp), "+c"(dst), "+m"(h)\ |
1142 : "S"((long)dstStride), "m"(ff_pw_32)\ | |
1143 : "memory"\ | |
1144 );\ | |
3093 | 1145 tmp += 8 - size*24;\ |
1146 dst += 8 - size*dstStride;\ | |
1147 }while(w--);\ | |
2754 | 1148 }\ |
3094 | 1149 \ |
1150 static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1151 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\ | |
1152 }\ | |
2754 | 1153 static void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ |
3094 | 1154 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\ |
1155 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\ | |
2754 | 1156 }\ |
1157 \ | |
1158 static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1159 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\ | |
1160 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
1161 src += 8*srcStride;\ | |
1162 dst += 8*dstStride;\ | |
1163 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\ | |
1164 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
1165 }\ | |
1166 \ | |
3156 | 1167 static void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ |
1168 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\ | |
1169 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\ | |
1170 src += 8*dstStride;\ | |
1171 dst += 8*dstStride;\ | |
1172 src2 += 8*src2Stride;\ | |
1173 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\ | |
1174 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\ | |
1175 }\ | |
1176 \ | |
3093 | 1177 static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ |
1178 OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 8);\ | |
1179 }\ | |
1180 \ | |
2754 | 1181 static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ |
3093 | 1182 OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\ |
2754 | 1183 }\ |
3095 | 1184 \ |
1185 static void OPNAME ## pixels4_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1186 {\ | |
1187 asm volatile(\ | |
1188 "movq %5, %%mm6 \n\t"\ | |
1189 "movq (%1), %%mm0 \n\t"\ | |
1190 "movq 24(%1), %%mm1 \n\t"\ | |
1191 "paddw %%mm6, %%mm0 \n\t"\ | |
1192 "paddw %%mm6, %%mm1 \n\t"\ | |
3102 | 1193 "psraw $5, %%mm0 \n\t"\ |
1194 "psraw $5, %%mm1 \n\t"\ | |
3163 | 1195 "packuswb %%mm0, %%mm0 \n\t"\ |
1196 "packuswb %%mm1, %%mm1 \n\t"\ | |
3095 | 1197 PAVGB" (%0), %%mm0 \n\t"\ |
1198 PAVGB" (%0,%3), %%mm1 \n\t"\ | |
1199 OP(%%mm0, (%2), %%mm4, d)\ | |
1200 OP(%%mm1, (%2,%4), %%mm5, d)\ | |
1201 "lea (%0,%3,2), %0 \n\t"\ | |
1202 "lea (%2,%4,2), %2 \n\t"\ | |
1203 "movq 48(%1), %%mm0 \n\t"\ | |
1204 "movq 72(%1), %%mm1 \n\t"\ | |
1205 "paddw %%mm6, %%mm0 \n\t"\ | |
1206 "paddw %%mm6, %%mm1 \n\t"\ | |
3102 | 1207 "psraw $5, %%mm0 \n\t"\ |
1208 "psraw $5, %%mm1 \n\t"\ | |
3163 | 1209 "packuswb %%mm0, %%mm0 \n\t"\ |
1210 "packuswb %%mm1, %%mm1 \n\t"\ | |
3095 | 1211 PAVGB" (%0), %%mm0 \n\t"\ |
1212 PAVGB" (%0,%3), %%mm1 \n\t"\ | |
1213 OP(%%mm0, (%2), %%mm4, d)\ | |
1214 OP(%%mm1, (%2,%4), %%mm5, d)\ | |
1215 :"+a"(src8), "+c"(src16), "+d"(dst)\ | |
3096 | 1216 :"S"((long)src8Stride), "D"((long)dstStride), "m"(ff_pw_16)\ |
3095 | 1217 :"memory");\ |
1218 }\ | |
1219 static void OPNAME ## pixels8_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1220 {\ | |
1221 asm volatile(\ | |
1222 "movq %0, %%mm6 \n\t"\ | |
1223 ::"m"(ff_pw_16)\ | |
1224 );\ | |
1225 while(h--){\ | |
1226 asm volatile(\ | |
1227 "movq (%1), %%mm0 \n\t"\ | |
1228 "movq 8(%1), %%mm1 \n\t"\ | |
1229 "paddw %%mm6, %%mm0 \n\t"\ | |
1230 "paddw %%mm6, %%mm1 \n\t"\ | |
3102 | 1231 "psraw $5, %%mm0 \n\t"\ |
1232 "psraw $5, %%mm1 \n\t"\ | |
3095 | 1233 "packuswb %%mm1, %%mm0 \n\t"\ |
1234 PAVGB" (%0), %%mm0 \n\t"\ | |
1235 OP(%%mm0, (%2), %%mm5, q)\ | |
1236 ::"a"(src8), "c"(src16), "d"(dst)\ | |
1237 :"memory");\ | |
1238 src8 += src8Stride;\ | |
1239 src16 += 24;\ | |
1240 dst += dstStride;\ | |
1241 }\ | |
1242 }\ | |
1243 static void OPNAME ## pixels16_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1244 {\ | |
1245 OPNAME ## pixels8_l2_shift5_ ## MMX(dst , src16 , src8 , dstStride, src8Stride, h);\ | |
1246 OPNAME ## pixels8_l2_shift5_ ## MMX(dst+8, src16+8, src8+8, dstStride, src8Stride, h);\ | |
1247 }\ | |
1248 | |
2754 | 1249 |
1250 #define H264_MC(OPNAME, SIZE, MMX) \ | |
1251 static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\ | |
1252 OPNAME ## pixels ## SIZE ## _mmx(dst, src, stride, SIZE);\ | |
1253 }\ | |
1254 \ | |
1255 static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1256 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\ |
2754 | 1257 }\ |
1258 \ | |
1259 static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1260 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\ | |
1261 }\ | |
1262 \ | |
1263 static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1264 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\ |
2754 | 1265 }\ |
1266 \ | |
1267 static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1268 uint64_t temp[SIZE*SIZE/8];\ | |
1269 uint8_t * const half= (uint8_t*)temp;\ | |
1270 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(half, src, SIZE, stride);\ | |
1271 OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, half, stride, stride, SIZE);\ | |
1272 }\ | |
1273 \ | |
1274 static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1275 OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\ | |
1276 }\ | |
1277 \ | |
1278 static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1279 uint64_t temp[SIZE*SIZE/8];\ | |
1280 uint8_t * const half= (uint8_t*)temp;\ | |
1281 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(half, src, SIZE, stride);\ | |
1282 OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, half, stride, stride, SIZE);\ | |
1283 }\ | |
1284 \ | |
1285 static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1286 uint64_t temp[SIZE*SIZE/8];\ |
1287 uint8_t * const halfV= (uint8_t*)temp;\ | |
2754 | 1288 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\ |
3156 | 1289 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfV, stride, SIZE);\ |
2754 | 1290 }\ |
1291 \ | |
1292 static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1293 uint64_t temp[SIZE*SIZE/8];\ |
1294 uint8_t * const halfV= (uint8_t*)temp;\ | |
2754 | 1295 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\ |
3156 | 1296 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfV, stride, SIZE);\ |
2754 | 1297 }\ |
1298 \ | |
1299 static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1300 uint64_t temp[SIZE*SIZE/8];\ |
1301 uint8_t * const halfV= (uint8_t*)temp;\ | |
2754 | 1302 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\ |
3156 | 1303 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfV, stride, SIZE);\ |
2754 | 1304 }\ |
1305 \ | |
1306 static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1307 uint64_t temp[SIZE*SIZE/8];\ |
1308 uint8_t * const halfV= (uint8_t*)temp;\ | |
2754 | 1309 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\ |
3156 | 1310 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfV, stride, SIZE);\ |
2754 | 1311 }\ |
1312 \ | |
1313 static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3093 | 1314 uint64_t temp[SIZE*(SIZE<8?12:24)/4];\ |
2754 | 1315 int16_t * const tmp= (int16_t*)temp;\ |
1316 OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, tmp, src, stride, SIZE, stride);\ | |
1317 }\ | |
1318 \ | |
1319 static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1320 uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\ |
1321 uint8_t * const halfHV= (uint8_t*)temp;\ | |
1322 int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE/2;\ | |
2754 | 1323 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\ |
3156 | 1324 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\ |
2754 | 1325 }\ |
1326 \ | |
1327 static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1328 uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\ |
1329 uint8_t * const halfHV= (uint8_t*)temp;\ | |
1330 int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE/2;\ | |
2754 | 1331 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\ |
3156 | 1332 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\ |
2754 | 1333 }\ |
1334 \ | |
1335 static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3095 | 1336 uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\ |
1337 int16_t * const halfV= ((int16_t*)temp) + SIZE*SIZE/2;\ | |
1338 uint8_t * const halfHV= ((uint8_t*)temp);\ | |
1339 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\ | |
1340 OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+2, halfHV, stride, SIZE, SIZE);\ | |
2754 | 1341 }\ |
1342 \ | |
1343 static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3095 | 1344 uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\ |
1345 int16_t * const halfV= ((int16_t*)temp) + SIZE*SIZE/2;\ | |
1346 uint8_t * const halfHV= ((uint8_t*)temp);\ | |
1347 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\ | |
1348 OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+3, halfHV, stride, SIZE, SIZE);\ | |
2754 | 1349 }\ |
1350 | |
1351 | |
1352 #define AVG_3DNOW_OP(a,b,temp, size) \ | |
2979 | 1353 "mov" #size " " #b ", " #temp " \n\t"\ |
1354 "pavgusb " #temp ", " #a " \n\t"\ | |
1355 "mov" #size " " #a ", " #b " \n\t" | |
2754 | 1356 #define AVG_MMX2_OP(a,b,temp, size) \ |
2979 | 1357 "mov" #size " " #b ", " #temp " \n\t"\ |
1358 "pavgb " #temp ", " #a " \n\t"\ | |
1359 "mov" #size " " #a ", " #b " \n\t" | |
2754 | 1360 |
3095 | 1361 #define PAVGB "pavgusb" |
2754 | 1362 QPEL_H264(put_, PUT_OP, 3dnow) |
1363 QPEL_H264(avg_, AVG_3DNOW_OP, 3dnow) | |
3095 | 1364 #undef PAVGB |
1365 #define PAVGB "pavgb" | |
2754 | 1366 QPEL_H264(put_, PUT_OP, mmx2) |
1367 QPEL_H264(avg_, AVG_MMX2_OP, mmx2) | |
3095 | 1368 #undef PAVGB |
2754 | 1369 |
1370 H264_MC(put_, 4, 3dnow) | |
1371 H264_MC(put_, 8, 3dnow) | |
1372 H264_MC(put_, 16,3dnow) | |
1373 H264_MC(avg_, 4, 3dnow) | |
1374 H264_MC(avg_, 8, 3dnow) | |
1375 H264_MC(avg_, 16,3dnow) | |
1376 H264_MC(put_, 4, mmx2) | |
1377 H264_MC(put_, 8, mmx2) | |
1378 H264_MC(put_, 16,mmx2) | |
1379 H264_MC(avg_, 4, mmx2) | |
1380 H264_MC(avg_, 8, mmx2) | |
1381 H264_MC(avg_, 16,mmx2) | |
1382 | |
1383 | |
1384 #define H264_CHROMA_OP(S,D) | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1385 #define H264_CHROMA_OP4(S,D,T) |
2754 | 1386 #define H264_CHROMA_MC8_TMPL put_h264_chroma_mc8_mmx |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1387 #define H264_CHROMA_MC4_TMPL put_h264_chroma_mc4_mmx |
3213 | 1388 #define H264_CHROMA_MC2_TMPL put_h264_chroma_mc2_mmx2 |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1389 #define H264_CHROMA_MC8_MV0 put_pixels8_mmx |
2754 | 1390 #include "dsputil_h264_template_mmx.c" |
1391 #undef H264_CHROMA_OP | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1392 #undef H264_CHROMA_OP4 |
2754 | 1393 #undef H264_CHROMA_MC8_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1394 #undef H264_CHROMA_MC4_TMPL |
3213 | 1395 #undef H264_CHROMA_MC2_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1396 #undef H264_CHROMA_MC8_MV0 |
2754 | 1397 |
1398 #define H264_CHROMA_OP(S,D) "pavgb " #S ", " #D " \n\t" | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1399 #define H264_CHROMA_OP4(S,D,T) "movd " #S ", " #T " \n\t"\ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1400 "pavgb " #T ", " #D " \n\t" |
2754 | 1401 #define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_mmx2 |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1402 #define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_mmx2 |
3213 | 1403 #define H264_CHROMA_MC2_TMPL avg_h264_chroma_mc2_mmx2 |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1404 #define H264_CHROMA_MC8_MV0 avg_pixels8_mmx2 |
2754 | 1405 #include "dsputil_h264_template_mmx.c" |
1406 #undef H264_CHROMA_OP | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1407 #undef H264_CHROMA_OP4 |
2754 | 1408 #undef H264_CHROMA_MC8_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1409 #undef H264_CHROMA_MC4_TMPL |
3213 | 1410 #undef H264_CHROMA_MC2_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1411 #undef H264_CHROMA_MC8_MV0 |
2754 | 1412 |
1413 #define H264_CHROMA_OP(S,D) "pavgusb " #S ", " #D " \n\t" | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1414 #define H264_CHROMA_OP4(S,D,T) "movd " #S ", " #T " \n\t"\ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1415 "pavgusb " #T ", " #D " \n\t" |
2754 | 1416 #define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_3dnow |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1417 #define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_3dnow |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1418 #define H264_CHROMA_MC8_MV0 avg_pixels8_3dnow |
2754 | 1419 #include "dsputil_h264_template_mmx.c" |
1420 #undef H264_CHROMA_OP | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1421 #undef H264_CHROMA_OP4 |
2754 | 1422 #undef H264_CHROMA_MC8_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1423 #undef H264_CHROMA_MC4_TMPL |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1424 #undef H264_CHROMA_MC8_MV0 |
2754 | 1425 |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1426 /***********************************/ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1427 /* weighted prediction */ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1428 |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1429 static inline void ff_h264_weight_WxH_mmx2(uint8_t *dst, int stride, int log2_denom, int weight, int offset, int w, int h) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1430 { |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1431 int x, y; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1432 offset <<= log2_denom; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1433 offset += (1 << log2_denom) >> 1; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1434 asm volatile( |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1435 "movd %0, %%mm4 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1436 "movd %1, %%mm5 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1437 "movd %2, %%mm6 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1438 "pshufw $0, %%mm4, %%mm4 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1439 "pshufw $0, %%mm5, %%mm5 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1440 "pxor %%mm7, %%mm7 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1441 :: "g"(weight), "g"(offset), "g"(log2_denom) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1442 ); |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1443 for(y=0; y<h; y+=2){ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1444 for(x=0; x<w; x+=4){ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1445 asm volatile( |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1446 "movd %0, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1447 "movd %1, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1448 "punpcklbw %%mm7, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1449 "punpcklbw %%mm7, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1450 "pmullw %%mm4, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1451 "pmullw %%mm4, %%mm1 \n\t" |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
1452 "paddsw %%mm5, %%mm0 \n\t" |
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
1453 "paddsw %%mm5, %%mm1 \n\t" |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1454 "psraw %%mm6, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1455 "psraw %%mm6, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1456 "packuswb %%mm7, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1457 "packuswb %%mm7, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1458 "movd %%mm0, %0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1459 "movd %%mm1, %1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1460 : "+m"(*(uint32_t*)(dst+x)), |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1461 "+m"(*(uint32_t*)(dst+x+stride)) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1462 ); |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1463 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1464 dst += 2*stride; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1465 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1466 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1467 |
3029 | 1468 static inline void ff_h264_biweight_WxH_mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset, int w, int h) |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1469 { |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1470 int x, y; |
3029 | 1471 offset = ((offset + 1) | 1) << log2_denom; |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1472 asm volatile( |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1473 "movd %0, %%mm3 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1474 "movd %1, %%mm4 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1475 "movd %2, %%mm5 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1476 "movd %3, %%mm6 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1477 "pshufw $0, %%mm3, %%mm3 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1478 "pshufw $0, %%mm4, %%mm4 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1479 "pshufw $0, %%mm5, %%mm5 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1480 "pxor %%mm7, %%mm7 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1481 :: "g"(weightd), "g"(weights), "g"(offset), "g"(log2_denom+1) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1482 ); |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1483 for(y=0; y<h; y++){ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1484 for(x=0; x<w; x+=4){ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1485 asm volatile( |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1486 "movd %0, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1487 "movd %1, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1488 "punpcklbw %%mm7, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1489 "punpcklbw %%mm7, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1490 "pmullw %%mm3, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1491 "pmullw %%mm4, %%mm1 \n\t" |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
1492 "paddsw %%mm1, %%mm0 \n\t" |
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
1493 "paddsw %%mm5, %%mm0 \n\t" |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1494 "psraw %%mm6, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1495 "packuswb %%mm0, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1496 "movd %%mm0, %0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1497 : "+m"(*(uint32_t*)(dst+x)) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1498 : "m"(*(uint32_t*)(src+x)) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1499 ); |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1500 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1501 src += stride; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1502 dst += stride; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1503 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1504 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1505 |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1506 #define H264_WEIGHT(W,H) \ |
3029 | 1507 static void ff_h264_biweight_ ## W ## x ## H ## _mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset){ \ |
1508 ff_h264_biweight_WxH_mmx2(dst, src, stride, log2_denom, weightd, weights, offset, W, H); \ | |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1509 } \ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1510 static void ff_h264_weight_ ## W ## x ## H ## _mmx2(uint8_t *dst, int stride, int log2_denom, int weight, int offset){ \ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1511 ff_h264_weight_WxH_mmx2(dst, stride, log2_denom, weight, offset, W, H); \ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1512 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1513 |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1514 H264_WEIGHT(16,16) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1515 H264_WEIGHT(16, 8) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1516 H264_WEIGHT( 8,16) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1517 H264_WEIGHT( 8, 8) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1518 H264_WEIGHT( 8, 4) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1519 H264_WEIGHT( 4, 8) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1520 H264_WEIGHT( 4, 4) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1521 H264_WEIGHT( 4, 2) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1522 |