Skip to content

Commit 5519924

Browse files
committed
DngDecoder/RawImageDataFloat::scaleBlackWhite(): no white level means 1.0F
`RawImageDataFloat::scaleBlackWhite()` is dead code, i bet nobody uses it.
1 parent dc35ed4 commit 5519924

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/librawspeed/common/RawImageDataFloat.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ void RawImageDataFloat::scaleBlackWhite() {
122122

123123
const int skipBorder = 150;
124124
int gw = (dim.x - skipBorder) * cpp;
125-
if ((blackAreas.empty() && !blackLevelSeparate && blackLevel < 0) ||
126-
!whitePoint) { // Estimate
125+
// NOTE: lack of whitePoint means that it is pre-normalized.
126+
if (blackAreas.empty() && !blackLevelSeparate && blackLevel < 0) { // Estimate
127127
float b = 100000000;
128128
float m = -10000000;
129129
for (int row = skipBorder * cpp; row < (dim.y - skipBorder); row++) {
@@ -135,10 +135,7 @@ void RawImageDataFloat::scaleBlackWhite() {
135135
}
136136
if (blackLevel < 0)
137137
blackLevel = static_cast<int>(b);
138-
if (!whitePoint)
139-
whitePoint = static_cast<int>(m);
140-
writeLog(DEBUG_PRIO::INFO, "Estimated black:%d, Estimated white: %d",
141-
blackLevel, *whitePoint);
138+
writeLog(DEBUG_PRIO::INFO, "Estimated black:%d", blackLevel);
142139
}
143140

144141
/* If filter has not set separate blacklevel, compute or fetch it */
@@ -161,8 +158,8 @@ void RawImageDataFloat::scaleValues(int start_y, int end_y) {
161158
v ^= 1;
162159
if ((mOffset.y & 1) != 0)
163160
v ^= 2;
164-
mul[i] =
165-
65535.0F / static_cast<float>(*whitePoint - blackLevelSeparate1D(v));
161+
mul[i] = 65535.0F / static_cast<float>(whitePoint.value_or(1.0F) -
162+
blackLevelSeparate1D(v));
166163
sub[i] = static_cast<float>(blackLevelSeparate1D(v));
167164
}
168165
for (int y = start_y; y < end_y; y++) {

src/librawspeed/decoders/DngDecoder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,9 @@ void DngDecoder::handleMetadata(const TiffIFD* raw) {
602602
// Default white level is (2 ** BitsPerSample) - 1
603603
mRaw->whitePoint = implicit_cast<int>((1UL << bps) - 1UL);
604604
} else if (mRaw->getDataType() == RawImageType::F32) {
605-
// Default white level is 1.0f. But we can't represent that here.
606-
// Fall back to uninitialized value instead.
607-
mRaw->whitePoint = 65536;
605+
// Default white level is 1.0f. But we can't represent that here,
606+
// so just claim that we don't know it, and users shall default to 1.0F.
607+
mRaw->whitePoint.reset();
608608
}
609609

610610
if (raw->hasEntry(TiffTag::WHITELEVEL)) {

0 commit comments

Comments
 (0)