From 1be0462c509000e39baf940dbc88373de7ff2033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Wed, 20 Sep 2023 11:31:31 +0200 Subject: [PATCH] Relax DNG black level parsing Use the default BlackLevelRepeatDim (1,1) if the single entry value is 1 --- src/librawspeed/decoders/DngDecoder.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librawspeed/decoders/DngDecoder.cpp b/src/librawspeed/decoders/DngDecoder.cpp index 9922eaa02..6fd7cfbd3 100644 --- a/src/librawspeed/decoders/DngDecoder.cpp +++ b/src/librawspeed/decoders/DngDecoder.cpp @@ -767,9 +767,13 @@ bool DngDecoder::decodeBlackLevels(const TiffIFD* raw) const { iPoint2D blackdim(1, 1); if (raw->hasEntry(TiffTag::BLACKLEVELREPEATDIM)) { const TiffEntry* bleveldim = raw->getEntry(TiffTag::BLACKLEVELREPEATDIM); - if (bleveldim->count != 2) + if (bleveldim->count == 2) + blackdim = iPoint2D(bleveldim->getU32(0), bleveldim->getU32(1)); + else if (bleveldim->count != 1 || 1 != bleveldim->getU32(0)) { + writeLog(DEBUG_PRIO::EXTRA, + "BLACKLEVELREPEATDIM entry is invalid, not allowed to guess"); return false; - blackdim = iPoint2D(bleveldim->getU32(0), bleveldim->getU32(1)); + } } if (!blackdim.hasPositiveArea())