//通过接口findShutterValues 传递一个float类型, 可以查找匹配的shutter值
int shutter_tbl[][2] =
{
{1, 30},
{1, 40},
{1, 50},
{1, 60},
{1, 80},
{1, 100},
{1, 125},
{1, 160},
{1, 200},
{1, 250},
{1, 320},
{1, 400},
{1, 480},
{1, 500},
{1, 640},
{1, 800},
{1, 1000},
{1, 1250},
{1, 1600},
{1, 2000},
{1, 2500},
{1, 3200},
{1, 4000},
{1, 5000},
{1, 6400},
{1, 8000}
};
#define SHUTTER_TABLE_SIZE (sizeof(shutter_tbl)/(sizeof(shutter_tbl[0])-1))
findShutterValues(float shutter_requested_s,int *shutter_value_1, int *shutter_value_2)
{
const float accuracy = (1.0f / 8000.0f) / 10.0f;
for (int i = 0; i < SHUTTER_TABLE_SIZE; ++i)
{
float diff = fabsf(((float)shutter_tbl[i][0] / (float)shutter_tbl[i][1]) - shutter_requested_s);
if (diff < accuracy)
{
*shutter_value_1 = shutter_tbl[i][0];
*shutter_value_2 = shutter_tbl[i][1];
return true;
}
}
return false;
}
fabsf用法
最新推荐文章于 2024-03-15 21:26:08 发布