Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::unordered_map for TiffTreeStruct lookup #2305

Merged
merged 4 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
286 changes: 142 additions & 144 deletions src/tiffimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,143 +1215,142 @@ constexpr ArrayDef samsungPwDef[] = {
With this table, it is possible, for a given group (and tag) to find a
path, i.e., a list of groups and tags, from the root to that group (tag).
*/
const TiffTreeStruct TiffCreator::tiffTreeStruct_[] = {
const TiffTreeTable TiffCreator::tiffTreeTable_ = {
// root group parent group parent tag
//--------- ----------------- ----------------- ----------
{Tag::root, IfdId::ifdIdNotSet, IfdId::ifdIdNotSet, Tag::root},
{Tag::root, IfdId::ifd0Id, IfdId::ifdIdNotSet, Tag::root},
{Tag::root, IfdId::subImage1Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::subImage2Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::subImage3Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::subImage4Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::subImage5Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::subImage6Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::subImage7Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::subImage8Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::subImage9Id, IfdId::ifd0Id, 0x014a},
{Tag::root, IfdId::exifId, IfdId::ifd0Id, 0x8769},
{Tag::root, IfdId::gpsId, IfdId::ifd0Id, 0x8825},
{Tag::root, IfdId::iopId, IfdId::exifId, 0xa005},
{Tag::root, IfdId::ifd1Id, IfdId::ifd0Id, Tag::next},
{Tag::root, IfdId::ifd2Id, IfdId::ifd1Id, Tag::next},
{Tag::root, IfdId::ifd3Id, IfdId::ifd2Id, Tag::next},
{Tag::root, IfdId::olympusId, IfdId::exifId, 0x927c},
{Tag::root, IfdId::olympus2Id, IfdId::exifId, 0x927c},
{Tag::root, IfdId::subThumb1Id, IfdId::ifd1Id, 0x014a},
{Tag::root, IfdId::olympusEqId, IfdId::olympus2Id, 0x2010},
{Tag::root, IfdId::olympusCsId, IfdId::olympus2Id, 0x2020},
{Tag::root, IfdId::olympusRdId, IfdId::olympus2Id, 0x2030},
{Tag::root, IfdId::olympusRd2Id, IfdId::olympus2Id, 0x2031},
{Tag::root, IfdId::olympusIpId, IfdId::olympus2Id, 0x2040},
{Tag::root, IfdId::olympusFiId, IfdId::olympus2Id, 0x2050},
{Tag::root, IfdId::olympusFe1Id, IfdId::olympus2Id, 0x2100},
{Tag::root, IfdId::olympusFe2Id, IfdId::olympus2Id, 0x2200},
{Tag::root, IfdId::olympusFe3Id, IfdId::olympus2Id, 0x2300},
{Tag::root, IfdId::olympusFe4Id, IfdId::olympus2Id, 0x2400},
{Tag::root, IfdId::olympusFe5Id, IfdId::olympus2Id, 0x2500},
{Tag::root, IfdId::olympusFe6Id, IfdId::olympus2Id, 0x2600},
{Tag::root, IfdId::olympusFe7Id, IfdId::olympus2Id, 0x2700},
{Tag::root, IfdId::olympusFe8Id, IfdId::olympus2Id, 0x2800},
{Tag::root, IfdId::olympusFe9Id, IfdId::olympus2Id, 0x2900},
{Tag::root, IfdId::olympusRiId, IfdId::olympus2Id, 0x3000},
{Tag::root, IfdId::fujiId, IfdId::exifId, 0x927c},
{Tag::root, IfdId::canonId, IfdId::exifId, 0x927c},
{Tag::root, IfdId::canonCsId, IfdId::canonId, 0x0001},
{Tag::root, IfdId::canonSiId, IfdId::canonId, 0x0004},
{Tag::root, IfdId::canonPaId, IfdId::canonId, 0x0005},
{Tag::root, IfdId::canonCfId, IfdId::canonId, 0x000f},
{Tag::root, IfdId::canonPiId, IfdId::canonId, 0x0012},
{Tag::root, IfdId::canonTiId, IfdId::canonId, 0x0035},
{Tag::root, IfdId::canonFiId, IfdId::canonId, 0x0093},
{Tag::root, IfdId::canonPrId, IfdId::canonId, 0x00a0},
{Tag::root, IfdId::canonAfMiAdjId, IfdId::canonId, 0x4013},
{Tag::root, IfdId::canonVigCor2Id, IfdId::canonId, 0x4016},
{Tag::root, IfdId::canonLiOpId, IfdId::canonId, 0x4018},
{Tag::root, IfdId::canonLeId, IfdId::canonId, 0x4019},
{Tag::root, IfdId::canonAmId, IfdId::canonId, 0x4020},
{Tag::root, IfdId::canonMeId, IfdId::canonId, 0x4021},
{Tag::root, IfdId::canonFilId, IfdId::canonId, 0x4024},
{Tag::root, IfdId::canonHdrId, IfdId::canonId, 0x4025},
{Tag::root, IfdId::canonAfCId, IfdId::canonId, 0x4028},
{Tag::root, IfdId::canonRawBId, IfdId::canonId, 0x403f},
{Tag::root, IfdId::nikon1Id, IfdId::exifId, 0x927c},
{Tag::root, IfdId::nikon2Id, IfdId::exifId, 0x927c},
{Tag::root, IfdId::nikon3Id, IfdId::exifId, 0x927c},
{Tag::root, IfdId::nikonPvId, IfdId::nikon3Id, 0x0011},
{Tag::root, IfdId::nikonVrId, IfdId::nikon3Id, 0x001f},
{Tag::root, IfdId::nikonPcId, IfdId::nikon3Id, 0x0023},
{Tag::root, IfdId::nikonWtId, IfdId::nikon3Id, 0x0024},
{Tag::root, IfdId::nikonIiId, IfdId::nikon3Id, 0x0025},
{Tag::root, IfdId::nikonAfId, IfdId::nikon3Id, 0x0088},
{Tag::root, IfdId::nikonSi1Id, IfdId::nikon3Id, 0x0091},
{Tag::root, IfdId::nikonSi2Id, IfdId::nikon3Id, 0x0091},
{Tag::root, IfdId::nikonSi3Id, IfdId::nikon3Id, 0x0091},
{Tag::root, IfdId::nikonSi4Id, IfdId::nikon3Id, 0x0091},
{Tag::root, IfdId::nikonSi5Id, IfdId::nikon3Id, 0x0091},
{Tag::root, IfdId::nikonSi6Id, IfdId::nikon3Id, 0x0091},
{Tag::root, IfdId::nikonCb1Id, IfdId::nikon3Id, 0x0097},
{Tag::root, IfdId::nikonCb2Id, IfdId::nikon3Id, 0x0097},
{Tag::root, IfdId::nikonCb2aId, IfdId::nikon3Id, 0x0097},
{Tag::root, IfdId::nikonCb2bId, IfdId::nikon3Id, 0x0097},
{Tag::root, IfdId::nikonCb3Id, IfdId::nikon3Id, 0x0097},
{Tag::root, IfdId::nikonCb4Id, IfdId::nikon3Id, 0x0097},
{Tag::root, IfdId::nikonLd1Id, IfdId::nikon3Id, 0x0098},
{Tag::root, IfdId::nikonLd2Id, IfdId::nikon3Id, 0x0098},
{Tag::root, IfdId::nikonLd3Id, IfdId::nikon3Id, 0x0098},
{Tag::root, IfdId::nikonLd4Id, IfdId::nikon3Id, 0x0098},
{Tag::root, IfdId::nikonMeId, IfdId::nikon3Id, 0x00b0},
{Tag::root, IfdId::nikonAf21Id, IfdId::nikon3Id, 0x00b7},
{Tag::root, IfdId::nikonAf22Id, IfdId::nikon3Id, 0x00b7},
{Tag::root, IfdId::nikonFiId, IfdId::nikon3Id, 0x00b8},
{Tag::root, IfdId::nikonAFTId, IfdId::nikon3Id, 0x00b9},
{Tag::root, IfdId::nikonFl1Id, IfdId::nikon3Id, 0x00a8},
{Tag::root, IfdId::nikonFl2Id, IfdId::nikon3Id, 0x00a8},
{Tag::root, IfdId::nikonFl3Id, IfdId::nikon3Id, 0x00a8},
{Tag::root, IfdId::nikonFl7Id, IfdId::nikon3Id, 0x00a8},
{Tag::root, IfdId::panasonicId, IfdId::exifId, 0x927c},
{Tag::root, IfdId::pentaxId, IfdId::exifId, 0x927c},
{Tag::root, IfdId::pentaxDngId, IfdId::ifd0Id, 0xc634},
{Tag::root, IfdId::samsung2Id, IfdId::exifId, 0x927c},
{Tag::root, IfdId::samsungPwId, IfdId::samsung2Id, 0x0021},
{Tag::root, IfdId::samsungPvId, IfdId::samsung2Id, 0x0035},
{Tag::root, IfdId::sigmaId, IfdId::exifId, 0x927c},
{Tag::root, IfdId::sony1Id, IfdId::exifId, 0x927c},
{Tag::root, IfdId::sony2010eId, IfdId::sony1Id, 0x2010},
{Tag::root, IfdId::sony2FpId, IfdId::sony1Id, 0x9402},
{Tag::root, IfdId::sonyMisc1Id, IfdId::sony1Id, 0x9403},
{Tag::root, IfdId::sonyMisc2bId, IfdId::sony1Id, 0x9404},
{Tag::root, IfdId::sonyMisc3cId, IfdId::sony1Id, 0x9400},
{Tag::root, IfdId::sonySInfo1Id, IfdId::sony1Id, 0x3000},
{Tag::root, IfdId::sony1CsId, IfdId::sony1Id, 0x0114},
{Tag::root, IfdId::sony1Cs2Id, IfdId::sony1Id, 0x0114},
{Tag::root, IfdId::sonyMltId, IfdId::sony1Id, 0xb028},
{Tag::root, IfdId::sony1MltCsOldId, IfdId::sonyMltId, 0x0001},
{Tag::root, IfdId::sony1MltCsNewId, IfdId::sonyMltId, 0x0003},
{Tag::root, IfdId::sony1MltCs7DId, IfdId::sonyMltId, 0x0004},
{Tag::root, IfdId::sony1MltCsA100Id, IfdId::sonyMltId, 0x0114},
{Tag::root, IfdId::sony2Id, IfdId::exifId, 0x927c},
{Tag::root, IfdId::sony2010eId, IfdId::sony2Id, 0x2010},
{Tag::root, IfdId::sony2FpId, IfdId::sony2Id, 0x9402},
{Tag::root, IfdId::sonyMisc1Id, IfdId::sony2Id, 0x9403},
{Tag::root, IfdId::sonyMisc2bId, IfdId::sony2Id, 0x9404},
{Tag::root, IfdId::sonyMisc3cId, IfdId::sony2Id, 0x9400},
{Tag::root, IfdId::sonySInfo1Id, IfdId::sony2Id, 0x3000},
{Tag::root, IfdId::sony2CsId, IfdId::sony2Id, 0x0114},
{Tag::root, IfdId::sony2Cs2Id, IfdId::sony2Id, 0x0114},
{Tag::root, IfdId::minoltaId, IfdId::exifId, 0x927c},
{Tag::root, IfdId::minoltaCsOldId, IfdId::minoltaId, 0x0001},
{Tag::root, IfdId::minoltaCsNewId, IfdId::minoltaId, 0x0003},
{Tag::root, IfdId::minoltaCs7DId, IfdId::minoltaId, 0x0004},
{Tag::root, IfdId::minoltaCs5DId, IfdId::minoltaId, 0x0114},
{Tag::root, IfdId::casioId, IfdId::exifId, 0x927c},
{Tag::root, IfdId::casio2Id, IfdId::exifId, 0x927c},
{{Tag::root, IfdId::ifdIdNotSet}, {IfdId::ifdIdNotSet, Tag::root}},
{{Tag::root, IfdId::ifd0Id}, {IfdId::ifdIdNotSet, Tag::root}},
{{Tag::root, IfdId::subImage1Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::subImage2Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::subImage3Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::subImage4Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::subImage5Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::subImage6Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::subImage7Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::subImage8Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::subImage9Id}, {IfdId::ifd0Id, 0x014a}},
{{Tag::root, IfdId::exifId}, {IfdId::ifd0Id, 0x8769}},
{{Tag::root, IfdId::gpsId}, {IfdId::ifd0Id, 0x8825}},
{{Tag::root, IfdId::iopId}, {IfdId::exifId, 0xa005}},
{{Tag::root, IfdId::ifd1Id}, {IfdId::ifd0Id, Tag::next}},
{{Tag::root, IfdId::ifd2Id}, {IfdId::ifd1Id, Tag::next}},
{{Tag::root, IfdId::ifd3Id}, {IfdId::ifd2Id, Tag::next}},
{{Tag::root, IfdId::olympusId}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::olympus2Id}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::subThumb1Id}, {IfdId::ifd1Id, 0x014a}},
{{Tag::root, IfdId::olympusEqId}, {IfdId::olympus2Id, 0x2010}},
{{Tag::root, IfdId::olympusCsId}, {IfdId::olympus2Id, 0x2020}},
{{Tag::root, IfdId::olympusRdId}, {IfdId::olympus2Id, 0x2030}},
{{Tag::root, IfdId::olympusRd2Id}, {IfdId::olympus2Id, 0x2031}},
{{Tag::root, IfdId::olympusIpId}, {IfdId::olympus2Id, 0x2040}},
{{Tag::root, IfdId::olympusFiId}, {IfdId::olympus2Id, 0x2050}},
{{Tag::root, IfdId::olympusFe1Id}, {IfdId::olympus2Id, 0x2100}},
{{Tag::root, IfdId::olympusFe2Id}, {IfdId::olympus2Id, 0x2200}},
{{Tag::root, IfdId::olympusFe3Id}, {IfdId::olympus2Id, 0x2300}},
{{Tag::root, IfdId::olympusFe4Id}, {IfdId::olympus2Id, 0x2400}},
{{Tag::root, IfdId::olympusFe5Id}, {IfdId::olympus2Id, 0x2500}},
{{Tag::root, IfdId::olympusFe6Id}, {IfdId::olympus2Id, 0x2600}},
{{Tag::root, IfdId::olympusFe7Id}, {IfdId::olympus2Id, 0x2700}},
{{Tag::root, IfdId::olympusFe8Id}, {IfdId::olympus2Id, 0x2800}},
{{Tag::root, IfdId::olympusFe9Id}, {IfdId::olympus2Id, 0x2900}},
{{Tag::root, IfdId::olympusRiId}, {IfdId::olympus2Id, 0x3000}},
{{Tag::root, IfdId::fujiId}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::canonId}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::canonCsId}, {IfdId::canonId, 0x0001}},
{{Tag::root, IfdId::canonSiId}, {IfdId::canonId, 0x0004}},
{{Tag::root, IfdId::canonPaId}, {IfdId::canonId, 0x0005}},
{{Tag::root, IfdId::canonCfId}, {IfdId::canonId, 0x000f}},
{{Tag::root, IfdId::canonPiId}, {IfdId::canonId, 0x0012}},
{{Tag::root, IfdId::canonTiId}, {IfdId::canonId, 0x0035}},
{{Tag::root, IfdId::canonFiId}, {IfdId::canonId, 0x0093}},
{{Tag::root, IfdId::canonPrId}, {IfdId::canonId, 0x00a0}},
{{Tag::root, IfdId::canonAfMiAdjId}, {IfdId::canonId, 0x4013}},
{{Tag::root, IfdId::canonVigCor2Id}, {IfdId::canonId, 0x4016}},
{{Tag::root, IfdId::canonLiOpId}, {IfdId::canonId, 0x4018}},
{{Tag::root, IfdId::canonLeId}, {IfdId::canonId, 0x4019}},
{{Tag::root, IfdId::canonAmId}, {IfdId::canonId, 0x4020}},
{{Tag::root, IfdId::canonMeId}, {IfdId::canonId, 0x4021}},
{{Tag::root, IfdId::canonFilId}, {IfdId::canonId, 0x4024}},
{{Tag::root, IfdId::canonHdrId}, {IfdId::canonId, 0x4025}},
{{Tag::root, IfdId::canonAfCId}, {IfdId::canonId, 0x4028}},
{{Tag::root, IfdId::canonRawBId}, {IfdId::canonId, 0x403f}},
{{Tag::root, IfdId::nikon1Id}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::nikon2Id}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::nikon3Id}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::nikonPvId}, {IfdId::nikon3Id, 0x0011}},
{{Tag::root, IfdId::nikonVrId}, {IfdId::nikon3Id, 0x001f}},
{{Tag::root, IfdId::nikonPcId}, {IfdId::nikon3Id, 0x0023}},
{{Tag::root, IfdId::nikonWtId}, {IfdId::nikon3Id, 0x0024}},
{{Tag::root, IfdId::nikonIiId}, {IfdId::nikon3Id, 0x0025}},
{{Tag::root, IfdId::nikonAfId}, {IfdId::nikon3Id, 0x0088}},
{{Tag::root, IfdId::nikonSi1Id}, {IfdId::nikon3Id, 0x0091}},
{{Tag::root, IfdId::nikonSi2Id}, {IfdId::nikon3Id, 0x0091}},
{{Tag::root, IfdId::nikonSi3Id}, {IfdId::nikon3Id, 0x0091}},
{{Tag::root, IfdId::nikonSi4Id}, {IfdId::nikon3Id, 0x0091}},
{{Tag::root, IfdId::nikonSi5Id}, {IfdId::nikon3Id, 0x0091}},
{{Tag::root, IfdId::nikonSi6Id}, {IfdId::nikon3Id, 0x0091}},
{{Tag::root, IfdId::nikonCb1Id}, {IfdId::nikon3Id, 0x0097}},
{{Tag::root, IfdId::nikonCb2Id}, {IfdId::nikon3Id, 0x0097}},
{{Tag::root, IfdId::nikonCb2aId}, {IfdId::nikon3Id, 0x0097}},
{{Tag::root, IfdId::nikonCb2bId}, {IfdId::nikon3Id, 0x0097}},
{{Tag::root, IfdId::nikonCb3Id}, {IfdId::nikon3Id, 0x0097}},
{{Tag::root, IfdId::nikonCb4Id}, {IfdId::nikon3Id, 0x0097}},
{{Tag::root, IfdId::nikonLd1Id}, {IfdId::nikon3Id, 0x0098}},
{{Tag::root, IfdId::nikonLd2Id}, {IfdId::nikon3Id, 0x0098}},
{{Tag::root, IfdId::nikonLd3Id}, {IfdId::nikon3Id, 0x0098}},
{{Tag::root, IfdId::nikonLd4Id}, {IfdId::nikon3Id, 0x0098}},
{{Tag::root, IfdId::nikonMeId}, {IfdId::nikon3Id, 0x00b0}},
{{Tag::root, IfdId::nikonAf21Id}, {IfdId::nikon3Id, 0x00b7}},
{{Tag::root, IfdId::nikonAf22Id}, {IfdId::nikon3Id, 0x00b7}},
{{Tag::root, IfdId::nikonFiId}, {IfdId::nikon3Id, 0x00b8}},
{{Tag::root, IfdId::nikonAFTId}, {IfdId::nikon3Id, 0x00b9}},
{{Tag::root, IfdId::nikonFl1Id}, {IfdId::nikon3Id, 0x00a8}},
{{Tag::root, IfdId::nikonFl2Id}, {IfdId::nikon3Id, 0x00a8}},
{{Tag::root, IfdId::nikonFl3Id}, {IfdId::nikon3Id, 0x00a8}},
{{Tag::root, IfdId::nikonFl7Id}, {IfdId::nikon3Id, 0x00a8}},
{{Tag::root, IfdId::panasonicId}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::pentaxId}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::pentaxDngId}, {IfdId::ifd0Id, 0xc634}},
{{Tag::root, IfdId::samsung2Id}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::samsungPwId}, {IfdId::samsung2Id, 0x0021}},
{{Tag::root, IfdId::samsungPvId}, {IfdId::samsung2Id, 0x0035}},
{{Tag::root, IfdId::sigmaId}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::sony1Id}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::sony2010eId}, {IfdId::sony1Id, 0x2010}},
{{Tag::root, IfdId::sony2FpId}, {IfdId::sony1Id, 0x9402}},
{{Tag::root, IfdId::sonyMisc1Id}, {IfdId::sony1Id, 0x9403}},
{{Tag::root, IfdId::sonyMisc2bId}, {IfdId::sony1Id, 0x9404}},
{{Tag::root, IfdId::sonyMisc3cId}, {IfdId::sony1Id, 0x9400}},
{{Tag::root, IfdId::sonySInfo1Id}, {IfdId::sony1Id, 0x3000}},
{{Tag::root, IfdId::sony1CsId}, {IfdId::sony1Id, 0x0114}},
{{Tag::root, IfdId::sony1Cs2Id}, {IfdId::sony1Id, 0x0114}},
{{Tag::root, IfdId::sonyMltId}, {IfdId::sony1Id, 0xb028}},
{{Tag::root, IfdId::sony1MltCsOldId}, {IfdId::sonyMltId, 0x0001}},
{{Tag::root, IfdId::sony1MltCsNewId}, {IfdId::sonyMltId, 0x0003}},
{{Tag::root, IfdId::sony1MltCs7DId}, {IfdId::sonyMltId, 0x0004}},
{{Tag::root, IfdId::sony1MltCsA100Id}, {IfdId::sonyMltId, 0x0114}},
{{Tag::root, IfdId::sony2Id}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::sony2010eId}, {IfdId::sony2Id, 0x2010}},
{{Tag::root, IfdId::sony2FpId}, {IfdId::sony2Id, 0x9402}},
{{Tag::root, IfdId::sonyMisc1Id}, {IfdId::sony2Id, 0x9403}},
{{Tag::root, IfdId::sonyMisc2bId}, {IfdId::sony2Id, 0x9404}},
{{Tag::root, IfdId::sonyMisc3cId}, {IfdId::sony2Id, 0x9400}},
{{Tag::root, IfdId::sonySInfo1Id}, {IfdId::sony2Id, 0x3000}},
{{Tag::root, IfdId::sony2CsId}, {IfdId::sony2Id, 0x0114}},
{{Tag::root, IfdId::sony2Cs2Id}, {IfdId::sony2Id, 0x0114}},
{{Tag::root, IfdId::minoltaId}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::minoltaCsOldId}, {IfdId::minoltaId, 0x0001}},
{{Tag::root, IfdId::minoltaCsNewId}, {IfdId::minoltaId, 0x0003}},
{{Tag::root, IfdId::minoltaCs7DId}, {IfdId::minoltaId, 0x0004}},
{{Tag::root, IfdId::minoltaCs5DId}, {IfdId::minoltaId, 0x0114}},
{{Tag::root, IfdId::casioId}, {IfdId::exifId, 0x927c}},
{{Tag::root, IfdId::casio2Id}, {IfdId::exifId, 0x927c}},
// ---------------------------------------------------------
// Panasonic RW2 raw images
{Tag::pana, IfdId::ifdIdNotSet, IfdId::ifdIdNotSet, Tag::pana},
{Tag::pana, IfdId::panaRawId, IfdId::ifdIdNotSet, Tag::pana},
{Tag::pana, IfdId::exifId, IfdId::panaRawId, 0x8769},
{Tag::pana, IfdId::gpsId, IfdId::panaRawId, 0x8825},
};
{{Tag::pana, IfdId::ifdIdNotSet}, {IfdId::ifdIdNotSet, Tag::pana}},
{{Tag::pana, IfdId::panaRawId}, {IfdId::ifdIdNotSet, Tag::pana}},
{{Tag::pana, IfdId::exifId}, {IfdId::panaRawId, 0x8769}},
{{Tag::pana, IfdId::gpsId}, {IfdId::panaRawId, 0x8825}}};

