1 /*
2 * Floating point AAN DCT
3 * this implementation is based upon the IJG integer AAN DCT (see jfdctfst.c)
4 *
5 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
6 * Copyright (c) 2003 Roman Shaposhnik
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21 /**
22 * @file
23 * @brief
24 * Floating point AAN DCT
25 * @author Michael Niedermayer <michaelni@gmx.at>
26 */
27
32
34
35 /* numbers generated by arbitrary precision arithmetic followed by truncation
36 to 36 fractional digits (enough for a 128-bit IEEE quad, see /usr/include/math.h
37 for this approach). Unfortunately, long double is not always available correctly,
38 e.g ppc has issues.
39 TODO: add L suffixes when ppc and toolchains sort out their stuff.
40 */
41 #define B0 1.000000000000000000000000000000000000
42 #define B1 0.720959822006947913789091890943021267 // (cos(pi*1/16)sqrt(2))^-1
43 #define B2 0.765366864730179543456919968060797734 // (cos(pi*2/16)sqrt(2))^-1
44 #define B3 0.850430094767256448766702844371412325 // (cos(pi*3/16)sqrt(2))^-1
45 #define B4 1.000000000000000000000000000000000000 // (cos(pi*4/16)sqrt(2))^-1
46 #define B5 1.272758580572833938461007018281767032 // (cos(pi*5/16)sqrt(2))^-1
47 #define B6 1.847759065022573512256366378793576574 // (cos(pi*6/16)sqrt(2))^-1
48 #define B7 3.624509785411551372409941227504289587 // (cos(pi*7/16)sqrt(2))^-1
49
50 #define A1 M_SQRT1_2 // cos(pi*4/16)
51 #define A2 0.54119610014619698435 // cos(pi*6/16)sqrt(2)
52 #define A5 0.38268343236508977170 // cos(pi*6/16)
53 #define A4 1.30656296487637652774 // cos(pi*2/16)sqrt(2)
54
64 };
65
67 {
68 FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
69 FLOAT tmp10, tmp11, tmp12, tmp13;
70 FLOAT z2, z4, z11, z13;
72
73 for (
i=0;
i<8*8;
i+=8) {
82
83 tmp10= tmp0 + tmp3;
84 tmp13= tmp0 - tmp3;
85 tmp11= tmp1 + tmp2;
86 tmp12= tmp1 - tmp2;
87
88 temp[0 +
i]= tmp10 + tmp11;
89 temp[4 +
i]= tmp10 - tmp11;
90
91 tmp12 += tmp13;
93 temp[2 +
i]= tmp13 + tmp12;
94 temp[6 +
i]= tmp13 - tmp12;
95
96 tmp4 += tmp5;
97 tmp5 += tmp6;
98 tmp6 += tmp7;
99
100 z2= tmp4*(
A2+
A5) - tmp6*
A5;
101 z4= tmp6*(
A4-
A5) + tmp4*
A5;
102
104
105 z11= tmp7 + tmp5;
106 z13= tmp7 - tmp5;
107
108 temp[5 +
i]= z13 + z2;
109 temp[3 +
i]= z13 - z2;
110 temp[1 +
i]= z11 + z4;
111 temp[7 +
i]= z11 - z4;
112 }
113 }
114
116 {
117 FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
118 FLOAT tmp10, tmp11, tmp12, tmp13;
119 FLOAT z2, z4, z11, z13;
122
124
126
127 for (
i=0;
i<8;
i++) {
136
137 tmp10= tmp0 + tmp3;
138 tmp13= tmp0 - tmp3;
139 tmp11= tmp1 + tmp2;
140 tmp12= tmp1 - tmp2;
141
144
145 tmp12 += tmp13;
149
150 tmp4 += tmp5;
151 tmp5 += tmp6;
152 tmp6 += tmp7;
153
154 z2= tmp4*(
A2+
A5) - tmp6*
A5;
155 z4= tmp6*(
A4-
A5) + tmp4*
A5;
156
158
159 z11= tmp7 + tmp5;
160 z13= tmp7 - tmp5;
161
166 }
167 }
168
170 {
171 FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
172 FLOAT tmp10, tmp11, tmp12, tmp13;
175
177
179
180 for (
i=0;
i<8;
i++) {
189
190 tmp10 = tmp0 + tmp3;
191 tmp11 = tmp1 + tmp2;
192 tmp12 = tmp1 - tmp2;
193 tmp13 = tmp0 - tmp3;
194
197
198 tmp12 += tmp13;
202
203 tmp10 = tmp4 + tmp7;
204 tmp11 = tmp5 + tmp6;
205 tmp12 = tmp5 - tmp6;
206 tmp13 = tmp4 - tmp7;
207
210
211 tmp12 += tmp13;
215 }
216 }