| 52 | } |
| 53 | |
| 54 | Buffer KdcDecoder::getInputBuffer() { |
| 55 | TiffEntry* offset = mRootIFD->getEntryRecursive(KODAK_KDC_OFFSET); |
| 56 | if (!offset || offset->count < 13) |
| 57 | ThrowRDE("Couldn't find the KDC offset"); |
| 58 | |
| 59 | assert(offset != nullptr); |
| 60 | uint64_t off = uint64_t(offset->getU32(4)) + uint64_t(offset->getU32(12)); |
| 61 | if (off > std::numeric_limits<uint32_t>::max()) |
| 62 | ThrowRDE("Offset is too large."); |
| 63 | |
| 64 | // Offset hardcoding gotten from dcraw |
| 65 | if (hints.has("easyshare_offset_hack")) |
| 66 | off = off < 0x15000 ? 0x15000 : 0x17000; |
| 67 | |
| 68 | if (off > mFile->getSize()) |
| 69 | ThrowRDE("offset is out of bounds"); |
| 70 | |
| 71 | const auto area = mRaw->dim.area(); |
| 72 | if (area > std::numeric_limits<decltype(area)>::max() / 12) // round down |
| 73 | ThrowRDE("Image dimensions are way too large, potential for overflow"); |
| 74 | |
| 75 | const auto bits = 12 * area; |
| 76 | if (bits % 8 != 0) |
| 77 | ThrowRDE("Bad combination of image dims and bpp, bit count %% 8 != 0"); |
| 78 | const auto bytes = bits / 8; |
| 79 | |
| 80 | return mFile->getSubView(off, bytes); |
| 81 | } |
| 82 | |
| 83 | RawImage KdcDecoder::decodeRawInternal() { |
| 84 | if (!mRootIFD->hasEntryRecursive(COMPRESSION)) |
nothing calls this directly
no test coverage detected