RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
LJpegDecoder.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
22#include "adt/Casts.h"
23#include "common/RawImage.h"
25#include "fuzz/Common.h"
26#include "io/Buffer.h"
27#include "io/ByteStream.h"
28#include "io/Endianness.h"
29#include <cassert>
30#include <cstdint>
31#include <cstdio>
32
33extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
34
35extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
36 assert(Data);
37
38 try {
39 const rawspeed::Buffer b(
43
45
46 const auto offsetX = bs.getU32();
47 const auto offsetY = bs.getU32();
48 const auto width = bs.getU32();
49 const auto height = bs.getU32();
50 const auto maxWidth = bs.getU32();
51 const auto maxHeight = bs.getU32();
52 const auto fixDng16Bug = bs.getU32();
53
54 rawspeed::LJpegDecoder j(bs, mRaw);
55 mRaw->createData();
56 j.decode(offsetX, offsetY, width, height,
57 rawspeed::iPoint2D(maxWidth, maxHeight), fixDng16Bug);
58
59 // we can not check that all the image was initialized, because normally
60 // LJpegDecoder decodes just some one tile/slice.
61 } catch (const rawspeed::RawspeedException&) { // NOLINT(bugprone-empty-catch)
62 // Exceptions are good, crashes are bad.
63 }
64
65 return 0;
66}
assert(dim.area() >=area)
void decode(uint32_t offsetX, uint32_t offsetY, uint32_t width, uint32_t height, iPoint2D maxDim, bool fixDng16Bug_)
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
rawspeed::RawImage CreateRawImage(rawspeed::ByteStream &bs)
Definition Common.cpp:31
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
Definition Casts.h:32