1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/jpeg/convert8x8_c.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,208 @@
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 +#include <liboil/liboil.h>
1.36 +#include "jpeg.h"
1.37 +
1.38 +#include <math.h>
1.39 +
1.40 +/**
1.41 + * oil_conv8x8_s16_f64:
1.42 + * @d_8x8:
1.43 + * @dstr:
1.44 + * @s_8x8:
1.45 + * @sstr:
1.46 + *
1.47 + * Converts elements in source array @s_8x8 to the destination
1.48 + * type, placing the results in @d_8x8.
1.49 + */
1.50 +OIL_DEFINE_CLASS (conv8x8_s16_f64,
1.51 + "int16_t * d_8x8, int dstr, double *s_8x8, int sstr");
1.52 +/**
1.53 + * oil_conv8x8_f64_s16:
1.54 + * @d_8x8:
1.55 + * @dstr:
1.56 + * @s_8x8:
1.57 + * @sstr:
1.58 + *
1.59 + * Converts elements in source array @s_8x8 to the destination
1.60 + * type, placing the results in @d_8x8. The conversion of source
1.61 + * values outside the destination range are undefined and
1.62 + * implementation dependent.
1.63 + */
1.64 +OIL_DEFINE_CLASS (conv8x8_f64_s16,
1.65 + "double *d_8x8, int dstr, int16_t * s_8x8, int sstr");
1.66 +/**
1.67 + * oil_clipconv8x8_u8_s16:
1.68 + * @d_8x8:
1.69 + * @dstr:
1.70 + * @s_8x8:
1.71 + * @sstr:
1.72 + *
1.73 + * Converts elements in source array @s_8x8 to the destination
1.74 + * type, placing the results in @d_8x8. Source values outside
1.75 + * the destination range are clipped to the destination range.
1.76 + */
1.77 +OIL_DEFINE_CLASS (clipconv8x8_u8_s16,
1.78 + "uint8_t * d_8x8, int dstr, int16_t * s_8x8, int sstr");
1.79 +
1.80 +#define BLOCK8x8_F64(ptr, stride, row, column) \
1.81 + (*((double *)((unsigned char *)ptr + stride*row) + column))
1.82 +
1.83 +#define BLOCK8x8_PTR_F64(ptr, stride, row, column) \
1.84 + ((double *)((unsigned char *)ptr + stride*row) + column)
1.85 +
1.86 +#define BLOCK8x8_S16(ptr, stride, row, column) \
1.87 + (*((int16_t *)((unsigned char *)ptr + stride*row) + column))
1.88 +
1.89 +#define BLOCK8x8_U8(ptr, stride, row, column) \
1.90 + (*((uint8_t *)((unsigned char *)ptr + stride*row) + column))
1.91 +
1.92 +
1.93 +static void
1.94 +conv8x8_s16_f64_c (int16_t * dest, int dstr, double *src, int sstr)
1.95 +{
1.96 + int i, j;
1.97 +
1.98 + for (i = 0; i < 8; i++) {
1.99 + for (j = 0; j < 8; j++) {
1.100 + BLOCK8x8_S16 (dest, dstr, i, j) = floor (0.5 + BLOCK8x8_F64 (src, sstr, i, j));
1.101 + }
1.102 + }
1.103 +}
1.104 +
1.105 +OIL_DEFINE_IMPL_REF (conv8x8_s16_f64_c, conv8x8_s16_f64);
1.106 +
1.107 +static void
1.108 +conv8x8_f64_s16_c (double *dest, int dstr, int16_t * src, int sstr)
1.109 +{
1.110 + int i, j;
1.111 +
1.112 + for (i = 0; i < 8; i++) {
1.113 + for (j = 0; j < 8; j++) {
1.114 + BLOCK8x8_F64 (dest, dstr, i, j) = BLOCK8x8_S16 (src, sstr, i, j);
1.115 + }
1.116 + }
1.117 +}
1.118 +
1.119 +OIL_DEFINE_IMPL_REF (conv8x8_f64_s16_c, conv8x8_f64_s16);
1.120 +
1.121 +static void
1.122 +clipconv8x8_u8_s16_c (uint8_t * dest, int dstr, int16_t * src, int sstr)
1.123 +{
1.124 + int i, j;
1.125 + int16_t x;
1.126 +
1.127 + for (i = 0; i < 8; i++) {
1.128 + for (j = 0; j < 8; j++) {
1.129 + x = BLOCK8x8_S16 (src, sstr, i, j);
1.130 + if (x < 0)
1.131 + x = 0;
1.132 + if (x > 255)
1.133 + x = 255;
1.134 + BLOCK8x8_U8 (dest, dstr, i, j) = x;
1.135 + }
1.136 + }
1.137 +}
1.138 +
1.139 +OIL_DEFINE_IMPL_REF (clipconv8x8_u8_s16_c, clipconv8x8_u8_s16);
1.140 +
1.141 +
1.142 +#ifdef __SYMBIAN32__
1.143 +
1.144 +OilFunctionClass* __oil_function_class_conv8x8_s16_f64() {
1.145 + return &_oil_function_class_conv8x8_s16_f64;
1.146 +}
1.147 +#endif
1.148 +
1.149 +#ifdef __SYMBIAN32__
1.150 +
1.151 +OilFunctionClass* __oil_function_class_conv8x8_f64_s16() {
1.152 + return &_oil_function_class_conv8x8_f64_s16;
1.153 +}
1.154 +#endif
1.155 +
1.156 +#ifdef __SYMBIAN32__
1.157 +
1.158 +OilFunctionClass* __oil_function_class_clipconv8x8_u8_s16() {
1.159 + return &_oil_function_class_clipconv8x8_u8_s16;
1.160 +}
1.161 +#endif
1.162 +
1.163 +
1.164 +
1.165 +#ifdef __SYMBIAN32__
1.166 +
1.167 +OilFunctionImpl* __oil_function_impl_conv8x8_s16_f64_c() {
1.168 + return &_oil_function_impl_conv8x8_s16_f64_c;
1.169 +}
1.170 +#endif
1.171 +
1.172 +#ifdef __SYMBIAN32__
1.173 +
1.174 +OilFunctionImpl* __oil_function_impl_conv8x8_f64_s16_c() {
1.175 + return &_oil_function_impl_conv8x8_f64_s16_c;
1.176 +}
1.177 +#endif
1.178 +
1.179 +#ifdef __SYMBIAN32__
1.180 +
1.181 +OilFunctionImpl* __oil_function_impl_clipconv8x8_u8_s16_c() {
1.182 + return &_oil_function_impl_clipconv8x8_u8_s16_c;
1.183 +}
1.184 +#endif
1.185 +
1.186 +
1.187 +
1.188 +#ifdef __SYMBIAN32__
1.189 +
1.190 +EXPORT_C void** _oil_function_class_ptr_conv8x8_s16_f64 () {
1.191 + oil_function_class_ptr_conv8x8_s16_f64 = __oil_function_class_conv8x8_s16_f64();
1.192 + return &oil_function_class_ptr_conv8x8_s16_f64->func;
1.193 + }
1.194 +#endif
1.195 +
1.196 +#ifdef __SYMBIAN32__
1.197 +
1.198 +EXPORT_C void** _oil_function_class_ptr_conv8x8_f64_s16 () {
1.199 + oil_function_class_ptr_conv8x8_f64_s16 = __oil_function_class_conv8x8_f64_s16();
1.200 + return &oil_function_class_ptr_conv8x8_f64_s16->func;
1.201 + }
1.202 +#endif
1.203 +
1.204 +#ifdef __SYMBIAN32__
1.205 +
1.206 +EXPORT_C void** _oil_function_class_ptr_clipconv8x8_u8_s16 () {
1.207 + oil_function_class_ptr_clipconv8x8_u8_s16 = __oil_function_class_clipconv8x8_u8_s16();
1.208 + return &oil_function_class_ptr_clipconv8x8_u8_s16->func;
1.209 + }
1.210 +#endif
1.211 +