summaryrefslogtreecommitdiff
path: root/tools/icc_codec_fuzzer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/icc_codec_fuzzer.cc')
-rw-r--r--tools/icc_codec_fuzzer.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/tools/icc_codec_fuzzer.cc b/tools/icc_codec_fuzzer.cc
index 0af805c..410ece1 100644
--- a/tools/icc_codec_fuzzer.cc
+++ b/tools/icc_codec_fuzzer.cc
@@ -6,7 +6,15 @@
#include "lib/jxl/enc_icc_codec.h"
#include "lib/jxl/icc_codec.h"
-namespace jxl {
+namespace jpegxl {
+namespace tools {
+
+using ::jxl::PaddedBytes;
+
+#ifdef JXL_ICC_FUZZER_SLOW_TEST
+using ::jxl::BitReader;
+using ::jxl::Span;
+#endif
int TestOneInput(const uint8_t* data, size_t size) {
#if defined(JXL_ICC_FUZZER_ONLY_WRITE)
@@ -27,33 +35,32 @@ int TestOneInput(const uint8_t* data, size_t size) {
// the ICC parsing.
if (read) {
// Reading parses the compressed format.
- BitReader br(Span<const uint8_t>(data, size));
- PaddedBytes result;
- (void)ReadICC(&br, &result);
+ BitReader br(Bytes(data, size));
+ std::vector<uint8_t> result;
+ (void)jxl::test::ReadICC(&br, &result);
(void)br.Close();
} else {
// Writing parses the original ICC profile.
PaddedBytes icc;
icc.assign(data, data + size);
BitWriter writer;
- AuxOut aux;
// Writing should support any random bytestream so must succeed, make
// fuzzer fail if not.
- JXL_ASSERT(WriteICC(icc, &writer, 0, &aux));
+ JXL_ASSERT(jxl::WriteICC(icc, &writer, 0, nullptr));
}
#else // JXL_ICC_FUZZER_SLOW_TEST
if (read) {
// Reading (unpredicting) parses the compressed format.
PaddedBytes result;
- (void)UnpredictICC(data, size, &result);
+ (void)jxl::UnpredictICC(data, size, &result);
} else {
// Writing (predicting) parses the original ICC profile.
PaddedBytes result;
// Writing should support any random bytestream so must succeed, make
// fuzzer fail if not.
- JXL_ASSERT(PredictICC(data, size, &result));
+ JXL_ASSERT(jxl::PredictICC(data, size, &result));
PaddedBytes reconstructed;
- JXL_ASSERT(UnpredictICC(result.data(), result.size(), &reconstructed));
+ JXL_ASSERT(jxl::UnpredictICC(result.data(), result.size(), &reconstructed));
JXL_ASSERT(reconstructed.size() == size);
JXL_ASSERT(memcmp(data, reconstructed.data(), size) == 0);
}
@@ -61,8 +68,9 @@ int TestOneInput(const uint8_t* data, size_t size) {
return 0;
}
-} // namespace jxl
+} // namespace tools
+} // namespace jpegxl
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- return jxl::TestOneInput(data, size);
+ return jpegxl::tools::TestOneInput(data, size);
}