RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
RawDecoder.h
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#pragma once
23
24#include "adt/Point.h"
26#include "common/RawImage.h"
27#include "io/Buffer.h"
28#include "metadata/Camera.h"
29#include <cstdint>
30#include <string>
31
32namespace rawspeed {
33
34class CameraMetaData;
35class TiffIFD;
36
38public:
39 /* Construct decoder instance - Buffer is a filemap of the file to be decoded
40 */
41 /* The Buffer is not owned by this class, will not be deleted, and must remain
42 */
43 /* valid while this object exists */
44 explicit RawDecoder(Buffer file);
45 virtual ~RawDecoder() = default;
46
47 /* Check if the decoder can decode the image from this camera */
48 /* A RawDecoderException will be thrown if the camera isn't supported */
49 /* Unknown cameras does NOT generate any specific feedback */
50 /* This function must be overridden by actual decoders */
51 void checkSupport(const CameraMetaData* meta);
52
53 /* Attempt to decode the image */
54 /* A RawDecoderException will be thrown if the image cannot be decoded, */
55 /* and there will not be any data in the mRaw image. */
57
58 /* This will apply metadata information from the camera database, */
59 /* such as crop, black+white level, etc. */
60 /* This function is expected to use the protected "setMetaData" */
61 /* after retrieving make, model and mode if applicate. */
62 /* If meta-data is set during load, this function can be empty. */
63 /* The image is expected to be cropped after this, but black/whitelevel */
64 /* compensation is not expected to be applied to the image */
65 void decodeMetaData(const CameraMetaData* meta);
66
67 /* Allows access to the root IFD structure */
68 /* If image isn't TIFF based NULL will be returned */
69 virtual TiffIFD* getRootIFD() { return nullptr; }
70
71 /* The decoded image - undefined if image has not or could not be decoded. */
72 /* Remember this is automatically refcounted, so a reference is retained until
73 * this class is destroyed */
75
76 /* You can set this if you do not want Rawspeed to attempt to decode images,
77 */
78 /* where it does not have reliable information about CFA, cropping, black and
79 * white point */
80 /* It is pretty safe to leave this disabled (default behaviour), but if you do
81 * not want to */
82 /* support unknown cameras, you can enable this */
83 /* DNGs are always attempted to be decoded, so this variable has no effect on
84 * DNGs */
85 bool failOnUnknown{false};
86
87 /* Set how to handle bad pixels. */
88 /* If you disable this parameter, no bad pixel interpolation will be done */
90
91 /* Apply stage 1 DNG opcodes. */
92 /* This usually maps out bad pixels, etc */
94
95 /* Apply crop - if false uncropped image is delivered */
96 bool applyCrop{true};
97
98 /* This will skip all corrections, and deliver the raw data */
99 /* This will skip any compression curves or other things that */
100 /* is needed to get the correct values */
101 /* Only enable if you are sure that is what you want */
103
104 /* Should Fuji images be rotated? */
105 bool fujiRotate{true};
106
107 struct {
108 /* Should Quadrant Multipliers be applied to the IIQ raws? */
110
111 // Is *any* of the corrections enabled?
112 explicit operator bool() const { return quadrantMultipliers /*|| ...*/; }
114
115 // Indicate if the cameras.xml says that the camera support status is unknown
116 // due to the lack of RPU samples
117 bool noSamples = false;
118
119protected:
120 /* Attempt to decode the image */
121 /* A RawDecoderException will be thrown if the image cannot be decoded, */
122 /* and there will not be any data in the mRaw image. */
123 /* This function must be overridden by actual decoders. */
125 virtual void decodeMetaDataInternal(const CameraMetaData* meta) = 0;
126 virtual void checkSupportInternal(const CameraMetaData* meta) = 0;
127
128 bool handleCameraSupport(const CameraMetaData* meta, const std::string& make,
129 const std::string& model, const std::string& mode);
130
131 /* Check the camera and mode against the camera database. */
132 /* A RawDecoderException will be thrown if the camera isn't supported */
133 /* Unknown cameras does NOT generate any errors, but returns false */
134 bool checkCameraSupported(const CameraMetaData* meta, const std::string& make,
135 const std::string& model, const std::string& mode);
136
137 /* Helper function for decodeMetaData(), that find the camera in the
138 * CameraMetaData DB */
139 /* and sets common settings such as crop, black- white level, and sets CFA
140 * information */
141 virtual void setMetaData(const CameraMetaData* meta, const std::string& make,
142 const std::string& model, const std::string& mode,
143 int iso_speed = 0);
144
145 /* Shall return a crop area if none is specified in the camera database
146 * entry. final this to apply camera vendor defaults (where available). */
148
149 /* Generic decompressor for uncompressed images */
150 /* order: Order of the bits - see Common.h for possibilities. */
151 void decodeUncompressed(const TiffIFD* rawIFD, BitOrder order) const;
152
153 /* The Raw input file to be decoded */
155
156 /* Decoder version */
157 /* This can be used to avoid newer version of an xml file to indicate that a
158 * file */
159 /* can be decoded, when a specific version of the code is needed */
160 /* Higher number in camera xml file: Files for this camera will not be decoded
161 */
162 /* Higher number in code than xml: Image will be decoded. */
163 [[nodiscard]] virtual int getDecoderVersion() const = 0;
164
165 /* Hints set for the camera after checkCameraSupported has been called from
166 * the implementation*/
168
169 struct RawSlice;
170};
171
177
178} // namespace rawspeed
virtual void setMetaData(const CameraMetaData *meta, const std::string &make, const std::string &model, const std::string &mode, int iso_speed=0)
virtual TiffIFD * getRootIFD()
Definition RawDecoder.h:69
void checkSupport(const CameraMetaData *meta)
RawDecoder(Buffer file)
struct rawspeed::RawDecoder::@224365236145247220354374363215210370336104332222 iiq
bool checkCameraSupported(const CameraMetaData *meta, const std::string &make, const std::string &model, const std::string &mode)
virtual void decodeMetaDataInternal(const CameraMetaData *meta)=0
bool handleCameraSupport(const CameraMetaData *meta, const std::string &make, const std::string &model, const std::string &mode)
void decodeUncompressed(const TiffIFD *rawIFD, BitOrder order) const
void decodeMetaData(const CameraMetaData *meta)
virtual int getDecoderVersion() const =0
virtual RawImage decodeRawInternal()=0
virtual void checkSupportInternal(const CameraMetaData *meta)=0
virtual iRectangle2D getDefaultCrop()
virtual ~RawDecoder()=default
static RawImage create(RawImageType type=RawImageType::UINT16)
Definition RawImage.h:265