Git init
[profile/ivi/liboil.git] / liboil / deprecated / vectoradd_s.c
1 /*
2  * LIBOIL - Library of Optimized Inner Loops
3  * Copyright (c) 2005 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
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #include <liboil/liboilfunction.h>
33 #include <liboil/simdpack/simdpack.h>
34
35 #define oil_type_min_f32 -1.0
36 #define oil_type_max_f32 1.0
37 #define oil_type_min_f64 -1.0
38 #define oil_type_max_f64 1.0
39
40 #define VECTORADD_S_DEFINE_IMPL(type,bigger)            \
41 static void vectoradd_s_ ## type ## _ref (      \
42     oil_type_ ## type *dest, int dstr,          \
43     oil_type_ ## type *src1, int sstr1,         \
44     oil_type_ ## type *src2, int sstr2,         \
45     int n) \
46 {                                               \
47   int i;                                        \
48   for(i=0;i<n;i++) {                            \
49     OIL_GET(dest,i*dstr, oil_type_ ## type) = CLAMP((oil_type_ ## bigger)OIL_GET(src1,i*sstr1, oil_type_ ## type) +     \
50         (oil_type_ ## bigger)OIL_GET(src2,i*sstr2, oil_type_ ## type),oil_type_min_ ## type, oil_type_max_ ## type);            \
51   }                                             \
52 }                                               \
53 OIL_DEFINE_CLASS (vectoradd_s_ ## type,         \
54     "oil_type_" #type " *d, int dstr, "         \
55     "oil_type_" #type " *s1, int sstr1, "               \
56     "oil_type_" #type " *s2, int sstr2, "               \
57     "int n");   \
58 OIL_DEFINE_IMPL_REF (vectoradd_s_ ## type ## _ref, vectoradd_s_ ## type);
59
60
61 /**
62  * oil_vectoradd_s_s8:
63  * @d:
64  * @dstr:
65  * @s1:
66  * @sstr1:
67  * @s2:
68  * @sstr2:
69  * @n:
70  *
71  * Adds each element of @s1 to @s2 and clamps the result to the range
72  * of the type and places the result in @d.
73  *
74  * FIXME: This function is difficult to optimize and will likely be
75  * replaced.
76  */
77 VECTORADD_S_DEFINE_IMPL (s8,s16);
78 /**
79  * oil_vectoradd_s_u8:
80  * @d:
81  * @dstr:
82  * @s1:
83  * @sstr1:
84  * @s2:
85  * @sstr2:
86  * @n:
87  *
88  * Adds each element of @s1 to @s2 and clamps the result to the range
89  * of the type and places the result in @d.
90  *
91  * FIXME: This function is difficult to optimize and will likely be
92  * replaced.
93  */
94 VECTORADD_S_DEFINE_IMPL (u8,u16);
95 /**
96  * oil_vectoradd_s_s16:
97  * @d:
98  * @dstr:
99  * @s1:
100  * @sstr1:
101  * @s2:
102  * @sstr2:
103  * @n:
104  *
105  * Adds each element of @s1 to @s2 and clamps the result to the range
106  * of the type and places the result in @d.
107  *
108  * FIXME: This function is difficult to optimize and will likely be
109  * replaced.
110  */
111 VECTORADD_S_DEFINE_IMPL (s16,s32);
112 /**
113  * oil_vectoradd_s_u16:
114  * @d:
115  * @dstr:
116  * @s1:
117  * @sstr1:
118  * @s2:
119  * @sstr2:
120  * @n:
121  *
122  * Adds each element of @s1 to @s2 and clamps the result to the range
123  * of the type and places the result in @d.
124  *
125  * FIXME: This function is difficult to optimize and will likely be
126  * replaced.
127  */
128 VECTORADD_S_DEFINE_IMPL (u16,u32);
129 /**
130  * oil_vectoradd_s_f32:
131  * @d:
132  * @dstr:
133  * @s1:
134  * @sstr1:
135  * @s2:
136  * @sstr2:
137  * @n:
138  *
139  * Adds each element of @s1 to @s2 and clamps the result to the range
140  * [-1,1] and places the result in @d.
141  *
142  * FIXME: This function is difficult to optimize and will likely be
143  * replaced.
144  */
145 VECTORADD_S_DEFINE_IMPL (f32,f32);
146 /**
147  * oil_vectoradd_s_f64:
148  * @d:
149  * @dstr:
150  * @s1:
151  * @sstr1:
152  * @s2:
153  * @sstr2:
154  * @n:
155  *
156  * Adds each element of @s1 to @s2 and clamps the result to the range
157  * [-1,1] and places the result in @d.
158  *
159  * FIXME: This function is difficult to optimize and will likely be
160  * replaced.
161  */
162 VECTORADD_S_DEFINE_IMPL (f64,f64);
163