awb_tuning_custom_main(附解析笔记)
*/
#include "camera_custom_types.h"
#include "camera_custom_nvram.h"
#include "awb_feature.h"
#include "awb_param.h"
#include "awb_tuning_custom.h"
using namespace NSIspTuning;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
template <>
MBOOL
isAWBEnabled<ESensorDev_Main>()
{
return MTRUE;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
template <>
AWB_PARAM_T const&
getAWBParam<ESensorDev_Main>()
{
static AWB_PARAM_T rAWBParam =
{
// Chip dependent parameter
{
512, // i4AWBGainOutputScaleUnit: 1.0x = 512
8191, // i4AWBGainOutputUpperLimit: format 4.9 (11 bit)
256 // i4RotationMatrixUnit: 1.0x = 256
},
// AWB Light source probability look-up table (Max: 100; Min: 0) //P1 环境亮度和光源匹配的程度,越匹配,此值越大
{
AWB_LV_INDEX_NUM, // i4SizeX: horizontal dimension
AWB_LIGHT_NUM, // i4SizeY: vertical dimension
// LUT
{ // LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}, // Strobe
{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 66, 33, 1, 1, 1, 1, 1}, // Tungsten
{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 66, 33, 1, 1, 1, 1, 1}, // Warm fluorescent
{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 66, 66, 66, 66, 66, 66, 66}, // Fluorescent
{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 66, 33, 1, 1, 1, 1, 1}, // CWF
{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}, // Daylight
{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 66, 33, 1, 1, 1}, // Shade
{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 66, 33, 1, 1, 1, 1, 1} // Daylight fluorescent
}
},
// AWB convergence parameter //建议保持默认
{
10, // i4Speed: Convergence speed: (0 ~ 100) //AWB一帧在current gain和target gain之间收敛的速度(例:一帧收敛10%)
225,//225 // i4StableThr: Stable threshold ((currentRgain - targetRgain)^2 + (currentBgain - targetBgain)^2), WB gai n format: 4.9
},////////((currentRgain - targetRgain)^2 + (currentBgain - targetBgain)^2)此公式所得计算值与阈值比较,小于此值时AWB收敛完成//////////
// AWB daylight locus target offset ratio LUT for tungsten //低色温偏色控制机制(shade类似)
{
AWB_DAYLIGHT_LOCUS_NEW_OFFSET_INDEX_NUM, // i4Size: LUT dimension
{// LUT: use daylight locus new offset (0~10000) as index to get daylight locus target offset ratio (0~100) //根据DP中AWB_TAG_DAY_LOCUS NEW OFFSET T/WF数据获得 映射LUT In行 ;AWB_TAG_DAY_LOCUS_OFFSET_T/WF(根据光源的白点统计出来的值)—TUNG_OFFS值=AWB_TAG_DAY_LOCUS NEW OFFSET T/WF;LUT In后经过一系列计算index映射后得到AWB_TAG_DAY_LOCUS_TARGET_OFFSET_RATIO_T/WF,此值最终决定颜色偏色程度,值↑偏色程度↑
// 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 8500 9000 9500 10000 //LUT In:对应DP中AWB_TAG_DAY_LOCUS NEW OFFSET T/WF
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100 //LUT Out:AWB_TAG_DAY_LOCUS_TARGET_OFFSET_RATIO_S/T/WF的 index ratio
}
},
// AWB daylight locus target offset ratio LUT for warm fluorescent //低色温偏色控制机制(shade类似)
{
AWB_DAYLIGHT_LOCUS_NEW_OFFSET_INDEX_NUM, // i4Size: LUT dimension
{// LUT: use daylight locus new offset (0~10000) as index to get daylight locus target offset ratio (0~100)
// 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 8500 9000 9500 10000
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100
}
},
// AWB green offset threshold for warm fluorescent //当AWB_TAG_GREEN_OFFSET_THR_WF<AWB_TAG_GREEN_OFFSET__WF 偏绿
{ 当AWB_TAG_GREEN_OFFSET_THR_WF>AWB_TAG_GREEN_OFFSET__WF 偏紫
AWB_DAYLIGHT_LOCUS_OFFSET_INDEX_NUM, // i4Size: LUT dimension
{// LUT: use daylight locus offset (0~10000) as index to get green offset threshold
// 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 8500 9000 9500 10000 //i4LUTIn: AWB_TAG_DAY_LOCUS_OFFSET_WF 根据光源的白点落点统计出来的
//600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 750, 900, 1050, 1200
1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1050, 900, 900, 900, 900, 900, 900, 900, 900, 900 //i4LUTout:AWB_TAG_GREEN_OFFSET_THR_WF 根据AWB_TAG_DAY_LOCUS_OFFSET_WF的index得到
}
},
// AWB light source weight LUT for tungsten light //P2 白点落点特征和光源匹配的程度,越匹配,此数值越高;可以根据DP中AWB_TAG_GM_OFFSET_T/WF/S数据获得(由白点落点特性统计的到,包括A/H/D75光源); 映射LUT In行 (Rane o~256)
/////////////AWB_TAG_P=AWB_TAG_P0*AWB_TAG_P1*AWB_TAG_P2/////////////
{
AWB_TUNGSTEN_MAGENTA_OFFSET_INDEX_NUM, // i4Size: LUT dimension
{// LUT: use magenta offset (0~1000) as index to get tungsten weight (x/256)
// 0 100 200 300 400 500 600 700 800 900 1000 //i4LUTIn
256, 256, 256, 256, 256, 256, 256, 128, 64, 32, 16 //i4LUTout
} //例:AWB_TAG_GM_Offset_T=600时 即LUT In=600,P2=256匹配程度为100% AWB_TAG_GM_Offset_T=700时 即LUT In=700,P2=128匹配程度为50%
},
// AWB light source weight LUT for warm fluorescent //P2 (Rane o~256)
{
AWB_WARM_FLUORESCENT_GREEN_OFFSET_INDEX_NUM, // i4Size: LUT dimension
{// LUT: use green offset (0~2000) as index to get fluorescent0 weight (x/256)
// 0 200 400 600 800 1000 1200 1400 1600 1800 2000
256, 256, 256, 256, 128, 64, 32, 16, 16, 16, 16
}
},
// AWB light source weight LUT for shade light //P2 (Rane o~256)
{
AWB_SHADE_MAGENTA_OFFSET_INDEX_NUM, // i4MagentaLUTSize: Magenta LUT dimension
{// MagentaLUT: use magenta offset (0~1000) as index to get shade light weight (x/256)
// 0 100 200 300 400 500 600 700 800 900 1000
256, 256, 128, 56, 28, 16, 16, 16, 16, 16, 16
},
AWB_SHADE_GREEN_OFFSET_INDEX_NUM, // i4GreenLUTSize: Green LUT dimension
{// GreenLUT: use green offset (0~1000) as index to get shade light weight (x/256)
// 0 100 200 300 400 500 600 700 800 900 1000
// 256, 256, 256, 256, 256, 128, 64, 32, 16, 16, 16
256, 256, 128, 64, 32, 32, 16, 16, 16, 16, 16
}
},
// One-shot AWB parameter //建议保持默认
{
MFALSE,
10, // LV 1.0 //环境亮度>LV5时:capture gain结果不会参考preview gain 结果;LV1<环境亮度>LV5时:capture结果会参考preview gain和capture gain混合的结果
50 // LV 5.0 //环境亮度<LV1时:capture 结果会直接参考Daylight Default Gain结果//
}, //注:ZSD模式,此参数不起作用
// AWB gain prediction parameter 属于spatial Predictor(老平台)
{
// Strobe
{
0, // i4IntermediateSceneLvThr_L1: useless
0, // i4IntermediateSceneLvThr_H1: useless
105, //100, //90, // i4IntermediateSceneLvThr_L2
135, //130, //120, // i4IntermediateSceneLvThr_H2
0, // i4DaylightLocusLvThr_L: useless
0 // i4DaylightLocusLvThr_H: useless
},
// Tungsten
{
100, // i4IntermediateSceneLvThr_L1
130, // i4IntermediateSceneLvThr_H1
120, //115, //105, // i4IntermediateSceneLvThr_L2 //小于此LV混spatial Low \ 中间LV为L和H内插(线性插值)
160, //155, //145, // i4IntermediateSceneLvThr_H2 //小于此LV混spatial Hight /
50, // i4DaylightLocusLvThr_L \ //AWB_TAG_DAY_LOCUS_TARGET_OFFSET_RATIO_S/T/WF的 index ratio根据LV计算出一个新的ratio,此值为最终的ratio,在PD中无显示;
100 // i4DaylightLocusLvThr_H / 例:若AWB_TAG_DAY_LOCUS_TARGET_OFFSET_RATIO_S/T/WF的 index ratio是50 当前LV和i4DaylightLocusLvThr_L与 i4DaylightLocusLvThr_H之间关系映射得到一个new ratio, new ratio范围50~100之间进行插值,new ratio越大 AWB_TAG_DAY_LOCUS_TARGET_OFFSET_S/T/WF值越大
},
// Warm fluorescent
{
100, // i4IntermediateSceneLvThr_L1
130, // i4IntermediateSceneLvThr_H1
120, //115, //105, // i4IntermediateSceneLvThr_L2
160, //155, //145, // i4IntermediateSceneLvThr_H2
50, // i4DaylightLocusLvThr_L
100 // i4DaylightLocusLvThr_H
},
// Fluorescent
{
0, // i4IntermediateSceneLvThr_L1: useless
0, // i4IntermediateSceneLvThr_H1: useless
125, //120 ,//110, // i4IntermediateSceneLvThr_L2
165, //160, //150, // i4IntermediateSceneLvThr_H2
0, // i4DaylightLocusLvThr_L: useless
0 // i4DaylightLocusLvThr_H: useless
},
// CWF
{
0, // i4IntermediateSceneLvThr_L1: useless
0, // i4IntermediateSceneLvThr_H1: useless
115, //110, //100, // i4IntermediateSceneLvThr_L2
155, //150, //140, // i4IntermediateSceneLvThr_H2
0, // i4DaylightLocusLvThr_L: useless
0 // i4DaylightLocusLvThr_H: useless
},
// Daylight
{
0, // i4IntermediateSceneLvThr_L1: useless
0, // i4IntermediateSceneLvThr_H1: useless
135, //130, //120, // i4IntermediateSceneLvThr_L2
170, //160, // i4IntermediateSceneLvThr_H2
0, // i4DaylightLocusLvThr_L: useless
0 // i4DaylightLocusLvThr_H: useless
},
// Daylight fluorescent
{
0, // i4IntermediateSceneLvThr_L1: useless
0, // i4IntermediateSceneLvThr_H1: useless
115, //110, //100, // i4IntermediateSceneLvThr_L2
155, //150, //140 , // i4IntermediateSceneLvThr_H2
0, // i4DaylightLocusLvThr_L: useless
0 // i4DaylightLocusLvThr_H: useless
},
// Shade
{
100, // i4IntermediateSceneLvThr_L1
130, // i4IntermediateSceneLvThr_H1
115, //110, //100, // i4IntermediateSceneLvThr_L2
145, //140, //130, // i4IntermediateSceneLvThr_H2
50, // i4DaylightLocusLvThr_L
100 // i4DaylightLocusLvThr_H
}
},
// F - subwindow
{
0,// i4Method
1,// i4Mode
128,// i4SpeedRight_F
192,// i4SpeedLeft_F
192,// i4SpeedUpper_F
256 // i4SpeedLower_F
},
// CWF - subwindow
{
0,// i4Method
1, // i4Mode
128,// i4SpeedRight_CWF
192,// i4SpeedLeft_CWF
192,// i4SpeedUpper_CWF
256 // i4SpeedLower_CWF
}
};
return (rAWBParam);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
template <>
AWB_STAT_PARAM_T const&
getAWBStatParam<ESensorDev_Main>()
{
// AWB Statistics Parameter
static AWB_STAT_PARAM_T rAWBStatParam =
{
// Number of AWB windows
120, // Number of horizontal AWB windows
90, // Number of vertical AWB windows
// Thresholds
1, // Low threshold of R \
1, // Low threshold of G | 当前像素值<1时,判定为过暗的点
1, // Low threshold of B |_ 当前像素值>254时,判定为过亮的点
254, // High threshold of R | 统称error pixel
254, // High threshold of G |
254, // High threshold of B /
// Pre-gain maximum limit clipping
0xFFF, // Maximum limit clipping for R color
0xFFF, // Maximum limit clipping for G color
0xFFF, // Maximum limit clipping for B color
// AWB error threshold //值↑ 一个block中允许过暗或过亮的pixels越多
20, // Programmable threshold for the allowed total over-exposed and under-exposed pixels in one main stat window
// AWB error count shift bits
0 // Programmable error count shift bits: 0 ~ 7; note: AWB statistics provide 4-bits error count output only
};
return (rAWBStatParam);
}