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