| 553 | } |
| 554 | |
| 555 | void 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]; |
nothing calls this directly
no test coverage detected