os/ossrv/genericopenlibs/liboil/src/dct/idct8x8theora_ref.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/dct/idct8x8theora_ref.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,254 @@
     1.4 +/*
     1.5 + * LIBOIL - Library of Optimized Inner Loops
     1.6 + * Copyright (c) 2001,2002,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/liboil.h>
    1.37 +#include <liboil/liboiltest.h>
    1.38 +#include <liboil/liboilrandom.h>
    1.39 +#include "liboil/dct/dct.h"
    1.40 +#include <math.h>
    1.41 +
    1.42 +#ifdef __SYMBIAN32__
    1.43 +#ifdef __WINSCW__
    1.44 +#pragma warn_unusedarg off 
    1.45 +#endif//__WINSCW__
    1.46 +#endif//__SYMBIAN32__
    1.47 +
    1.48 +static void
    1.49 +idct8theora_s16_test (OilTest *test)
    1.50 +{
    1.51 +  int i;
    1.52 +  int stride = test->params[OIL_ARG_SSTR1].value;
    1.53 +  uint16_t *ptr = (uint16_t *)oil_test_get_source_data(test,OIL_ARG_SRC1);
    1.54 +
    1.55 +  for(i=0;i<8;i++){
    1.56 +    OIL_GET(ptr, i*stride, int16_t) = oil_rand_s16() >> 3;
    1.57 +    //OIL_GET(ptr, i*stride, int16_t) = 0;
    1.58 +  }
    1.59 +  //OIL_GET(ptr, 0*stride, int16_t) = 100;
    1.60 +
    1.61 +}
    1.62 +
    1.63 +static void
    1.64 +idct8x8theora_s16_test (OilTest *test)
    1.65 +{
    1.66 +  int i;
    1.67 +  int j;
    1.68 +  int stride = test->params[OIL_ARG_SSTR1].value;
    1.69 +  uint16_t *ptr = (uint16_t *)oil_test_get_source_data(test,OIL_ARG_SRC1);
    1.70 +
    1.71 +  for(i=0;i<8;i++){
    1.72 +    for(j=0;j<8;j++){
    1.73 +      OIL_GET(ptr, i*stride + j*2, int16_t) = oil_rand_s16() >> 3;
    1.74 +    }
    1.75 +  }
    1.76 +
    1.77 +}
    1.78 +
    1.79 +/**
    1.80 + * oil_idct8theora_s16:
    1.81 + * @d_8:
    1.82 + * @dstr:
    1.83 + * @s_8:
    1.84 + * @sstr:
    1.85 + *
    1.86 + * Performs a Inverse Discrete Cosine Transform on @s_8 and places
    1.87 + * the result in @d_8, as defined by the Theora specification.
    1.88 + */
    1.89 +OIL_DEFINE_CLASS_FULL (idct8theora_s16, "int16_t *d_8, int dstr, int16_t *s_8, int sstr", idct8theora_s16_test);
    1.90 +/**
    1.91 + * oil_idct8x8theora_s16:
    1.92 + * @d_8x8:
    1.93 + * @dstr:
    1.94 + * @s_8x8:
    1.95 + * @sstr:
    1.96 + *
    1.97 + * Performs a Inverse Discrete Cosine Transform on @s_8x8 and places
    1.98 + * the result in @d_8x8, as defined by the Theora specification.
    1.99 + */
   1.100 +OIL_DEFINE_CLASS_FULL (idct8x8theora_s16, "int16_t *d_8x8, int dstr, int16_t *s_8x8, int sstr", idct8x8theora_s16_test);
   1.101 +
   1.102 +
   1.103 +
   1.104 +#define C1 64277
   1.105 +#define C2 60547
   1.106 +#define C3 54491
   1.107 +#define C4 46341
   1.108 +#define C5 36410
   1.109 +#define C6 25080
   1.110 +#define C7 12785
   1.111 +
   1.112 +#define S7 64277
   1.113 +#define S6 60547
   1.114 +#define S5 54491
   1.115 +#define S4 46341
   1.116 +#define S3 36410
   1.117 +#define S2 25080
   1.118 +#define S1 12785
   1.119 +
   1.120 +#define TRUNC(x) ((int16_t)x)
   1.121 +#define MULT(a,b) (((a)*(b))>>16)
   1.122 +
   1.123 +static void
   1.124 +idct8theora_s16_ref (int16_t *dest, int dstr, const int16_t *src, int sstr)
   1.125 +{
   1.126 +  int32_t t[10];
   1.127 +  int32_t r;
   1.128 +
   1.129 +#define Y(i) OIL_GET(src,sstr*(i),int16_t)
   1.130 +#define X(i) OIL_GET(dest,sstr*(i),int16_t)
   1.131 +
   1.132 +  /* the ordering here corresponds closely to the theora spec */
   1.133 +  t[0] = MULT(C4, Y(0) + Y(4));
   1.134 +  t[0] = TRUNC(t[0]);
   1.135 +  t[1] = MULT(C4, Y(0) - Y(4));
   1.136 +  t[1] = TRUNC(t[1]);
   1.137 +  t[2] = MULT(C6, Y(2)) - MULT(S6, Y(6));
   1.138 +  t[3] = MULT(S6, Y(2)) + MULT(C6, Y(6));
   1.139 +  t[4] = MULT(C7, Y(1)) - MULT(S7, Y(7));
   1.140 +  t[5] = MULT(C3, Y(5)) - MULT(S3, Y(3));
   1.141 +  t[6] = MULT(S3, Y(5)) + MULT(C3, Y(3));
   1.142 +  t[7] = MULT(S7, Y(1)) + MULT(C7, Y(7));
   1.143 +  r = t[4] + t[5];
   1.144 +  t[5] = MULT(C4, t[4] - t[5]);
   1.145 +  t[5] = TRUNC(t[5]);
   1.146 +  t[4] = r;
   1.147 +  r = t[7] + t[6];
   1.148 +  t[6] = MULT(C4, t[7] - t[6]);
   1.149 +  t[6] = TRUNC(t[6]);
   1.150 +  t[7] = r;
   1.151 +  r = t[0] + t[3];
   1.152 +  t[3] = t[0] - t[3];
   1.153 +  t[0] = r;
   1.154 +  r = t[1] + t[2];
   1.155 +  t[2] = t[1] - t[2];
   1.156 +  t[1] = r;
   1.157 +  r = t[6] + t[5];
   1.158 +  t[5] = t[6] - t[5];
   1.159 +  t[6] = r;
   1.160 +  r = t[0] + t[7];
   1.161 +  r = TRUNC(r);
   1.162 +  X(0) = r;
   1.163 +  r = t[1] + t[6];
   1.164 +  r = TRUNC(r);
   1.165 +  X(1) = r;
   1.166 +  r = t[2] + t[5];
   1.167 +  r = TRUNC(r);
   1.168 +  X(2) = r;
   1.169 +  r = t[3] + t[4];
   1.170 +  r = TRUNC(r);
   1.171 +  X(3) = r;
   1.172 +  r = t[3] - t[4];
   1.173 +  r = TRUNC(r);
   1.174 +  X(4) = r;
   1.175 +  r = t[2] - t[5];
   1.176 +  r = TRUNC(r);
   1.177 +  X(5) = r;
   1.178 +  r = t[1] - t[6];
   1.179 +  r = TRUNC(r);
   1.180 +  X(6) = r;
   1.181 +  r = t[0] - t[7];
   1.182 +  r = TRUNC(r);
   1.183 +  X(7) = r;
   1.184 +}
   1.185 +OIL_DEFINE_IMPL_REF (idct8theora_s16_ref, idct8theora_s16);
   1.186 +
   1.187 +
   1.188 +static void
   1.189 +idct8x8theora_s16_ref (int16_t *dest, int dstr, const int16_t *src, int sstr)
   1.190 +{
   1.191 +  int i;
   1.192 +  int16_t tmp[64];
   1.193 +
   1.194 +  for(i=0;i<8;i++){
   1.195 +    idct8theora_s16_ref(
   1.196 +        OIL_OFFSET(tmp, 8*sizeof(int16_t) * i), sizeof(int16_t),
   1.197 +        OIL_OFFSET(src, sstr * i), sizeof(int16_t));
   1.198 +  }
   1.199 +  for(i=0;i<8;i++){
   1.200 +    idct8theora_s16_ref(
   1.201 +        OIL_OFFSET(dest, sizeof(int16_t) * i), dstr,
   1.202 +        OIL_OFFSET(tmp, sizeof(int16_t) * i), sizeof(int16_t) * 8);
   1.203 +  }
   1.204 +}
   1.205 +OIL_DEFINE_IMPL_REF (idct8x8theora_s16_ref, idct8x8theora_s16);
   1.206 +
   1.207 +
   1.208 +
   1.209 +
   1.210 +#ifdef	__SYMBIAN32__
   1.211 + 
   1.212 +OilFunctionClass* __oil_function_class_idct8theora_s16() {
   1.213 +		return &_oil_function_class_idct8theora_s16;
   1.214 +}
   1.215 +#endif
   1.216 +
   1.217 +#ifdef	__SYMBIAN32__
   1.218 + 
   1.219 +OilFunctionClass* __oil_function_class_idct8x8theora_s16() {
   1.220 +		return &_oil_function_class_idct8x8theora_s16;
   1.221 +}
   1.222 +#endif
   1.223 +
   1.224 +
   1.225 +
   1.226 +#ifdef	__SYMBIAN32__
   1.227 + 
   1.228 +OilFunctionImpl* __oil_function_impl_idct8theora_s16_ref() {
   1.229 +		return &_oil_function_impl_idct8theora_s16_ref;
   1.230 +}
   1.231 +#endif
   1.232 +
   1.233 +#ifdef	__SYMBIAN32__
   1.234 + 
   1.235 +OilFunctionImpl* __oil_function_impl_idct8x8theora_s16_ref() {
   1.236 +		return &_oil_function_impl_idct8x8theora_s16_ref;
   1.237 +}
   1.238 +#endif
   1.239 +
   1.240 +
   1.241 +
   1.242 +#ifdef	__SYMBIAN32__
   1.243 + 
   1.244 +EXPORT_C void** _oil_function_class_ptr_idct8theora_s16 ()	{
   1.245 +	oil_function_class_ptr_idct8theora_s16 = __oil_function_class_idct8theora_s16();
   1.246 +	return &oil_function_class_ptr_idct8theora_s16->func;
   1.247 +	}
   1.248 +#endif
   1.249 +
   1.250 +#ifdef	__SYMBIAN32__
   1.251 + 
   1.252 +EXPORT_C void** _oil_function_class_ptr_idct8x8theora_s16 ()	{
   1.253 +	oil_function_class_ptr_idct8x8theora_s16 = __oil_function_class_idct8x8theora_s16();
   1.254 +	return &oil_function_class_ptr_idct8x8theora_s16->func;
   1.255 +	}
   1.256 +#endif
   1.257 +