RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
ErfDecoder.cpp
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2009-2014 Klaus Post
5 Copyright (C) 2014 Pedro CĂ´rte-Real
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#include "decoders/ErfDecoder.h"
23#include "adt/Point.h"
25#include "common/RawImage.h"
29#include "io/Buffer.h"
30#include "io/ByteStream.h"
31#include "io/Endianness.h"
32#include "tiff/TiffEntry.h"
33#include "tiff/TiffIFD.h"
34#include "tiff/TiffTag.h"
35#include <array>
36#include <memory>
37#include <string>
38
39namespace rawspeed {
40
41class CameraMetaData;
42
44 [[maybe_unused]] Buffer file) {
45 const auto id = rootIFD->getID();
46 const std::string& make = id.make;
47
48 // FIXME: magic
49
50 return make == "SEIKO EPSON CORP.";
51}
52
54 if (width > 3040 || height > 2024)
55 ThrowRDE("Unexpected image dimensions found: (%u; %u)", width, height);
56}
57
60
64 (12 * width / 8) + ((width + 2) / 10), 12, BitOrder::MSB);
65 mRaw->createData();
66
67 u.decode12BitRawWithControl<Endianness::big>();
68
69 return mRaw;
70}
71
73 setMetaData(meta, "", 0);
74
75 if (mRootIFD->hasEntryRecursive(TiffTag::EPSONWB)) {
76 const TiffEntry* wb = mRootIFD->getEntryRecursive(TiffTag::EPSONWB);
77 if (wb->count == 256) {
78 // Magic values taken directly from dcraw
79 std::array<float, 4> wbCoeffs = {};
80 wbCoeffs[0] = static_cast<float>(wb->getU16(24)) * 508.0F * 1.078F /
81 static_cast<float>(0x10000);
82 wbCoeffs[1] = 1.0F;
83 wbCoeffs[2] = static_cast<float>(wb->getU16(25)) * 382.0F * 1.173F /
84 static_cast<float>(0x10000);
85 mRaw->metadata.wbCoeffs = wbCoeffs;
86 }
87 }
88}
89
90} // namespace rawspeed
#define ThrowRDE(...)
void setMetaData(const CameraMetaData *meta, const TiffID &id, const std::string &mode, int iso_speed)
static bool isAppropriateDecoder(const TiffRootIFD *rootIFD, Buffer file)
void decodeMetaDataInternal(const CameraMetaData *meta) override
RawImage decodeRawInternal() override
void checkImageDimensions() override
Definition TiffEntry.h:62
uint32_t count
Definition TiffEntry.h:84
uint16_t getU16(uint32_t index=0) const
TiffID getID() const
Definition TiffIFD.cpp:325
std::string make
Definition TiffIFD.h:134