Skip to content

Commit 16e56c4

Browse files
committed
AbstractDngDecompressor: add JPEG XL specialization
1 parent 49fea25 commit 16e56c4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/librawspeed/decompressors/AbstractDngDecompressor.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
#include "decompressors/JpegDecompressor.h"
5050
#endif
5151

52+
#ifdef HAVE_JXL
53+
#include "decompressors/JpegXLDecompressor.h"
54+
#endif
55+
5256
namespace rawspeed {
5357

5458
template <> void AbstractDngDecompressor::decompressThread<1>() const noexcept {
@@ -201,6 +205,29 @@ void AbstractDngDecompressor::decompressThread<0x884c>() const noexcept {
201205
}
202206
#endif
203207

208+
#ifdef HAVE_JXL
209+
template <>
210+
void AbstractDngDecompressor::decompressThread<0xcd42>() const noexcept {
211+
#ifdef HAVE_OPENMP
212+
#pragma omp for schedule(static)
213+
#endif
214+
for (const auto& e :
215+
Array1DRef(slices.data(), implicit_cast<int>(slices.size()))) {
216+
try {
217+
JpegXLDecompressor j(e.bs.peekBuffer(e.bs.getRemainSize()), mRaw);
218+
j.decode(e.offX, e.offY);
219+
} catch (const RawDecoderException& err) {
220+
mRaw->setError(err.what());
221+
} catch (const IOException& err) {
222+
mRaw->setError(err.what());
223+
} catch (...) {
224+
// We should not get any other exception type here.
225+
__builtin_unreachable();
226+
}
227+
}
228+
}
229+
#endif
230+
204231
void AbstractDngDecompressor::decompressThread() const noexcept {
205232
invariant(mRaw->dim.x > 0);
206233
invariant(mRaw->dim.y > 0);
@@ -232,6 +259,14 @@ void AbstractDngDecompressor::decompressThread() const noexcept {
232259
#else
233260
#pragma message "JPEG is not present! Lossy JPEG DNG will not be supported!"
234261
mRaw->setError("jpeg support is disabled.");
262+
#endif
263+
} else if (compression == 0xcd42) {
264+
/* Lossy DNG */
265+
#ifdef HAVE_JXL
266+
decompressThread<0xcd42>();
267+
#else
268+
#pragma message "JPEG XL is not present! JPEG XL DNG will not be supported!"
269+
mRaw->setError("jpeg xl support is disabled.");
235270
#endif
236271
} else
237272
mRaw->setError("AbstractDngDecompressor: Unknown compression");

0 commit comments

Comments
 (0)