]>
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 _REF_VECTOR_FUNC_H_INCLUDED_ | |
16 | #define _REF_VECTOR_FUNC_H_INCLUDED_ | |
17 | ||
a49d2536 AC |
18 | |
19 | #ifdef INLINE_VECTOR_FUNC | |
4c5133f5 MCC |
20 | #define STORAGE_CLASS_REF_VECTOR_FUNC_H static inline |
21 | #define STORAGE_CLASS_REF_VECTOR_DATA_H static inline_DATA | |
a49d2536 | 22 | #else /* INLINE_VECTOR_FUNC */ |
4c5133f5 MCC |
23 | #define STORAGE_CLASS_REF_VECTOR_FUNC_H extern |
24 | #define STORAGE_CLASS_REF_VECTOR_DATA_H extern_DATA | |
a49d2536 AC |
25 | #endif /* INLINE_VECTOR_FUNC */ |
26 | ||
27 | ||
28 | #include "ref_vector_func_types.h" | |
29 | ||
d929fb4e | 30 | /* @brief Doubling multiply accumulate with saturation |
a49d2536 AC |
31 | * |
32 | * @param[in] acc accumulator | |
33 | * @param[in] a multiply input | |
34 | * @param[in] b multiply input | |
35 | * | |
36 | * @return acc + (a*b) | |
37 | * | |
38 | * This function will do a doubling multiply ont | |
39 | * inputs a and b, and will add the result to acc. | |
40 | * in case of an overflow of acc, it will saturate. | |
41 | */ | |
42 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector2w OP_1w_maccd_sat( | |
43 | tvector2w acc, | |
44 | tvector1w a, | |
45 | tvector1w b ); | |
46 | ||
d929fb4e | 47 | /* @brief Doubling multiply accumulate |
a49d2536 AC |
48 | * |
49 | * @param[in] acc accumulator | |
50 | * @param[in] a multiply input | |
51 | * @param[in] b multiply input | |
52 | * | |
53 | * @return acc + (a*b) | |
54 | * | |
55 | * This function will do a doubling multiply ont | |
56 | * inputs a and b, and will add the result to acc. | |
57 | * in case of overflow it will not saturate but wrap around. | |
58 | */ | |
59 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector2w OP_1w_maccd( | |
60 | tvector2w acc, | |
61 | tvector1w a, | |
62 | tvector1w b ); | |
63 | ||
d929fb4e | 64 | /* @brief Re-aligning multiply |
a49d2536 AC |
65 | * |
66 | * @param[in] a multiply input | |
67 | * @param[in] b multiply input | |
68 | * @param[in] shift shift amount | |
69 | * | |
70 | * @return (a*b)>>shift | |
71 | * | |
72 | * This function will multiply a with b, followed by a right | |
73 | * shift with rounding. the result is saturated and casted | |
74 | * to single precision. | |
75 | */ | |
76 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_mul_realigning( | |
77 | tvector1w a, | |
78 | tvector1w b, | |
79 | tscalar1w shift ); | |
80 | ||
d929fb4e | 81 | /* @brief Leading bit index |
a49d2536 AC |
82 | * |
83 | * @param[in] a input | |
84 | * | |
85 | * @return index of the leading bit of each element | |
86 | * | |
87 | * This function finds the index of leading one (set) bit of the | |
88 | * input. The index starts with 0 for the LSB and can go upto | |
89 | * ISP_VEC_ELEMBITS-1 for the MSB. For an input equal to zero, | |
90 | * the returned index is -1. | |
91 | */ | |
92 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_lod( | |
93 | tvector1w a); | |
94 | ||
d929fb4e | 95 | /* @brief Config Unit Input Processing |
a49d2536 AC |
96 | * |
97 | * @param[in] a input | |
98 | * @param[in] input_scale input scaling factor | |
99 | * @param[in] input_offset input offset factor | |
100 | * | |
101 | * @return scaled & offset added input clamped to MAXVALUE | |
102 | * | |
103 | * As part of input processing for piecewise linear estimation config unit, | |
104 | * this function will perform scaling followed by adding offset and | |
105 | * then clamping to the MAX InputValue | |
106 | * It asserts -MAX_SHIFT_1W <= input_scale <= MAX_SHIFT_1W, and | |
107 | * -MAX_SHIFT_1W <= input_offset <= MAX_SHIFT_1W | |
108 | */ | |
109 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_input_scaling_offset_clamping( | |
110 | tvector1w a, | |
111 | tscalar1w_5bit_signed input_scale, | |
112 | tscalar1w_5bit_signed input_offset); | |
113 | ||
d929fb4e | 114 | /* @brief Config Unit Output Processing |
a49d2536 AC |
115 | * |
116 | * @param[in] a output | |
117 | * @param[in] output_scale output scaling factor | |
118 | * | |
119 | * @return scaled & clamped output value | |
120 | * | |
121 | * As part of output processing for piecewise linear estimation config unit, | |
122 | * This function will perform scaling and then clamping to output | |
123 | * MAX value. | |
124 | * It asserts -MAX_SHIFT_1W <= output_scale <= MAX_SHIFT_1W | |
125 | */ | |
126 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_output_scaling_clamping( | |
127 | tvector1w a, | |
128 | tscalar1w_5bit_signed output_scale); | |
129 | ||
d929fb4e | 130 | /* @brief Config Unit Piecewiselinear estimation |
a49d2536 AC |
131 | * |
132 | * @param[in] a input | |
133 | * @param[in] config_points config parameter structure | |
134 | * | |
135 | * @return piecewise linear estimated output | |
136 | * | |
137 | * Given a set of N points {(x1,y1),()x2,y2), ....,(xn,yn)}, to find | |
138 | * the functional value at an arbitrary point around the input set, | |
139 | * this function will perform input processing followed by piecewise | |
140 | * linear estimation and then output processing to yield the final value. | |
141 | */ | |
142 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_piecewise_estimation( | |
143 | tvector1w a, | |
144 | ref_config_points config_points); | |
145 | ||
d929fb4e | 146 | /* @brief Fast Config Unit |
a49d2536 AC |
147 | * |
148 | * @param[in] x input | |
149 | * @param[in] init_vectors LUT data structure | |
150 | * | |
151 | * @return piecewise linear estimated output | |
152 | * This block gets an input x and a set of input configuration points stored in a look-up | |
153 | * table of 32 elements. First, the x input is clipped to be within the range [x1, xn+1]. | |
154 | * Then, it computes the interval in which the input lies. Finally, the output is computed | |
155 | * by performing linear interpolation based on the interval properties (i.e. x_prev, slope, | |
156 | * and offset). This block assumes that the points are equally spaced and that the interval | |
157 | * size is a power of 2. | |
158 | **/ | |
159 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_XCU( | |
160 | tvector1w x, | |
161 | xcu_ref_init_vectors init_vectors); | |
162 | ||
163 | ||
d929fb4e | 164 | /* @brief LXCU |
a49d2536 AC |
165 | * |
166 | * @param[in] x input | |
167 | * @param[in] init_vectors LUT data structure | |
168 | * | |
169 | * @return logarithmic piecewise linear estimated output. | |
170 | * This block gets an input x and a set of input configuration points stored in a look-up | |
171 | * table of 32 elements. It computes the interval in which the input lies. | |
172 | * Then output is computed by performing linear interpolation based on the interval | |
173 | * properties (i.e. x_prev, slope, * and offset). | |
174 | * This BBB assumes spacing x-coordinates of "init vectors" increase exponentially as | |
175 | * shown below. | |
176 | * interval size : 2^0 2^1 2^2 2^3 | |
177 | * x-coordinates: x0<--->x1<---->x2<---->x3<----> | |
178 | **/ | |
179 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_LXCU( | |
180 | tvector1w x, | |
181 | xcu_ref_init_vectors init_vectors); | |
182 | ||
d929fb4e | 183 | /* @brief Coring |
a49d2536 AC |
184 | * |
185 | * @param[in] coring_vec Amount of coring based on brightness level | |
186 | * @param[in] filt_input Vector of input pixels on which Coring is applied | |
187 | * @param[in] m_CnrCoring0 Coring Level0 | |
188 | * | |
189 | * @return vector of filtered pixels after coring is applied | |
190 | * | |
191 | * This function will perform adaptive coring based on brightness level to | |
192 | * remove noise | |
193 | */ | |
194 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w coring( | |
195 | tvector1w coring_vec, | |
196 | tvector1w filt_input, | |
197 | tscalar1w m_CnrCoring0 ); | |
198 | ||
d929fb4e | 199 | /* @brief Normalised FIR with coefficients [3,4,1] |
a49d2536 AC |
200 | * |
201 | * @param[in] m 1x3 matrix with pixels | |
202 | * | |
203 | * @return filtered output | |
204 | * | |
205 | * This function will calculate the | |
206 | * Normalised FIR with coefficients [3,4,1], | |
207 | *-5dB at Fs/2, -90 degree phase shift (quarter pixel) | |
208 | */ | |
209 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_5dB_m90_nrm ( | |
210 | const s_1w_1x3_matrix m); | |
211 | ||
d929fb4e | 212 | /* @brief Normalised FIR with coefficients [1,4,3] |
a49d2536 AC |
213 | * |
214 | * @param[in] m 1x3 matrix with pixels | |
215 | * | |
216 | * @return filtered output | |
217 | * | |
218 | * This function will calculate the | |
219 | * Normalised FIR with coefficients [1,4,3], | |
220 | *-5dB at Fs/2, +90 degree phase shift (quarter pixel) | |
221 | */ | |
222 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_5dB_p90_nrm ( | |
223 | const s_1w_1x3_matrix m); | |
224 | ||
d929fb4e | 225 | /* @brief Normalised FIR with coefficients [1,2,1] |
a49d2536 AC |
226 | * |
227 | * @param[in] m 1x3 matrix with pixels | |
228 | * | |
229 | * @return filtered output | |
230 | * | |
231 | * This function will calculate the | |
232 | * Normalised FIR with coefficients [1,2,1], -6dB at Fs/2 | |
233 | */ | |
234 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_6dB_nrm ( | |
235 | const s_1w_1x3_matrix m); | |
236 | ||
d929fb4e | 237 | /* @brief Normalised FIR with coefficients [13,16,3] |
a49d2536 AC |
238 | * |
239 | * @param[in] m 1x3 matrix with pixels | |
240 | * | |
241 | * @return filtered output | |
242 | * | |
243 | * This function will calculate the | |
244 | * Normalised FIR with coefficients [13,16,3], | |
245 | */ | |
246 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_6dB_nrm_ph0 ( | |
247 | const s_1w_1x3_matrix m); | |
248 | ||
d929fb4e | 249 | /* @brief Normalised FIR with coefficients [9,16,7] |
a49d2536 AC |
250 | * |
251 | * @param[in] m 1x3 matrix with pixels | |
252 | * | |
253 | * @return filtered output | |
254 | * | |
255 | * This function will calculate the | |
256 | * Normalised FIR with coefficients [9,16,7], | |
257 | */ | |
258 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_6dB_nrm_ph1 ( | |
259 | const s_1w_1x3_matrix m); | |
260 | ||
d929fb4e | 261 | /* @brief Normalised FIR with coefficients [5,16,11] |
a49d2536 AC |
262 | * |
263 | * @param[in] m 1x3 matrix with pixels | |
264 | * | |
265 | * @return filtered output | |
266 | * | |
267 | * This function will calculate the | |
268 | * Normalised FIR with coefficients [5,16,11], | |
269 | */ | |
270 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_6dB_nrm_ph2 ( | |
271 | const s_1w_1x3_matrix m); | |
272 | ||
d929fb4e | 273 | /* @brief Normalised FIR with coefficients [1,16,15] |
a49d2536 AC |
274 | * |
275 | * @param[in] m 1x3 matrix with pixels | |
276 | * | |
277 | * @return filtered output | |
278 | * | |
279 | * This function will calculate the | |
280 | * Normalised FIR with coefficients [1,16,15], | |
281 | */ | |
282 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_6dB_nrm_ph3 ( | |
283 | const s_1w_1x3_matrix m); | |
284 | ||
d929fb4e | 285 | /* @brief Normalised FIR with programable phase shift |
a49d2536 AC |
286 | * |
287 | * @param[in] m 1x3 matrix with pixels | |
288 | * @param[in] coeff phase shift | |
289 | * | |
290 | * @return filtered output | |
291 | * | |
292 | * This function will calculate the | |
293 | * Normalised FIR with coefficients [8-coeff,16,8+coeff], | |
294 | */ | |
295 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_6dB_nrm_calc_coeff ( | |
296 | const s_1w_1x3_matrix m, tscalar1w_3bit coeff); | |
297 | ||
d929fb4e | 298 | /* @brief 3 tap FIR with coefficients [1,1,1] |
a49d2536 AC |
299 | * |
300 | * @param[in] m 1x3 matrix with pixels | |
301 | * | |
302 | * @return filtered output | |
303 | * | |
304 | * This function will calculate the | |
305 | * FIR with coefficients [1,1,1], -9dB at Fs/2 normalized with factor 1/2 | |
306 | */ | |
307 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x3m_9dB_nrm ( | |
308 | const s_1w_1x3_matrix m); | |
309 | ||
310 | #ifdef ISP2401 | |
d929fb4e | 311 | /* @brief symmetric 3 tap FIR acts as LPF or BSF |
a49d2536 AC |
312 | * |
313 | * @param[in] m 1x3 matrix with pixels | |
314 | * @param[in] k filter coefficient shift | |
315 | * @param[in] bsf_flag 1 for BSF and 0 for LPF | |
316 | * | |
317 | * @return filtered output | |
318 | * | |
319 | * This function performs variable coefficient symmetric 3 tap filter which can | |
320 | * be either used as Low Pass Filter or Band Stop Filter. | |
321 | * Symmetric 3tap tap filter with DC gain 1 has filter coefficients [a, 1-2a, a] | |
322 | * For LPF 'a' can be approximated as (1 - 2^(-k))/4, k = 0, 1, 2, ... | |
323 | * and filter output can be approximated as: | |
324 | * out_LPF = ((v00 + v02) - ((v00 + v02) >> k) + (2 * (v01 + (v01 >> k)))) >> 2 | |
325 | * For BSF 'a' can be approximated as (1 + 2^(-k))/4, k = 0, 1, 2, ... | |
326 | * and filter output can be approximated as: | |
327 | * out_BSF = ((v00 + v02) + ((v00 + v02) >> k) + (2 * (v01 - (v01 >> k)))) >> 2 | |
328 | * For a given filter coefficient shift 'k' and bsf_flag this function | |
329 | * behaves either as LPF or BSF. | |
330 | * All computation is done using 1w arithmetic and implementation does not use | |
331 | * any multiplication. | |
332 | */ | |
333 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
334 | sym_fir1x3m_lpf_bsf(s_1w_1x3_matrix m, | |
335 | tscalar1w k, | |
336 | tscalar_bool bsf_flag); | |
337 | #endif | |
338 | ||
d929fb4e | 339 | /* @brief Normalised 2D FIR with coefficients [1;2;1] * [1,2,1] |
a49d2536 AC |
340 | * |
341 | * @param[in] m 3x3 matrix with pixels | |
342 | * | |
343 | * @return filtered output | |
344 | * | |
345 | * This function will calculate the | |
346 | * Normalised FIR with coefficients [1;2;1] * [1,2,1] | |
347 | * Unity gain filter through repeated scaling and rounding | |
348 | * - 6 rotate operations per output | |
349 | * - 8 vector operations per output | |
350 | * _______ | |
351 | * 14 total operations | |
352 | */ | |
353 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir3x3m_6dB_nrm ( | |
354 | const s_1w_3x3_matrix m); | |
355 | ||
d929fb4e | 356 | /* @brief Normalised 2D FIR with coefficients [1;1;1] * [1,1,1] |
a49d2536 AC |
357 | * |
358 | * @param[in] m 3x3 matrix with pixels | |
359 | * | |
360 | * @return filtered output | |
361 | * | |
362 | * This function will calculate the | |
363 | * Normalised FIR with coefficients [1;1;1] * [1,1,1] | |
364 | * | |
365 | * (near) Unity gain filter through repeated scaling and rounding | |
366 | * - 6 rotate operations per output | |
367 | * - 8 vector operations per output | |
368 | * _______ | |
369 | * 14 operations | |
370 | */ | |
371 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir3x3m_9dB_nrm ( | |
372 | const s_1w_3x3_matrix m); | |
373 | ||
d929fb4e | 374 | /* @brief Normalised dual output 2D FIR with coefficients [1;2;1] * [1,2,1] |
a49d2536 AC |
375 | * |
376 | * @param[in] m 4x3 matrix with pixels | |
377 | * | |
378 | * @return two filtered outputs (2x1 matrix) | |
379 | * | |
380 | * This function will calculate the | |
381 | * Normalised FIR with coefficients [1;2;1] * [1,2,1] | |
382 | * and produce two outputs (vertical) | |
383 | * Unity gain filter through repeated scaling and rounding | |
384 | * compute two outputs per call to re-use common intermediates | |
385 | * - 4 rotate operations per output | |
386 | * - 6 vector operations per output (alternative possible, but in this | |
387 | * form it's not obvious to re-use variables) | |
388 | * _______ | |
389 | * 10 total operations | |
390 | */ | |
391 | STORAGE_CLASS_REF_VECTOR_FUNC_H s_1w_2x1_matrix fir3x3m_6dB_out2x1_nrm ( | |
392 | const s_1w_4x3_matrix m); | |
393 | ||
d929fb4e | 394 | /* @brief Normalised dual output 2D FIR with coefficients [1;1;1] * [1,1,1] |
a49d2536 AC |
395 | * |
396 | * @param[in] m 4x3 matrix with pixels | |
397 | * | |
398 | * @return two filtered outputs (2x1 matrix) | |
399 | * | |
400 | * This function will calculate the | |
401 | * Normalised FIR with coefficients [1;1;1] * [1,1,1] | |
402 | * and produce two outputs (vertical) | |
403 | * (near) Unity gain filter through repeated scaling and rounding | |
404 | * compute two outputs per call to re-use common intermediates | |
405 | * - 4 rotate operations per output | |
406 | * - 7 vector operations per output (alternative possible, but in this | |
407 | * form it's not obvious to re-use variables) | |
408 | * _______ | |
409 | * 11 total operations | |
410 | */ | |
411 | STORAGE_CLASS_REF_VECTOR_FUNC_H s_1w_2x1_matrix fir3x3m_9dB_out2x1_nrm ( | |
412 | const s_1w_4x3_matrix m); | |
413 | ||
d929fb4e | 414 | /* @brief Normalised 2D FIR 5x5 |
a49d2536 AC |
415 | * |
416 | * @param[in] m 5x5 matrix with pixels | |
417 | * | |
418 | * @return filtered output | |
419 | * | |
420 | * This function will calculate the | |
421 | * Normalised FIR with coefficients [1;1;1] * [1;2;1] * [1,2,1] * [1,1,1] | |
422 | * and produce a filtered output | |
423 | * (near) Unity gain filter through repeated scaling and rounding | |
424 | * - 20 rotate operations per output | |
425 | * - 28 vector operations per output | |
426 | * _______ | |
427 | * 48 total operations | |
428 | */ | |
429 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir5x5m_15dB_nrm ( | |
430 | const s_1w_5x5_matrix m); | |
431 | ||
d929fb4e | 432 | /* @brief Normalised FIR 1x5 |
a49d2536 AC |
433 | * |
434 | * @param[in] m 1x5 matrix with pixels | |
435 | * | |
436 | * @return filtered output | |
437 | * | |
438 | * This function will calculate the | |
439 | * Normalised FIR with coefficients [1,2,1] * [1,1,1] = [1,4,6,4,1] | |
440 | * and produce a filtered output | |
441 | * (near) Unity gain filter through repeated scaling and rounding | |
442 | * - 4 rotate operations per output | |
443 | * - 5 vector operations per output | |
444 | * _______ | |
445 | * 9 total operations | |
446 | */ | |
447 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x5m_12dB_nrm ( | |
448 | const s_1w_1x5_matrix m); | |
449 | ||
d929fb4e | 450 | /* @brief Normalised 2D FIR 5x5 |
a49d2536 AC |
451 | * |
452 | * @param[in] m 5x5 matrix with pixels | |
453 | * | |
454 | * @return filtered output | |
455 | * | |
456 | * This function will calculate the | |
457 | * Normalised FIR with coefficients [1;2;1] * [1;2;1] * [1,2,1] * [1,2,1] | |
458 | * and produce a filtered output | |
459 | * (near) Unity gain filter through repeated scaling and rounding | |
460 | * - 20 rotate operations per output | |
461 | * - 30 vector operations per output | |
462 | * _______ | |
463 | * 50 total operations | |
464 | */ | |
465 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir5x5m_12dB_nrm ( | |
466 | const s_1w_5x5_matrix m); | |
467 | ||
d929fb4e | 468 | /* @brief Approximate averaging FIR 1x5 |
a49d2536 AC |
469 | * |
470 | * @param[in] m 1x5 matrix with pixels | |
471 | * | |
472 | * @return filtered output | |
473 | * | |
474 | * This function will produce filtered output by | |
475 | * applying the filter coefficients (1/8) * [1,1,1,1,1] | |
476 | * _______ | |
477 | * 5 vector operations | |
478 | */ | |
479 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x5m_box ( | |
480 | s_1w_1x5_matrix m); | |
481 | ||
d929fb4e | 482 | /* @brief Approximate averaging FIR 1x9 |
a49d2536 AC |
483 | * |
484 | * @param[in] m 1x9 matrix with pixels | |
485 | * | |
486 | * @return filtered output | |
487 | * | |
488 | * This function will produce filtered output by | |
489 | * applying the filter coefficients (1/16) * [1,1,1,1,1,1,1,1,1] | |
490 | * _______ | |
491 | * 9 vector operations | |
492 | */ | |
493 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x9m_box ( | |
494 | s_1w_1x9_matrix m); | |
495 | ||
d929fb4e | 496 | /* @brief Approximate averaging FIR 1x11 |
a49d2536 AC |
497 | * |
498 | * @param[in] m 1x11 matrix with pixels | |
499 | * | |
500 | * @return filtered output | |
501 | * | |
502 | * This function will produce filtered output by | |
503 | * applying the filter coefficients (1/16) * [1,1,1,1,1,1,1,1,1,1,1] | |
504 | * _______ | |
505 | * 12 vector operations | |
506 | */ | |
507 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w fir1x11m_box ( | |
508 | s_1w_1x11_matrix m); | |
509 | ||
d929fb4e | 510 | /* @brief Symmetric 7 tap filter with normalization |
a49d2536 AC |
511 | * |
512 | * @param[in] in 1x7 matrix with pixels | |
513 | * @param[in] coeff 1x4 matrix with coefficients | |
514 | * @param[in] out_shift output pixel shift value for normalization | |
515 | * | |
516 | * @return symmetric 7 tap filter output | |
517 | * | |
518 | * This function performs symmetric 7 tap filter over input pixels. | |
519 | * Filter sum is normalized by shifting out_shift bits. | |
520 | * Filter sum: p0*c3 + p1*c2 + p2*c1 + p3*c0 + p4*c1 + p5*c2 + p6*c3 | |
521 | * is implemented as: (p0 + p6)*c3 + (p1 + p5)*c2 + (p2 + p4)*c1 + p3*c0 to | |
522 | * reduce multiplication. | |
523 | * Input pixels should to be scaled, otherwise overflow is possible during | |
524 | * addition | |
525 | */ | |
526 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
527 | fir1x7m_sym_nrm(s_1w_1x7_matrix in, | |
528 | s_1w_1x4_matrix coeff, | |
529 | tvector1w out_shift); | |
530 | ||
d929fb4e | 531 | /* @brief Symmetric 7 tap filter with normalization at input side |
a49d2536 AC |
532 | * |
533 | * @param[in] in 1x7 matrix with pixels | |
534 | * @param[in] coeff 1x4 matrix with coefficients | |
535 | * | |
536 | * @return symmetric 7 tap filter output | |
537 | * | |
538 | * This function performs symmetric 7 tap filter over input pixels. | |
539 | * Filter sum: p0*c3 + p1*c2 + p2*c1 + p3*c0 + p4*c1 + p5*c2 + p6*c3 | |
540 | * = (p0 + p6)*c3 + (p1 + p5)*c2 + (p2 + p4)*c1 + p3*c0 | |
541 | * Input pixels and coefficients are in Qn format, where n = | |
542 | * ISP_VEC_ELEMBITS - 1 (ie Q15 for Broxton) | |
543 | * To avoid double precision arithmetic input pixel sum and final sum is | |
544 | * implemented using avgrnd and coefficient multiplication using qrmul. | |
545 | * Final result is in Qm format where m = ISP_VEC_ELEMBITS - 2 (ie Q14 for | |
546 | * Broxton) | |
547 | */ | |
548 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
549 | fir1x7m_sym_innrm_approx(s_1w_1x7_matrix in, | |
550 | s_1w_1x4_matrix coeff); | |
551 | ||
d929fb4e | 552 | /* @brief Symmetric 7 tap filter with normalization at output side |
a49d2536 AC |
553 | * |
554 | * @param[in] in 1x7 matrix with pixels | |
555 | * @param[in] coeff 1x4 matrix with coefficients | |
556 | * | |
557 | * @return symmetric 7 tap filter output | |
558 | * | |
559 | * This function performs symmetric 7 tap filter over input pixels. | |
560 | * Filter sum: p0*c3 + p1*c2 + p2*c1 + p3*c0 + p4*c1 + p5*c2 + p6*c3 | |
561 | * = (p0 + p6)*c3 + (p1 + p5)*c2 + (p2 + p4)*c1 + p3*c0 | |
562 | * Input pixels are in Qn and coefficients are in Qm format, where n = | |
563 | * ISP_VEC_ELEMBITS - 2 and m = ISP_VEC_ELEMBITS - 1 (ie Q14 and Q15 | |
564 | * respectively for Broxton) | |
565 | * To avoid double precision arithmetic input pixel sum and final sum is | |
566 | * implemented using addsat and coefficient multiplication using qrmul. | |
567 | * Final sum is left shifted by 2 and saturated to produce result is Qm format | |
568 | * (ie Q15 for Broxton) | |
569 | */ | |
570 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
571 | fir1x7m_sym_outnrm_approx(s_1w_1x7_matrix in, | |
572 | s_1w_1x4_matrix coeff); | |
573 | ||
d929fb4e | 574 | /* @brief 4 tap filter with normalization |
a49d2536 AC |
575 | * |
576 | * @param[in] in 1x4 matrix with pixels | |
577 | * @param[in] coeff 1x4 matrix with coefficients | |
578 | * @param[in] out_shift output pixel shift value for normalization | |
579 | * | |
580 | * @return 4 tap filter output | |
581 | * | |
582 | * This function performs 4 tap filter over input pixels. | |
583 | * Filter sum is normalized by shifting out_shift bits. | |
584 | * Filter sum: p0*c0 + p1*c1 + p2*c2 + p3*c3 | |
585 | */ | |
586 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
587 | fir1x4m_nrm(s_1w_1x4_matrix in, | |
588 | s_1w_1x4_matrix coeff, | |
589 | tvector1w out_shift); | |
590 | ||
d929fb4e | 591 | /* @brief 4 tap filter with normalization for half pixel interpolation |
a49d2536 AC |
592 | * |
593 | * @param[in] in 1x4 matrix with pixels | |
594 | * | |
595 | * @return 4 tap filter output with filter tap [-1 9 9 -1]/16 | |
596 | * | |
597 | * This function performs 4 tap filter over input pixels. | |
598 | * Filter sum: -p0 + 9*p1 + 9*p2 - p3 | |
599 | * This filter implementation is completely free from multiplication and double | |
600 | * precision arithmetic. | |
601 | * Typical usage of this filter is to half pixel interpolation of Bezier | |
602 | * surface | |
603 | * */ | |
604 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
605 | fir1x4m_bicubic_bezier_half(s_1w_1x4_matrix in); | |
606 | ||
d929fb4e | 607 | /* @brief 4 tap filter with normalization for quarter pixel interpolation |
a49d2536 AC |
608 | * |
609 | * @param[in] in 1x4 matrix with pixels | |
610 | * @param[in] coeff 1x4 matrix with coefficients | |
611 | * | |
612 | * @return 4 tap filter output | |
613 | * | |
614 | * This function performs 4 tap filter over input pixels. | |
615 | * Filter sum: p0*c0 + p1*c1 + p2*c2 + p3*c3 | |
616 | * To avoid double precision arithmetic we implemented multiplication using | |
617 | * qrmul and addition using avgrnd. Coefficients( c0 to c3) formats are assumed | |
618 | * to be: Qm, Qn, Qo, Qm, where m = n + 2 and o = n + 1. | |
619 | * Typical usage of this filter is to quarter pixel interpolation of Bezier | |
620 | * surface with filter coefficients:[-9 111 29 -3]/128. For which coefficient | |
621 | * values should be: [-9216/2^17 28416/2^15 1484/2^16 -3072/2^17] for | |
622 | * ISP_VEC_ELEMBITS = 16. | |
623 | */ | |
624 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
625 | fir1x4m_bicubic_bezier_quarter(s_1w_1x4_matrix in, | |
626 | s_1w_1x4_matrix coeff); | |
627 | ||
628 | ||
d929fb4e | 629 | /* @brief Symmetric 3 tap filter with normalization |
a49d2536 AC |
630 | * |
631 | * @param[in] in 1x3 matrix with pixels | |
632 | * @param[in] coeff 1x2 matrix with coefficients | |
633 | * @param[in] out_shift output pixel shift value for normalization | |
634 | * | |
635 | * @return symmetric 3 tap filter output | |
636 | * | |
637 | * This function performs symmetric 3 tap filter input pixels. | |
638 | * Filter sum is normalized by shifting out_shift bits. | |
639 | * Filter sum: p0*c1 + p1*c0 + p2*c1 | |
640 | * is implemented as: (p0 + p2)*c1 + p1*c0 to reduce multiplication. | |
641 | * Input pixels should to be scaled, otherwise overflow is possible during | |
642 | * addition | |
643 | */ | |
644 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
645 | fir1x3m_sym_nrm(s_1w_1x3_matrix in, | |
646 | s_1w_1x2_matrix coeff, | |
647 | tvector1w out_shift); | |
648 | ||
d929fb4e | 649 | /* @brief Symmetric 3 tap filter with normalization |
a49d2536 AC |
650 | * |
651 | * @param[in] in 1x3 matrix with pixels | |
652 | * @param[in] coeff 1x2 matrix with coefficients | |
653 | * | |
654 | * @return symmetric 3 tap filter output | |
655 | * | |
656 | * This function performs symmetric 3 tap filter over input pixels. | |
657 | * Filter sum: p0*c1 + p1*c0 + p2*c1 = (p0 + p2)*c1 + p1*c0 | |
658 | * Input pixels are in Qn and coefficient c0 is in Qm and c1 is in Qn format, | |
659 | * where n = ISP_VEC_ELEMBITS - 1 and m = ISP_VEC_ELEMBITS - 2 ( ie Q15 and Q14 | |
660 | * respectively for Broxton) | |
661 | * To avoid double precision arithmetic input pixel sum is implemented using | |
662 | * avgrnd, coefficient multiplication using qrmul and final sum using addsat | |
663 | * Final sum is Qm format (ie Q14 for Broxton) | |
664 | */ | |
665 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
666 | fir1x3m_sym_nrm_approx(s_1w_1x3_matrix in, | |
667 | s_1w_1x2_matrix coeff); | |
668 | ||
d929fb4e | 669 | /* @brief Mean of 1x3 matrix |
a49d2536 AC |
670 | * |
671 | * @param[in] m 1x3 matrix with pixels | |
672 | * | |
673 | * @return mean of 1x3 matrix | |
674 | * | |
675 | * This function calculates the mean of 1x3 pixels, | |
676 | * with a factor of 4/3. | |
677 | */ | |
678 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean1x3m( | |
679 | s_1w_1x3_matrix m); | |
680 | ||
d929fb4e | 681 | /* @brief Mean of 3x3 matrix |
a49d2536 AC |
682 | * |
683 | * @param[in] m 3x3 matrix with pixels | |
684 | * | |
685 | * @return mean of 3x3 matrix | |
686 | * | |
687 | * This function calculates the mean of 3x3 pixels, | |
688 | * with a factor of 16/9. | |
689 | */ | |
690 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean3x3m( | |
691 | s_1w_3x3_matrix m); | |
692 | ||
d929fb4e | 693 | /* @brief Mean of 1x4 matrix |
a49d2536 AC |
694 | * |
695 | * @param[in] m 1x4 matrix with pixels | |
696 | * | |
697 | * @return mean of 1x4 matrix | |
698 | * | |
699 | * This function calculates the mean of 1x4 pixels | |
700 | */ | |
701 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean1x4m( | |
702 | s_1w_1x4_matrix m); | |
703 | ||
d929fb4e | 704 | /* @brief Mean of 4x4 matrix |
a49d2536 AC |
705 | * |
706 | * @param[in] m 4x4 matrix with pixels | |
707 | * | |
708 | * @return mean of 4x4 matrix | |
709 | * | |
710 | * This function calculates the mean of 4x4 matrix with pixels | |
711 | */ | |
712 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean4x4m( | |
713 | s_1w_4x4_matrix m); | |
714 | ||
d929fb4e | 715 | /* @brief Mean of 2x3 matrix |
a49d2536 AC |
716 | * |
717 | * @param[in] m 2x3 matrix with pixels | |
718 | * | |
719 | * @return mean of 2x3 matrix | |
720 | * | |
721 | * This function calculates the mean of 2x3 matrix with pixels | |
722 | * with a factor of 8/6. | |
723 | */ | |
724 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean2x3m( | |
725 | s_1w_2x3_matrix m); | |
726 | ||
d929fb4e | 727 | /* @brief Mean of 1x5 matrix |
a49d2536 AC |
728 | * |
729 | * @param[in] m 1x5 matrix with pixels | |
730 | * | |
731 | * @return mean of 1x5 matrix | |
732 | * | |
733 | * This function calculates the mean of 1x5 matrix with pixels | |
734 | * with a factor of 8/5. | |
735 | */ | |
736 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean1x5m(s_1w_1x5_matrix m); | |
737 | ||
d929fb4e | 738 | /* @brief Mean of 1x6 matrix |
a49d2536 AC |
739 | * |
740 | * @param[in] m 1x6 matrix with pixels | |
741 | * | |
742 | * @return mean of 1x6 matrix | |
743 | * | |
744 | * This function calculates the mean of 1x6 matrix with pixels | |
745 | * with a factor of 8/6. | |
746 | */ | |
747 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean1x6m( | |
748 | s_1w_1x6_matrix m); | |
749 | ||
d929fb4e | 750 | /* @brief Mean of 5x5 matrix |
a49d2536 AC |
751 | * |
752 | * @param[in] m 5x5 matrix with pixels | |
753 | * | |
754 | * @return mean of 5x5 matrix | |
755 | * | |
756 | * This function calculates the mean of 5x5 matrix with pixels | |
757 | * with a factor of 32/25. | |
758 | */ | |
759 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean5x5m( | |
760 | s_1w_5x5_matrix m); | |
761 | ||
d929fb4e | 762 | /* @brief Mean of 6x6 matrix |
a49d2536 AC |
763 | * |
764 | * @param[in] m 6x6 matrix with pixels | |
765 | * | |
766 | * @return mean of 6x6 matrix | |
767 | * | |
768 | * This function calculates the mean of 6x6 matrix with pixels | |
769 | * with a factor of 64/36. | |
770 | */ | |
771 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w mean6x6m( | |
772 | s_1w_6x6_matrix m); | |
773 | ||
d929fb4e | 774 | /* @brief Minimum of 4x4 matrix |
a49d2536 AC |
775 | * |
776 | * @param[in] m 4x4 matrix with pixels | |
777 | * | |
778 | * @return minimum of 4x4 matrix | |
779 | * | |
780 | * This function calculates the minimum of | |
781 | * 4x4 matrix with pixels. | |
782 | */ | |
783 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w min4x4m( | |
784 | s_1w_4x4_matrix m); | |
785 | ||
d929fb4e | 786 | /* @brief Maximum of 4x4 matrix |
a49d2536 AC |
787 | * |
788 | * @param[in] m 4x4 matrix with pixels | |
789 | * | |
790 | * @return maximum of 4x4 matrix | |
791 | * | |
792 | * This function calculates the maximum of | |
793 | * 4x4 matrix with pixels. | |
794 | */ | |
795 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w max4x4m( | |
796 | s_1w_4x4_matrix m); | |
797 | ||
d929fb4e | 798 | /* @brief SAD between two 3x3 matrices |
a49d2536 AC |
799 | * |
800 | * @param[in] a 3x3 matrix with pixels | |
801 | * | |
802 | * @param[in] b 3x3 matrix with pixels | |
803 | * | |
804 | * @return 3x3 matrix SAD | |
805 | * | |
806 | * This function calculates the sum of absolute difference between two matrices. | |
807 | * Both input pixels and SAD are normalized by a factor of SAD3x3_IN_SHIFT and | |
808 | * SAD3x3_OUT_SHIFT respectively. | |
809 | * Computed SAD is 1/(2 ^ (SAD3x3_IN_SHIFT + SAD3x3_OUT_SHIFT)) ie 1/16 factor | |
810 | * of original SAD and it's more precise than sad3x3m() | |
811 | */ | |
812 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w sad3x3m_precise( | |
813 | s_1w_3x3_matrix a, | |
814 | s_1w_3x3_matrix b); | |
815 | ||
d929fb4e | 816 | /* @brief SAD between two 3x3 matrices |
a49d2536 AC |
817 | * |
818 | * @param[in] a 3x3 matrix with pixels | |
819 | * | |
820 | * @param[in] b 3x3 matrix with pixels | |
821 | * | |
822 | * @return 3x3 matrix SAD | |
823 | * | |
824 | * This function calculates the sum of absolute difference between two matrices. | |
825 | * This version saves cycles by avoiding input normalization and wide vector | |
826 | * operation during sum computation | |
827 | * Input pixel differences are computed by absolute of rounded, halved | |
828 | * subtraction. Normalized sum is computed by rounded averages. | |
829 | * Computed SAD is (1/2)*(1/16) = 1/32 factor of original SAD. Factor 1/2 comes | |
830 | * from input halving operation and factor 1/16 comes from mean operation | |
831 | */ | |
832 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w sad3x3m( | |
833 | s_1w_3x3_matrix a, | |
834 | s_1w_3x3_matrix b); | |
835 | ||
d929fb4e | 836 | /* @brief SAD between two 5x5 matrices |
a49d2536 AC |
837 | * |
838 | * @param[in] a 5x5 matrix with pixels | |
839 | * | |
840 | * @param[in] b 5x5 matrix with pixels | |
841 | * | |
842 | * @return 5x5 matrix SAD | |
843 | * | |
844 | * Computed SAD is = 1/32 factor of original SAD. | |
845 | */ | |
846 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w sad5x5m( | |
847 | s_1w_5x5_matrix a, | |
848 | s_1w_5x5_matrix b); | |
849 | ||
d929fb4e | 850 | /* @brief Absolute gradient between two sets of 1x5 matrices |
a49d2536 AC |
851 | * |
852 | * @param[in] m0 first set of 1x5 matrix with pixels | |
853 | * @param[in] m1 second set of 1x5 matrix with pixels | |
854 | * | |
855 | * @return absolute gradient between two 1x5 matrices | |
856 | * | |
857 | * This function computes mean of two input 1x5 matrices and returns | |
858 | * absolute difference between two mean values. | |
859 | */ | |
860 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w | |
861 | absgrad1x5m(s_1w_1x5_matrix m0, s_1w_1x5_matrix m1); | |
862 | ||
d929fb4e | 863 | /* @brief Bi-linear Interpolation optimized(approximate) |
a49d2536 AC |
864 | * |
865 | * @param[in] a input0 | |
866 | * @param[in] b input1 | |
867 | * @param[in] c cloned weight factor | |
868 | * | |
869 | * @return (a-b)*c + b | |
870 | * | |
871 | * This function will do bi-linear Interpolation on | |
872 | * inputs a and b using constant weight factor c | |
873 | * | |
874 | * Inputs a,b are assumed in S1.15 format | |
875 | * Weight factor has to be in range [0,1] and is assumed to be in S2.14 format | |
876 | * | |
877 | * The bilinear interpolation equation is (a*c) + b*(1-c), | |
878 | * But this is implemented as (a-b)*c + b for optimization | |
879 | */ | |
880 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_bilinear_interpol_approx_c( | |
881 | tvector1w a, | |
882 | tvector1w b, | |
883 | tscalar1w_weight c); | |
884 | ||
d929fb4e | 885 | /* @brief Bi-linear Interpolation optimized(approximate) |
a49d2536 AC |
886 | * |
887 | * @param[in] a input0 | |
888 | * @param[in] b input1 | |
889 | * @param[in] c weight factor | |
890 | * | |
891 | * @return (a-b)*c + b | |
892 | * | |
893 | * This function will do bi-linear Interpolation on | |
894 | * inputs a and b using weight factor c | |
895 | * | |
896 | * Inputs a,b are assumed in S1.15 format | |
897 | * Weight factor has to be in range [0,1] and is assumed to be in S2.14 format | |
898 | * | |
899 | * The bilinear interpolation equation is (a*c) + b*(1-c), | |
900 | * But this is implemented as (a-b)*c + b for optimization | |
901 | */ | |
902 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_bilinear_interpol_approx( | |
903 | tvector1w a, | |
904 | tvector1w b, | |
905 | tvector1w_weight c); | |
906 | ||
d929fb4e | 907 | /* @brief Bi-linear Interpolation |
a49d2536 AC |
908 | * |
909 | * @param[in] a input0 | |
910 | * @param[in] b input1 | |
911 | * @param[in] c weight factor | |
912 | * | |
913 | * @return (a*c) + b*(1-c) | |
914 | * | |
915 | * This function will do bi-linear Interpolation on | |
916 | * inputs a and b using weight factor c | |
917 | * | |
918 | * Inputs a,b are assumed in S1.15 format | |
919 | * Weight factor has to be in range [0,1] and is assumed to be in S2.14 format | |
920 | * | |
921 | * The bilinear interpolation equation is (a*c) + b*(1-c), | |
922 | */ | |
923 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_bilinear_interpol( | |
924 | tvector1w a, | |
925 | tvector1w b, | |
926 | tscalar1w_weight c); | |
927 | ||
d929fb4e | 928 | /* @brief Generic Block Matching Algorithm |
a49d2536 AC |
929 | * @param[in] search_window pointer to input search window of 16x16 pixels |
930 | * @param[in] ref_block pointer to input reference block of 8x8 pixels, where N<=M | |
931 | * @param[in] output pointer to output sads | |
932 | * @param[in] search_sz search size for SAD computation | |
933 | * @param[in] ref_sz block size | |
934 | * @param[in] pixel_shift pixel shift to search the data | |
935 | * @param[in] search_block_sz search window block size | |
936 | * @param[in] shift shift value, with which the output is shifted right | |
937 | * | |
938 | * @return 0 when the computation is successful. | |
939 | ||
940 | * * This function compares the reference block with a block of size NxN in the search | |
941 | * window. Sum of absolute differences for each pixel in the reference block and the | |
942 | * corresponding pixel in the search block. Whole search window os traversed with the | |
943 | * reference block with the given pixel shift. | |
944 | * | |
945 | */ | |
946 | STORAGE_CLASS_REF_VECTOR_FUNC_H int generic_block_matching_algorithm( | |
947 | tscalar1w **search_window, | |
948 | tscalar1w **ref_block, | |
949 | tscalar1w *output, | |
950 | int search_sz, | |
951 | int ref_sz, | |
952 | int pixel_shift, | |
953 | int search_block_sz, | |
954 | tscalar1w_4bit_bma_shift shift); | |
955 | ||
956 | #ifndef ISP2401 | |
d929fb4e | 957 | /* @brief OP_1w_asp_bma_16_1_32way |
a49d2536 | 958 | #else |
d929fb4e | 959 | /* @brief OP_1w_asp_bma_16_1_32way_nomask |
a49d2536 AC |
960 | #endif |
961 | * | |
962 | * @param[in] search_area input search window of 16x16 pixels | |
963 | * @param[in] input_block input reference block of 8x8 pixels, where N<=M | |
964 | * @param[in] shift shift value, with which the output is shifted right | |
965 | * | |
966 | * @return 81 SADs for all the search blocks. | |
967 | ||
968 | * This function compares the reference block with a block of size 8x8 pixels in the | |
969 | * search window of 16x16 pixels. Sum of absolute differences for each pixel in the | |
970 | * reference block and the corresponding pixel in the search block is calculated. | |
971 | * Whole search window is traversed with the reference block with the pixel shift of 1 | |
972 | * pixels. The output is right shifted with the given shift value. The shift value is | |
973 | * a 4 bit value. | |
974 | * | |
975 | */ | |
976 | ||
977 | #ifndef ISP2401 | |
978 | STORAGE_CLASS_REF_VECTOR_FUNC_H bma_output_16_1 OP_1w_asp_bma_16_1_32way( | |
979 | #else | |
980 | STORAGE_CLASS_REF_VECTOR_FUNC_H bma_output_16_1 OP_1w_asp_bma_16_1_32way_nomask( | |
981 | #endif | |
982 | bma_16x16_search_window search_area, | |
983 | ref_block_8x8 input_block, | |
984 | tscalar1w_4bit_bma_shift shift); | |
985 | ||
986 | #ifndef ISP2401 | |
d929fb4e | 987 | /* @brief OP_1w_asp_bma_16_2_32way |
a49d2536 | 988 | #else |
d929fb4e | 989 | /* @brief OP_1w_asp_bma_16_2_32way_nomask |
a49d2536 AC |
990 | #endif |
991 | * | |
992 | * @param[in] search_area input search window of 16x16 pixels | |
993 | * @param[in] input_block input reference block of 8x8 pixels, where N<=M | |
994 | * @param[in] shift shift value, with which the output is shifted right | |
995 | * | |
996 | * @return 25 SADs for all the search blocks. | |
997 | * This function compares the reference block with a block of size 8x8 in the search | |
998 | * window of 16x61. Sum of absolute differences for each pixel in the reference block | |
999 | * and the corresponding pixel in the search block is computed. Whole search window is | |
1000 | * traversed with the reference block with the given pixel shift of 2 pixels. The output | |
1001 | * is right shifted with the given shift value. The shift value is a 4 bit value. | |
1002 | * | |
1003 | */ | |
1004 | ||
1005 | #ifndef ISP2401 | |
1006 | STORAGE_CLASS_REF_VECTOR_FUNC_H bma_output_16_2 OP_1w_asp_bma_16_2_32way( | |
1007 | #else | |
1008 | STORAGE_CLASS_REF_VECTOR_FUNC_H bma_output_16_2 OP_1w_asp_bma_16_2_32way_nomask( | |
1009 | #endif | |
1010 | bma_16x16_search_window search_area, | |
1011 | ref_block_8x8 input_block, | |
1012 | tscalar1w_4bit_bma_shift shift); | |
1013 | #ifndef ISP2401 | |
d929fb4e | 1014 | /* @brief OP_1w_asp_bma_14_1_32way |
a49d2536 | 1015 | #else |
d929fb4e | 1016 | /* @brief OP_1w_asp_bma_14_1_32way_nomask |
a49d2536 AC |
1017 | #endif |
1018 | * | |
1019 | * @param[in] search_area input search block of 16x16 pixels with search window of 14x14 pixels | |
1020 | * @param[in] input_block input reference block of 8x8 pixels, where N<=M | |
1021 | * @param[in] shift shift value, with which the output is shifted right | |
1022 | * | |
1023 | * @return 49 SADs for all the search blocks. | |
1024 | * This function compares the reference block with a block of size 8x8 in the search | |
1025 | * window of 14x14. Sum of absolute differences for each pixel in the reference block | |
1026 | * and the corresponding pixel in the search block. Whole search window is traversed | |
1027 | * with the reference block with 2 pixel shift. The output is right shifted with the | |
1028 | * given shift value. The shift value is a 4 bit value. Input is always a 16x16 block | |
1029 | * but the search window is 14x14, with last 2 pixels of row and column are not used | |
1030 | * for computation. | |
1031 | * | |
1032 | */ | |
1033 | ||
1034 | #ifndef ISP2401 | |
1035 | STORAGE_CLASS_REF_VECTOR_FUNC_H bma_output_14_1 OP_1w_asp_bma_14_1_32way( | |
1036 | #else | |
1037 | STORAGE_CLASS_REF_VECTOR_FUNC_H bma_output_14_1 OP_1w_asp_bma_14_1_32way_nomask( | |
1038 | #endif | |
1039 | bma_16x16_search_window search_area, | |
1040 | ref_block_8x8 input_block, | |
1041 | tscalar1w_4bit_bma_shift shift); | |
1042 | ||
1043 | #ifndef ISP2401 | |
d929fb4e | 1044 | /* @brief OP_1w_asp_bma_14_2_32way |
a49d2536 | 1045 | #else |
d929fb4e | 1046 | /* @brief OP_1w_asp_bma_14_2_32way_nomask |
a49d2536 AC |
1047 | #endif |
1048 | * | |
1049 | * @param[in] search_area input search block of 16x16 pixels with search window of 14x14 pixels | |
1050 | * @param[in] input_block input reference block of 8x8 pixels, where N<=M | |
1051 | * @param[in] shift shift value, with which the output is shifted right | |
1052 | * | |
1053 | * @return 16 SADs for all the search blocks. | |
1054 | * This function compares the reference block with a block of size 8x8 in the search | |
1055 | * window of 14x14. Sum of absolute differences for each pixel in the reference block | |
1056 | * and the corresponding pixel in the search block. Whole search window is traversed | |
1057 | * with the reference block with 2 pixels shift. The output is right shifted with the | |
1058 | * given shift value. The shift value is a 4 bit value. | |
1059 | * | |
1060 | */ | |
1061 | ||
1062 | #ifndef ISP2401 | |
1063 | STORAGE_CLASS_REF_VECTOR_FUNC_H bma_output_14_2 OP_1w_asp_bma_14_2_32way( | |
1064 | #else | |
1065 | STORAGE_CLASS_REF_VECTOR_FUNC_H bma_output_14_2 OP_1w_asp_bma_14_2_32way_nomask( | |
1066 | #endif | |
1067 | bma_16x16_search_window search_area, | |
1068 | ref_block_8x8 input_block, | |
1069 | tscalar1w_4bit_bma_shift shift); | |
1070 | ||
1071 | #ifdef ISP2401 | |
d929fb4e | 1072 | /* @brief multiplex addition and passing |
a49d2536 AC |
1073 | * |
1074 | * @param[in] _a first pixel | |
1075 | * @param[in] _b second pixel | |
1076 | * @param[in] _c condition flag | |
1077 | * | |
1078 | * @return (_a + _b) if condition flag is true | |
1079 | * _a if condition flag is false | |
1080 | * | |
1081 | * This function does multiplex addition depending on the input condition flag | |
1082 | */ | |
1083 | STORAGE_CLASS_REF_VECTOR_FUNC_H tvector1w OP_1w_cond_add( | |
1084 | tvector1w _a, | |
1085 | tvector1w _b, | |
1086 | tflags _c); | |
1087 | ||
1088 | #endif | |
1089 | #ifdef HAS_bfa_unit | |
d929fb4e | 1090 | /* @brief OP_1w_single_bfa_7x7 |
a49d2536 AC |
1091 | * |
1092 | * @param[in] weights - spatial and range weight lut | |
1093 | * @param[in] threshold - threshold plane, for range weight scaling | |
1094 | * @param[in] central_pix - central pixel plane | |
1095 | * @param[in] src_plane - src pixel plane | |
1096 | * | |
1097 | * @return Bilateral filter output | |
1098 | * | |
1099 | * This function implements, 7x7 single bilateral filter. | |
1100 | * Output = {sum(pixel * weight), sum(weight)} | |
1101 | * Where sum is summation over 7x7 block set. | |
1102 | * weight = spatial weight * range weight | |
1103 | * spatial weights are loaded from spatial_weight_lut depending on src pixel | |
1104 | * position in the 7x7 block | |
1105 | * range weights are computed by table look up from range_weight_lut depending | |
1106 | * on scaled absolute difference between src and central pixels. | |
1107 | * threshold is used as scaling factor. range_weight_lut consists of | |
1108 | * BFA_RW_LUT_SIZE numbers of LUT entries to model any distribution function. | |
1109 | * Piecewise linear approximation technique is used to compute range weight | |
1110 | * It computes absolute difference between central pixel and 61 src pixels. | |
1111 | */ | |
1112 | STORAGE_CLASS_REF_VECTOR_FUNC_H bfa_7x7_output OP_1w_single_bfa_7x7( | |
1113 | bfa_weights weights, | |
1114 | tvector1w threshold, | |
1115 | tvector1w central_pix, | |
1116 | s_1w_7x7_matrix src_plane); | |
1117 | ||
d929fb4e | 1118 | /* @brief OP_1w_joint_bfa_7x7 |
a49d2536 AC |
1119 | * |
1120 | * @param[in] weights - spatial and range weight lut | |
1121 | * @param[in] threshold0 - 1st threshold plane, for range weight scaling | |
1122 | * @param[in] central_pix0 - 1st central pixel plane | |
1123 | * @param[in] src0_plane - 1st pixel plane | |
1124 | * @param[in] threshold1 - 2nd threshold plane, for range weight scaling | |
1125 | * @param[in] central_pix1 - 2nd central pixel plane | |
1126 | * @param[in] src1_plane - 2nd pixel plane | |
1127 | * | |
1128 | * @return Joint bilateral filter output | |
1129 | * | |
1130 | * This function implements, 7x7 joint bilateral filter. | |
1131 | * Output = {sum(pixel * weight), sum(weight)} | |
1132 | * Where sum is summation over 7x7 block set. | |
1133 | * weight = spatial weight * range weight | |
1134 | * spatial weights are loaded from spatial_weight_lut depending on src pixel | |
1135 | * position in the 7x7 block | |
1136 | * range weights are computed by table look up from range_weight_lut depending | |
1137 | * on sum of scaled absolute difference between central pixel and two src pixel | |
1138 | * planes. threshold is used as scaling factor. range_weight_lut consists of | |
1139 | * BFA_RW_LUT_SIZE numbers of LUT entries to model any distribution function. | |
1140 | * Piecewise linear approximation technique is used to compute range weight | |
1141 | * It computes absolute difference between central pixel and 61 src pixels. | |
1142 | */ | |
1143 | STORAGE_CLASS_REF_VECTOR_FUNC_H bfa_7x7_output OP_1w_joint_bfa_7x7( | |
1144 | bfa_weights weights, | |
1145 | tvector1w threshold0, | |
1146 | tvector1w central_pix0, | |
1147 | s_1w_7x7_matrix src0_plane, | |
1148 | tvector1w threshold1, | |
1149 | tvector1w central_pix1, | |
1150 | s_1w_7x7_matrix src1_plane); | |
1151 | ||
d929fb4e | 1152 | /* @brief bbb_bfa_gen_spatial_weight_lut |
a49d2536 AC |
1153 | * |
1154 | * @param[in] in - 7x7 matrix of spatial weights | |
1155 | * @param[in] out - generated LUT | |
1156 | * | |
1157 | * @return None | |
1158 | * | |
1159 | * This function implements, creates spatial weight look up table used | |
1160 | * for bilaterl filter instruction. | |
1161 | */ | |
1162 | STORAGE_CLASS_REF_VECTOR_FUNC_H void bbb_bfa_gen_spatial_weight_lut( | |
1163 | s_1w_7x7_matrix in, | |
1164 | tvector1w out[BFA_MAX_KWAY]); | |
1165 | ||
d929fb4e | 1166 | /* @brief bbb_bfa_gen_range_weight_lut |
a49d2536 AC |
1167 | * |
1168 | * @param[in] in - input range weight, | |
1169 | * @param[in] out - generated LUT | |
1170 | * | |
1171 | * @return None | |
1172 | * | |
1173 | * This function implements, creates range weight look up table used | |
1174 | * for bilaterl filter instruction. | |
1175 | * 8 unsigned 7b weights are represented in 7 16bits LUT | |
1176 | * LUT formation is done as follows: | |
1177 | * higher 8 bit: Point(N) = Point(N+1) - Point(N) | |
1178 | * lower 8 bit: Point(N) = Point(N) | |
1179 | * Weight function can be any monotonic decreasing function for x >= 0 | |
1180 | */ | |
1181 | STORAGE_CLASS_REF_VECTOR_FUNC_H void bbb_bfa_gen_range_weight_lut( | |
1182 | tvector1w in[BFA_RW_LUT_SIZE+1], | |
1183 | tvector1w out[BFA_RW_LUT_SIZE]); | |
1184 | #endif | |
1185 | ||
1186 | #ifdef ISP2401 | |
d929fb4e | 1187 | /* @brief OP_1w_imax32 |
a49d2536 AC |
1188 | * |
1189 | * @param[in] src - structure that holds an array of 32 elements. | |
1190 | * | |
1191 | * @return maximum element among input array. | |
1192 | * | |
1193 | *This function gets maximum element from an array of 32 elements. | |
1194 | */ | |
1195 | STORAGE_CLASS_REF_VECTOR_FUNC_H int OP_1w_imax32( | |
1196 | imax32_ref_in_vector src); | |
1197 | ||
d929fb4e | 1198 | /* @brief OP_1w_imaxidx32 |
a49d2536 AC |
1199 | * |
1200 | * @param[in] src - structure that holds a vector of elements. | |
1201 | * | |
1202 | * @return index of first element with maximum value among array. | |
1203 | * | |
1204 | * This function gets index of first element with maximum value | |
1205 | * from 32 elements. | |
1206 | */ | |
1207 | STORAGE_CLASS_REF_VECTOR_FUNC_H int OP_1w_imaxidx32( | |
1208 | imax32_ref_in_vector src); | |
1209 | ||
1210 | #endif | |
1211 | #ifndef INLINE_VECTOR_FUNC | |
1212 | #define STORAGE_CLASS_REF_VECTOR_FUNC_C | |
1213 | #define STORAGE_CLASS_REF_VECTOR_DATA_C const | |
1214 | #else /* INLINE_VECTOR_FUNC */ | |
1215 | #define STORAGE_CLASS_REF_VECTOR_FUNC_C STORAGE_CLASS_REF_VECTOR_FUNC_H | |
1216 | #define STORAGE_CLASS_REF_VECTOR_DATA_C STORAGE_CLASS_REF_VECTOR_DATA_H | |
1217 | #include "ref_vector_func.c" | |
1218 | #define VECTOR_FUNC_INLINED | |
1219 | #endif /* INLINE_VECTOR_FUNC */ | |
1220 | ||
1221 | #endif /*_REF_VECTOR_FUNC_H_INCLUDED_*/ |