22
22
File: tiffparser.cpp
24
24
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
25
25
History: 15-Mar-06, ahu: created
28
28
// *****************************************************************************
29
29
#include "rcsid.hpp"
30
EXIV2_RCSID("@(#) $Id: tiffparser.cpp 808 2006-06-01 15:09:39Z ahuggel $");
30
EXIV2_RCSID("@(#) $Id: tiffparser.cpp 866 2006-08-24 15:24:12Z ahuggel $")
32
32
// *****************************************************************************
33
33
// included header files
100
101
{ 0x8825, Group::ifd0, newTiffSubIfd, Group::gps },
101
102
{ 0xa005, Group::exif, newTiffSubIfd, Group::iop },
102
103
{ 0x927c, Group::exif, newTiffMnEntry, Group::mn },
103
{ 0x0201, Group::ifd1, newTiffThumbData, Group::ifd1 },
104
{ 0x0202, Group::ifd1, newTiffThumbSize, Group::ifd1 },
104
{ 0x0111, Group::ifd1, newTiffThumbData<0x0117, Group::ifd1>, Group::ifd1 },
105
{ 0x0117, Group::ifd1, newTiffThumbSize<0x0111, Group::ifd1>, Group::ifd1 },
106
{ 0x0201, Group::ifd1, newTiffThumbData<0x0202, Group::ifd1>, Group::ifd1 },
107
{ 0x0202, Group::ifd1, newTiffThumbSize<0x0201, Group::ifd1>, Group::ifd1 },
105
108
{ Tag::next, Group::ifd0, newTiffDirectory, Group::ifd1 },
106
109
{ Tag::next, Group::ifd1, newTiffDirectory, Group::ignr },
107
110
{ Tag::next, Group::ignr, newTiffDirectory, Group::ignr },
110
113
// Canon makernote structure
111
114
{ 0x0001, Group::canonmn, newTiffArrayEntry<2>, Group::canoncs },
112
115
{ 0x0004, Group::canonmn, newTiffArrayEntry<2>, Group::canonsi },
116
{ 0x0005, Group::canonmn, newTiffArrayEntry<2>, Group::canonpa },
113
117
{ 0x000f, Group::canonmn, newTiffArrayEntry<2>, Group::canoncf },
118
{ 0x0012, Group::canonmn, newTiffArrayEntry<2>, Group::canonpi },
114
119
{ Tag::all, Group::canoncs, newTiffArrayElement<unsignedShort>, Group::canoncs },
115
120
{ Tag::all, Group::canonsi, newTiffArrayElement<unsignedShort>, Group::canonsi },
121
{ Tag::all, Group::canonpa, newTiffArrayElement<unsignedShort>, Group::canonpa },
116
122
{ Tag::all, Group::canoncf, newTiffArrayElement<unsignedShort>, Group::canoncf },
123
{ Tag::all, Group::canonpi, newTiffArrayElement<unsignedShort>, Group::canonpi },
117
124
// Some Olympus cameras use Minolta structures
118
125
{ 0x0001, Group::olympmn, newTiffArrayEntry<4>, Group::minocso },
119
126
{ 0x0003, Group::olympmn, newTiffArrayEntry<4>, Group::minocsn },
128
135
{ Tag::all, Group::minocs5, newTiffArrayElement<unsignedShort, bigEndian>, Group::minocs5 }
138
// TIFF Decoder table for special decoding requirements, default decoder is decodeStdTiffEntry
139
const TiffDecoderInfo TiffDecoder::tiffDecoderInfo_[] = {
140
{ "*", Tag::all, Group::ignr, 0 }, // Do not decode tags with group == Group::ignr
141
{ "OLYMPUS", 0x0100, Group::olympmn, &TiffMetadataDecoder::decodeOlympThumb },
142
{ "*", 0x014a, Group::ifd0, 0 }, // Todo: Controversial, causes problems with Exiftool
143
{ "*", Tag::all, Group::sub0_0, &TiffMetadataDecoder::decodeSubIfd },
144
{ "*", Tag::all, Group::sub0_1, &TiffMetadataDecoder::decodeSubIfd },
145
{ "*", 0x8649, Group::ifd0, &TiffMetadataDecoder::decodeIrbIptc }
148
const DecoderFct TiffDecoder::findDecoder(const std::string& make,
149
uint32_t extendedTag,
152
DecoderFct decoderFct = &TiffMetadataDecoder::decodeStdTiffEntry;
153
const TiffDecoderInfo* td = find(tiffDecoderInfo_,
154
TiffDecoderInfo::Key(make, extendedTag, group));
156
// This may set decoderFct to 0, meaning that the tag should not be decoded
157
decoderFct = td->decoderFct_;
131
162
TiffComponent::AutoPtr TiffCreator::create(uint32_t extendedTag,
145
176
} // TiffCreator::create
147
void TiffParser::decode(Image* pImage,
150
TiffCompFactoryFct createFct)
178
void TiffParser::decode(Image* pImage,
181
TiffCompFactoryFct createFct,
182
FindDecoderFct findDecoderFct)
152
184
assert(pImage != 0);
153
185
assert(pData != 0);
165
197
TiffReader reader(pData, size, rootDir.get(), state);
166
198
rootDir->accept(reader);
168
TiffMetadataDecoder decoder(pImage, rootDir.get(), 4096);
200
TiffMetadataDecoder decoder(pImage, rootDir.get(), findDecoderFct, 4096);
169
201
rootDir->accept(decoder);
171
203
} // TiffParser::decode