1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/dct/idct8_f64.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,165 @@
1.4 +/*
1.5 + * LIBOIL - Library of Optimized Inner Loops
1.6 + * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
1.7 + * All rights reserved.
1.8 + *
1.9 + * Redistribution and use in source and binary forms, with or without
1.10 + * modification, are permitted provided that the following conditions
1.11 + * are met:
1.12 + * 1. Redistributions of source code must retain the above copyright
1.13 + * notice, this list of conditions and the following disclaimer.
1.14 + * 2. Redistributions in binary form must reproduce the above copyright
1.15 + * notice, this list of conditions and the following disclaimer in the
1.16 + * documentation and/or other materials provided with the distribution.
1.17 + *
1.18 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1.19 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1.20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.21 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
1.22 + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1.23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1.24 + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.25 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.26 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
1.27 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1.28 + * POSSIBILITY OF SUCH DAMAGE.
1.29 + */
1.30 +//Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.31 +
1.32 +#ifdef HAVE_CONFIG_H
1.33 +#include "config.h"
1.34 +#endif
1.35 +
1.36 +#include <liboil/liboilfunction.h>
1.37 +#include "liboil/dct/dct.h"
1.38 +#include <math.h>
1.39 +
1.40 +/**
1.41 + * oil_idct8_f64:
1.42 + * @d_8:
1.43 + * @dstr:
1.44 + * @s_8:
1.45 + * @sstr:
1.46 + *
1.47 + * Performs a Inverse Discrete Cosine Transform on @s_8 and places
1.48 + * the result in @d_8.
1.49 + */
1.50 +OIL_DEFINE_CLASS (idct8_f64, "double *d_8, int dstr, double *s_8, int sstr");
1.51 +
1.52 +#define C0_9808 0.980785280
1.53 +#define C0_9239 0.923879532
1.54 +#define C0_8315 0.831469612
1.55 +#define C0_7071 0.707106781
1.56 +#define C0_5556 0.555570233
1.57 +#define C0_3827 0.382683432
1.58 +#define C0_1951 0.195090322
1.59 +
1.60 +static void idct8_f64_ref(double *dest, int dstr, const double *src, int sstr)
1.61 +{
1.62 + static double idct_coeff[8][8];
1.63 + static int idct_coeff_init = 0;
1.64 + int i,j;
1.65 + double x;
1.66 +
1.67 + if(!idct_coeff_init){
1.68 + double scale;
1.69 +
1.70 + for(i=0;i<8;i++){
1.71 + scale = (i==0) ? sqrt(0.125) : 0.5;
1.72 + for(j=0;j<8;j++){
1.73 + idct_coeff[j][i] = scale *
1.74 + cos((M_PI/8)*i*(j+0.5));
1.75 + }
1.76 + }
1.77 + idct_coeff_init = 1;
1.78 + }
1.79 +
1.80 + for(i=0;i<8;i++){
1.81 + x = 0;
1.82 + for(j=0;j<8;j++){
1.83 + x += idct_coeff[i][j] * OIL_GET (src, sstr*j, double);
1.84 + }
1.85 + OIL_GET (dest, dstr*i, double) = x;
1.86 + }
1.87 +}
1.88 +
1.89 +OIL_DEFINE_IMPL_REF (idct8_f64_ref, idct8_f64);
1.90 +
1.91 +
1.92 +static void idct8_f64_fastx(double *dest, int dstr, const double *src, int sstr)
1.93 +{
1.94 + double s07, s16, s25, s34;
1.95 + double d07, d16, d25, d34;
1.96 + double ss07s34, ss16s25;
1.97 + double ds07s34, ds16s25;
1.98 +
1.99 + ss07s34 = C0_7071*(OIL_GET(src,sstr*0, double) + OIL_GET(src,sstr*4, double));
1.100 + ss16s25 = C0_7071*(OIL_GET(src,sstr*0, double) - OIL_GET(src,sstr*4, double));
1.101 +
1.102 + ds07s34 = C0_9239* OIL_GET(src,sstr*2, double) + C0_3827* OIL_GET(src,sstr*6, double);
1.103 + ds16s25 = C0_3827* OIL_GET(src,sstr*2, double) - C0_9239* OIL_GET(src,sstr*6, double);
1.104 +
1.105 + s07 = ss07s34 + ds07s34;
1.106 + s34 = ss07s34 - ds07s34;
1.107 +
1.108 + s16 = ss16s25 + ds16s25;
1.109 + s25 = ss16s25 - ds16s25;
1.110 +
1.111 + d07 = C0_9808* OIL_GET(src,sstr*1, double) + C0_8315* OIL_GET(src,sstr*3, double)
1.112 + + C0_5556* OIL_GET(src,sstr*5, double) + C0_1951* OIL_GET(src,sstr*7, double);
1.113 + d16 = C0_8315* OIL_GET(src,sstr*1, double) - C0_1951* OIL_GET(src,sstr*3, double)
1.114 + - C0_9808* OIL_GET(src,sstr*5, double) - C0_5556* OIL_GET(src,sstr*7, double);
1.115 + d25 = C0_5556* OIL_GET(src,sstr*1, double) - C0_9808* OIL_GET(src,sstr*3, double)
1.116 + + C0_1951* OIL_GET(src,sstr*5, double) + C0_8315* OIL_GET(src,sstr*7, double);
1.117 + d34 = C0_1951* OIL_GET(src,sstr*1, double) - C0_5556* OIL_GET(src,sstr*3, double)
1.118 + + C0_8315* OIL_GET(src,sstr*5, double) - C0_9808* OIL_GET(src,sstr*7, double);
1.119 +
1.120 + OIL_GET(dest,dstr*0, double) = 0.5 * (s07 + d07);
1.121 + OIL_GET(dest,dstr*1, double) = 0.5 * (s16 + d16);
1.122 + OIL_GET(dest,dstr*2, double) = 0.5 * (s25 + d25);
1.123 + OIL_GET(dest,dstr*3, double) = 0.5 * (s34 + d34);
1.124 + OIL_GET(dest,dstr*4, double) = 0.5 * (s34 - d34);
1.125 + OIL_GET(dest,dstr*5, double) = 0.5 * (s25 - d25);
1.126 + OIL_GET(dest,dstr*6, double) = 0.5 * (s16 - d16);
1.127 + OIL_GET(dest,dstr*7, double) = 0.5 * (s07 - d07);
1.128 +
1.129 +}
1.130 +
1.131 +OIL_DEFINE_IMPL (idct8_f64_fastx, idct8_f64);
1.132 +
1.133 +
1.134 +
1.135 +
1.136 +#ifdef __SYMBIAN32__
1.137 +
1.138 +OilFunctionClass* __oil_function_class_idct8_f64() {
1.139 + return &_oil_function_class_idct8_f64;
1.140 +}
1.141 +#endif
1.142 +
1.143 +
1.144 +
1.145 +#ifdef __SYMBIAN32__
1.146 +
1.147 +OilFunctionImpl* __oil_function_impl_idct8_f64_ref() {
1.148 + return &_oil_function_impl_idct8_f64_ref;
1.149 +}
1.150 +#endif
1.151 +
1.152 +#ifdef __SYMBIAN32__
1.153 +
1.154 +OilFunctionImpl* __oil_function_impl_idct8_f64_fastx() {
1.155 + return &_oil_function_impl_idct8_f64_fastx;
1.156 +}
1.157 +#endif
1.158 +
1.159 +
1.160 +
1.161 +#ifdef __SYMBIAN32__
1.162 +
1.163 +EXPORT_C void** _oil_function_class_ptr_idct8_f64 () {
1.164 + oil_function_class_ptr_idct8_f64 = __oil_function_class_idct8_f64();
1.165 + return &oil_function_class_ptr_idct8_f64->func;
1.166 + }
1.167 +#endif
1.168 +