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
"
24
#include "
bitstreams/BitStreams.h
"
25
#include "
common/RawImage.h
"
26
#include "
decoders/RawDecoderException.h
"
27
#include "
decoders/SimpleTiffDecoder.h
"
28
#include "
decompressors/UncompressedDecompressor.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
39
namespace
rawspeed
{
40
41
class
CameraMetaData
;
42
43
bool
DcsDecoder::isAppropriateDecoder
(
const
TiffRootIFD
* rootIFD,
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
53
void
DcsDecoder::checkImageDimensions
() {
54
if
(
width
> 3072 ||
height
> 2048)
55
ThrowRDE
(
"Unexpected image dimensions found: (%u; %u)"
,
width
,
height
);
56
}
57
58
RawImage
DcsDecoder::decodeRawInternal
() {
59
SimpleTiffDecoder::prepareForRawDecoding
();
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
72
UncompressedDecompressor
u(
73
ByteStream
(
DataBuffer
(
mFile
.getSubView(
off
,
c2
),
Endianness::little
)),
74
mRaw
,
iRectangle2D
({0, 0},
iPoint2D
(
width
,
height
)), 8 *
width
/ 8, 8,
75
BitOrder::LSB
);
76
mRaw
->createData();
77
78
if
(
uncorrectedRawValues
)
79
u.decode8BitRaw<
true
>();
80
else
81
u.decode8BitRaw<
false
>();
82
83
return
mRaw
;
84
}
85
86
void
DcsDecoder::decodeMetaDataInternal
(
const
CameraMetaData
* meta) {
87
setMetaData
(meta,
""
, 0);
88
}
89
90
}
// namespace rawspeed
BitStreams.h
Buffer.h
ByteStream.h
DcsDecoder.h
Endianness.h
Point.h
RawDecoderException.h
ThrowRDE
#define ThrowRDE(...)
Definition
RawDecoderException.h:37
RawImage.h
SimpleTiffDecoder.h
TiffEntry.h
TiffIFD.h
TiffTag.h
UncompressedDecompressor.h
assert
assert(dim.area() >=area)
rawspeed::AbstractTiffDecoder::setMetaData
void setMetaData(const CameraMetaData *meta, const TiffID &id, const std::string &mode, int iso_speed)
Definition
AbstractTiffDecoder.h:55
rawspeed::AbstractTiffDecoder::mRootIFD
TiffRootIFDOwner mRootIFD
Definition
AbstractTiffDecoder.h:40
rawspeed::Buffer
Definition
Buffer.h:47
rawspeed::ByteStream
Definition
ByteStream.h:43
rawspeed::CameraMetaData
Definition
CameraMetaData.h:47
rawspeed::DataBuffer
Definition
Buffer.h:133
rawspeed::DcsDecoder::isAppropriateDecoder
static bool RAWSPEED_READONLY isAppropriateDecoder(const TiffRootIFD *rootIFD, Buffer file)
Definition
DcsDecoder.cpp:43
rawspeed::DcsDecoder::decodeRawInternal
RawImage decodeRawInternal() override
Definition
DcsDecoder.cpp:58
rawspeed::DcsDecoder::checkImageDimensions
void checkImageDimensions() override
Definition
DcsDecoder.cpp:53
rawspeed::DcsDecoder::decodeMetaDataInternal
void decodeMetaDataInternal(const CameraMetaData *meta) override
Definition
DcsDecoder.cpp:86
rawspeed::RawDecoder::uncorrectedRawValues
bool uncorrectedRawValues
Definition
RawDecoder.h:102
rawspeed::RawDecoder::mFile
Buffer mFile
Definition
RawDecoder.h:154
rawspeed::RawDecoder::mRaw
RawImage mRaw
Definition
RawDecoder.h:74
rawspeed::RawImageCurveGuard
Definition
RawImage.h:365
rawspeed::RawImage
Definition
RawImage.h:247
rawspeed::SimpleTiffDecoder::off
uint32_t off
Definition
SimpleTiffDecoder.h:50
rawspeed::SimpleTiffDecoder::c2
uint32_t c2
Definition
SimpleTiffDecoder.h:51
rawspeed::SimpleTiffDecoder::prepareForRawDecoding
void prepareForRawDecoding()
Definition
SimpleTiffDecoder.cpp:39
rawspeed::SimpleTiffDecoder::height
uint32_t height
Definition
SimpleTiffDecoder.h:49
rawspeed::SimpleTiffDecoder::width
uint32_t width
Definition
SimpleTiffDecoder.h:48
rawspeed::TiffEntry
Definition
TiffEntry.h:62
rawspeed::TiffEntry::getU16Array
std::vector< uint16_t > getU16Array(uint32_t count_) const
Definition
TiffEntry.h:107
rawspeed::TiffEntry::count
uint32_t count
Definition
TiffEntry.h:84
rawspeed::TiffEntry::type
TiffDataType type
Definition
TiffEntry.h:83
rawspeed::TiffRootIFD
Definition
TiffIFD.h:138
rawspeed::TiffRootIFD::getID
TiffID getID() const
Definition
TiffIFD.cpp:325
rawspeed::UncompressedDecompressor
Definition
UncompressedDecompressor.h:37
rawspeed::iPoint2D
Definition
Point.h:35
rawspeed::iRectangle2D
Definition
Point.h:107
rawspeed
Definition
CoalescingOutputIteratorBenchmark.cpp:35
rawspeed::TiffDataType::SHORT
@ SHORT
Definition
TiffEntry.h:49
rawspeed::BitOrder::LSB
@ LSB
Definition
BitStreams.h:29
rawspeed::TiffTag::GRAYRESPONSECURVE
@ GRAYRESPONSECURVE
Definition
TiffTag.h:63
rawspeed::Endianness::little
@ little
Definition
Endianness.h:32
rawspeed::TiffID::make
std::string make
Definition
TiffIFD.h:134
librawspeed
decoders
DcsDecoder.cpp
Generated by
1.15.0