summaryrefslogtreecommitdiff
path: root/include/ia_imaging/ia_cp.h
blob: 598d1463dfbf30cd0ceeeab1efc72bdff270506b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/*
 * Copyright (C) 2015 - 2017 Intel Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _IA_CP_H_
#define _IA_CP_H_

/** @file ia_cp.h
 * This file declares the Intel camera computational photography API.
 */

#include "ia_types.h"
#include "ia_cp_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/** @brief Initialize HDR acceleration setup
 *
 * @param[out] cp_context pointer to CP instance
 * @param[in] acc_api pointer to acceleration api
 * @param[in] environment pointer to environment setup
 * @param[in] mem_environment pointer to memory environment setup
 *
 * This function initializes the acceleration setup by using input acc_api
 * and log_env.
*/
LIBEXPORT void
ia_cp_init (ia_cp_context         ** cp_context,
            const ia_acceleration * acc_api,
            const ia_env          * environment,
            const ia_mem_env      * mem_environment);


/** @brief Close HDR acceleration setup
 *
 * @param[in] cp_context pointer to CP instance
 *
 * This function frees and closes all the resources allocated for HDR
 * in its initialization call.
 */
LIBEXPORT void
ia_cp_uninit (ia_cp_context * cp_context);

/** @brief allocate and map all HDR intermediate data buffers
 *
 * @param[out] hdr pointer to HDR instance
 * @param[in] cp_context pointer to CP instance
 * @param[in] width input frame width
 * @param[in] height input frame height
 * @param[in] hdrb_data CPF binary data with tuning choices
 * @param[in] tgt target platform for HDR execution (host, ipu etc.)
 * @return error status
 *
 * This function allocates and maps all HDR intermediate buffers
 * required to do the processing. It also passes tuning choices
 * set in the CPFF for the particular platform. If hdrb_data is
 * NULL, default choices are used.
 */
LIBEXPORT ia_err
ia_cp_hdr_init (ia_cp_hdr ** hdr, ia_cp_context * cp_context, int width, int height, const ia_binary_data * hdrb_data, ia_cp_target tgt);

/** @brief release and unmap intermediate HDR data buffers
 *
 * @param[in] hdr pointer to HDR instance
 * @return error status
 *
 * This function release all resources used for intermediate
 * data storage during HDR composition.
 */
LIBEXPORT ia_err
ia_cp_hdr_uninit (ia_cp_hdr * hdr);

/** @brief compose HDR image
 *
 * @param[in] hdr pointer to HDR instance
 * @param[out] out pointer to the HDR output buffer
 * @param[out] out_pv pointer to postview output buffer
 * @param[in] in pointer to the input frame sequence
 * @param[in] in_pv pointer to the downscaled input frame sequence
 * @param[in] num_frames number of input frames
 * @param[in] cfg configuration parameters
 * @return error status
 *
 * This function composes an HDR image. It produces and output HDR frame and a downscaled version
 * of the full resolution output. Composition of the output frame is controlled via configuration
 * structure given as an input.
 */
LIBEXPORT ia_err
ia_cp_hdr_compose (ia_cp_hdr           * hdr,
                   ia_frame            * out,
                   ia_frame            * out_pv,
                   const ia_frame      * in,
                   const ia_frame      * in_pv,
                   unsigned int          num_frames,
                   const ia_cp_hdr_cfg * cfg);

/** @brief abort HDR image composition
 *
 * @param[in] hdr pointer to HDR instance
 * @return error status
 *
 * This function aborts composition of an HDR image.
 */
LIBEXPORT ia_err
ia_cp_hdr_abort (ia_cp_hdr * hdr);

/** @brief allocate and map all VHDR intermediate data buffers
 *
 * @param[out] vhdr pointer to VHDR instance
 * @param[in] cp_context pointer to CP instance
 * @param[in] width input frame width
 * @param[in] height input frame height
 * @param[in] vhdrb_data CPF binary data with tuning choices
 * @param[in] tgt target platform for VHDR execution (host, gpu etc.)
 * @return error status
 *
 * This function allocates and maps all VHDR intermediate buffers
 * required to do the processing. It also passes tuning choices
 * set in the CPF for the particular platform. If vhdrb_data is
 * NULL, default choices are used.
 */
LIBEXPORT ia_err
ia_cp_vhdr_init (ia_cp_vhdr ** vhdr, ia_cp_context * cp_context, int width, int height, const ia_binary_data * vhdrb_data, ia_cp_target tgt);

/** @brief release and unmap intermediate VHDR data buffers
 *
 * @param[in] vhdr pointer to VHDR instance
 * @return error status
 *
 * This function release all resources used for intermediate
 * data storage during VHDR composition.
 */
LIBEXPORT ia_err
ia_cp_vhdr_uninit (ia_cp_vhdr * vhdr);

