Mercurial > libavcodec.hg
annotate i386/dsputil_h264_template_mmx.c @ 3711:4a5536551692 libavcodec
Swap back and forward motion vectors to achieve correct picture
author | kostya |
---|---|
date | Tue, 12 Sep 2006 04:35:11 +0000 |
parents | b2ffd9fb4153 |
children | c8c591fe26f8 |
rev | line source |
---|---|
2732 | 1 /* |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
2 * Copyright (c) 2005 Zoltan Hidvegi <hzoli -a- hzoli -d- com>, |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
3 * Loren Merritt |
2732 | 4 * |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2922
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2732 | 18 */ |
19 | |
20 /** | |
21 * MMX optimized version of (put|avg)_h264_chroma_mc8. | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
22 * H264_CHROMA_MC8_TMPL must be defined to the desired function name |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
23 * H264_CHROMA_OP must be defined to empty for put and pavgb/pavgusb for avg |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
24 * H264_CHROMA_MC8_MV0 must be defined to a (put|avg)_pixels8 function |
2732 | 25 */ |
26 static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) | |
27 { | |
3089 | 28 DECLARE_ALIGNED_8(uint64_t, AA); |
29 DECLARE_ALIGNED_8(uint64_t, DD); | |
2732 | 30 int i; |
31 | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
32 if(y==0 && x==0) { |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
33 /* no filter needed */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
34 H264_CHROMA_MC8_MV0(dst, src, stride, h); |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
35 return; |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
36 } |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
37 |
2732 | 38 assert(x<8 && y<8 && x>=0 && y>=0); |
39 | |
3218 | 40 if(y==0 || x==0) |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
41 { |
3218 | 42 /* 1 dimensional filter only */ |
43 const int dxy = x ? 1 : stride; | |
44 | |
45 asm volatile( | |
46 "movd %0, %%mm5\n\t" | |
47 "movq %1, %%mm4\n\t" | |
48 "punpcklwd %%mm5, %%mm5\n\t" | |
49 "punpckldq %%mm5, %%mm5\n\t" /* mm5 = B = x */ | |
50 "movq %%mm4, %%mm6\n\t" | |
51 "pxor %%mm7, %%mm7\n\t" | |
52 "psubw %%mm5, %%mm4\n\t" /* mm4 = A = 8-x */ | |
53 "psrlw $1, %%mm6\n\t" /* mm6 = 4 */ | |
54 :: "rm"(x+y), "m"(ff_pw_8)); | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
55 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
56 for(i=0; i<h; i++) { |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
57 asm volatile( |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
58 /* mm0 = src[0..7], mm1 = src[1..8] */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
59 "movq %0, %%mm0\n\t" |
3218 | 60 "movq %1, %%mm2\n\t" |
61 :: "m"(src[0]), "m"(src[dxy])); | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
62 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
63 asm volatile( |
3218 | 64 /* [mm0,mm1] = A * src[0..7] */ |
65 /* [mm2,mm3] = B * src[1..8] */ | |
66 "movq %%mm0, %%mm1\n\t" | |
67 "movq %%mm2, %%mm3\n\t" | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
68 "punpcklbw %%mm7, %%mm0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
69 "punpckhbw %%mm7, %%mm1\n\t" |
3218 | 70 "punpcklbw %%mm7, %%mm2\n\t" |
71 "punpckhbw %%mm7, %%mm3\n\t" | |
72 "pmullw %%mm4, %%mm0\n\t" | |
73 "pmullw %%mm4, %%mm1\n\t" | |
74 "pmullw %%mm5, %%mm2\n\t" | |
75 "pmullw %%mm5, %%mm3\n\t" | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
76 |
3218 | 77 /* dst[0..7] = (A * src[0..7] + B * src[1..8] + 4) >> 3 */ |
78 "paddw %%mm6, %%mm0\n\t" | |
79 "paddw %%mm6, %%mm1\n\t" | |
80 "paddw %%mm2, %%mm0\n\t" | |
81 "paddw %%mm3, %%mm1\n\t" | |
82 "psrlw $3, %%mm0\n\t" | |
83 "psrlw $3, %%mm1\n\t" | |
84 "packuswb %%mm1, %%mm0\n\t" | |
85 H264_CHROMA_OP(%0, %%mm0) | |
86 "movq %%mm0, %0\n\t" | |
87 : "=m" (dst[0])); | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
88 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
89 src += stride; |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
90 dst += stride; |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
91 } |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
92 return; |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
93 } |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
94 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
95 /* general case, bilinear */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
96 asm volatile("movd %2, %%mm4\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
97 "movd %3, %%mm6\n\t" |
2732 | 98 "punpcklwd %%mm4, %%mm4\n\t" |
99 "punpcklwd %%mm6, %%mm6\n\t" | |
100 "punpckldq %%mm4, %%mm4\n\t" /* mm4 = x words */ | |
101 "punpckldq %%mm6, %%mm6\n\t" /* mm6 = y words */ | |
102 "movq %%mm4, %%mm5\n\t" | |
103 "pmullw %%mm6, %%mm4\n\t" /* mm4 = x * y */ | |
104 "psllw $3, %%mm5\n\t" | |
105 "psllw $3, %%mm6\n\t" | |
106 "movq %%mm5, %%mm7\n\t" | |
107 "paddw %%mm6, %%mm7\n\t" | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
108 "movq %%mm4, %1\n\t" /* DD = x * y */ |
2732 | 109 "psubw %%mm4, %%mm5\n\t" /* mm5 = B = 8x - xy */ |
110 "psubw %%mm4, %%mm6\n\t" /* mm6 = C = 8y - xy */ | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
111 "paddw %4, %%mm4\n\t" |
2732 | 112 "psubw %%mm7, %%mm4\n\t" /* mm4 = A = xy - (8x+8y) + 64 */ |
113 "pxor %%mm7, %%mm7\n\t" | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
114 "movq %%mm4, %0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
115 : "=m" (AA), "=m" (DD) : "rm" (x), "rm" (y), "m" (ff_pw_64)); |
2732 | 116 |
117 asm volatile( | |
118 /* mm0 = src[0..7], mm1 = src[1..8] */ | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
119 "movq %0, %%mm0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
120 "movq %1, %%mm1\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
121 : : "m" (src[0]), "m" (src[1])); |
2732 | 122 |
123 for(i=0; i<h; i++) { | |
3218 | 124 src += stride; |
2732 | 125 |
3218 | 126 asm volatile( |
127 /* mm2 = A * src[0..3] + B * src[1..4] */ | |
128 /* mm3 = A * src[4..7] + B * src[5..8] */ | |
129 "movq %%mm0, %%mm2\n\t" | |
130 "movq %%mm1, %%mm3\n\t" | |
131 "punpckhbw %%mm7, %%mm0\n\t" | |
132 "punpcklbw %%mm7, %%mm1\n\t" | |
133 "punpcklbw %%mm7, %%mm2\n\t" | |
134 "punpckhbw %%mm7, %%mm3\n\t" | |
135 "pmullw %0, %%mm0\n\t" | |
136 "pmullw %0, %%mm2\n\t" | |
2732 | 137 "pmullw %%mm5, %%mm1\n\t" |
3218 | 138 "pmullw %%mm5, %%mm3\n\t" |
139 "paddw %%mm1, %%mm2\n\t" | |
140 "paddw %%mm0, %%mm3\n\t" | |
2732 | 141 : : "m" (AA)); |
142 | |
143 asm volatile( | |
3218 | 144 /* [mm2,mm3] += C * src[0..7] */ |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
145 "movq %0, %%mm0\n\t" |
3218 | 146 "movq %%mm0, %%mm1\n\t" |
147 "punpcklbw %%mm7, %%mm0\n\t" | |
148 "punpckhbw %%mm7, %%mm1\n\t" | |
149 "pmullw %%mm6, %%mm0\n\t" | |
150 "pmullw %%mm6, %%mm1\n\t" | |
151 "paddw %%mm0, %%mm2\n\t" | |
152 "paddw %%mm1, %%mm3\n\t" | |
153 : : "m" (src[0])); | |
2732 | 154 |
155 asm volatile( | |
3218 | 156 /* [mm2,mm3] += D * src[1..8] */ |
157 "movq %1, %%mm1\n\t" | |
158 "movq %%mm1, %%mm0\n\t" | |
159 "movq %%mm1, %%mm4\n\t" | |
160 "punpcklbw %%mm7, %%mm0\n\t" | |
161 "punpckhbw %%mm7, %%mm4\n\t" | |
162 "pmullw %2, %%mm0\n\t" | |
163 "pmullw %2, %%mm4\n\t" | |
164 "paddw %%mm0, %%mm2\n\t" | |
165 "paddw %%mm4, %%mm3\n\t" | |
166 "movq %0, %%mm0\n\t" | |
167 : : "m" (src[0]), "m" (src[1]), "m" (DD)); | |
2732 | 168 |
169 asm volatile( | |
3218 | 170 /* dst[0..7] = ([mm2,mm3] + 32) >> 6 */ |
2732 | 171 "paddw %1, %%mm2\n\t" |
172 "paddw %1, %%mm3\n\t" | |
173 "psrlw $6, %%mm2\n\t" | |
174 "psrlw $6, %%mm3\n\t" | |
175 "packuswb %%mm3, %%mm2\n\t" | |
176 H264_CHROMA_OP(%0, %%mm2) | |
177 "movq %%mm2, %0\n\t" | |
2754 | 178 : "=m" (dst[0]) : "m" (ff_pw_32)); |
2732 | 179 dst+= stride; |
180 } | |
181 } | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
182 |
3213 | 183 static void H264_CHROMA_MC4_TMPL(uint8_t *dst/*align 4*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
184 { |
3089 | 185 DECLARE_ALIGNED_8(uint64_t, AA); |
186 DECLARE_ALIGNED_8(uint64_t, DD); | |
2922
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
187 int i; |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
188 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
189 /* no special case for mv=(0,0) in 4x*, since it's much less common than in 8x*. |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
190 * could still save a few cycles, but maybe not worth the complexity. */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
191 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
192 assert(x<8 && y<8 && x>=0 && y>=0); |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
193 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
194 asm volatile("movd %2, %%mm4\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
195 "movd %3, %%mm6\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
196 "punpcklwd %%mm4, %%mm4\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
197 "punpcklwd %%mm6, %%mm6\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
198 "punpckldq %%mm4, %%mm4\n\t" /* mm4 = x words */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
199 "punpckldq %%mm6, %%mm6\n\t" /* mm6 = y words */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
200 "movq %%mm4, %%mm5\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
201 "pmullw %%mm6, %%mm4\n\t" /* mm4 = x * y */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
202 "psllw $3, %%mm5\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
203 "psllw $3, %%mm6\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
204 "movq %%mm5, %%mm7\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
205 "paddw %%mm6, %%mm7\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
206 "movq %%mm4, %1\n\t" /* DD = x * y */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
207 "psubw %%mm4, %%mm5\n\t" /* mm5 = B = 8x - xy */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
208 "psubw %%mm4, %%mm6\n\t" /* mm6 = C = 8y - xy */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
209 "paddw %4, %%mm4\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
210 "psubw %%mm7, %%mm4\n\t" /* mm4 = A = xy - (8x+8y) + 64 */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
211 "pxor %%mm7, %%mm7\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
212 "movq %%mm4, %0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
213 : "=m" (AA), "=m" (DD) : "rm" (x), "rm" (y), "m" (ff_pw_64)); |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
214 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
215 asm volatile( |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
216 /* mm0 = src[0..3], mm1 = src[1..4] */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
217 "movd %0, %%mm0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
218 "movd %1, %%mm1\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
219 "punpcklbw %%mm7, %%mm0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
220 "punpcklbw %%mm7, %%mm1\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
221 : : "m" (src[0]), "m" (src[1])); |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
222 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
223 for(i=0; i<h; i++) { |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
224 asm volatile( |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
225 /* mm2 = A * src[0..3] + B * src[1..4] */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
226 "movq %%mm0, %%mm2\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
227 "pmullw %0, %%mm2\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
228 "pmullw %%mm5, %%mm1\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
229 "paddw %%mm1, %%mm2\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
230 : : "m" (AA)); |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
231 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
232 src += stride; |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
233 asm volatile( |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
234 /* mm0 = src[0..3], mm1 = src[1..4] */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
235 "movd %0, %%mm0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
236 "movd %1, %%mm1\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
237 "punpcklbw %%mm7, %%mm0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
238 "punpcklbw %%mm7, %%mm1\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
239 : : "m" (src[0]), "m" (src[1])); |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
240 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
241 asm volatile( |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
242 /* mm2 += C * src[0..3] + D * src[1..4] */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
243 "movq %%mm0, %%mm3\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
244 "movq %%mm1, %%mm4\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
245 "pmullw %%mm6, %%mm3\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
246 "pmullw %0, %%mm4\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
247 "paddw %%mm3, %%mm2\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
248 "paddw %%mm4, %%mm2\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
249 : : "m" (DD)); |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
250 |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
251 asm volatile( |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
252 /* dst[0..3] = pack((mm2 + 32) >> 6) */ |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
253 "paddw %1, %%mm2\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
254 "psrlw $6, %%mm2\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
255 "packuswb %%mm7, %%mm2\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
256 H264_CHROMA_OP4(%0, %%mm2, %%mm3) |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
257 "movd %%mm2, %0\n\t" |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
258 : "=m" (dst[0]) : "m" (ff_pw_32)); |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
259 dst += stride; |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
260 } |
d772011258ec
faster h264_chroma_mc8_mmx, added h264_chroma_mc4_mmx.
lorenm
parents:
2754
diff
changeset
|
261 } |
3213 | 262 |
263 #ifdef H264_CHROMA_MC2_TMPL | |
264 static void H264_CHROMA_MC2_TMPL(uint8_t *dst/*align 2*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y) | |
265 { | |
266 int CD=((1<<16)-1)*x*y + 8*y; | |
267 int AB=((8<<16)-8)*x + 64 - CD; | |
268 int i; | |
269 | |
270 asm volatile( | |
271 /* mm5 = {A,B,A,B} */ | |
272 /* mm6 = {C,D,C,D} */ | |
273 "movd %0, %%mm5\n\t" | |
274 "movd %1, %%mm6\n\t" | |
275 "punpckldq %%mm5, %%mm5\n\t" | |
276 "punpckldq %%mm6, %%mm6\n\t" | |
277 "pxor %%mm7, %%mm7\n\t" | |
278 :: "r"(AB), "r"(CD)); | |
279 | |
280 asm volatile( | |
281 /* mm0 = src[0,1,1,2] */ | |
282 "movd %0, %%mm0\n\t" | |
283 "punpcklbw %%mm7, %%mm0\n\t" | |
284 "pshufw $0x94, %%mm0, %%mm0\n\t" | |
285 :: "m"(src[0])); | |
286 | |
287 for(i=0; i<h; i++) { | |
288 asm volatile( | |
289 /* mm1 = A * src[0,1] + B * src[1,2] */ | |
290 "movq %%mm0, %%mm1\n\t" | |
291 "pmaddwd %%mm5, %%mm1\n\t" | |
292 ::); | |
293 | |
294 src += stride; | |
295 asm volatile( | |
296 /* mm0 = src[0,1,1,2] */ | |
297 "movd %0, %%mm0\n\t" | |
298 "punpcklbw %%mm7, %%mm0\n\t" | |
299 "pshufw $0x94, %%mm0, %%mm0\n\t" | |
300 :: "m"(src[0])); | |
301 | |
302 asm volatile( | |
303 /* mm1 += C * src[0,1] + D * src[1,2] */ | |
304 "movq %%mm0, %%mm2\n\t" | |
305 "pmaddwd %%mm6, %%mm2\n\t" | |
306 "paddw %%mm2, %%mm1\n\t" | |
307 ::); | |
308 | |
309 asm volatile( | |
310 /* dst[0,1] = pack((mm1 + 32) >> 6) */ | |
311 "paddw %1, %%mm1\n\t" | |
312 "psrlw $6, %%mm1\n\t" | |
313 "packssdw %%mm7, %%mm1\n\t" | |
314 "packuswb %%mm7, %%mm1\n\t" | |
315 /* writes garbage to the right of dst. | |
316 * ok because partitions are processed from left to right. */ | |
317 H264_CHROMA_OP4(%0, %%mm1, %%mm3) | |
318 "movd %%mm1, %0\n\t" | |
3214 | 319 : "=m" (dst[0]) : "m" (ff_pw_32)); |
3213 | 320 dst += stride; |
321 } | |
322 } | |
323 #endif | |
324 |