Mercurial > libavcodec.hg
annotate i386/h264dsp_mmx.c @ 4104:04ff8026d9c0 libavcodec
dont set the sampling rate just because 1 mp3 packet header says so (fixes playback speed on some old mencoder generated avis which where then dumped to mp3)
author | michael |
---|---|
date | Mon, 30 Oct 2006 02:19:55 +0000 |
parents | c8c591fe26f8 |
children | d011a097bb85 |
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)\ | |
340 /* a = q0^p0^((p1-q1)>>2) */\ | |
341 "movq %%mm0, %%mm4 \n\t"\ | |
342 "psubb %%mm3, %%mm4 \n\t"\ | |
343 "psrlw $2, %%mm4 \n\t"\ | |
344 "pxor %%mm1, %%mm4 \n\t"\ | |
345 "pxor %%mm2, %%mm4 \n\t"\ | |
346 /* b = p0^(q1>>2) */\ | |
347 "psrlw $2, %%mm3 \n\t"\ | |
348 "pand "#pb_3f", %%mm3 \n\t"\ | |
349 "movq %%mm1, %%mm5 \n\t"\ | |
350 "pxor %%mm3, %%mm5 \n\t"\ | |
351 /* c = q0^(p1>>2) */\ | |
352 "psrlw $2, %%mm0 \n\t"\ | |
353 "pand "#pb_3f", %%mm0 \n\t"\ | |
354 "movq %%mm2, %%mm6 \n\t"\ | |
355 "pxor %%mm0, %%mm6 \n\t"\ | |
356 /* d = (c^b) & ~(b^a) & 1 */\ | |
357 "pxor %%mm5, %%mm6 \n\t"\ | |
358 "pxor %%mm4, %%mm5 \n\t"\ | |
359 "pandn %%mm6, %%mm5 \n\t"\ | |
360 "pand "#pb_01", %%mm5 \n\t"\ | |
361 /* delta = (avg(q0, p1>>2) + (d&a)) | |
362 * - (avg(p0, q1>>2) + (d&~a)) */\ | |
363 "pavgb %%mm2, %%mm0 \n\t"\ | |
2855
da95623de901
simplify (d&a) and (d&~a) calculation, hint by skal
michael
parents:
2754
diff
changeset
|
364 "pand %%mm5, %%mm4 \n\t"\ |
da95623de901
simplify (d&a) and (d&~a) calculation, hint by skal
michael
parents:
2754
diff
changeset
|
365 "paddusb %%mm4, %%mm0 \n\t"\ |
2754 | 366 "pavgb %%mm1, %%mm3 \n\t"\ |
2855
da95623de901
simplify (d&a) and (d&~a) calculation, hint by skal
michael
parents:
2754
diff
changeset
|
367 "pxor %%mm5, %%mm4 \n\t"\ |
2754 | 368 "paddusb %%mm4, %%mm3 \n\t"\ |
369 /* p0 += clip(delta, -tc0, tc0) | |
370 * q0 -= clip(delta, -tc0, tc0) */\ | |
371 "movq %%mm0, %%mm4 \n\t"\ | |
372 "psubusb %%mm3, %%mm0 \n\t"\ | |
373 "psubusb %%mm4, %%mm3 \n\t"\ | |
374 "pminub %%mm7, %%mm0 \n\t"\ | |
375 "pminub %%mm7, %%mm3 \n\t"\ | |
376 "paddusb %%mm0, %%mm1 \n\t"\ | |
377 "paddusb %%mm3, %%mm2 \n\t"\ | |
378 "psubusb %%mm3, %%mm1 \n\t"\ | |
379 "psubusb %%mm0, %%mm2 \n\t" | |
380 | |
381 // in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask) %8=mm_bone | |
382 // out: (q1addr) = clip( (q2+((p0+q0+1)>>1))>>1, q1-tc0, q1+tc0 ) | |
383 // clobbers: q2, tmp, tc0 | |
384 #define H264_DEBLOCK_Q1(p1, q2, q2addr, q1addr, tc0, tmp)\ | |
385 "movq %%mm1, "#tmp" \n\t"\ | |
386 "pavgb %%mm2, "#tmp" \n\t"\ | |
387 "pavgb "#tmp", "#q2" \n\t" /* avg(p2,avg(p0,q0)) */\ | |
388 "pxor "q2addr", "#tmp" \n\t"\ | |
389 "pand %8, "#tmp" \n\t" /* (p2^avg(p0,q0))&1 */\ | |
390 "psubusb "#tmp", "#q2" \n\t" /* (p2+((p0+q0+1)>>1))>>1 */\ | |
391 "movq "#p1", "#tmp" \n\t"\ | |
392 "psubusb "#tc0", "#tmp" \n\t"\ | |
393 "paddusb "#p1", "#tc0" \n\t"\ | |
394 "pmaxub "#tmp", "#q2" \n\t"\ | |
395 "pminub "#tc0", "#q2" \n\t"\ | |
396 "movq "#q2", "q1addr" \n\t" | |
397 | |
398 static inline void h264_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0) | |
399 { | |
400 uint64_t tmp0; | |
401 uint64_t tc = (uint8_t)tc0[1]*0x01010000 | (uint8_t)tc0[0]*0x0101; | |
402 // with luma, tc0=0 doesn't mean no filtering, so we need a separate input mask | |
403 uint32_t mask[2] = { (tc0[0]>=0)*0xffffffff, (tc0[1]>=0)*0xffffffff }; | |
404 | |
405 asm volatile( | |
406 "movq (%1,%3), %%mm0 \n\t" //p1 | |
407 "movq (%1,%3,2), %%mm1 \n\t" //p0 | |
408 "movq (%2), %%mm2 \n\t" //q0 | |
409 "movq (%2,%3), %%mm3 \n\t" //q1 | |
410 H264_DEBLOCK_MASK(%6, %7) | |
411 "pand %5, %%mm7 \n\t" | |
412 "movq %%mm7, %0 \n\t" | |
413 | |
414 /* filter p1 */ | |
415 "movq (%1), %%mm3 \n\t" //p2 | |
416 DIFF_GT_MMX(%%mm1, %%mm3, %%mm5, %%mm6, %%mm4) // |p2-p0|>beta-1 | |
417 "pandn %%mm7, %%mm6 \n\t" | |
418 "pcmpeqb %%mm7, %%mm6 \n\t" | |
419 "pand %%mm7, %%mm6 \n\t" // mask & |p2-p0|<beta | |
420 "pshufw $80, %4, %%mm4 \n\t" | |
421 "pand %%mm7, %%mm4 \n\t" // mask & tc0 | |
422 "movq %8, %%mm7 \n\t" | |
423 "pand %%mm6, %%mm7 \n\t" // mask & |p2-p0|<beta & 1 | |
424 "pand %%mm4, %%mm6 \n\t" // mask & |p2-p0|<beta & tc0 | |
425 "paddb %%mm4, %%mm7 \n\t" // tc++ | |
426 H264_DEBLOCK_Q1(%%mm0, %%mm3, "(%1)", "(%1,%3)", %%mm6, %%mm4) | |
427 | |
428 /* filter q1 */ | |
429 "movq (%2,%3,2), %%mm4 \n\t" //q2 | |
430 DIFF_GT_MMX(%%mm2, %%mm4, %%mm5, %%mm6, %%mm3) // |q2-q0|>beta-1 | |
431 "pandn %0, %%mm6 \n\t" | |
432 "pcmpeqb %0, %%mm6 \n\t" | |
433 "pand %0, %%mm6 \n\t" | |
434 "pshufw $80, %4, %%mm5 \n\t" | |
435 "pand %%mm6, %%mm5 \n\t" | |
436 "pand %8, %%mm6 \n\t" | |
437 "paddb %%mm6, %%mm7 \n\t" | |
438 "movq (%2,%3), %%mm3 \n\t" | |
439 H264_DEBLOCK_Q1(%%mm3, %%mm4, "(%2,%3,2)", "(%2,%3)", %%mm5, %%mm6) | |
440 | |
441 /* filter p0, q0 */ | |
442 H264_DEBLOCK_P0_Q0(%8, %9) | |
443 "movq %%mm1, (%1,%3,2) \n\t" | |
444 "movq %%mm2, (%2) \n\t" | |
445 | |
446 : "=m"(tmp0) | |
447 : "r"(pix-3*stride), "r"(pix), "r"((long)stride), | |
448 "m"(tc), "m"(*(uint64_t*)mask), "m"(alpha1), "m"(beta1), | |
449 "m"(mm_bone), "m"(ff_pb_3F) | |
450 ); | |
451 } | |
452 | |
453 static void h264_v_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
454 { | |
455 if((tc0[0] & tc0[1]) >= 0) | |
456 h264_loop_filter_luma_mmx2(pix, stride, alpha-1, beta-1, tc0); | |
457 if((tc0[2] & tc0[3]) >= 0) | |
458 h264_loop_filter_luma_mmx2(pix+8, stride, alpha-1, beta-1, tc0+2); | |
459 } | |
460 static void h264_h_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
461 { | |
462 //FIXME: could cut some load/stores by merging transpose with filter | |
463 // also, it only needs to transpose 6x8 | |
464 uint8_t trans[8*8]; | |
465 int i; | |
466 for(i=0; i<2; i++, pix+=8*stride, tc0+=2) { | |
467 if((tc0[0] & tc0[1]) < 0) | |
468 continue; | |
469 transpose4x4(trans, pix-4, 8, stride); | |
470 transpose4x4(trans +4*8, pix, 8, stride); | |
471 transpose4x4(trans+4, pix-4+4*stride, 8, stride); | |
472 transpose4x4(trans+4+4*8, pix +4*stride, 8, stride); | |
473 h264_loop_filter_luma_mmx2(trans+4*8, 8, alpha-1, beta-1, tc0); | |
474 transpose4x4(pix-2, trans +2*8, stride, 8); | |
475 transpose4x4(pix-2+4*stride, trans+4+2*8, stride, 8); | |
476 } | |
477 } | |
478 | |
479 static inline void h264_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0) | |
480 { | |
481 asm volatile( | |
482 "movq (%0), %%mm0 \n\t" //p1 | |
483 "movq (%0,%2), %%mm1 \n\t" //p0 | |
484 "movq (%1), %%mm2 \n\t" //q0 | |
485 "movq (%1,%2), %%mm3 \n\t" //q1 | |
486 H264_DEBLOCK_MASK(%4, %5) | |
487 "movd %3, %%mm6 \n\t" | |
488 "punpcklbw %%mm6, %%mm6 \n\t" | |
489 "pand %%mm6, %%mm7 \n\t" // mm7 = tc&mask | |
490 H264_DEBLOCK_P0_Q0(%6, %7) | |
491 "movq %%mm1, (%0,%2) \n\t" | |
492 "movq %%mm2, (%1) \n\t" | |
493 | |
494 :: "r"(pix-2*stride), "r"(pix), "r"((long)stride), | |
495 "r"(*(uint32_t*)tc0), | |
496 "m"(alpha1), "m"(beta1), "m"(mm_bone), "m"(ff_pb_3F) | |
497 ); | |
498 } | |
499 | |
500 static void h264_v_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
501 { | |
502 h264_loop_filter_chroma_mmx2(pix, stride, alpha-1, beta-1, tc0); | |
503 } | |
504 | |
505 static void h264_h_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
506 { | |
507 //FIXME: could cut some load/stores by merging transpose with filter | |
508 uint8_t trans[8*4]; | |
509 transpose4x4(trans, pix-2, 8, stride); | |
510 transpose4x4(trans+4, pix-2+4*stride, 8, stride); | |
511 h264_loop_filter_chroma_mmx2(trans+2*8, 8, alpha-1, beta-1, tc0); | |
512 transpose4x4(pix-2, trans, stride, 8); | |
513 transpose4x4(pix-2+4*stride, trans+4, stride, 8); | |
514 } | |
515 | |
516 // p0 = (p0 + q1 + 2*p1 + 2) >> 2 | |
517 #define H264_FILTER_CHROMA4(p0, p1, q1, one) \ | |
518 "movq "#p0", %%mm4 \n\t"\ | |
519 "pxor "#q1", %%mm4 \n\t"\ | |
520 "pand "#one", %%mm4 \n\t" /* mm4 = (p0^q1)&1 */\ | |
521 "pavgb "#q1", "#p0" \n\t"\ | |
522 "psubusb %%mm4, "#p0" \n\t"\ | |
523 "pavgb "#p1", "#p0" \n\t" /* dst = avg(p1, avg(p0,q1) - ((p0^q1)&1)) */\ | |
524 | |
525 static inline void h264_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha1, int beta1) | |
526 { | |
527 asm volatile( | |
528 "movq (%0), %%mm0 \n\t" | |
529 "movq (%0,%2), %%mm1 \n\t" | |
530 "movq (%1), %%mm2 \n\t" | |
531 "movq (%1,%2), %%mm3 \n\t" | |
532 H264_DEBLOCK_MASK(%3, %4) | |
533 "movq %%mm1, %%mm5 \n\t" | |
534 "movq %%mm2, %%mm6 \n\t" | |
535 H264_FILTER_CHROMA4(%%mm1, %%mm0, %%mm3, %5) //p0' | |
536 H264_FILTER_CHROMA4(%%mm2, %%mm3, %%mm0, %5) //q0' | |
537 "psubb %%mm5, %%mm1 \n\t" | |
538 "psubb %%mm6, %%mm2 \n\t" | |
539 "pand %%mm7, %%mm1 \n\t" | |
540 "pand %%mm7, %%mm2 \n\t" | |
541 "paddb %%mm5, %%mm1 \n\t" | |
542 "paddb %%mm6, %%mm2 \n\t" | |
543 "movq %%mm1, (%0,%2) \n\t" | |
544 "movq %%mm2, (%1) \n\t" | |
545 :: "r"(pix-2*stride), "r"(pix), "r"((long)stride), | |
546 "m"(alpha1), "m"(beta1), "m"(mm_bone) | |
547 ); | |
548 } | |
549 | |
550 static void h264_v_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta) | |
551 { | |
552 h264_loop_filter_chroma_intra_mmx2(pix, stride, alpha-1, beta-1); | |
553 } | |
554 | |
555 static void h264_h_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta) | |
556 { | |
557 //FIXME: could cut some load/stores by merging transpose with filter | |
558 uint8_t trans[8*4]; | |
559 transpose4x4(trans, pix-2, 8, stride); | |
560 transpose4x4(trans+4, pix-2+4*stride, 8, stride); | |
561 h264_loop_filter_chroma_intra_mmx2(trans+2*8, 8, alpha-1, beta-1); | |
562 transpose4x4(pix-2, trans, stride, 8); | |
563 transpose4x4(pix-2+4*stride, trans+4, stride, 8); | |
564 } | |
565 | |
3645
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
566 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
|
567 int bidir, int edges, int step, int mask_mv0, int mask_mv1 ) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
568 int dir; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
569 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
570 "pxor %%mm7, %%mm7 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
571 "movq %0, %%mm6 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
572 "movq %1, %%mm5 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
573 "movq %2, %%mm4 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
574 ::"m"(ff_pb_1), "m"(ff_pb_3), "m"(ff_pb_7) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
575 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
576 // 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
|
577 // average filter time by 1.2% |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
578 for( dir=1; dir>=0; dir-- ) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
579 const int d_idx = dir ? -8 : -1; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
580 const int mask_mv = dir ? mask_mv1 : mask_mv0; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
581 const uint64_t mask_dir = dir ? 0 : 0xffffffffffffffffULL; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
582 int b_idx, edge, l; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
583 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
|
584 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
585 "pand %0, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
586 ::"m"(mask_dir) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
587 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
588 if(!(mask_mv & edge)) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
589 asm volatile("pxor %%mm0, %%mm0 \n\t":); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
590 for( l = bidir; l >= 0; l-- ) { |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
591 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
592 "movd %0, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
593 "punpckldq %1, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
594 "movq %%mm1, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
595 "psrlw $7, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
596 "pand %%mm6, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
597 "por %%mm2, %%mm1 \n\t" // ref_cache with -2 mapped to -1 |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
598 "punpckldq %%mm1, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
599 "pcmpeqb %%mm2, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
600 "paddb %%mm6, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
601 "punpckhbw %%mm7, %%mm1 \n\t" // ref[b] != ref[bn] |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
602 "por %%mm1, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
603 |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
604 "movq %2, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
605 "movq %3, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
606 "psubw %4, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
607 "psubw %5, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
608 "packsswb %%mm2, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
609 "paddb %%mm5, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
610 "pminub %%mm4, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
611 "pcmpeqb %%mm4, %%mm1 \n\t" // abs(mv[b] - mv[bn]) >= limit |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
612 "por %%mm1, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
613 ::"m"(ref[l][b_idx]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
614 "m"(ref[l][b_idx+d_idx]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
615 "m"(mv[l][b_idx][0]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
616 "m"(mv[l][b_idx+2][0]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
617 "m"(mv[l][b_idx+d_idx][0]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
618 "m"(mv[l][b_idx+d_idx+2][0]) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
619 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
620 } |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
621 } |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
622 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
623 "movd %0, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
624 "por %1, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
625 "punpcklbw %%mm7, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
626 "pcmpgtw %%mm7, %%mm1 \n\t" // nnz[b] || nnz[bn] |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
627 ::"m"(nnz[b_idx]), |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
628 "m"(nnz[b_idx+d_idx]) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
629 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
630 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
631 "pcmpeqw %%mm7, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
632 "pcmpeqw %%mm7, %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
633 "psrlw $15, %%mm0 \n\t" // nonzero -> 1 |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
634 "psrlw $14, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
635 "movq %%mm0, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
636 "por %%mm1, %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
637 "psrlw $1, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
638 "pandn %%mm2, %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
639 "movq %%mm1, %0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
640 :"=m"(*bS[dir][edge]) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
641 ::"memory" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
642 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
643 } |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
644 edges = 4; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
645 step = 1; |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
646 } |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
647 asm volatile( |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
648 "movq (%0), %%mm0 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
649 "movq 8(%0), %%mm1 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
650 "movq 16(%0), %%mm2 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
651 "movq 24(%0), %%mm3 \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
652 TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
653 "movq %%mm0, (%0) \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
654 "movq %%mm3, 8(%0) \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
655 "movq %%mm4, 16(%0) \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
656 "movq %%mm2, 24(%0) \n\t" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
657 ::"r"(bS[0]) |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
658 :"memory" |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
659 ); |
47821be55b6c
mmx implementation of deblocking strength decision.
lorenm
parents:
3394
diff
changeset
|
660 } |
2754 | 661 |
662 /***********************************/ | |
663 /* motion compensation */ | |
664 | |
665 #define QPEL_H264V(A,B,C,D,E,F,OP)\ | |
2979 | 666 "movd (%0), "#F" \n\t"\ |
667 "movq "#C", %%mm6 \n\t"\ | |
668 "paddw "#D", %%mm6 \n\t"\ | |
669 "psllw $2, %%mm6 \n\t"\ | |
670 "psubw "#B", %%mm6 \n\t"\ | |
671 "psubw "#E", %%mm6 \n\t"\ | |
672 "pmullw %4, %%mm6 \n\t"\ | |
673 "add %2, %0 \n\t"\ | |
674 "punpcklbw %%mm7, "#F" \n\t"\ | |
675 "paddw %5, "#A" \n\t"\ | |
676 "paddw "#F", "#A" \n\t"\ | |
677 "paddw "#A", %%mm6 \n\t"\ | |
678 "psraw $5, %%mm6 \n\t"\ | |
679 "packuswb %%mm6, %%mm6 \n\t"\ | |
2754 | 680 OP(%%mm6, (%1), A, d)\ |
2979 | 681 "add %3, %1 \n\t" |
2754 | 682 |
683 #define QPEL_H264HV(A,B,C,D,E,F,OF)\ | |
2979 | 684 "movd (%0), "#F" \n\t"\ |
685 "movq "#C", %%mm6 \n\t"\ | |
686 "paddw "#D", %%mm6 \n\t"\ | |
687 "psllw $2, %%mm6 \n\t"\ | |
688 "psubw "#B", %%mm6 \n\t"\ | |
689 "psubw "#E", %%mm6 \n\t"\ | |
690 "pmullw %3, %%mm6 \n\t"\ | |
691 "add %2, %0 \n\t"\ | |
692 "punpcklbw %%mm7, "#F" \n\t"\ | |
693 "paddw "#F", "#A" \n\t"\ | |
694 "paddw "#A", %%mm6 \n\t"\ | |
695 "movq %%mm6, "#OF"(%1) \n\t" | |
2967 | 696 |
2754 | 697 #define QPEL_H264(OPNAME, OP, MMX)\ |
698 static void OPNAME ## h264_qpel4_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
699 int h=4;\ | |
700 \ | |
701 asm volatile(\ | |
2979 | 702 "pxor %%mm7, %%mm7 \n\t"\ |
703 "movq %5, %%mm4 \n\t"\ | |
704 "movq %6, %%mm5 \n\t"\ | |
705 "1: \n\t"\ | |
706 "movd -1(%0), %%mm1 \n\t"\ | |
707 "movd (%0), %%mm2 \n\t"\ | |
708 "movd 1(%0), %%mm3 \n\t"\ | |
709 "movd 2(%0), %%mm0 \n\t"\ | |
710 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
711 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
712 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
713 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
714 "paddw %%mm0, %%mm1 \n\t"\ | |
715 "paddw %%mm3, %%mm2 \n\t"\ | |
716 "movd -2(%0), %%mm0 \n\t"\ | |
717 "movd 3(%0), %%mm3 \n\t"\ | |
718 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
719 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
720 "paddw %%mm3, %%mm0 \n\t"\ | |
721 "psllw $2, %%mm2 \n\t"\ | |
722 "psubw %%mm1, %%mm2 \n\t"\ | |
723 "pmullw %%mm4, %%mm2 \n\t"\ | |
724 "paddw %%mm5, %%mm0 \n\t"\ | |
725 "paddw %%mm2, %%mm0 \n\t"\ | |
726 "psraw $5, %%mm0 \n\t"\ | |
727 "packuswb %%mm0, %%mm0 \n\t"\ | |
2754 | 728 OP(%%mm0, (%1),%%mm6, d)\ |
2979 | 729 "add %3, %0 \n\t"\ |
730 "add %4, %1 \n\t"\ | |
731 "decl %2 \n\t"\ | |
732 " jnz 1b \n\t"\ | |
2754 | 733 : "+a"(src), "+c"(dst), "+m"(h)\ |
734 : "d"((long)srcStride), "S"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
735 : "memory"\ | |
736 );\ | |
737 }\ | |
3156 | 738 static void OPNAME ## h264_qpel4_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ |
739 int h=4;\ | |
740 asm volatile(\ | |
741 "pxor %%mm7, %%mm7 \n\t"\ | |
3165 | 742 "movq %0, %%mm4 \n\t"\ |
743 "movq %1, %%mm5 \n\t"\ | |
744 :: "m"(ff_pw_5), "m"(ff_pw_16)\ | |
745 );\ | |
746 do{\ | |
747 asm volatile(\ | |
3156 | 748 "movd -1(%0), %%mm1 \n\t"\ |
749 "movd (%0), %%mm2 \n\t"\ | |
750 "movd 1(%0), %%mm3 \n\t"\ | |
751 "movd 2(%0), %%mm0 \n\t"\ | |
752 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
753 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
754 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
755 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
756 "paddw %%mm0, %%mm1 \n\t"\ | |
757 "paddw %%mm3, %%mm2 \n\t"\ | |
758 "movd -2(%0), %%mm0 \n\t"\ | |
759 "movd 3(%0), %%mm3 \n\t"\ | |
760 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
761 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
762 "paddw %%mm3, %%mm0 \n\t"\ | |
763 "psllw $2, %%mm2 \n\t"\ | |
764 "psubw %%mm1, %%mm2 \n\t"\ | |
765 "pmullw %%mm4, %%mm2 \n\t"\ | |
766 "paddw %%mm5, %%mm0 \n\t"\ | |
767 "paddw %%mm2, %%mm0 \n\t"\ | |
768 "movd (%2), %%mm3 \n\t"\ | |
769 "psraw $5, %%mm0 \n\t"\ | |
770 "packuswb %%mm0, %%mm0 \n\t"\ | |
771 PAVGB" %%mm3, %%mm0 \n\t"\ | |
772 OP(%%mm0, (%1),%%mm6, d)\ | |
3165 | 773 "add %4, %0 \n\t"\ |
774 "add %4, %1 \n\t"\ | |
775 "add %3, %2 \n\t"\ | |
776 : "+a"(src), "+c"(dst), "+d"(src2)\ | |
777 : "D"((long)src2Stride), "S"((long)dstStride)\ | |
3156 | 778 : "memory"\ |
779 );\ | |
3165 | 780 }while(--h);\ |
3156 | 781 }\ |
2754 | 782 static void OPNAME ## h264_qpel4_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ |
783 src -= 2*srcStride;\ | |
784 asm volatile(\ | |
2979 | 785 "pxor %%mm7, %%mm7 \n\t"\ |
786 "movd (%0), %%mm0 \n\t"\ | |
787 "add %2, %0 \n\t"\ | |
788 "movd (%0), %%mm1 \n\t"\ | |
789 "add %2, %0 \n\t"\ | |
790 "movd (%0), %%mm2 \n\t"\ | |
791 "add %2, %0 \n\t"\ | |
792 "movd (%0), %%mm3 \n\t"\ | |
793 "add %2, %0 \n\t"\ | |
794 "movd (%0), %%mm4 \n\t"\ | |
795 "add %2, %0 \n\t"\ | |
796 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
797 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
798 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
799 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
800 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
2754 | 801 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ |
802 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
803 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
804 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
805 \ | |
806 : "+a"(src), "+c"(dst)\ | |
807 : "S"((long)srcStride), "D"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
808 : "memory"\ | |
809 );\ | |
810 }\ | |
811 static void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | |
812 int h=4;\ | |
813 int w=3;\ | |
814 src -= 2*srcStride+2;\ | |
815 while(w--){\ | |
816 asm volatile(\ | |
2979 | 817 "pxor %%mm7, %%mm7 \n\t"\ |
818 "movd (%0), %%mm0 \n\t"\ | |
819 "add %2, %0 \n\t"\ | |
820 "movd (%0), %%mm1 \n\t"\ | |
821 "add %2, %0 \n\t"\ | |
822 "movd (%0), %%mm2 \n\t"\ | |
823 "add %2, %0 \n\t"\ | |
824 "movd (%0), %%mm3 \n\t"\ | |
825 "add %2, %0 \n\t"\ | |
826 "movd (%0), %%mm4 \n\t"\ | |
827 "add %2, %0 \n\t"\ | |
828 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
829 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
830 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
831 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
832 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
2754 | 833 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*8*3)\ |
834 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*8*3)\ | |
835 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*8*3)\ | |
836 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*8*3)\ | |
837 \ | |
838 : "+a"(src)\ | |
839 : "c"(tmp), "S"((long)srcStride), "m"(ff_pw_5)\ | |
840 : "memory"\ | |
841 );\ | |
842 tmp += 4;\ | |
843 src += 4 - 9*srcStride;\ | |
844 }\ | |
845 tmp -= 3*4;\ | |
846 asm volatile(\ | |
2979 | 847 "movq %4, %%mm6 \n\t"\ |
848 "1: \n\t"\ | |
849 "movq (%0), %%mm0 \n\t"\ | |
850 "paddw 10(%0), %%mm0 \n\t"\ | |
851 "movq 2(%0), %%mm1 \n\t"\ | |
852 "paddw 8(%0), %%mm1 \n\t"\ | |
853 "movq 4(%0), %%mm2 \n\t"\ | |
854 "paddw 6(%0), %%mm2 \n\t"\ | |
855 "psubw %%mm1, %%mm0 \n\t"/*a-b (abccba)*/\ | |
856 "psraw $2, %%mm0 \n\t"/*(a-b)/4 */\ | |
857 "psubw %%mm1, %%mm0 \n\t"/*(a-b)/4-b */\ | |
858 "paddsw %%mm2, %%mm0 \n\t"\ | |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
859 "psraw $2, %%mm0 \n\t"/*((a-b)/4-b+c)/4 */\ |
2979 | 860 "paddw %%mm6, %%mm2 \n\t"\ |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
861 "paddw %%mm2, %%mm0 \n\t"/*(a-5*b+20*c)/16 +32 */\ |
2979 | 862 "psraw $6, %%mm0 \n\t"\ |
863 "packuswb %%mm0, %%mm0 \n\t"\ | |
2754 | 864 OP(%%mm0, (%1),%%mm7, d)\ |
2979 | 865 "add $24, %0 \n\t"\ |
866 "add %3, %1 \n\t"\ | |
867 "decl %2 \n\t"\ | |
868 " jnz 1b \n\t"\ | |
2754 | 869 : "+a"(tmp), "+c"(dst), "+m"(h)\ |
870 : "S"((long)dstStride), "m"(ff_pw_32)\ | |
871 : "memory"\ | |
872 );\ | |
873 }\ | |
874 \ | |
875 static void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
876 int h=8;\ | |
877 asm volatile(\ | |
2979 | 878 "pxor %%mm7, %%mm7 \n\t"\ |
879 "movq %5, %%mm6 \n\t"\ | |
880 "1: \n\t"\ | |
881 "movq (%0), %%mm0 \n\t"\ | |
882 "movq 1(%0), %%mm2 \n\t"\ | |
883 "movq %%mm0, %%mm1 \n\t"\ | |
884 "movq %%mm2, %%mm3 \n\t"\ | |
885 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
886 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
887 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
888 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
889 "paddw %%mm2, %%mm0 \n\t"\ | |
890 "paddw %%mm3, %%mm1 \n\t"\ | |
891 "psllw $2, %%mm0 \n\t"\ | |
892 "psllw $2, %%mm1 \n\t"\ | |
893 "movq -1(%0), %%mm2 \n\t"\ | |
894 "movq 2(%0), %%mm4 \n\t"\ | |
895 "movq %%mm2, %%mm3 \n\t"\ | |
896 "movq %%mm4, %%mm5 \n\t"\ | |
897 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
898 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
899 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
900 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
901 "paddw %%mm4, %%mm2 \n\t"\ | |
902 "paddw %%mm3, %%mm5 \n\t"\ | |
903 "psubw %%mm2, %%mm0 \n\t"\ | |
904 "psubw %%mm5, %%mm1 \n\t"\ | |
905 "pmullw %%mm6, %%mm0 \n\t"\ | |
906 "pmullw %%mm6, %%mm1 \n\t"\ | |
907 "movd -2(%0), %%mm2 \n\t"\ | |
908 "movd 7(%0), %%mm5 \n\t"\ | |
909 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
910 "punpcklbw %%mm7, %%mm5 \n\t"\ | |
911 "paddw %%mm3, %%mm2 \n\t"\ | |
912 "paddw %%mm5, %%mm4 \n\t"\ | |
913 "movq %6, %%mm5 \n\t"\ | |
914 "paddw %%mm5, %%mm2 \n\t"\ | |
915 "paddw %%mm5, %%mm4 \n\t"\ | |
916 "paddw %%mm2, %%mm0 \n\t"\ | |
917 "paddw %%mm4, %%mm1 \n\t"\ | |
918 "psraw $5, %%mm0 \n\t"\ | |
919 "psraw $5, %%mm1 \n\t"\ | |
920 "packuswb %%mm1, %%mm0 \n\t"\ | |
2754 | 921 OP(%%mm0, (%1),%%mm5, q)\ |
2979 | 922 "add %3, %0 \n\t"\ |
923 "add %4, %1 \n\t"\ | |
924 "decl %2 \n\t"\ | |
925 " jnz 1b \n\t"\ | |
2754 | 926 : "+a"(src), "+c"(dst), "+m"(h)\ |
927 : "d"((long)srcStride), "S"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
928 : "memory"\ | |
929 );\ | |
930 }\ | |
931 \ | |
3156 | 932 static void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ |
933 int h=8;\ | |
934 asm volatile(\ | |
935 "pxor %%mm7, %%mm7 \n\t"\ | |
3165 | 936 "movq %0, %%mm6 \n\t"\ |
937 :: "m"(ff_pw_5)\ | |
938 );\ | |
939 do{\ | |
940 asm volatile(\ | |
3156 | 941 "movq (%0), %%mm0 \n\t"\ |
942 "movq 1(%0), %%mm2 \n\t"\ | |
943 "movq %%mm0, %%mm1 \n\t"\ | |
944 "movq %%mm2, %%mm3 \n\t"\ | |
945 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
946 "punpckhbw %%mm7, %%mm1 \n\t"\ | |
947 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
948 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
949 "paddw %%mm2, %%mm0 \n\t"\ | |
950 "paddw %%mm3, %%mm1 \n\t"\ | |
951 "psllw $2, %%mm0 \n\t"\ | |
952 "psllw $2, %%mm1 \n\t"\ | |
953 "movq -1(%0), %%mm2 \n\t"\ | |
954 "movq 2(%0), %%mm4 \n\t"\ | |
955 "movq %%mm2, %%mm3 \n\t"\ | |
956 "movq %%mm4, %%mm5 \n\t"\ | |
957 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
958 "punpckhbw %%mm7, %%mm3 \n\t"\ | |
959 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
960 "punpckhbw %%mm7, %%mm5 \n\t"\ | |
961 "paddw %%mm4, %%mm2 \n\t"\ | |
962 "paddw %%mm3, %%mm5 \n\t"\ | |
963 "psubw %%mm2, %%mm0 \n\t"\ | |
964 "psubw %%mm5, %%mm1 \n\t"\ | |
965 "pmullw %%mm6, %%mm0 \n\t"\ | |
966 "pmullw %%mm6, %%mm1 \n\t"\ | |
967 "movd -2(%0), %%mm2 \n\t"\ | |
968 "movd 7(%0), %%mm5 \n\t"\ | |
969 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
970 "punpcklbw %%mm7, %%mm5 \n\t"\ | |
971 "paddw %%mm3, %%mm2 \n\t"\ | |
972 "paddw %%mm5, %%mm4 \n\t"\ | |
3165 | 973 "movq %5, %%mm5 \n\t"\ |
3156 | 974 "paddw %%mm5, %%mm2 \n\t"\ |
975 "paddw %%mm5, %%mm4 \n\t"\ | |
976 "paddw %%mm2, %%mm0 \n\t"\ | |
977 "paddw %%mm4, %%mm1 \n\t"\ | |
978 "psraw $5, %%mm0 \n\t"\ | |
979 "psraw $5, %%mm1 \n\t"\ | |
980 "movq (%2), %%mm4 \n\t"\ | |
981 "packuswb %%mm1, %%mm0 \n\t"\ | |
982 PAVGB" %%mm4, %%mm0 \n\t"\ | |
983 OP(%%mm0, (%1),%%mm5, q)\ | |
3165 | 984 "add %4, %0 \n\t"\ |
985 "add %4, %1 \n\t"\ | |
986 "add %3, %2 \n\t"\ | |
987 : "+a"(src), "+c"(dst), "+d"(src2)\ | |
3156 | 988 : "D"((long)src2Stride), "S"((long)dstStride),\ |
3165 | 989 "m"(ff_pw_16)\ |
3156 | 990 : "memory"\ |
991 );\ | |
3165 | 992 }while(--h);\ |
3156 | 993 }\ |
994 \ | |
3094 | 995 static inline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ |
996 int w= 2;\ | |
2754 | 997 src -= 2*srcStride;\ |
998 \ | |
3094 | 999 while(w--){\ |
2754 | 1000 asm volatile(\ |
2979 | 1001 "pxor %%mm7, %%mm7 \n\t"\ |
1002 "movd (%0), %%mm0 \n\t"\ | |
1003 "add %2, %0 \n\t"\ | |
1004 "movd (%0), %%mm1 \n\t"\ | |
1005 "add %2, %0 \n\t"\ | |
1006 "movd (%0), %%mm2 \n\t"\ | |
1007 "add %2, %0 \n\t"\ | |
1008 "movd (%0), %%mm3 \n\t"\ | |
1009 "add %2, %0 \n\t"\ | |
1010 "movd (%0), %%mm4 \n\t"\ | |
1011 "add %2, %0 \n\t"\ | |
1012 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1013 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1014 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1015 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1016 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
2754 | 1017 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ |
1018 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1019 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1020 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1021 QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\ | |
1022 QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\ | |
1023 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
1024 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1025 \ | |
1026 : "+a"(src), "+c"(dst)\ | |
1027 : "S"((long)srcStride), "D"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1028 : "memory"\ | |
1029 );\ | |
3094 | 1030 if(h==16){\ |
1031 asm volatile(\ | |
1032 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1033 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1034 QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\ | |
1035 QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\ | |
1036 QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\ | |
1037 QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\ | |
1038 QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\ | |
1039 QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\ | |
1040 \ | |
1041 : "+a"(src), "+c"(dst)\ | |
1042 : "S"((long)srcStride), "D"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\ | |
1043 : "memory"\ | |
1044 );\ | |
1045 }\ | |
1046 src += 4-(h+5)*srcStride;\ | |
1047 dst += 4-h*dstStride;\ | |
2754 | 1048 }\ |
1049 }\ | |
3093 | 1050 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){\ |
1051 int h = size;\ | |
1052 int w = (size+8)>>2;\ | |
2754 | 1053 src -= 2*srcStride+2;\ |
1054 while(w--){\ | |
1055 asm volatile(\ | |
2979 | 1056 "pxor %%mm7, %%mm7 \n\t"\ |
1057 "movd (%0), %%mm0 \n\t"\ | |
1058 "add %2, %0 \n\t"\ | |
1059 "movd (%0), %%mm1 \n\t"\ | |
1060 "add %2, %0 \n\t"\ | |
1061 "movd (%0), %%mm2 \n\t"\ | |
1062 "add %2, %0 \n\t"\ | |
1063 "movd (%0), %%mm3 \n\t"\ | |
1064 "add %2, %0 \n\t"\ | |
1065 "movd (%0), %%mm4 \n\t"\ | |
1066 "add %2, %0 \n\t"\ | |
1067 "punpcklbw %%mm7, %%mm0 \n\t"\ | |
1068 "punpcklbw %%mm7, %%mm1 \n\t"\ | |
1069 "punpcklbw %%mm7, %%mm2 \n\t"\ | |
1070 "punpcklbw %%mm7, %%mm3 \n\t"\ | |
1071 "punpcklbw %%mm7, %%mm4 \n\t"\ | |
3093 | 1072 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*48)\ |
1073 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*48)\ | |
1074 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*48)\ | |
1075 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*48)\ | |
1076 QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 4*48)\ | |
1077 QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 5*48)\ | |
1078 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 6*48)\ | |
1079 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 7*48)\ | |
2754 | 1080 : "+a"(src)\ |
1081 : "c"(tmp), "S"((long)srcStride), "m"(ff_pw_5)\ | |
1082 : "memory"\ | |
1083 );\ | |
3093 | 1084 if(size==16){\ |
1085 asm volatile(\ | |
1086 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 8*48)\ | |
1087 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 9*48)\ | |
1088 QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 10*48)\ | |
1089 QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 11*48)\ | |
1090 QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 12*48)\ | |
1091 QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 13*48)\ | |
1092 QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 14*48)\ | |
1093 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\ | |
1094 : "+a"(src)\ | |
1095 : "c"(tmp), "S"((long)srcStride), "m"(ff_pw_5)\ | |
1096 : "memory"\ | |
1097 );\ | |
1098 }\ | |
2754 | 1099 tmp += 4;\ |
3093 | 1100 src += 4 - (size+5)*srcStride;\ |
2754 | 1101 }\ |
3093 | 1102 tmp -= size+8;\ |
1103 w = size>>4;\ | |
1104 do{\ | |
1105 h = size;\ | |
2754 | 1106 asm volatile(\ |
2979 | 1107 "movq %4, %%mm6 \n\t"\ |
1108 "1: \n\t"\ | |
1109 "movq (%0), %%mm0 \n\t"\ | |
1110 "movq 8(%0), %%mm3 \n\t"\ | |
1111 "movq 2(%0), %%mm1 \n\t"\ | |
1112 "movq 10(%0), %%mm4 \n\t"\ | |
1113 "paddw %%mm4, %%mm0 \n\t"\ | |
1114 "paddw %%mm3, %%mm1 \n\t"\ | |
1115 "paddw 18(%0), %%mm3 \n\t"\ | |
1116 "paddw 16(%0), %%mm4 \n\t"\ | |
1117 "movq 4(%0), %%mm2 \n\t"\ | |
1118 "movq 12(%0), %%mm5 \n\t"\ | |
1119 "paddw 6(%0), %%mm2 \n\t"\ | |
1120 "paddw 14(%0), %%mm5 \n\t"\ | |
1121 "psubw %%mm1, %%mm0 \n\t"\ | |
1122 "psubw %%mm4, %%mm3 \n\t"\ | |
1123 "psraw $2, %%mm0 \n\t"\ | |
1124 "psraw $2, %%mm3 \n\t"\ | |
1125 "psubw %%mm1, %%mm0 \n\t"\ | |
1126 "psubw %%mm4, %%mm3 \n\t"\ | |
1127 "paddsw %%mm2, %%mm0 \n\t"\ | |
1128 "paddsw %%mm5, %%mm3 \n\t"\ | |
1129 "psraw $2, %%mm0 \n\t"\ | |
1130 "psraw $2, %%mm3 \n\t"\ | |
1131 "paddw %%mm6, %%mm2 \n\t"\ | |
1132 "paddw %%mm6, %%mm5 \n\t"\ | |
1133 "paddw %%mm2, %%mm0 \n\t"\ | |
1134 "paddw %%mm5, %%mm3 \n\t"\ | |
1135 "psraw $6, %%mm0 \n\t"\ | |
1136 "psraw $6, %%mm3 \n\t"\ | |
1137 "packuswb %%mm3, %%mm0 \n\t"\ | |
2754 | 1138 OP(%%mm0, (%1),%%mm7, q)\ |
3093 | 1139 "add $48, %0 \n\t"\ |
2979 | 1140 "add %3, %1 \n\t"\ |
1141 "decl %2 \n\t"\ | |
1142 " jnz 1b \n\t"\ | |
2754 | 1143 : "+a"(tmp), "+c"(dst), "+m"(h)\ |
1144 : "S"((long)dstStride), "m"(ff_pw_32)\ | |
1145 : "memory"\ | |
1146 );\ | |
3093 | 1147 tmp += 8 - size*24;\ |
1148 dst += 8 - size*dstStride;\ | |
1149 }while(w--);\ | |
2754 | 1150 }\ |
3094 | 1151 \ |
1152 static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1153 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\ | |
1154 }\ | |
2754 | 1155 static void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ |
3094 | 1156 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\ |
1157 OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\ | |
2754 | 1158 }\ |
1159 \ | |
1160 static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | |
1161 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\ | |
1162 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
1163 src += 8*srcStride;\ | |
1164 dst += 8*dstStride;\ | |
1165 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\ | |
1166 OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\ | |
1167 }\ | |
1168 \ | |
3156 | 1169 static void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\ |
1170 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\ | |
1171 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\ | |
1172 src += 8*dstStride;\ | |
1173 dst += 8*dstStride;\ | |
1174 src2 += 8*src2Stride;\ | |
1175 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\ | |
1176 OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\ | |
1177 }\ | |
1178 \ | |
3093 | 1179 static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ |
1180 OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 8);\ | |
1181 }\ | |
1182 \ | |
2754 | 1183 static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ |
3093 | 1184 OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\ |
2754 | 1185 }\ |
3095 | 1186 \ |
1187 static void OPNAME ## pixels4_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1188 {\ | |
1189 asm volatile(\ | |
1190 "movq %5, %%mm6 \n\t"\ | |
1191 "movq (%1), %%mm0 \n\t"\ | |
1192 "movq 24(%1), %%mm1 \n\t"\ | |
1193 "paddw %%mm6, %%mm0 \n\t"\ | |
1194 "paddw %%mm6, %%mm1 \n\t"\ | |
3102 | 1195 "psraw $5, %%mm0 \n\t"\ |
1196 "psraw $5, %%mm1 \n\t"\ | |
3163 | 1197 "packuswb %%mm0, %%mm0 \n\t"\ |
1198 "packuswb %%mm1, %%mm1 \n\t"\ | |
3095 | 1199 PAVGB" (%0), %%mm0 \n\t"\ |
1200 PAVGB" (%0,%3), %%mm1 \n\t"\ | |
1201 OP(%%mm0, (%2), %%mm4, d)\ | |
1202 OP(%%mm1, (%2,%4), %%mm5, d)\ | |
1203 "lea (%0,%3,2), %0 \n\t"\ | |
1204 "lea (%2,%4,2), %2 \n\t"\ | |
1205 "movq 48(%1), %%mm0 \n\t"\ | |
1206 "movq 72(%1), %%mm1 \n\t"\ | |
1207 "paddw %%mm6, %%mm0 \n\t"\ | |
1208 "paddw %%mm6, %%mm1 \n\t"\ | |
3102 | 1209 "psraw $5, %%mm0 \n\t"\ |
1210 "psraw $5, %%mm1 \n\t"\ | |
3163 | 1211 "packuswb %%mm0, %%mm0 \n\t"\ |
1212 "packuswb %%mm1, %%mm1 \n\t"\ | |
3095 | 1213 PAVGB" (%0), %%mm0 \n\t"\ |
1214 PAVGB" (%0,%3), %%mm1 \n\t"\ | |
1215 OP(%%mm0, (%2), %%mm4, d)\ | |
1216 OP(%%mm1, (%2,%4), %%mm5, d)\ | |
1217 :"+a"(src8), "+c"(src16), "+d"(dst)\ | |
3096 | 1218 :"S"((long)src8Stride), "D"((long)dstStride), "m"(ff_pw_16)\ |
3095 | 1219 :"memory");\ |
1220 }\ | |
1221 static void OPNAME ## pixels8_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1222 {\ | |
1223 asm volatile(\ | |
1224 "movq %0, %%mm6 \n\t"\ | |
1225 ::"m"(ff_pw_16)\ | |
1226 );\ | |
1227 while(h--){\ | |
1228 asm volatile(\ | |
1229 "movq (%1), %%mm0 \n\t"\ | |
1230 "movq 8(%1), %%mm1 \n\t"\ | |
1231 "paddw %%mm6, %%mm0 \n\t"\ | |
1232 "paddw %%mm6, %%mm1 \n\t"\ | |
3102 | 1233 "psraw $5, %%mm0 \n\t"\ |
1234 "psraw $5, %%mm1 \n\t"\ | |
3095 | 1235 "packuswb %%mm1, %%mm0 \n\t"\ |
1236 PAVGB" (%0), %%mm0 \n\t"\ | |
1237 OP(%%mm0, (%2), %%mm5, q)\ | |
1238 ::"a"(src8), "c"(src16), "d"(dst)\ | |
1239 :"memory");\ | |
1240 src8 += src8Stride;\ | |
1241 src16 += 24;\ | |
1242 dst += dstStride;\ | |
1243 }\ | |
1244 }\ | |
1245 static void OPNAME ## pixels16_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\ | |
1246 {\ | |
1247 OPNAME ## pixels8_l2_shift5_ ## MMX(dst , src16 , src8 , dstStride, src8Stride, h);\ | |
1248 OPNAME ## pixels8_l2_shift5_ ## MMX(dst+8, src16+8, src8+8, dstStride, src8Stride, h);\ | |
1249 }\ | |
1250 | |
2754 | 1251 |
1252 #define H264_MC(OPNAME, SIZE, MMX) \ | |
1253 static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\ | |
1254 OPNAME ## pixels ## SIZE ## _mmx(dst, src, stride, SIZE);\ | |
1255 }\ | |
1256 \ | |
1257 static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1258 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\ |
2754 | 1259 }\ |
1260 \ | |
1261 static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1262 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\ | |
1263 }\ | |
1264 \ | |
1265 static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1266 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\ |
2754 | 1267 }\ |
1268 \ | |
1269 static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1270 uint64_t temp[SIZE*SIZE/8];\ | |
1271 uint8_t * const half= (uint8_t*)temp;\ | |
1272 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(half, src, SIZE, stride);\ | |
1273 OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, half, stride, stride, SIZE);\ | |
1274 }\ | |
1275 \ | |
1276 static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1277 OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\ | |
1278 }\ | |
1279 \ | |
1280 static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
1281 uint64_t temp[SIZE*SIZE/8];\ | |
1282 uint8_t * const half= (uint8_t*)temp;\ | |
1283 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(half, src, SIZE, stride);\ | |
1284 OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, half, stride, stride, SIZE);\ | |
1285 }\ | |
1286 \ | |
1287 static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1288 uint64_t temp[SIZE*SIZE/8];\ |
1289 uint8_t * const halfV= (uint8_t*)temp;\ | |
2754 | 1290 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\ |
3156 | 1291 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfV, stride, SIZE);\ |
2754 | 1292 }\ |
1293 \ | |
1294 static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1295 uint64_t temp[SIZE*SIZE/8];\ |
1296 uint8_t * const halfV= (uint8_t*)temp;\ | |
2754 | 1297 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\ |
3156 | 1298 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfV, stride, SIZE);\ |
2754 | 1299 }\ |
1300 \ | |
1301 static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1302 uint64_t temp[SIZE*SIZE/8];\ |
1303 uint8_t * const halfV= (uint8_t*)temp;\ | |
2754 | 1304 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\ |
3156 | 1305 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfV, stride, SIZE);\ |
2754 | 1306 }\ |
1307 \ | |
1308 static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1309 uint64_t temp[SIZE*SIZE/8];\ |
1310 uint8_t * const halfV= (uint8_t*)temp;\ | |
2754 | 1311 put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\ |
3156 | 1312 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfV, stride, SIZE);\ |
2754 | 1313 }\ |
1314 \ | |
1315 static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3093 | 1316 uint64_t temp[SIZE*(SIZE<8?12:24)/4];\ |
2754 | 1317 int16_t * const tmp= (int16_t*)temp;\ |
1318 OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, tmp, src, stride, SIZE, stride);\ | |
1319 }\ | |
1320 \ | |
1321 static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1322 uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\ |
1323 uint8_t * const halfHV= (uint8_t*)temp;\ | |
1324 int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE/2;\ | |
2754 | 1325 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\ |
3156 | 1326 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\ |
2754 | 1327 }\ |
1328 \ | |
1329 static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3156 | 1330 uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\ |
1331 uint8_t * const halfHV= (uint8_t*)temp;\ | |
1332 int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE/2;\ | |
2754 | 1333 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\ |
3156 | 1334 OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\ |
2754 | 1335 }\ |
1336 \ | |
1337 static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3095 | 1338 uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\ |
1339 int16_t * const halfV= ((int16_t*)temp) + SIZE*SIZE/2;\ | |
1340 uint8_t * const halfHV= ((uint8_t*)temp);\ | |
1341 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\ | |
1342 OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+2, halfHV, stride, SIZE, SIZE);\ | |
2754 | 1343 }\ |
1344 \ | |
1345 static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\ | |
3095 | 1346 uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\ |
1347 int16_t * const halfV= ((int16_t*)temp) + SIZE*SIZE/2;\ | |
1348 uint8_t * const halfHV= ((uint8_t*)temp);\ | |
1349 put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\ | |
1350 OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+3, halfHV, stride, SIZE, SIZE);\ | |
2754 | 1351 }\ |
1352 | |
1353 | |
1354 #define AVG_3DNOW_OP(a,b,temp, size) \ | |
2979 | 1355 "mov" #size " " #b ", " #temp " \n\t"\ |
1356 "pavgusb " #temp ", " #a " \n\t"\ | |
1357 "mov" #size " " #a ", " #b " \n\t" | |
2754 | 1358 #define AVG_MMX2_OP(a,b,temp, size) \ |
2979 | 1359 "mov" #size " " #b ", " #temp " \n\t"\ |
1360 "pavgb " #temp ", " #a " \n\t"\ | |
1361 "mov" #size " " #a ", " #b " \n\t" | |
2754 | 1362 |
3095 | 1363 #define PAVGB "pavgusb" |
2754 | 1364 QPEL_H264(put_, PUT_OP, 3dnow) |
1365 QPEL_H264(avg_, AVG_3DNOW_OP, 3dnow) | |
3095 | 1366 #undef PAVGB |
1367 #define PAVGB "pavgb" | |
2754 | 1368 QPEL_H264(put_, PUT_OP, mmx2) |
1369 QPEL_H264(avg_, AVG_MMX2_OP, mmx2) | |
3095 | 1370 #undef PAVGB |
2754 | 1371 |
1372 H264_MC(put_, 4, 3dnow) | |
1373 H264_MC(put_, 8, 3dnow) | |
1374 H264_MC(put_, 16,3dnow) | |
1375 H264_MC(avg_, 4, 3dnow) | |
1376 H264_MC(avg_, 8, 3dnow) | |
1377 H264_MC(avg_, 16,3dnow) | |
1378 H264_MC(put_, 4, mmx2) | |
1379 H264_MC(put_, 8, mmx2) | |
1380 H264_MC(put_, 16,mmx2) | |
1381 H264_MC(avg_, 4, mmx2) | |
1382 H264_MC(avg_, 8, mmx2) | |
1383 H264_MC(avg_, 16,mmx2) | |
1384 | |
1385 | |
1386 #define H264_CHROMA_OP(S,D) | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1387 #define H264_CHROMA_OP4(S,D,T) |
2754 | 1388 #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
|
1389 #define H264_CHROMA_MC4_TMPL put_h264_chroma_mc4_mmx |
3213 | 1390 #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
|
1391 #define H264_CHROMA_MC8_MV0 put_pixels8_mmx |
2754 | 1392 #include "dsputil_h264_template_mmx.c" |
1393 #undef H264_CHROMA_OP | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1394 #undef H264_CHROMA_OP4 |
2754 | 1395 #undef H264_CHROMA_MC8_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1396 #undef H264_CHROMA_MC4_TMPL |
3213 | 1397 #undef H264_CHROMA_MC2_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1398 #undef H264_CHROMA_MC8_MV0 |
2754 | 1399 |
1400 #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
|
1401 #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
|
1402 "pavgb " #T ", " #D " \n\t" |
2754 | 1403 #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
|
1404 #define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_mmx2 |
3213 | 1405 #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
|
1406 #define H264_CHROMA_MC8_MV0 avg_pixels8_mmx2 |
2754 | 1407 #include "dsputil_h264_template_mmx.c" |
1408 #undef H264_CHROMA_OP | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1409 #undef H264_CHROMA_OP4 |
2754 | 1410 #undef H264_CHROMA_MC8_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1411 #undef H264_CHROMA_MC4_TMPL |
3213 | 1412 #undef H264_CHROMA_MC2_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1413 #undef H264_CHROMA_MC8_MV0 |
2754 | 1414 |
1415 #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
|
1416 #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
|
1417 "pavgusb " #T ", " #D " \n\t" |
2754 | 1418 #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
|
1419 #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
|
1420 #define H264_CHROMA_MC8_MV0 avg_pixels8_3dnow |
2754 | 1421 #include "dsputil_h264_template_mmx.c" |
1422 #undef H264_CHROMA_OP | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1423 #undef H264_CHROMA_OP4 |
2754 | 1424 #undef H264_CHROMA_MC8_TMPL |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1425 #undef H264_CHROMA_MC4_TMPL |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2902
diff
changeset
|
1426 #undef H264_CHROMA_MC8_MV0 |
2754 | 1427 |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1428 /***********************************/ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1429 /* weighted prediction */ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1430 |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1431 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
|
1432 { |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1433 int x, y; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1434 offset <<= log2_denom; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1435 offset += (1 << log2_denom) >> 1; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1436 asm volatile( |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1437 "movd %0, %%mm4 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1438 "movd %1, %%mm5 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1439 "movd %2, %%mm6 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1440 "pshufw $0, %%mm4, %%mm4 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1441 "pshufw $0, %%mm5, %%mm5 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1442 "pxor %%mm7, %%mm7 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1443 :: "g"(weight), "g"(offset), "g"(log2_denom) |
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 for(y=0; y<h; y+=2){ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1446 for(x=0; x<w; x+=4){ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1447 asm volatile( |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1448 "movd %0, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1449 "movd %1, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1450 "punpcklbw %%mm7, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1451 "punpcklbw %%mm7, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1452 "pmullw %%mm4, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1453 "pmullw %%mm4, %%mm1 \n\t" |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
1454 "paddsw %%mm5, %%mm0 \n\t" |
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
1455 "paddsw %%mm5, %%mm1 \n\t" |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1456 "psraw %%mm6, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1457 "psraw %%mm6, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1458 "packuswb %%mm7, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1459 "packuswb %%mm7, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1460 "movd %%mm0, %0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1461 "movd %%mm1, %1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1462 : "+m"(*(uint32_t*)(dst+x)), |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1463 "+m"(*(uint32_t*)(dst+x+stride)) |
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 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1466 dst += 2*stride; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1467 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1468 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1469 |
3029 | 1470 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
|
1471 { |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1472 int x, y; |
3029 | 1473 offset = ((offset + 1) | 1) << log2_denom; |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1474 asm volatile( |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1475 "movd %0, %%mm3 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1476 "movd %1, %%mm4 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1477 "movd %2, %%mm5 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1478 "movd %3, %%mm6 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1479 "pshufw $0, %%mm3, %%mm3 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1480 "pshufw $0, %%mm4, %%mm4 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1481 "pshufw $0, %%mm5, %%mm5 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1482 "pxor %%mm7, %%mm7 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1483 :: "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
|
1484 ); |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1485 for(y=0; y<h; y++){ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1486 for(x=0; x<w; x+=4){ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1487 asm volatile( |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1488 "movd %0, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1489 "movd %1, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1490 "punpcklbw %%mm7, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1491 "punpcklbw %%mm7, %%mm1 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1492 "pmullw %%mm3, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1493 "pmullw %%mm4, %%mm1 \n\t" |
3001
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
1494 "paddsw %%mm1, %%mm0 \n\t" |
b52d8ee430f6
fix some potential arithmetic overflows in pred_direct_motion() and
lorenm
parents:
2979
diff
changeset
|
1495 "paddsw %%mm5, %%mm0 \n\t" |
2902
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1496 "psraw %%mm6, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1497 "packuswb %%mm0, %%mm0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1498 "movd %%mm0, %0 \n\t" |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1499 : "+m"(*(uint32_t*)(dst+x)) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1500 : "m"(*(uint32_t*)(src+x)) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1501 ); |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1502 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1503 src += stride; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1504 dst += stride; |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1505 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1506 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1507 |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1508 #define H264_WEIGHT(W,H) \ |
3029 | 1509 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){ \ |
1510 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
|
1511 } \ |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1512 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
|
1513 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
|
1514 } |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1515 |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1516 H264_WEIGHT(16,16) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1517 H264_WEIGHT(16, 8) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1518 H264_WEIGHT( 8,16) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1519 H264_WEIGHT( 8, 8) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1520 H264_WEIGHT( 8, 4) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1521 H264_WEIGHT( 4, 8) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1522 H264_WEIGHT( 4, 4) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1523 H264_WEIGHT( 4, 2) |
3c79bc9f3aa9
h264 mmx weighted prediction. up to 3% overall speedup.
lorenm
parents:
2855
diff
changeset
|
1524 |