2
#include "PefDecoder.h"
4
RawSpeed - RAW file decoder.
6
Copyright (C) 2009 Klaus Post
8
This library is free software; you can redistribute it and/or
9
modify it under the terms of the GNU Lesser General Public
10
License as published by the Free Software Foundation; either
11
version 2 of the License, or (at your option) any later version.
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library; if not, write to the Free Software
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
http://www.klauspost.com
27
PefDecoder::PefDecoder(TiffIFD *rootIFD, FileMap* file) :
28
RawDecoder(file), mRootIFD(rootIFD) {
32
PefDecoder::~PefDecoder(void) {
35
RawImage PefDecoder::decodeRaw() {
36
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
39
ThrowRDE("PEF Decoder: No image data found");
41
TiffIFD* raw = data[0];
43
int compression = raw->getEntry(COMPRESSION)->getInt();
45
if (1 == compression) {
46
decodeUncompressed(raw, true);
50
if (65535 != compression)
51
ThrowRDE("PEF Decoder: Unsupported compression");
53
TiffEntry *offsets = raw->getEntry(STRIPOFFSETS);
54
TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS);
56
if (offsets->count != 1) {
57
ThrowRDE("PEF Decoder: Multiple Strips found: %u", offsets->count);
59
if (counts->count != offsets->count) {
60
ThrowRDE("PEF Decoder: Byte count number does not match strip size: count:%u, strips:%u ", counts->count, offsets->count);
62
if (!mFile->isValid(offsets->getInt() + counts->getInt()))
63
ThrowRDE("PEF Decoder: Truncated file.");
65
uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
66
uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
68
mRaw->dim = iPoint2D(width, height);
71
PentaxDecompressor l(mFile, mRaw);
72
l.decodePentax(mRootIFD, offsets->getInt(), counts->getInt());
73
} catch (IOException e) {
74
errors.push_back(_strdup(e.what()));
75
// Let's ignore it, it may have delivered somewhat useful data.
81
void PefDecoder::checkSupport(CameraMetaData *meta) {
82
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
84
ThrowRDE("PEF Support check: Model name found");
86
string make = data[0]->getEntry(MAKE)->getString();
87
string model = data[0]->getEntry(MODEL)->getString();
88
this->checkCameraSupported(meta, make, model, "");
91
void PefDecoder::decodeMetaData(CameraMetaData *meta) {
92
mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
93
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
96
ThrowRDE("PEF Meta Decoder: Model name found");
98
TiffIFD* raw = data[0];
100
string make = raw->getEntry(MAKE)->getString();
101
string model = raw->getEntry(MODEL)->getString();
103
setMetaData(meta, make, model, "");
106
} // namespace RawSpeed