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