33 #define round(bias) ((int)(((bias)+0.5) * (1<<ROW_SHIFT)))
34 #define rounder(bias) {round (bias), round (bias)}
55 a0 = C4*row[0] + C2*row[2] + C4*row[4] + C6*row[6] + *
rounder;
56 a1 = C4*row[0] + C6*row[2] - C4*row[4] - C2*row[6] + *
rounder;
57 a2 = C4*row[0] - C6*row[2] - C4*row[4] + C2*row[6] + *
rounder;
58 a3 = C4*row[0] - C2*row[2] + C4*row[4] - C6*row[6] + *
rounder;
60 b0 = C1*row[1] + C3*row[3] + C5*row[5] + C7*row[7];
61 b1 = C3*row[1] - C7*row[3] - C1*row[5] - C5*row[7];
62 b2 = C5*row[1] - C1*row[3] + C7*row[5] + C3*row[7];
63 b3 = C7*row[1] - C5*row[3] + C3*row[5] - C1*row[7];
79 #define mmxext_table(c1,c2,c3,c4,c5,c6,c7) { c4, c2, -c4, -c2, \
88 static inline void mmxext_row_head (int16_t *
const row,
const int offset,
89 const int16_t *
const table)
92 "movq (%0), %%mm2 \n\t"
94 "movq 8(%0), %%mm5 \n\t"
95 "movq %%mm2, %%mm0 \n\t"
97 "movq (%1), %%mm3 \n\t"
98 "movq %%mm5, %%mm6 \n\t"
100 "movq 8(%1), %%mm4 \n\t"
101 "pmaddwd %%mm0, %%mm3 \n\t"
103 "pshufw $0x4e, %%mm2, %%mm2 \n\t"
108 static inline void mmxext_row (
const int16_t *
const table,
112 "movq 16(%0), %%mm1 \n\t"
113 "pmaddwd %%mm2, %%mm4 \n\t"
115 "pmaddwd 32(%0), %%mm0 \n\t"
116 "pshufw $0x4e, %%mm6, %%mm6 \n\t"
118 "movq 24(%0), %%mm7 \n\t"
119 "pmaddwd %%mm5, %%mm1 \n\t"
121 "paddd (%1), %%mm3 \n\t"
122 "pmaddwd %%mm6, %%mm7 \n\t"
124 "pmaddwd 40(%0), %%mm2 \n\t"
125 "paddd %%mm4, %%mm3 \n\t"
127 "pmaddwd 48(%0), %%mm5 \n\t"
128 "movq %%mm3, %%mm4 \n\t"
130 "pmaddwd 56(%0), %%mm6 \n\t"
131 "paddd %%mm7, %%mm1 \n\t"
133 "paddd (%1), %%mm0 \n\t"
134 "psubd %%mm1, %%mm3 \n\t"
137 "paddd %%mm4, %%mm1 \n\t"
139 "paddd %%mm2, %%mm0 \n\t"
142 "paddd %%mm6, %%mm5 \n\t"
143 "movq %%mm0, %%mm4 \n\t"
145 "paddd %%mm5, %%mm0 \n\t"
146 "psubd %%mm5, %%mm4 \n\t"
147 : :
"r" (
table),
"r" (rounder));
150 static inline void mmxext_row_tail (int16_t *
const row,
const int store)
157 "packssdw %%mm0, %%mm1 \n\t"
159 "packssdw %%mm3, %%mm4 \n\t"
161 "movq %%mm1, (%0) \n\t"
162 "pshufw $0xb1, %%mm4, %%mm4 \n\t"
166 "movq %%mm4, 8(%0) \n\t"
171 static inline void mmxext_row_mid (int16_t *
const row,
const int store,
173 const int16_t *
const table)
176 "movq (%0,%1), %%mm2 \n\t"
179 "movq 8(%0,%1), %%mm5 \n\t"
182 "packssdw %%mm0, %%mm1 \n\t"
183 "movq %%mm5, %%mm6 \n\t"
185 "packssdw %%mm3, %%mm4 \n\t"
186 "movq %%mm2, %%mm0 \n\t"
188 "movq %%mm1, (%0,%2) \n\t"
189 "pshufw $0xb1, %%mm4, %%mm4\n\t"
191 "movq (%3), %%mm3 \n\t"
192 "movq %%mm4, 8(%0,%2) \n\t"
194 "pmaddwd %%mm0, %%mm3 \n\t"
196 "movq 8(%3), %%mm4 \n\t"
197 "pshufw $0x4e, %%mm2, %%mm2\n\t"
205 #define mmx_table(c1,c2,c3,c4,c5,c6,c7) { c4, c2, c4, c6, \
214 static inline void mmx_row_head (int16_t *
const row,
const int offset,
215 const int16_t *
const table)
218 "movq (%0), %%mm2 \n\t"
220 "movq 8(%0), %%mm5 \n\t"
221 "movq %%mm2, %%mm0 \n\t"
223 "movq (%1), %%mm3 \n\t"
224 "movq %%mm5, %%mm6 \n\t"
226 "punpckldq %%mm0, %%mm0 \n\t"
228 "movq 8(%1), %%mm4 \n\t"
229 "pmaddwd %%mm0, %%mm3 \n\t"
231 "movq 16(%1), %%mm1 \n\t"
232 "punpckhdq %%mm2, %%mm2 \n\t"
237 static inline void mmx_row (
const int16_t *
const table,
241 "pmaddwd %%mm2, %%mm4 \n\t"
242 "punpckldq %%mm5, %%mm5 \n\t"
244 "pmaddwd 32(%0), %%mm0 \n\t"
245 "punpckhdq %%mm6, %%mm6 \n\t"
247 "movq 24(%0), %%mm7 \n\t"
248 "pmaddwd %%mm5, %%mm1 \n\t"
250 "paddd (%1), %%mm3 \n\t"
251 "pmaddwd %%mm6, %%mm7 \n\t"
253 "pmaddwd 40(%0), %%mm2 \n\t"
254 "paddd %%mm4, %%mm3 \n\t"
256 "pmaddwd 48(%0), %%mm5 \n\t"
257 "movq %%mm3, %%mm4 \n\t"
259 "pmaddwd 56(%0), %%mm6 \n\t"
260 "paddd %%mm7, %%mm1 \n\t"
262 "paddd (%1), %%mm0 \n\t"
263 "psubd %%mm1, %%mm3 \n\t"
266 "paddd %%mm4, %%mm1 \n\t"
268 "paddd %%mm2, %%mm0 \n\t"
271 "paddd %%mm6, %%mm5 \n\t"
272 "movq %%mm0, %%mm7 \n\t"
274 "paddd %%mm5, %%mm0 \n\t"
275 "psubd %%mm5, %%mm7 \n\t"
276 ::
"r" (
table),
"r" (rounder)
280 static inline void mmx_row_tail (int16_t *
const row,
const int store)
287 "packssdw %%mm0, %%mm1 \n\t"
289 "packssdw %%mm3, %%mm7 \n\t"
291 "movq %%mm1, (%0) \n\t"
292 "movq %%mm7, %%mm4 \n\t"
294 "pslld $16, %%mm7 \n\t"
296 "psrld $16, %%mm4 \n\t"
298 "por %%mm4, %%mm7 \n\t"
302 "movq %%mm7, 8(%0) \n\t"
307 static inline void mmx_row_mid (int16_t *
const row,
const int store,
308 const int offset,
const int16_t *
const table)
312 "movq (%0,%1), %%mm2 \n\t"
315 "movq 8(%0,%1), %%mm5 \n\t"
318 "packssdw %%mm0, %%mm1 \n\t"
319 "movq %%mm5, %%mm6 \n\t"
321 "packssdw %%mm3, %%mm7 \n\t"
322 "movq %%mm2, %%mm0 \n\t"
324 "movq %%mm1, (%0,%2) \n\t"
325 "movq %%mm7, %%mm1 \n\t"
327 "punpckldq %%mm0, %%mm0 \n\t"
328 "psrld $16, %%mm7 \n\t"
330 "movq (%3), %%mm3 \n\t"
331 "pslld $16, %%mm1 \n\t"
333 "movq 8(%3), %%mm4 \n\t"
334 "por %%mm1, %%mm7 \n\t"
336 "movq 16(%3), %%mm1 \n\t"
337 "punpckhdq %%mm2, %%mm2 \n\t"
339 "movq %%mm7, 8(%0,%2) \n\t"
340 "pmaddwd %%mm0, %%mm3 \n\t"
348 static inline void idct_col (int16_t * col,
int offset)
351 #define F(c,x) (((c) * (x)) >> 16)
354 #define S(x) (((x)>32767) ? 32767 : ((x)<-32768) ? -32768 : (x))
356 int16_t x0, x1, x2, x3, x4, x5, x6, x7;
357 int16_t y0, y1, y2, y3, y4, y5, y6, y7;
358 int16_t
a0,
a1,
a2,
a3, b0, b1, b2, b3;
359 int16_t u04, v04, u26, v26, u17, v17, u35, v35, u12, v12;
374 u26 =
S (
F (T2, x6) + x2);
375 v26 =
S (
F (T2, x2) - x6);
382 u17 =
S (
F (T1, x7) + x1);
383 v17 =
S (
F (T1, x1) - x7);
384 u35 =
S (
F (T3, x5) + x3);
385 v35 =
S (
F (T3, x3) - x5);
391 u12 =
S (2 *
F (
C4, u12));
392 v12 =
S (2 *
F (
C4, v12));
419 static inline void idct_col (int16_t *
const col,
const int offset)
437 "movq (%0), %%mm0 \n\t"
439 "movq 2*8(%1), %%mm1 \n\t"
440 "movq %%mm0, %%mm2 \n\t"
442 "movq 7*2*8(%1), %%mm4 \n\t"
443 "pmulhw %%mm1, %%mm0 \n\t"
445 "movq 16(%0), %%mm5 \n\t"
446 "pmulhw %%mm4, %%mm2 \n\t"
448 "movq 2*5*8(%1), %%mm6 \n\t"
449 "movq %%mm5, %%mm7 \n\t"
451 "movq 3*8*2(%1), %%mm3 \n\t"
452 "psubsw %%mm4, %%mm0 \n\t"
454 "movq 8(%0), %%mm4 \n\t"
455 "pmulhw %%mm3, %%mm5 \n\t"
457 "paddsw %%mm2, %%mm1 \n\t"
458 "pmulhw %%mm6, %%mm7 \n\t"
462 "movq %%mm4, %%mm2 \n\t"
463 "paddsw %%mm3, %%mm5 \n\t"
465 "pmulhw 2*8*2(%1), %%mm4 \n\t"
466 "paddsw %%mm6, %%mm7 \n\t"
468 "psubsw %%mm6, %%mm5 \n\t"
469 "paddsw %%mm3, %%mm7 \n\t"
471 "movq 6*8*2(%1), %%mm3 \n\t"
472 "movq %%mm0, %%mm6 \n\t"
474 "pmulhw %%mm3, %%mm2 \n\t"
475 "psubsw %%mm5, %%mm0 \n\t"
477 "psubsw %%mm3, %%mm4 \n\t"
478 "paddsw %%mm6, %%mm5 \n\t"
480 "movq %%mm0, 3*8*2(%1)\n\t"
481 "movq %%mm1, %%mm6 \n\t"
483 "paddsw 2*8*2(%1), %%mm2 \n\t"
484 "paddsw %%mm7, %%mm6 \n\t"
486 "psubsw %%mm7, %%mm1 \n\t"
487 "movq %%mm1, %%mm7 \n\t"
489 "movq 0*8(%1), %%mm3 \n\t"
490 "paddsw %%mm5, %%mm1 \n\t"
492 "movq 24(%0), %%mm0 \n\t"
493 "psubsw %%mm5, %%mm7 \n\t"
495 "movq %%mm6, 5*8*2(%1)\n\t"
496 "pmulhw %%mm0, %%mm1 \n\t"
498 "movq %%mm4, %%mm6 \n\t"
499 "pmulhw %%mm0, %%mm7 \n\t"
501 "movq 4*8*2(%1), %%mm5 \n\t"
502 "movq %%mm3, %%mm0 \n\t"
504 "psubsw %%mm5, %%mm3 \n\t"
505 "paddsw %%mm5, %%mm0 \n\t"
507 "paddsw %%mm3, %%mm4 \n\t"
508 "movq %%mm0, %%mm5 \n\t"
510 "psubsw %%mm6, %%mm3 \n\t"
511 "paddsw %%mm2, %%mm5 \n\t"
513 "paddsw %%mm1, %%mm1 \n\t"
514 "psubsw %%mm2, %%mm0 \n\t"
516 "paddsw %%mm7, %%mm7 \n\t"
517 "movq %%mm3, %%mm2 \n\t"
519 "movq %%mm4, %%mm6 \n\t"
520 "paddsw %%mm7, %%mm3 \n\t"
523 "paddsw %%mm1, %%mm4\n\t"
526 "psubsw %%mm1, %%mm6 \n\t"
528 "movq 5*8*2(%1), %%mm1 \n\t"
529 "psubsw %%mm7, %%mm2 \n\t"
532 "movq %%mm5, %%mm7 \n\t"
534 "movq %%mm4, 1*8*2(%1)\n\t"
537 "movq %%mm3, 2*8*2(%1)\n\t"
538 "paddsw %%mm1, %%mm5 \n\t"
540 "movq 3*8*2(%1), %%mm4 \n\t"
541 "psubsw %%mm1, %%mm7 \n\t"
544 "movq %%mm0, %%mm3 \n\t"
546 "movq %%mm2, 5*8*2(%1)\n\t"
547 "psubsw %%mm4, %%mm3 \n\t"
550 "paddsw %%mm0, %%mm4 \n\t"
552 "movq %%mm5, 0*8*2(%1)\n\t"
555 "movq %%mm6, 6*8*2(%1)\n\t"
558 "movq %%mm7, 7*8*2(%1)\n\t"
560 "movq %%mm3, 4*8*2(%1)\n\t"
562 "movq %%mm4, 3*8*2(%1)\n\t"
563 ::
"r" (t1_vector),
"r" (col+offset)
592 #define declare_idct(idct,table,idct_row_head,idct_row,idct_row_tail,idct_row_mid) \
593 void idct (int16_t * const block) \
595 DECLARE_ALIGNED(16, static const int16_t, table04)[] = \
596 table (22725, 21407, 19266, 16384, 12873, 8867, 4520); \
597 DECLARE_ALIGNED(16, static const int16_t, table17)[] = \
598 table (31521, 29692, 26722, 22725, 17855, 12299, 6270); \
599 DECLARE_ALIGNED(16, static const int16_t, table26)[] = \
600 table (29692, 27969, 25172, 21407, 16819, 11585, 5906); \
601 DECLARE_ALIGNED(16, static const int16_t, table35)[] = \
602 table (26722, 25172, 22654, 19266, 15137, 10426, 5315); \
604 idct_row_head (block, 0*8, table04); \
605 idct_row (table04, rounder0); \
606 idct_row_mid (block, 0*8, 4*8, table04); \
607 idct_row (table04, rounder4); \
608 idct_row_mid (block, 4*8, 1*8, table17); \
609 idct_row (table17, rounder1); \
610 idct_row_mid (block, 1*8, 7*8, table17); \
611 idct_row (table17, rounder7); \
612 idct_row_mid (block, 7*8, 2*8, table26); \
613 idct_row (table26, rounder2); \
614 idct_row_mid (block, 2*8, 6*8, table26); \
615 idct_row (table26, rounder6); \
616 idct_row_mid (block, 6*8, 3*8, table35); \
617 idct_row (table35, rounder3); \
618 idct_row_mid (block, 3*8, 5*8, table35); \
619 idct_row (table35, rounder5); \
620 idct_row_tail (block, 5*8); \
622 idct_col (block, 0); \
623 idct_col (block, 4); \
627 mmxext_row_head, mmxext_row, mmxext_row_tail, mmxext_row_mid)
630 mmx_row_head, mmx_row, mmx_row_tail, mmx_row_mid)