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_V2_H_
21 #define _RK_AIQ_TYPE_AYNR_ALGO_INT_V2_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 "aynr2/rk_aiq_types_aynr_algo_v2.h"
29 #include "ynr_head_v2.h"
30 
31 
32 //RKAIQ_BEGIN_DECLARE
33 #define AYNRV2_RECALCULATE_DELTA_ISO       (10)
34 #define YNR_V2_ISO_CURVE_POINT_BIT          4
35 #define YNR_V2_ISO_CURVE_POINT_NUM          ((1 << YNR_V2_ISO_CURVE_POINT_BIT)+1)
36 #define YNR_V2_SIGMA_BITS                  10
37 #define YNR_V2_NOISE_SIGMA_FIX_BIT              3
38 #define LOG2(x)                             (log((double)x)                 / log((double)2))
39 
40 
41 typedef enum Aynr_result_e {
42     AYNR_RET_SUCCESS             = 0,   // this has to be 0, if clauses rely on it
43     AYNR_RET_FAILURE             = 1,   // process failure
44     AYNR_RET_INVALID_PARM        = 2,   // invalid parameter
45     AYNR_RET_WRONG_CONFIG        = 3,   // feature not supported
46     AYNR_RET_BUSY                = 4,   // there's already something going on...
47     AYNR_RET_CANCELED            = 5,   // operation canceled
48     AYNR_RET_OUTOFMEM            = 6,   // out of memory
49     AYNR_RET_OUTOFRANGE          = 7,   // parameter/value out of range
50     AYNR_RET_NULL_POINTER        = 8,   // the/one/all parameter(s) is a(are) NULL pointer(s)
51     AYNR_RET_DIVISION_BY_ZERO    = 9,   // a divisor equals ZERO
52     AYNR_RET_NO_INPUTIMAGE       = 10   // no input image
53 } Aynr_result_t;
54 
55 typedef enum Aynr_State_e {
56     AYNR_STATE_INVALID           = 0,                   /**< initialization value */
57     AYNR_STATE_INITIALIZED       = 1,                   /**< instance is created, but not initialized */
58     AYNR_STATE_STOPPED           = 2,                   /**< instance is confiured (ready to start) or stopped */
59     AYNR_STATE_RUNNING           = 3,                   /**< instance is running (processes frames) */
60     AYNR_STATE_LOCKED            = 4,                   /**< instance is locked (for taking snapshots) */
61     AYNR_STATE_MAX                                      /**< max */
62 } Aynr_State_t;
63 
64 typedef enum Aynr_OPMode_e {
65     AYNR_OP_MODE_INVALID           = 0,                   /**< initialization value */
66     AYNR_OP_MODE_AUTO              = 1,                   /**< instance is created, but not initialized */
67     AYNR_OP_MODE_MANUAL            = 2,                   /**< instance is confiured (ready to start) or stopped */
68     AYNR_OP_MODE_MAX                                      /**< max */
69 } Aynr_OPMode_t;
70 
71 typedef enum Aynr_ParamMode_e {
72     AYNR_PARAM_MODE_INVALID           = 0,
73     AYNR_PARAM_MODE_NORMAL          = 1,                   /**< initialization value */
74     AYNR_PARAM_MODE_HDR              = 2,                   /**< instance is created, but not initialized */
75     AYNR_PARAM_MODE_GRAY            = 3,                   /**< instance is confiured (ready to start) or stopped */
76     AYNR_PARAM_MODE_MAX                                      /**< max */
77 } Aynr_ParamMode_t;
78 
79 typedef struct Aynr_ExpInfo_s {
80     int hdr_mode;
81     float arTime[3];
82     float arAGain[3];
83     float arDGain[3];
84     int   arIso[3];
85     int   snr_mode;
86     int rawWidth;
87     int rawHeight;
88 } Aynr_ExpInfo_t;
89 
90 typedef struct RK_YNR_Params_V2_Select_s
91 {
92     int enable;
93     float ciISO_V2[2];
94     float noiseSigma_V2[YNR_V2_ISO_CURVE_POINT_NUM];
95     short lumaPoints_V2[YNR_V2_ISO_CURVE_POINT_NUM];
96 
97     // low frequency
98     int ynr_big_resolution_mode;
99     int ynr_global_gain_V2;
100     float ynr_rnr_strength_V2[17];
101     int ynr_bft3x3_bypass_V2;
102     int ynr_lbft5x5_bypass_V2;
103     int ynr_lgft3x3_bypass_V2;
104     int ynr_flt1x1_bypass_V2;
105     int ynr_sft5x5_bypass_V2;
106     float ynr_low_bf_V2[2];
107     float ynr_low_thred_adj_V2;
108     float ynr_low_peak_supress_V2;
109     float ynr_low_edge_adj_thresh_V2;
110     float ynr_low_center_weight_V2;
111     float ynr_low_dist_adj_V2;
112     float ynr_low_weight_V2;
113     float ynr_low_filt1_strength_V2;
114     float ynr_low_filt2_strength_V2;
115     float ynr_low_bi_weight_V2;
116 
117     // high frequency
118     float ynr_base_filter_weight1_V2;
119     float ynr_base_filter_weight2_V2;
120     float ynr_base_filter_weight3_V2;
121     float ynr_high_thred_adj_V2;
122     float ynr_high_weight_V2;
123     float ynr_direction_weight_V2[8];
124     float ynr_hi_min_adj_V2;
125     float ynr_hi_edge_thed_V2;
126 } RK_YNR_Params_V2_Select_t;
127 
128 
129 
130 typedef struct RK_YNR_Params_V2_s
131 {
132     int enable;
133     char version[64];
134     float iso[RK_YNR_V2_MAX_ISO_NUM];
135     RK_YNR_Params_V2_Select_t arYnrParamsISO[RK_YNR_V2_MAX_ISO_NUM];
136 
137 } RK_YNR_Params_V2_t;
138 
139 
140 typedef struct Aynr_Manual_Attr_V2_s
141 {
142     int ynrEn;
143     RK_YNR_Params_V2_Select_t stSelect;
144 
145 } Aynr_Manual_Attr_V2_t;
146 
147 typedef struct Aynr_Auto_Attr_V2_s
148 {
149     //all ISO params and select param
150     int ynrEn;
151 
152     RK_YNR_Params_V2_t stParams;
153     RK_YNR_Params_V2_Select_t stSelect;
154 
155 } Aynr_Auto_Attr_V2_t;
156 
157 typedef struct Aynr_ProcResult_V2_s {
158     int ynrEn;
159 
160     //for sw simultaion
161     //RK_YNR_Params_V2_Select_t stSelect;
162 
163     //for hw register
164     RK_YNR_Fix_V2_t* stFix;
165 } Aynr_ProcResult_V2_t;
166 
167 
168 typedef struct Aynr_Config_V2_s {
169     Aynr_State_t eState;
170     Aynr_OPMode_t eMode;
171     int rawHeight;
172     int rawWidth;
173 } Aynr_Config_V2_t;
174 
175 
176 typedef struct rk_aiq_ynr_attrib_v2_s {
177     Aynr_OPMode_t eMode;
178     Aynr_Auto_Attr_V2_t stAuto;
179     Aynr_Manual_Attr_V2_t stManual;
180 } rk_aiq_ynr_attrib_v2_t;
181 
182 
183 typedef struct rk_aiq_ynr_IQPara_V2_s {
184     struct list_head* listHead;
185 } rk_aiq_ynr_IQPara_V2_t;
186 
187 
188 //calibdb
189 
190 
191 //RKAIQ_END_DECLARE
192 
193 #endif
194 
195