sl@0: /* sl@0: * LIBOIL - Library of Optimized Inner Loops sl@0: * Copyright (c) 2001,2002,2003,2004 David A. Schleef sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR sl@0: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED sl@0: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE sl@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, sl@0: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES sl@0: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR sl@0: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, sl@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING sl@0: * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE sl@0: * POSSIBILITY OF SUCH DAMAGE. sl@0: */ sl@0: //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: sl@0: #ifdef HAVE_CONFIG_H sl@0: #include "config.h" sl@0: #endif sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "liboil/dct/dct.h" sl@0: #include sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: #ifdef __WINSCW__ sl@0: #pragma warn_unusedarg off sl@0: #endif//__WINSCW__ sl@0: #endif//__SYMBIAN32__ sl@0: sl@0: static void sl@0: idct8theora_s16_test (OilTest *test) sl@0: { sl@0: int i; sl@0: int stride = test->params[OIL_ARG_SSTR1].value; sl@0: uint16_t *ptr = (uint16_t *)oil_test_get_source_data(test,OIL_ARG_SRC1); sl@0: sl@0: for(i=0;i<8;i++){ sl@0: OIL_GET(ptr, i*stride, int16_t) = oil_rand_s16() >> 3; sl@0: //OIL_GET(ptr, i*stride, int16_t) = 0; sl@0: } sl@0: //OIL_GET(ptr, 0*stride, int16_t) = 100; sl@0: sl@0: } sl@0: sl@0: static void sl@0: idct8x8theora_s16_test (OilTest *test) sl@0: { sl@0: int i; sl@0: int j; sl@0: int stride = test->params[OIL_ARG_SSTR1].value; sl@0: uint16_t *ptr = (uint16_t *)oil_test_get_source_data(test,OIL_ARG_SRC1); sl@0: sl@0: for(i=0;i<8;i++){ sl@0: for(j=0;j<8;j++){ sl@0: OIL_GET(ptr, i*stride + j*2, int16_t) = oil_rand_s16() >> 3; sl@0: } sl@0: } sl@0: sl@0: } sl@0: sl@0: /** sl@0: * oil_idct8theora_s16: sl@0: * @d_8: sl@0: * @dstr: sl@0: * @s_8: sl@0: * @sstr: sl@0: * sl@0: * Performs a Inverse Discrete Cosine Transform on @s_8 and places sl@0: * the result in @d_8, as defined by the Theora specification. sl@0: */ sl@0: OIL_DEFINE_CLASS_FULL (idct8theora_s16, "int16_t *d_8, int dstr, int16_t *s_8, int sstr", idct8theora_s16_test); sl@0: /** sl@0: * oil_idct8x8theora_s16: sl@0: * @d_8x8: sl@0: * @dstr: sl@0: * @s_8x8: sl@0: * @sstr: sl@0: * sl@0: * Performs a Inverse Discrete Cosine Transform on @s_8x8 and places sl@0: * the result in @d_8x8, as defined by the Theora specification. sl@0: */ sl@0: OIL_DEFINE_CLASS_FULL (idct8x8theora_s16, "int16_t *d_8x8, int dstr, int16_t *s_8x8, int sstr", idct8x8theora_s16_test); sl@0: sl@0: sl@0: sl@0: #define C1 64277 sl@0: #define C2 60547 sl@0: #define C3 54491 sl@0: #define C4 46341 sl@0: #define C5 36410 sl@0: #define C6 25080 sl@0: #define C7 12785 sl@0: sl@0: #define S7 64277 sl@0: #define S6 60547 sl@0: #define S5 54491 sl@0: #define S4 46341 sl@0: #define S3 36410 sl@0: #define S2 25080 sl@0: #define S1 12785 sl@0: sl@0: #define TRUNC(x) ((int16_t)x) sl@0: #define MULT(a,b) (((a)*(b))>>16) sl@0: sl@0: static void sl@0: idct8theora_s16_ref (int16_t *dest, int dstr, const int16_t *src, int sstr) sl@0: { sl@0: int32_t t[10]; sl@0: int32_t r; sl@0: sl@0: #define Y(i) OIL_GET(src,sstr*(i),int16_t) sl@0: #define X(i) OIL_GET(dest,sstr*(i),int16_t) sl@0: sl@0: /* the ordering here corresponds closely to the theora spec */ sl@0: t[0] = MULT(C4, Y(0) + Y(4)); sl@0: t[0] = TRUNC(t[0]); sl@0: t[1] = MULT(C4, Y(0) - Y(4)); sl@0: t[1] = TRUNC(t[1]); sl@0: t[2] = MULT(C6, Y(2)) - MULT(S6, Y(6)); sl@0: t[3] = MULT(S6, Y(2)) + MULT(C6, Y(6)); sl@0: t[4] = MULT(C7, Y(1)) - MULT(S7, Y(7)); sl@0: t[5] = MULT(C3, Y(5)) - MULT(S3, Y(3)); sl@0: t[6] = MULT(S3, Y(5)) + MULT(C3, Y(3)); sl@0: t[7] = MULT(S7, Y(1)) + MULT(C7, Y(7)); sl@0: r = t[4] + t[5]; sl@0: t[5] = MULT(C4, t[4] - t[5]); sl@0: t[5] = TRUNC(t[5]); sl@0: t[4] = r; sl@0: r = t[7] + t[6]; sl@0: t[6] = MULT(C4, t[7] - t[6]); sl@0: t[6] = TRUNC(t[6]); sl@0: t[7] = r; sl@0: r = t[0] + t[3]; sl@0: t[3] = t[0] - t[3]; sl@0: t[0] = r; sl@0: r = t[1] + t[2]; sl@0: t[2] = t[1] - t[2]; sl@0: t[1] = r; sl@0: r = t[6] + t[5]; sl@0: t[5] = t[6] - t[5]; sl@0: t[6] = r; sl@0: r = t[0] + t[7]; sl@0: r = TRUNC(r); sl@0: X(0) = r; sl@0: r = t[1] + t[6]; sl@0: r = TRUNC(r); sl@0: X(1) = r; sl@0: r = t[2] + t[5]; sl@0: r = TRUNC(r); sl@0: X(2) = r; sl@0: r = t[3] + t[4]; sl@0: r = TRUNC(r); sl@0: X(3) = r; sl@0: r = t[3] - t[4]; sl@0: r = TRUNC(r); sl@0: X(4) = r; sl@0: r = t[2] - t[5]; sl@0: r = TRUNC(r); sl@0: X(5) = r; sl@0: r = t[1] - t[6]; sl@0: r = TRUNC(r); sl@0: X(6) = r; sl@0: r = t[0] - t[7]; sl@0: r = TRUNC(r); sl@0: X(7) = r; sl@0: } sl@0: OIL_DEFINE_IMPL_REF (idct8theora_s16_ref, idct8theora_s16); sl@0: sl@0: sl@0: static void sl@0: idct8x8theora_s16_ref (int16_t *dest, int dstr, const int16_t *src, int sstr) sl@0: { sl@0: int i; sl@0: int16_t tmp[64]; sl@0: sl@0: for(i=0;i<8;i++){ sl@0: idct8theora_s16_ref( sl@0: OIL_OFFSET(tmp, 8*sizeof(int16_t) * i), sizeof(int16_t), sl@0: OIL_OFFSET(src, sstr * i), sizeof(int16_t)); sl@0: } sl@0: for(i=0;i<8;i++){ sl@0: idct8theora_s16_ref( sl@0: OIL_OFFSET(dest, sizeof(int16_t) * i), dstr, sl@0: OIL_OFFSET(tmp, sizeof(int16_t) * i), sizeof(int16_t) * 8); sl@0: } sl@0: } sl@0: OIL_DEFINE_IMPL_REF (idct8x8theora_s16_ref, idct8x8theora_s16); sl@0: sl@0: sl@0: sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionClass* __oil_function_class_idct8theora_s16() { sl@0: return &_oil_function_class_idct8theora_s16; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionClass* __oil_function_class_idct8x8theora_s16() { sl@0: return &_oil_function_class_idct8x8theora_s16; sl@0: } sl@0: #endif sl@0: sl@0: sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionImpl* __oil_function_impl_idct8theora_s16_ref() { sl@0: return &_oil_function_impl_idct8theora_s16_ref; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionImpl* __oil_function_impl_idct8x8theora_s16_ref() { sl@0: return &_oil_function_impl_idct8x8theora_s16_ref; sl@0: } sl@0: #endif sl@0: sl@0: sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: EXPORT_C void** _oil_function_class_ptr_idct8theora_s16 () { sl@0: oil_function_class_ptr_idct8theora_s16 = __oil_function_class_idct8theora_s16(); sl@0: return &oil_function_class_ptr_idct8theora_s16->func; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: EXPORT_C void** _oil_function_class_ptr_idct8x8theora_s16 () { sl@0: oil_function_class_ptr_idct8x8theora_s16 = __oil_function_class_idct8x8theora_s16(); sl@0: return &oil_function_class_ptr_idct8x8theora_s16->func; sl@0: } sl@0: #endif sl@0: