From ea43e056a83fcfcf627669b4e5ee922d97c95d4b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 16 Jun 2024 00:34:16 +0300 Subject: ipa: rkisp1: agc: Simplify predivider calculation The condition if (std::pow(std::floor(root), 2) < factor) predivider = static_cast(std::ceil(root)); else predivider = static_cast(std::floor(root)); can only be false when the factor's root is an integer. In that case, std::ceil(root) and std::floor(root) will be equal. The computation can thus be simplified by always rounding up. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/algorithms/agc.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src') diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 9f3b59b4..a61201bb 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -115,12 +115,7 @@ uint8_t Agc::computeHistogramPredivider(const Size &size, int count = mode == RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED ? 3 : 1; double factor = size.width * size.height * count / 65536.0; double root = std::sqrt(factor); - uint8_t predivider; - - if (std::pow(std::floor(root), 2) < factor) - predivider = static_cast(std::ceil(root)); - else - predivider = static_cast(std::floor(root)); + uint8_t predivider = static_cast(std::ceil(root)); return std::clamp(predivider, 3, 127); } -- cgit v1.2.1