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

Method decodeMetaDataInternal

src/librawspeed/decoders/NefDecoder.cpp:473–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471 0xb3, 0x61, 0x7f, 0x2f}};
472
473void NefDecoder::decodeMetaDataInternal(const CameraMetaData* meta) {
474 int iso = 0;
475 mRaw->cfa.setCFA(iPoint2D(2,2), CFA_RED, CFA_GREEN, CFA_GREEN, CFA_BLUE);
476
477 int white = mRaw->whitePoint;
478 int black = mRaw->blackLevel;
479
480 if (mRootIFD->hasEntryRecursive(ISOSPEEDRATINGS))
481 iso = mRootIFD->getEntryRecursive(ISOSPEEDRATINGS)->getU32();
482
483 // Read the whitebalance
484
485 if (mRootIFD->hasEntryRecursive(static_cast<TiffTag>(12))) {
486 TiffEntry* wb = mRootIFD->getEntryRecursive(static_cast<TiffTag>(12));
487 if (wb->count == 4) {
488 mRaw->metadata.wbCoeffs[0] = wb->getFloat(0);
489 mRaw->metadata.wbCoeffs[1] = wb->getFloat(2);
490 mRaw->metadata.wbCoeffs[2] = wb->getFloat(1);
491 if (mRaw->metadata.wbCoeffs[1] <= 0.0F)
492 mRaw->metadata.wbCoeffs[1] = 1.0F;
493 }
494 } else if (mRootIFD->hasEntryRecursive(static_cast<TiffTag>(0x0097))) {
495 TiffEntry* wb = mRootIFD->getEntryRecursive(static_cast<TiffTag>(0x0097));
496 if (wb->count > 4) {
497 uint32_t version = 0;
498 for (uint32_t i = 0; i < 4; i++) {
499 const auto v = wb->getByte(i);
500 if (v < '0' || v > '9')
501 ThrowRDE("Bad version component: %c - not a digit", v);
502 version = (version << 4) + v - '0';
503 }
504
505 if (version == 0x100 && wb->count >= 80 && wb->type == TIFF_UNDEFINED) {
506 mRaw->metadata.wbCoeffs[0] = static_cast<float>(wb->getU16(36));
507 mRaw->metadata.wbCoeffs[2] = static_cast<float>(wb->getU16(37));
508 mRaw->metadata.wbCoeffs[1] = static_cast<float>(wb->getU16(38));
509 } else if (version == 0x103 && wb->count >= 26 && wb->type == TIFF_UNDEFINED) {
510 mRaw->metadata.wbCoeffs[0] = static_cast<float>(wb->getU16(10));
511 mRaw->metadata.wbCoeffs[1] = static_cast<float>(wb->getU16(11));
512 mRaw->metadata.wbCoeffs[2] = static_cast<float>(wb->getU16(12));
513 } else if (((version == 0x204 && wb->count >= 564) ||
514 (version == 0x205 && wb->count >= 284)) &&
515 mRootIFD->hasEntryRecursive(static_cast<TiffTag>(0x001d)) &&
516 mRootIFD->hasEntryRecursive(static_cast<TiffTag>(0x00a7))) {
517 // Get the serial number
518 string serial =
519 mRootIFD->getEntryRecursive(static_cast<TiffTag>(0x001d))
520 ->getString();
521 if (serial.length() > 9)
522 ThrowRDE("Serial number is too long (%zu)", serial.length());
523 uint32_t serialno = 0;
524 for (unsigned char c : serial) {
525 if (c >= '0' && c <= '9')
526 serialno = serialno*10 + c-'0';
527 else
528 serialno = serialno*10 + c%10;
529 }
530

Callers

nothing calls this directly

Calls 15

getU16BEFunction · 0.85
setCFAMethod · 0.80
setByteOrderMethod · 0.80
hasPatternAtMethod · 0.80
hasMethod · 0.80
getIDMethod · 0.80
hasCameraMethod · 0.80
iPoint2DClass · 0.70
hasEntryRecursiveMethod · 0.45
getU32Method · 0.45
getEntryRecursiveMethod · 0.45
getFloatMethod · 0.45

Tested by

no test coverage detected