summaryrefslogtreecommitdiff
path: root/include/ia_imaging/ia_dvs_types.h
blob: fce666345eaa1179eaebfb4fd25bc7e902183b78 (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
/*
 * 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.
 */
/*!
 * \file ia_dvs_types.h
 * \brief Data types and enumerations for Intel DVS library.
 */
#ifndef _IA_DVS_TYPES_H_
#define _IA_DVS_TYPES_H_
#include <stdint.h>
#include "ia_types.h"

typedef struct t_dvs_facade ia_dvs_state;

/** DVS Algorithm.
 * These settings specify the members of correction axes.
 * ia_dvs_algorihm_0_axis is a special mode. In this case, library does not compensate the
 * motion, works for digital zoom and distortion correction.
 */
typedef enum
{
    ia_dvs_algorithm_0_axis     = 0,                        /**< 0 axis, means video stabilization is turned off */
    ia_dvs_algorithm_2_axis     = 2,                        /**< 2 axis - x and y translations */
    ia_dvs_algorithm_3_axis     = 3,                        /**< 3 axis - x and y translations and z-scale*/
    ia_dvs_algorithm_4_axis     = 4,                        /**< 4 axis */
    ia_dvs_algorithm_5_axis     = 5,                        /**< 5 axis - x and y translations and all rotations*/
    ia_dvs_algorithm_6_axis     = 6,                        /**< 6 axis - x and y translations, z-scale and all rotations*/
    ia_dvs_algorithm_max_axis   = ia_dvs_algorithm_6_axis,  /**< maximum axis */
    ia_dvs_algorithm_motion_sensor = 10                     /**< motion sensor based stabilization */
} ia_dvs_algorithm_version;

/** DVS2 BQ resolution.
 * These parameter are BQ resolution configuration.
 */
typedef struct
{
    int width_bq;                           /**< width [BQ] */
    int height_bq;                          /**< height [BQ] */
} ia_dvs_bq_resolution;

/** GDC Scan Mode
 * These settings specify the gdc scan mode.
 */
typedef enum
{
    ia_dvs_gdc_scan_mode_stb    = 0,        /**< STB (slide to the bottom) */
    ia_dvs_gdc_scan_mode_str,               /**< STR (slide to the right) */
} ia_dvs_gdc_scan_mode;

/** GDC Interpolation Method
 * These settings specify the gdc interpolation method.
 */
typedef enum
{
    ia_dvs_gdc_interpolation_nnd= 0,        /**< NND (nearest neighbor) */
    ia_dvs_gdc_interpolation_bli,           /**< BLI (bilinear) */
    ia_dvs_gdc_interpolation_bci,           /**< BCI (bicubic) */
    ia_dvs_gdc_interpolation_lut,           /**< LUT (look up table) */
} ia_dvs_gdc_interpolation;

/** GDC Performance Point
 * These settings specify the gdc performance point.
 */
typedef enum
{
    ia_dvs_gdc_performance_point_1x1= 0,    /**< 1x1 */
    ia_dvs_gdc_performance_point_2x1,       /**< 2x1 */
    ia_dvs_gdc_performance_point_1x2,       /**< 1x2 */
    ia_dvs_gdc_performance_point_2x2,       /**< 2x2 */
} ia_dvs_gdc_performance_point;

/** GDC hardware configuration
 * These parametes are the gdc hardware block configuration.
 * dvs library use these parameters just check the gdc constraints,
 * do NOT use these parameters for any controls nor calculations.
 */
typedef struct
{
    ia_dvs_gdc_scan_mode scan_mode;
    ia_dvs_gdc_interpolation interpolation;
    ia_dvs_gdc_performance_point performance_point;
} ia_dvs_gdc_hw_configuration;

/** GDC buffer configuration
 *  These parameters indicates the limits of the GDC ISP buffer.
 *  DVS needs to limit morphing table coordinates to fit inside GDC
 *  ISP buffer.
 */
typedef struct
{
    unsigned int x_offset;  /* X offset [BQ] for the first pixel of image data */
    unsigned int y_offset;  /* Y offset [BQ] for the first pixel of image data*/
    unsigned int width;     /* Total width [BQ] for the buffer */
    unsigned int height;    /* Total height [BQ] for the buffer */
} ia_dvs_gdc_buffer_config;

/** Total cropping parameters
 *  These parameters contain sensor and ISP cropping information without any scaling or binning.
 *  In case of scaling before cropping, cropping params needs to be scaled back to the original resolution.
 *  This information is used to crop lens distortion grids accordingly.
 */
typedef struct
{
    unsigned int horizontal_crop_offset;    /* Read out offset horizontal [BQ] */
    unsigned int vertical_crop_offset;      /* Read out offset vertical [BQ] */
    unsigned int cropped_width;             /* Width of cropped area without any scaling [BQ] */
    unsigned int cropped_height;            /* Height of cropped area without any scaling [BQ] */
} ia_dvs_crop_params;

/** DVS configuration.
 * This structure contains DVS configuration.
 */
typedef struct
{
    ia_dvs_algorithm_version num_axis;          /**< Algorithm mode */
    float nonblanking_ratio;                    /**< Effective vertical scan ratio, used for rolling correction (Non-blanking ration of frame interval) */
    ia_dvs_bq_resolution source_bq;             /**< Input image size [BQ] for GDC block */
    ia_dvs_bq_resolution output_bq;             /**< Output image size [BQ] from GDC block */
    ia_dvs_bq_resolution envelope_bq;           /**< GDC effective envelope size [BQ] */
    ia_dvs_bq_resolution ispfilter_bq;          /**< Padding of the image which is corrupted and should not be visible in the output image [BQ] */
    int gdc_shift_x;                            /**< Shift value of morphing table depend on ISP pipe. [chroma pixel] */
    int gdc_shift_y;                            /**< Shift value of morphing table depend on ISP pipe. [chroma pixel] */
    unsigned int oxdim_y;                       /**< Output block width  for Y plane [pixel] */
    unsigned int oydim_y;                       /**< Output block height for Y plane [pixel] */
    unsigned int oxdim_uv;                      /**< Output block width  for U/V plane [chroma pixel] */
    unsigned int oydim_uv;                      /**< Output block height for U/V plane [chroma pixel] */
    ia_dvs_gdc_hw_configuration hw_config;      /**< GDC h/w configuration. DVS does not set these values anywhere so it's only
                                                     used when validating outgoing morphing table. */
    bool use_lens_distortion_correction;        /**< False disables LDC, true enables */
    int frame_rate;                             /**< Frame rate */
    ia_dvs_gdc_buffer_config gdc_buffer_config; /**< Configuration of the GDC buffer is used inside DVS to prevent morphing table to point
                                                     invalid memory locations in GDC.

                                                     This configuration should come from FW
                                                     to inform how large buffer is allocated for GDC processing.
                                                     Morphing table coordinates generated by DVS must fit inside
                                                     GDC buffer limits. GDC buffer is allocated by FW and
                                                     it needs to allocate extra padding for each side of the image data.
                                                     This allows DVS to generate morphing table which points are outside of the image area
                                                     but still inside GDC buffer (padding area). This might be the case e.g. if LDC grid is
                                                     barrel shaped. */
    ia_dvs_crop_params crop_params;             /**< Sensor and ISP cropping parameteres in native resolution (without any scaling or binning).
                                                     If scaling is performed before cropping, cropping offsets need to be calculated in native
                                                     resolution. Also if cropping is done in multiple places, everything needs to be combined
                                                     together.
                                                     Lens distortion correction is calculated from the full sensor resolution and
                                                     DVS needs to know how distortion grids need to be cropped so that they will match with
                                                     the GDC input image.*/
    bool validate_morph_table;                  /**< False disables morph table validation, true enables. Morph table needs to be validated to
                                                     protect FW. Starting from IPU4 validation is performed in PAL. */
} ia_dvs_configuration;

/** Distortion grid configuration.
 * Structure defines lens distortion grid.
 */
typedef struct
{
    int16_t GDC_col_start;      /*!< Table X offset in pixels from left corner of the sensor maximum visible area.
                                     e.g. If GDC_col_start=GDC_block_width*(-1)
                                     then GDC table offset is is one block left compared to the maximum visible sensor area. */
    int16_t GDC_row_start;      /*!< Table Y offset in pixels from upper corner of the sensor maximum visible area.
                                     e.g. If GDC_row_start=GDC_block_height*(-1)
                                     then GDC table offset is is one block up compared to the maximum visible sensor area.  */
    int16_t GDC_grid_width;     /*!< Indicates number of grid vertices on the horizontal axis. */
    int16_t GDC_grid_height;    /*!< Indicates number of grid vertices on the vertical axis. */
    int16_t GDC_block_width;    /*!< Width of the original grid cell (without correction). */
    int16_t GDC_block_height;   /*!< Height of the original grid cell (without correction). */
    float *x_deltas;            /*!< Table of x-axis deltas of the grid points. The delta at each point represents the distortion
                                     that was done. Contains [GDC_grid_height  x GDC_grid_width] values. */
    float *y_deltas;            /*!< Table of y-axis deltas of the grid points. The delta at each point represents the distortion
                                     that was done. Contains [GDC_grid_height  x GDC_grid_width] values. */
} ia_dvs_distortion_config;

/** DVS Motion vector structure.
 * This structure contains definition for one local motion vector.
 */
typedef struct
{
    float x_start;          /* Normalized X start position */
    float y_start;          /* Normalized Y start position */
    float x_end;            /* Normalized X end position */
    float y_end;            /* Normalized y end position */
    float weight;           /* Weight of the motion vector [0.0, 1.0]. Describes accuracy of the motion vector */
} ia_dvs_motion_vector;

/** DVS Motion vectors.
 * This structure contains DVS statistics.
 */
typedef struct
{
    unsigned int vector_count;              /* Number of motion vectors */
    ia_dvs_motion_vector *motion_vectors;   /* Table of local motion vectors. Contains [vector_count] values. */
} ia_dvs_statistics;

/** DVS morphing table structure.
 * This structure contains morphing table which includes
 * lens distortion correction, digital zoom, rolling shutter correction and video stabilization.
 */
typedef struct
{
    uint32_t width_y;
    uint32_t height_y;
    uint32_t width_uv;
    uint32_t height_uv;
    uint32_t *xcoords_y;
    uint32_t *ycoords_y;
    uint32_t *xcoords_uv;
    uint32_t *ycoords_uv;
    bool morph_table_changed;
} ia_dvs_morph_table;

/** Digital zoom mode
 * These settings specify digital zoom mode.
 */
typedef enum {
        ia_dvs_zoom_mode_center = 0,
        ia_dvs_zoom_mode_region,
        ia_dvs_zoom_mode_coordinate
} ia_dvs_zoom_mode;

/** DVS global translation parameters.
 * This structure contains the frame-to-frame translations along x and y axes
 * and also a coefficient for scene reliability in the range [0, 1] with 1 being
 * totally reliable estimate and 0 being totally unreliable
 */
typedef struct
{
    uint32_t plane_translation_x;
    uint32_t plane_translation_y;
    float reliability_coefficient;
} ia_dvs_global_translation;

#endif /* _IA_DVS_TYPES_H_ */