/*
This table describes the layout of each known TIFF group (including
Expand Down Expand Up @@ -1941,10 +1940,6 @@ EncoderFct TiffMapping::findEncoder(const std::string& make, uint32_t extendedTa
return encoderFct;
}

bool TiffTreeStruct::operator==(const TiffTreeStruct::Key& key) const {
return key.first == root_ && key.second == group_;
}

TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag, IfdId group) {
auto tag = static_cast<uint16_t>(extendedTag & 0xffff);
auto i = tiffGroupTable_.find(TiffGroupKey(extendedTag, group));
Expand All @@ -1969,13 +1964,16 @@ TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag, IfdId group)
} // TiffCreator::create

void TiffCreator::getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root) {
const TiffTreeStruct* ts = nullptr;
do {
tiffPath.push(TiffPathItem(extendedTag, group));
ts = find(tiffTreeStruct_, TiffTreeStruct::Key(root, group));
extendedTag = ts->parentExtTag_;
group = ts->parentGroup_;
} while (!(ts->root_ == root && ts->group_ == IfdId::ifdIdNotSet));
while (true) {
tiffPath.emplace(extendedTag, group);
const auto ts = tiffTreeTable_.find(TiffGroupKey(root, group));
assert(ts != tiffTreeTable_.end());
extendedTag = ts->second.second;
group = ts->second.first;
if (ts->first == TiffGroupKey(root, IfdId::ifdIdNotSet)) {
break;
}
}
}

ByteOrder TiffParserWorker::decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
Expand Down
17 changes: 4 additions & 13 deletions src/tiffimage_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,8 @@ using TiffGroupTable = std::unordered_map<TiffGroupKey, NewTiffCompFct, TiffGrou
Multiple trees are needed as TIFF-based RAW image formats do not always
use standard TIFF layout.
*/
struct TiffTreeStruct {
using Key = std::pair<uint32_t, IfdId>;
//! Comparison operator to compare a TiffTreeStruct with a TiffTreeStruct::Key
bool operator==(const Key& key) const;

// DATA
uint32_t root_; //!< Tree root element, identifies a tree
IfdId group_; //!< Each group is a node in the tree
IfdId parentGroup_; //!< Parent group
uint32_t parentExtTag_; //!< Parent tag (32 bit so that it can contain special tags)
};
using TiffTreeParent = std::pair<IfdId, uint32_t>; // Parent group, parent tag
using TiffTreeTable = std::unordered_map<TiffGroupKey, TiffTreeParent, TiffGroupKey_hash>;

/*!
@brief TIFF component factory.
Expand All @@ -186,8 +177,8 @@ class TiffCreator {
static void getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root);

private:
static const TiffTreeStruct tiffTreeStruct_[]; //<! TIFF tree structure
static const TiffGroupTable tiffGroupTable_; //<! TIFF group structure
static const TiffTreeTable tiffTreeTable_; //<! TIFF tree structure
static const TiffGroupTable tiffGroupTable_; //<! TIFF group structure

}; // class TiffCreator

Expand Down