summaryrefslogtreecommitdiff
path: root/include/ia_imaging/ia_cp_types.h
blob: 8f540676cf306c4245630848c3871b017ce1a017 (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
/*
 * 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_TYPES_H_
#define _IA_CP_TYPES_H_

#include "ia_aiq_types.h"
#include "rgbpp_public.h"

/** @file ia_cp_types.h
 * This file declares data types used for computational photography.
 * These data types are declared in a separate header file to allow re-use
 * across components in the software stack.
 */

#ifdef __cplusplus
extern "C" {
#endif

#define IA_CP_HISTOGRAM_SIZE    256

/** @brief Histogram and related statistics.
 *
 * The structure to hold the plane histogram and the corresponding
 * cumulative distribution function (CDF).
 */
typedef struct
{
    int data[IA_CP_HISTOGRAM_SIZE];       /**< Histogram values */
    int cdf[IA_CP_HISTOGRAM_SIZE];        /**< Normalized CDF for the histogram */
    int levels[IA_CP_HISTOGRAM_SIZE + 1]; /**< Histogram levels */
    int size;                             /**< Total number of samples in all bins */
} ia_cp_histogram;

/** @brief Local contrast enhancement controls
 *
 * Contrast enhancement can be applied as part of the computational photography pipelines.
 * This is usually done as a post-processing step to make up for a loss in sharpness and
 * texture details introduced by composition of multiple images. This can be achieved either
 * as a multi-level sharpening, or as a pixel modification based on its local neighbourhood.
 */
typedef enum
{
    ia_cp_contrast_none,              /**< No contrast enhancement */
    ia_cp_contrast_sharpening,        /**< Enable sharpening */
    ia_cp_contrast_details,           /**< Enable texture enhancement */
    ia_cp_contrast_all,               /**< Enable both sharpening and texture enhancement */
} ia_cp_contrast;

/** @brief Vividness enhancement
 *
 * Vividness enhancement can be enabled in certain CP features to boost color saturation.
 * Processing operates on the S channel (HSV color space) and increases its value while
 * preserving the color gammut. Saturation is not applied to skin tones.
 */
typedef enum
{
    ia_cp_vividness_off,      /**< Color saturation enhancement disabled */
    ia_cp_vividness_on,       /**< Color saturation enhancement enabled */
} ia_cp_vividness;

/** @brief Gamma LUT applied on each of RGB channels.
 *
 */
typedef struct {
    unsigned short *r_gamma_lut;
    unsigned short *b_gamma_lut;
    unsigned short *g_gamma_lut;
    unsigned int gamma_lut_size;
} ia_cp_gamma_lut;

/** @brief HDR configuration interface
 *
 * This structure contains HDR runtime parameters computed by the
 * AIQ+ module or obtain differently (e.g. read from the disk). These
 * settings represent HDR runtime control interface.
 */
typedef struct
{
    ia_cp_gamma_lut gamma_lut;                   /**< Gamma LUT applied on each of RGB channels */
} ia_cp_hdr_cfg;

/** @brief vHDR configuration interface
 *
 * This structure contains vHDR runtime parameters computed by the
 * AIQ+ module or obtain differently (e.g. read from the disk). These
 * settings represent vHDR runtime control interface.
 */
#define IA_CP_GAIN_LUT_SZ    18
#define IA_CP_GAMMA_LUT_SZ    1024

typedef struct
{
    ia_aiq_ae_results   *ae_results;      /* Exposure times, analog and digital gain, lux level,... */
    ia_aiq_gbce_results *gbce_results;    /* Long gamma LUTs applied on each RGB channel */
} ia_cp_vhdr_cfg;

typedef struct gtm_coeff {
	struct csc_public_config yuv2rgbConv;	/**< vHDR: GTM: YUV to RGB converstion */
	struct csc_public_config rgb2yuvConv;	/**< vHDR: GTM: RGB to YUV converstion */
	struct cds_public_config rgb2yuvDs;	/**< vHDR: GTM: RGB to YUV downscale */
} gtm_coeff_t;

typedef struct gtm_luts_t {
	float gtm_gamma_lut[IA_CP_GAMMA_LUT_SZ]; /* limited to 1024 entries */
	float gtm_gain_lut[IA_CP_GAIN_LUT_SZ]; /* limited to 18 entries */
} gtm_luts_t;

typedef struct
{
	int			se_exposure_time;
	int			le_exposure_time;
	uint8_t		gae_model;                  /* 0 - None (GAE is off), 1 - Translation [1]*/
	uint8_t		gae_bright_thr_low;			/* Brightness threshold low (can be sensor dependent) [4] */
	uint8_t		gae_bright_thr_high;		/* Brightness threshold high (can be sensor dependent) [250] */
	int			gae_pyr_low;
	int			gae_pyr_high;
	float       gae_zeros_thr_w;			/*!< Minimal weight of zero motion vectors before declaring that camera is still */
	float       gae_flat_thr_ratio;         /*!< Flat regions ratio */
	float		gae_motion_min_area_low;    /*!< Minimal motion area wieght before entering fallback state */
	float		gae_motion_min_area_high;   /*!< Minimal motion area wieght before leaving fallback state */
	uint8_t		mrg_blend_thr_low;
	uint8_t		mrg_blend_thr_high;
	gtm_luts_t	gtm_luts;
	gtm_coeff_t gtm_coeff; /* GTM color space & down Scale converstion parameters */
} ia_vhdr_config; /* dynamic config params, given by aic */



/** @brief ULL configuration interface
 *
 * This structure contains ULL runtime parameters computed by the
 * AIQ+ module or obtain differently (e.g. read from the disk). These
 * settings represent ULL runtime control interface.
 */
typedef struct
{
    ia_aiq_exposure_parameters exposure;        /**< Generic exposure parameters for the input captures */
    int * imreg_fallback;                       /**< List of frames to ignore when using external alignment estimation (NULL for internal) */
    unsigned int zoom_factor;                   /**< Zoom factor */
} ia_cp_ull_cfg;

/** @brief Global motion estimation model
 *
 * This enumerator lists valid global motion estimation models
 * which can be specified during the global motion estimation process.
 */
typedef enum
{
    ia_cp_me_translation,                /**< Pure in-plane translation model */
    ia_cp_me_translation_rotation,       /**< Pure in-plane translation and rotation model */
    ia_cp_me_affine,                     /**< General affine model */
    ia_cp_me_projective                  /**< General projective (homography) model */
} ia_cp_me_model;

/** @brief Global motion estimation configuration interface
 *
 * This structure contains global motion estimation parameters. These
 * settings control the execution of the algorithm at runtime.
 */
typedef struct
{
    int pyr_depth;             /**< Depth of the pyramid for coarse-to-fine search */
    ia_cp_me_model model;      /**< Transformation model */
} ia_cp_me_cfg;

/** @brief Results of the global motion estimation
 *
 * This structure contains results of the global motion estimation.
 */
typedef struct
{
    double transform[3][3];        /**< Resulting 3x3 transformation matrix */
    int fallback;                  /**< Flag to indicate large global motion */
} ia_cp_me_result;

/** @brief Processing unit target
 *
 * This enumerator lists valid targets for execution of CP applications.
 */
typedef enum
{
    ia_cp_tgt_ia,        /**< Intel Architecture (IA) host */
    ia_cp_tgt_ipu,       /**< Image Processing Unit */
    ia_cp_tgt_gpu,       /**< Graphics Processing Unit */
    ia_cp_tgt_ate,       /**< ATE C bitexact reference model */
    ia_cp_tgt_ref,       /**< Generic C reference model */
    ia_cp_tgt_skl_gpu,   /**< Platform SKL, target GPU */
    ia_cp_tgt_skl_ref,   /**< Platform SKL, Generic C reference model */
    ia_cp_tgt_none       /**< Use to indicate error in target choice */
} ia_cp_target;

/** @brief HDR internal state.
 *
 * Opaque structure which holds HDR internal state.
 */
typedef struct ia_cp_hdr ia_cp_hdr;

/** @brief vHDR internal state.
 *
 * Opaque structure which holds vHDR internal state.
 */
typedef struct ia_cp_vhdr ia_cp_vhdr;

/** @brief vHDR internal state.
 *
 * Opaque structure which holds vHDR internal state.
 */
typedef struct ia_cp_vhdr_v2 ia_cp_vhdr_v2;

/** @brief ULL internal state.
 *
 * Opaque structure which holds ULL internal state.
 */
typedef struct ia_cp_ull ia_cp_ull;

/** @brief CP library context.
 *
 * Opaque structure which holds CP library internal state.
 */
typedef struct ia_cp_context ia_cp_context;

/**
 * @brief Chart descriptor
 */
typedef struct {
    ia_frame container;            /**< Image container */
    int roi_width;                 /**< Width of the patch ROI */
    int roi_height;                /**< Height of the patch ROI */
    int patch_num;                 /**< Number of relevant patches */
    int *points_x;                 /**< Top-left X coordinates of the patch */
    int *points_y;                 /**< Top-left Y coordinates of the patch */
} ia_cp_chart;

#ifdef __cplusplus
}
#endif

#endif /* _IA_CP_TYPES_H_ */