os/ossrv/genericopenlibs/liboil/src/ref/rowcolsad8x8.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2  * LIBOIL - Library of Optimized Inner Loops
     3  * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
     4  * All rights reserved.
     5  *
     6  * Redistribution and use in source and binary forms, with or without
     7  * modification, are permitted provided that the following conditions
     8  * are met:
     9  * 1. Redistributions of source code must retain the above copyright
    10  *    notice, this list of conditions and the following disclaimer.
    11  * 2. Redistributions in binary form must reproduce the above copyright
    12  *    notice, this list of conditions and the following disclaimer in the
    13  *    documentation and/or other materials provided with the distribution.
    14  * 
    15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    23  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    25  * POSSIBILITY OF SUCH DAMAGE.
    26  */
    27 //Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    28 
    29 #ifdef HAVE_CONFIG_H
    30 #include "config.h"
    31 #endif
    32 
    33 #include <liboil/liboilfunction.h>
    34 #include "liboil/simdpack/simdpack.h"
    35 #include <math.h>
    36 
    37 #define ABS(x) ((x)>0 ? (x) : -(x))
    38 #define DSP_OP_ABS_DIFF(a,b) ABS((((int)(a)) - ((int)(b))))
    39 
    40 /**
    41  * oil_rowsad8x8_u8:
    42  * @d_1:
    43  * @s1_8x8:
    44  * @s2_8x8:
    45  *
    46  * Calculates the sum of absolute differences between @s1_8x8 and @s1_8s8
    47  * for the first 4 elements of the first row, and the sum of absolute
    48  * differences for the last 4 elements of the first row, and places the
    49  * maximum of those values in @dest.
    50  *
    51  * FIXME: This function is declared incorrectly.
    52  */
    53 OIL_DEFINE_CLASS (rowsad8x8_u8,
    54     "uint32_t *d_1, uint8_t *s1_8x8, uint8_t *s2_8x8");
    55 /**
    56  * oil_colsad8x8_u8:
    57  * @d_1:
    58  * @s1_8x8:
    59  * @s2_8x8:
    60  *
    61  * Divides the 8x8 block into 16 1x4 regions, and calculates the
    62  * sum of absolute differences between @s1_8x8 and @s2_8x8 for
    63  * each region.  The maximum of the results in each region is
    64  * placed in @d_1.
    65  */
    66 OIL_DEFINE_CLASS (colsad8x8_u8,
    67     "uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, int ss2");
    68 
    69 static void
    70 rowsad8x8_u8_ref (uint32_t *dest, uint8_t *src1, uint8_t *src2)
    71 {
    72   uint32_t SadValue;
    73   uint32_t SadValue1;
    74 
    75   SadValue    = DSP_OP_ABS_DIFF (src1[0], src2[0]) + 
    76 	        DSP_OP_ABS_DIFF (src1[1], src2[1]) +
    77 	        DSP_OP_ABS_DIFF (src1[2], src2[2]) +
    78 	        DSP_OP_ABS_DIFF (src1[3], src2[3]);
    79 
    80   SadValue1   = DSP_OP_ABS_DIFF (src1[4], src2[4]) + 
    81 	        DSP_OP_ABS_DIFF (src1[5], src2[5]) +
    82 	        DSP_OP_ABS_DIFF (src1[6], src2[6]) +
    83 	        DSP_OP_ABS_DIFF (src1[7], src2[7]);
    84 
    85   *dest = (SadValue > SadValue1) ? SadValue : SadValue1;
    86 }
    87 OIL_DEFINE_IMPL_REF (rowsad8x8_u8_ref, rowsad8x8_u8);
    88 
    89 static void
    90 colsad8x8_u8_ref (uint32_t *dest, uint8_t *src1, int ss1, uint8_t *src2, int ss2)
    91 {
    92   uint32_t SadValue[8] = {0,0,0,0,0,0,0,0};
    93   uint32_t SadValue2[8] = {0,0,0,0,0,0,0,0};
    94   uint32_t MaxSad = 0;
    95   uint32_t i;
    96 
    97   for ( i = 0; i < 4; i++ ){
    98     SadValue[0] += ABS(src1[0] - src2[0]);
    99     SadValue[1] += ABS(src1[1] - src2[1]);
   100     SadValue[2] += ABS(src1[2] - src2[2]);
   101     SadValue[3] += ABS(src1[3] - src2[3]);
   102     SadValue[4] += ABS(src1[4] - src2[4]);
   103     SadValue[5] += ABS(src1[5] - src2[5]);
   104     SadValue[6] += ABS(src1[6] - src2[6]);
   105     SadValue[7] += ABS(src1[7] - src2[7]);
   106     
   107     src1 += ss1;
   108     src2 += ss2;
   109   }
   110 
   111   for ( i = 0; i < 4; i++ ){
   112     SadValue2[0] += ABS(src1[0] - src2[0]);
   113     SadValue2[1] += ABS(src1[1] - src2[1]);
   114     SadValue2[2] += ABS(src1[2] - src2[2]);
   115     SadValue2[3] += ABS(src1[3] - src2[3]);
   116     SadValue2[4] += ABS(src1[4] - src2[4]);
   117     SadValue2[5] += ABS(src1[5] - src2[5]);
   118     SadValue2[6] += ABS(src1[6] - src2[6]);
   119     SadValue2[7] += ABS(src1[7] - src2[7]);
   120     
   121     src1 += ss1;
   122     src2 += ss2;
   123   }
   124     
   125   for ( i = 0; i < 8; i++ ){
   126     if ( SadValue[i] > MaxSad )
   127       MaxSad = SadValue[i];
   128     if ( SadValue2[i] > MaxSad )
   129       MaxSad = SadValue2[i];
   130   }
   131     
   132   *dest = MaxSad;
   133 }
   134 OIL_DEFINE_IMPL_REF (colsad8x8_u8_ref, colsad8x8_u8);
   135 
   136 
   137 
   138 #ifdef	__SYMBIAN32__
   139  
   140 OilFunctionClass* __oil_function_class_rowsad8x8_u8() {
   141 		return &_oil_function_class_rowsad8x8_u8;
   142 }
   143 #endif
   144 
   145 #ifdef	__SYMBIAN32__
   146  
   147 OilFunctionClass* __oil_function_class_colsad8x8_u8() {
   148 		return &_oil_function_class_colsad8x8_u8;
   149 }
   150 #endif
   151 
   152 
   153 
   154 #ifdef	__SYMBIAN32__
   155  
   156 OilFunctionImpl* __oil_function_impl_rowsad8x8_u8_ref() {
   157 		return &_oil_function_impl_rowsad8x8_u8_ref;
   158 }
   159 #endif
   160 
   161 #ifdef	__SYMBIAN32__
   162  
   163 OilFunctionImpl* __oil_function_impl_colsad8x8_u8_ref() {
   164 		return &_oil_function_impl_colsad8x8_u8_ref;
   165 }
   166 #endif
   167 
   168 
   169 
   170 #ifdef	__SYMBIAN32__
   171  
   172 EXPORT_C void** _oil_function_class_ptr_rowsad8x8_u8 ()	{
   173 	oil_function_class_ptr_rowsad8x8_u8 = __oil_function_class_rowsad8x8_u8();
   174 	return &oil_function_class_ptr_rowsad8x8_u8->func;
   175 	}
   176 #endif
   177 
   178 #ifdef	__SYMBIAN32__
   179  
   180 EXPORT_C void** _oil_function_class_ptr_colsad8x8_u8 ()	{
   181 	oil_function_class_ptr_colsad8x8_u8 = __oil_function_class_colsad8x8_u8();
   182 	return &oil_function_class_ptr_colsad8x8_u8->func;
   183 	}
   184 #endif
   185