4
#include "RawDecoderException.h"
6
#include "BitPumpJPEG.h" // Includes bytestream
8
#include "BitPumpMSB.h"
9
#include "BitPumpPlain.h"
10
#include "CameraMetaData.h"
14
RawSpeed - RAW file decoder.
16
Copyright (C) 2009 Klaus Post
18
This library is free software; you can redistribute it and/or
19
modify it under the terms of the GNU Lesser General Public
20
License as published by the Free Software Foundation; either
21
version 2 of the License, or (at your option) any later version.
23
This library is distributed in the hope that it will be useful,
24
but WITHOUT ANY WARRANTY; without even the implied warranty of
25
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26
Lesser General Public License for more details.
28
You should have received a copy of the GNU Lesser General Public
29
License along with this library; if not, write to the Free Software
30
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32
http://www.klauspost.com
39
/* Class with information delivered to RawDecoder::decodeThreaded() */
40
class RawDecoderThread
43
RawDecoderThread() {error = 0;};
54
/* Construct decoder instance - FileMap is a filemap of the file to be decoded */
55
/* The FileMap is not owned by this class, will not be deleted, and must remain */
56
/* valid while this object exists */
57
RawDecoder(FileMap* file);
58
virtual ~RawDecoder(void);
60
/* Check if the decoder can decode the image from this camera */
61
/* A RawDecoderException will be thrown if the camera isn't supported */
62
/* Unknown cameras does NOT generate any specific feedback */
63
/* This function must be overridden by actual decoders */
64
virtual void checkSupport(CameraMetaData *meta) = 0;
66
/* Attempt to decode the image */
67
/* A RawDecoderException will be thrown if the image cannot be decoded, */
68
/* and there will not be any data in the mRaw image. */
69
/* This function must be overridden by actual decoders. */
70
virtual RawImage decodeRaw() = 0;
72
/* This will apply metadata information from the camera database, */
73
/* such as crop, black+white level, etc. */
74
/* This function is expected to use the protected "setMetaData" */
75
/* after retrieving make, model and mode if applicate. */
76
/* If meta-data is set during load, this function can be empty. */
77
/* The image is expected to be cropped after this, but black/whitelevel */
78
/* compensation is not expected to be applied to the image */
79
virtual void decodeMetaData(CameraMetaData *meta) = 0;
81
/* Called function for filters that are capable of doing simple multi-threaded decode */
82
/* The delivered class gives information on what part of the image should be decoded. */
83
virtual void decodeThreaded(RawDecoderThread* t);
85
/* The decoded image - undefined if image has not or could not be decoded. */
86
/* Remember this is automatically refcounted, so a reference is retained until this class is destroyed */
89
/* You can set this if you do not want Rawspeed to attempt to decode images, */
90
/* where it does not have reliable information about CFA, cropping, black and white point */
91
/* It is pretty safe to leave this disabled (default behaviour), but if you do not want to */
92
/* support unknown cameras, you can enable this */
93
/* DNGs are always attempted to be decoded, so this variable has no effect on DNGs */
96
/* Vector containing silent errors that occurred doing decoding, that may have lead to */
97
/* an incomplete image. */
98
vector<const char*> errors;
102
/* Helper function for decoders - splits the image vertically and starts of decoder threads */
103
/* The function returns when all threads are done */
104
/* All errors are silently pushed into the "errors" array.*/
105
/* If all threads report an error an exception will be thrown*/
108
/* Check the camera and mode against the camera database. */
109
/* A RawDecoderException will be thrown if the camera isn't supported */
110
/* Unknown cameras does NOT generate any errors, but returns false */
111
bool checkCameraSupported(CameraMetaData *meta, string make, string model, string mode);
113
/* Helper function for decodeMetaData(), that find the camera in the CameraMetaData DB */
114
/* and sets common settings such as crop, black- white level, and sets CFA information */
115
virtual void setMetaData(CameraMetaData *meta, string make, string model, string mode);
117
/* Helper function for decoders, that will unpack uncompressed image data */
118
/* input: Input image, positioned at first pixel */
119
/* size: Size of the image to decode in pixels */
120
/* offset: offset to write the data into the final image */
121
/* inputPitch: Number of bytes between each line in the input image */
122
/* bitPerPixel: Number of bits to read for each input pixel. */
123
/* MSBOrder: true - bits are read from MSB (JPEG style) False: Read from LSB. */
124
void readUncompressedRaw(ByteStream &input, iPoint2D& size, iPoint2D& offset, int inputPitch, int bitPerPixel, bool MSBOrder);
126
/* Faster version for unpacking 12 bit LSB data */
127
void Decode12BitRaw(ByteStream &input, uint32 w, uint32 h);
129
/* Generic decompressor for uncompressed images */
130
/* MSBOrder: true - bits are read from MSB (JPEG style) False: Read from LSB. */
131
void decodeUncompressed(TiffIFD *rawIFD, bool MSBOrder);
133
/* The Raw input file to be decoded */
136
/* Decoder version - defaults to 0, but can be overridden by decoders */
137
/* This can be used to avoid newer version of an xml file to indicate that a file */
138
/* can be decoded, when a specific version of the code is needed */
139
/* Higher number in camera xml file: Files for this camera will not be decoded */
140
/* Higher number in code than xml: Image will be decoded. */
143
/* Hints set for the camera after checkCameraSupported has been called from the implementation*/
144
map<string,string> hints;
149
RawSlice() { h = offset = count = 0;};
156
} // namespace RawSpeed