1
2 #include "rk_aiq_aynr_algo_ynr_v2.h"
3
4 RKAIQ_BEGIN_DECLARE
5
6
ynr_get_mode_by_name_V2(struct list_head * pCalibdbList,char * name,Calibdb_Ynr_V2_t ** ppProfile)7 Aynr_result_t ynr_get_mode_by_name_V2(struct list_head* pCalibdbList, char *name, Calibdb_Ynr_V2_t** ppProfile)
8 {
9 int i = 0;
10 Aynr_result_t res = AYNR_RET_SUCCESS;
11
12 if(pCalibdbList == NULL) {
13 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
14 return AYNR_RET_NULL_POINTER;
15 }
16
17 if(name == NULL) {
18 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
19 return AYNR_RET_NULL_POINTER;
20 }
21
22 if(ppProfile == NULL) {
23 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
24 return AYNR_RET_NULL_POINTER;
25 }
26
27 #if 1
28 *ppProfile = NULL;
29 struct list_head* p;
30 p = pCalibdbList->next;
31 while (p != pCalibdbList)
32 {
33 Calibdb_Ynr_V2_t* pProfile = container_of(p, Calibdb_Ynr_V2_t, listItem);
34 LOGD_ANR("%s:%d %s %p \n",
35 __FUNCTION__, __LINE__, pProfile->modeName, p);
36 if (!strncmp(pProfile->modeName, name, sizeof(pProfile->modeName))) {
37 *ppProfile = pProfile;
38 return res;
39 }
40 p = p->next;
41 }
42
43 Calibdb_Ynr_V2_t* pProfile = container_of(pCalibdbList->next, Calibdb_Ynr_V2_t, listItem);
44 *ppProfile = pProfile;
45 #else
46
47
48 #endif
49
50 return res;
51
52 }
53
54
ynr_get_setting_by_name_V2(struct list_head * pSettingList,char * name,Calibdb_Ynr_params_V2_t ** ppSetting)55 Aynr_result_t ynr_get_setting_by_name_V2(struct list_head *pSettingList, char *name, Calibdb_Ynr_params_V2_t** ppSetting)
56 {
57 int i = 0;
58 Aynr_result_t res = AYNR_RET_SUCCESS;
59
60 if(pSettingList == NULL) {
61 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
62 return AYNR_RET_NULL_POINTER;
63 }
64
65 if(name == NULL) {
66 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
67 return AYNR_RET_NULL_POINTER;
68 }
69
70 if(ppSetting == NULL) {
71 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
72 return AYNR_RET_NULL_POINTER;
73 }
74
75 *ppSetting = NULL;
76
77 struct list_head* p;
78 p = pSettingList->next;
79 while (p != pSettingList)
80 {
81 Calibdb_Ynr_params_V2_t* pSetting = container_of(p, Calibdb_Ynr_params_V2_t, listItem);
82 LOGD_ANR("%s:%d: %s %p ",
83 __FUNCTION__, __LINE__, pSetting->snr_mode, p);
84 if (!strncmp(pSetting->snr_mode, name, sizeof(pSetting->snr_mode))) {
85 *ppSetting = pSetting;
86 return res;
87 }
88 p = p->next;
89 }
90
91 Calibdb_Ynr_params_V2_t* pSetting = container_of(pSettingList->next, Calibdb_Ynr_params_V2_t, listItem);
92 *ppSetting = pSetting;
93 return res;
94 }
95
ynr_config_setting_param_V2(RK_YNR_Params_V2_t * pParams,struct list_head * pCalibdbList,char * param_mode,char * snr_name)96 Aynr_result_t ynr_config_setting_param_V2(RK_YNR_Params_V2_t *pParams, struct list_head *pCalibdbList, char* param_mode, char * snr_name)
97 {
98 Aynr_result_t res = AYNR_RET_SUCCESS;
99 Calibdb_Ynr_V2_t *pProfile;
100 Calibdb_Ynr_params_V2_t *pCalibParms;
101
102 if(pParams == NULL) {
103 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
104 return AYNR_RET_NULL_POINTER;
105 }
106
107 if(pCalibdbList == NULL) {
108 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
109 return AYNR_RET_NULL_POINTER;
110 }
111
112 if(param_mode == NULL) {
113 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
114 return AYNR_RET_NULL_POINTER;
115 }
116
117 if(snr_name == NULL) {
118 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
119 return AYNR_RET_NULL_POINTER;
120 }
121
122 res = ynr_get_mode_by_name_V2(pCalibdbList, param_mode, &pProfile);
123 if(res != AYNR_RET_SUCCESS) {
124 LOGW_ANR("%s(%d): error!!! can't find mode name in iq files, use 0 instead\n", __FUNCTION__, __LINE__);
125 }
126
127 res = ynr_get_setting_by_name_V2(&pProfile->listHead, snr_name, &pCalibParms);
128 if(res != AYNR_RET_SUCCESS) {
129 LOGW_ANR("%s(%d): error!!! can't find setting in iq files, use 0 instead\n", __FUNCTION__, __LINE__);
130 }
131
132 res = ynr_init_params_V2(pParams, pCalibParms);
133 pParams->enable = pProfile->enable;
134 return res;
135
136 }
ynr_init_params_V2(RK_YNR_Params_V2_t * pYnrParams,Calibdb_Ynr_params_V2_t * pCalibParms)137 Aynr_result_t ynr_init_params_V2(RK_YNR_Params_V2_t *pYnrParams, Calibdb_Ynr_params_V2_t* pCalibParms)
138 {
139 Aynr_result_t res = AYNR_RET_SUCCESS;
140 int i = 0;
141 int j = 0;
142 short isoCurveSectValue;
143 short isoCurveSectValue1;
144 float ave1, ave2, ave3, ave4;
145 int bit_calib = 12;
146 int bit_proc;
147 int bit_shift;
148
149 if(pYnrParams == NULL) {
150 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
151 return AYNR_RET_NULL_POINTER;
152 }
153
154 if(pCalibParms == NULL) {
155 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
156 return AYNR_RET_NULL_POINTER;
157 }
158
159 bit_proc = YNR_V2_SIGMA_BITS; // for V3, YNR_SIGMA_BITS = 10
160 bit_shift = bit_calib - bit_proc;
161
162 isoCurveSectValue = (1 << (bit_calib - YNR_V2_ISO_CURVE_POINT_BIT));
163 isoCurveSectValue1 = (1 << bit_calib);
164
165 for(j = 0; j < RK_YNR_V2_MAX_ISO_NUM; j++) {
166 pYnrParams->iso[j] = pCalibParms->iso[j];
167 pYnrParams->arYnrParamsISO[j].ciISO_V2[0] = pCalibParms->ciISO_V2[0][j];
168 pYnrParams->arYnrParamsISO[j].ciISO_V2[1] = pCalibParms->ciISO_V2[1][j];
169
170 // get noise sigma sample data at [0, 64, 128, ... , 1024]
171 for (i = 0; i < YNR_V2_ISO_CURVE_POINT_NUM; i++) {
172 if (i == (YNR_V2_ISO_CURVE_POINT_NUM - 1)) {
173 ave1 = (float)isoCurveSectValue1;
174 } else {
175 ave1 = (float)(i * isoCurveSectValue);
176 }
177 pYnrParams->arYnrParamsISO[j].lumaPoints_V2[i] = (short)ave1;
178 ave2 = ave1 * ave1;
179 ave3 = ave2 * ave1;
180 ave4 = ave3 * ave1;
181 pYnrParams->arYnrParamsISO[j].noiseSigma_V2[i] = pCalibParms->sigmaCurve[j][0] * ave4
182 + pCalibParms->sigmaCurve[j][1] * ave3
183 + pCalibParms->sigmaCurve[j][2] * ave2
184 + pCalibParms->sigmaCurve[j][3] * ave1
185 + pCalibParms->sigmaCurve[j][4];
186
187 if (pYnrParams->arYnrParamsISO[j].noiseSigma_V2[i] < 0) {
188 pYnrParams->arYnrParamsISO[j].noiseSigma_V2[i] = 0;
189 }
190
191 if (bit_shift > 0) {
192 pYnrParams->arYnrParamsISO[j].lumaPoints_V2[i] >>= bit_shift;
193 } else {
194 pYnrParams->arYnrParamsISO[j].lumaPoints_V2[i] <<= ABS(bit_shift);
195 }
196 }
197
198 for(i = 0; i < 17; i++) {
199 pYnrParams->arYnrParamsISO[j].ynr_rnr_strength_V2[i] = pCalibParms->ynr_rnr_strength_V2[j][i];
200 }
201
202 pYnrParams->arYnrParamsISO[j].ynr_bft3x3_bypass_V2 = pCalibParms->ynr_bft3x3_bypass_V2[j];
203 pYnrParams->arYnrParamsISO[j].ynr_lbft5x5_bypass_V2 = pCalibParms->ynr_lbft5x5_bypass_V2[j];
204 pYnrParams->arYnrParamsISO[j].ynr_lgft3x3_bypass_V2 = pCalibParms->ynr_lgft3x3_bypass_V2[j];
205 pYnrParams->arYnrParamsISO[j].ynr_flt1x1_bypass_V2 = pCalibParms->ynr_flt1x1_bypass_V2[j];
206 pYnrParams->arYnrParamsISO[j].ynr_sft5x5_bypass_V2 = pCalibParms->ynr_sft5x5_bypass_V2[j];
207
208 pYnrParams->arYnrParamsISO[j].ynr_low_bf_V2[0] = pCalibParms->ynr_low_bf_V2[0][j];
209 pYnrParams->arYnrParamsISO[j].ynr_low_bf_V2[1] = pCalibParms->ynr_low_bf_V2[1][j];
210 pYnrParams->arYnrParamsISO[j].ynr_low_thred_adj_V2 = pCalibParms->ynr_low_thred_adj_V2[j];
211 pYnrParams->arYnrParamsISO[j].ynr_low_peak_supress_V2 = pCalibParms->ynr_low_peak_supress_V2[j];
212 pYnrParams->arYnrParamsISO[j].ynr_low_edge_adj_thresh_V2 = pCalibParms->ynr_low_edge_adj_thresh_V2[j];
213 pYnrParams->arYnrParamsISO[j].ynr_low_center_weight_V2 = pCalibParms->ynr_low_center_weight_V2[j];
214 pYnrParams->arYnrParamsISO[j].ynr_low_dist_adj_V2 = pCalibParms->ynr_low_dist_adj_V2[j];
215 pYnrParams->arYnrParamsISO[j].ynr_low_weight_V2 = pCalibParms->ynr_low_weight_V2[j];
216 pYnrParams->arYnrParamsISO[j].ynr_low_filt1_strength_V2 = pCalibParms->ynr_low_filt_strength_V2[0][j];
217 pYnrParams->arYnrParamsISO[j].ynr_low_filt2_strength_V2 = pCalibParms->ynr_low_filt_strength_V2[1][j];
218 pYnrParams->arYnrParamsISO[j].ynr_low_bi_weight_V2 = pCalibParms->ynr_low_bi_weight_V2[j];
219
220 pYnrParams->arYnrParamsISO[j].ynr_base_filter_weight1_V2 = pCalibParms->ynr_base_filter_weight_V2[0][j];
221 pYnrParams->arYnrParamsISO[j].ynr_base_filter_weight2_V2 = pCalibParms->ynr_base_filter_weight_V2[1][j];
222 pYnrParams->arYnrParamsISO[j].ynr_base_filter_weight3_V2 = pCalibParms->ynr_base_filter_weight_V2[2][j];
223 pYnrParams->arYnrParamsISO[j].ynr_high_thred_adj_V2 = pCalibParms->ynr_high_thred_adj_V2[j];
224 pYnrParams->arYnrParamsISO[j].ynr_high_weight_V2 = pCalibParms->ynr_high_weight_V2[j];
225 for(i = 0; i < 8; i++) {
226 pYnrParams->arYnrParamsISO[j].ynr_direction_weight_V2[i] = pCalibParms->ynr_direction_weight_V2[j][i];
227 }
228 pYnrParams->arYnrParamsISO[j].ynr_hi_min_adj_V2 = pCalibParms->ynr_hi_min_adj_V2[j];
229 pYnrParams->arYnrParamsISO[j].ynr_hi_edge_thed_V2 = pCalibParms->ynr_hi_edge_thed_V2[j];
230
231 }
232
233
234 return res;
235 }
236
237
ynr_select_params_by_ISO_V2(RK_YNR_Params_V2_t * pParams,RK_YNR_Params_V2_Select_t * pSelect,Aynr_ExpInfo_t * pExpInfo)238 Aynr_result_t ynr_select_params_by_ISO_V2(RK_YNR_Params_V2_t *pParams, RK_YNR_Params_V2_Select_t *pSelect, Aynr_ExpInfo_t *pExpInfo)
239 {
240 short multBit;
241 float ratio = 0.0f;
242 int iso = 50;
243 RK_YNR_Params_V2_Select_t *pParamHi = NULL;
244 RK_YNR_Params_V2_Select_t *pParamLo = NULL;
245 RK_YNR_Params_V2_Select_t* pParamTmp = NULL;
246
247
248 Aynr_result_t res = AYNR_RET_SUCCESS;
249
250 if(pParams == NULL) {
251 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
252 return AYNR_RET_NULL_POINTER;
253 }
254
255 if(pSelect == NULL) {
256 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
257 return AYNR_RET_NULL_POINTER;
258 }
259
260 if(pExpInfo == NULL) {
261 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
262 return AYNR_RET_NULL_POINTER;
263 }
264
265 iso = pExpInfo->arIso[pExpInfo->hdr_mode];
266
267 // choose integer type data
268 int cur_iso_idx = 0;
269 int idx = 0;
270 for (idx = 0; idx < RK_YNR_V2_MAX_ISO_NUM; idx++) {
271 if (iso < pParams->iso[idx]) {
272 if (idx == 0) {
273 cur_iso_idx = 0;
274 break;
275 } else {
276 int dist1 = iso - pParams->iso[idx - 1];
277 int dist2 = pParams->iso[idx] - iso;
278 cur_iso_idx = (dist1 > dist2) ? (idx) : (idx - 1);
279 break;
280 }
281 }
282 }
283 if (idx == RK_YNR_V2_MAX_ISO_NUM)
284 cur_iso_idx = RK_YNR_V2_MAX_ISO_NUM - 1;
285
286
287 pParamTmp = &pParams->arYnrParamsISO[cur_iso_idx];
288
289 pSelect->enable = pParams->enable;
290 pSelect->ynr_bft3x3_bypass_V2 = pParamTmp->ynr_bft3x3_bypass_V2;
291 pSelect->ynr_lbft5x5_bypass_V2 = pParamTmp->ynr_lbft5x5_bypass_V2;
292 pSelect->ynr_lgft3x3_bypass_V2 = pParamTmp->ynr_lgft3x3_bypass_V2;
293 pSelect->ynr_flt1x1_bypass_V2 = pParamTmp->ynr_flt1x1_bypass_V2;
294 pSelect->ynr_sft5x5_bypass_V2 = pParamTmp->ynr_sft5x5_bypass_V2;
295
296
297 int iso_div = 50;
298 int lowIso = 50;
299 int highIso = 50;
300 int minIso = 50;
301 int maxIso = 50;
302
303 for(int i = 0; i < RK_YNR_V2_MAX_ISO_NUM - 1; i++) {
304 #ifndef RK_SIMULATOR_HW
305 lowIso = pParams->iso[i];
306 highIso = pParams->iso[i + 1];
307 #else
308 lowIso = iso_div * (1 << i);
309 highIso = iso_div * (1 << (i + 1));
310 #endif
311 if(iso >= lowIso && iso <= highIso) {
312 ratio = (iso - lowIso ) / (float)(highIso - lowIso);
313 pParamLo = &pParams->arYnrParamsISO[i];
314 pParamHi = &pParams->arYnrParamsISO[i + 1];
315 break;
316 }
317 }
318
319 #ifndef RK_SIMULATOR_HW
320 minIso = pParams->iso[0];
321 maxIso = pParams->iso[RK_YNR_V2_MAX_ISO_NUM - 1];
322 #else
323 minIso = iso_div * (1 << 0);
324 maxIso = iso_div * (1 << (RK_YNR_V2_MAX_ISO_NUM - 1));
325 #endif
326
327 if(iso < minIso) {
328 ratio = 0;
329 pParamLo = &pParams->arYnrParamsISO[0];
330 pParamHi = &pParams->arYnrParamsISO[1];
331 }
332
333 if(iso > maxIso) {
334 ratio = 1;
335 pParamLo = &pParams->arYnrParamsISO[RK_YNR_V2_MAX_ISO_NUM - 1];
336 pParamHi = &pParams->arYnrParamsISO[RK_YNR_V2_MAX_ISO_NUM];
337 }
338
339
340 LOGD_ANR("oyyf %s:%d iso:%d low:%d hight:%d ratio:%f iso_index:%d \n", __FUNCTION__, __LINE__,
341 iso, lowIso, highIso, ratio, cur_iso_idx);
342 pSelect->ynr_global_gain_V2 = 16;
343 // get rnr parameters
344 for (int i = 0; i < 17; i++)
345 {
346 pSelect->ynr_rnr_strength_V2[i] = ratio * (pParamHi->ynr_rnr_strength_V2[i] - pParamLo->ynr_rnr_strength_V2[i]) + pParamLo->ynr_rnr_strength_V2[i];
347 }
348
349 // get the parameters for current ISO
350 // ci
351 for (int i = 0; i < 2; i++)
352 {
353 pSelect->ciISO_V2[i] = ratio * (pParamHi->ciISO_V2[i] - pParamLo->ciISO_V2[i]) + pParamLo->ciISO_V2[i];
354 }
355
356 // noise curve
357 for (int i = 0; i < YNR_V2_ISO_CURVE_POINT_NUM; i++)
358 {
359 pSelect->noiseSigma_V2[i] = ratio * (pParamHi->noiseSigma_V2[i] - pParamLo->noiseSigma_V2[i]) + pParamLo->noiseSigma_V2[i];
360 pSelect->lumaPoints_V2[i] = (short)(ratio * (pParamHi->lumaPoints_V2[i] - pParamLo->lumaPoints_V2[i]) + pParamLo->lumaPoints_V2[i]);
361 }
362
363 // lo bf
364 for (int i = 0; i < 2; i++)
365 {
366 pSelect->ynr_low_bf_V2[i] = ratio * (pParamHi->ynr_low_bf_V2[i] - pParamLo->ynr_low_bf_V2[i]) + pParamLo->ynr_low_bf_V2[i];
367 }
368
369 pSelect->ynr_low_thred_adj_V2 = ratio * (pParamHi->ynr_low_thred_adj_V2 - pParamLo->ynr_low_thred_adj_V2) + pParamLo->ynr_low_thred_adj_V2;
370 pSelect->ynr_low_peak_supress_V2 = ratio * (pParamHi->ynr_low_peak_supress_V2 - pParamLo->ynr_low_peak_supress_V2) + pParamLo->ynr_low_peak_supress_V2;
371 pSelect->ynr_low_edge_adj_thresh_V2 = ratio * (pParamHi->ynr_low_edge_adj_thresh_V2 - pParamLo->ynr_low_edge_adj_thresh_V2) + pParamLo->ynr_low_edge_adj_thresh_V2;
372 pSelect->ynr_low_center_weight_V2 = ratio * (pParamHi->ynr_low_center_weight_V2 - pParamLo->ynr_low_center_weight_V2) + pParamLo->ynr_low_center_weight_V2;
373 pSelect->ynr_low_dist_adj_V2 = ratio * (pParamHi->ynr_low_dist_adj_V2 - pParamLo->ynr_low_dist_adj_V2) + pParamLo->ynr_low_dist_adj_V2;
374 pSelect->ynr_low_weight_V2 = ratio * (pParamHi->ynr_low_weight_V2 - pParamLo->ynr_low_weight_V2) + pParamLo->ynr_low_weight_V2;
375
376 pSelect->ynr_low_filt1_strength_V2 = ratio * (pParamHi->ynr_low_filt1_strength_V2 - pParamLo->ynr_low_filt1_strength_V2) + pParamLo->ynr_low_filt1_strength_V2;
377 pSelect->ynr_low_filt2_strength_V2 = ratio * (pParamHi->ynr_low_filt2_strength_V2 - pParamLo->ynr_low_filt2_strength_V2) + pParamLo->ynr_low_filt2_strength_V2;
378
379 pSelect->ynr_low_bi_weight_V2 = ratio * (pParamHi->ynr_low_bi_weight_V2 - pParamLo->ynr_low_bi_weight_V2) + pParamLo->ynr_low_bi_weight_V2;
380
381 // High Freq
382 pSelect->ynr_base_filter_weight1_V2 = ratio * (pParamHi->ynr_base_filter_weight1_V2 - pParamLo->ynr_base_filter_weight1_V2) + pParamLo->ynr_base_filter_weight1_V2;
383 pSelect->ynr_base_filter_weight2_V2 = ratio * (pParamHi->ynr_base_filter_weight2_V2 - pParamLo->ynr_base_filter_weight2_V2) + pParamLo->ynr_base_filter_weight2_V2;
384 pSelect->ynr_base_filter_weight3_V2 = ratio * (pParamHi->ynr_base_filter_weight3_V2 - pParamLo->ynr_base_filter_weight3_V2) + pParamLo->ynr_base_filter_weight3_V2;
385
386
387 pSelect->ynr_high_thred_adj_V2 = ratio * (pParamHi->ynr_high_thred_adj_V2 - pParamLo->ynr_high_thred_adj_V2) + pParamLo->ynr_high_thred_adj_V2;
388 pSelect->ynr_high_weight_V2 = ratio * (pParamHi->ynr_high_weight_V2 - pParamLo->ynr_high_weight_V2) + pParamLo->ynr_high_weight_V2;
389
390 for (int i = 0; i < 8; i++)
391 {
392 pSelect->ynr_direction_weight_V2[i] = ratio * (pParamHi->ynr_direction_weight_V2[i] - pParamLo->ynr_direction_weight_V2[i]) + pParamLo->ynr_direction_weight_V2[i];
393 }
394 pSelect->ynr_hi_min_adj_V2 = ratio * (pParamHi->ynr_hi_min_adj_V2 - pParamLo->ynr_hi_min_adj_V2) + pParamLo->ynr_hi_min_adj_V2;
395 pSelect->ynr_hi_edge_thed_V2 = ratio * (pParamHi->ynr_hi_edge_thed_V2 - pParamLo->ynr_hi_edge_thed_V2) + pParamLo->ynr_hi_edge_thed_V2;
396
397 return res;
398 }
399
ynr_fix_transfer_V2(RK_YNR_Params_V2_Select_t * pSelect,RK_YNR_Fix_V2_t * pFix,float fStrength,Aynr_ExpInfo_t * pExpInfo)400 Aynr_result_t ynr_fix_transfer_V2(RK_YNR_Params_V2_Select_t* pSelect, RK_YNR_Fix_V2_t *pFix, float fStrength, Aynr_ExpInfo_t *pExpInfo)
401 {
402 LOGI_ANR("%s:(%d) enter \n", __FUNCTION__, __LINE__);
403
404 Aynr_result_t res = AYNR_RET_SUCCESS;
405 int w0, w1, w2;
406 int tmp;
407
408 if(pSelect == NULL) {
409 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
410 return AYNR_RET_NULL_POINTER;
411 }
412
413 if(pFix == NULL) {
414 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
415 return AYNR_RET_NULL_POINTER;
416 }
417
418 if(pExpInfo == NULL) {
419 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
420 return AYNR_RET_NULL_POINTER;
421 }
422
423 LOGD_ANR("%s:%d strength:%f raw:width:%d height:%d\n",
424 __FUNCTION__, __LINE__,
425 fStrength, pExpInfo->rawHeight, pExpInfo->rawWidth);
426
427 if(fStrength <= 0.0) {
428 fStrength = 0.000001;
429 }
430
431 // YNR_2700_GLOBAL_CTRL (0x0000)
432 pFix->ynr_debug_en = 0;
433 pFix->ynr_gate_dis = 0;
434 pFix->ynr_thumb_mix_cur_en = 0;
435 pFix->ynr_global_gain_alpha = 8;
436 pFix->ynr_global_gain = pSelect->ynr_global_gain_V2;
437 pFix->ynr_flt1x1_bypass_sel = 0;
438 pFix->ynr_sft5x5_bypass = pSelect->ynr_sft5x5_bypass_V2;
439 pFix->ynr_flt1x1_bypass = pSelect->ynr_flt1x1_bypass_V2;
440 pFix->ynr_lgft3x3_bypass = pSelect->ynr_lgft3x3_bypass_V2;
441 pFix->ynr_lbft5x5_bypass = pSelect->ynr_lbft5x5_bypass_V2;
442 pFix->ynr_bft3x3_bypass = pSelect->ynr_bft3x3_bypass_V2;
443 pFix->ynr_en = pSelect->enable;
444
445 // YNR_2700_RNR_MAX_R (0x0004)
446 int rows = pExpInfo->rawHeight; //raw height
447 int cols = pExpInfo->rawWidth; //raw width
448 float r_sq_inv = 16.0f / (cols * cols + rows * rows); // divide 2
449 float r_sq_inv_log = LOG2(r_sq_inv);
450 int E = abs(ceil(r_sq_inv_log));
451 int M = ROUND_F((pow(2, r_sq_inv_log + E)) * 256);
452 tmp = (M << 5) + E; // check: (M/256)/(1<<E) = r_sq_inv
453 pFix->ynr_rnr_max_r = CLIP(tmp, 0, 0x3fff);
454
455 // YNR_2700_LOWNR_CTRL0 (0x0010)
456 tmp = (int)(1.0f / pSelect->ynr_low_bf_V2[1] / fStrength * (1 << 9));
457 pFix->ynr_low_bf_inv[1] = CLIP(tmp, 0, 0x3fff);
458 tmp = (int)(1.0f / pSelect->ynr_low_bf_V2[0] / fStrength * (1 << 9));
459 pFix->ynr_low_bf_inv[0] = CLIP(tmp, 0, 0x3fff);
460
461
462 // YNR_2700_LOWNR_CTRL1 (0x0014)
463 tmp = (int)(pSelect->ynr_low_peak_supress_V2 / fStrength * (1 << 7));
464 pFix->ynr_low_peak_supress = CLIP(tmp, 0, 0x80);
465 tmp = (int)(pSelect->ynr_low_thred_adj_V2 * (1 << 6));
466 pFix->ynr_low_thred_adj = CLIP(tmp, 0, 0x7ff);
467
468 // YNR_2700_LOWNR_CTRL2 (0x0018)
469 tmp = (int)(pSelect->ynr_low_dist_adj_V2 * (1 << 2));
470 pFix->ynr_low_dist_adj = CLIP(tmp, 0, 0x1ff);
471 tmp = (int)(pSelect->ynr_low_edge_adj_thresh_V2);
472 pFix->ynr_low_edge_adj_thresh = CLIP(tmp, 0, 0x3ff);
473
474
475 // YNR_2700_LOWNR_CTRL3 (0x001c)
476 tmp = (int)(pSelect->ynr_low_bi_weight_V2 * fStrength * (1 << 7));
477 pFix->ynr_low_bi_weight = CLIP(tmp, 0, 0x80);
478 tmp = (int)(pSelect->ynr_low_weight_V2 * fStrength * (1 << 7));
479 pFix->ynr_low_weight = CLIP(tmp, 0, 0x80);
480 tmp = (int)(pSelect->ynr_low_center_weight_V2 / fStrength * (1 << 10));
481 pFix->ynr_low_center_weight = CLIP(tmp, 0, 0x400);
482
483 // YNR_2700_HIGHNR_CTRL0 (0x0020)
484 tmp = (int)(pSelect->ynr_hi_min_adj_V2 / fStrength * (1 << 6));
485 pFix->ynr_hi_min_adj = CLIP(tmp, 0, 0x3f);
486 tmp = (int)(pSelect->ynr_high_thred_adj_V2 * fStrength * (1 << 6));
487 pFix->ynr_high_thred_adj = CLIP(tmp, 0, 0x7ff);
488
489 // YNR_2700_HIGHNR_CTRL1 (0x0024)
490 tmp = (1 << 7) - (int)(pSelect->ynr_high_weight_V2 * fStrength * (1 << 7));
491 pFix->ynr_high_retain_weight = CLIP(tmp, 0, 0x80);
492 tmp = (int)(pSelect->ynr_hi_edge_thed_V2 / fStrength);
493 pFix->ynr_hi_edge_thed = CLIP(tmp, 0, 0xff);
494
495 // YNR_2700_HIGHNR_BASE_FILTER_WEIGHT (0x0028)
496 w2 = int(pSelect->ynr_base_filter_weight3_V2 * 64 / 2 + 0.5);
497 w1 = int(pSelect->ynr_base_filter_weight2_V2 * 64 / 2 + 0.5);
498 w0 = 64 - w1 * 2 - w2 * 2;
499 pFix->ynr_base_filter_weight[0] = CLIP(w0, 0, 0x40);
500 pFix->ynr_base_filter_weight[1] = CLIP(w1, 0, 0x1f);
501 pFix->ynr_base_filter_weight[2] = CLIP(w2, 0, 0xf);
502
503 // YNR_2700_GAUSS1_COEFF (0x0030)
504 float filter1_sigma = pSelect->ynr_low_filt1_strength_V2;
505 float filt1_coeff1 = exp(-1 / (2 * filter1_sigma * filter1_sigma));
506 float filt1_coeff0 = filt1_coeff1 * filt1_coeff1;
507 float coeff1_sum = 1 + 4 * filt1_coeff1 + 4 * filt1_coeff0;
508 w0 = int(filt1_coeff0 / coeff1_sum * 256 + 0.5);
509 w1 = int(filt1_coeff1 / coeff1_sum * 256 + 0.5);
510 w2 = 256 - w0 * 4 - w1 * 4;
511 pFix->ynr_low_gauss1_coeff[0] = CLIP(w0, 0, 0x3f);
512 pFix->ynr_low_gauss1_coeff[1] = CLIP(w1, 0, 0x3f);
513 pFix->ynr_low_gauss1_coeff[2] = CLIP(w2, 0, 0x100);
514
515 // YNR_2700_GAUSS2_COEFF (0x0034)
516 float filter2_sigma = pSelect->ynr_low_filt2_strength_V2;
517 float filt2_coeff1 = exp(-1 / (2 * filter2_sigma * filter2_sigma));
518 float filt2_coeff0 = filt2_coeff1 * filt2_coeff1;
519 float coeff2_sum = 1 + 4 * filt2_coeff1 + 4 * filt2_coeff0;
520 w0 = int(filt2_coeff0 / coeff2_sum * 256 + 0.5);
521 w1 = int(filt2_coeff1 / coeff2_sum * 256 + 0.5);
522 w2 = 256 - w0 * 4 - w1 * 4;
523 pFix->ynr_low_gauss2_coeff[0] = CLIP(w0, 0, 0x3f);
524 pFix->ynr_low_gauss2_coeff[1] = CLIP(w1, 0, 0x3f);
525 pFix->ynr_low_gauss2_coeff[2] = CLIP(w2, 0, 0x100);
526
527
528 // YNR_2700_DIRECTION_W_0_3 (0x0038 - 0x003c)
529 for (int i = 0; i < 8; i++) {
530 tmp = (int)(pSelect->ynr_direction_weight_V2[i] * (1 << 4));
531 pFix->ynr_direction_weight[i] = CLIP(tmp, 0, 0x10);
532 }
533
534 // YNR_2700_SGM_DX_0_1 (0x0040 - 0x0060)
535 // YNR_2700_LSGM_Y_0_1 (0x0070- 0x0090)
536 // YNR_2700_HSGM_Y_0_1 (0x00a0- 0x00c0)
537 for (int i = 0; i < YNR_V2_ISO_CURVE_POINT_NUM; i++) {
538 tmp = pSelect->lumaPoints_V2[i];
539 pFix->ynr_luma_points_x[i] = CLIP(tmp, 0, 0x400);
540 tmp = (int)(pSelect->noiseSigma_V2[i] * pSelect->ciISO_V2[0] * (1 << YNR_V2_NOISE_SIGMA_FIX_BIT));
541 pFix->ynr_lsgm_y[i] = CLIP(tmp, 0, 0xfff);
542 tmp = (int)(pSelect->noiseSigma_V2[i] * pSelect->ciISO_V2[1] * (1 << YNR_V2_NOISE_SIGMA_FIX_BIT));
543 pFix->ynr_hsgm_y[i] = CLIP(tmp, 0, 0xfff);
544 }
545
546 // YNR_2700_RNR_STRENGTH03 (0x00d0- 0x00e0)
547 for (int i = 0; i < 17; i++) {
548 tmp = int(pSelect->ynr_rnr_strength_V2[i] * 16);
549 pFix->ynr_rnr_strength[i] = CLIP(tmp, 0, 0xff);
550 }
551
552 ynr_fix_printf_V2(pFix);
553 return res;
554 }
555
ynr_fix_printf_V2(RK_YNR_Fix_V2_t * pFix)556 Aynr_result_t ynr_fix_printf_V2(RK_YNR_Fix_V2_t * pFix)
557 {
558 LOGD_ANR("%s:(%d) enter \n", __FUNCTION__, __LINE__);
559
560 Aynr_result_t res = AYNR_RET_SUCCESS;
561
562 if(pFix == NULL) {
563 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
564 return AYNR_RET_NULL_POINTER;
565 }
566
567
568 // YNR_2700_GLOBAL_CTRL (0x0000)
569 LOGD_ANR("(0x0000) ynr_global_gain_alpha:0x%x ynr_global_gain:0x%x \n ynr_flt1x1_bypass_sel:0x%x ynr_sft5x5_bypass:0x%x \n ynr_flt1x1_bypass:0x%x ynr_lgft3x3_bypass:0x%x \n ynr_lbft5x5_bypass:0x%x ynr_bft3x3_bypass:0x%x \n ynr_en:0x%x\n",
570 pFix->ynr_global_gain_alpha,
571 pFix->ynr_global_gain,
572 pFix->ynr_flt1x1_bypass_sel,
573 pFix->ynr_sft5x5_bypass,
574 pFix->ynr_flt1x1_bypass,
575 pFix->ynr_lgft3x3_bypass,
576 pFix->ynr_lbft5x5_bypass,
577 pFix->ynr_bft3x3_bypass,
578 pFix->ynr_en);
579
580
581 // YNR_2700_RNR_MAX_R (0x0004)
582 LOGD_ANR("(0x0004) ynr_rnr_max_r:0x%x \n",
583 pFix->ynr_rnr_max_r);
584
585 // YNR_2700_LOWNR_CTRL0 (0x0010)
586 for(int i = 0; i < 2; i++) {
587 LOGD_ANR("(0x0010) ynr_low_bf_inv[%d]:0x%x \n",
588 i, pFix->ynr_low_bf_inv[i]);
589 }
590
591 // YNR_2700_LOWNR_CTRL1 (0x0014)
592 LOGD_ANR("(0x0014) ynr_low_peak_supress:0x%x ynr_low_thred_adj:0x%x \n",
593 pFix->ynr_low_peak_supress,
594 pFix->ynr_low_thred_adj);
595
596 // YNR_2700_LOWNR_CTRL2 (0x0018)
597 LOGD_ANR("(0x0018) ynr_low_dist_adj:0x%x ynr_low_edge_adj_thresh:0x%x \n",
598 pFix->ynr_low_dist_adj,
599 pFix->ynr_low_edge_adj_thresh);
600
601 // YNR_2700_LOWNR_CTRL3 (0x001c)
602 LOGD_ANR("(0x001c) ynr_low_bi_weight:0x%x ynr_low_weight:0x%x ynr_low_center_weight:0x%x \n",
603 pFix->ynr_low_bi_weight,
604 pFix->ynr_low_weight,
605 pFix->ynr_low_center_weight);
606
607 // YNR_2700_HIGHNR_CTRL0 (0x0020)
608 LOGD_ANR("(0x0020) ynr_hi_min_adj:0x%x ynr_high_thred_adj:0x%x \n",
609 pFix->ynr_hi_min_adj,
610 pFix->ynr_high_thred_adj);
611
612 // YNR_2700_HIGHNR_CTRL1 (0x0024)
613 LOGD_ANR("(0x0024) ynr_high_retain_weight:0x%x ynr_hi_edge_thed:0x%x \n",
614 pFix->ynr_high_retain_weight,
615 pFix->ynr_hi_edge_thed);
616
617 // YNR_2700_HIGHNR_BASE_FILTER_WEIGHT (0x0028)
618 for(int i = 0; i < 3; i++) {
619 LOGD_ANR("(0x0028) ynr_base_filter_weight[%d]:0x%x \n",
620 i, pFix->ynr_base_filter_weight[i]);
621 }
622
623 // YNR_2700_GAUSS1_COEFF (0x0030)
624 for(int i = 0; i < 3; i++) {
625 LOGD_ANR("(0x0030) ynr_low_gauss1_coeff[%d]:0x%x \n",
626 i, pFix->ynr_low_gauss1_coeff[i]);
627 }
628
629 // YNR_2700_GAUSS2_COEFF (0x0034)
630 for(int i = 0; i < 3; i++) {
631 LOGD_ANR("(0x0034) ynr_low_gauss2_coeff[%d]:0x%x \n",
632 i, pFix->ynr_low_gauss2_coeff[i]);
633 }
634
635 // YNR_2700_DIRECTION_W_0_3 (0x0038 - 0x003c)
636 for(int i = 0; i < 8; i++) {
637 LOGD_ANR("(0x0038- 0x003c) ynr_direction_weight[%d]:0x%x \n",
638 i, pFix->ynr_direction_weight[i]);
639 }
640
641 // YNR_2700_SGM_DX_0_1 (0x0040 - 0x0060)
642 for(int i = 0; i < 17; i++) {
643 LOGD_ANR("(0x0040- 0x0060) ynr_luma_points_x[%d]:0x%x \n",
644 i, pFix->ynr_luma_points_x[i]);
645 }
646
647 // YNR_2700_LSGM_Y_0_1 (0x0070- 0x0090)
648 for(int i = 0; i < 17; i++) {
649 LOGD_ANR("(0x0070- 0x0090) ynr_lsgm_y[%d]:0x%x \n",
650 i, pFix->ynr_lsgm_y[i]);
651 }
652
653 // YNR_2700_HSGM_Y_0_1 (0x00a0- 0x00c0)
654 for(int i = 0; i < 17; i++) {
655 LOGD_ANR("(0x00a0- 0x00c0) ynr_hsgm_y[%d]:0x%x \n",
656 i, pFix->ynr_hsgm_y[i]);
657 }
658
659 // YNR_2700_RNR_STRENGTH03 (0x00d0- 0x00e0)
660 for(int i = 0; i < 17; i++) {
661 LOGD_ANR("(0x00d0- 0x00e0) ynr_rnr_strength[%d]:0x%x \n",
662 i, pFix->ynr_rnr_strength[i]);
663 }
664
665
666 LOGD_ANR("%s:(%d) exit \n", __FUNCTION__, __LINE__);
667
668 return res;
669 }
670
671
672
ynr_get_setting_by_name_json_V2(CalibDbV2_YnrV2_t * pCalibdbV2,char * name,int * calib_idx,int * tuning_idx)673 Aynr_result_t ynr_get_setting_by_name_json_V2(CalibDbV2_YnrV2_t *pCalibdbV2, char *name, int* calib_idx, int* tuning_idx)
674 {
675 int i = 0;
676 Aynr_result_t res = AYNR_RET_SUCCESS;
677
678 if(pCalibdbV2 == NULL || name == NULL
679 || calib_idx == NULL || tuning_idx == NULL) {
680 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
681 return AYNR_RET_NULL_POINTER;
682 }
683
684 for(i = 0; i < pCalibdbV2->TuningPara.Setting_len; i++) {
685 if(strncmp(name, pCalibdbV2->TuningPara.Setting[i].SNR_Mode, strlen(name)*sizeof(char)) == 0) {
686 break;
687 }
688 }
689
690 if(i < pCalibdbV2->TuningPara.Setting_len) {
691 *tuning_idx = i;
692 } else {
693 *tuning_idx = 0;
694 }
695
696 for(i = 0; i < pCalibdbV2->CalibPara.Setting_len; i++) {
697 if(strncmp(name, pCalibdbV2->CalibPara.Setting[i].SNR_Mode, strlen(name)*sizeof(char)) == 0) {
698 break;
699 }
700 }
701
702 if(i < pCalibdbV2->CalibPara.Setting_len) {
703 *calib_idx = i;
704 } else {
705 *calib_idx = 0;
706 }
707
708 LOGD_ANR("%s:%d snr_name:%s snr_idx:%d i:%d \n",
709 __FUNCTION__, __LINE__,
710 name, *calib_idx, i);
711
712 return res;
713 }
714
ynr_init_params_json_V2(RK_YNR_Params_V2_t * pYnrParams,CalibDbV2_YnrV2_t * pCalibdbV2,int calib_idx,int tuning_idx)715 Aynr_result_t ynr_init_params_json_V2(RK_YNR_Params_V2_t *pYnrParams, CalibDbV2_YnrV2_t *pCalibdbV2, int calib_idx, int tuning_idx)
716 {
717 Aynr_result_t res = AYNR_RET_SUCCESS;
718 int i = 0;
719 int j = 0;
720 short isoCurveSectValue;
721 short isoCurveSectValue1;
722 float ave1, ave2, ave3, ave4;
723 int bit_calib = 12;
724 int bit_proc;
725 int bit_shift;
726
727 CalibDbV2_YnrV2_T_ISO_t *pISO = NULL;
728 CalibDbV2_YnrV2_C_ISO_t *pCalibISO = NULL;
729
730 LOGD_ANR("%s(%d): enter\n", __FUNCTION__, __LINE__);
731
732 if(pYnrParams == NULL || pCalibdbV2 == NULL) {
733 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
734 return AYNR_RET_NULL_POINTER;
735 }
736
737 bit_proc = YNR_V2_SIGMA_BITS; // for V3, YNR_SIGMA_BITS = 10
738 bit_shift = bit_calib - bit_proc;
739
740 isoCurveSectValue = (1 << (bit_calib - YNR_V2_ISO_CURVE_POINT_BIT));
741 isoCurveSectValue1 = (1 << bit_calib);
742
743
744 for(j = 0; j < pCalibdbV2->CalibPara.Setting[tuning_idx].Calib_ISO_len && j < RK_YNR_V2_MAX_ISO_NUM ; j++) {
745 pCalibISO = &pCalibdbV2->CalibPara.Setting[tuning_idx].Calib_ISO[j];
746 pYnrParams->iso[j] = pCalibISO->iso;
747
748 // get noise sigma sample data at [0, 64, 128, ... , 1024]
749 for (i = 0; i < YNR_V2_ISO_CURVE_POINT_NUM; i++) {
750 if (i == (YNR_V2_ISO_CURVE_POINT_NUM - 1)) {
751 ave1 = (float)isoCurveSectValue1;
752 } else {
753 ave1 = (float)(i * isoCurveSectValue);
754 }
755 pYnrParams->arYnrParamsISO[j].lumaPoints_V2[i] = (short)ave1;
756 ave2 = ave1 * ave1;
757 ave3 = ave2 * ave1;
758 ave4 = ave3 * ave1;
759 pYnrParams->arYnrParamsISO[j].noiseSigma_V2[i] = pCalibISO->sigma_curve[0] * ave4
760 + pCalibISO->sigma_curve[1] * ave3
761 + pCalibISO->sigma_curve[2] * ave2
762 + pCalibISO->sigma_curve[3] * ave1
763 + pCalibISO->sigma_curve[4];
764
765 if (pYnrParams->arYnrParamsISO[j].noiseSigma_V2[i] < 0) {
766 pYnrParams->arYnrParamsISO[j].noiseSigma_V2[i] = 0;
767 }
768
769 if (bit_shift > 0) {
770 pYnrParams->arYnrParamsISO[j].lumaPoints_V2[i] >>= bit_shift;
771 } else {
772 pYnrParams->arYnrParamsISO[j].lumaPoints_V2[i] <<= ABS(bit_shift);
773 }
774 }
775
776 pYnrParams->arYnrParamsISO[j].ciISO_V2[0] = pCalibISO->ynr_ci_l;
777 pYnrParams->arYnrParamsISO[j].ciISO_V2[1] = pCalibISO->ynr_ci_h;
778 }
779
780 LOGD_ANR(" iso len:%d calib_max:%d\n", pCalibdbV2->TuningPara.Setting[tuning_idx].Tuning_ISO_len, RK_YNR_V2_MAX_ISO_NUM);
781
782 for(j = 0; j < pCalibdbV2->TuningPara.Setting[tuning_idx].Tuning_ISO_len && j < RK_YNR_V2_MAX_ISO_NUM; j++) {
783 pISO = &pCalibdbV2->TuningPara.Setting[tuning_idx].Tuning_ISO[j];
784
785 for(i = 0; i < 17; i++) {
786 pYnrParams->arYnrParamsISO[j].ynr_rnr_strength_V2[i] = pISO->rnr_strength[i];
787 }
788
789 pYnrParams->arYnrParamsISO[j].ynr_bft3x3_bypass_V2 = pISO->ynr_bft3x3_bypass;
790 pYnrParams->arYnrParamsISO[j].ynr_lbft5x5_bypass_V2 = pISO->ynr_lbft5x5_bypass;
791 pYnrParams->arYnrParamsISO[j].ynr_lgft3x3_bypass_V2 = pISO->ynr_lgft3x3_bypass;
792 pYnrParams->arYnrParamsISO[j].ynr_flt1x1_bypass_V2 = pISO->ynr_flt1x1_bypass;
793 pYnrParams->arYnrParamsISO[j].ynr_sft5x5_bypass_V2 = pISO->ynr_sft5x5_bypass;
794
795 pYnrParams->arYnrParamsISO[j].ynr_low_bf_V2[0] = pISO->low_bf_0;
796 pYnrParams->arYnrParamsISO[j].ynr_low_bf_V2[1] = pISO->low_bf_1;
797 pYnrParams->arYnrParamsISO[j].ynr_low_thred_adj_V2 = pISO->low_thred_adj;
798 pYnrParams->arYnrParamsISO[j].ynr_low_peak_supress_V2 = pISO->low_peak_supress;
799 pYnrParams->arYnrParamsISO[j].ynr_low_edge_adj_thresh_V2 = pISO->low_edge_adj_thresh;;
800 pYnrParams->arYnrParamsISO[j].ynr_low_center_weight_V2 = pISO->low_center_weight;
801 pYnrParams->arYnrParamsISO[j].ynr_low_dist_adj_V2 = pISO->low_dist_adj;
802 pYnrParams->arYnrParamsISO[j].ynr_low_weight_V2 = pISO->low_weight;
803 pYnrParams->arYnrParamsISO[j].ynr_low_filt1_strength_V2 = pISO->low_filt_strength_0;
804 pYnrParams->arYnrParamsISO[j].ynr_low_filt2_strength_V2 = pISO->low_filt_strength_1;
805 pYnrParams->arYnrParamsISO[j].ynr_low_bi_weight_V2 = pISO->low_bi_weight;
806
807 pYnrParams->arYnrParamsISO[j].ynr_base_filter_weight1_V2 = pISO->base_filter_weight_0;
808 pYnrParams->arYnrParamsISO[j].ynr_base_filter_weight2_V2 = pISO->base_filter_weight_1;
809 pYnrParams->arYnrParamsISO[j].ynr_base_filter_weight3_V2 = pISO->base_filter_weight_2;
810 pYnrParams->arYnrParamsISO[j].ynr_high_thred_adj_V2 = pISO->high_thred_adj;
811 pYnrParams->arYnrParamsISO[j].ynr_high_weight_V2 = pISO->high_weight;
812 for(i = 0; i < 8; i++) {
813 pYnrParams->arYnrParamsISO[j].ynr_direction_weight_V2[i] = pISO->high_direction_weight[i];
814 }
815 pYnrParams->arYnrParamsISO[j].ynr_hi_min_adj_V2 = pISO->hi_min_adj;
816 pYnrParams->arYnrParamsISO[j].ynr_hi_edge_thed_V2 = pISO->hi_edge_thed;
817
818 }
819
820 LOGD_ANR("%s(%d): exit\n", __FUNCTION__, __LINE__);
821
822 return res;
823 }
824
ynr_config_setting_param_json_V2(RK_YNR_Params_V2_t * pParams,CalibDbV2_YnrV2_t * pCalibdbV2,char * param_mode,char * snr_name)825 Aynr_result_t ynr_config_setting_param_json_V2(RK_YNR_Params_V2_t *pParams, CalibDbV2_YnrV2_t *pCalibdbV2, char* param_mode, char * snr_name)
826 {
827 Aynr_result_t res = AYNR_RET_SUCCESS;
828 int calib_idx = 0;
829 int tuning_idx = 0;
830
831 if(pParams == NULL || pCalibdbV2 == NULL
832 || param_mode == NULL || snr_name == NULL) {
833 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
834 return AYNR_RET_NULL_POINTER;
835 }
836
837 res = ynr_get_setting_by_name_json_V2(pCalibdbV2, snr_name, &calib_idx, &tuning_idx);
838 if(res != AYNR_RET_SUCCESS) {
839 LOGW_ANR("%s(%d): error!!! can't find setting in iq files, use 0 instead\n", __FUNCTION__, __LINE__);
840 }
841
842 res = ynr_init_params_json_V2(pParams, pCalibdbV2, calib_idx, tuning_idx);
843 pParams->enable = pCalibdbV2->TuningPara.enable;
844 return res;
845
846 }
847
848 RKAIQ_END_DECLARE
849
850