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
"
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 <array>
36
#include <memory>
37
#include <string>
38
39
namespace
rawspeed
{
40
41
class
CameraMetaData
;
42
43
bool
ErfDecoder::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 ==
"SEIKO EPSON CORP."
;
51
}
52
53
void
ErfDecoder::checkImageDimensions
() {
54
if
(
width
> 3040 ||
height
> 2024)
55
ThrowRDE
(
"Unexpected image dimensions found: (%u; %u)"
,
width
,
height
);
56
}
57
58
RawImage
ErfDecoder::decodeRawInternal
() {
59
SimpleTiffDecoder::prepareForRawDecoding
();
60
61
UncompressedDecompressor
u(
62
ByteStream
(
DataBuffer
(
mFile
.getSubView(
off
,
c2
),
Endianness::little
)),
63
mRaw
,
iRectangle2D
({0, 0},
iPoint2D
(
width
,
height
)),
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
72
void
ErfDecoder::decodeMetaDataInternal
(
const
CameraMetaData
* meta) {
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
BitStreams.h
Buffer.h
ByteStream.h
Endianness.h
ErfDecoder.h
Point.h
RawDecoderException.h
ThrowRDE
#define ThrowRDE(...)
Definition
RawDecoderException.h:37
RawImage.h
SimpleTiffDecoder.h
TiffEntry.h
TiffIFD.h
TiffTag.h
UncompressedDecompressor.h
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::ErfDecoder::isAppropriateDecoder
static bool isAppropriateDecoder(const TiffRootIFD *rootIFD, Buffer file)
Definition
ErfDecoder.cpp:43
rawspeed::ErfDecoder::decodeMetaDataInternal
void decodeMetaDataInternal(const CameraMetaData *meta) override
Definition
ErfDecoder.cpp:72
rawspeed::ErfDecoder::decodeRawInternal
RawImage decodeRawInternal() override
Definition
ErfDecoder.cpp:58
rawspeed::ErfDecoder::checkImageDimensions
void checkImageDimensions() override
Definition
ErfDecoder.cpp:53
rawspeed::RawDecoder::mFile
Buffer mFile
Definition
RawDecoder.h:154
rawspeed::RawDecoder::mRaw
RawImage mRaw
Definition
RawDecoder.h:74
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::count
uint32_t count
Definition
TiffEntry.h:84
rawspeed::TiffEntry::getU16
uint16_t getU16(uint32_t index=0) const
Definition
TiffEntry.cpp:187
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::BitOrder::MSB
@ MSB
Definition
BitStreams.h:30
rawspeed::TiffTag::EPSONWB
@ EPSONWB
Definition
TiffTag.h:120
rawspeed::Endianness::little
@ little
Definition
Endianness.h:32
rawspeed::Endianness::big
@ big
Definition
Endianness.h:33
rawspeed::TiffID::make
std::string make
Definition
TiffIFD.h:134
librawspeed
decoders
ErfDecoder.cpp
Generated by
1.15.0