From 91565728e50ab2eefe743c6a13295ba50f54522d Mon Sep 17 00:00:00 2001 From: rom9 <4711834+rom9@users.noreply.github.com> Date: Sun, 9 Jun 2019 19:25:15 +0200 Subject: [PATCH] Clamped output values to a max of 65535.f after applying multipliers, to avoid trouble further down the processing pipeline. --- rtengine/filmnegativeproc.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rtengine/filmnegativeproc.cc b/rtengine/filmnegativeproc.cc index d2a798abe..64f7a697b 100644 --- a/rtengine/filmnegativeproc.cc +++ b/rtengine/filmnegativeproc.cc @@ -255,9 +255,10 @@ void RawImageSource::filmNegativeProcess(const procparams::FilmNegativeParams &p #endif for (int row = 0; row < H; row ++) { for (int col = 0; col < W; col++) { - int c = FC(row, col); // three colors, 0=R, 1=G, 2=B - // Apply the multipliers - rawData[row][col] *= mults[c]; + int c = FC(row, col); // three colors, 0=R, 1=G, 2=B + // Apply the multipliers, clamp max output value to 65535 + float out = rawData[row][col] * mults[c]; + rawData[row][col] = out > 65535.f ? 65535.f : out; } } @@ -268,9 +269,10 @@ void RawImageSource::filmNegativeProcess(const procparams::FilmNegativeParams &p #endif for (int row = 0; row < H; row ++) { for (int col = 0; col < W; col++) { - int c = ri->XTRANSFC(row, col); // three colors, 0=R, 1=G, 2=B - // Apply the multipliers - rawData[row][col] *= mults[c]; + int c = ri->XTRANSFC(row, col); // three colors, 0=R, 1=G, 2=B + // Apply the multipliers, clamp max output value to 65535 + float out = rawData[row][col] * mults[c]; + rawData[row][col] = out > 65535.f ? 65535.f : out; } }