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_ASHARP_ALGO_INT_V4_H_ 21 #define _RK_AIQ_TYPE_ASHARP_ALGO_INT_V4_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 "asharp4/rk_aiq_types_asharp_algo_v4.h" 29 #include "sharp_head_v4.h" 30 #include "sharp_uapi_head_v4.h" 31 32 33 RKAIQ_BEGIN_DECLARE 34 #define RK_SHARP_V4_MAX_ISO_NUM CALIBDB_MAX_ISO_LEVEL 35 36 #if 0 37 #define RK_SHARP_V4_LUMA_POINT_NUM (8) 38 #define RK_SHARP_V4_PBF_DIAM 3 39 #define RK_SHARP_V4_RF_DIAM 5 40 #define RK_SHARP_V4_BF_DIAM 3 41 #endif 42 43 #define ASHARPV4_RECALCULATE_DELTA_ISO (10) 44 #define RK_SHARP_V4_AVG_DIAM 3 45 46 #define rk_sharp_V4_sharp_ratio_fix_bits 2 47 #define rk_sharp_V4_gaus_ratio_fix_bits 7 48 #define rk_sharp_V4_bf_ratio_fix_bits 7 49 #define rk_sharp_V4_pbfCoeff_fix_bits 7 50 #define rk_sharp_V4_rfCoeff_fix_bits 7 51 #define rk_sharp_V4_hbfCoeff_fix_bits 7 52 53 #define INTERP_V4(x0, x1, ratio) ((ratio) * ((x1) - (x0)) + x0) 54 #define CLIP(a, min_v, max_v) (((a) < (min_v)) ? (min_v) : (((a) > (max_v)) ? (max_v) : (a))) 55 56 57 #if 1 58 typedef enum Asharp4_result_e { 59 ASHARP4_RET_SUCCESS = 0, // this has to be 0, if clauses rely on it 60 ASHARP4_RET_FAILURE = 1, // process failure 61 ASHARP4_RET_INVALID_PARM = 2, // invalid parameter 62 ASHARP4_RET_WRONG_CONFIG = 3, // feature not supported 63 ASHARP4_RET_BUSY = 4, // there's already something going on... 64 ASHARP4_RET_CANCELED = 5, // operation canceled 65 ASHARP4_RET_OUTOFMEM = 6, // out of memory 66 ASHARP4_RET_OUTOFRANGE = 7, // parameter/value out of range 67 ASHARP4_RET_NULL_POINTER = 8, // the/one/all parameter(s) is a(are) NULL pointer(s) 68 ASHARP4_RET_DIVISION_BY_ZERO = 9, // a divisor equals ZERO 69 ASHARP4_RET_NO_INPUTIMAGE = 10 // no input image 70 } Asharp4_result_t; 71 72 typedef enum Asharp4_State_e { 73 ASHARP4_STATE_INVALID = 0, /**< initialization value */ 74 ASHARP4_STATE_INITIALIZED = 1, /**< instance is created, but not initialized */ 75 ASHARP4_STATE_STOPPED = 2, /**< instance is confiured (ready to start) or stopped */ 76 ASHARP4_STATE_RUNNING = 3, /**< instance is running (processes frames) */ 77 ASHARP4_STATE_LOCKED = 4, /**< instance is locked (for taking snapshots) */ 78 ASHARP4_STATE_MAX /**< max */ 79 } Asharp4_State_t; 80 81 typedef enum Asharp4_OPMode_e { 82 ASHARP4_OP_MODE_INVALID = 0, /**< initialization value */ 83 ASHARP4_OP_MODE_AUTO = 1, /**< instance is created, but not initialized */ 84 ASHARP4_OP_MODE_MANUAL = 2, /**< instance is confiured (ready to start) or stopped */ 85 ASHARP4_OP_MODE_REG_MANUAL = 3, 86 ASHARP4_OP_MODE_MAX /**< max */ 87 } Asharp4_OPMode_t; 88 89 typedef enum Asharp4_ParamMode_e { 90 ASHARP4_PARAM_MODE_INVALID = 0, 91 ASHARP4_PARAM_MODE_NORMAL = 1, /**< initialization value */ 92 ASHARP4_PARAM_MODE_HDR = 2, /**< instance is created, but not initialized */ 93 ASHARP4_PARAM_MODE_GRAY = 3, /**< instance is confiured (ready to start) or stopped */ 94 ASHARP4_PARAM_MODE_MAX /**< max */ 95 } Asharp4_ParamMode_t; 96 97 #endif 98 99 100 101 typedef struct RK_SHARP_Params_V4_s 102 { 103 int enable; 104 int kernel_sigma_enable; 105 106 int iso[RK_SHARP_V4_MAX_ISO_NUM]; 107 short luma_point [RK_SHARP_V4_LUMA_POINT_NUM]; 108 short luma_sigma [RK_SHARP_V4_MAX_ISO_NUM][RK_SHARP_V4_LUMA_POINT_NUM]; 109 float pbf_gain [RK_SHARP_V4_MAX_ISO_NUM]; 110 float pbf_add [RK_SHARP_V4_MAX_ISO_NUM]; 111 float pbf_ratio [RK_SHARP_V4_MAX_ISO_NUM]; 112 float gaus_ratio [RK_SHARP_V4_MAX_ISO_NUM]; 113 float sharp_ratio [RK_SHARP_V4_MAX_ISO_NUM]; 114 short hf_clip [RK_SHARP_V4_MAX_ISO_NUM][RK_SHARP_V4_LUMA_POINT_NUM]; 115 float bf_gain [RK_SHARP_V4_MAX_ISO_NUM]; 116 float bf_add [RK_SHARP_V4_MAX_ISO_NUM]; 117 float bf_ratio [RK_SHARP_V4_MAX_ISO_NUM]; 118 short local_sharp_strength [RK_SHARP_V4_MAX_ISO_NUM][RK_SHARP_V4_LUMA_POINT_NUM]; 119 120 float prefilter_coeff[RK_SHARP_V4_MAX_ISO_NUM][3]; 121 float GaussianFilter_coeff [RK_SHARP_V4_MAX_ISO_NUM][6]; 122 float hfBilateralFilter_coeff [RK_SHARP_V4_MAX_ISO_NUM][3]; 123 124 float prefilter_sigma[RK_SHARP_V4_MAX_ISO_NUM]; 125 float GaussianFilter_sigma[RK_SHARP_V4_MAX_ISO_NUM]; 126 float GaussianFilter_radius[RK_SHARP_V4_MAX_ISO_NUM]; 127 float hfBilateralFilter_sigma[RK_SHARP_V4_MAX_ISO_NUM]; 128 129 130 } RK_SHARP_Params_V4_t; 131 132 #if 0 133 typedef struct RK_SHARP_Params_V4_Select_s 134 { 135 int enable; 136 int kernel_sigma_enable; 137 138 short luma_point [RK_SHARP_V4_LUMA_POINT_NUM]; 139 short luma_sigma [RK_SHARP_V4_LUMA_POINT_NUM]; 140 float pbf_gain ; 141 float pbf_add ; 142 float pbf_ratio ; 143 float gaus_ratio ; 144 float sharp_ratio ; 145 short hf_clip [RK_SHARP_V4_LUMA_POINT_NUM]; 146 float bf_gain ; 147 float bf_add ; 148 float bf_ratio ; 149 short local_sharp_strength [RK_SHARP_V4_LUMA_POINT_NUM]; 150 151 float prefilter_coeff[RK_SHARPV4_PBF_DIAM * RK_SHARPV4_PBF_DIAM]; 152 float GaussianFilter_coeff [RK_SHARPV4_RF_DIAM * RK_SHARPV4_RF_DIAM]; 153 float hfBilateralFilter_coeff [RK_SHARPV4_BF_DIAM * RK_SHARPV4_BF_DIAM]; 154 155 float prefilter_sigma; 156 float GaussianFilter_sigma; 157 float GaussianFilter_radius; 158 float hfBilateralFilter_sigma; 159 160 } RK_SHARP_Params_V4_Select_t; 161 #endif 162 163 typedef struct Asharp_Manual_Attr_V4_s 164 { 165 RK_SHARP_Params_V4_Select_t stSelect; 166 167 RK_SHARP_Fix_V4_t stFix; 168 169 } Asharp_Manual_Attr_V4_t; 170 171 typedef struct Asharp_Auto_Attr_V4_s 172 { 173 //all ISO params and select param 174 175 RK_SHARP_Params_V4_t stParams; 176 RK_SHARP_Params_V4_Select_t stSelect; 177 178 } Asharp_Auto_Attr_V4_t; 179 180 typedef struct Asharp_ProcResult_V4_s { 181 int sharpEn; 182 183 //for sw simultaion 184 //RK_SHARP_Params_V4_Select_t stSelect; 185 186 //for hw register 187 RK_SHARP_Fix_V4_t* stFix; 188 } Asharp_ProcResult_V4_t; 189 190 191 typedef struct Asharp_Config_V4_s { 192 Asharp4_State_t eState; 193 Asharp4_OPMode_t eMode; 194 int rawHeight; 195 int rawWidth; 196 } Asharp_Config_V4_t; 197 198 199 typedef struct rk_aiq_sharp_attrib_v4_s { 200 rk_aiq_uapi_sync_t sync; 201 202 Asharp4_OPMode_t eMode; 203 Asharp_Auto_Attr_V4_t stAuto; 204 Asharp_Manual_Attr_V4_t stManual; 205 } rk_aiq_sharp_attrib_v4_t; 206 207 208 typedef struct rk_aiq_sharp_strength_v4_s { 209 rk_aiq_uapi_sync_t sync; 210 211 float percent; 212 bool strength_enable; 213 } rk_aiq_sharp_strength_v4_t; 214 215 216 217 //calibdb 218 219 220 RKAIQ_END_DECLARE 221 222 #endif 223 224