~ubuntu-branches/ubuntu/precise/exiv2/precise

« back to all changes in this revision

Viewing changes to src/tiffparser.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2006-12-07 18:40:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20061207184010-0ouu8v0dr8nznob9
Tags: 0.12-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
/*
22
22
  File:      tiffparser.cpp
23
 
  Version:   $Rev: 808 $
 
23
  Version:   $Rev: 866 $
24
24
  Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
25
25
  History:   15-Mar-06, ahu: created
26
26
 
27
27
 */
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 $")
31
31
 
32
32
// *****************************************************************************
33
33
// included header files
37
37
# include "exv_conf.h"
38
38
#endif
39
39
 
 
40
#include "types.hpp"
40
41
#include "tiffparser.hpp"
41
42
#include "tiffcomposite.hpp"
42
43
#include "makernote2.hpp"
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 }
129
136
    };
130
137
 
 
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      }
 
146
    };
 
147
 
 
148
    const DecoderFct TiffDecoder::findDecoder(const std::string& make, 
 
149
                                                    uint32_t     extendedTag,
 
150
                                                    uint16_t     group)
 
151
    {
 
152
        DecoderFct decoderFct = &TiffMetadataDecoder::decodeStdTiffEntry;
 
153
        const TiffDecoderInfo* td = find(tiffDecoderInfo_, 
 
154
                                         TiffDecoderInfo::Key(make, extendedTag, group));
 
155
        if (td) {
 
156
            // This may set decoderFct to 0, meaning that the tag should not be decoded
 
157
            decoderFct = td->decoderFct_;
 
158
        }
 
159
        return decoderFct;
 
160
    }
 
161
 
131
162
    TiffComponent::AutoPtr TiffCreator::create(uint32_t extendedTag,
132
163
                                               uint16_t group)
133
164
    {
144
175
        return tc;
145
176
    } // TiffCreator::create
146
177
 
147
 
    void TiffParser::decode(Image* pImage,
148
 
                            const byte* pData,
149
 
                            uint32_t size,
150
 
                            TiffCompFactoryFct createFct)
 
178
    void TiffParser::decode(Image*             pImage,
 
179
                            const byte*        pData,
 
180
                            uint32_t           size,
 
181
                            TiffCompFactoryFct createFct,
 
182
                            FindDecoderFct     findDecoderFct)
151
183
    {
152
184
        assert(pImage != 0);
153
185
        assert(pData != 0);
165
197
        TiffReader reader(pData, size, rootDir.get(), state);
166
198
        rootDir->accept(reader);
167
199
 
168
 
        TiffMetadataDecoder decoder(pImage, rootDir.get(), 4096);
 
200
        TiffMetadataDecoder decoder(pImage, rootDir.get(), findDecoderFct, 4096);
169
201
        rootDir->accept(decoder);
170
202
 
171
203
    } // TiffParser::decode