Skip to content

Commit 7d97477

Browse files
committed
ArwDecoder: LJpeg decompressor supports {2,2} MCU's, drop workaround
1 parent e2ff718 commit 7d97477

2 files changed

Lines changed: 1 addition & 43 deletions

File tree

src/librawspeed/decoders/ArwDecoder.cpp

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121

2222
#include "decoders/ArwDecoder.h"
23-
#include "MemorySanitizer.h"
2423
#include "adt/Array1DRef.h"
2524
#include "adt/Array2DRef.h"
2625
#include "adt/Casts.h"
@@ -318,17 +317,14 @@ void ArwDecoder::DecodeLJpeg(const TiffIFD* raw) {
318317
width > 9728 || height > 6656)
319318
ThrowRDE("Unexpected image dimensions found: (%u; %u)", width, height);
320319

321-
mRaw->dim = iPoint2D(2 * width, height / 2);
320+
mRaw->dim = iPoint2D(width, height);
322321

323322
auto tilew = uint64_t(raw->getEntry(TiffTag::TILEWIDTH)->getU32());
324323
uint32_t tileh = raw->getEntry(TiffTag::TILELENGTH)->getU32();
325324

326325
if (tilew <= 0 || tileh <= 0 || tileh % 2 != 0)
327326
ThrowRDE("Invalid tile size: (%" PRIu64 ", %u)", tilew, tileh);
328327

329-
tileh /= 2;
330-
tilew *= 2;
331-
332328
assert(tilew > 0);
333329
const auto tilesX =
334330
implicit_cast<uint32_t>(roundUpDivision(mRaw->dim.x, tilew));
@@ -409,48 +405,11 @@ void ArwDecoder::DecodeLJpeg(const TiffIFD* raw) {
409405
firstErr.c_str());
410406
}
411407

412-
PostProcessLJpeg();
413-
414408
const TiffEntry* size_entry = raw->getEntry(TiffTag::SONYRAWIMAGESIZE);
415409
iRectangle2D crop(0, 0, size_entry->getU32(0), size_entry->getU32(1));
416410
mRaw->subFrame(crop);
417411
}
418412

419-
void ArwDecoder::PostProcessLJpeg() {
420-
MSan::CheckMemIsInitialized(mRaw->getByteDataAsUncroppedArray2DRef());
421-
RawImage nonInterleavedRaw = mRaw;
422-
423-
invariant(nonInterleavedRaw->dim.x % 4 == 0);
424-
iPoint2D interleavedDims = {nonInterleavedRaw->dim.x / 2,
425-
2 * nonInterleavedRaw->dim.y};
426-
mRaw = RawImage::create(interleavedDims, RawImageType::UINT16, 1);
427-
428-
const Array2DRef<const uint16_t> in =
429-
nonInterleavedRaw->getU16DataAsUncroppedArray2DRef();
430-
const Array2DRef<uint16_t> out = mRaw->getU16DataAsUncroppedArray2DRef();
431-
432-
#ifdef HAVE_OPENMP
433-
#pragma omp parallel for schedule(static) default(none) firstprivate(in, out)
434-
#endif
435-
for (int inRow = 0; inRow < in.height(); ++inRow) {
436-
static constexpr iPoint2D inMCUSize = {4, 1};
437-
static constexpr iPoint2D outMCUSize = {2, 2};
438-
439-
invariant(in.width() % inMCUSize.x == 0);
440-
for (int MCUIdx = 0, numMCUsPerRow = in.width() / inMCUSize.x;
441-
MCUIdx < numMCUsPerRow; ++MCUIdx) {
442-
for (int outMCURow = 0; outMCURow != outMCUSize.y; ++outMCURow) {
443-
for (int outMCUСol = 0; outMCUСol != outMCUSize.x; ++outMCUСol) {
444-
out(outMCUSize.y * inRow + outMCURow,
445-
outMCUSize.x * MCUIdx + outMCUСol) =
446-
in(inRow,
447-
MCUIdx * inMCUSize.x + outMCUSize.x * outMCURow + outMCUСol);
448-
}
449-
}
450-
}
451-
}
452-
}
453-
454413
void ArwDecoder::DecodeARW2(ByteStream input, uint32_t w, uint32_t h,
455414
uint32_t bpp) {
456415

src/librawspeed/decoders/ArwDecoder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class ArwDecoder final : public AbstractTiffDecoder {
5454
RawImage decodeSRF();
5555
void DecodeARW2(ByteStream input, uint32_t w, uint32_t h, uint32_t bpp);
5656
void DecodeLJpeg(const TiffIFD* raw);
57-
void PostProcessLJpeg();
5857
void DecodeUncompressed(const TiffIFD* raw) const;
5958
static void SonyDecrypt(Array1DRef<const uint8_t> ibuf,
6059
Array1DRef<uint8_t> obuf, int len, uint32_t key);

0 commit comments

Comments
 (0)