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_ACNR_ALGO_INT_V30_H_ 21 #define _RK_AIQ_TYPE_ACNR_ALGO_INT_V30_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 "acnrV30/rk_aiq_types_acnr_algo_v30.h" 29 #include "cnr_head_v30.h" 30 #include "cnr_uapi_head_v30.h" 31 32 33 //RKAIQ_BEGIN_DECLARE 34 #define RK_CNR_V30_MAX_ISO_NUM (CALIBDB_MAX_ISO_LEVEL) 35 36 #define ACNRV30_RECALCULATE_DELTA_ISO (10) 37 ////////////////////////////////////////////////////////////////////////// 38 #define RKCNR_V30_MAX_DOWN_SCALE 8 39 // iir params 40 #define RKCNR_V30_FIX_BIT_BF_RATIO 10 41 #define RKCNR_V30_FIX_BIT_IIR_WGT 6//10 42 #define RKCNR_V30_FIX_BIT_INV_SIGMA 15 43 #define RKCNR_V30_FIX_BIT_SLOPE 7 44 #define RKCNR_V30_FIX_BIT_WGT_RATIO 3 45 #define RKCNR_V30_FIX_BIT_INT_TO_FLOAT 7 46 // gain params 47 #define RKCNR_V30_SIGMA_FIX_BIT 8 48 #define RKCNR_V30_LOCAL_GAIN_FIX_BITS 4 49 #define RKCNR_V30_G_GAIN_FIX_BITS 4 50 #define RKCNR_V30_G_GAIN_ALPHA_FIX_BITS 3 51 #define RKCNR_V30_GAIN_ISO_FIX_BITS 7 52 // 3x3 bf params 53 #define RKCNR_V30_FIX_BIT_GAUS_RATIO 10 54 #define RKCNR_V30_sgmRatio 6 55 #define RKCNR_V30_log2e 6 56 #define RKCNR_V30_uvgain 4 57 #define RKCNR_V30_exp2_lut_y 7 58 #define RKCNR_V30_bfRatio RKCNR_V30_exp2_lut_y 59 // saturation adj param fix bit 60 #define RKCNR_V30_FIX_BIT_SATURATION 10 61 // global alpha fix bit 62 #define RKCNR_V30_FIX_BIT_GLOBAL_ALPHA 10 63 // div sum wgt fix bit 64 #define RKCNR_V30_FIX_BIT_DIV_SUM_WGT 22// 65 #define RKCNR_V30_FIX_BIT_DIST_SCALE 7 66 ////////////////////////////////////////////////////////////////////////// 67 // params 68 #define RKCNR_V30_THUMB_BF_RADIUS 3 69 #define RKCNR_V30_IIR_RADIUSY 1 70 #define RKCNR_V30_IIR_RADIUSX 3//1 71 #define RKCNR_V30_BF_RADIUS 1 72 #define RKCNR_V30_IIR_COEFF_NUM 10 73 #define RKCNR_V30_SGM_ADJ_TABLE_LEN 13 74 // extend of down scale yuv, 3x3 IIR, 3x3 bf 75 #define RKCNR_V30_DS_EXTEND_Y (RKCNR_V30_IIR_RADIUSY) 76 #define RKCNR_V30_DS_EXTEND_X (RKCNR_V30_IIR_RADIUSX) 77 #define RKCNR_V30_GAUS_RADIUS 2 78 #define RKCNR_V30_CLIP_RADIUS 1 79 #define cnr_422_5x5_gaus 0 // 422: 5x3 or 5x5 gaussian filter 80 81 82 typedef enum AcnrV30_result_e { 83 ACNRV30_RET_SUCCESS = 0, // this has to be 0, if clauses rely on it 84 ACNRV30_RET_FAILURE = 1, // process failure 85 ACNRV30_RET_INVALID_PARM = 2, // invalid parameter 86 ACNRV30_RET_WRONG_CONFIG = 3, // feature not supported 87 ACNRV30_RET_BUSY = 4, // there's already something going on... 88 ACNRV30_RET_CANCELED = 5, // operation canceled 89 ACNRV30_RET_OUTOFMEM = 6, // out of memory 90 ACNRV30_RET_OUTOFRANGE = 7, // parameter/value out of range 91 ACNRV30_RET_NULL_POINTER = 8, // the/one/all parameter(s) is a(are) NULL pointer(s) 92 ACNRV30_RET_DIVISION_BY_ZERO = 9, // a divisor equals ZERO 93 ACNRV30_RET_NO_INPUTIMAGE = 10 // no input image 94 } AcnrV30_result_t; 95 96 typedef enum AcnrV30_State_e { 97 ACNRV30_STATE_INVALID = 0, /**< initialization value */ 98 ACNRV30_STATE_INITIALIZED = 1, /**< instance is created, but not initialized */ 99 ACNRV30_STATE_STOPPED = 2, /**< instance is confiured (ready to start) or stopped */ 100 ACNRV30_STATE_RUNNING = 3, /**< instance is running (processes frames) */ 101 ACNRV30_STATE_LOCKED = 4, /**< instance is locked (for taking snapshots) */ 102 ACNRV30_STATE_MAX /**< max */ 103 } AcnrV30_State_t; 104 105 typedef enum AcnrV30_OPMode_e { 106 ACNRV30_OP_MODE_INVALID = 0, /**< initialization value */ 107 ACNRV30_OP_MODE_AUTO = 1, /**< instance is created, but not initialized */ 108 ACNRV30_OP_MODE_MANUAL = 2, /**< instance is confiured (ready to start) or stopped */ 109 ACNRV30_OP_MODE_REG_MANUAL = 3, 110 ACNRV30_OP_MODE_MAX /**< max */ 111 } AcnrV30_OPMode_t; 112 113 typedef enum AcnrV30_ParamMode_e { 114 ACNRV30_PARAM_MODE_INVALID = 0, 115 ACNRV30_PARAM_MODE_NORMAL = 1, /**< initialization value */ 116 ACNRV30_PARAM_MODE_HDR = 2, /**< instance is created, but not initialized */ 117 ACNRV30_PARAM_MODE_GRAY = 3, /**< instance is confiured (ready to start) or stopped */ 118 ACNRV30_PARAM_MODE_MAX /**< max */ 119 } AcnrV30_ParamMode_t; 120 121 122 123 124 #if 0 125 typedef struct RK_CNR_Params_V30_Select_s 126 { 127 int enable; 128 129 int down_scale_x; 130 int down_scale_y; 131 132 float thumb_sigma; 133 float thumb_bf_ratio; 134 135 float chroma_filter_strength; 136 float chroma_filter_wgt_clip; 137 float anti_chroma_ghost; 138 float chroma_filter_uv_gain; 139 float wgt_slope; 140 141 float gaus_ratio; 142 143 float bf_sigmaR; 144 float bf_uvgain; 145 float bf_ratio; 146 float hbf_wgt_clip; 147 float bf_wgt0_sel; 148 float global_alpha; 149 150 float saturation_adj_offset; 151 float saturation_adj_ratio; 152 153 float global_gain; 154 float global_gain_alpha; 155 float local_gain_scale; 156 float global_gain_thumb; 157 float global_gain_alpha_thumb; 158 159 float gain_adj_strength_ratio[13]; 160 161 float thumb_filter_wgt_coeff[4]; 162 float gaus_coeff[6]; 163 164 165 } RK_CNR_Params_V30_Select_t; 166 #endif 167 168 typedef struct RK_CNR_Params_V30_s 169 { 170 int enable; 171 float iso[RK_CNR_V30_MAX_ISO_NUM]; 172 173 RK_CNR_Params_V30_Select_t CnrParamsISO[RK_CNR_V30_MAX_ISO_NUM]; 174 175 } RK_CNR_Params_V30_t; 176 177 178 typedef struct Acnr_Manual_Attr_V30_s 179 { 180 RK_CNR_Params_V30_Select_t stSelect; 181 182 RK_CNR_Fix_V30_t stFix; 183 184 } Acnr_Manual_Attr_V30_t; 185 186 typedef struct Acnr_Auto_Attr_V30_s 187 { 188 //all ISO params and select param 189 190 RK_CNR_Params_V30_t stParams; 191 RK_CNR_Params_V30_Select_t stSelect; 192 193 } Acnr_Auto_Attr_V30_t; 194 195 typedef struct Acnr_ProcResult_V30_s { 196 197 //for sw simultaion 198 //RK_CNR_Params_V30_Select_t stSelect; 199 200 //for hw register 201 RK_CNR_Fix_V30_t* stFix; 202 } Acnr_ProcResult_V30_t; 203 204 205 typedef struct Acnr_Config_V30_s { 206 AcnrV30_State_t eState; 207 AcnrV30_OPMode_t eMode; 208 int rawHeight; 209 int rawWidth; 210 } Acnr_Config_V30_t; 211 212 213 typedef struct rk_aiq_cnr_attrib_v30_s { 214 rk_aiq_uapi_sync_t sync; 215 AcnrV30_OPMode_t eMode; 216 Acnr_Auto_Attr_V30_t stAuto; 217 Acnr_Manual_Attr_V30_t stManual; 218 } rk_aiq_cnr_attrib_v30_t; 219 220 221 typedef struct rk_aiq_cnr_strength_v30_s { 222 rk_aiq_uapi_sync_t sync; 223 float percent; 224 bool strength_enable; 225 } rk_aiq_cnr_strength_v30_t; 226 227 228 229 //calibdb 230 231 232 //RKAIQ_END_DECLARE 233 234 #endif 235 236