From 6919d9e8acc884f15b4d37cdb493ac8e207842ee Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Fri, 21 Oct 2022 23:17:56 +0300 Subject: [PATCH] `RawImageDataU16::calculateBlackAreas()`: port to `Array2DRef` See also https://github.com/darktable-org/rawspeed/issues/389 --- src/librawspeed/common/RawImageDataU16.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librawspeed/common/RawImageDataU16.cpp b/src/librawspeed/common/RawImageDataU16.cpp index 8d851cff8..17371acef 100644 --- a/src/librawspeed/common/RawImageDataU16.cpp +++ b/src/librawspeed/common/RawImageDataU16.cpp @@ -57,6 +57,8 @@ RawImageDataU16::RawImageDataU16(const iPoint2D& _dim, uint32_t _cpp) } void RawImageDataU16::calculateBlackAreas() { + const Array2DRef img = getU16DataAsUncroppedArray2DRef(); + vector histogram(4 * 65536); fill(histogram.begin(), histogram.end(), 0); @@ -73,11 +75,10 @@ void RawImageDataU16::calculateBlackAreas() { uncropped_dim.y) ThrowRDE("Offset + size is larger than height of image"); for (uint32_t y = area.offset; y < area.offset + area.size; y++) { - const auto* pixel = - reinterpret_cast(getDataUncropped(mOffset.x, y)); auto* localhist = &histogram[(y & 1) * (65536UL * 2UL)]; for (int x = mOffset.x; x < dim.x+mOffset.x; x++) { - const auto hBin = ((x & 1) << 16) + *pixel; + // FIXME: this only samples a single row, not an area. + const auto hBin = ((x & 1) << 16) + img(y, mOffset.x); localhist[hBin]++; } } @@ -89,12 +90,11 @@ void RawImageDataU16::calculateBlackAreas() { if (static_cast(area.offset) + static_cast(area.size) > uncropped_dim.x) ThrowRDE("Offset + size is larger than width of image"); - for (int y = mOffset.y; y < dim.y+mOffset.y; y++) { - const auto* pixel = - reinterpret_cast(getDataUncropped(area.offset, y)); + for (int y = mOffset.y; y < dim.y + mOffset.y; y++) { auto* localhist = &histogram[(y & 1) * (65536UL * 2UL)]; for (uint32_t x = area.offset; x < area.size + area.offset; x++) { - const auto hBin = ((x & 1) << 16) + *pixel; + // FIXME: this only samples a single row, not an area. + const auto hBin = ((x & 1) << 16) + img(y, area.offset); localhist[hBin]++; } }