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

Method decodeData

src/librawspeed/decoders/DngDecoder.cpp:268–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268void DngDecoder::decodeData(const TiffIFD* raw, uint32_t sample_format) {
269 if (compression == 8 && sample_format != 3) {
270 ThrowRDE("Only float format is supported for "
271 "deflate-compressed data.");
272 } else if ((compression == 7 || compression == 0x884c) &&
273 sample_format != 1) {
274 ThrowRDE("Only 16 bit unsigned data supported for "
275 "JPEG-compressed data.");
276 }
277
278 uint32_t predictor = ~0U;
279 if (raw->hasEntry(PREDICTOR))
280 predictor = raw->getEntry(PREDICTOR)->getU32();
281
282 // Some decompressors (such as VC5) may depend on the white point
283 if (raw->hasEntry(WHITELEVEL)) {
284 TiffEntry* whitelevel = raw->getEntry(WHITELEVEL);
285 if (whitelevel->isInt())
286 mRaw->whitePoint = whitelevel->getU32();
287 }
288
289 AbstractDngDecompressor slices(mRaw, getTilingDescription(raw), compression,
290 mFixLjpeg, bps, predictor);
291
292 slices.slices.reserve(slices.dsc.numTiles);
293
294 TiffEntry* offsets = nullptr;
295 TiffEntry* counts = nullptr;
296 if (raw->hasEntry(TILEOFFSETS)) {
297 offsets = raw->getEntry(TILEOFFSETS);
298 counts = raw->getEntry(TILEBYTECOUNTS);
299 } else { // Strips
300 offsets = raw->getEntry(STRIPOFFSETS);
301 counts = raw->getEntry(STRIPBYTECOUNTS);
302 }
303 assert(slices.dsc.numTiles == offsets->count);
304 assert(slices.dsc.numTiles == counts->count);
305
306 NORangesSet<Buffer> tilesLegality;
307 for (auto n = 0U; n < slices.dsc.numTiles; n++) {
308 const auto offset = offsets->getU32(n);
309 const auto count = counts->getU32(n);
310
311 if (count < 1)
312 ThrowRDE("Tile %u is empty", n);
313
314 ByteStream bs(DataBuffer(mFile->getSubView(offset, count),
315 mRootIFD->rootBuffer.getByteOrder()));
316
317 if (!tilesLegality.emplace(bs).second)
318 ThrowTPE("Two tiles overlap. Raw corrupt!");
319
320 slices.slices.emplace_back(slices.dsc, n, bs);
321 }
322
323 assert(slices.slices.size() == slices.dsc.numTiles);
324 if (slices.slices.empty())
325 ThrowRDE("No valid slices found.");

Callers

nothing calls this directly

Calls 10

getSubViewMethod · 0.80
getByteOrderMethod · 0.80
emptyMethod · 0.80
createDataMethod · 0.80
DataBufferClass · 0.50
hasEntryMethod · 0.45
getU32Method · 0.45
getEntryMethod · 0.45
isIntMethod · 0.45
decompressMethod · 0.45

Tested by

no test coverage detected