ipa: rkisp1: Compute LSC algorithm parameter during configure
LSC gradient parameters are currently computed during prepare() phase. Because these parameters can be computed only one time and stay constant for each frame after, move the computation to the configure() function. Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
375a70d43e
commit
aa7b374054
2 changed files with 38 additions and 27 deletions
|
@ -122,27 +122,12 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,
|
||||||
int LensShadingCorrection::configure(IPAContext &context,
|
int LensShadingCorrection::configure(IPAContext &context,
|
||||||
[[maybe_unused]] const IPACameraSensorInfo &configInfo)
|
[[maybe_unused]] const IPACameraSensorInfo &configInfo)
|
||||||
{
|
{
|
||||||
context.configuration.lsc.enabled = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
|
||||||
*/
|
|
||||||
void LensShadingCorrection::prepare(IPAContext &context, const uint32_t frame,
|
|
||||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
|
||||||
rkisp1_params_cfg *params)
|
|
||||||
{
|
|
||||||
if (frame > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
struct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config;
|
|
||||||
const Size &size = context.configuration.sensor.size;
|
const Size &size = context.configuration.sensor.size;
|
||||||
Size totalSize{};
|
Size totalSize{};
|
||||||
|
|
||||||
for (unsigned int i = 0; i < RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE; ++i) {
|
for (unsigned int i = 0; i < RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE; ++i) {
|
||||||
config.x_size_tbl[i] = xSize_[i] * size.width;
|
xSizes_[i] = xSize_[i] * size.width;
|
||||||
config.y_size_tbl[i] = ySize_[i] * size.height;
|
ySizes_[i] = ySize_[i] * size.height;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To prevent unexpected behavior of the ISP, the sum of x_size_tbl and
|
* To prevent unexpected behavior of the ISP, the sum of x_size_tbl and
|
||||||
|
@ -151,25 +136,47 @@ void LensShadingCorrection::prepare(IPAContext &context, const uint32_t frame,
|
||||||
* rounding-induced errors.
|
* rounding-induced errors.
|
||||||
*/
|
*/
|
||||||
if (i == RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE - 1) {
|
if (i == RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE - 1) {
|
||||||
config.x_size_tbl[i] = size.width / 2 - totalSize.width;
|
xSizes_[i] = size.width / 2 - totalSize.width;
|
||||||
config.y_size_tbl[i] = size.height / 2 - totalSize.height;
|
ySizes_[i] = size.height / 2 - totalSize.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
totalSize.width += config.x_size_tbl[i];
|
totalSize.width += xSizes_[i];
|
||||||
totalSize.height += config.y_size_tbl[i];
|
totalSize.height += ySizes_[i];
|
||||||
|
|
||||||
config.x_grad_tbl[i] = std::round(32768 / config.x_size_tbl[i]);
|
xGrad_[i] = std::round(32768 / xSizes_[i]);
|
||||||
config.y_grad_tbl[i] = std::round(32768 / config.y_size_tbl[i]);
|
yGrad_[i] = std::round(32768 / ySizes_[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.configuration.lsc.enabled = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||||
|
*/
|
||||||
|
void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,
|
||||||
|
const uint32_t frame,
|
||||||
|
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||||
|
rkisp1_params_cfg *params)
|
||||||
|
{
|
||||||
|
if (frame > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config;
|
||||||
|
|
||||||
|
memcpy(config.x_grad_tbl, xGrad_, sizeof(config.x_grad_tbl));
|
||||||
|
memcpy(config.y_grad_tbl, yGrad_, sizeof(config.y_grad_tbl));
|
||||||
|
memcpy(config.x_size_tbl, xSizes_, sizeof(config.x_size_tbl));
|
||||||
|
memcpy(config.y_size_tbl, ySizes_, sizeof(config.y_size_tbl));
|
||||||
|
|
||||||
std::copy(rData_.begin(), rData_.end(),
|
std::copy(rData_.begin(), rData_.end(),
|
||||||
¶ms->others.lsc_config.r_data_tbl[0][0]);
|
&config.r_data_tbl[0][0]);
|
||||||
std::copy(grData_.begin(), grData_.end(),
|
std::copy(grData_.begin(), grData_.end(),
|
||||||
¶ms->others.lsc_config.gr_data_tbl[0][0]);
|
&config.gr_data_tbl[0][0]);
|
||||||
std::copy(gbData_.begin(), gbData_.end(),
|
std::copy(gbData_.begin(), gbData_.end(),
|
||||||
¶ms->others.lsc_config.gb_data_tbl[0][0]);
|
&config.gb_data_tbl[0][0]);
|
||||||
std::copy(bData_.begin(), bData_.end(),
|
std::copy(bData_.begin(), bData_.end(),
|
||||||
¶ms->others.lsc_config.b_data_tbl[0][0]);
|
&config.b_data_tbl[0][0]);
|
||||||
|
|
||||||
params->module_en_update |= RKISP1_CIF_ISP_MODULE_LSC;
|
params->module_en_update |= RKISP1_CIF_ISP_MODULE_LSC;
|
||||||
params->module_ens |= RKISP1_CIF_ISP_MODULE_LSC;
|
params->module_ens |= RKISP1_CIF_ISP_MODULE_LSC;
|
||||||
|
|
|
@ -33,6 +33,10 @@ private:
|
||||||
|
|
||||||
std::vector<double> xSize_;
|
std::vector<double> xSize_;
|
||||||
std::vector<double> ySize_;
|
std::vector<double> ySize_;
|
||||||
|
uint16_t xGrad_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
|
||||||
|
uint16_t yGrad_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
|
||||||
|
uint16_t xSizes_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
|
||||||
|
uint16_t ySizes_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ipa::rkisp1::algorithms */
|
} /* namespace ipa::rkisp1::algorithms */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue