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
21
#include "
decompressors/LJpegDecoder.h
"
22
#include "
adt/Casts.h
"
23
#include "
common/RawImage.h
"
24
#include "
common/RawspeedException.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
33
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t* Data,
size_t
Size);
34
35
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t* Data,
size_t
Size) {
36
assert
(Data);
37
38
try
{
39
const
rawspeed::Buffer
b(
40
Data,
rawspeed::implicit_cast<rawspeed::Buffer::size_type>
(Size));
41
const
rawspeed::DataBuffer
db(b,
rawspeed::Endianness::little
);
42
rawspeed::ByteStream
bs(db);
43
44
rawspeed::RawImage
mRaw(
CreateRawImage
(bs));
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
}
Buffer.h
ByteStream.h
Casts.h
Endianness.h
LJpegDecoder.h
RawImage.h
RawspeedException.h
assert
assert(dim.area() >=area)
rawspeed::Buffer
Definition
Buffer.h:47
rawspeed::ByteStream
Definition
ByteStream.h:43
rawspeed::ByteStream::getU32
uint32_t getU32()
Definition
ByteStream.h:196
rawspeed::DataBuffer
Definition
Buffer.h:133
rawspeed::LJpegDecoder
Definition
LJpegDecoder.h:34
rawspeed::LJpegDecoder::decode
void decode(uint32_t offsetX, uint32_t offsetY, uint32_t width, uint32_t height, iPoint2D maxDim, bool fixDng16Bug_)
Definition
LJpegDecoder.cpp:66
rawspeed::RawImageData::createData
void createData()
Definition
RawImage.cpp:68
rawspeed::RawImage
Definition
RawImage.h:247
rawspeed::RawspeedException
Definition
RawspeedException.h:56
rawspeed::iPoint2D
Definition
Point.h:35
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition
LJpegDecoder.cpp:35
CreateRawImage
rawspeed::RawImage CreateRawImage(rawspeed::ByteStream &bs)
Definition
Common.cpp:31
Common.h
rawspeed::implicit_cast
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
Definition
Casts.h:32
rawspeed::Endianness::little
@ little
Definition
Endianness.h:32
fuzz
librawspeed
decompressors
LJpegDecoder.cpp
Generated by
1.15.0