comparison i386/vp3dsp_sse2.c @ 7882:1a684e0e6420 libavcodec

Factorize SSE2_(Row|Column)_IDCT into one macro
author conrad
date Thu, 18 Sep 2008 03:07:41 +0000
parents 1e99834a163b
children 6f77eda89813
comparison
equal deleted inserted replaced
7881:1e99834a163b 7882:1a684e0e6420
36 25080,25080,25080,25080,25080,25080,25080,25080, 36 25080,25080,25080,25080,25080,25080,25080,25080,
37 12785,12785,12785,12785,12785,12785,12785,12785 37 12785,12785,12785,12785,12785,12785,12785,12785
38 }; 38 };
39 39
40 40
41 #define SSE2_Column_IDCT() \ 41 #define VP3_1D_IDCT_SSE2(ADD, SHIFT) \
42 "movdqa "I(3)", %%xmm2 \n\t" /* xmm2 = i3 */ \ 42 "movdqa "I(3)", %%xmm2 \n\t" /* xmm2 = i3 */ \
43 "movdqa "C(3)", %%xmm6 \n\t" /* xmm6 = c3 */ \ 43 "movdqa "C(3)", %%xmm6 \n\t" /* xmm6 = c3 */ \
44 "movdqa %%xmm2, %%xmm4 \n\t" /* xmm4 = i3 */ \ 44 "movdqa %%xmm2, %%xmm4 \n\t" /* xmm4 = i3 */ \
45 "movdqa "I(5)", %%xmm7 \n\t" /* xmm7 = i5 */ \ 45 "movdqa "I(5)", %%xmm7 \n\t" /* xmm7 = i5 */ \
46 "pmulhw %%xmm6, %%xmm4 \n\t" /* xmm4 = c3 * i3 - i3 */ \ 46 "pmulhw %%xmm6, %%xmm4 \n\t" /* xmm4 = c3 * i3 - i3 */ \
111 "paddsw %%xmm2, %%xmm2 \n\t" /* xmm2 = A. + A. */ \ 111 "paddsw %%xmm2, %%xmm2 \n\t" /* xmm2 = A. + A. */ \
112 "movdqa "I(1)", %%xmm0 \n\t" /* Load C. from I(1) */ \ 112 "movdqa "I(1)", %%xmm0 \n\t" /* Load C. from I(1) */ \
113 "paddsw %%xmm6, %%xmm2 \n\t" /* xmm2 = F + A. = A.. */ \ 113 "paddsw %%xmm6, %%xmm2 \n\t" /* xmm2 = F + A. = A.. */ \
114 "paddw %%xmm3, %%xmm4 \n\t" /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \ 114 "paddw %%xmm3, %%xmm4 \n\t" /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \
115 "psubsw %%xmm1, %%xmm2 \n\t" /* xmm2 = A.. - H. = R2 */ \ 115 "psubsw %%xmm1, %%xmm2 \n\t" /* xmm2 = A.. - H. = R2 */ \
116 "paddsw "OC_8", %%xmm2 \n\t" /* Adjust R2 and R1 before shifting */ \ 116 ADD(%%xmm2) /* Adjust R2 and R1 before shifting */ \
117 "paddsw %%xmm1, %%xmm1 \n\t" /* xmm1 = H. + H. */ \ 117 "paddsw %%xmm1, %%xmm1 \n\t" /* xmm1 = H. + H. */ \
118 "paddsw %%xmm2, %%xmm1 \n\t" /* xmm1 = A.. + H. = R1 */ \ 118 "paddsw %%xmm2, %%xmm1 \n\t" /* xmm1 = A.. + H. = R1 */ \
119 "psraw $4, %%xmm2 \n\t" /* xmm2 = op2 */ \ 119 SHIFT(%%xmm2) /* xmm2 = op2 */ \
120 "psubsw %%xmm7, %%xmm4 \n\t" /* xmm4 = E - G = E. */ \ 120 "psubsw %%xmm7, %%xmm4 \n\t" /* xmm4 = E - G = E. */ \
121 "psraw $4, %%xmm1 \n\t" /* xmm1 = op1 */ \ 121 SHIFT(%%xmm1) /* xmm1 = op1 */ \
122 "movdqa "I(2)", %%xmm3 \n\t" /* Load D. from I(2) */ \ 122 "movdqa "I(2)", %%xmm3 \n\t" /* Load D. from I(2) */ \
123 "paddsw %%xmm7, %%xmm7 \n\t" /* xmm7 = G + G */ \ 123 "paddsw %%xmm7, %%xmm7 \n\t" /* xmm7 = G + G */ \
124 "movdqa %%xmm2, "O(2)" \n\t" /* Write out op2 */ \ 124 "movdqa %%xmm2, "O(2)" \n\t" /* Write out op2 */ \
125 "paddsw %%xmm4, %%xmm7 \n\t" /* xmm7 = E + G = G. */ \ 125 "paddsw %%xmm4, %%xmm7 \n\t" /* xmm7 = E + G = G. */ \
126 "movdqa %%xmm1, "O(1)" \n\t" /* Write out op1 */ \ 126 "movdqa %%xmm1, "O(1)" \n\t" /* Write out op1 */ \
127 "psubsw %%xmm3, %%xmm4 \n\t" /* xmm4 = E. - D. = R4 */ \ 127 "psubsw %%xmm3, %%xmm4 \n\t" /* xmm4 = E. - D. = R4 */ \
128 "paddsw "OC_8", %%xmm4 \n\t" /* Adjust R4 and R3 before shifting */ \ 128 ADD(%%xmm4) /* Adjust R4 and R3 before shifting */ \
129 "paddsw %%xmm3, %%xmm3 \n\t" /* xmm3 = D. + D. */ \ 129 "paddsw %%xmm3, %%xmm3 \n\t" /* xmm3 = D. + D. */ \
130 "paddsw %%xmm4, %%xmm3 \n\t" /* xmm3 = E. + D. = R3 */ \ 130 "paddsw %%xmm4, %%xmm3 \n\t" /* xmm3 = E. + D. = R3 */ \
131 "psraw $4, %%xmm4 \n\t" /* xmm4 = op4 */ \ 131 SHIFT(%%xmm4) /* xmm4 = op4 */ \
132 "psubsw %%xmm5, %%xmm6 \n\t" /* xmm6 = F. - B..= R6 */ \ 132 "psubsw %%xmm5, %%xmm6 \n\t" /* xmm6 = F. - B..= R6 */ \
133 "psraw $4, %%xmm3 \n\t" /* xmm3 = op3 */ \ 133 SHIFT(%%xmm3) /* xmm3 = op3 */ \
134 "paddsw "OC_8", %%xmm6 \n\t" /* Adjust R6 and R5 before shifting */ \ 134 ADD(%%xmm6) /* Adjust R6 and R5 before shifting */ \
135 "paddsw %%xmm5, %%xmm5 \n\t" /* xmm5 = B.. + B.. */ \ 135 "paddsw %%xmm5, %%xmm5 \n\t" /* xmm5 = B.. + B.. */ \
136 "paddsw %%xmm6, %%xmm5 \n\t" /* xmm5 = F. + B.. = R5 */ \ 136 "paddsw %%xmm6, %%xmm5 \n\t" /* xmm5 = F. + B.. = R5 */ \
137 "psraw $4, %%xmm6 \n\t" /* xmm6 = op6 */ \ 137 SHIFT(%%xmm6) /* xmm6 = op6 */ \
138 "movdqa %%xmm4, "O(4)" \n\t" /* Write out op4 */ \ 138 "movdqa %%xmm4, "O(4)" \n\t" /* Write out op4 */ \
139 "psraw $4, %%xmm5 \n\t" /* xmm5 = op5 */ \ 139 SHIFT(%%xmm5) /* xmm5 = op5 */ \
140 "movdqa %%xmm3, "O(3)" \n\t" /* Write out op3 */ \ 140 "movdqa %%xmm3, "O(3)" \n\t" /* Write out op3 */ \
141 "psubsw %%xmm0, %%xmm7 \n\t" /* xmm7 = G. - C. = R7 */ \ 141 "psubsw %%xmm0, %%xmm7 \n\t" /* xmm7 = G. - C. = R7 */ \
142 "paddsw "OC_8", %%xmm7 \n\t" /* Adjust R7 and R0 before shifting */ \ 142 ADD(%%xmm7) /* Adjust R7 and R0 before shifting */ \
143 "paddsw %%xmm0, %%xmm0 \n\t" /* xmm0 = C. + C. */ \ 143 "paddsw %%xmm0, %%xmm0 \n\t" /* xmm0 = C. + C. */ \
144 "paddsw %%xmm7, %%xmm0 \n\t" /* xmm0 = G. + C. */ \ 144 "paddsw %%xmm7, %%xmm0 \n\t" /* xmm0 = G. + C. */ \
145 "psraw $4, %%xmm7 \n\t" /* xmm7 = op7 */ \ 145 SHIFT(%%xmm7) /* xmm7 = op7 */ \
146 "movdqa %%xmm6, "O(6)" \n\t" /* Write out op6 */ \ 146 "movdqa %%xmm6, "O(6)" \n\t" /* Write out op6 */ \
147 "psraw $4, %%xmm0 \n\t" /* xmm0 = op0 */ \ 147 SHIFT(%%xmm0) /* xmm0 = op0 */ \
148 "movdqa %%xmm5, "O(5)" \n\t" /* Write out op5 */ \ 148 "movdqa %%xmm5, "O(5)" \n\t" /* Write out op5 */ \
149 "movdqa %%xmm7, "O(7)" \n\t" /* Write out op7 */ \ 149 "movdqa %%xmm7, "O(7)" \n\t" /* Write out op7 */ \
150 "movdqa %%xmm0, "O(0)" \n\t" /* Write out op0 */ 150 "movdqa %%xmm0, "O(0)" \n\t" /* Write out op0 */
151 151
152
153 #define SSE2_Row_IDCT() \
154 "movdqa "I(3)", %%xmm2 \n\t" /* xmm2 = i3 */ \
155 "movdqa "C(3)", %%xmm6 \n\t" /* xmm6 = c3 */ \
156 "movdqa %%xmm2, %%xmm4 \n\t" /* xmm4 = i3 */ \
157 "movdqa "I(5)", %%xmm7 \n\t" /* xmm7 = i5 */ \
158 "pmulhw %%xmm6, %%xmm4 \n\t" /* xmm4 = c3 * i3 - i3 */ \
159 "movdqa "C(5)", %%xmm1 \n\t" /* xmm1 = c5 */ \
160 "pmulhw %%xmm7, %%xmm6 \n\t" /* xmm6 = c3 * i5 - i5 */ \
161 "movdqa %%xmm1, %%xmm5 \n\t" /* xmm5 = c5 */ \
162 "pmulhw %%xmm2, %%xmm1 \n\t" /* xmm1 = c5 * i3 - i3 */ \
163 "movdqa "I(1)", %%xmm3 \n\t" /* xmm3 = i1 */ \
164 "pmulhw %%xmm7, %%xmm5 \n\t" /* xmm5 = c5 * i5 - i5 */ \
165 "movdqa "C(1)", %%xmm0 \n\t" /* xmm0 = c1 */ \
166 "paddw %%xmm2, %%xmm4 \n\t" /* xmm4 = c3 * i3 */ \
167 "paddw %%xmm7, %%xmm6 \n\t" /* xmm6 = c3 * i5 */ \
168 "paddw %%xmm1, %%xmm2 \n\t" /* xmm2 = c5 * i3 */ \
169 "movdqa "I(7)", %%xmm1 \n\t" /* xmm1 = i7 */ \
170 "paddw %%xmm5, %%xmm7 \n\t" /* xmm7 = c5 * i5 */ \
171 "movdqa %%xmm0, %%xmm5 \n\t" /* xmm5 = c1 */ \
172 "pmulhw %%xmm3, %%xmm0 \n\t" /* xmm0 = c1 * i1 - i1 */ \
173 "paddsw %%xmm7, %%xmm4 \n\t" /* xmm4 = c3 * i3 + c5 * i5 = C */ \
174 "pmulhw %%xmm1, %%xmm5 \n\t" /* xmm5 = c1 * i7 - i7 */ \
175 "movdqa "C(7)", %%xmm7 \n\t" /* xmm7 = c7 */ \
176 "psubsw %%xmm2, %%xmm6 \n\t" /* xmm6 = c3 * i5 - c5 * i3 = D */ \
177 "paddw %%xmm3, %%xmm0 \n\t" /* xmm0 = c1 * i1 */ \
178 "pmulhw %%xmm7, %%xmm3 \n\t" /* xmm3 = c7 * i1 */ \
179 "movdqa "I(2)", %%xmm2 \n\t" /* xmm2 = i2 */ \
180 "pmulhw %%xmm1, %%xmm7 \n\t" /* xmm7 = c7 * i7 */ \
181 "paddw %%xmm1, %%xmm5 \n\t" /* xmm5 = c1 * i7 */ \
182 "movdqa %%xmm2, %%xmm1 \n\t" /* xmm1 = i2 */ \
183 "pmulhw "C(2)", %%xmm2 \n\t" /* xmm2 = i2 * c2 -i2 */ \
184 "psubsw %%xmm5, %%xmm3 \n\t" /* xmm3 = c7 * i1 - c1 * i7 = B */ \
185 "movdqa "I(6)", %%xmm5 \n\t" /* xmm5 = i6 */ \
186 "paddsw %%xmm7, %%xmm0 \n\t" /* xmm0 = c1 * i1 + c7 * i7 = A */ \
187 "movdqa %%xmm5, %%xmm7 \n\t" /* xmm7 = i6 */ \
188 "psubsw %%xmm4, %%xmm0 \n\t" /* xmm0 = A - C */ \
189 "pmulhw "C(2)", %%xmm5 \n\t" /* xmm5 = c2 * i6 - i6 */ \
190 "paddw %%xmm1, %%xmm2 \n\t" /* xmm2 = i2 * c2 */ \
191 "pmulhw "C(6)", %%xmm1 \n\t" /* xmm1 = c6 * i2 */ \
192 "paddsw %%xmm4, %%xmm4 \n\t" /* xmm4 = C + C */ \
193 "paddsw %%xmm0, %%xmm4 \n\t" /* xmm4 = A + C = C. */ \
194 "psubsw %%xmm6, %%xmm3 \n\t" /* xmm3 = B - D */ \
195 "paddw %%xmm7, %%xmm5 \n\t" /* xmm5 = c2 * i6 */ \
196 "paddsw %%xmm6, %%xmm6 \n\t" /* xmm6 = D + D */ \
197 "pmulhw "C(6)", %%xmm7 \n\t" /* xmm7 = c6 * i6 */ \
198 "paddsw %%xmm3, %%xmm6 \n\t" /* xmm6 = B + D = D. */ \
199 "movdqa %%xmm4, "I(1)" \n\t" /* Save C. at I(1) */ \
200 "psubsw %%xmm5, %%xmm1 \n\t" /* xmm1 = c6 * i2 - c2 * i6 = H */ \
201 "movdqa "C(4)", %%xmm4 \n\t" /* xmm4 = c4 */ \
202 "movdqa %%xmm3, %%xmm5 \n\t" /* xmm5 = B - D */ \
203 "pmulhw %%xmm4, %%xmm3 \n\t" /* xmm3 = ( c4 -1 ) * ( B - D ) */ \
204 "paddsw %%xmm2, %%xmm7 \n\t" /* xmm7 = c2 * i2 + c6 * i6 = G */ \
205 "movdqa %%xmm6, "I(2)" \n\t" /* Save D. at I(2) */ \
206 "movdqa %%xmm0, %%xmm2 \n\t" /* xmm2 = A - C */ \
207 "movdqa "I(0)", %%xmm6 \n\t" /* xmm6 = i0 */ \
208 "pmulhw %%xmm4, %%xmm0 \n\t" /* xmm0 = ( c4 - 1 ) * ( A - C ) = A. */ \
209 "paddw %%xmm3, %%xmm5 \n\t" /* xmm5 = c4 * ( B - D ) = B. */ \
210 "movdqa "I(4)", %%xmm3 \n\t" /* xmm3 = i4 */ \
211 "psubsw %%xmm1, %%xmm5 \n\t" /* xmm5 = B. - H = B.. */ \
212 "paddw %%xmm0, %%xmm2 \n\t" /* xmm2 = c4 * ( A - C) = A. */ \
213 "psubsw %%xmm3, %%xmm6 \n\t" /* xmm6 = i0 - i4 */ \
214 "movdqa %%xmm6, %%xmm0 \n\t" /* xmm0 = i0 - i4 */ \
215 "pmulhw %%xmm4, %%xmm6 \n\t" /* xmm6 = ( c4 - 1 ) * ( i0 - i4 ) = F */ \
216 "paddsw %%xmm3, %%xmm3 \n\t" /* xmm3 = i4 + i4 */ \
217 "paddsw %%xmm1, %%xmm1 \n\t" /* xmm1 = H + H */ \
218 "paddsw %%xmm0, %%xmm3 \n\t" /* xmm3 = i0 + i4 */ \
219 "paddsw %%xmm5, %%xmm1 \n\t" /* xmm1 = B. + H = H. */ \
220 "pmulhw %%xmm3, %%xmm4 \n\t" /* xmm4 = ( c4 - 1 ) * ( i0 + i4 ) */ \
221 "paddw %%xmm0, %%xmm6 \n\t" /* xmm6 = c4 * ( i0 - i4 ) */ \
222 "psubsw %%xmm2, %%xmm6 \n\t" /* xmm6 = F - A. = F. */ \
223 "paddsw %%xmm2, %%xmm2 \n\t" /* xmm2 = A. + A. */ \
224 "movdqa "I(1)", %%xmm0 \n\t" /* Load C. from I(1) */ \
225 "paddsw %%xmm6, %%xmm2 \n\t" /* xmm2 = F + A. = A.. */ \
226 "paddw %%xmm3, %%xmm4 \n\t" /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \
227 "psubsw %%xmm1, %%xmm2 \n\t" /* xmm2 = A.. - H. = R2 */ \
228 "paddsw %%xmm1, %%xmm1 \n\t" /* xmm1 = H. + H. */ \
229 "paddsw %%xmm2, %%xmm1 \n\t" /* xmm1 = A.. + H. = R1 */ \
230 "psubsw %%xmm7, %%xmm4 \n\t" /* xmm4 = E - G = E. */ \
231 "movdqa "I(2)", %%xmm3 \n\t" /* Load D. from I(2) */ \
232 "paddsw %%xmm7, %%xmm7 \n\t" /* xmm7 = G + G */ \
233 "movdqa %%xmm2, "I(2)" \n\t" /* Write out op2 */ \
234 "paddsw %%xmm4, %%xmm7 \n\t" /* xmm7 = E + G = G. */ \
235 "movdqa %%xmm1, "I(1)" \n\t" /* Write out op1 */ \
236 "psubsw %%xmm3, %%xmm4 \n\t" /* xmm4 = E. - D. = R4 */ \
237 "paddsw %%xmm3, %%xmm3 \n\t" /* xmm3 = D. + D. */ \
238 "paddsw %%xmm4, %%xmm3 \n\t" /* xmm3 = E. + D. = R3 */ \
239 "psubsw %%xmm5, %%xmm6 \n\t" /* xmm6 = F. - B..= R6 */ \
240 "paddsw %%xmm5, %%xmm5 \n\t" /* xmm5 = B.. + B.. */ \
241 "paddsw %%xmm6, %%xmm5 \n\t" /* xmm5 = F. + B.. = R5 */ \
242 "movdqa %%xmm4, "I(4)" \n\t" /* Write out op4 */ \
243 "movdqa %%xmm3, "I(3)" \n\t" /* Write out op3 */ \
244 "psubsw %%xmm0, %%xmm7 \n\t" /* xmm7 = G. - C. = R7 */ \
245 "paddsw %%xmm0, %%xmm0 \n\t" /* xmm0 = C. + C. */ \
246 "paddsw %%xmm7, %%xmm0 \n\t" /* xmm0 = G. + C. */ \
247 "movdqa %%xmm6, "I(6)" \n\t" /* Write out op6 */ \
248 "movdqa %%xmm5, "I(5)" \n\t" /* Write out op5 */ \
249 "movdqa %%xmm7, "I(7)" \n\t" /* Write out op7 */ \
250 "movdqa %%xmm0, "I(0)" \n\t" /* Write out op0 */
251 152
252 #define SSE2_Transpose() \ 153 #define SSE2_Transpose() \
253 "movdqa "I(4)", %%xmm4 \n\t" /* xmm4=e7e6e5e4e3e2e1e0 */ \ 154 "movdqa "I(4)", %%xmm4 \n\t" /* xmm4=e7e6e5e4e3e2e1e0 */ \
254 "movdqa "I(5)", %%xmm0 \n\t" /* xmm4=f7f6f5f4f3f2f1f0 */ \ 155 "movdqa "I(5)", %%xmm0 \n\t" /* xmm4=f7f6f5f4f3f2f1f0 */ \
255 "movdqa %%xmm4, %%xmm5 \n\t" /* make a copy */ \ 156 "movdqa %%xmm4, %%xmm5 \n\t" /* make a copy */ \
303 "punpcklqdq %%xmm6, %%xmm5 \n\t" /* xmm5=h6g6f6e6d6c6b6a6 */ \ 204 "punpcklqdq %%xmm6, %%xmm5 \n\t" /* xmm5=h6g6f6e6d6c6b6a6 */ \
304 "punpckhqdq %%xmm6, %%xmm7 \n\t" /* xmm7=h7g7f7e7d7c7b7a7 */ \ 205 "punpckhqdq %%xmm6, %%xmm7 \n\t" /* xmm7=h7g7f7e7d7c7b7a7 */ \
305 "movdqa %%xmm5, "I(6)" \n\t" /* save I(6) */ \ 206 "movdqa %%xmm5, "I(6)" \n\t" /* save I(6) */ \
306 "movdqa %%xmm7, "I(7)" \n\t" /* save I(7) */ 207 "movdqa %%xmm7, "I(7)" \n\t" /* save I(7) */
307 208
209 #define NOP(xmm)
210 #define SHIFT4(xmm) "psraw $4, "#xmm"\n\t"
211 #define ADD8(xmm) "paddsw %2, "#xmm"\n\t"
212
308 void ff_vp3_idct_sse2(int16_t *input_data) 213 void ff_vp3_idct_sse2(int16_t *input_data)
309 { 214 {
310 #define OC_8 "%2"
311
312 #define I(x) AV_STRINGIFY(16*x)"(%0)" 215 #define I(x) AV_STRINGIFY(16*x)"(%0)"
313 #define O(x) I(x) 216 #define O(x) I(x)
314 #define C(x) AV_STRINGIFY(16*(x-1))"(%1)" 217 #define C(x) AV_STRINGIFY(16*(x-1))"(%1)"
315 218
316 asm volatile ( 219 asm volatile (
317 SSE2_Row_IDCT() 220 VP3_1D_IDCT_SSE2(NOP, NOP)
318 221
319 SSE2_Transpose() 222 SSE2_Transpose()
320 223
321 SSE2_Column_IDCT() 224 VP3_1D_IDCT_SSE2(ADD8, SHIFT4)
322 :: "r"(input_data), "r"(ff_vp3_idct_data), "m"(ff_pw_8) 225 :: "r"(input_data), "r"(ff_vp3_idct_data), "m"(ff_pw_8)
323 ); 226 );
324 } 227 }
325 228
326 void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, DCTELEM *block) 229 void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, DCTELEM *block)