1 /*
2  *rk_aiq_types_alsc_algo_int.h
3  *
4  *  Copyright (c) 2019 Rockchip Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 
20 #ifndef _RK_AIQ_TYPE_AYNR_ALGO_INT_V22_H_
21 #define _RK_AIQ_TYPE_AYNR_ALGO_INT_V22_H_
22 
23 #include <math.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include "rk_aiq_comm.h"
27 #include "RkAiqCalibDbTypes.h"
28 #include "aynrV22/rk_aiq_types_aynr_algo_v22.h"
29 #include "ynr_head_v22.h"
30 #include "ynr_uapi_head_v22.h"
31 
32 
33 //RKAIQ_BEGIN_DECLARE
34 #define RK_YNR_V22_MAX_ISO_NUM (CALIBDB_MAX_ISO_LEVEL)
35 
36 
37 #define AYNRV22_RECALCULATE_DELTA_ISO       (10)
38 #define YNR_V22_SIGMA_BITS                  10
39 #define YNR_V22_NOISE_SIGMA_FIX_BIT              3
40 #define LOG2(x)                             (log((double)x)                 / log((double)2))
41 
42 
43 typedef enum Aynr_result_V22_e {
44     AYNRV22_RET_SUCCESS             = 0,   // this has to be 0, if clauses rely on it
45     AYNRV22_RET_FAILURE             = 1,   // process failure
46     AYNRV22_RET_INVALID_PARM        = 2,   // invalid parameter
47     AYNRV22_RET_WRONG_CONFIG        = 3,   // feature not supported
48     AYNRV22_RET_BUSY                = 4,   // there's already something going on...
49     AYNRV22_RET_CANCELED            = 5,   // operation canceled
50     AYNRV22_RET_OUTOFMEM            = 6,   // out of memory
51     AYNRV22_RET_OUTOFRANGE          = 7,   // parameter/value out of range
52     AYNRV22_RET_NULL_POINTER        = 8,   // the/one/all parameter(s) is a(are) NULL pointer(s)
53     AYNRV22_RET_DIVISION_BY_ZERO    = 9,   // a divisor equals ZERO
54     AYNRV22_RET_NO_INPUTIMAGE       = 10   // no input image
55 } Aynr_result_V22_t;
56 
57 typedef enum Aynr_State_V22_e {
58     AYNRV22_STATE_INVALID           = 0,                   /**< initialization value */
59     AYNRV22_STATE_INITIALIZED       = 1,                   /**< instance is created, but not initialized */
60     AYNRV22_STATE_STOPPED           = 2,                   /**< instance is confiured (ready to start) or stopped */
61     AYNRV22_STATE_RUNNING           = 3,                   /**< instance is running (processes frames) */
62     AYNRV22_STATE_LOCKED            = 4,                   /**< instance is locked (for taking snapshots) */
63     AYNRV22_STATE_MAX                                      /**< max */
64 } Aynr_State_V22_t;
65 
66 typedef enum Aynr_OPMode_V22_e {
67     AYNRV22_OP_MODE_INVALID           = 0,                   /**< initialization value */
68     AYNRV22_OP_MODE_AUTO              = 1,                   /**< instance is created, but not initialized */
69     AYNRV22_OP_MODE_MANUAL            = 2,                   /**< instance is confiured (ready to start) or stopped */
70     AYNRV22_OP_MODE_REG_MANUAL        = 3,
71     AYNRV22_OP_MODE_MAX                                      /**< max */
72 } Aynr_OPMode_V22_t;
73 
74 typedef enum Aynr_ParamMode_V22_e {
75     AYNRV22_PARAM_MODE_INVALID           = 0,
76     AYNRV22_PARAM_MODE_NORMAL          = 1,                   /**< initialization value */
77     AYNRV22_PARAM_MODE_HDR              = 2,                   /**< instance is created, but not initialized */
78     AYNRV22_PARAM_MODE_GRAY            = 3,                   /**< instance is confiured (ready to start) or stopped */
79     AYNRV22_PARAM_MODE_MAX                                      /**< max */
80 } Aynr_ParamMode_V22_t;
81 
82 
83 #if 0
84 typedef struct RK_YNR_Params_V22_Select_s
85 {
86     int enable;
87 
88     float lci;
89     float hci;
90     float sigma[YNR_V22_ISO_CURVE_POINT_NUM];
91     short lumaPoint[YNR_V22_ISO_CURVE_POINT_NUM];
92 
93     float lo_lumaPoint[6];
94     float lo_ratio[6];
95 
96     float hi_lumaPoint[6];
97     float hi_ratio[6];
98 
99     //local gain control
100     float ynr_global_gain_alpha;
101     float ynr_global_gain;
102     float ynr_adjust_thresh;
103     float ynr_adjust_scale;
104 
105     // low frequency
106     float rnr_strength[17];
107     int ynr_bft3x3_bypass;
108     int ynr_lbft5x5_bypass;
109     int ynr_lgft3x3_bypass;
110     int ynr_flt1x1_bypass;
111     int ynr_nlm11x11_bypass;
112 
113     float low_bf1;
114     float low_bf2;
115     float low_thred_adj;
116     float low_peak_supress;
117     float low_edge_adj_thresh;
118     float low_lbf_weight_thresh;
119     float low_center_weight;
120     float low_dist_adj;
121     float low_weight;
122     float low_filt1_strength;
123     float low_filt2_strength;
124     float low_bi_weight;
125 
126 
127     // high frequency
128     float hi_weight_offset;
129     float hi_center_weight;
130     float hi_bf_scale;
131     float hi_min_sigma;
132     float hi_nr_weight;
133     float hi_gain_alpha;
134     int hi_filter_coeff1_1;
135     int hi_filter_coeff1_2;
136     int hi_filter_coeff1_3;
137     int hi_filter_coeff2_1;
138     int hi_filter_coeff2_2;
139     int hi_filter_coeff2_3;
140 } RK_YNR_Params_V22_Select_t;
141 #endif
142 
143 
144 typedef struct RK_YNR_Params_V22_s
145 {
146     int enable;
147     char version[64];
148     float iso[RK_YNR_V22_MAX_ISO_NUM];
149     RK_YNR_Params_V22_Select_t arYnrParamsISO[RK_YNR_V22_MAX_ISO_NUM];
150 
151 } RK_YNR_Params_V22_t;
152 
153 
154 typedef struct Aynr_Manual_Attr_V22_s
155 {
156     RK_YNR_Params_V22_Select_t stSelect;
157 
158     RK_YNR_Fix_V22_t stFix;
159 
160 } Aynr_Manual_Attr_V22_t;
161 
162 typedef struct Aynr_Auto_Attr_V22_s
163 {
164     //all ISO params and select param
165 
166     RK_YNR_Params_V22_t stParams;
167     RK_YNR_Params_V22_Select_t stSelect;
168 
169 } Aynr_Auto_Attr_V22_t;
170 
171 typedef struct Aynr_ProcResult_V22_s {
172 
173     //for sw simultaion
174     RK_YNR_Params_V22_Select_t* stSelect;
175 
176     //for hw register
177     RK_YNR_Fix_V22_t* stFix;
178 
179     //bool isNeedUpdate;
180 
181 } Aynr_ProcResult_V22_t;
182 
183 
184 typedef struct Aynr_Config_V22_s {
185     Aynr_State_V22_t eState;
186     Aynr_OPMode_V22_t eMode;
187     int rawHeight;
188     int rawWidth;
189 } Aynr_Config_V22_t;
190 
191 
192 typedef struct rk_aiq_ynr_attrib_v22_s {
193     /*
194      * @sync (param in): flags for param update mode,
195      *     true for sync, false for async.
196      * @done (parsm out): flags for param update status,
197      *     true indicate param has been updated, false
198      *     indicate param has not been updated.
199      */
200     rk_aiq_uapi_sync_t sync;
201 
202     Aynr_OPMode_V22_t eMode;
203     Aynr_Auto_Attr_V22_t stAuto;
204     Aynr_Manual_Attr_V22_t stManual;
205 } rk_aiq_ynr_attrib_v22_t;
206 
207 
208 typedef struct rk_aiq_ynr_strength_v22_s {
209     /*
210      * @sync (param in): flags for param update mode,
211      *     true for sync, false for async.
212      * @done (parsm out): flags for param update status,
213      *     true indicate param has been updated, false
214      *     indicate param has not been updated.
215      */
216     rk_aiq_uapi_sync_t sync;
217 
218     float percent;
219     bool strength_enable;
220 } rk_aiq_ynr_strength_v22_t;
221 
222 
223 
224 
225 
226 //calibdb
227 
228 
229 //RKAIQ_END_DECLARE
230 
231 #endif
232 
233