1
2 #include "rk_aiq_amfnr_algo_v1.h"
3 #include "rk_aiq_amfnr_algo_itf_v1.h"
4
5 RKAIQ_BEGIN_DECLARE
6
Amfnr_Start_V1(Amfnr_Context_V1_t * pAmfnrCtx)7 Amfnr_Result_V1_t Amfnr_Start_V1(Amfnr_Context_V1_t *pAmfnrCtx)
8 {
9 LOGI_ANR( "%s:enter!\n", __FUNCTION__);
10
11 // initial checks
12 if (pAmfnrCtx == NULL) {
13 return (AMFNR_RET_V1_NULL_POINTER);
14 }
15
16 if ((AMFNR_STATE_V1_RUNNING == pAmfnrCtx->eState)
17 || (AMFNR_STATE_V1_LOCKED == pAmfnrCtx->eState)) {
18 return (AMFNR_RET_V1_FAILURE);
19 }
20
21 pAmfnrCtx->eState = AMFNR_STATE_V1_RUNNING;
22
23 LOGI_ANR( "%s:exit!\n", __FUNCTION__);
24 return (AMFNR_RET_V1_SUCCESS);
25 }
26
27
Amfnr_Stop_V1(Amfnr_Context_V1_t * pAmfnrCtx)28 Amfnr_Result_V1_t Amfnr_Stop_V1(Amfnr_Context_V1_t *pAmfnrCtx)
29 {
30 LOGI_ANR( "%s:enter!\n", __FUNCTION__);
31
32 // initial checks
33 if (pAmfnrCtx == NULL) {
34 return (AMFNR_RET_V1_NULL_POINTER);
35 }
36
37 if (AMFNR_STATE_V1_LOCKED == pAmfnrCtx->eState) {
38 return (AMFNR_RET_V1_FAILURE);
39 }
40
41 pAmfnrCtx->eState = AMFNR_STATE_V1_STOPPED;
42
43 LOGI_ANR( "%s:exit!\n", __FUNCTION__);
44 return (AMFNR_RET_V1_SUCCESS);
45 }
46
47
48 //anr inint
Amfnr_Init_V1(Amfnr_Context_V1_t ** ppAmfnrCtx,CamCalibDbContext_t * pCalibDb)49 Amfnr_Result_V1_t Amfnr_Init_V1(Amfnr_Context_V1_t **ppAmfnrCtx, CamCalibDbContext_t *pCalibDb)
50 {
51 Amfnr_Context_V1_t * pAmfnrCtx;
52
53 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
54
55 pAmfnrCtx = (Amfnr_Context_V1_t *)malloc(sizeof(Amfnr_Context_V1_t));
56 if(pAmfnrCtx == NULL) {
57 LOGE_ANR("%s(%d): malloc fail\n", __FUNCTION__, __LINE__);
58 return AMFNR_RET_V1_NULL_POINTER;
59 }
60
61 memset(pAmfnrCtx, 0x00, sizeof(Amfnr_Context_V1_t));
62
63 //gain state init
64 pAmfnrCtx->stGainState.gain_stat_full_last = -1;
65 pAmfnrCtx->stGainState.gainState = -1;
66 pAmfnrCtx->stGainState.gainState_last = -1;
67 pAmfnrCtx->stGainState.gain_th0[0] = 2.0;
68 pAmfnrCtx->stGainState.gain_th1[0] = 4.0;
69 pAmfnrCtx->stGainState.gain_th0[1] = 32.0;
70 pAmfnrCtx->stGainState.gain_th1[1] = 64.0;
71
72 pAmfnrCtx->fLuma_TF_Strength = 1.0;
73 pAmfnrCtx->fChroma_TF_Strength = 1.0;
74 pAmfnrCtx->refYuvBit = 8;
75
76 pAmfnrCtx->eState = AMFNR_STATE_V1_INITIALIZED;
77 *ppAmfnrCtx = pAmfnrCtx;
78
79 pAmfnrCtx->eMode = AMFNR_OP_MODE_V1_AUTO;
80 pAmfnrCtx->isIQParaUpdate = false;
81 pAmfnrCtx->isGrayMode = false;
82
83 #if AMFNR_USE_XML_FILE_V1
84 //read v1 params from xml
85 pAmfnrCtx->stMfnrCalib =
86 *(CalibDb_MFNR_2_t*)(CALIBDB_GET_MODULE_PTR((void*)pCalibDb, mfnr));
87
88 #endif
89
90 #if RK_SIMULATOR_HW
91 //just for v1 params from html
92
93 #endif
94
95 #if AMFNR_USE_XML_FILE_V1
96 pAmfnrCtx->stExpInfo.snr_mode = 0;
97 pAmfnrCtx->eParamMode = AMFNR_PARAM_MODE_V1_NORMAL;
98 Amfnr_ConfigSettingParam_V1(pAmfnrCtx, pAmfnrCtx->eParamMode, pAmfnrCtx->stExpInfo.snr_mode);
99 #endif
100
101 LOGD_ANR("%s(%d):", __FUNCTION__, __LINE__);
102
103
104 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
105 return AMFNR_RET_V1_SUCCESS;
106 }
107
108
109
110 //anr inint
Amfnr_Init_Json_V1(Amfnr_Context_V1_t ** ppAmfnrCtx,CamCalibDbV2Context_t * pCalibDbV2)111 Amfnr_Result_V1_t Amfnr_Init_Json_V1(Amfnr_Context_V1_t **ppAmfnrCtx, CamCalibDbV2Context_t *pCalibDbV2)
112 {
113 Amfnr_Context_V1_t * pAmfnrCtx;
114
115 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
116
117 pAmfnrCtx = (Amfnr_Context_V1_t *)malloc(sizeof(Amfnr_Context_V1_t));
118 if(pAmfnrCtx == NULL) {
119 LOGE_ANR("%s(%d): malloc fail\n", __FUNCTION__, __LINE__);
120 return AMFNR_RET_V1_NULL_POINTER;
121 }
122
123 memset(pAmfnrCtx, 0x00, sizeof(Amfnr_Context_V1_t));
124
125 //gain state init
126 pAmfnrCtx->stGainState.gain_stat_full_last = -1;
127 pAmfnrCtx->stGainState.gainState = -1;
128 pAmfnrCtx->stGainState.gainState_last = -1;
129 pAmfnrCtx->stGainState.gain_th0[0] = 2.0;
130 pAmfnrCtx->stGainState.gain_th1[0] = 4.0;
131 pAmfnrCtx->stGainState.gain_th0[1] = 32.0;
132 pAmfnrCtx->stGainState.gain_th1[1] = 64.0;
133
134 pAmfnrCtx->fLuma_TF_Strength = 1.0;
135 pAmfnrCtx->fChroma_TF_Strength = 1.0;
136 pAmfnrCtx->refYuvBit = 8;
137
138 pAmfnrCtx->eState = AMFNR_STATE_V1_INITIALIZED;
139 *ppAmfnrCtx = pAmfnrCtx;
140
141 pAmfnrCtx->eMode = AMFNR_OP_MODE_V1_AUTO;
142 pAmfnrCtx->isIQParaUpdate = false;
143 pAmfnrCtx->isGrayMode = false;
144
145 #if AMFNR_USE_JSON_PARA_V1
146 //read v1 params from xml
147 CalibDbV2_MFNR_t* calibv2_mfnr_v1 =
148 (CalibDbV2_MFNR_t*)(CALIBDBV2_GET_MODULE_PTR(pCalibDbV2, mfnr_v1));
149 mfnr_calibdbV2_assign_v1(&pAmfnrCtx->mfnr_v1, calibv2_mfnr_v1);
150
151
152 LOGI_ANR("%s(%d): mode_3to1:%d mfnr version:%s %p\n",
153 __FUNCTION__, __LINE__,
154 pAmfnrCtx->mfnr_mode_3to1,
155 pAmfnrCtx->mfnr_v1.Version,
156 pAmfnrCtx->mfnr_v1.Version);
157 #endif
158
159 #if RK_SIMULATOR_HW
160 //just for v1 params from html
161
162 #endif
163
164 #if AMFNR_USE_JSON_PARA_V1
165 pAmfnrCtx->stExpInfo.snr_mode = 0;
166 pAmfnrCtx->eParamMode = AMFNR_PARAM_MODE_V1_NORMAL;
167 Amfnr_ConfigSettingParam_V1(pAmfnrCtx, pAmfnrCtx->eParamMode, pAmfnrCtx->stExpInfo.snr_mode);
168 #endif
169
170
171
172 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
173 return AMFNR_RET_V1_SUCCESS;
174 }
175
176 //anr release
Amfnr_Release_V1(Amfnr_Context_V1_t * pAmfnrCtx)177 Amfnr_Result_V1_t Amfnr_Release_V1(Amfnr_Context_V1_t *pAmfnrCtx)
178 {
179 Amfnr_Result_V1_t result = AMFNR_RET_V1_SUCCESS;
180 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
181 if(pAmfnrCtx == NULL) {
182 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
183 return AMFNR_RET_V1_NULL_POINTER;
184 }
185
186 result = Amfnr_Stop_V1(pAmfnrCtx);
187 if (result != AMFNR_RET_V1_SUCCESS) {
188 LOGE_ANR( "%s: ANRStop() failed!\n", __FUNCTION__);
189 return (result);
190 }
191
192 // check state
193 if ((AMFNR_STATE_V1_RUNNING == pAmfnrCtx->eState)
194 || (AMFNR_STATE_V1_LOCKED == pAmfnrCtx->eState)) {
195 return (AMFNR_RET_V1_BUSY);
196 }
197
198 #if AMFNR_USE_JSON_PARA_V1
199 mfnr_calibdbV2_free_v1(&pAmfnrCtx->mfnr_v1);
200 #endif
201 memset(pAmfnrCtx, 0x00, sizeof(Amfnr_Context_V1_t));
202 free(pAmfnrCtx);
203
204 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
205 return AMFNR_RET_V1_SUCCESS;
206 }
207
208 //anr config
Amfnr_Prepare_V1(Amfnr_Context_V1_t * pAmfnrCtx,Amfnr_Config_V1_t * pAmfnrConfig)209 Amfnr_Result_V1_t Amfnr_Prepare_V1(Amfnr_Context_V1_t *pAmfnrCtx, Amfnr_Config_V1_t* pAmfnrConfig)
210 {
211 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
212
213 if(pAmfnrCtx == NULL) {
214 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
215 return AMFNR_RET_V1_INVALID_PARM;
216 }
217
218 if(pAmfnrConfig == NULL) {
219 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
220 return AMFNR_RET_V1_INVALID_PARM;
221 }
222
223 if(!!(pAmfnrCtx->prepare_type & RK_AIQ_ALGO_CONFTYPE_UPDATECALIB)) {
224 Amfnr_IQParaUpdate_V1(pAmfnrCtx);
225 }
226
227 Amfnr_Start_V1(pAmfnrCtx);
228
229 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
230 return AMFNR_RET_V1_SUCCESS;
231 }
232
233 //anr reconfig
Amfnr_ReConfig_V1(Amfnr_Context_V1_t * pAmfnrCtx,Amfnr_Config_V1_t * pAmfnrConfig)234 Amfnr_Result_V1_t Amfnr_ReConfig_V1(Amfnr_Context_V1_t *pAmfnrCtx, Amfnr_Config_V1_t* pAmfnrConfig)
235 {
236 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
237 //need todo what?
238
239 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
240 return AMFNR_RET_V1_SUCCESS;
241 }
242
243 //anr reconfig
Amfnr_IQParaUpdate_V1(Amfnr_Context_V1_t * pAmfnrCtx)244 Amfnr_Result_V1_t Amfnr_IQParaUpdate_V1(Amfnr_Context_V1_t *pAmfnrCtx)
245 {
246 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
247 //need todo what?
248
249 if(pAmfnrCtx->isIQParaUpdate) {
250 LOGD_ANR("IQ data reconfig\n");
251 Amfnr_ConfigSettingParam_V1(pAmfnrCtx, pAmfnrCtx->eParamMode, pAmfnrCtx->stExpInfo.snr_mode);
252 pAmfnrCtx->isIQParaUpdate = false;
253 }
254
255 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
256 return AMFNR_RET_V1_SUCCESS;
257 }
258
259
260 //anr preprocess
Amfnr_PreProcess_V1(Amfnr_Context_V1_t * pAmfnrCtx)261 Amfnr_Result_V1_t Amfnr_PreProcess_V1(Amfnr_Context_V1_t *pAmfnrCtx)
262 {
263 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
264 //need todo what?
265
266 Amfnr_IQParaUpdate_V1(pAmfnrCtx);
267
268 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
269 return AMFNR_RET_V1_SUCCESS;
270 }
271
272
Amfnr_GainRatioProcess_V1(Amfnr_GainState_t * pGainState,Amfnr_ExpInfo_V1_t * pExpInfo)273 Amfnr_Result_V1_t Amfnr_GainRatioProcess_V1(Amfnr_GainState_t *pGainState, Amfnr_ExpInfo_V1_t *pExpInfo)
274 {
275 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
276
277 if(pGainState == NULL) {
278 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
279 return AMFNR_RET_V1_INVALID_PARM;
280 }
281
282 if(pExpInfo == NULL) {
283 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
284 return AMFNR_RET_V1_INVALID_PARM;
285 }
286
287 float gain_cur = pExpInfo->arAGain[pExpInfo->hdr_mode] * pExpInfo->arDGain[pExpInfo->hdr_mode];
288 float th[2];
289 float gain_th0[2];
290 float gain_th1[2];
291 for(int i = 0; i < 2; i++) {
292 gain_th0[i] = pGainState->gain_th0[i];
293 gain_th1[i] = pGainState->gain_th1[i];
294 th[i] = pow(2.0, (log2(gain_th0[i]) + log2(gain_th1[i])) / 2);
295 }
296
297 pGainState->gain_cur = gain_cur;
298
299 int gain_stat_full = -1;
300 int gain_stat_full_last = pGainState->gain_stat_full_last;
301 int gain_stat_last = pGainState->gainState_last;
302 int gain_stat_cur = -1;
303 int gain_stat = -1;
304
305 if(gain_cur <= gain_th0[0])
306 {
307 gain_stat_full = 0;
308 gain_stat_cur = 0;
309 }
310 else if(gain_cur <= gain_th1[0] && gain_cur >= gain_th0[0])
311 {
312 gain_stat_full = 1;
313 }
314 else if(gain_cur <= gain_th0[1] && gain_cur >= gain_th1[0])
315 {
316 gain_stat_full = 2;
317 gain_stat_cur = 1;
318 }
319 else if(gain_cur <= gain_th1[1] && gain_cur >= gain_th0[1])
320 {
321 gain_stat_full = 3;
322 }
323 else if(gain_cur >= gain_th1[1])
324 {
325 gain_stat_full = 4;
326 gain_stat_cur = 2;
327 }
328 if(gain_stat_last == -1 || (abs(gain_stat_full - gain_stat_full_last) >= 2 && gain_stat_cur == -1)) {
329 if(gain_cur <= th[0])
330 gain_stat_cur = 0;
331 else if(gain_cur <= th[1])
332 gain_stat_cur = 1;
333 else
334 gain_stat_cur = 2;
335 }
336 if (gain_stat_cur != -1) {
337 gain_stat_last = gain_stat_cur;
338 gain_stat_full_last = gain_stat_full;
339 gain_stat = gain_stat_cur;
340 } else {
341 gain_stat = gain_stat_last;
342 }
343 if (gain_stat == 0)
344 pGainState->ratio = 16;
345 else if (gain_stat == 1)
346 pGainState->ratio = 1;
347 else
348 pGainState->ratio = 1.0 / 16.0;
349
350 pGainState->gain_stat_full_last = gain_stat_full_last;
351 pGainState->gainState = gain_stat;
352 pGainState->gainState_last = gain_stat_last;
353
354 LOGD_ANR("%s:%d gain_cur:%f gain th %f %fd %f %f ratio:%f gain_state:%d %d full %d %d\n",
355 __FUNCTION__, __LINE__,
356 gain_cur,
357 gain_th0[0], gain_th0[1],
358 gain_th1[0], gain_th1[1],
359 pGainState->ratio,
360 pGainState->gainState_last,
361 pGainState->gainState,
362 pGainState->gain_stat_full_last,
363 gain_stat_full);
364
365
366 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
367
368 return AMFNR_RET_V1_SUCCESS;
369 }
370
371
372 //anr process
Amfnr_Process_V1(Amfnr_Context_V1_t * pAmfnrCtx,Amfnr_ExpInfo_V1_t * pExpInfo)373 Amfnr_Result_V1_t Amfnr_Process_V1(Amfnr_Context_V1_t *pAmfnrCtx, Amfnr_ExpInfo_V1_t *pExpInfo)
374 {
375 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
376 Amfnr_ParamMode_V1_t mode = AMFNR_PARAM_MODE_V1_INVALID;
377
378 if(pAmfnrCtx == NULL) {
379 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
380 return AMFNR_RET_V1_INVALID_PARM;
381 }
382
383 if(pExpInfo == NULL) {
384 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
385 return AMFNR_RET_V1_INVALID_PARM;
386 }
387
388 if(pAmfnrCtx->eState != AMFNR_STATE_V1_RUNNING) {
389 return AMFNR_RET_V1_SUCCESS;
390 }
391
392 Amfnr_GainRatioProcess_V1(&pAmfnrCtx->stGainState, pExpInfo);
393 Amfnr_ParamModeProcess_V1(pAmfnrCtx, pExpInfo, &mode);
394
395 pExpInfo->mfnr_mode_3to1 = pAmfnrCtx->mfnr_mode_3to1;
396 if(pExpInfo->mfnr_mode_3to1 ) {
397 pExpInfo->snr_mode = pExpInfo->pre_snr_mode;
398 } else {
399 pExpInfo->snr_mode = pExpInfo->cur_snr_mode;
400 }
401
402 if(pAmfnrCtx->eMode == AMFNR_OP_MODE_V1_AUTO) {
403
404 LOGD_ANR("%s(%d): \n", __FUNCTION__, __LINE__);
405
406 #if AMFNR_USE_XML_FILE_V1
407 if(pExpInfo->snr_mode != pAmfnrCtx->stExpInfo.snr_mode || pAmfnrCtx->eParamMode != mode) {
408 LOGD_ANR("param mode:%d snr_mode:%d\n", mode, pExpInfo->snr_mode);
409 pAmfnrCtx->eParamMode = mode;
410 Amfnr_ConfigSettingParam_V1(pAmfnrCtx, pAmfnrCtx->eParamMode, pExpInfo->snr_mode);
411 }
412 #endif
413
414 //select param
415 select_mfnr_params_by_ISO_v1(&pAmfnrCtx->stAuto.stParams, &pAmfnrCtx->stAuto.stSelect, pExpInfo, pAmfnrCtx->refYuvBit);
416 mfnr_dynamic_calc_v1(&pAmfnrCtx->stAuto.stMfnr_dynamic, pExpInfo);
417 } else if(pAmfnrCtx->eMode == AMFNR_OP_MODE_V1_MANUAL) {
418 //TODO
419 }
420
421 memcpy(&pAmfnrCtx->stExpInfo, pExpInfo, sizeof(Amfnr_ExpInfo_V1_t));
422
423 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
424 return AMFNR_RET_V1_SUCCESS;
425
426 }
427
428
429 //anr get result
Amfnr_GetProcResult_V1(Amfnr_Context_V1_t * pAmfnrCtx,Amfnr_ProcResult_V1_t * pAmfnrResult)430 Amfnr_Result_V1_t Amfnr_GetProcResult_V1(Amfnr_Context_V1_t *pAmfnrCtx, Amfnr_ProcResult_V1_t* pAmfnrResult)
431 {
432 LOGI_ANR("%s(%d): enter!\n", __FUNCTION__, __LINE__);
433
434 if(pAmfnrCtx == NULL) {
435 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
436 return AMFNR_RET_V1_INVALID_PARM;
437 }
438
439 if(pAmfnrResult == NULL) {
440 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
441 return AMFNR_RET_V1_INVALID_PARM;
442 }
443
444 if(pAmfnrCtx->eMode == AMFNR_OP_MODE_V1_AUTO) {
445 pAmfnrResult->stSelect = pAmfnrCtx->stAuto.stSelect;
446 pAmfnrResult->mfnrEn = pAmfnrCtx->stAuto.mfnrEn;
447 if(pAmfnrCtx->stAuto.mfnrEn && pAmfnrCtx->stAuto.stMfnr_dynamic.enable) {
448 pAmfnrResult->mfnrEn = pAmfnrCtx->stAuto.stMfnr_dynamic.mfnr_enable_state;
449 }
450 } else if(pAmfnrCtx->eMode == AMFNR_OP_MODE_V1_MANUAL) {
451 //TODO
452 pAmfnrResult->stSelect = pAmfnrCtx->stManual.stSelect;
453 pAmfnrResult->mfnrEn = pAmfnrCtx->stManual.mfnrEn;
454 pAmfnrCtx->fLuma_TF_Strength = 1.0;
455 pAmfnrCtx->fChroma_TF_Strength = 1.0;
456 }
457
458 if(pAmfnrCtx->isGrayMode) {
459 LOGD_ANR("anr: set gray mode!\n");
460 for(int i = 0; i < MFNR_MAX_LVL_UV; i++) {
461 pAmfnrResult->stSelect.weight_limit_uv[i] = MFNR_MAX_WEIGHT_LIMIT_UV;
462 }
463 }
464
465 //transfer to reg value
466 mfnr_fix_transfer_v1(&pAmfnrResult->stSelect, &pAmfnrResult->stFix, &pAmfnrCtx->stExpInfo, pAmfnrCtx->stGainState.ratio, pAmfnrCtx->fLuma_TF_Strength, pAmfnrCtx->fChroma_TF_Strength);
467 pAmfnrResult->stFix.tnr_en = pAmfnrResult->mfnrEn;
468
469 //set local gain & 3to1 mode
470 int local_gain_en = 1;
471 #if(AMFNR_USE_JSON_PARA_V1)
472 pAmfnrResult->stFix.mode = pAmfnrCtx->mfnr_v1.TuningPara.mode_3to1;
473 local_gain_en = pAmfnrCtx->mfnr_v1.TuningPara.local_gain_en;
474 #else
475 pAmfnrResult->stFix.mode = pAmfnrCtx->stMfnrCalib.mode_3to1;
476 local_gain_en = pAmfnrCtx->stMfnrCalib.local_gain_en;
477 #endif
478 if(local_gain_en) {
479 pAmfnrResult->stFix.gain_en = 0;
480 } else {
481 pAmfnrResult->stFix.gain_en = 1;
482 }
483
484
485 //motion detect
486 #if AMFNR_USE_JSON_PARA_V1
487 pAmfnrResult->stMotion = pAmfnrCtx->stMotion;
488 #else
489 int mode_idx = 0;
490 if(pAmfnrCtx->eParamMode == ANR_PARAM_MODE_NORMAL) {
491 mfnr_get_mode_cell_idx_by_name(&pAmfnrCtx->stMfnrCalib, "normal", &mode_idx);
492 } else if(pAmfnrCtx->eParamMode == ANR_PARAM_MODE_HDR) {
493 mfnr_get_mode_cell_idx_by_name(&pAmfnrCtx->stMfnrCalib, "hdr", &mode_idx);
494 } else if(pAmfnrCtx->eParamMode == ANR_PARAM_MODE_GRAY) {
495 mfnr_get_mode_cell_idx_by_name(&pAmfnrCtx->stMfnrCalib, "gray", &mode_idx);
496 } else {
497 LOGE_ANR("%s(%d): not support param mode!\n", __FUNCTION__, __LINE__);
498 }
499 pAmfnrResult->stMotion = pAmfnrCtx->stMfnrCalib.mode_cell[mode_idx].motion;
500 #endif
501
502 LOGI_ANR("%s(%d): exit!\n", __FUNCTION__, __LINE__);
503 return AMFNR_RET_V1_SUCCESS;
504 }
505
Amfnr_ConfigSettingParam_V1(Amfnr_Context_V1_t * pAmfnrCtx,Amfnr_ParamMode_V1_t eParamMode,int snr_mode)506 Amfnr_Result_V1_t Amfnr_ConfigSettingParam_V1(Amfnr_Context_V1_t *pAmfnrCtx, Amfnr_ParamMode_V1_t eParamMode, int snr_mode)
507 {
508 char snr_name[CALIBDB_NR_SHARP_NAME_LENGTH];
509 char param_mode_name[CALIBDB_MAX_MODE_NAME_LENGTH];
510 memset(param_mode_name, 0x00, sizeof(param_mode_name));
511 memset(snr_name, 0x00, sizeof(snr_name));
512
513 if(pAmfnrCtx == NULL) {
514 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
515 return AMFNR_RET_V1_INVALID_PARM;
516 }
517
518 //select param mode first
519 if(eParamMode == AMFNR_PARAM_MODE_V1_NORMAL) {
520 sprintf(param_mode_name, "%s", "normal");
521 } else if(eParamMode == AMFNR_PARAM_MODE_V1_HDR) {
522 sprintf(param_mode_name, "%s", "hdr");
523 } else if(eParamMode == AMFNR_PARAM_MODE_V1_GRAY) {
524 sprintf(param_mode_name, "%s", "gray");
525 } else {
526 LOGE_ANR("%s(%d): not support param mode!\n", __FUNCTION__, __LINE__);
527 sprintf(param_mode_name, "%s", "normal");
528 }
529
530
531 //then select snr mode next
532 if(snr_mode == 1) {
533 sprintf(snr_name, "%s", "HSNR");
534 } else if(snr_mode == 0) {
535 sprintf(snr_name, "%s", "LSNR");
536 } else {
537 LOGE_ANR("%s(%d): not support snr mode!\n", __FUNCTION__, __LINE__);
538 sprintf(snr_name, "%s", "LSNR");
539 }
540
541 #if AMFNR_USE_JSON_PARA_V1
542 pAmfnrCtx->stAuto.mfnrEn = pAmfnrCtx->mfnr_v1.TuningPara.enable;
543 mfnr_config_setting_param_json_v1(&pAmfnrCtx->stAuto.stParams, &pAmfnrCtx->mfnr_v1, param_mode_name, snr_name);
544 mfnr_config_dynamic_param_json_v1(&pAmfnrCtx->stAuto.stMfnr_dynamic, &pAmfnrCtx->mfnr_v1, param_mode_name);
545 mfnr_config_motion_param_json_v1(&pAmfnrCtx->stMotion, &pAmfnrCtx->mfnr_v1, param_mode_name);
546 #else
547 pAmfnrCtx->stAuto.mfnrEn = pAmfnrCtx->stMfnrCalib.enable;
548 mfnr_config_setting_param_v1(&pAmfnrCtx->stAuto.stParams, &pAmfnrCtx->stMfnrCalib, param_mode_name, snr_name);
549 mfnr_config_dynamic_param(&pAmfnrCtx->stAuto.stMfnr_dynamic, &pAmfnrCtx->stMfnrCalib, param_mode_name);
550 #endif
551
552 return AMFNR_RET_V1_SUCCESS;
553 }
554
Amfnr_ParamModeProcess_V1(Amfnr_Context_V1_t * pAmfnrCtx,Amfnr_ExpInfo_V1_t * pExpInfo,Amfnr_ParamMode_V1_t * mode)555 Amfnr_Result_V1_t Amfnr_ParamModeProcess_V1(Amfnr_Context_V1_t *pAmfnrCtx, Amfnr_ExpInfo_V1_t *pExpInfo, Amfnr_ParamMode_V1_t *mode) {
556 Amfnr_Result_V1_t res = AMFNR_RET_V1_SUCCESS;
557 *mode = pAmfnrCtx->eParamMode;
558
559 if(pAmfnrCtx == NULL) {
560 LOGE_ANR("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
561 return AMFNR_RET_V1_INVALID_PARM;
562 }
563
564 if(pAmfnrCtx->isGrayMode) {
565 *mode = AMFNR_PARAM_MODE_V1_GRAY;
566 } else if(pExpInfo->hdr_mode == 0) {
567 *mode = AMFNR_PARAM_MODE_V1_NORMAL;
568 } else if(pExpInfo->hdr_mode >= 1) {
569 *mode = AMFNR_PARAM_MODE_V1_HDR;
570 } else {
571 *mode = AMFNR_PARAM_MODE_V1_NORMAL;
572 }
573
574 return res;
575 }
576
577
578 RKAIQ_END_DECLARE
579
580
581