Message ID | 20250911135144.56586-6-mzamazal@redhat.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
On 9/11/25 15:51, Milan Zamazal wrote: > 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> > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> > --- Reviewed-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Thanks, Maciej
diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp index 8c1e9ed08..ea5356443 100644 --- a/src/ipa/simple/algorithms/blc.cpp +++ b/src/ipa/simple/algorithms/blc.cpp @@ -77,6 +77,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 =