Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiframe DNGs #350

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cscope.out
*.vcproj
*.vcxproj
.vscode/
CMakeLists.txt.user

# Compiled Object files
*.slo
Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/Cr2Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

using slice_type = uint16_t;
const auto numSlices = bs.get<slice_type>();
Expand All @@ -48,7 +48,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {

const rawspeed::Cr2Slicing slicing(numSlices, sliceWidth, lastSliceWidth);

rawspeed::Cr2Decompressor c(bs, mRaw);
rawspeed::Cr2Decompressor c(bs, mRaw.get());
mRaw->createData();
c.decode(slicing);

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/CrwDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const uint32_t dec_table = bs.getU32();
const uint32_t lowbits = bs.getU32();

rawspeed::CrwDecompressor c(mRaw, dec_table, lowbits,
rawspeed::CrwDecompressor c(mRaw.get(), dec_table, lowbits,
bs.getStream(bs.getRemainSize()));
mRaw->createData();
c.decompress();
Expand Down
6 changes: 3 additions & 3 deletions fuzz/librawspeed/decompressors/DummyLJpegDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DummyLJpegDecompressor final

public:
DummyLJpegDecompressor(const rawspeed::ByteStream& bs,
const rawspeed::RawImage& img)
rawspeed::RawImageData* img)
: AbstractLJpegDecompressor(bs, img) {}

void decode() { AbstractLJpegDecompressor::decode(); }
Expand All @@ -55,9 +55,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

DummyLJpegDecompressor d(bs, mRaw);
DummyLJpegDecompressor d(bs, mRaw.get());
d.decode();
mRaw->createData();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/FujiDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));
mRaw->cfa = CreateCFA(bs);

rawspeed::FujiDecompressor f(mRaw, bs.getStream(bs.getRemainSize()));
rawspeed::FujiDecompressor f(mRaw.get(), bs.getStream(bs.getRemainSize()));
mRaw->createData();
f.decompress();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/HasselbladDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto pixelBaseOffset = bs.get<int>();

rawspeed::HasselbladDecompressor h(bs, mRaw);
rawspeed::HasselbladDecompressor h(bs, mRaw.get());
mRaw->createData();
h.decode(pixelBaseOffset);

Expand Down
6 changes: 3 additions & 3 deletions fuzz/librawspeed/decompressors/KodakDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const bool bps = bs.getU32();
const bool uncorrectedRawValues = bs.getU32();

rawspeed::KodakDecompressor k(mRaw, bs.getStream(bs.getRemainSize()), bps,
uncorrectedRawValues);
rawspeed::KodakDecompressor k(mRaw.get(), bs.getStream(bs.getRemainSize()),
bps, uncorrectedRawValues);

mRaw->createData();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/LJpegDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto offsetX = bs.getU32();
const auto offsetY = bs.getU32();
const auto width = bs.getU32();
const auto height = bs.getU32();
const auto fixDng16Bug = bs.getU32();

rawspeed::LJpegDecompressor j(bs, mRaw);
rawspeed::LJpegDecompressor j(bs, mRaw.get());
mRaw->createData();
j.decode(offsetX, offsetY, width, height, fixDng16Bug);

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/NikonDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto bitsPS = bs.get<uint32_t>();
const auto uncorrectedRawValues = bs.get<uint32_t>();
const auto medataLength = bs.get<uint32_t>();
rawspeed::ByteStream metaData = bs.getStream(medataLength);
rawspeed::ByteStream rawData = bs.getStream(bs.getRemainSize());

rawspeed::NikonDecompressor n(mRaw, metaData, bitsPS);
rawspeed::NikonDecompressor n(mRaw.get(), metaData, bitsPS);
mRaw->createData();
n.decompress(rawData, uncorrectedRawValues);

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/OlympusDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

rawspeed::OlympusDecompressor o(mRaw);
rawspeed::OlympusDecompressor o(mRaw.get());

mRaw->createData();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/PanasonicV4Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto zero_is_not_bad = bs.get<uint32_t>();
const auto section_split_offset = bs.get<uint32_t>();
rawspeed::ByteStream rawData = bs.getStream(bs.getRemainSize());

rawspeed::PanasonicV4Decompressor p(mRaw, rawData, zero_is_not_bad,
rawspeed::PanasonicV4Decompressor p(mRaw.get(), rawData, zero_is_not_bad,
section_split_offset);
mRaw->createData();
p.decompress();
Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/PanasonicV5Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto bps = bs.get<uint32_t>();
rawspeed::ByteStream rawData = bs.getStream(bs.getRemainSize());

rawspeed::PanasonicV5Decompressor p(mRaw, rawData, bps);
rawspeed::PanasonicV5Decompressor p(mRaw.get(), rawData, bps);
mRaw->createData();
p.decompress();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/PanasonicV6Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

rawspeed::ByteStream rawData = bs.getStream(bs.getRemainSize());

rawspeed::PanasonicV6Decompressor p(mRaw, rawData);
rawspeed::PanasonicV6Decompressor p(mRaw.get(), rawData);
mRaw->createData();
p.decompress();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/PentaxDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

std::optional<rawspeed::ByteStream> metaData;

Expand All @@ -51,7 +51,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {

rawspeed::ByteStream rawData = bs.getStream(bs.getRemainSize());

rawspeed::PentaxDecompressor p(mRaw, metaData);
rawspeed::PentaxDecompressor p(mRaw.get(), metaData);
mRaw->createData();
p.decompress(rawData);

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/PhaseOneDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto numStrips = bs.getU32();
std::vector<rawspeed::PhaseOneStrip> strips;
Expand All @@ -53,7 +53,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
});
assert(strips.size() == numStrips);

