RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2017 Roman Lebedev
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#include "adt/Casts.h"
22#ifndef PARSER
23#error PARSER must be defined
24#endif
25
26#ifndef GETDECODER
27#error GETDECODER must be defined as bool
28#endif
29
30#ifndef DECODE
31#error DECODE must be defined as bool
32#endif
33
34#include "io/Buffer.h"
35#include "io/IOException.h"
36#include "parsers/CiffParser.h" // IWYU pragma: keep
37#include "parsers/FiffParser.h" // IWYU pragma: keep
38#include "parsers/RawParser.h" // IWYU pragma: keep
40#include "parsers/TiffParser.h"
41#include <cassert>
42#include <cstdint>
43#include <cstdio>
44
45#if GETDECODER
47#if DECODE
50#include <memory>
51#endif
52#endif
53
54#if GETDECODER && DECODE
56#endif
57
58extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
59
60extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
61 assert(Data);
62
63 const rawspeed::Buffer buffer(
65
66 try {
67 rawspeed::PARSER parser(buffer);
68
69#if GETDECODER
70#if DECODE
71 auto decoder =
72#endif
73 parser.getDecoder();
74#endif
75
76#if DECODE
77 decoder->applyCrop = false;
78 decoder->interpolateBadPixels = false;
79 decoder->failOnUnknown = false;
80 // decoder->checkSupport(&metadata);
81
82 decoder->decodeRaw();
83 decoder->decodeMetaData(&metadata);
84#endif
85 } catch (const rawspeed::RawParserException&) {
86 return 0;
87#if GETDECODER
88 } catch (const rawspeed::RawDecoderException&) {
89 return 0;
90#endif
91 } catch (const rawspeed::IOException&) {
92 return 0;
93#if DECODE
94 } catch (const rawspeed::RawspeedException&) {
95 return 0;
96#endif
97 }
98
99 return 0;
100}
assert(dim.area() >=area)
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition main.cpp:60
static const rawspeed::CameraMetaData metadata
Definition main.cpp:54
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
Definition Casts.h:32