os/ossrv/genericopenlibs/liboil/src/dct/idct8_f64.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2  * LIBOIL - Library of Optimized Inner Loops
     3  * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
     4  * All rights reserved.
     5  *
     6  * Redistribution and use in source and binary forms, with or without
     7  * modification, are permitted provided that the following conditions
     8  * are met:
     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.
    14  * 
    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.
    26  */
    27 //Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    28 
    29 #ifdef HAVE_CONFIG_H
    30 #include "config.h"
    31 #endif
    32 
    33 #include <liboil/liboilfunction.h>
    34 #include "liboil/dct/dct.h"
    35 #include <math.h>
    36 
    37 /**
    38  * oil_idct8_f64:
    39  * @d_8:
    40  * @dstr:
    41  * @s_8:
    42  * @sstr:
    43  *
    44  * Performs a Inverse Discrete Cosine Transform on @s_8 and places
    45  * the result in @d_8.
    46  */
    47 OIL_DEFINE_CLASS (idct8_f64, "double *d_8, int dstr, double *s_8, int sstr");
    48 
    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
    56 
    57 static void idct8_f64_ref(double *dest, int dstr, const double *src, int sstr)
    58 {
    59 	static double idct_coeff[8][8];
    60 	static int idct_coeff_init = 0;
    61 	int i,j;
    62 	double x;
    63 
    64 	if(!idct_coeff_init){
    65 		double scale;
    66 
    67 		for(i=0;i<8;i++){
    68 			scale = (i==0) ? sqrt(0.125) : 0.5;
    69 			for(j=0;j<8;j++){
    70 				idct_coeff[j][i] = scale *
    71 					cos((M_PI/8)*i*(j+0.5));
    72 			}
    73 		}
    74 		idct_coeff_init = 1;
    75 	}
    76 
    77 	for(i=0;i<8;i++){
    78 		x = 0;
    79 		for(j=0;j<8;j++){
    80 			x += idct_coeff[i][j] * OIL_GET (src, sstr*j, double);
    81 		}
    82 		OIL_GET (dest, dstr*i, double) = x;
    83 	}
    84 }
    85 
    86 OIL_DEFINE_IMPL_REF (idct8_f64_ref, idct8_f64);
    87 
    88 
    89 static void idct8_f64_fastx(double *dest, int dstr, const double *src, int sstr)
    90 {
    91 	double s07, s16, s25, s34;
    92 	double d07, d16, d25, d34;
    93 	double ss07s34, ss16s25;
    94 	double ds07s34, ds16s25;
    95 
    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));
    98 
    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);
   101 
   102 	s07 = ss07s34 + ds07s34;
   103 	s34 = ss07s34 - ds07s34;
   104 
   105 	s16 = ss16s25 + ds16s25;
   106 	s25 = ss16s25 - ds16s25;
   107 
   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);
   116 
   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);
   125 
   126 }
   127 
   128 OIL_DEFINE_IMPL (idct8_f64_fastx, idct8_f64);
   129 
   130 
   131 
   132 
   133 #ifdef	__SYMBIAN32__
   134  
   135 OilFunctionClass* __oil_function_class_idct8_f64() {
   136 		return &_oil_function_class_idct8_f64;
   137 }
   138 #endif
   139 
   140 
   141 
   142 #ifdef	__SYMBIAN32__
   143  
   144 OilFunctionImpl* __oil_function_impl_idct8_f64_ref() {
   145 		return &_oil_function_impl_idct8_f64_ref;
   146 }
   147 #endif
   148 
   149 #ifdef	__SYMBIAN32__
   150  
   151 OilFunctionImpl* __oil_function_impl_idct8_f64_fastx() {
   152 		return &_oil_function_impl_idct8_f64_fastx;
   153 }
   154 #endif
   155 
   156 
   157 
   158 #ifdef	__SYMBIAN32__
   159  
   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;
   163 	}
   164 #endif
   165