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

Method decodeMetaDataInternal

src/librawspeed/decoders/DngDecoder.cpp:555–615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555void DngDecoder::decodeMetaDataInternal(const CameraMetaData* meta) {
556 if (mRootIFD->hasEntryRecursive(ISOSPEEDRATINGS))
557 mRaw->metadata.isoSpeed = mRootIFD->getEntryRecursive(ISOSPEEDRATINGS)->getU32();
558
559 TiffID id;
560
561 try {
562 id = mRootIFD->getID();
563 } catch (RawspeedException& e) {
564 mRaw->setError(e.what());
565 // not all dngs have MAKE/MODEL entries,
566 // will be dealt with by using UNIQUECAMERAMODEL below
567 }
568
569 // Set the make and model
570 mRaw->metadata.make = id.make;
571 mRaw->metadata.model = id.model;
572
573 const Camera* cam = meta->getCamera(id.make, id.model, "dng");
574 if (!cam) //Also look for non-DNG cameras in case it's a converted file
575 cam = meta->getCamera(id.make, id.model, "");
576 if (!cam) // Worst case scenario, look for any such camera.
577 cam = meta->getCamera(id.make, id.model);
578 if (cam) {
579 mRaw->metadata.canonical_make = cam->canonical_make;
580 mRaw->metadata.canonical_model = cam->canonical_model;
581 mRaw->metadata.canonical_alias = cam->canonical_alias;
582 mRaw->metadata.canonical_id = cam->canonical_id;
583 } else {
584 mRaw->metadata.canonical_make = id.make;
585 mRaw->metadata.canonical_model = mRaw->metadata.canonical_alias = id.model;
586 if (mRootIFD->hasEntryRecursive(UNIQUECAMERAMODEL)) {
587 mRaw->metadata.canonical_id = mRootIFD->getEntryRecursive(UNIQUECAMERAMODEL)->getString();
588 } else {
589 mRaw->metadata.canonical_id = id.make + " " + id.model;
590 }
591 }
592
593 // Fetch the white balance
594 if (mRootIFD->hasEntryRecursive(ASSHOTNEUTRAL)) {
595 TiffEntry* as_shot_neutral = mRootIFD->getEntryRecursive(ASSHOTNEUTRAL);
596 if (as_shot_neutral->count == 3) {
597 for (uint32_t i = 0; i < 3; i++) {
598 float c = as_shot_neutral->getFloat(i);
599 mRaw->metadata.wbCoeffs[i] = (c > 0.0F) ? (1.0F / c) : 0.0F;
600 }
601 }
602 } else if (mRootIFD->hasEntryRecursive(ASSHOTWHITEXY)) {
603 TiffEntry* as_shot_white_xy = mRootIFD->getEntryRecursive(ASSHOTWHITEXY);
604 if (as_shot_white_xy->count == 2) {
605 mRaw->metadata.wbCoeffs[0] = as_shot_white_xy->getFloat(0);
606 mRaw->metadata.wbCoeffs[1] = as_shot_white_xy->getFloat(1);
607 mRaw->metadata.wbCoeffs[2] =
608 1 - mRaw->metadata.wbCoeffs[0] - mRaw->metadata.wbCoeffs[1];
609
610 const std::array<float, 3> d65_white = {{0.950456, 1, 1.088754}};
611 for (uint32_t i = 0; i < 3; i++)
612 mRaw->metadata.wbCoeffs[i] /= d65_white[i];

Callers

nothing calls this directly

Calls 8

getIDMethod · 0.80
setErrorMethod · 0.80
getCameraMethod · 0.80
hasEntryRecursiveMethod · 0.45
getU32Method · 0.45
getEntryRecursiveMethod · 0.45
getStringMethod · 0.45
getFloatMethod · 0.45

Tested by

no test coverage detected