MCPcopy Create free account
hub / github.com/darktable-org/rawspeed / getInputBuffer

Method getInputBuffer

src/librawspeed/decoders/KdcDecoder.cpp:54–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54Buffer 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
83RawImage KdcDecoder::decodeRawInternal() {
84 if (!mRootIFD->hasEntryRecursive(COMPRESSION))

Callers

nothing calls this directly

Calls 6

hasMethod · 0.80
getSubViewMethod · 0.80
getEntryRecursiveMethod · 0.45
getU32Method · 0.45
getSizeMethod · 0.45
areaMethod · 0.45

Tested by

no test coverage detected