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

Method decodeRawInternal

src/librawspeed/decoders/DngDecoder.cpp:334–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334RawImage DngDecoder::decodeRawInternal() {
335 vector<const TiffIFD*> data = mRootIFD->getIFDsWithTag(COMPRESSION);
336
337 if (data.empty())
338 ThrowRDE("No image data found");
339
340 dropUnsuportedChunks(&data);
341
342 if (data.empty())
343 ThrowRDE("No RAW chunks found");
344
345 if (data.size() > 1) {
346 writeLog(DEBUG_PRIO_EXTRA, "Multiple RAW chunks found - using first only!");
347 }
348
349 const TiffIFD* raw = data[0];
350
351 bps = raw->getEntry(BITSPERSAMPLE)->getU32();
352 if (bps < 1 || bps > 32)
353 ThrowRDE("Unsupported bit per sample count: %u.", bps);
354
355 uint32_t sample_format = 1;
356 if (raw->hasEntry(SAMPLEFORMAT))
357 sample_format = raw->getEntry(SAMPLEFORMAT)->getU32();
358
359 compression = raw->getEntry(COMPRESSION)->getU16();
360
361 switch (sample_format) {
362 case 1:
363 mRaw = RawImage::create(TYPE_USHORT16);
364 break;
365 case 3:
366 mRaw = RawImage::create(TYPE_FLOAT32);
367 break;
368 default:
369 ThrowRDE("Only 16 bit unsigned or float point data supported. Sample "
370 "format %u is not supported.",
371 sample_format);
372 }
373
374 mRaw->isCFA = (raw->getEntry(PHOTOMETRICINTERPRETATION)->getU16() == 32803);
375
376 if (mRaw->isCFA)
377 writeLog(DEBUG_PRIO_EXTRA, "This is a CFA image");
378 else {
379 writeLog(DEBUG_PRIO_EXTRA, "This is NOT a CFA image");
380 }
381
382 if (sample_format == 1 && bps > 16)
383 ThrowRDE("Integer precision larger than 16 bits currently not supported.");
384
385 if (sample_format == 3 && bps != 16 && bps != 24 && bps != 32)
386 ThrowRDE("Floating point must be 16/24/32 bits per sample.");
387
388 mRaw->dim.x = raw->getEntry(IMAGEWIDTH)->getU32();
389 mRaw->dim.y = raw->getEntry(IMAGELENGTH)->getU32();
390
391 if (!mRaw->dim.hasPositiveArea())

Callers

nothing calls this directly

Calls 9

writeLogFunction · 0.85
emptyMethod · 0.80
setCppMethod · 0.80
getIFDsWithTagMethod · 0.45
getU32Method · 0.45
getEntryMethod · 0.45
hasEntryMethod · 0.45
getU16Method · 0.45
hasPositiveAreaMethod · 0.45

Tested by

no test coverage detected