annotate alpha/simple_idct_alpha.c @ 886:3abff5a87548 libavcodec

warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
author michael
date Sat, 23 Nov 2002 10:58:05 +0000
parents 2f7da29ede37
children 3dbbdc2f8bd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
744
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
1 /*
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
2 * Simple IDCT (Alpha optimized)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
3 *
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
4 * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at>
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
5 *
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
10 *
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful,
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
14 * Lesser General Public License for more details.
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
15 *
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
17 * License along with this library; if not, write to the Free Software
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
19 *
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
20 * based upon some outcommented c code from mpeg2dec (idct_mmx.c
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
21 * written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
22 *
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
23 * Alpha optimiziations by Mns Rullgrd <mru@users.sourceforge.net>
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
24 * and Falk Hueffner <falk@debian.org>
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
25 */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
26
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
27 #include "asm.h"
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
28 #include "../dsputil.h"
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
29
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
30 // cos(i * M_PI / 16) * sqrt(2) * (1 << 14)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
31 // W4 is actually exactly 16384, but using 16383 works around
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
32 // accumulating rounding errors for some encoders
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
33 #define W1 ((int_fast32_t) 22725)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
34 #define W2 ((int_fast32_t) 21407)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
35 #define W3 ((int_fast32_t) 19266)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
36 #define W4 ((int_fast32_t) 16383)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
37 #define W5 ((int_fast32_t) 12873)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
38 #define W6 ((int_fast32_t) 8867)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
39 #define W7 ((int_fast32_t) 4520)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
40 #define ROW_SHIFT 11
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
41 #define COL_SHIFT 20
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
42
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
43 /* 0: all entries 0, 1: only first entry nonzero, 2: otherwise */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
44 static inline int idct_row(DCTELEM *row)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
45 {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
46 int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3, t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
47 uint64_t l, r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
48 l = ldq(row);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
49 r = ldq(row + 4);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
50
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
51 if (l == 0 && r == 0)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
52 return 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
53
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
54 a0 = W4 * sextw(l) + (1 << (ROW_SHIFT - 1));
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
55
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
56 if (((l & ~0xffffUL) | r) == 0) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
57 a0 >>= ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
58 a0 = (uint16_t) a0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
59 a0 |= a0 << 16;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
60 a0 |= a0 << 32;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
61
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
62 stq(a0, row);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
63 stq(a0, row + 4);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
64 return 1;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
65 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
66
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
67 a1 = a0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
68 a2 = a0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
69 a3 = a0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
70
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
71 t = extwl(l, 4); /* row[2] */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
72 if (t != 0) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
73 t = sextw(t);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
74 a0 += W2 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
75 a1 += W6 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
76 a2 -= W6 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
77 a3 -= W2 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
78 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
79
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
80 t = extwl(r, 0); /* row[4] */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
81 if (t != 0) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
82 t = sextw(t);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
83 a0 += W4 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
84 a1 -= W4 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
85 a2 -= W4 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
86 a3 += W4 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
87 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
88
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
89 t = extwl(r, 4); /* row[6] */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
90 if (t != 0) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
91 t = sextw(t);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
92 a0 += W6 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
93 a1 -= W2 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
94 a2 += W2 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
95 a3 -= W6 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
96 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
97
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
98 t = extwl(l, 2); /* row[1] */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
99 if (t != 0) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
100 t = sextw(t);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
101 b0 = W1 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
102 b1 = W3 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
103 b2 = W5 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
104 b3 = W7 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
105 } else {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
106 b0 = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
107 b1 = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
108 b2 = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
109 b3 = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
110 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
111
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
112 t = extwl(l, 6); /* row[3] */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
113 if (t) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
114 t = sextw(t);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
115 b0 += W3 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
116 b1 -= W7 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
117 b2 -= W1 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
118 b3 -= W5 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
119 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
120
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
121
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
122 t = extwl(r, 2); /* row[5] */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
123 if (t) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
124 t = sextw(t);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
125 b0 += W5 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
126 b1 -= W1 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
127 b2 += W7 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
128 b3 += W3 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
129 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
130
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
131 t = extwl(r, 6); /* row[7] */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
132 if (t) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
133 t = sextw(t);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
134 b0 += W7 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
135 b1 -= W5 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
136 b2 += W3 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
137 b3 -= W1 * t;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
138 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
139
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
140 row[0] = (a0 + b0) >> ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
141 row[1] = (a1 + b1) >> ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
142 row[2] = (a2 + b2) >> ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
143 row[3] = (a3 + b3) >> ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
144 row[4] = (a3 - b3) >> ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
145 row[5] = (a2 - b2) >> ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
146 row[6] = (a1 - b1) >> ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
147 row[7] = (a0 - b0) >> ROW_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
148
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
149 return 2;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
150 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
151
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
152 static inline void idct_col(DCTELEM *col)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
153 {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
154 int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
155
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
156 col[0] += (1 << (COL_SHIFT - 1)) / W4;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
157
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
158 a0 = W4 * col[8 * 0];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
159 a1 = W4 * col[8 * 0];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
160 a2 = W4 * col[8 * 0];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
161 a3 = W4 * col[8 * 0];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
162
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
163 if (col[8 * 2]) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
164 a0 += W2 * col[8 * 2];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
165 a1 += W6 * col[8 * 2];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
166 a2 -= W6 * col[8 * 2];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
167 a3 -= W2 * col[8 * 2];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
168 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
169
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
170 if (col[8 * 4]) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
171 a0 += W4 * col[8 * 4];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
172 a1 -= W4 * col[8 * 4];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
173 a2 -= W4 * col[8 * 4];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
174 a3 += W4 * col[8 * 4];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
175 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
176
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
177 if (col[8 * 6]) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
178 a0 += W6 * col[8 * 6];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
179 a1 -= W2 * col[8 * 6];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
180 a2 += W2 * col[8 * 6];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
181 a3 -= W6 * col[8 * 6];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
182 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
183
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
184 if (col[8 * 1]) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
185 b0 = W1 * col[8 * 1];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
186 b1 = W3 * col[8 * 1];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
187 b2 = W5 * col[8 * 1];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
188 b3 = W7 * col[8 * 1];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
189 } else {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
190 b0 = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
191 b1 = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
192 b2 = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
193 b3 = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
194 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
195
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
196 if (col[8 * 3]) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
197 b0 += W3 * col[8 * 3];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
198 b1 -= W7 * col[8 * 3];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
199 b2 -= W1 * col[8 * 3];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
200 b3 -= W5 * col[8 * 3];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
201 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
202
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
203 if (col[8 * 5]) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
204 b0 += W5 * col[8 * 5];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
205 b1 -= W1 * col[8 * 5];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
206 b2 += W7 * col[8 * 5];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
207 b3 += W3 * col[8 * 5];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
208 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
209
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
210 if (col[8 * 7]) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
211 b0 += W7 * col[8 * 7];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
212 b1 -= W5 * col[8 * 7];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
213 b2 += W3 * col[8 * 7];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
214 b3 -= W1 * col[8 * 7];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
215 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
216
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
217 col[8 * 0] = (a0 + b0) >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
218 col[8 * 7] = (a0 - b0) >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
219 col[8 * 1] = (a1 + b1) >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
220 col[8 * 6] = (a1 - b1) >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
221 col[8 * 2] = (a2 + b2) >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
222 col[8 * 5] = (a2 - b2) >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
223 col[8 * 3] = (a3 + b3) >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
224 col[8 * 4] = (a3 - b3) >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
225 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
226
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
227 /* If all rows but the first one are zero after row transformation,
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
228 all rows will be identical after column transformation. */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
229 static inline void idct_col2(DCTELEM *col)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
230 {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
231 int i;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
232 uint64_t l, r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
233 uint64_t *lcol = (uint64_t *) col;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
234
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
235 for (i = 0; i < 8; ++i) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
236 int_fast32_t a0 = col[0] + (1 << (COL_SHIFT - 1)) / W4;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
237
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
238 a0 *= W4;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
239 col[0] = a0 >> COL_SHIFT;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
240 ++col;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
241 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
242
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
243 l = lcol[0];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
244 r = lcol[1];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
245 lcol[ 2] = l; lcol[ 3] = r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
246 lcol[ 4] = l; lcol[ 5] = r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
247 lcol[ 6] = l; lcol[ 7] = r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
248 lcol[ 8] = l; lcol[ 9] = r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
249 lcol[10] = l; lcol[11] = r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
250 lcol[12] = l; lcol[13] = r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
251 lcol[14] = l; lcol[15] = r;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
252 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
253
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
254 void simple_idct_axp(DCTELEM *block)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
255 {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
256
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
257 int i;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
258 int rowsZero = 1; /* all rows except row 0 zero */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
259 int rowsConstant = 1; /* all rows consist of a constant value */
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
260
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
261 for (i = 0; i < 8; i++) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
262 int sparseness = idct_row(block + 8 * i);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
263
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
264 if (i > 0 && sparseness > 0)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
265 rowsZero = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
266 if (sparseness == 2)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
267 rowsConstant = 0;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
268 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
269
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
270 if (rowsZero) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
271 idct_col2(block);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
272 } else if (rowsConstant) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
273 uint64_t *lblock = (uint64_t *) block;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
274
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
275 idct_col(block);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
276 for (i = 0; i < 8; i += 2) {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
277 uint64_t v = (uint16_t) block[i * 8];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
278 uint64_t w = (uint16_t) block[i * 8 + 8];
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
279
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
280 v |= v << 16;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
281 w |= w << 16;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
282 v |= v << 32;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
283 w |= w << 32;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
284 lblock[0] = v;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
285 lblock[1] = v;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
286 lblock[2] = w;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
287 lblock[3] = w;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
288 lblock += 4;
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
289 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
290 } else {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
291 for (i = 0; i < 8; i++)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
292 idct_col(block + i);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
293 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
294 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
295
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
296 void simple_idct_put_axp(uint8_t *dest, int line_size, DCTELEM *block)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
297 {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
298 simple_idct_axp(block);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
299 put_pixels_clamped(block, dest, line_size);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
300 }
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
301
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
302 void simple_idct_add_axp(uint8_t *dest, int line_size, DCTELEM *block)
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
303 {
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
304 simple_idct_axp(block);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
305 add_pixels_clamped(block, dest, line_size);
2f7da29ede37 Move Alpha optimized IDCT to own file. Based on a patch by Mns
mellum
parents:
diff changeset
306 }