rawspeed::PhaseOneDecompressor f(mRaw, std::move(strips));
rawspeed::PhaseOneDecompressor f(mRaw.get(), std::move(strips));
mRaw->createData();
f.decompress();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/SamsungV0Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto bsoLength = bs.get<uint32_t>();
rawspeed::ByteStream bso = bs.getStream(bsoLength);
rawspeed::ByteStream bsr = bs.getStream(bs.getRemainSize());

rawspeed::SamsungV0Decompressor p(mRaw, bso, bsr);
rawspeed::SamsungV0Decompressor p(mRaw.get(), bso, bsr);
mRaw->createData();
p.decompress();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/SamsungV1Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto bit = bs.get<uint32_t>();
rawspeed::ByteStream rawData = bs.getStream(bs.getRemainSize());

rawspeed::SamsungV1Decompressor p(mRaw, rawData, bit);
rawspeed::SamsungV1Decompressor p(mRaw.get(), rawData, bit);
mRaw->createData();
p.decompress();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/SamsungV2Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

const auto bit = bs.get<uint32_t>();
rawspeed::ByteStream rawData = bs.getStream(bs.getRemainSize());

rawspeed::SamsungV2Decompressor p(mRaw, rawData, bit);
rawspeed::SamsungV2Decompressor p(mRaw.get(), rawData, bit);
mRaw->createData();
p.decompress();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/SonyArw1Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

rawspeed::SonyArw1Decompressor a(mRaw);
rawspeed::SonyArw1Decompressor a(mRaw.get());

mRaw->createData();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/SonyArw2Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));

rawspeed::SonyArw2Decompressor a(mRaw, bs.getStream(bs.getRemainSize()));
rawspeed::SonyArw2Decompressor a(mRaw.get(), bs.getStream(bs.getRemainSize()));

mRaw->createData();

Expand Down
4 changes: 2 additions & 2 deletions fuzz/librawspeed/decompressors/VC5Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);

rawspeed::RawImage mRaw(CreateRawImage(bs));
auto mRaw(CreateRawImage(bs));
mRaw->whitePoint = bs.getI32();

const auto offsetX = bs.getU32();
const auto offsetY = bs.getU32();
const auto width = bs.getU32();
const auto height = bs.getU32();

rawspeed::VC5Decompressor v(bs, mRaw);
rawspeed::VC5Decompressor v(bs, mRaw.get());
mRaw->createData();
v.decode(offsetX, offsetY, width, height);

Expand Down
14 changes: 11 additions & 3 deletions fuzz/librawspeed/fuzz/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <cstdint> // for uint32_t
#include <limits> // for numeric_limits

rawspeed::RawImage CreateRawImage(rawspeed::ByteStream& bs) {
std::shared_ptr<rawspeed::RawImageData> CreateRawImage(rawspeed::ByteStream& bs) {
const uint32_t width = bs.getU32();
const uint32_t height = bs.getU32();
const uint32_t type = bs.getU32();
Expand All @@ -40,8 +40,16 @@ rawspeed::RawImage CreateRawImage(rawspeed::ByteStream& bs) {
type != static_cast<uint32_t>(rawspeed::RawImageType::F32))
ThrowRSE("Unknown image type: %u", type);

rawspeed::RawImage mRaw(
rawspeed::RawImage::create(static_cast<rawspeed::RawImageType>(type)));
/*rawspeed::RawImage mRaw(
rawspeed::RawImage::create(static_cast<rawspeed::RawImageType>(type)));*/
std::shared_ptr<rawspeed::RawImageData> mRaw;

if(type != static_cast<uint32_t>(rawspeed::RawImageType::UINT16))
mRaw = std::make_shared<rawspeed::RawImageDataU16>();

if(type != static_cast<uint32_t>(rawspeed::RawImageType::F32))
mRaw = std::make_shared<rawspeed::RawImageDataFloat>();


mRaw->dim =
rawspeed::iPoint2D(static_cast<rawspeed::iPoint2D::value_type>(width),
Expand Down
2 changes: 1 addition & 1 deletion fuzz/librawspeed/fuzz/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ namespace rawspeed {
class ByteStream;
} // namespace rawspeed

rawspeed::RawImage CreateRawImage(rawspeed::ByteStream& bs);
std::shared_ptr<rawspeed::RawImageData> CreateRawImage(rawspeed::ByteStream& bs);
rawspeed::ColorFilterArray CreateCFA(rawspeed::ByteStream& bs);
Loading