sl@0: /* sl@0: * LIBOIL - Library of Optimized Inner Loops sl@0: * Copyright (c) 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 sl@0: sl@0: sl@0: /** sl@0: * oil_resample_linear_u8: sl@0: * @d_n: sl@0: * @s_2xn: sl@0: * @n: sl@0: * @i_2: sl@0: * sl@0: * Linearly resamples a row of pixels. FIXME. sl@0: */ sl@0: static void sl@0: resample_linear_u8_test (OilTest *test) sl@0: { sl@0: uint32_t *in = (uint32_t *) oil_test_get_source_data (test, OIL_ARG_INPLACE1); sl@0: sl@0: in[0] = 0; sl@0: in[1] = 65536; sl@0: } sl@0: OIL_DEFINE_CLASS_FULL (resample_linear_u8, sl@0: "uint8_t *d_n, uint8_t *s_2xn, int n, uint32_t *i_2", sl@0: resample_linear_u8_test); sl@0: sl@0: /** sl@0: * oil_resample_linear_argb: sl@0: * @d_n: sl@0: * @s_2xn: sl@0: * @n: sl@0: * @i_2: sl@0: * sl@0: * Linearly resamples a row of pixels. FIXME. sl@0: */ sl@0: static void sl@0: resample_linear_argb_test (OilTest *test) sl@0: { sl@0: uint32_t *in = (uint32_t *) oil_test_get_source_data (test, OIL_ARG_INPLACE1); sl@0: sl@0: in[0] = 0; sl@0: in[1] = 65536; sl@0: } sl@0: OIL_DEFINE_CLASS_FULL (resample_linear_argb, sl@0: "uint32_t *d_n, uint32_t *s_2xn, int n, uint32_t *i_2", sl@0: resample_linear_argb_test); sl@0: sl@0: static void sl@0: resample_linear_u8_ref (uint8_t *dest, uint8_t *src, int n, sl@0: uint32_t *in) sl@0: { sl@0: int acc = in[0]; sl@0: int increment = in[1]; sl@0: int i; sl@0: int j; sl@0: int x; sl@0: sl@0: for(i=0;i>16; sl@0: x = (acc&0xffff)>>8; sl@0: dest[i] = (src[j]*(256-x) + src[j+1]*x) >> 8; sl@0: sl@0: acc += increment; sl@0: } sl@0: sl@0: in[0] = acc; sl@0: } sl@0: OIL_DEFINE_IMPL_REF (resample_linear_u8_ref, resample_linear_u8); sl@0: sl@0: static void sl@0: resample_linear_argb_ref (uint32_t *d, uint32_t *s, int n, uint32_t *in) sl@0: { sl@0: uint8_t *src = (uint8_t *)s; sl@0: uint8_t *dest = (uint8_t *)d; sl@0: int acc = in[0]; sl@0: int increment = in[1]; sl@0: int i; sl@0: int j; sl@0: int x; sl@0: sl@0: for(i=0;i>16; sl@0: x = (acc&0xffff)>>8; sl@0: dest[4*i+0] = (src[4*j+0]*(256-x) + src[4*j+4]*x) >> 8; sl@0: dest[4*i+1] = (src[4*j+1]*(256-x) + src[4*j+5]*x) >> 8; sl@0: dest[4*i+2] = (src[4*j+2]*(256-x) + src[4*j+6]*x) >> 8; sl@0: dest[4*i+3] = (src[4*j+3]*(256-x) + src[4*j+7]*x) >> 8; sl@0: sl@0: acc += increment; sl@0: } sl@0: sl@0: in[0] = acc; sl@0: } sl@0: OIL_DEFINE_IMPL_REF (resample_linear_argb_ref, resample_linear_argb); sl@0: sl@0: sl@0: static void sl@0: merge_linear_test (OilTest *test) sl@0: { sl@0: uint32_t *src3 = (uint32_t *) oil_test_get_source_data (test, OIL_ARG_SRC3); sl@0: sl@0: do { sl@0: src3[0] = oil_rand_u16() & 0x1ff; sl@0: } while (src3[0] > 256); sl@0: } sl@0: OIL_DEFINE_CLASS_FULL (merge_linear_argb, sl@0: "uint32_t *d_n, uint32_t *s_n, uint32_t *s2_n, uint32_t *s3_1, int n", sl@0: merge_linear_test); sl@0: OIL_DEFINE_CLASS_FULL (merge_linear_u8, sl@0: "uint8_t *d_n, uint8_t *s_n, uint8_t *s2_n, uint32_t *s3_1, int n", sl@0: merge_linear_test); sl@0: sl@0: /** sl@0: * oil_merge_linear_argb: sl@0: * @d_n: sl@0: * @s_n: sl@0: * @s2_n: sl@0: * @s3_1: sl@0: * @n: sl@0: * sl@0: * Linearly interpolate the @s_n and @s2_n arrays using the scale sl@0: * factor in @s3_1. The value @s3_1 must be in the range [0, 256] sl@0: * A value of 0 indicates weights of 1.0 and 0.0 for sl@0: * the s_n and s2_n arrays respectively. A value of 256 indicates sl@0: * weights of 0.0 and 1.0 respectively. sl@0: * sl@0: * This function is not intended for alpha blending; use one of the sl@0: * compositing functions instead. sl@0: */ sl@0: static void sl@0: merge_linear_argb_ref (uint32_t *d, uint32_t *s1, uint32_t *s2, sl@0: uint32_t *src3, int n) sl@0: { sl@0: uint8_t *src1 = (uint8_t *)s1; sl@0: uint8_t *src2 = (uint8_t *)s2; sl@0: uint8_t *dest = (uint8_t *)d; sl@0: int i; sl@0: int x = src3[0]; sl@0: sl@0: for(i=0;i> 8; sl@0: dest[4*i+1] = (src1[4*i+1]*(256-x) + src2[4*i+1]*x) >> 8; sl@0: dest[4*i+2] = (src1[4*i+2]*(256-x) + src2[4*i+2]*x) >> 8; sl@0: dest[4*i+3] = (src1[4*i+3]*(256-x) + src2[4*i+3]*x) >> 8; sl@0: } sl@0: } sl@0: OIL_DEFINE_IMPL_REF (merge_linear_argb_ref, merge_linear_argb); sl@0: sl@0: sl@0: /** sl@0: * oil_merge_linear_u8: sl@0: * @d_n: sl@0: * @s_n: sl@0: * @s2_n: sl@0: * @s3_1: sl@0: * @n: sl@0: * sl@0: * Linearly interpolate the @s_n and @s2_n arrays using the scale sl@0: * factor in @s3_1. The value @s3_1 must be in the range [0, 255]. sl@0: * The value translates into weights of 1.0-(value/256.0) and sl@0: * (value/256.0) for the s_n and s2_n arrays respectively. sl@0: * sl@0: * This function is not intended for alpha blending; use one of the sl@0: * compositing functions instead. sl@0: */ sl@0: static void sl@0: merge_linear_u8_ref (uint8_t *dest, uint8_t *src1, uint8_t *src2, sl@0: uint32_t *src3, int n) sl@0: { sl@0: int i; sl@0: int x = src3[0]; sl@0: sl@0: for(i=0;i> 8; sl@0: } sl@0: } sl@0: OIL_DEFINE_IMPL_REF (merge_linear_u8_ref, merge_linear_u8); sl@0: sl@0: sl@0: sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionClass* __oil_function_class_resample_linear_u8() { sl@0: return &_oil_function_class_resample_linear_u8; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionClass* __oil_function_class_resample_linear_argb() { sl@0: return &_oil_function_class_resample_linear_argb; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionClass* __oil_function_class_merge_linear_argb() { sl@0: return &_oil_function_class_merge_linear_argb; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionClass* __oil_function_class_merge_linear_u8() { sl@0: return &_oil_function_class_merge_linear_u8; sl@0: } sl@0: #endif sl@0: sl@0: sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionImpl* __oil_function_impl_resample_linear_u8_ref() { sl@0: return &_oil_function_impl_resample_linear_u8_ref; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionImpl* __oil_function_impl_resample_linear_argb_ref() { sl@0: return &_oil_function_impl_resample_linear_argb_ref; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionImpl* __oil_function_impl_merge_linear_argb_ref() { sl@0: return &_oil_function_impl_merge_linear_argb_ref; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: OilFunctionImpl* __oil_function_impl_merge_linear_u8_ref() { sl@0: return &_oil_function_impl_merge_linear_u8_ref; sl@0: } sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: EXPORT_C void** _oil_function_class_ptr_resample_linear_u8 () { sl@0: oil_function_class_ptr_resample_linear_u8 = __oil_function_class_resample_linear_u8(); sl@0: return &oil_function_class_ptr_resample_linear_u8->func; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: EXPORT_C void** _oil_function_class_ptr_resample_linear_argb () { sl@0: oil_function_class_ptr_resample_linear_argb = __oil_function_class_resample_linear_argb(); sl@0: return &oil_function_class_ptr_resample_linear_argb->func; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: EXPORT_C void** _oil_function_class_ptr_merge_linear_argb () { sl@0: oil_function_class_ptr_merge_linear_argb = __oil_function_class_merge_linear_argb(); sl@0: return &oil_function_class_ptr_merge_linear_argb->func; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __SYMBIAN32__ sl@0: sl@0: EXPORT_C void** _oil_function_class_ptr_merge_linear_u8 () { sl@0: oil_function_class_ptr_merge_linear_u8 = __oil_function_class_merge_linear_u8(); sl@0: return &oil_function_class_ptr_merge_linear_u8->func; sl@0: } sl@0: #endif sl@0: