os/ossrv/genericopenlibs/liboil/src/jpeg/yuv2rgb_c.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/jpeg/yuv2rgb_c.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,276 @@
     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/liboil.h>
    1.37 +#include <liboil/liboiltest.h>
    1.38 +#include "jpeg.h"
    1.39 +
    1.40 +/**
    1.41 + * oil_yuv2rgbx_u8:
    1.42 + * @d_4xn:
    1.43 + * @src1: Y component
    1.44 + * @src2: U component
    1.45 + * @src3: V component
    1.46 + * @n:
    1.47 + *
    1.48 + * Converts YUV pixels to RGB pixels.  Each YUV component is in a
    1.49 + * separate source array, and are combined and converted to RGB.
    1.50 + *
    1.51 + * This function should be replaced by one that makes sense.
    1.52 + */
    1.53 +OIL_DEFINE_CLASS (yuv2rgbx_u8,
    1.54 +    "uint8_t *d_4xn, uint8_t *src1, uint8_t *src2, uint8_t *src3, int n");
    1.55 +/**
    1.56 + * oil_yuv2rgbx_sub2_u8:
    1.57 + * @d_4xn:
    1.58 + * @src1: Y component
    1.59 + * @src2: U component
    1.60 + * @src3: V component
    1.61 + * @n:
    1.62 + *
    1.63 + * Converts YUV pixels to RGB pixels.  Each YUV component is in a
    1.64 + * separate source array, and are combined and converted to RGB.
    1.65 + * The U and V arrays are subsampled by a factor of 2, so only
    1.66 + * half of each array is used.
    1.67 + *
    1.68 + * This function should be replaced by one that makes sense.
    1.69 + */
    1.70 +OIL_DEFINE_CLASS (yuv2rgbx_sub2_u8,
    1.71 +    "uint8_t *d_4xn, uint8_t *src1, uint8_t *src2, uint8_t *src3, int n");
    1.72 +/**
    1.73 + * oil_yuv2rgbx_sub4_u8:
    1.74 + * @d_4xn:
    1.75 + * @src1: Y component
    1.76 + * @src2: U component
    1.77 + * @src3: V component
    1.78 + * @n:
    1.79 + *
    1.80 + * Converts YUV pixels to RGB pixels.  Each YUV component is in a
    1.81 + * separate source array, and are combined and converted to RGB.
    1.82 + * The U and V arrays are subsampled by a factor of 4, so only
    1.83 + * a quarter of each array is used.
    1.84 + *
    1.85 + * This function should be replaced by one that makes sense.
    1.86 + */
    1.87 +OIL_DEFINE_CLASS (yuv2rgbx_sub4_u8,
    1.88 +    "uint8_t *d_4xn, uint8_t *src1, uint8_t *src2, uint8_t *src3, int n");
    1.89 +
    1.90 +#define clamp(x,a,b) clamp_lower(clamp_upper(x,b),a)
    1.91 +#define clamp_lower(x,a) ((x<a)?(a):(x))
    1.92 +#define clamp_upper(x,b) ((x>b)?(b):(x))
    1.93 +
    1.94 +/* from the JFIF spec */
    1.95 +#define YUV_TO_R(y,u,v) clamp((y) + 1.402*((v)-128),0,255)
    1.96 +#define YUV_TO_G(y,u,v) clamp((y) - 0.34414*((u)-128) - 0.71414*((v)-128),0,255)
    1.97 +#define YUV_TO_B(y,u,v) clamp((y) + 1.772*((u)-128),0,255)
    1.98 +
    1.99 +#define YUV_TO_R_INT(y,u,v) clamp(((y)*256 + 358*((v)-128))>>8,0,255)
   1.100 +#define YUV_TO_G_INT(y,u,v) clamp(((y)*256 - 88*((u)-128) - 183*((v)-128))>>8,0,255)
   1.101 +#define YUV_TO_B_INT(y,u,v) clamp(((y)*256 + 454*((u)-128))>>8,0,255)
   1.102 +
   1.103 +
   1.104 +static void
   1.105 +yuv2rgbx_u8_ref (uint8_t *rgbp, uint8_t *yp, uint8_t *up, uint8_t *vp, int n)
   1.106 +{
   1.107 +	int i;
   1.108 +
   1.109 +	for(i=0;i<n;i++){
   1.110 +		rgbp[0] = YUV_TO_R(yp[0], up[0], vp[0]);
   1.111 +		rgbp[1] = YUV_TO_G(yp[0], up[0], vp[0]);
   1.112 +		rgbp[2] = YUV_TO_B(yp[0], up[0], vp[0]);
   1.113 +		rgbp[3] = 0;
   1.114 +		rgbp+=4;
   1.115 +		yp++;
   1.116 +		up++;
   1.117 +		vp++;
   1.118 +	}
   1.119 +}
   1.120 +
   1.121 +OIL_DEFINE_IMPL_REF (yuv2rgbx_u8_ref, yuv2rgbx_u8);
   1.122 +
   1.123 +#ifdef ENABLE_BROKEN_IMPLS
   1.124 +static void
   1.125 +yuv2rgbx_u8_int (uint8_t *rgbp, uint8_t *yp, uint8_t *up, uint8_t *vp, int n)
   1.126 +{
   1.127 +	int i;
   1.128 +
   1.129 +	for(i=0;i<n;i++){
   1.130 +		rgbp[0] = YUV_TO_R_INT(yp[0], up[0], vp[0]);
   1.131 +		rgbp[1] = YUV_TO_G_INT(yp[0], up[0], vp[0]);
   1.132 +		rgbp[2] = YUV_TO_B_INT(yp[0], up[0], vp[0]);
   1.133 +		rgbp[3] = 0;
   1.134 +		rgbp+=4;
   1.135 +		yp++;
   1.136 +		up++;
   1.137 +		vp++;
   1.138 +	}
   1.139 +}
   1.140 +
   1.141 +OIL_DEFINE_IMPL (yuv2rgbx_u8_int, yuv2rgbx_u8);
   1.142 +#endif
   1.143 +
   1.144 +static void
   1.145 +yuv2rgbx_sub2_u8_ref (uint8_t *rgbp, uint8_t *yp, uint8_t *up, uint8_t *vp, int n)
   1.146 +{
   1.147 +	int i;
   1.148 +
   1.149 +	for(i=0;i<n/2;i++){
   1.150 +		rgbp[0] = YUV_TO_R(yp[0], up[0], vp[0]);
   1.151 +		rgbp[1] = YUV_TO_G(yp[0], up[0], vp[0]);
   1.152 +		rgbp[2] = YUV_TO_B(yp[0], up[0], vp[0]);
   1.153 +		rgbp[3] = 0;
   1.154 +		rgbp+=4;
   1.155 +		yp++;
   1.156 +		rgbp[0] = YUV_TO_R(yp[0], up[0], vp[0]);
   1.157 +		rgbp[1] = YUV_TO_G(yp[0], up[0], vp[0]);
   1.158 +		rgbp[2] = YUV_TO_B(yp[0], up[0], vp[0]);
   1.159 +		rgbp[3] = 0;
   1.160 +		rgbp+=4;
   1.161 +		yp++;
   1.162 +		up++;
   1.163 +		vp++;
   1.164 +	}
   1.165 +}
   1.166 +
   1.167 +OIL_DEFINE_IMPL_REF (yuv2rgbx_sub2_u8_ref, yuv2rgbx_sub2_u8);
   1.168 +
   1.169 +static void
   1.170 +yuv2rgbx_sub4_u8_ref (uint8_t *rgbp, uint8_t *yp, uint8_t *up, uint8_t *vp, int n)
   1.171 +{
   1.172 +	int i;
   1.173 +
   1.174 +	for(i=0;i<n/4;i++){
   1.175 +		rgbp[0] = YUV_TO_R(yp[0], up[0], vp[0]);
   1.176 +		rgbp[1] = YUV_TO_G(yp[0], up[0], vp[0]);
   1.177 +		rgbp[2] = YUV_TO_B(yp[0], up[0], vp[0]);
   1.178 +		rgbp[3] = 0;
   1.179 +		rgbp+=4;
   1.180 +		yp++;
   1.181 +		rgbp[0] = YUV_TO_R(yp[0], up[0], vp[0]);
   1.182 +		rgbp[1] = YUV_TO_G(yp[0], up[0], vp[0]);
   1.183 +		rgbp[2] = YUV_TO_B(yp[0], up[0], vp[0]);
   1.184 +		rgbp[3] = 0;
   1.185 +		rgbp+=4;
   1.186 +		yp++;
   1.187 +		rgbp[0] = YUV_TO_R(yp[0], up[0], vp[0]);
   1.188 +		rgbp[1] = YUV_TO_G(yp[0], up[0], vp[0]);
   1.189 +		rgbp[2] = YUV_TO_B(yp[0], up[0], vp[0]);
   1.190 +		rgbp[3] = 0;
   1.191 +		rgbp+=4;
   1.192 +		yp++;
   1.193 +		rgbp[0] = YUV_TO_R(yp[0], up[0], vp[0]);
   1.194 +		rgbp[1] = YUV_TO_G(yp[0], up[0], vp[0]);
   1.195 +		rgbp[2] = YUV_TO_B(yp[0], up[0], vp[0]);
   1.196 +		rgbp[3] = 0;
   1.197 +		rgbp+=4;
   1.198 +		yp++;
   1.199 +		up++;
   1.200 +		vp++;
   1.201 +	}
   1.202 +}
   1.203 +
   1.204 +OIL_DEFINE_IMPL_REF (yuv2rgbx_sub4_u8_ref, yuv2rgbx_sub4_u8);
   1.205 +
   1.206 +
   1.207 +
   1.208 +#ifdef	__SYMBIAN32__
   1.209 + 
   1.210 +OilFunctionClass* __oil_function_class_yuv2rgbx_u8() {
   1.211 +		return &_oil_function_class_yuv2rgbx_u8;
   1.212 +}
   1.213 +#endif
   1.214 +
   1.215 +#ifdef	__SYMBIAN32__
   1.216 + 
   1.217 +OilFunctionClass* __oil_function_class_yuv2rgbx_sub2_u8() {
   1.218 +		return &_oil_function_class_yuv2rgbx_sub2_u8;
   1.219 +}
   1.220 +#endif
   1.221 +
   1.222 +#ifdef	__SYMBIAN32__
   1.223 + 
   1.224 +OilFunctionClass* __oil_function_class_yuv2rgbx_sub4_u8() {
   1.225 +		return &_oil_function_class_yuv2rgbx_sub4_u8;
   1.226 +}
   1.227 +#endif
   1.228 +
   1.229 +
   1.230 +
   1.231 +#ifdef	__SYMBIAN32__
   1.232 + 
   1.233 +OilFunctionImpl* __oil_function_impl_yuv2rgbx_u8_ref() {
   1.234 +		return &_oil_function_impl_yuv2rgbx_u8_ref;
   1.235 +}
   1.236 +#endif
   1.237 +
   1.238 +
   1.239 +
   1.240 +#ifdef	__SYMBIAN32__
   1.241 + 
   1.242 +OilFunctionImpl* __oil_function_impl_yuv2rgbx_sub2_u8_ref() {
   1.243 +		return &_oil_function_impl_yuv2rgbx_sub2_u8_ref;
   1.244 +}
   1.245 +#endif
   1.246 +
   1.247 +#ifdef	__SYMBIAN32__
   1.248 + 
   1.249 +OilFunctionImpl* __oil_function_impl_yuv2rgbx_sub4_u8_ref() {
   1.250 +		return &_oil_function_impl_yuv2rgbx_sub4_u8_ref;
   1.251 +}
   1.252 +#endif
   1.253 +
   1.254 +
   1.255 +
   1.256 +#ifdef	__SYMBIAN32__
   1.257 + 
   1.258 +EXPORT_C void** _oil_function_class_ptr_yuv2rgbx_u8 ()	{
   1.259 +	oil_function_class_ptr_yuv2rgbx_u8 = __oil_function_class_yuv2rgbx_u8();
   1.260 +	return &oil_function_class_ptr_yuv2rgbx_u8->func;
   1.261 +	}
   1.262 +#endif
   1.263 +
   1.264 +#ifdef	__SYMBIAN32__
   1.265 + 
   1.266 +EXPORT_C void** _oil_function_class_ptr_yuv2rgbx_sub2_u8 ()	{
   1.267 +	oil_function_class_ptr_yuv2rgbx_sub2_u8 = __oil_function_class_yuv2rgbx_sub2_u8();
   1.268 +	return &oil_function_class_ptr_yuv2rgbx_sub2_u8->func;
   1.269 +	}
   1.270 +#endif
   1.271 +
   1.272 +#ifdef	__SYMBIAN32__
   1.273 + 
   1.274 +EXPORT_C void** _oil_function_class_ptr_yuv2rgbx_sub4_u8 ()	{
   1.275 +	oil_function_class_ptr_yuv2rgbx_sub4_u8 = __oil_function_class_yuv2rgbx_sub4_u8();
   1.276 +	return &oil_function_class_ptr_yuv2rgbx_sub4_u8->func;
   1.277 +	}
   1.278 +#endif
   1.279 +