]>
Commit | Line | Data |
---|---|---|
a49d2536 AC |
1 | /* |
2 | * Support for Intel Camera Imaging ISP subsystem. | |
3 | * Copyright (c) 2015, Intel Corporation. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms and conditions of the GNU General Public License, | |
7 | * version 2, as published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | */ | |
14 | ||
15 | #ifndef __ISP_OP2W_H_INCLUDED__ | |
16 | #define __ISP_OP2W_H_INCLUDED__ | |
17 | ||
18 | /* | |
19 | * This file is part of the Multi-precision vector operations exstension package. | |
20 | */ | |
21 | ||
22 | /* | |
23 | * Double-precision vector operations | |
24 | */ | |
25 | ||
26 | /* | |
27 | * Prerequisites: | |
28 | * | |
29 | */ | |
a49d2536 AC |
30 | |
31 | #ifdef INLINE_ISP_OP2W | |
4c5133f5 MCC |
32 | #define STORAGE_CLASS_ISP_OP2W_FUNC_H static inline |
33 | #define STORAGE_CLASS_ISP_OP2W_DATA_H static inline_DATA | |
a49d2536 | 34 | #else /* INLINE_ISP_OP2W */ |
4c5133f5 MCC |
35 | #define STORAGE_CLASS_ISP_OP2W_FUNC_H extern |
36 | #define STORAGE_CLASS_ISP_OP2W_DATA_H extern_DATA | |
a49d2536 AC |
37 | #endif /* INLINE_ISP_OP2W */ |
38 | ||
39 | /* | |
40 | * Double-precision data type specification | |
41 | */ | |
42 | ||
43 | #include "isp_op2w_types.h" | |
44 | ||
45 | /* | |
46 | * Double-precision prototype specification | |
47 | */ | |
48 | ||
49 | /* Arithmetic */ | |
50 | ||
d929fb4e | 51 | /* @brief bitwise AND |
a49d2536 AC |
52 | * |
53 | * @param[in] _a first argument | |
54 | * @param[in] _b second argument | |
55 | * | |
56 | * @return bitwise and of both input arguments | |
57 | * | |
58 | * This function will calculate the bitwise and. | |
59 | * result = _a & _b | |
60 | */ | |
61 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_and( | |
62 | const tvector2w _a, | |
63 | const tvector2w _b); | |
64 | ||
d929fb4e | 65 | /* @brief bitwise OR |
a49d2536 AC |
66 | * |
67 | * @param[in] _a first argument | |
68 | * @param[in] _b second argument | |
69 | * | |
70 | * @return bitwise or of both input arguments | |
71 | * | |
72 | * This function will calculate the bitwise or. | |
73 | * result = _a | _b | |
74 | */ | |
75 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_or( | |
76 | const tvector2w _a, | |
77 | const tvector2w _b); | |
78 | ||
d929fb4e | 79 | /* @brief bitwise XOR |
a49d2536 AC |
80 | * |
81 | * @param[in] _a first argument | |
82 | * @param[in] _b second argument | |
83 | * | |
84 | * @return bitwise xor of both input arguments | |
85 | * | |
86 | * This function will calculate the bitwise xor. | |
87 | * result = _a ^ _b | |
88 | */ | |
89 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_xor( | |
90 | const tvector2w _a, | |
91 | const tvector2w _b); | |
92 | ||
d929fb4e | 93 | /* @brief bitwise inverse |
a49d2536 AC |
94 | * |
95 | * @param[in] _a first argument | |
96 | * | |
97 | * @return bitwise inverse of both input arguments | |
98 | * | |
99 | * This function will calculate the bitwise inverse. | |
100 | * result = ~_a | |
101 | */ | |
102 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_inv( | |
103 | const tvector2w _a); | |
104 | ||
105 | /* Additive */ | |
106 | ||
d929fb4e | 107 | /* @brief addition |
a49d2536 AC |
108 | * |
109 | * @param[in] _a first argument | |
110 | * @param[in] _b second argument | |
111 | * | |
112 | * @return sum of both input arguments | |
113 | * | |
114 | * This function will calculate the sum of the input arguments. | |
115 | * in case of overflow it will wrap around. | |
116 | * result = _a + _b | |
117 | */ | |
118 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_add( | |
119 | const tvector2w _a, | |
120 | const tvector2w _b); | |
121 | ||
d929fb4e | 122 | /* @brief subtraction |
a49d2536 AC |
123 | * |
124 | * @param[in] _a first argument | |
125 | * @param[in] _b second argument | |
126 | * | |
127 | * @return _b subtracted from _a. | |
128 | * | |
129 | * This function will subtract _b from _a. | |
130 | * in case of overflow it will wrap around. | |
131 | * result = _a - _b | |
132 | */ | |
133 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_sub( | |
134 | const tvector2w _a, | |
135 | const tvector2w _b); | |
136 | ||
d929fb4e | 137 | /* @brief saturated addition |
a49d2536 AC |
138 | * |
139 | * @param[in] _a first argument | |
140 | * @param[in] _b second argument | |
141 | * | |
142 | * @return saturated sum of both input arguments | |
143 | * | |
144 | * This function will calculate the sum of the input arguments. | |
145 | * in case of overflow it will saturate | |
146 | * result = CLIP(_a + _b, MIN_RANGE, MAX_RANGE); | |
147 | */ | |
148 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_addsat( | |
149 | const tvector2w _a, | |
150 | const tvector2w _b); | |
151 | ||
d929fb4e | 152 | /* @brief saturated subtraction |
a49d2536 AC |
153 | * |
154 | * @param[in] _a first argument | |
155 | * @param[in] _b second argument | |
156 | * | |
157 | * @return saturated subtraction of both input arguments | |
158 | * | |
159 | * This function will subtract _b from _a. | |
160 | * in case of overflow it will saturate | |
161 | * result = CLIP(_a - _b, MIN_RANGE, MAX_RANGE); | |
162 | */ | |
163 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_subsat( | |
164 | const tvector2w _a, | |
165 | const tvector2w _b); | |
166 | ||
d929fb4e | 167 | /* @brief subtraction with shift right and rounding |
a49d2536 AC |
168 | * |
169 | * @param[in] _a first argument | |
170 | * @param[in] _b second argument | |
171 | * | |
172 | * @return (a - b) >> 1 | |
173 | * | |
174 | * This function subtracts _b from _a and right shifts | |
175 | * the result by 1 bit with rounding. | |
176 | * No overflow can occur. | |
177 | * result = (_a - _b) >> 1 | |
178 | * | |
179 | * Note: This function will be deprecated due to | |
180 | * the naming confusion and it will be replaced | |
181 | * by "OP_2w_subhalfrnd". | |
182 | */ | |
183 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_subasr1( | |
184 | const tvector2w _a, | |
185 | const tvector2w _b); | |
186 | ||
d929fb4e | 187 | /* @brief Subtraction with shift right and rounding |
a49d2536 AC |
188 | * |
189 | * @param[in] _a first operand | |
190 | * @param[in] _b second operand | |
191 | * | |
192 | * @return (_a - _b) >> 1 | |
193 | * | |
194 | * This function subtracts _b from _a and right shifts | |
195 | * the result by 1 bit with rounding. | |
196 | * No overflow can occur. | |
197 | */ | |
198 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_subhalfrnd( | |
199 | const tvector2w _a, | |
200 | const tvector2w _b); | |
201 | ||
d929fb4e | 202 | /* @brief Subtraction with shift right and no rounding |
a49d2536 AC |
203 | * |
204 | * @param[in] _a first operand | |
205 | * @param[in] _b second operand | |
206 | * | |
207 | * @return (_a - _b) >> 1 | |
208 | * | |
209 | * This function subtracts _b from _a and right shifts | |
210 | * the result by 1 bit without rounding (i.e. truncation). | |
211 | * No overflow can occur. | |
212 | */ | |
213 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_subhalf( | |
214 | const tvector2w _a, | |
215 | const tvector2w _b); | |
216 | ||
d929fb4e | 217 | /* @brief saturated absolute value |
a49d2536 AC |
218 | * |
219 | * @param[in] _a input | |
220 | * | |
221 | * @return saturated absolute value of the input | |
222 | * | |
223 | * This function will calculate the saturated absolute value of the input. | |
224 | * In case of overflow it will saturate. | |
225 | * if (_a > 0) return _a;<br> | |
226 | * else return CLIP(-_a, MIN_RANGE, MAX_RANGE);<br> | |
227 | */ | |
228 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_abs( | |
229 | const tvector2w _a); | |
230 | ||
d929fb4e | 231 | /* @brief saturated absolute difference |
a49d2536 AC |
232 | * |
233 | * @param[in] _a first argument | |
234 | * @param[in] _b second argument | |
235 | * | |
236 | * @return sat(abs(sat(a-b))); | |
237 | * | |
238 | * This function will calculate the saturated absolute value | |
239 | * of the saturated difference of both inputs. | |
240 | * result = sat(abs(sat(_a - _b))); | |
241 | */ | |
242 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_subabssat( | |
243 | const tvector2w _a, | |
244 | const tvector2w _b); | |
245 | ||
246 | /* Multiplicative */ | |
247 | ||
d929fb4e | 248 | /* @brief integer multiply |
a49d2536 AC |
249 | * |
250 | * @param[in] _a first argument | |
251 | * @param[in] _b second argument | |
252 | * | |
253 | * @return product of _a and _b | |
254 | * | |
255 | * This function will calculate the product | |
256 | * of the input arguments and returns the LSB | |
257 | * aligned double precision result. | |
258 | * In case of overflow it will wrap around. | |
259 | * result = _a * _b; | |
260 | */ | |
261 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_mul( | |
262 | const tvector2w _a, | |
263 | const tvector2w _b); | |
264 | ||
d929fb4e | 265 | /* @brief fractional saturating multiply |
a49d2536 AC |
266 | * |
267 | * @param[in] _a first argument | |
268 | * @param[in] _b second argument | |
269 | * | |
270 | * @return saturated product of _a and _b | |
271 | * | |
272 | * This function will calculate the fixed point | |
273 | * product of the input arguments | |
274 | * and returns a double precision result. | |
275 | * In case of overflow it will saturate. | |
276 | * result =((_a * _b) << 1) >> (2*NUM_BITS); | |
277 | */ | |
278 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_qmul( | |
279 | const tvector2w _a, | |
280 | const tvector2w _b); | |
281 | ||
d929fb4e | 282 | /* @brief fractional saturating multiply with rounding |
a49d2536 AC |
283 | * |
284 | * @param[in] _a first argument | |
285 | * @param[in] _b second argument | |
286 | * | |
287 | * @return product of _a and _b | |
288 | * | |
289 | * This function will calculate the fixed point | |
290 | * product of the input arguments | |
291 | * and returns a double precision result. | |
292 | * Depending on the rounding mode of the core | |
293 | * it will round to nearest or to nearest even. | |
294 | * In case of overflow it will saturate. | |
295 | * result = ((_a * _b) << 1) >> (2*NUM_BITS); | |
296 | */ | |
297 | ||
298 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_qrmul( | |
299 | const tvector2w _a, | |
300 | const tvector2w _b); | |
301 | ||
302 | /* Comparative */ | |
303 | ||
d929fb4e | 304 | /* @brief equal |
a49d2536 AC |
305 | * |
306 | * @param[in] _a first argument | |
307 | * @param[in] _b second argument | |
308 | * | |
309 | * @return _a == _b | |
310 | * | |
311 | * This function will return true if both inputs | |
312 | * are equal, and false if not equal. | |
313 | */ | |
314 | STORAGE_CLASS_ISP_OP2W_FUNC_H tflags OP_2w_eq( | |
315 | const tvector2w _a, | |
316 | const tvector2w _b); | |
317 | ||
d929fb4e | 318 | /* @brief not equal |
a49d2536 AC |
319 | * |
320 | * @param[in] _a first argument | |
321 | * @param[in] _b second argument | |
322 | * | |
323 | * @return _a != _b | |
324 | * | |
325 | * This function will return false if both inputs | |
326 | * are equal, and true if not equal. | |
327 | */ | |
328 | STORAGE_CLASS_ISP_OP2W_FUNC_H tflags OP_2w_ne( | |
329 | const tvector2w _a, | |
330 | const tvector2w _b); | |
331 | ||
d929fb4e | 332 | /* @brief less or equal |
a49d2536 AC |
333 | * |
334 | * @param[in] _a first argument | |
335 | * @param[in] _b second argument | |
336 | * | |
337 | * @return _a <= _b | |
338 | * | |
339 | * This function will return true if _a is smaller | |
340 | * or equal than _b. | |
341 | */ | |
342 | STORAGE_CLASS_ISP_OP2W_FUNC_H tflags OP_2w_le( | |
343 | const tvector2w _a, | |
344 | const tvector2w _b); | |
345 | ||
d929fb4e | 346 | /* @brief less then |
a49d2536 AC |
347 | * |
348 | * @param[in] _a first argument | |
349 | * @param[in] _b second argument | |
350 | * | |
351 | * @return _a < _b | |
352 | * | |
353 | * This function will return true if _a is smaller | |
354 | * than _b. | |
355 | */ | |
356 | STORAGE_CLASS_ISP_OP2W_FUNC_H tflags OP_2w_lt( | |
357 | const tvector2w _a, | |
358 | const tvector2w _b); | |
359 | ||
d929fb4e | 360 | /* @brief greater or equal |
a49d2536 AC |
361 | * |
362 | * @param[in] _a first argument | |
363 | * @param[in] _b second argument | |
364 | * | |
365 | * @return _a >= _b | |
366 | * | |
367 | * This function will return true if _a is greater | |
368 | * or equal than _b. | |
369 | */ | |
370 | STORAGE_CLASS_ISP_OP2W_FUNC_H tflags OP_2w_ge( | |
371 | const tvector2w _a, | |
372 | const tvector2w _b); | |
373 | ||
d929fb4e | 374 | /* @brief greater than |
a49d2536 AC |
375 | * |
376 | * @param[in] _a first argument | |
377 | * @param[in] _b second argument | |
378 | * | |
379 | * @return _a > _b | |
380 | * | |
381 | * This function will return true if _a is greater | |
382 | * than _b. | |
383 | */ | |
384 | STORAGE_CLASS_ISP_OP2W_FUNC_H tflags OP_2w_gt( | |
385 | const tvector2w _a, | |
386 | const tvector2w _b); | |
387 | ||
388 | /* Shift */ | |
389 | ||
d929fb4e | 390 | /* @brief aritmetic shift right |
a49d2536 AC |
391 | * |
392 | * @param[in] _a input | |
393 | * @param[in] _b shift amount | |
394 | * | |
395 | * @return _a >> _b | |
396 | * | |
397 | * This function will shift _a with _b bits to the right, | |
398 | * preserving the sign bit. | |
399 | * It asserts 0 <= _b <= MAX_SHIFT_2W. | |
400 | * The operation count for this function assumes that | |
401 | * the shift amount is a cloned scalar input. | |
402 | */ | |
403 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_asr( | |
404 | const tvector2w _a, | |
405 | const tvector2w _b); | |
406 | ||
d929fb4e | 407 | /* @brief aritmetic shift right with rounding |
a49d2536 AC |
408 | * |
409 | * @param[in] _a input | |
410 | * @param[in] _b shift amount | |
411 | * | |
412 | * @return _a >> _b | |
413 | * | |
414 | * If _b < 2*NUM_BITS, this function will shift _a with _b bits to the right, | |
415 | * preserving the sign bit, and depending on the rounding mode of the core | |
416 | * it will round to nearest or to nearest even. | |
417 | * If _b >= 2*NUM_BITS, this function will return 0. | |
418 | * It asserts 0 <= _b <= MAX_SHIFT_2W. | |
419 | * The operation count for this function assumes that | |
420 | * the shift amount is a cloned scalar input. | |
421 | */ | |
422 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_asrrnd( | |
423 | const tvector2w _a, | |
424 | const tvector2w _b); | |
425 | ||
d929fb4e | 426 | /* @brief saturating aritmetic shift left |
a49d2536 AC |
427 | * |
428 | * @param[in] _a input | |
429 | * @param[in] _b shift amount | |
430 | * | |
431 | * @return _a << _b | |
432 | * | |
433 | * If _b < MAX_BITDEPTH, this function will shift _a with _b bits to the left, | |
434 | * saturating at MIN_RANGE/MAX_RANGE in case of overflow. | |
435 | * If _b >= MAX_BITDEPTH, this function will return MIN_RANGE if _a < 0, | |
436 | * MAX_RANGE if _a > 0, 0 if _a == 0. | |
437 | * (with MAX_BITDEPTH=64) | |
438 | * It asserts 0 <= _b <= MAX_SHIFT_2W. | |
439 | * The operation count for this function assumes that | |
440 | * the shift amount is a cloned scalar input. | |
441 | */ | |
442 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_asl( | |
443 | const tvector2w _a, | |
444 | const tvector2w _b); | |
445 | ||
d929fb4e | 446 | /* @brief saturating aritmetic shift left |
a49d2536 AC |
447 | * |
448 | * @param[in] _a input | |
449 | * @param[in] _b shift amount | |
450 | * | |
451 | * @return _a << _b | |
452 | * | |
453 | * This function is identical to OP_2w_asl( ) | |
454 | */ | |
455 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_aslsat( | |
456 | const tvector2w _a, | |
457 | const tvector2w _b); | |
458 | ||
d929fb4e | 459 | /* @brief logical shift left |
a49d2536 AC |
460 | * |
461 | * @param[in] _a input | |
462 | * @param[in] _b shift amount | |
463 | * | |
464 | * @return _a << _b | |
465 | * | |
466 | * This function will shift _a with _b bits to the left. | |
467 | * It will insert zeroes on the right. | |
468 | * It asserts 0 <= _b <= MAX_SHIFT_2W. | |
469 | * The operation count for this function assumes that | |
470 | * the shift amount is a cloned scalar input. | |
471 | */ | |
472 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_lsl( | |
473 | const tvector2w _a, | |
474 | const tvector2w _b); | |
475 | ||
d929fb4e | 476 | /* @brief logical shift right |
a49d2536 AC |
477 | * |
478 | * @param[in] _a input | |
479 | * @param[in] _b shift amount | |
480 | * | |
481 | * @return _a >> _b | |
482 | * | |
483 | * This function will shift _a with _b bits to the right. | |
484 | * It will insert zeroes on the left. | |
485 | * It asserts 0 <= _b <= MAX_SHIFT_2W. | |
486 | * The operation count for this function assumes that | |
487 | * the shift amount is a cloned scalar input. | |
488 | */ | |
489 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_lsr( | |
490 | const tvector2w _a, | |
491 | const tvector2w _b); | |
492 | ||
493 | /* clipping */ | |
494 | ||
d929fb4e | 495 | /* @brief Clip asymmetrical |
a49d2536 AC |
496 | * |
497 | * @param[in] _a first argument | |
498 | * @param[in] _b second argument | |
499 | * | |
500 | * @return _a clipped between ~_b and b | |
501 | * | |
502 | * This function will clip the first argument between | |
503 | * (-_b - 1) and _b. | |
504 | * It asserts _b >= 0. | |
505 | */ | |
506 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_clip_asym( | |
507 | const tvector2w _a, | |
508 | const tvector2w _b); | |
509 | ||
d929fb4e | 510 | /* @brief Clip zero |
a49d2536 AC |
511 | * |
512 | * @param[in] _a first argument | |
513 | * @param[in] _b second argument | |
514 | * | |
515 | * @return _a clipped beteween 0 and _b | |
516 | * | |
517 | * This function will clip the first argument between | |
518 | * zero and _b. | |
519 | * It asserts _b >= 0. | |
520 | */ | |
521 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_clipz( | |
522 | const tvector2w _a, | |
523 | const tvector2w _b); | |
524 | ||
525 | /* division */ | |
526 | ||
d929fb4e | 527 | /* @brief Truncated division |
a49d2536 AC |
528 | * |
529 | * @param[in] _a first argument | |
530 | * @param[in] _b second argument | |
531 | * | |
532 | * @return trunc( _a / _b ) | |
533 | * | |
534 | * This function will divide the first argument by | |
535 | * the second argument, with rounding toward 0. | |
536 | * If _b == 0 and _a < 0, the function will return MIN_RANGE. | |
537 | * If _b == 0 and _a == 0, the function will return 0. | |
538 | * If _b == 0 and _a > 0, the function will return MAX_RANGE. | |
539 | */ | |
540 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_div( | |
541 | const tvector2w _a, | |
542 | const tvector2w _b); | |
543 | ||
d929fb4e | 544 | /* @brief Saturating truncated division |
a49d2536 AC |
545 | * |
546 | * @param[in] _a first argument | |
547 | * @param[in] _b second argument | |
548 | * | |
549 | * @return CLIP( trunc( _a / _b ), MIN_RANGE1w, MAX_RANGE1w ) | |
550 | * | |
551 | * This function will divide the first argument by | |
552 | * the second argument, with rounding toward 0, and | |
553 | * saturate the result to the range of single precision. | |
554 | * If _b == 0 and _a < 0, the function will return MIN_RANGE. | |
555 | * If _b == 0 and _a == 0, the function will return 0. | |
556 | * If _b == 0 and _a > 0, the function will return MAX_RANGE. | |
557 | */ | |
558 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector1w OP_2w_divh( | |
559 | const tvector2w _a, | |
560 | const tvector1w _b); | |
561 | ||
d929fb4e | 562 | /* @brief Modulo |
a49d2536 AC |
563 | * |
564 | * @param[in] _a first argument | |
565 | * @param[in] _b second argument | |
566 | * | |
567 | * @return n/a | |
568 | * | |
569 | * This function has not yet been implemented. | |
570 | */ | |
571 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_mod( | |
572 | const tvector2w _a, | |
573 | const tvector2w _b); | |
574 | ||
d929fb4e | 575 | /* @brief Unsigned Integer Square root |
a49d2536 AC |
576 | * |
577 | * @param[in] _a input | |
578 | * | |
579 | * @return square root of _a | |
580 | * | |
581 | * This function will calculate the unsigned integer square root of _a | |
582 | */ | |
583 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector1w_unsigned OP_2w_sqrt_u( | |
584 | const tvector2w_unsigned _a); | |
585 | ||
586 | /* Miscellaneous */ | |
587 | ||
d929fb4e | 588 | /* @brief Multiplexer |
a49d2536 AC |
589 | * |
590 | * @param[in] _a first argument | |
591 | * @param[in] _b second argument | |
592 | * @param[in] _c condition | |
593 | * | |
594 | * @return _c ? _a : _b | |
595 | * | |
596 | * This function will return _a if the condition _c | |
597 | * is true and _b otherwise. | |
598 | */ | |
599 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_mux( | |
600 | const tvector2w _a, | |
601 | const tvector2w _b, | |
602 | const tflags _c); | |
603 | ||
d929fb4e | 604 | /* @brief Average without rounding |
a49d2536 AC |
605 | * |
606 | * @param[in] _a first operand | |
607 | * @param[in] _b second operand | |
608 | * | |
609 | * @return (_a + _b) >> 1 | |
610 | * | |
611 | * This function will add _a and _b, and right shift | |
612 | * the result by one without rounding. No overflow | |
613 | * will occur because addition is performed in the | |
614 | * proper precision. | |
615 | */ | |
616 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_avg( | |
617 | const tvector2w _a, | |
618 | const tvector2w _b); | |
619 | ||
d929fb4e | 620 | /* @brief Average with rounding |
a49d2536 AC |
621 | * |
622 | * @param[in] _a first argument | |
623 | * @param[in] _b second argument | |
624 | * | |
625 | * @return (_a + _b) >> 1 | |
626 | * | |
627 | * This function will add _a and _b at full precision, | |
628 | * and right shift with rounding the result with 1 bit. | |
629 | * Depending on the rounding mode of the core | |
630 | * it will round to nearest or to nearest even. | |
631 | */ | |
632 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_avgrnd( | |
633 | const tvector2w _a, | |
634 | const tvector2w _b); | |
635 | ||
d929fb4e | 636 | /* @brief Minimum |
a49d2536 AC |
637 | * |
638 | * @param[in] _a first argument | |
639 | * @param[in] _b second argument | |
640 | * | |
641 | * @return (_a < _b) ? _a : _b; | |
642 | * | |
643 | * This function will return the smallest of both | |
644 | * input arguments. | |
645 | */ | |
646 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_min( | |
647 | const tvector2w _a, | |
648 | const tvector2w _b); | |
649 | ||
d929fb4e | 650 | /* @brief Maximum |
a49d2536 AC |
651 | * |
652 | * @param[in] _a first argument | |
653 | * @param[in] _b second argument | |
654 | * | |
655 | * @return (_a > _b) ? _a : _b; | |
656 | * | |
657 | * This function will return the largest of both | |
658 | * input arguments. | |
659 | */ | |
660 | STORAGE_CLASS_ISP_OP2W_FUNC_H tvector2w OP_2w_max( | |
661 | const tvector2w _a, | |
662 | const tvector2w _b); | |
663 | ||
664 | #ifndef INLINE_ISP_OP2W | |
665 | #define STORAGE_CLASS_ISP_OP2W_FUNC_C | |
666 | #define STORAGE_CLASS_ISP_OP2W_DATA_C const | |
667 | #else /* INLINE_ISP_OP2W */ | |
668 | #define STORAGE_CLASS_ISP_OP2W_FUNC_C STORAGE_CLASS_ISP_OP2W_FUNC_H | |
669 | #define STORAGE_CLASS_ISP_OP2W_DATA_C STORAGE_CLASS_ISP_OP2W_DATA_H | |
670 | #include "isp_op2w.c" | |
671 | #define ISP_OP2W_INLINED | |
672 | #endif /* INLINE_ISP_OP2W */ | |
673 | ||
674 | #endif /* __ISP_OP2W_H_INCLUDED__ */ |