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