RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
DcsDecoder.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) 2015 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/DcsDecoder.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 <cassert>
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 == "KODAK";
51}
52
54 if (width > 3072 || height > 2048)
55 ThrowRDE("Unexpected image dimensions found: (%u; %u)", width, height);
56}
57
60
61 const TiffEntry* linearization =
62 mRootIFD->getEntryRecursive(TiffTag::GRAYRESPONSECURVE);
63 if (!linearization || linearization->count != 256 ||
64 linearization->type != TiffDataType::SHORT)
65 ThrowRDE("Couldn't find the linearization table");
66
67 assert(linearization != nullptr);
68 auto table = linearization->getU16Array(256);
69
70 RawImageCurveGuard curveHandler(&mRaw, table, uncorrectedRawValues);
71
74 mRaw, iRectangle2D({0, 0}, iPoint2D(width, height)), 8 * width / 8, 8,
76 mRaw->createData();
77
79 u.decode8BitRaw<true>();
80 else
81 u.decode8BitRaw<false>();
82
83 return mRaw;
84}
85
87 setMetaData(meta, "", 0);
88}
89
90} // namespace rawspeed
#define ThrowRDE(...)
assert(dim.area() >=area)
void setMetaData(const CameraMetaData *meta, const TiffID &id, const std::string &mode, int iso_speed)
static bool RAWSPEED_READONLY isAppropriateDecoder(const TiffRootIFD *rootIFD, Buffer file)
RawImage decodeRawInternal() override
void checkImageDimensions() override
void decodeMetaDataInternal(const CameraMetaData *meta) override
Definition TiffEntry.h:62
std::vector< uint16_t > getU16Array(uint32_t count_) const
Definition TiffEntry.h:107
uint32_t count
Definition TiffEntry.h:84
TiffDataType type
Definition TiffEntry.h:83
TiffID getID() const
Definition TiffIFD.cpp:325
std::string make
Definition TiffIFD.h:134