|
20 | 20 | */ |
21 | 21 |
|
22 | 22 | #include "decoders/ArwDecoder.h" |
23 | | -#include "MemorySanitizer.h" |
24 | 23 | #include "adt/Array1DRef.h" |
25 | 24 | #include "adt/Array2DRef.h" |
26 | 25 | #include "adt/Casts.h" |
@@ -318,17 +317,14 @@ void ArwDecoder::DecodeLJpeg(const TiffIFD* raw) { |
318 | 317 | width > 9728 || height > 6656) |
319 | 318 | ThrowRDE("Unexpected image dimensions found: (%u; %u)", width, height); |
320 | 319 |
|
321 | | - mRaw->dim = iPoint2D(2 * width, height / 2); |
| 320 | + mRaw->dim = iPoint2D(width, height); |
322 | 321 |
|
323 | 322 | auto tilew = uint64_t(raw->getEntry(TiffTag::TILEWIDTH)->getU32()); |
324 | 323 | uint32_t tileh = raw->getEntry(TiffTag::TILELENGTH)->getU32(); |
325 | 324 |
|
326 | 325 | if (tilew <= 0 || tileh <= 0 || tileh % 2 != 0) |
327 | 326 | ThrowRDE("Invalid tile size: (%" PRIu64 ", %u)", tilew, tileh); |
328 | 327 |
|
329 | | - tileh /= 2; |
330 | | - tilew *= 2; |
331 | | - |
332 | 328 | assert(tilew > 0); |
333 | 329 | const auto tilesX = |
334 | 330 | implicit_cast<uint32_t>(roundUpDivision(mRaw->dim.x, tilew)); |
@@ -409,48 +405,11 @@ void ArwDecoder::DecodeLJpeg(const TiffIFD* raw) { |
409 | 405 | firstErr.c_str()); |
410 | 406 | } |
411 | 407 |
|
412 | | - PostProcessLJpeg(); |
413 | | - |
414 | 408 | const TiffEntry* size_entry = raw->getEntry(TiffTag::SONYRAWIMAGESIZE); |
415 | 409 | iRectangle2D crop(0, 0, size_entry->getU32(0), size_entry->getU32(1)); |
416 | 410 | mRaw->subFrame(crop); |
417 | 411 | } |
418 | 412 |
|
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 | | - |
454 | 413 | void ArwDecoder::DecodeARW2(ByteStream input, uint32_t w, uint32_t h, |
455 | 414 | uint32_t bpp) { |
456 | 415 |
|
|
0 commit comments