/** @brief compose VHDR image
 *
 * @param[in] vhdr pointer to VHDR instance
 * @param[out] out pointer to the VHDR output buffer
 * @param[in] in pointer to the input frame sequence
 * @param[in] num_frames number of input frames
 * @param[in] cfg configuration parameters
 * @return error status
 *
 * This function composes an VHDR image. It produces and output VHDR frame.
 * Composition of the output frame is controlled via configuration
 * structure given as an input.
 */
LIBEXPORT ia_err
ia_cp_vhdr_compose (ia_cp_vhdr           * vhdr,
                    ia_frame             * out,
                    const ia_frame       * in,
                    unsigned int           num_frames,
                    const ia_cp_vhdr_cfg * cfg);

/** @brief abort VHDR image composition
 *
 * @param[in] vhdr pointer to VHDR instance
 * @return error status
 *
 * This function aborts composition of an VHDR image.
 */
LIBEXPORT ia_err
ia_cp_vhdr_abort (ia_cp_vhdr * vhdr);

/** @brief allocate and map all VHDR intermediate data buffers
 *
 * @param[out] vhdr address of pointer to VHDR instance
 * @param[in] cp_context pointer to CP instance
 * @param[in] width input frame width
 * @param[in] height input frame height
 * @param[in] vhdrb_data CPF binary data with tuning choices
 * @param[in] tgt target platform for VHDR execution (host, gpu etc.)
 * @return error status
 *
 * This function allocates and maps all VHDR intermediate buffers
 * required to do the processing. It also passes tuning choices
 * set in the CPF for the particular platform. If vhdrb_data is
 * NULL, default choices are used.
 */
LIBEXPORT ia_err
ia_cp_vhdr_v2_init (ia_cp_vhdr_v2 **vhdr, ia_cp_context *cp_context, int width, int height, const ia_binary_data *vhdrb_data, ia_cp_target tgt);

/** @brief release and unmap intermediate VHDR data buffers
 *
 * @param[in] vhdr pointer to VHDR instance
 * @return error status
 *
 * This function release all resources used for intermediate
 * data storage during VHDR composition.
 */
LIBEXPORT ia_err
ia_cp_vhdr_v2_uninit (ia_cp_vhdr_v2 *vhdr);

/** @brief compose VHDR image
 *
 * @param[in] vhdr pointer to VHDR instance
 * @param[out] out pointer to the VHDR output buffer
 * @param[in] in pointer to the input frame sequence
 * @param[in] cfg configuration parameters
 * @return error status
 *
 * This function composes an VHDR image. It produces and output VHDR frame.
 * Composition of the output frame is controlled via configuration
 * structure given as an input.
 */
LIBEXPORT ia_err
ia_cp_vhdr_v2_compose (ia_cp_vhdr_v2        *vhdr,
                       ia_frame             *out,
                       const ia_frame       *in,
                       const ia_cp_vhdr_cfg *cfg);

/** @brief initialize ULL parameters
 *
 * @param[out] ull pointer to ULL instance
 * @param[in] cp_context pointer to CP instance
 * @param[in] width input frame width
 * @param[in] height input frame height
 * @param[in] ullb_data CPF binary data with tuning choices
 * @param[in] tgt target platform for ULL execution (host, ipu etc.)
 * @return error status
 *
 * This function initializes internals for ULL processing. It also
 * passes tuning choices set in the CPFF for the particular platform.
 * If ullb_data is NULL, default choices are used.
 */
LIBEXPORT ia_err
ia_cp_ull_init (ia_cp_ull ** ull, ia_cp_context * cp_context, int width, int height, const ia_binary_data * ullb_data, ia_cp_target tgt);

/** @brief deinitialize ULL internals
 *
 * @param[in] ull pointer to ULL instance
 * @return error status
 *
 * This function release all resources used during ULL composition.
 */
LIBEXPORT ia_err
ia_cp_ull_uninit (ia_cp_ull * ull);

/** @brief compose ULL image
 *
 * @param[in] ull pointer to ULL instance
 * @param[out] out pointer to the ULL output buffer
 * @param[out] out_pv pointer to postview output buffer
 * @param[in] in pointer to the input frame sequence
 * @param[in] in_pv pointer to the downscaled input frame sequence
 * @param[in] num_frames number of input frames
 * @param[in] cfg configuration parameters
 * @return error status
 *
 * This function composes a denoised image from a set of input images captured in exteme low-light
 * conditions. It produces an output frame and a downscaled version of the full resolution output.
 * Composition of the output frame is controlled via configuration structure given as an input.
 */
LIBEXPORT ia_err
ia_cp_ull_compose (ia_cp_ull           * ull,
                   ia_frame            * out,
                   ia_frame            * out_pv,
                   const ia_frame      * in,
                   const ia_frame      * in_pv,
                   unsigned int          num_frames,
                   const ia_cp_ull_cfg * cfg);

