diff --git a/src/librawspeed/decompressors/LJpegDecompressor.cpp b/src/librawspeed/decompressors/LJpegDecompressor.cpp index 9c0602db3..9c4015ef2 100644 --- a/src/librawspeed/decompressors/LJpegDecompressor.cpp +++ b/src/librawspeed/decompressors/LJpegDecompressor.cpp @@ -167,7 +167,7 @@ std::array LJpegDecompressor::getInitialPreds() const { return preds; } -template +template void LJpegDecompressor::decodeRowN( Array1DRef outRow, std::array pred, std::array>, N_COMP> ht, @@ -187,10 +187,7 @@ void LJpegDecompressor::decodeRowN( } // Sometimes we also need to consume one more block, and produce part of it. - if /*constexpr*/ (WeirdWidth) { - // FIXME: evaluate i-cache implications due to this being compile-time. - static_assert(N_COMP > 1 || !WeirdWidth, - "can't want part of 1-pixel-wide block"); + if (trailingPixels != 0) { // Some rather esoteric DNG's have odd dimensions, e.g. width % 2 = 1. // We may end up needing just part of last N_COMP pixels. invariant(trailingPixels > 0); @@ -218,8 +215,7 @@ void LJpegDecompressor::decodeRowN( } // N_COMP == number of components (2, 3 or 4) -template -ByteStream::size_type LJpegDecompressor::decodeN() const { +template ByteStream::size_type LJpegDecompressor::decodeN() const { invariant(mRaw->getCpp() > 0); invariant(N_COMP > 0); @@ -292,7 +288,7 @@ ByteStream::size_type LJpegDecompressor::decodeN() const { /*index=*/0) .getAsArray1DRef(); - decodeRowN(outRow, pred, ht, bs); + decodeRowN(outRow, pred, ht, bs); } inputStream.skipBytes(bs.getStreamPosition()); @@ -302,34 +298,17 @@ ByteStream::size_type LJpegDecompressor::decodeN() const { } ByteStream::size_type LJpegDecompressor::decode() const { - if (trailingPixels == 0) { - switch (frame.cps) { - case 1: - return decodeN<1>(); - case 2: - return decodeN<2>(); - case 3: - return decodeN<3>(); - case 4: - return decodeN<4>(); - default: - __builtin_unreachable(); - } - } else /* trailingPixels != 0 */ { - // FIXME: using different function just for one tile likely causes - // i-cache misses and whatnot. Need to check how not splitting it into - // two different functions affects performance of the normal case. - switch (frame.cps) { - // Naturally can't happen for CPS=1. - case 2: - return decodeN<2, /*WeirdWidth=*/true>(); - case 3: - return decodeN<3, /*WeirdWidth=*/true>(); - case 4: - return decodeN<4, /*WeirdWidth=*/true>(); - default: - __builtin_unreachable(); - } + switch (frame.cps) { + case 1: + return decodeN<1>(); + case 2: + return decodeN<2>(); + case 3: + return decodeN<3>(); + case 4: + return decodeN<4>(); + default: + __builtin_unreachable(); } } diff --git a/src/librawspeed/decompressors/LJpegDecompressor.h b/src/librawspeed/decompressors/LJpegDecompressor.h index 14abeb320..18aef77f0 100644 --- a/src/librawspeed/decompressors/LJpegDecompressor.h +++ b/src/librawspeed/decompressors/LJpegDecompressor.h @@ -75,14 +75,13 @@ class LJpegDecompressor final { template [[nodiscard]] std::array getInitialPreds() const; - template + template __attribute__((always_inline)) inline void decodeRowN( Array1DRef outRow, std::array pred, std::array>, N_COMP> ht, BitStreamerJPEG& bs) const; - template - [[nodiscard]] ByteStream::size_type decodeN() const; + template [[nodiscard]] ByteStream::size_type decodeN() const; public: LJpegDecompressor(RawImage img, iRectangle2D imgFrame, Frame frame,