ipa: simple: agc: Prevent division by zero in AGC
If the histogram size is non-zero but lower than the number of bins, yHistValsPerBin is zero and then the AGC processing crashes on division by it. Let's check yHistValsPerBin for being zero and stop AGC processing in such a case. The condition also covers the cases where histogramSize or yHistValsPerBinMod are zero. Tested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Hans de Goede <hansg@kernel.org> Tested-by: Hans de Goede <hansg@kernel.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
1102a96854
commit
f0f2aca566
@@ -145,6 +145,12 @@ void Agc::process(IPAContext &context,
|
||||
unsigned int denom = 0;
|
||||
unsigned int num = 0;
|
||||
|
||||
if (yHistValsPerBin == 0) {
|
||||
LOG(IPASoftExposure, Debug)
|
||||
<< "Not adjusting exposure due to insufficient histogram data";
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < histogramSize; i++) {
|
||||
unsigned int idx = (i - (i / yHistValsPerBinMod)) / yHistValsPerBin;
|
||||
exposureBins[idx] += histogram[blackLevelHistIdx + i];
|
||||
|
||||
Reference in New Issue
Block a user