/** @brief abort ULL image composition
 *
 * @return error status
 *
 * This function aborts composition of a ULL image.
 */
LIBEXPORT ia_err
ia_cp_ull_abort (void);

/** @brief Estimate global motion between two frames provided in a form of gaussian pyramids
 *
 * @param[out] result outcome of the estimation process
 * @param[in] target_pyr array of target frame pyramid levels
 * @param[in] source_pyr array of source frame pyramid levels
 * @param[in] cfg configuration parameters
 * @return error status
 *
 * This function estimates global motion between the source frame and the target (base) frame given in a form of
 * gaussian pyramids. Results are produced in a form of a 3x3 global transformation matrix sufficient to cover the
 * most complex use case of projective transformation. Estimation also advocates fallback in case the global motion
 * was sufficiently large.
 *
 */
LIBEXPORT ia_err
ia_cp_global_me_multires (ia_cp_me_result * result, const ia_frame target_pyr[],
                          const ia_frame source_pyr[], const ia_cp_me_cfg * cfg);

/** @brief Estimate global motion between two frames
 *
 * @param[out] result outcome of the estimation process
 * @param[in] target pointer to the target buffer
 * @param[in] source pointer to the source buffer
 * @param[in] cfg configuration parameters
 * @return error status
 *
 * This function estimates global motion between the source frame and the target (base) frame. Results are
 * produced in a form of a 3x3 global transformation matrix sufficient to cover the most complex use case
 * of projective transformation. Estimation also advocates fallback in case the global motion was
 * sufficiently large.
 *
 */
LIBEXPORT ia_err
ia_cp_global_me (ia_cp_me_result * result, const ia_frame * target, const ia_frame * source,
                 const ia_cp_me_cfg * cfg);

/** @brief Compensate frame motion based on the transformation matrix
 *
 * @param[out] target pointer to the target buffer
 * @param[in] source pointer to the source buffer
 * @param[in] result outcome of the estimation process
 * @return error status
 *
 * This function compensates global motion based on the provided motion estimation results.
 *
 */
LIBEXPORT ia_err
ia_cp_global_mc (ia_frame * target, ia_frame * source, ia_cp_me_result * result);


/** @brief Zoom provided frame with specified zoom factor
 *
 * @param[inout] in_out frame
 * @param[in] zoom_factor
 * @return error status
 *
 * This function performs zooming of input frame with specified zoom factor.
 *
 */
LIBEXPORT ia_err
ia_cp_zoom_frame(ia_frame * in_out, int zoom_factor);

/** @brief Load extension binaries
 *
 * @param[in] cp_context pointer to CP instance
 * @return error status
 *
 * This function loads CP binaries as an extension to the preview pipe.
 */
LIBEXPORT ia_err
ia_cp_load_extensions (ia_cp_context * cp_context);

/** @brief Unload extension binaries
 *
 * @param[in] cp_context pointer to CP instance
 * @return error status
 *
 * This function unloads CP binaries which are previously loaded as an extension
 * to the preview pipe.
 */
LIBEXPORT ia_err
ia_cp_unload_extensions (ia_cp_context * cp_context);

/**
 * @brief   Computes standard deviation for the patches in the provided chart
 *
 * @param[in]   chart             Chart descriptor
 * @param[in]   mean_min          Minimal valid patch mean
 * @param[in]   mean_max          Maximal valid patch mean
 * @param[out]  deviation         Average deviation for valid patches
 *
 * @return                        Flag indicating success or failure
 *
 * Function computes standard deviation for the patches in the provided chart. Chart data type contains
 * a frame and location of all patches of interest. Expected are 8-bit frames, computation is done only
 * for the first plane in the frame. Resulting deviation is scaled into the [0, 1) range.
 */
LIBEXPORT ia_err
ia_cp_chart_compute_deviation (ia_cp_chart chart, int mean_min, int mean_max, float *deviation);

/**
 * @brief   Performs linear regression fitting for the given dataset
 *
 * @param[in]   psrc_x            Pointer to dataset X values
 * @param[in]   psrc_y            Pointer to dataset Y values
 * @param[in]   len               Length of the dataset
 * @param[out]  slope             Slope of the resulting linear curve
 * @param[out]  offset            Offset of the resulting linear curve
 *
 * @return                        Flag indicating success or failure
 *
 * Function performs linear curve fitting for the given dataset via means of linear regression. Resulting
 * slope and offset describe the linear fit as y = slope * x + offset.
 */
LIBEXPORT ia_err
ia_cp_linear_regression (const float *psrc_x, const float *psrc_y, int len, float *slope, float *offset);

#ifdef __cplusplus
}
#endif

#endif /* _IA_CP_H */