hc
2024-08-12 233ab1bd4c5697f5cdec94e60206e8c6ac609b4c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "asharp4/rk_aiq_uapi_asharp_int_v4.h"
#include "asharp4/rk_aiq_types_asharp_algo_prvt_v4.h"
 
#define ASHSRPV4_STRENGTH_SLOPE_FACTOR (4.0)
 
 
XCamReturn
rk_aiq_uapi_asharpV4_SetAttrib(RkAiqAlgoContext *ctx,
                               rk_aiq_sharp_attrib_v4_t *attr,
                               bool need_sync)
{
 
    Asharp_Context_V4_t* pAsharpCtx = (Asharp_Context_V4_t*)ctx;
 
    pAsharpCtx->eMode = attr->eMode;
 
    if(pAsharpCtx->eMode == ASHARP4_OP_MODE_AUTO) {
        pAsharpCtx->stAuto = attr->stAuto;
    } else if(pAsharpCtx->eMode == ASHARP4_OP_MODE_MANUAL) {
        pAsharpCtx->stManual.stSelect = attr->stManual.stSelect;
    } else if(pAsharpCtx->eMode == ASHARP4_OP_MODE_REG_MANUAL) {
        pAsharpCtx->stManual.stFix = attr->stManual.stFix;
    }
 
    pAsharpCtx->isReCalculate |= 1;
 
    return XCAM_RETURN_NO_ERROR;
}
 
XCamReturn
rk_aiq_uapi_asharpV4_GetAttrib(const RkAiqAlgoContext *ctx,
                               rk_aiq_sharp_attrib_v4_t *attr)
{
 
    Asharp_Context_V4_t* pAsharpCtx = (Asharp_Context_V4_t*)ctx;
 
    attr->eMode = pAsharpCtx->eMode;
    memcpy(&attr->stAuto, &pAsharpCtx->stAuto, sizeof(attr->stAuto));
    memcpy(&attr->stManual, &pAsharpCtx->stManual, sizeof(attr->stManual));
 
    return XCAM_RETURN_NO_ERROR;
}
 
XCamReturn
rk_aiq_uapi_asharpV4_SetStrength(const RkAiqAlgoContext *ctx,
                                 rk_aiq_sharp_strength_v4_t *pStrength)
{
 
    Asharp_Context_V4_t* pAsharpCtx = (Asharp_Context_V4_t*)ctx;
    float fslope = ASHSRPV4_STRENGTH_SLOPE_FACTOR;
    float fStrength = 1.0;
    float fPercent = 0.5;
 
    fPercent = pStrength->percent;
 
    if(fPercent <= 0.5) {
        fStrength =  fPercent / 0.5;
    } else {
        if(fPercent >= 0.999999)
            fPercent = 0.999999;
        fStrength = 0.5 * fslope / (1.0 - fPercent) - fslope + 1;
    }
 
    pAsharpCtx->stStrength = *pStrength;
    pAsharpCtx->stStrength.percent = fStrength;
    pAsharpCtx->isReCalculate |= 1;
 
    LOGD_ASHARP("%s:%d percent:%f fStrength:%f \n",
                __FUNCTION__, __LINE__,
                fStrength, fPercent);
 
    return XCAM_RETURN_NO_ERROR;
}
 
XCamReturn
rk_aiq_uapi_asharpV4_GetStrength(const RkAiqAlgoContext *ctx,
                                 rk_aiq_sharp_strength_v4_t *pStrength)
{
 
    Asharp_Context_V4_t* pAsharpCtx = (Asharp_Context_V4_t*)ctx;
    float fslope = ASHSRPV4_STRENGTH_SLOPE_FACTOR;
    float fStrength = 1.0;
    float fPercent = 0.5;
 
    fStrength = pAsharpCtx->stStrength.percent;
 
    if(fStrength <= 1) {
        fPercent = fStrength * 0.5;
    } else {
        float tmp = 1.0;
        tmp = 1 - 0.5 * fslope / (fStrength + fslope - 1);
        if(abs(tmp - 0.999999) < 0.000001) {
            tmp = 1.0;
        }
        fPercent = tmp;
    }
 
    *pStrength = pAsharpCtx->stStrength;
    pStrength->percent = fPercent;
 
    LOGD_ASHARP("%s:%d fStrength:%f percent:%f\n",
                __FUNCTION__, __LINE__,
                fStrength, fPercent);
 
    return XCAM_RETURN_NO_ERROR;
}