RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
RawParser.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) 2017 Axel Waggershauser
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 "
parsers/RawParser.h
"
23
#include "
decoders/MrwDecoder.h
"
24
#include "
decoders/NakedDecoder.h
"
25
#include "
decoders/RafDecoder.h
"
26
#include "
decoders/RawDecoder.h
"
27
#include "
decoders/RawDecoderException.h
"
28
#include "
io/Buffer.h
"
29
#include "
metadata/CameraMetaData.h
"
30
#include "
parsers/CiffParser.h
"
31
#include "
parsers/CiffParserException.h
"
32
#include "
parsers/FiffParser.h
"
33
#include "
parsers/FiffParserException.h
"
34
#include "
parsers/TiffParser.h
"
35
#include "
parsers/TiffParserException.h
"
36
#include <memory>
37
38
namespace
rawspeed
{
39
40
class
Camera
;
41
42
std::unique_ptr<RawDecoder>
RawParser::getDecoder
(
const
CameraMetaData
* meta) {
43
// We need some data.
44
// For now it is 104 bytes for RAF/FUJIFIM images.
45
// FIXME: each decoder/parser should check it on their own.
46
if
(
mInput
.getSize() <= 104)
47
ThrowRDE
(
"File too small"
);
48
49
// MRW images are easy to check for, let's try that first
50
if
(
MrwDecoder::isMRW
(
mInput
)) {
51
try
{
52
return
std::make_unique<MrwDecoder>(
mInput
);
53
}
catch
(
const
RawDecoderException
&) {
// NOLINT(bugprone-empty-catch)
54
// Yes, just ignore the exception.
55
}
56
}
57
58
// FUJI has pointers to IFD's at fixed byte offsets
59
// So if camera is FUJI, we cannot use ordinary TIFF parser
60
if
(
RafDecoder::isRAF
(
mInput
)) {
61
try
{
62
FiffParser
p(
mInput
);
63
return
p.getDecoder(meta);
64
}
catch
(
const
FiffParserException
&) {
// NOLINT(bugprone-empty-catch)
65
// Yes, just ignore the exception.
66
}
67
}
68
69
// Ordinary TIFF images
70
try
{
71
TiffParser
p(
mInput
);
72
return
p.getDecoder(meta);
73
}
catch
(
const
TiffParserException
&) {
// NOLINT(bugprone-empty-catch)
74
// Yes, just ignore the exception.
75
}
76
77
// CIFF images
78
try
{
79
CiffParser
p(
mInput
);
80
return
p.getDecoder(meta);
81
}
catch
(
const
CiffParserException
&) {
// NOLINT(bugprone-empty-catch)
82
// Yes, just ignore the exception.
83
}
84
85
// Detect camera on filesize (CHDK).
86
if
(meta !=
nullptr
&& meta->
hasChdkCamera
(
mInput
.getSize())) {
87
const
Camera
* c = meta->
getChdkCamera
(
mInput
.getSize());
88
89
try
{
90
return
std::make_unique<NakedDecoder>(
mInput
, c);
91
}
catch
(
const
RawDecoderException
&) {
// NOLINT(bugprone-empty-catch)
92
// Yes, just ignore the exception.
93
}
94
}
95
96
// File could not be decoded, so no further options for now.
97
ThrowRDE
(
"No decoder found. Sorry."
);
98
}
99
100
}
// namespace rawspeed
Buffer.h
CameraMetaData.h
CiffParser.h
CiffParserException.h
FiffParser.h
FiffParserException.h
MrwDecoder.h
NakedDecoder.h
RafDecoder.h
RawDecoder.h
RawDecoderException.h
ThrowRDE
#define ThrowRDE(...)
Definition
RawDecoderException.h:37
RawParser.h
TiffParser.h
TiffParserException.h
rawspeed::Camera
Definition
Camera.h:77
rawspeed::CameraMetaData
Definition
CameraMetaData.h:47
rawspeed::CameraMetaData::getChdkCamera
const Camera *RAWSPEED_READONLY getChdkCamera(uint32_t filesize) const
Definition
CameraMetaData.cpp:122
rawspeed::CameraMetaData::hasChdkCamera
bool RAWSPEED_READONLY hasChdkCamera(uint32_t filesize) const
Definition
CameraMetaData.cpp:127
rawspeed::CiffParserException
Definition
CiffParserException.h:32
rawspeed::CiffParser
Definition
CiffParser.h:34
rawspeed::FiffParserException
Definition
FiffParserException.h:30
rawspeed::FiffParser
Definition
FiffParser.h:33
rawspeed::MrwDecoder::isMRW
static int isMRW(Buffer input)
Definition
MrwDecoder.cpp:47
rawspeed::RafDecoder::isRAF
static bool isRAF(Buffer input)
Definition
RafDecoder.cpp:52
rawspeed::RawDecoderException
Definition
RawDecoderException.h:30
rawspeed::RawParser::getDecoder
virtual std::unique_ptr< RawDecoder > getDecoder(const CameraMetaData *meta=nullptr)
Definition
RawParser.cpp:42
rawspeed::RawParser::mInput
Buffer mInput
Definition
RawParser.h:40
rawspeed::TiffParserException
Definition
TiffParserException.h:31
rawspeed::TiffParser
Definition
TiffParser.h:37
rawspeed
Definition
CoalescingOutputIteratorBenchmark.cpp:35
librawspeed
parsers
RawParser.cpp
Generated by
1.15.0