ipa: simple: blc: Prevent division by zero in BLC
When there are no values in the histogram, BLC simple IPA can crash on division by zero. We cannot get anything meaningful in such a case anyway, let's simply return from `process()' then. Tested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Reviewed-by: Hans de Goede <hansg@kernel.org> Tested-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
0201e11f27
commit
1102a96854
@@ -80,6 +80,11 @@ void BlackLevel::process(IPAContext &context,
|
||||
constexpr float ignoredPercentage = 0.02;
|
||||
const unsigned int total =
|
||||
std::accumulate(begin(histogram), end(histogram), 0);
|
||||
if (total == 0) {
|
||||
LOG(IPASoftBL, Debug) << "Not guessing black level, histogram is empty";
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned int pixelThreshold = ignoredPercentage * total;
|
||||
const unsigned int histogramRatio = 256 / SwIspStats::kYHistogramSize;
|
||||
const unsigned int currentBlackIdx =
|
||||
|
||||
Reference in New Issue
Block a user