Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
27 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
33 #include <liboil/liboilfunction.h>
34 #include "liboil/dct/dct.h"
44 * Performs a Inverse Discrete Cosine Transform on @s_8 and places
47 OIL_DEFINE_CLASS (idct8_f64, "double *d_8, int dstr, double *s_8, int sstr");
49 #define C0_9808 0.980785280
50 #define C0_9239 0.923879532
51 #define C0_8315 0.831469612
52 #define C0_7071 0.707106781
53 #define C0_5556 0.555570233
54 #define C0_3827 0.382683432
55 #define C0_1951 0.195090322
57 static void idct8_f64_ref(double *dest, int dstr, const double *src, int sstr)
59 static double idct_coeff[8][8];
60 static int idct_coeff_init = 0;
68 scale = (i==0) ? sqrt(0.125) : 0.5;
70 idct_coeff[j][i] = scale *
71 cos((M_PI/8)*i*(j+0.5));
80 x += idct_coeff[i][j] * OIL_GET (src, sstr*j, double);
82 OIL_GET (dest, dstr*i, double) = x;
86 OIL_DEFINE_IMPL_REF (idct8_f64_ref, idct8_f64);
89 static void idct8_f64_fastx(double *dest, int dstr, const double *src, int sstr)
91 double s07, s16, s25, s34;
92 double d07, d16, d25, d34;
93 double ss07s34, ss16s25;
94 double ds07s34, ds16s25;
96 ss07s34 = C0_7071*(OIL_GET(src,sstr*0, double) + OIL_GET(src,sstr*4, double));
97 ss16s25 = C0_7071*(OIL_GET(src,sstr*0, double) - OIL_GET(src,sstr*4, double));
99 ds07s34 = C0_9239* OIL_GET(src,sstr*2, double) + C0_3827* OIL_GET(src,sstr*6, double);
100 ds16s25 = C0_3827* OIL_GET(src,sstr*2, double) - C0_9239* OIL_GET(src,sstr*6, double);
102 s07 = ss07s34 + ds07s34;
103 s34 = ss07s34 - ds07s34;
105 s16 = ss16s25 + ds16s25;
106 s25 = ss16s25 - ds16s25;
108 d07 = C0_9808* OIL_GET(src,sstr*1, double) + C0_8315* OIL_GET(src,sstr*3, double)
109 + C0_5556* OIL_GET(src,sstr*5, double) + C0_1951* OIL_GET(src,sstr*7, double);
110 d16 = C0_8315* OIL_GET(src,sstr*1, double) - C0_1951* OIL_GET(src,sstr*3, double)
111 - C0_9808* OIL_GET(src,sstr*5, double) - C0_5556* OIL_GET(src,sstr*7, double);
112 d25 = C0_5556* OIL_GET(src,sstr*1, double) - C0_9808* OIL_GET(src,sstr*3, double)
113 + C0_1951* OIL_GET(src,sstr*5, double) + C0_8315* OIL_GET(src,sstr*7, double);
114 d34 = C0_1951* OIL_GET(src,sstr*1, double) - C0_5556* OIL_GET(src,sstr*3, double)
115 + C0_8315* OIL_GET(src,sstr*5, double) - C0_9808* OIL_GET(src,sstr*7, double);
117 OIL_GET(dest,dstr*0, double) = 0.5 * (s07 + d07);
118 OIL_GET(dest,dstr*1, double) = 0.5 * (s16 + d16);
119 OIL_GET(dest,dstr*2, double) = 0.5 * (s25 + d25);
120 OIL_GET(dest,dstr*3, double) = 0.5 * (s34 + d34);
121 OIL_GET(dest,dstr*4, double) = 0.5 * (s34 - d34);
122 OIL_GET(dest,dstr*5, double) = 0.5 * (s25 - d25);
123 OIL_GET(dest,dstr*6, double) = 0.5 * (s16 - d16);
124 OIL_GET(dest,dstr*7, double) = 0.5 * (s07 - d07);
128 OIL_DEFINE_IMPL (idct8_f64_fastx, idct8_f64);
135 OilFunctionClass* __oil_function_class_idct8_f64() {
136 return &_oil_function_class_idct8_f64;
144 OilFunctionImpl* __oil_function_impl_idct8_f64_ref() {
145 return &_oil_function_impl_idct8_f64_ref;
151 OilFunctionImpl* __oil_function_impl_idct8_f64_fastx() {
152 return &_oil_function_impl_idct8_f64_fastx;
160 EXPORT_C void** _oil_function_class_ptr_idct8_f64 () {
161 oil_function_class_ptr_idct8_f64 = __oil_function_class_idct8_f64();
162 return &oil_function_class_ptr_idct8_f64->func;