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