liyujie
2025-08-28 d9927380ed7c8366f762049be9f3fee225860833
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
 
/*
 ******************************************************************************
 *
 * isp_rolloff.h
 *
 * Hawkview ISP - isp_rolloff.h module
 *
 * Copyright (c) 2021 by Allwinnertech Co., Ltd.  http://www.allwinnertech.com
 *
 * Version          Author         Date            Description
 *   4.0        guoqiuwang       2021/09/30        VIDEO INPUT
 *
 *****************************************************************************
 */
 
#ifndef _ISP_3A_ROLLOFF_H_
#define _ISP_3A_ROLLOFF_H_
 
#if (ISP_VERSION == 522)
#define ISP_LIB_USE_ROLLOFF            1
#endif
 
#define CORRECTFREQ                    6
#define ROLLOFFSTART                (5 * CORRECTFREQ)
 
#define TH_FROSTEDGLASS                0.018       /* 0.025 */
#define TH_LOWLIGHT                    35
#define TH_COMPLEX                    0.55
#define TH_HIGHSAT                    0.63
#define TH_SEMIFLAT                    0.045        /* 0.045 */
#define TH_MAXPERCENTAGE            0.95        /* 0.95 * 256 */
#define TH_THRATIO                    0.11        /* 0.11 * 256 */
#define    TH_DARKPIXEL                20
#define    TH_BRIGHTPIXEL                240
#define    TH_AREAOPENNUMBER            60
#define    TH_FLATGRADRG                0.026
#define    TH_RGDIFFPEAK                0.18        /* 0.18 */
#define    TH_AREAOPENNUMBER2            40
#define TH_HIGHPERCENTAGE            0.85        /* 0.85 * 256 */
#define TH_LOWPERCENTAGE            0.15        /* 0.15 * 256 */
#define TH_ERRBASEDIFF                0.1
#define TH_FLATSTDY                    70
#define TH_FLATMEANY                210
#define TH_FLATRANGERG                0.24
#define TH_DIFFA                    15
#define TH_DIFFB                    10
#define TH_SATURATION                0.53
#define TH_LOWSATURATION            0.25
#define TH_ERRGAINDIFF                0.03
 
#define Y_WEIGHT_R                    0.299        /* 0.299 * 1024 */
#define Y_WEIGHT_G                    0.587        /* 0.587 * 1024 */
#define Y_WEIGHT_B                    0.114        /* 0.114 * 1024 */
 
#define TWICE_CORRECT_TABLE_NUM        11
 
#define RATIOEDGE                    2
 
#define ROLLOFF_ROW_SIZE            32
#define ROLLOFF_COL_SIZE            32
#define ROLLOFF_WIN_SIZE            (ROLLOFF_ROW_SIZE * ROLLOFF_COL_SIZE)
 
#define CENTERX                        15
#define CENTERY                        16
 
#define LSCGAINPOOLSIZE                64
 
 
typedef struct Point {
   HW_S32 row;
   HW_S32 col;
} Point_t;
 
typedef struct Lab {
   float Lab_L;
   float Lab_a;
   float Lab_b;
} Lab_t;
typedef struct notFlatPointInfo {
   Lab_t Lab;
   HW_S32 position;
} notFlatPointInfo_t;
 
typedef struct flatPointInfo {
   HW_U16 position;
   float _RG;
   float Lab_L;
   float Lab_a;
   float Lab_b;
} flatPointInfo_t;
 
typedef struct flatPointDistTOGain {
   HW_U8 dist;
   float gain;
} flatPointDistToGain_t;
 
typedef struct flatDistToGain {
   float *gain;
} flatDistToGain_t;
 
typedef struct LscGainPool {
   float *LscRGain;
   float *LscGGain;
   float *LscBGain;
} LscGainPool_t;
 
typedef enum rolloff_correct_mode {
   RGBChCorrect = 0,
   PreCorrect,
   RChCorrect,
   TwiceCorrect,
} rolloff_correct_mode_t;
 
typedef struct FlatPreCorrectInfo {
   float flatPreIndex;
   float flatPreDiff;
} flatPreCorrectInfo_t;
 
 
typedef enum isp_rolloff_param_type {
   ISP_ROLLOFF_INI_DATA,
   ISP_ROLLOFF_PARAM_TYPE_MAX,
} rolloff_param_type_t;
 
typedef struct isp_rolloff_ini_cfg {
   HW_U16 Rgain[ROLLOFF_WIN_SIZE * 11];
} rolloff_ini_cfg_t;
 
typedef enum rolloff_triger_type {
   ROLLOFF_TRIGER_BY_LUM_IDX = 0,
   ROLLOFF_TRIGER_BY_GAIN_IDX,
   ROLLOFF_TRIGER_MAX,
} rolloff_triger_type_t;
 
typedef struct isp_rolloff_iso_config {
   rolloff_triger_type_t    triger_type;
   HW_S32    shading_comp_dynamic_cfg[14];
} isp_rolloff_iso_config_t;
 
 
typedef struct isp_rolloff_setting {
   HW_U16    smooth_pool_size;
   HW_U16  th_tableSwitch;
   HW_U16    frequency;
   HW_U16    start;
   HW_U16    th_lowLight;
   HW_U16    th_complex;
   HW_U16    th_highSat;
   HW_U16    th_maxPercent;
   HW_U16    th_thRatio;
   HW_U16    th_semiFlat;
   isp_rolloff_iso_config_t iso_config;
} isp_rolloff_setting_t;
 
typedef struct isp_rolloff_param {
   rolloff_param_type_t type;
   HW_S32 isp_platform_id;
   HW_S32 rolloff_frame_id;
   isp_sensor_info_t rolloff_sensor_info;
   rolloff_ini_cfg_t rolloff_ini;
   isp_rolloff_setting_t rolloff_ctrl;
} rolloff_param_t;
 
typedef struct isp_rolloff_stats {
   struct isp_stats_s *rolloff_stats;
} rolloff_stats_t;
 
typedef struct isp_rolloff_result {
   float RGainTbl[ISP_LENS_TBL_SIZE];
   float GGainTbl[ISP_LENS_TBL_SIZE];
   float BGainTbl[ISP_LENS_TBL_SIZE];
   rolloff_correct_mode_t correctMode;
} rolloff_result_t;
 
typedef struct isp_rolloff_core_ops {
   HW_S32 (*isp_rolloff_set_params)(void *rolloff_core_obj, rolloff_param_t *param, rolloff_result_t *result);
   HW_S32 (*isp_rolloff_get_params)(void *rolloff_core_obj, rolloff_param_t **param);
   HW_S32 (*isp_rolloff_run)(void *rolloff_core_obj, rolloff_stats_t *stats, rolloff_result_t *result);
} isp_rolloff_core_ops_t;
 
void *rolloff_init(isp_rolloff_core_ops_t **rolloff_core_ops);
void  rolloff_exit(void *rolloff_core_obj);
 
#endif /*_ISP_3A_ROLLOFF_H_*/