| 64 | } |
| 65 | |
| 66 | RawImage NefDecoder::decodeRawInternal() { |
| 67 | const auto* raw = mRootIFD->getIFDWithTag(CFAPATTERN); |
| 68 | auto compression = raw->getEntry(COMPRESSION)->getU32(); |
| 69 | |
| 70 | TiffEntry *offsets = raw->getEntry(STRIPOFFSETS); |
| 71 | TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS); |
| 72 | |
| 73 | if (mRootIFD->getEntryRecursive(MODEL)->getString() == "NIKON D100 ") { /**Sigh**/ |
| 74 | if (!mFile->isValid(offsets->getU32())) |
| 75 | ThrowRDE("Image data outside of file."); |
| 76 | if (!D100IsCompressed(offsets->getU32())) { |
| 77 | DecodeD100Uncompressed(); |
| 78 | return mRaw; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | if (compression == 1 || (hints.has("force_uncompressed")) || |
| 83 | NEFIsUncompressed(raw)) { |
| 84 | DecodeUncompressed(); |
| 85 | return mRaw; |
| 86 | } |
| 87 | |
| 88 | if (NEFIsUncompressedRGB(raw)) { |
| 89 | DecodeSNefUncompressed(); |
| 90 | return mRaw; |
| 91 | } |
| 92 | |
| 93 | if (offsets->count != 1) { |
| 94 | ThrowRDE("Multiple Strips found: %u", offsets->count); |
| 95 | } |
| 96 | if (counts->count != offsets->count) { |
| 97 | ThrowRDE( |
| 98 | "Byte count number does not match strip size: count:%u, strips:%u ", |
| 99 | counts->count, offsets->count); |
| 100 | } |
| 101 | if (!mFile->isValid(offsets->getU32(), counts->getU32())) |
| 102 | ThrowRDE("Invalid strip byte count. File probably truncated."); |
| 103 | |
| 104 | if (34713 != compression) |
| 105 | ThrowRDE("Unsupported compression"); |
| 106 | |
| 107 | uint32_t width = raw->getEntry(IMAGEWIDTH)->getU32(); |
| 108 | uint32_t height = raw->getEntry(IMAGELENGTH)->getU32(); |
| 109 | uint32_t bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getU32(); |
| 110 | |
| 111 | mRaw->dim = iPoint2D(width, height); |
| 112 | |
| 113 | raw = mRootIFD->getIFDWithTag(static_cast<TiffTag>(0x8c)); |
| 114 | |
| 115 | TiffEntry *meta; |
| 116 | if (raw->hasEntry(static_cast<TiffTag>(0x96))) { |
| 117 | meta = raw->getEntry(static_cast<TiffTag>(0x96)); |
| 118 | } else { |
| 119 | meta = raw->getEntry(static_cast<TiffTag>(0x8c)); // Fall back |
| 120 | } |
| 121 | |
| 122 | ByteStream rawData( |
| 123 | DataBuffer(mFile->getSubView(offsets->getU32(), counts->getU32()), |
nothing calls this directly
no test coverage detected