MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / decodeArray

Method decodeArray

src/crwimage_int.cpp:681–743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

679} // CrwMap::decode0x080a
680
681void CrwMap::decodeArray(const CiffComponent& ciffComponent, const CrwMapping* pCrwMapping, Image& image,
682 ByteOrder byteOrder) {
683 if (ciffComponent.typeId() != unsignedShort) {
684 return decodeBasic(ciffComponent, pCrwMapping, image, byteOrder);
685 }
686
687 int64_t aperture = 0;
688 int64_t shutterSpeed = 0;
689
690 IfdId ifdId = IfdId::ifdIdNotSet;
691 switch (pCrwMapping->tag_) {
692 case 0x0001:
693 ifdId = IfdId::canonCsId;
694 break;
695 case 0x0004:
696 ifdId = IfdId::canonSiId;
697 break;
698 case 0x000f:
699 ifdId = IfdId::canonCfId;
700 break;
701 case 0x0012:
702 ifdId = IfdId::canonPiId;
703 break;
704 }
705
706 std::string groupName(Internal::groupName(ifdId));
707 const size_t component_size = ciffComponent.size();
708 enforce(component_size % 2 == 0, ErrorCode::kerCorruptedMetadata);
709 enforce(component_size / 2 <= static_cast<size_t>(std::numeric_limits<uint16_t>::max()),
710 ErrorCode::kerCorruptedMetadata);
711 const auto num_components = static_cast<uint16_t>(component_size / 2);
712 uint16_t c = 1;
713 while (c < num_components) {
714 uint16_t n = 1;
715 ExifKey key(c, groupName);
716 UShortValue value;
717 if (ifdId == IfdId::canonCsId && c == 23 && component_size >= 52)
718 n = 3;
719 value.read(ciffComponent.pData() + c * 2, n * 2, byteOrder);
720 image.exifData().add(key, &value);
721 if (ifdId == IfdId::canonSiId && c == 21)
722 aperture = value.toInt64();
723 if (ifdId == IfdId::canonSiId && c == 22)
724 shutterSpeed = value.toInt64();
725 c += n;
726 }
727
728 if (ifdId == IfdId::canonSiId) {
729 // Exif.Photo.FNumber
730 float f = fnumber(canonEv(aperture));
731 auto [r, s] = floatToRationalCast(f);
732 auto ur = URational(r, s);
733 URationalValue fn;
734 fn.value_.push_back(ur);
735 image.exifData().add(ExifKey("Exif.Photo.FNumber"), &fn);
736
737 // Exif.Photo.ExposureTime
738 ur = exposureTime(canonEv(shutterSpeed));

Callers

nothing calls this directly

Calls 13

groupNameFunction · 0.85
enforceFunction · 0.85
fnumberFunction · 0.85
canonEvFunction · 0.85
floatToRationalCastFunction · 0.85
ExifKeyClass · 0.85
exposureTimeFunction · 0.70
typeIdMethod · 0.45
sizeMethod · 0.45
readMethod · 0.45
pDataMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected