• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __HI_COMM_VIDEO_ADAPT_H__
20 #define __HI_COMM_VIDEO_ADAPT_H__
21 
22 #include "hi_type.h"
23 #include "hi_common.h"
24 #include "hi_comm_video.h"
25 #include "hi_common_adapt.h"
26 
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif
31 #endif /* __cplusplus */
32 
33 typedef OPERATION_MODE_E hi_operation_mode;
34 
35 typedef ROTATION_E hi_rotation;
36 typedef VB_SOURCE_E hi_vb_source;
37 typedef DATA_RATE_E hi_data_rate;
38 
39 typedef struct {
40     hi_u32 top_width;
41     hi_u32 bottom_width;
42     hi_u32 left_width;
43     hi_u32 right_width;
44     hi_u32 color;
45 } hi_border;
46 
47 typedef struct {
48     hi_s32 x;
49     hi_s32 y;
50 } hi_point;
51 
52 typedef struct {
53     hi_u32 width;
54     hi_u32 height;
55 } hi_size;
56 
57 typedef struct {
58     hi_s32 x;
59     hi_s32 y;
60     hi_u32 width;
61     hi_u32 height;
62 } hi_rect;
63 
64 typedef struct {
65     hi_u32           region_num;       /* W; count of the region */
66     hi_rect ATTRIBUTE* region;         /* W; region attribute */
67 } hi_video_region_info;
68 
69 typedef struct {
70     hi_bool enable;
71     hi_rect  rect;
72 } hi_crop_info;
73 
74 typedef struct {
75     hi_s32  src_frame_rate;        /* RW; source frame rate */
76     hi_s32  dst_frame_rate;        /* RW; dest frame rate */
77 } hi_frame_rate_ctrl;
78 
79 typedef ASPECT_RATIO_E hi_aspect_ratio_type;
80 
81 typedef struct {
82     hi_aspect_ratio_type mode;          /* aspect ratio mode: none/auto/manual */
83     hi_u32         bg_color;      /* background color, RGB 888 */
84     hi_rect         video_rect;     /* valid in ASPECT_RATIO_MANUAL mode */
85 } hi_aspect_ratio;
86 
87 /* we ONLY define picture format used, all unused will be deleted! */
88 typedef PIXEL_FORMAT_E hi_pixel_format;
89 
90 typedef VIDEO_FIELD_E hi_video_field;
91 
92 typedef VIDEO_FORMAT_E hi_video_format;
93 
94 typedef COMPRESS_MODE_E hi_compress_mode;
95 
96 typedef VIDEO_DISPLAY_MODE_E hi_video_display_mode;
97 
98 #define is_yuv_sp422(pixel_format)  ((pixel_format) == PIXEL_FORMAT_YUV_SEMIPLANAR_422)
99 #define is_yvu_sp422(pixel_format)  ((pixel_format) == PIXEL_FORMAT_YVU_SEMIPLANAR_422)
100 #define is_yuv_sp420(pixel_format)  ((pixel_format) == PIXEL_FORMAT_YUV_SEMIPLANAR_420)
101 #define is_yvu_sp420(pixel_format)  ((pixel_format) == PIXEL_FORMAT_YVU_SEMIPLANAR_420)
102 #define is_yuv_400(pixel_format)    ((pixel_format) == PIXEL_FORMAT_YUV_400)
103 #define is_sp422(pixel_format)      (is_yuv_sp422(pixel_format) || is_yvu_sp422(pixel_format))
104 #define is_sp420(pixel_format)      (is_yuv_sp420(pixel_format) || is_yvu_sp420(pixel_format))
105 
106 typedef struct {
107     hi_u64 luma_pix_sum;      /* luma sum of current frame */
108     hi_u32 luma_pix_average;  /* luma average of current frame */
109     hi_u64 pts;             /* PTS of current frame  */
110 } hi_luma_info;
111 
112 typedef struct {
113     hi_u8       image_description[DCF_DESCRIPTION_LENGTH];        /* describes image */
114     hi_u8       make[DCF_DESCRIPTION_LENGTH];          /* shows manufacturer of digital cameras */
115     hi_u8       model[DCF_DESCRIPTION_LENGTH];         /* shows model number of digital cameras */
116     hi_u8       software[DCF_DESCRIPTION_LENGTH];      /* shows firmware (internal software of digital cameras)
117                                                         version number */
118 
119     hi_u8       light_source;        /* light source, actually this means white balance setting. '0' means unknown,
120                                      '1' daylight, '2' fluorescent, '3' tungsten, '10' flash, '17' standard light A,
121                                      '18' standard light B, '19' standard lightC, '20' D55, '21' D65,
122                                      '22' D75, '255' other */
123     hi_u32      focal_length;         /* focal length of lens used to take image. unit is millimeter */
124     hi_u8       scene_type;           /* indicates the type of scene. value '0x01' means that the image was directly
125                                         photographed. */
126     hi_u8       custom_rendered;       /* indicates the use of special processing on image data, such as rendering
127                                         geared to output. 0 = normal process  1 = custom process */
128     hi_u8       focal_length_in35mm_film; /* indicates the equivalent focal length assuming a 35mm film camera, in mm */
129     hi_u8       scene_capture_type;       /* indicates the type of scene that was shot. 0 = standard, 1 = landscape,
130                                                 2 = portrait,3 = night scene. */
131     hi_u8       gain_control;           /* indicates the degree of overall image gain adjustment. 0 = none,
132                                         1 = low gain up,2 = high gain up,3 = low gain down,4 = high gain down. */
133     hi_u8       contrast;        /* indicates the direction of contrast processing applied by the camera when the image
134                                     was shot. 0 = normal,1 = soft,2 = hard */
135     hi_u8       saturation;     /* indicates the direction of saturation processing applied by the camera when
136                                     the image was shot. 0 = normal,1 = low saturation,2 = high saturation */
137     hi_u8       sharpness;    /* indicates the direction of sharpness processing applied by the camera when the image
138                                 was shot. 0 = normal,1 = soft,2 = hard . */
139     hi_u8       metering_mode;      /* exposure metering method. '0' means unknown, '1' average, '2' center weighted
140                                     average, '3' spot, '4' multi-spot, '5' multi-segment, '6' partial, '255' other */
141 } hi_isp_dcf_const_info;
142 
143 typedef struct {
144     hi_u32      iso_speed_ratings;        /* CCD sensitivity equivalent to ag-hr film speedrate */
145     hi_u32      exposure_time;           /* exposure time (reciprocal of shutter speed). */
146     hi_u32      exposure_bias_value;      /* exposure bias (compensation) value of taking picture */
147     hi_u8       exposure_program;   /* exposure program that the camera used when image was taken.
148                                        '1' means manual control, '2' program normal, '3' aperture priority,
149                                        '4' shutter priority, '5' program creative (slow program),
150                                        '6' program action(high-speed program), '7' portrait mode, '8' landscape mode */
151     hi_u32      f_number;                /* the actual F-number (F-stop) of lens when the image was taken */
152     hi_u32      max_aperture_value;       /* maximum aperture value of lens. */
153     hi_u8       exposure_mode;            /* indicates the exposure mode set when the image was shot.
154                                                      0 = auto exposure,1 = manual exposure, 2 = auto bracket */
155     hi_u8       white_balance;            /* indicates the white balance mode set when the image was shot.
156                                                        0 = auto white balance ,1 = manual white balance */
157 } hi_isp_dcf_update_info;
158 
159 typedef struct {
160     hi_isp_dcf_const_info  isp_dcf_const_info;
161     hi_isp_dcf_update_info isp_dcf_update_info;
162 } hi_isp_dcf_info;
163 
164 typedef struct {
165     hi_u8           capture_time[DCF_CAPTURE_TIME_LENGTH];   /* the date and time when the picture data was generated */
166     hi_bool         flash;               /* whether the picture is captured when a flash lamp is on */
167     hi_u32          digital_zoom_ratio; /* indicates the digital zoom ratio when the image was shot. if the
168                                          * numerator of the recorded value is 0, this indicates that digital zoom
169                                          * was not used. */
170     hi_isp_dcf_info isp_dcf_info;
171 } hi_jpeg_dcf;
172 
173 typedef struct {
174     hi_u32      iso;                    /* ISP internal ISO : again*dgain*is_pgain */
175     hi_u32      exposure_time;           /* exposure time (reciprocal of shutter speed),unit is us */
176     hi_u32      isp_dgain;
177     hi_u32      again;
178     hi_u32      dgain;
179     hi_u32      ratio[3];
180     hi_u32      isp_nr_strength;
181     hi_u32      f_number;                /* the actual F-number (F-stop) of lens when the image was taken */
182     hi_u32      sensor_id;               /* which sensor is used */
183     hi_u32      sensor_mode;
184     hi_u32      hmax_times;              /* sensor hmax_times,unit is ns */
185     hi_u32      vmax;                   /* sensor vmax,unit is line */
186     hi_u32      vc_num;                  /* when dump wdr frame, which is long or short  exposure frame. */
187 } hi_isp_frame_info;
188 
189 typedef struct {
190     hi_u32 numerator;   /* represents the numerator of a fraction, */
191     hi_u32 denominator; /* the denominator. */
192 } hi_dng_rational;
193 
194 /*
195 defines the structure of DNG image dynamic information
196 */
197 typedef struct {
198     hi_u32 black_level[ISP_BAYER_CHN];  /* RO;range: [0x0, 0xFFFF]; black level */
199     hi_dng_rational as_shot_neutral[CFACOLORPLANE]; /* specifies the selected white balance at time of capture,
200                                 encoded as the coordinates of a perfectly neutral color
201                                 in linear reference space values. */
202     hi_double ad_noise_profile[DNG_NP_SIZE];  /* RO;describes the amount of noise in a raw image */
203 } hi_dng_image_dynamic_info;
204 
205 typedef struct {
206     hi_u32 color_temp;
207     hi_u16 ccm[9];
208     hi_u8  saturation;
209 } hi_isp_hdr_info;
210 
211 typedef struct {
212     hi_isp_hdr_info     isp_hdr;
213     hi_u32 iso;
214     hi_u32 init_iso;
215     hi_u8 sns_wdr_mode;
216 } hi_isp_attach_info;
217 
218 typedef FRAME_FLAG_E hi_frame_flag;
219 
220 typedef struct {
221     hi_u32 iso;
222     hi_u32 isp_dgain;
223     hi_u32 exposure_time;
224     hi_u32 white_balance_gain[ISP_WB_GAIN_NUM];
225     hi_u32 color_temperature;
226     hi_u16 cap_ccm[ISP_CAP_CCM_NUM];
227 } hi_isp_config_info;
228 
229 typedef struct {
230     hi_u64   jpeg_dcf_phy_addr;
231     hi_u64   isp_info_phy_addr;
232     hi_u64   low_delay_phy_addr;
233     hi_u64   motion_data_phy_addr;
234     hi_u64   frame_dng_phy_addr;
235 
236     hi_void* ATTRIBUTE jpeg_dcf_vir_addr;        /* jpeg_dcf, used in JPEG DCF */
237     hi_void* ATTRIBUTE isp_info_vir_addr;        /* isp_frame_info, used in ISP debug, when get raw and send raw */
238     hi_void* ATTRIBUTE low_delay_vir_addr;       /* used in low delay */
239     hi_void* ATTRIBUTE motion_data_vir_addr;     /* vpss 3dnr use: gme motion data, filter motion data, gyro data. */
240     hi_void* ATTRIBUTE frame_dng_vir_addr;
241 } hi_video_supplement;
242 
243 typedef COLOR_GAMUT_E hi_color_gamut;
244 
245 typedef struct {
246         hi_color_gamut color_gamut;
247 } hi_isp_colorgammut_info;
248 
249 typedef DYNAMIC_RANGE_E hi_dynamic_range;
250 
251 typedef DATA_BITWIDTH_E hi_data_bitwidth;
252 
253 typedef struct {
254     hi_u32              width;
255     hi_u32              height;
256     hi_video_field       field;
257     hi_pixel_format      pixel_format;
258     hi_video_format      video_format;
259     hi_compress_mode     compress_mode;
260     hi_dynamic_range     dynamic_range;
261     hi_color_gamut       color_gamut;
262     hi_u32              header_stride[3];
263     hi_u32              stride[3];
264     hi_u32              ext_stride[3];
265 
266     hi_u64              header_phy_addr[3];
267     hi_u64              header_vir_addr[3];
268     hi_u64              phy_addr[3];
269     hi_u64              vir_addr[3];
270     hi_u64              ext_phy_addr[3];
271     hi_u64              ext_vir_addr[3];
272 
273     hi_s16              offset_top;        /* top offset of show area */
274     hi_s16              offset_bottom;    /* bottom offset of show area */
275     hi_s16              offset_left;        /* left offset of show area */
276     hi_s16              offset_right;        /* right offset of show area */
277 
278     hi_u32              max_luminance;
279     hi_u32              min_luminance;
280 
281     hi_u32              time_ref;
282     hi_u64              pts;
283 
284     hi_u64              private_data;
285     hi_u32              frame_flag;     /* frame_flag, can be OR operation. */
286     hi_video_supplement  supplement;
287 } hi_video_frame;
288 
289 typedef struct {
290     hi_video_frame v_frame;
291     hi_u32        pool_id;
292     hi_mod_id      mod_id;
293 } hi_video_frame_info;
294 
295 typedef struct {
296     hi_u32 vb_size;
297 
298     hi_u32 head_stride;
299     hi_u32 head_size;
300     hi_u32 head_y_size;
301 
302     hi_u32 main_stride;
303     hi_u32 main_size;
304     hi_u32 main_y_size;
305 
306     hi_u32 ext_stride;
307     hi_u32 ext_y_size;
308 } hi_vb_cal_config;
309 
310 typedef struct {
311     hi_pixel_format pixel_format;  /* bitmap's pixel format */
312     hi_u32 width;               /* bitmap's width */
313     hi_u32 height;              /* bitmap's height */
314     hi_void* ATTRIBUTE data;      /* address of bitmap's data */
315 } hi_bitmap;
316 
317 typedef struct {
318     hi_bool    aspect;             /* RW;range: [0, 1];whether aspect ration  is keep */
319     hi_s32     x_ratio;           /* RW; range: [0, 100]; field angle ration of  horizontal,valid when aspect=0. */
320     hi_s32     y_ratio;           /* RW; range: [0, 100]; field angle ration of  vertical,valid when aspect=0. */
321     hi_s32     xy_ratio;          /* RW; range: [0, 100]; field angle ration of  all,valid when aspect=1. */
322     hi_s32 center_x_offset;        /* RW; range: [-511, 511]; horizontal offset of the image distortion center
323                                     relative to image center. */
324     hi_s32 center_y_offset;        /* RW; range: [-511, 511]; vertical offset of the image distortion center relative
325                                     to image center. */
326     hi_s32 distortion_ratio;      /* RW; range: [-300, 500]; LDC distortion ratio.when spread on, distortion_ratio
327                                     range should be [0, 500] */
328 } hi_ldc_attr;
329 
330 typedef struct {
331     hi_s32 focal_len_x;                  /* RW; focal length in horizontal direction, with 2 decimal numbers */
332     hi_s32 focal_len_y;                  /* RW; focal length in vertical direction, with 2 decimal numbers */
333     hi_s32 coor_shift_x;                 /* RW; coordinate of image center, with 2 decimal numbers */
334     hi_s32 coor_shift_y;                 /* RW; Y coordinate of image center, with 2 decimal numbers */
335     hi_s32 src_cali_ratio[SRC_LENS_COEF_SEG][SRC_LENS_COEF_NUM];  /* RW; lens distortion coefficients of the source
336                                                                     image, with 5 decimal numbers */
337     hi_s32 src_jun_pt;                                             /* RW; junction point of the two segments */
338     hi_s32 dst_cali_ratio[DST_LENS_COEF_SEG][DST_LENS_COEF_NUM];  /* RW; lens distortion coefficients, with 5 decimal
339                                                                     numbers */
340     hi_s32 dst_jun_pt[DST_LENS_COEF_SEG_POINT];                   /* RW; junction point of the three segments */
341     hi_s32 max_du;                                                /* RW; max undistorted distance before 3rd
342                                                                     polynomial drop, with 16bits decimal */
343 } hi_ldc_v2_attr;
344 
345 typedef LDC_VIEW_TYPE_E hi_ldc_view_type;
346 
347 typedef struct {
348     hi_ldc_view_type view_type; /* RW; range: [0, 1], 0: all mode, 1: crop mode. */
349     hi_s32 center_x_offset;    /* RW; range: ABS(center_x_offset)->[0, min(128, width*0.08)], horizontal offset
350                                 of the image distortion center relative to image center. */
351     hi_s32 center_y_offset;    /* RW; range: ABS(center_x_offset)->[0, min(128, height*0.08)], vertical offset of
352                                 the image distortion center relative to image center. */
353     hi_s32 distortion_ratio;  /* RW; range: [-300, 300], LDC distortion ratio. */
354     hi_s32 min_ratio;         /* RW; range: [-300, 300], to remove the black region around when performing
355                                 pinchusion distortion correction with crop mode. */
356 } hi_ldc_v3_attr;
357 
358 typedef ROTATION_VIEW_TYPE_E hi_rotation_view_type;
359 
360 typedef struct {
361     hi_rotation_view_type view_type;       /* RW;range: [0, 2];rotation mode */
362     hi_u32               angle;         /* RW;range: [0,360];rotation angle:[0,360] */
363     hi_s32               center_x_offset; /* RW;range: [-511, 511];horizontal offset of the image distortion center
364                                             relative to image center. */
365     hi_s32               center_y_offset; /* RW;range: [-511, 511];vertical offset of the image distortion center
366                                             relative to image center. */
367     hi_size               dest_size;       /* RW;dest size of any angle rotation */
368 } hi_rotation_ex;
369 
370 typedef WDR_MODE_E hi_wdr_mode;
371 
372 typedef FRAME_INTERRUPT_TYPE_E hi_frame_interrupt_type;
373 
374 typedef struct {
375     hi_frame_interrupt_type int_type;
376     hi_u32 early_line;
377 } hi_frame_interrupt_attr;
378 
379 #ifdef __cplusplus
380 #if __cplusplus
381 }
382 #endif
383 #endif /* __cplusplus */
384 
385 #endif /* __HI_COMM_VIDEO_ADAPT_H__ */
386 
387