/src/libwebp/tests/fuzzer/fuzz_utils.h
Line | Count | Source |
1 | | // Copyright 2018-2024 Google LLC |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | // |
15 | | //////////////////////////////////////////////////////////////////////////////// |
16 | | |
17 | | #ifndef WEBP_TESTS_FUZZER_FUZZ_UTILS_H_ |
18 | | #define WEBP_TESTS_FUZZER_FUZZ_UTILS_H_ |
19 | | |
20 | | #include <array> |
21 | | #include <cassert> |
22 | | #include <cstddef> |
23 | | #include <cstdint> |
24 | | #include <cstdlib> |
25 | | #include <cstring> |
26 | | #include <optional> |
27 | | #include <string> |
28 | | #include <string_view> |
29 | | #include <utility> |
30 | | #include <vector> |
31 | | |
32 | | #include "./img_alpha.h" |
33 | | #include "./img_grid.h" |
34 | | #include "./img_peak.h" |
35 | | #include "fuzztest/fuzztest.h" |
36 | | #include "src/dsp/cpu.h" |
37 | | #include "src/webp/decode.h" |
38 | | #include "src/webp/encode.h" |
39 | | #include "src/webp/types.h" |
40 | | |
41 | | namespace fuzz_utils { |
42 | | |
43 | | //------------------------------------------------------------------------------ |
44 | | // Arbitrary limits to prevent OOM, timeout, or slow execution. |
45 | | |
46 | | // The decoded image size, and for animations additionally the canvas size. |
47 | | // Enabling some sanitizers slow down runtime significantly. |
48 | | // Use a very low threshold in this case to avoid timeouts. |
49 | | #if defined(__SANITIZE_ADDRESS__) // GCC |
50 | | static const size_t kFuzzPxLimit = 1024 * 1024 / 10; |
51 | | #elif !defined(__has_feature) // Clang |
52 | | static const size_t kFuzzPxLimit = 1024 * 1024; |
53 | | #elif __has_feature(address_sanitizer) || __has_feature(memory_sanitizer) |
54 | | static const size_t kFuzzPxLimit = 1024 * 1024 / 18; |
55 | | #else |
56 | | static const size_t kFuzzPxLimit = 1024 * 1024; |
57 | | #endif |
58 | | |
59 | | // Demuxed or decoded animation frames. |
60 | | static const int kFuzzFrameLimit = 3; |
61 | | |
62 | | // Reads and sums (up to) 128 spread-out bytes. |
63 | 12.5k | static WEBP_INLINE uint8_t FuzzHash(const uint8_t* const data, size_t size) { |
64 | 12.5k | uint8_t value = 0; |
65 | 12.5k | size_t incr = size / 128; |
66 | 12.5k | if (!incr) incr = 1; |
67 | 615k | for (size_t i = 0; i < size; i += incr) value += data[i]; |
68 | 12.5k | return value; |
69 | 12.5k | } Unexecuted instantiation: mux_demux_api_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: imageio_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: fuzz_utils.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: huffman_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: enc_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: animdecoder_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: animation_api_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: dec_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: enc_dec_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Unexecuted instantiation: animencoder_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) advanced_api_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Line | Count | Source | 63 | 7.68k | static WEBP_INLINE uint8_t FuzzHash(const uint8_t* const data, size_t size) { | 64 | 7.68k | uint8_t value = 0; | 65 | 7.68k | size_t incr = size / 128; | 66 | 7.68k | if (!incr) incr = 1; | 67 | 417k | for (size_t i = 0; i < size; i += incr) value += data[i]; | 68 | 7.68k | return value; | 69 | 7.68k | } |
simple_api_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long) Line | Count | Source | 63 | 4.81k | static WEBP_INLINE uint8_t FuzzHash(const uint8_t* const data, size_t size) { | 64 | 4.81k | uint8_t value = 0; | 65 | 4.81k | size_t incr = size / 128; | 66 | 4.81k | if (!incr) incr = 1; | 67 | 197k | for (size_t i = 0; i < size; i += incr) value += data[i]; | 68 | 4.81k | return value; | 69 | 4.81k | } |
|
70 | | |
71 | | #ifdef __cplusplus |
72 | | extern "C" VP8CPUInfo VP8GetCPUInfo; |
73 | | #else |
74 | | extern VP8CPUInfo VP8GetCPUInfo; |
75 | | #endif |
76 | | |
77 | | //------------------------------------------------------------------------------ |
78 | | |
79 | | constexpr const uint8_t* kImagesData[] = {kImgAlphaData, kImgGridData, |
80 | | kImgPeakData}; |
81 | | constexpr size_t kNumSourceImages = |
82 | | sizeof(kImagesData) / sizeof(kImagesData[0]); |
83 | | |
84 | | WebPPicture GetSourcePicture(int image_index, bool use_argb); |
85 | | |
86 | | // Struct to use in a unique_ptr to free the memory. |
87 | | struct UniquePtrDeleter { |
88 | 12.9k | void operator()(WebPMemoryWriter* writer) const { |
89 | 12.9k | WebPMemoryWriterClear(writer); |
90 | 12.9k | } |
91 | 12.9k | void operator()(WebPPicture* pic) const { WebPPictureFree(pic); } |
92 | 12.9k | void operator()(WebPDecoderConfig* config) const { |
93 | 12.9k | WebPFreeDecBuffer(&config->output); |
94 | 12.9k | } |
95 | | }; |
96 | | |
97 | 12 | static inline auto ArbitraryWebPConfig() { |
98 | 12 | return fuzztest::Map( |
99 | 12 | [](int lossless, int quality, int method, int image_hint, int segments, |
100 | 12 | int sns_strength, int filter_strength, int filter_sharpness, |
101 | 12 | int filter_type, int autofilter, int alpha_compression, |
102 | 12 | int alpha_filtering, int alpha_quality, int pass, int preprocessing, |
103 | 12 | int partitions, int partition_limit, int emulate_jpeg_size, |
104 | 12 | int thread_level, int low_memory, int near_lossless, int exact, |
105 | 35.2k | int use_delta_palette, int use_sharp_yuv) -> WebPConfig { |
106 | 35.2k | WebPConfig config; |
107 | 35.2k | if (!WebPConfigInit(&config)) assert(false); |
108 | 35.2k | config.lossless = lossless; |
109 | 35.2k | config.quality = quality; |
110 | 35.2k | config.method = method; |
111 | 35.2k | config.image_hint = (WebPImageHint)image_hint; |
112 | 35.2k | config.segments = segments; |
113 | 35.2k | config.sns_strength = sns_strength; |
114 | 35.2k | config.filter_strength = filter_strength; |
115 | 35.2k | config.filter_sharpness = filter_sharpness; |
116 | 35.2k | config.filter_type = filter_type; |
117 | 35.2k | config.autofilter = autofilter; |
118 | 35.2k | config.alpha_compression = alpha_compression; |
119 | 35.2k | config.alpha_filtering = alpha_filtering; |
120 | 35.2k | config.alpha_quality = alpha_quality; |
121 | 35.2k | config.pass = pass; |
122 | 35.2k | config.show_compressed = 1; |
123 | 35.2k | config.preprocessing = preprocessing; |
124 | 35.2k | config.partitions = partitions; |
125 | 35.2k | config.partition_limit = 10 * partition_limit; |
126 | 35.2k | config.emulate_jpeg_size = emulate_jpeg_size; |
127 | 35.2k | config.thread_level = thread_level; |
128 | 35.2k | config.low_memory = low_memory; |
129 | 35.2k | config.near_lossless = 20 * near_lossless; |
130 | 35.2k | config.exact = exact; |
131 | 35.2k | config.use_delta_palette = use_delta_palette; |
132 | 35.2k | config.use_sharp_yuv = use_sharp_yuv; |
133 | 35.2k | if (!WebPValidateConfig(&config)) assert(false); |
134 | 35.2k | return config; |
135 | 35.2k | }, enc_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()::{lambda(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int)#1}::operator()(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) constLine | Count | Source | 105 | 8.88k | int use_delta_palette, int use_sharp_yuv) -> WebPConfig { | 106 | 8.88k | WebPConfig config; | 107 | 8.88k | if (!WebPConfigInit(&config)) assert(false); | 108 | 8.88k | config.lossless = lossless; | 109 | 8.88k | config.quality = quality; | 110 | 8.88k | config.method = method; | 111 | 8.88k | config.image_hint = (WebPImageHint)image_hint; | 112 | 8.88k | config.segments = segments; | 113 | 8.88k | config.sns_strength = sns_strength; | 114 | 8.88k | config.filter_strength = filter_strength; | 115 | 8.88k | config.filter_sharpness = filter_sharpness; | 116 | 8.88k | config.filter_type = filter_type; | 117 | 8.88k | config.autofilter = autofilter; | 118 | 8.88k | config.alpha_compression = alpha_compression; | 119 | 8.88k | config.alpha_filtering = alpha_filtering; | 120 | 8.88k | config.alpha_quality = alpha_quality; | 121 | 8.88k | config.pass = pass; | 122 | 8.88k | config.show_compressed = 1; | 123 | 8.88k | config.preprocessing = preprocessing; | 124 | 8.88k | config.partitions = partitions; | 125 | 8.88k | config.partition_limit = 10 * partition_limit; | 126 | 8.88k | config.emulate_jpeg_size = emulate_jpeg_size; | 127 | 8.88k | config.thread_level = thread_level; | 128 | 8.88k | config.low_memory = low_memory; | 129 | 8.88k | config.near_lossless = 20 * near_lossless; | 130 | 8.88k | config.exact = exact; | 131 | 8.88k | config.use_delta_palette = use_delta_palette; | 132 | 8.88k | config.use_sharp_yuv = use_sharp_yuv; | 133 | 8.88k | if (!WebPValidateConfig(&config)) assert(false); | 134 | 8.88k | return config; | 135 | 8.88k | }, |
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()::{lambda(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int)#1}::operator()(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) constLine | Count | Source | 105 | 12.9k | int use_delta_palette, int use_sharp_yuv) -> WebPConfig { | 106 | 12.9k | WebPConfig config; | 107 | 12.9k | if (!WebPConfigInit(&config)) assert(false); | 108 | 12.9k | config.lossless = lossless; | 109 | 12.9k | config.quality = quality; | 110 | 12.9k | config.method = method; | 111 | 12.9k | config.image_hint = (WebPImageHint)image_hint; | 112 | 12.9k | config.segments = segments; | 113 | 12.9k | config.sns_strength = sns_strength; | 114 | 12.9k | config.filter_strength = filter_strength; | 115 | 12.9k | config.filter_sharpness = filter_sharpness; | 116 | 12.9k | config.filter_type = filter_type; | 117 | 12.9k | config.autofilter = autofilter; | 118 | 12.9k | config.alpha_compression = alpha_compression; | 119 | 12.9k | config.alpha_filtering = alpha_filtering; | 120 | 12.9k | config.alpha_quality = alpha_quality; | 121 | 12.9k | config.pass = pass; | 122 | 12.9k | config.show_compressed = 1; | 123 | 12.9k | config.preprocessing = preprocessing; | 124 | 12.9k | config.partitions = partitions; | 125 | 12.9k | config.partition_limit = 10 * partition_limit; | 126 | 12.9k | config.emulate_jpeg_size = emulate_jpeg_size; | 127 | 12.9k | config.thread_level = thread_level; | 128 | 12.9k | config.low_memory = low_memory; | 129 | 12.9k | config.near_lossless = 20 * near_lossless; | 130 | 12.9k | config.exact = exact; | 131 | 12.9k | config.use_delta_palette = use_delta_palette; | 132 | 12.9k | config.use_sharp_yuv = use_sharp_yuv; | 133 | 12.9k | if (!WebPValidateConfig(&config)) assert(false); | 134 | 12.9k | return config; | 135 | 12.9k | }, |
animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()::{lambda(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int)#1}::operator()(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) constLine | Count | Source | 105 | 13.4k | int use_delta_palette, int use_sharp_yuv) -> WebPConfig { | 106 | 13.4k | WebPConfig config; | 107 | 13.4k | if (!WebPConfigInit(&config)) assert(false); | 108 | 13.4k | config.lossless = lossless; | 109 | 13.4k | config.quality = quality; | 110 | 13.4k | config.method = method; | 111 | 13.4k | config.image_hint = (WebPImageHint)image_hint; | 112 | 13.4k | config.segments = segments; | 113 | 13.4k | config.sns_strength = sns_strength; | 114 | 13.4k | config.filter_strength = filter_strength; | 115 | 13.4k | config.filter_sharpness = filter_sharpness; | 116 | 13.4k | config.filter_type = filter_type; | 117 | 13.4k | config.autofilter = autofilter; | 118 | 13.4k | config.alpha_compression = alpha_compression; | 119 | 13.4k | config.alpha_filtering = alpha_filtering; | 120 | 13.4k | config.alpha_quality = alpha_quality; | 121 | 13.4k | config.pass = pass; | 122 | 13.4k | config.show_compressed = 1; | 123 | 13.4k | config.preprocessing = preprocessing; | 124 | 13.4k | config.partitions = partitions; | 125 | 13.4k | config.partition_limit = 10 * partition_limit; | 126 | 13.4k | config.emulate_jpeg_size = emulate_jpeg_size; | 127 | 13.4k | config.thread_level = thread_level; | 128 | 13.4k | config.low_memory = low_memory; | 129 | 13.4k | config.near_lossless = 20 * near_lossless; | 130 | 13.4k | config.exact = exact; | 131 | 13.4k | config.use_delta_palette = use_delta_palette; | 132 | 13.4k | config.use_sharp_yuv = use_sharp_yuv; | 133 | 13.4k | if (!WebPValidateConfig(&config)) assert(false); | 134 | 13.4k | return config; | 135 | 13.4k | }, |
|
136 | 12 | /*lossless=*/fuzztest::InRange<int>(0, 1), |
137 | 12 | /*quality=*/fuzztest::InRange<int>(0, 100), |
138 | 12 | /*method=*/fuzztest::InRange<int>(0, 6), |
139 | 12 | /*image_hint=*/fuzztest::InRange<int>(0, WEBP_HINT_LAST - 1), |
140 | 12 | /*segments=*/fuzztest::InRange<int>(1, 4), |
141 | 12 | /*sns_strength=*/fuzztest::InRange<int>(0, 100), |
142 | 12 | /*filter_strength=*/fuzztest::InRange<int>(0, 100), |
143 | 12 | /*filter_sharpness=*/fuzztest::InRange<int>(0, 7), |
144 | 12 | /*filter_type=*/fuzztest::InRange<int>(0, 1), |
145 | 12 | /*autofilter=*/fuzztest::InRange<int>(0, 1), |
146 | 12 | /*alpha_compression=*/fuzztest::InRange<int>(0, 1), |
147 | 12 | /*alpha_filtering=*/fuzztest::InRange<int>(0, 2), |
148 | 12 | /*alpha_quality=*/fuzztest::InRange<int>(0, 100), |
149 | 12 | /*pass=*/fuzztest::InRange<int>(1, 10), |
150 | 12 | /*preprocessing=*/fuzztest::InRange<int>(0, 2), |
151 | 12 | /*partitions=*/fuzztest::InRange<int>(0, 3), |
152 | 12 | /*partition_limit=*/fuzztest::InRange<int>(0, 10), |
153 | 12 | /*emulate_jpeg_size=*/fuzztest::InRange<int>(0, 1), |
154 | 12 | /*thread_level=*/fuzztest::InRange<int>(0, 1), |
155 | 12 | /*low_memory=*/fuzztest::InRange<int>(0, 1), |
156 | 12 | /*near_lossless=*/fuzztest::InRange<int>(0, 5), |
157 | 12 | /*exact=*/fuzztest::InRange<int>(0, 1), |
158 | 12 | /*use_delta_palette=*/fuzztest::InRange<int>(0, 1), |
159 | 12 | /*use_sharp_yuv=*/fuzztest::InRange<int>(0, 1)); |
160 | 12 | } Unexecuted instantiation: mux_demux_api_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Unexecuted instantiation: imageio_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Unexecuted instantiation: fuzz_utils.cc:fuzz_utils::ArbitraryWebPConfig() Unexecuted instantiation: huffman_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() enc_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Line | Count | Source | 97 | 2 | static inline auto ArbitraryWebPConfig() { | 98 | 2 | return fuzztest::Map( | 99 | 2 | [](int lossless, int quality, int method, int image_hint, int segments, | 100 | 2 | int sns_strength, int filter_strength, int filter_sharpness, | 101 | 2 | int filter_type, int autofilter, int alpha_compression, | 102 | 2 | int alpha_filtering, int alpha_quality, int pass, int preprocessing, | 103 | 2 | int partitions, int partition_limit, int emulate_jpeg_size, | 104 | 2 | int thread_level, int low_memory, int near_lossless, int exact, | 105 | 2 | int use_delta_palette, int use_sharp_yuv) -> WebPConfig { | 106 | 2 | WebPConfig config; | 107 | 2 | if (!WebPConfigInit(&config)) assert(false); | 108 | 2 | config.lossless = lossless; | 109 | 2 | config.quality = quality; | 110 | 2 | config.method = method; | 111 | 2 | config.image_hint = (WebPImageHint)image_hint; | 112 | 2 | config.segments = segments; | 113 | 2 | config.sns_strength = sns_strength; | 114 | 2 | config.filter_strength = filter_strength; | 115 | 2 | config.filter_sharpness = filter_sharpness; | 116 | 2 | config.filter_type = filter_type; | 117 | 2 | config.autofilter = autofilter; | 118 | 2 | config.alpha_compression = alpha_compression; | 119 | 2 | config.alpha_filtering = alpha_filtering; | 120 | 2 | config.alpha_quality = alpha_quality; | 121 | 2 | config.pass = pass; | 122 | 2 | config.show_compressed = 1; | 123 | 2 | config.preprocessing = preprocessing; | 124 | 2 | config.partitions = partitions; | 125 | 2 | config.partition_limit = 10 * partition_limit; | 126 | 2 | config.emulate_jpeg_size = emulate_jpeg_size; | 127 | 2 | config.thread_level = thread_level; | 128 | 2 | config.low_memory = low_memory; | 129 | 2 | config.near_lossless = 20 * near_lossless; | 130 | 2 | config.exact = exact; | 131 | 2 | config.use_delta_palette = use_delta_palette; | 132 | 2 | config.use_sharp_yuv = use_sharp_yuv; | 133 | 2 | if (!WebPValidateConfig(&config)) assert(false); | 134 | 2 | return config; | 135 | 2 | }, | 136 | 2 | /*lossless=*/fuzztest::InRange<int>(0, 1), | 137 | 2 | /*quality=*/fuzztest::InRange<int>(0, 100), | 138 | 2 | /*method=*/fuzztest::InRange<int>(0, 6), | 139 | 2 | /*image_hint=*/fuzztest::InRange<int>(0, WEBP_HINT_LAST - 1), | 140 | 2 | /*segments=*/fuzztest::InRange<int>(1, 4), | 141 | 2 | /*sns_strength=*/fuzztest::InRange<int>(0, 100), | 142 | 2 | /*filter_strength=*/fuzztest::InRange<int>(0, 100), | 143 | 2 | /*filter_sharpness=*/fuzztest::InRange<int>(0, 7), | 144 | 2 | /*filter_type=*/fuzztest::InRange<int>(0, 1), | 145 | 2 | /*autofilter=*/fuzztest::InRange<int>(0, 1), | 146 | 2 | /*alpha_compression=*/fuzztest::InRange<int>(0, 1), | 147 | 2 | /*alpha_filtering=*/fuzztest::InRange<int>(0, 2), | 148 | 2 | /*alpha_quality=*/fuzztest::InRange<int>(0, 100), | 149 | 2 | /*pass=*/fuzztest::InRange<int>(1, 10), | 150 | 2 | /*preprocessing=*/fuzztest::InRange<int>(0, 2), | 151 | 2 | /*partitions=*/fuzztest::InRange<int>(0, 3), | 152 | 2 | /*partition_limit=*/fuzztest::InRange<int>(0, 10), | 153 | 2 | /*emulate_jpeg_size=*/fuzztest::InRange<int>(0, 1), | 154 | 2 | /*thread_level=*/fuzztest::InRange<int>(0, 1), | 155 | 2 | /*low_memory=*/fuzztest::InRange<int>(0, 1), | 156 | 2 | /*near_lossless=*/fuzztest::InRange<int>(0, 5), | 157 | 2 | /*exact=*/fuzztest::InRange<int>(0, 1), | 158 | 2 | /*use_delta_palette=*/fuzztest::InRange<int>(0, 1), | 159 | 2 | /*use_sharp_yuv=*/fuzztest::InRange<int>(0, 1)); | 160 | 2 | } |
Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Unexecuted instantiation: animdecoder_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Unexecuted instantiation: animation_api_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Unexecuted instantiation: dec_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Line | Count | Source | 97 | 8 | static inline auto ArbitraryWebPConfig() { | 98 | 8 | return fuzztest::Map( | 99 | 8 | [](int lossless, int quality, int method, int image_hint, int segments, | 100 | 8 | int sns_strength, int filter_strength, int filter_sharpness, | 101 | 8 | int filter_type, int autofilter, int alpha_compression, | 102 | 8 | int alpha_filtering, int alpha_quality, int pass, int preprocessing, | 103 | 8 | int partitions, int partition_limit, int emulate_jpeg_size, | 104 | 8 | int thread_level, int low_memory, int near_lossless, int exact, | 105 | 8 | int use_delta_palette, int use_sharp_yuv) -> WebPConfig { | 106 | 8 | WebPConfig config; | 107 | 8 | if (!WebPConfigInit(&config)) assert(false); | 108 | 8 | config.lossless = lossless; | 109 | 8 | config.quality = quality; | 110 | 8 | config.method = method; | 111 | 8 | config.image_hint = (WebPImageHint)image_hint; | 112 | 8 | config.segments = segments; | 113 | 8 | config.sns_strength = sns_strength; | 114 | 8 | config.filter_strength = filter_strength; | 115 | 8 | config.filter_sharpness = filter_sharpness; | 116 | 8 | config.filter_type = filter_type; | 117 | 8 | config.autofilter = autofilter; | 118 | 8 | config.alpha_compression = alpha_compression; | 119 | 8 | config.alpha_filtering = alpha_filtering; | 120 | 8 | config.alpha_quality = alpha_quality; | 121 | 8 | config.pass = pass; | 122 | 8 | config.show_compressed = 1; | 123 | 8 | config.preprocessing = preprocessing; | 124 | 8 | config.partitions = partitions; | 125 | 8 | config.partition_limit = 10 * partition_limit; | 126 | 8 | config.emulate_jpeg_size = emulate_jpeg_size; | 127 | 8 | config.thread_level = thread_level; | 128 | 8 | config.low_memory = low_memory; | 129 | 8 | config.near_lossless = 20 * near_lossless; | 130 | 8 | config.exact = exact; | 131 | 8 | config.use_delta_palette = use_delta_palette; | 132 | 8 | config.use_sharp_yuv = use_sharp_yuv; | 133 | 8 | if (!WebPValidateConfig(&config)) assert(false); | 134 | 8 | return config; | 135 | 8 | }, | 136 | 8 | /*lossless=*/fuzztest::InRange<int>(0, 1), | 137 | 8 | /*quality=*/fuzztest::InRange<int>(0, 100), | 138 | 8 | /*method=*/fuzztest::InRange<int>(0, 6), | 139 | 8 | /*image_hint=*/fuzztest::InRange<int>(0, WEBP_HINT_LAST - 1), | 140 | 8 | /*segments=*/fuzztest::InRange<int>(1, 4), | 141 | 8 | /*sns_strength=*/fuzztest::InRange<int>(0, 100), | 142 | 8 | /*filter_strength=*/fuzztest::InRange<int>(0, 100), | 143 | 8 | /*filter_sharpness=*/fuzztest::InRange<int>(0, 7), | 144 | 8 | /*filter_type=*/fuzztest::InRange<int>(0, 1), | 145 | 8 | /*autofilter=*/fuzztest::InRange<int>(0, 1), | 146 | 8 | /*alpha_compression=*/fuzztest::InRange<int>(0, 1), | 147 | 8 | /*alpha_filtering=*/fuzztest::InRange<int>(0, 2), | 148 | 8 | /*alpha_quality=*/fuzztest::InRange<int>(0, 100), | 149 | 8 | /*pass=*/fuzztest::InRange<int>(1, 10), | 150 | 8 | /*preprocessing=*/fuzztest::InRange<int>(0, 2), | 151 | 8 | /*partitions=*/fuzztest::InRange<int>(0, 3), | 152 | 8 | /*partition_limit=*/fuzztest::InRange<int>(0, 10), | 153 | 8 | /*emulate_jpeg_size=*/fuzztest::InRange<int>(0, 1), | 154 | 8 | /*thread_level=*/fuzztest::InRange<int>(0, 1), | 155 | 8 | /*low_memory=*/fuzztest::InRange<int>(0, 1), | 156 | 8 | /*near_lossless=*/fuzztest::InRange<int>(0, 5), | 157 | 8 | /*exact=*/fuzztest::InRange<int>(0, 1), | 158 | 8 | /*use_delta_palette=*/fuzztest::InRange<int>(0, 1), | 159 | 8 | /*use_sharp_yuv=*/fuzztest::InRange<int>(0, 1)); | 160 | 8 | } |
animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Line | Count | Source | 97 | 2 | static inline auto ArbitraryWebPConfig() { | 98 | 2 | return fuzztest::Map( | 99 | 2 | [](int lossless, int quality, int method, int image_hint, int segments, | 100 | 2 | int sns_strength, int filter_strength, int filter_sharpness, | 101 | 2 | int filter_type, int autofilter, int alpha_compression, | 102 | 2 | int alpha_filtering, int alpha_quality, int pass, int preprocessing, | 103 | 2 | int partitions, int partition_limit, int emulate_jpeg_size, | 104 | 2 | int thread_level, int low_memory, int near_lossless, int exact, | 105 | 2 | int use_delta_palette, int use_sharp_yuv) -> WebPConfig { | 106 | 2 | WebPConfig config; | 107 | 2 | if (!WebPConfigInit(&config)) assert(false); | 108 | 2 | config.lossless = lossless; | 109 | 2 | config.quality = quality; | 110 | 2 | config.method = method; | 111 | 2 | config.image_hint = (WebPImageHint)image_hint; | 112 | 2 | config.segments = segments; | 113 | 2 | config.sns_strength = sns_strength; | 114 | 2 | config.filter_strength = filter_strength; | 115 | 2 | config.filter_sharpness = filter_sharpness; | 116 | 2 | config.filter_type = filter_type; | 117 | 2 | config.autofilter = autofilter; | 118 | 2 | config.alpha_compression = alpha_compression; | 119 | 2 | config.alpha_filtering = alpha_filtering; | 120 | 2 | config.alpha_quality = alpha_quality; | 121 | 2 | config.pass = pass; | 122 | 2 | config.show_compressed = 1; | 123 | 2 | config.preprocessing = preprocessing; | 124 | 2 | config.partitions = partitions; | 125 | 2 | config.partition_limit = 10 * partition_limit; | 126 | 2 | config.emulate_jpeg_size = emulate_jpeg_size; | 127 | 2 | config.thread_level = thread_level; | 128 | 2 | config.low_memory = low_memory; | 129 | 2 | config.near_lossless = 20 * near_lossless; | 130 | 2 | config.exact = exact; | 131 | 2 | config.use_delta_palette = use_delta_palette; | 132 | 2 | config.use_sharp_yuv = use_sharp_yuv; | 133 | 2 | if (!WebPValidateConfig(&config)) assert(false); | 134 | 2 | return config; | 135 | 2 | }, | 136 | 2 | /*lossless=*/fuzztest::InRange<int>(0, 1), | 137 | 2 | /*quality=*/fuzztest::InRange<int>(0, 100), | 138 | 2 | /*method=*/fuzztest::InRange<int>(0, 6), | 139 | 2 | /*image_hint=*/fuzztest::InRange<int>(0, WEBP_HINT_LAST - 1), | 140 | 2 | /*segments=*/fuzztest::InRange<int>(1, 4), | 141 | 2 | /*sns_strength=*/fuzztest::InRange<int>(0, 100), | 142 | 2 | /*filter_strength=*/fuzztest::InRange<int>(0, 100), | 143 | 2 | /*filter_sharpness=*/fuzztest::InRange<int>(0, 7), | 144 | 2 | /*filter_type=*/fuzztest::InRange<int>(0, 1), | 145 | 2 | /*autofilter=*/fuzztest::InRange<int>(0, 1), | 146 | 2 | /*alpha_compression=*/fuzztest::InRange<int>(0, 1), | 147 | 2 | /*alpha_filtering=*/fuzztest::InRange<int>(0, 2), | 148 | 2 | /*alpha_quality=*/fuzztest::InRange<int>(0, 100), | 149 | 2 | /*pass=*/fuzztest::InRange<int>(1, 10), | 150 | 2 | /*preprocessing=*/fuzztest::InRange<int>(0, 2), | 151 | 2 | /*partitions=*/fuzztest::InRange<int>(0, 3), | 152 | 2 | /*partition_limit=*/fuzztest::InRange<int>(0, 10), | 153 | 2 | /*emulate_jpeg_size=*/fuzztest::InRange<int>(0, 1), | 154 | 2 | /*thread_level=*/fuzztest::InRange<int>(0, 1), | 155 | 2 | /*low_memory=*/fuzztest::InRange<int>(0, 1), | 156 | 2 | /*near_lossless=*/fuzztest::InRange<int>(0, 5), | 157 | 2 | /*exact=*/fuzztest::InRange<int>(0, 1), | 158 | 2 | /*use_delta_palette=*/fuzztest::InRange<int>(0, 1), | 159 | 2 | /*use_sharp_yuv=*/fuzztest::InRange<int>(0, 1)); | 160 | 2 | } |
Unexecuted instantiation: advanced_api_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig() |
161 | | |
162 | | // Like WebPDecoderOptions but with no C array. |
163 | | // This can be removed once b/294098900 is fixed. |
164 | | struct WebPDecoderOptionsCpp { |
165 | | int bypass_filtering; |
166 | | int no_fancy_upsampling; |
167 | | int use_cropping; |
168 | | int crop_left, crop_top; |
169 | | |
170 | | int crop_width, crop_height; |
171 | | int use_scaling; |
172 | | int scaled_width, scaled_height; |
173 | | |
174 | | int use_threads; |
175 | | int dithering_strength; |
176 | | int flip; |
177 | | int alpha_dithering_strength; |
178 | | |
179 | | std::array<uint32_t, 5> pad; |
180 | | }; |
181 | | |
182 | 10 | static inline auto ArbitraryValidWebPDecoderOptions() { |
183 | 10 | return fuzztest::Map( |
184 | 10 | [](int bypass_filtering, int no_fancy_upsampling, int use_cropping, |
185 | 10 | int crop_left, int crop_top, int crop_width, int crop_height, |
186 | 10 | int use_scaling, int scaled_width, int scaled_height, int use_threads, |
187 | 10 | int dithering_strength, int flip, |
188 | 18.0k | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { |
189 | 18.0k | WebPDecoderOptions options; |
190 | 18.0k | options.bypass_filtering = bypass_filtering; |
191 | 18.0k | options.no_fancy_upsampling = no_fancy_upsampling; |
192 | 18.0k | options.use_cropping = use_cropping; |
193 | 18.0k | options.crop_left = crop_left; |
194 | 18.0k | options.crop_top = crop_top; |
195 | 18.0k | options.crop_width = crop_width; |
196 | 18.0k | options.crop_height = crop_height; |
197 | 18.0k | options.use_scaling = use_scaling; |
198 | 18.0k | options.scaled_width = scaled_width; |
199 | 18.0k | options.scaled_height = scaled_height; |
200 | 18.0k | options.use_threads = use_threads; |
201 | 18.0k | options.dithering_strength = dithering_strength; |
202 | 18.0k | options.flip = flip; |
203 | 18.0k | options.alpha_dithering_strength = alpha_dithering_strength; |
204 | 18.0k | WebPDecoderConfig config; |
205 | 18.0k | if (!WebPInitDecoderConfig(&config)) assert(false); |
206 | 18.0k | config.options = options; |
207 | 18.0k | if (!WebPValidateDecoderConfig(&config)) assert(false); |
208 | 18.0k | WebPDecoderOptionsCpp options_cpp; |
209 | 18.0k | std::memcpy(&options_cpp, &options, sizeof(options)); |
210 | 18.0k | return options_cpp; |
211 | 18.0k | }, dec_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions()::{lambda(int, int, int, int, int, int, int, int, int, int, int, int, int, int)#1}::operator()(int, int, int, int, int, int, int, int, int, int, int, int, int, int) constLine | Count | Source | 188 | 3.81k | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { | 189 | 3.81k | WebPDecoderOptions options; | 190 | 3.81k | options.bypass_filtering = bypass_filtering; | 191 | 3.81k | options.no_fancy_upsampling = no_fancy_upsampling; | 192 | 3.81k | options.use_cropping = use_cropping; | 193 | 3.81k | options.crop_left = crop_left; | 194 | 3.81k | options.crop_top = crop_top; | 195 | 3.81k | options.crop_width = crop_width; | 196 | 3.81k | options.crop_height = crop_height; | 197 | 3.81k | options.use_scaling = use_scaling; | 198 | 3.81k | options.scaled_width = scaled_width; | 199 | 3.81k | options.scaled_height = scaled_height; | 200 | 3.81k | options.use_threads = use_threads; | 201 | 3.81k | options.dithering_strength = dithering_strength; | 202 | 3.81k | options.flip = flip; | 203 | 3.81k | options.alpha_dithering_strength = alpha_dithering_strength; | 204 | 3.81k | WebPDecoderConfig config; | 205 | 3.81k | if (!WebPInitDecoderConfig(&config)) assert(false); | 206 | 3.81k | config.options = options; | 207 | 3.81k | if (!WebPValidateDecoderConfig(&config)) assert(false); | 208 | 3.81k | WebPDecoderOptionsCpp options_cpp; | 209 | 3.81k | std::memcpy(&options_cpp, &options, sizeof(options)); | 210 | 3.81k | return options_cpp; | 211 | 3.81k | }, |
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions()::{lambda(int, int, int, int, int, int, int, int, int, int, int, int, int, int)#1}::operator()(int, int, int, int, int, int, int, int, int, int, int, int, int, int) constLine | Count | Source | 188 | 6.41k | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { | 189 | 6.41k | WebPDecoderOptions options; | 190 | 6.41k | options.bypass_filtering = bypass_filtering; | 191 | 6.41k | options.no_fancy_upsampling = no_fancy_upsampling; | 192 | 6.41k | options.use_cropping = use_cropping; | 193 | 6.41k | options.crop_left = crop_left; | 194 | 6.41k | options.crop_top = crop_top; | 195 | 6.41k | options.crop_width = crop_width; | 196 | 6.41k | options.crop_height = crop_height; | 197 | 6.41k | options.use_scaling = use_scaling; | 198 | 6.41k | options.scaled_width = scaled_width; | 199 | 6.41k | options.scaled_height = scaled_height; | 200 | 6.41k | options.use_threads = use_threads; | 201 | 6.41k | options.dithering_strength = dithering_strength; | 202 | 6.41k | options.flip = flip; | 203 | 6.41k | options.alpha_dithering_strength = alpha_dithering_strength; | 204 | 6.41k | WebPDecoderConfig config; | 205 | 6.41k | if (!WebPInitDecoderConfig(&config)) assert(false); | 206 | 6.41k | config.options = options; | 207 | 6.41k | if (!WebPValidateDecoderConfig(&config)) assert(false); | 208 | 6.41k | WebPDecoderOptionsCpp options_cpp; | 209 | 6.41k | std::memcpy(&options_cpp, &options, sizeof(options)); | 210 | 6.41k | return options_cpp; | 211 | 6.41k | }, |
advanced_api_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions()::{lambda(int, int, int, int, int, int, int, int, int, int, int, int, int, int)#1}::operator()(int, int, int, int, int, int, int, int, int, int, int, int, int, int) constLine | Count | Source | 188 | 7.78k | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { | 189 | 7.78k | WebPDecoderOptions options; | 190 | 7.78k | options.bypass_filtering = bypass_filtering; | 191 | 7.78k | options.no_fancy_upsampling = no_fancy_upsampling; | 192 | 7.78k | options.use_cropping = use_cropping; | 193 | 7.78k | options.crop_left = crop_left; | 194 | 7.78k | options.crop_top = crop_top; | 195 | 7.78k | options.crop_width = crop_width; | 196 | 7.78k | options.crop_height = crop_height; | 197 | 7.78k | options.use_scaling = use_scaling; | 198 | 7.78k | options.scaled_width = scaled_width; | 199 | 7.78k | options.scaled_height = scaled_height; | 200 | 7.78k | options.use_threads = use_threads; | 201 | 7.78k | options.dithering_strength = dithering_strength; | 202 | 7.78k | options.flip = flip; | 203 | 7.78k | options.alpha_dithering_strength = alpha_dithering_strength; | 204 | 7.78k | WebPDecoderConfig config; | 205 | 7.78k | if (!WebPInitDecoderConfig(&config)) assert(false); | 206 | 7.78k | config.options = options; | 207 | 7.78k | if (!WebPValidateDecoderConfig(&config)) assert(false); | 208 | 7.78k | WebPDecoderOptionsCpp options_cpp; | 209 | 7.78k | std::memcpy(&options_cpp, &options, sizeof(options)); | 210 | 7.78k | return options_cpp; | 211 | 7.78k | }, |
|
212 | 10 | /*bypass_filtering=*/fuzztest::InRange<int>(0, 1), |
213 | 10 | /*no_fancy_upsampling=*/fuzztest::InRange<int>(0, 1), |
214 | 10 | /*use_cropping=*/fuzztest::InRange<int>(0, 1), |
215 | 10 | /*crop_left=*/fuzztest::InRange<int>(0, 10), |
216 | 10 | /*crop_top=*/fuzztest::InRange<int>(0, 10), |
217 | 10 | /*crop_width=*/fuzztest::InRange<int>(1, 10), |
218 | 10 | /*crop_height=*/fuzztest::InRange<int>(1, 10), |
219 | 10 | /*use_scaling=*/fuzztest::InRange<int>(0, 1), |
220 | 10 | /*scaled_width=*/fuzztest::InRange<int>(1, 10), |
221 | 10 | /*scaled_height=*/fuzztest::InRange<int>(1, 10), |
222 | 10 | /*use_threads=*/fuzztest::InRange<int>(0, 1), |
223 | 10 | /*dithering_strength=*/fuzztest::InRange<int>(0, 100), |
224 | 10 | /*flip=*/fuzztest::InRange<int>(0, 1), |
225 | 10 | /*alpha_dithering_strength=*/fuzztest::InRange<int>(0, 100)); |
226 | 10 | } Unexecuted instantiation: mux_demux_api_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Unexecuted instantiation: imageio_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Unexecuted instantiation: fuzz_utils.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Unexecuted instantiation: huffman_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Unexecuted instantiation: enc_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Unexecuted instantiation: animdecoder_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Unexecuted instantiation: animation_api_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() dec_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Line | Count | Source | 182 | 4 | static inline auto ArbitraryValidWebPDecoderOptions() { | 183 | 4 | return fuzztest::Map( | 184 | 4 | [](int bypass_filtering, int no_fancy_upsampling, int use_cropping, | 185 | 4 | int crop_left, int crop_top, int crop_width, int crop_height, | 186 | 4 | int use_scaling, int scaled_width, int scaled_height, int use_threads, | 187 | 4 | int dithering_strength, int flip, | 188 | 4 | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { | 189 | 4 | WebPDecoderOptions options; | 190 | 4 | options.bypass_filtering = bypass_filtering; | 191 | 4 | options.no_fancy_upsampling = no_fancy_upsampling; | 192 | 4 | options.use_cropping = use_cropping; | 193 | 4 | options.crop_left = crop_left; | 194 | 4 | options.crop_top = crop_top; | 195 | 4 | options.crop_width = crop_width; | 196 | 4 | options.crop_height = crop_height; | 197 | 4 | options.use_scaling = use_scaling; | 198 | 4 | options.scaled_width = scaled_width; | 199 | 4 | options.scaled_height = scaled_height; | 200 | 4 | options.use_threads = use_threads; | 201 | 4 | options.dithering_strength = dithering_strength; | 202 | 4 | options.flip = flip; | 203 | 4 | options.alpha_dithering_strength = alpha_dithering_strength; | 204 | 4 | WebPDecoderConfig config; | 205 | 4 | if (!WebPInitDecoderConfig(&config)) assert(false); | 206 | 4 | config.options = options; | 207 | 4 | if (!WebPValidateDecoderConfig(&config)) assert(false); | 208 | 4 | WebPDecoderOptionsCpp options_cpp; | 209 | 4 | std::memcpy(&options_cpp, &options, sizeof(options)); | 210 | 4 | return options_cpp; | 211 | 4 | }, | 212 | 4 | /*bypass_filtering=*/fuzztest::InRange<int>(0, 1), | 213 | 4 | /*no_fancy_upsampling=*/fuzztest::InRange<int>(0, 1), | 214 | 4 | /*use_cropping=*/fuzztest::InRange<int>(0, 1), | 215 | 4 | /*crop_left=*/fuzztest::InRange<int>(0, 10), | 216 | 4 | /*crop_top=*/fuzztest::InRange<int>(0, 10), | 217 | 4 | /*crop_width=*/fuzztest::InRange<int>(1, 10), | 218 | 4 | /*crop_height=*/fuzztest::InRange<int>(1, 10), | 219 | 4 | /*use_scaling=*/fuzztest::InRange<int>(0, 1), | 220 | 4 | /*scaled_width=*/fuzztest::InRange<int>(1, 10), | 221 | 4 | /*scaled_height=*/fuzztest::InRange<int>(1, 10), | 222 | 4 | /*use_threads=*/fuzztest::InRange<int>(0, 1), | 223 | 4 | /*dithering_strength=*/fuzztest::InRange<int>(0, 100), | 224 | 4 | /*flip=*/fuzztest::InRange<int>(0, 1), | 225 | 4 | /*alpha_dithering_strength=*/fuzztest::InRange<int>(0, 100)); | 226 | 4 | } |
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Line | Count | Source | 182 | 4 | static inline auto ArbitraryValidWebPDecoderOptions() { | 183 | 4 | return fuzztest::Map( | 184 | 4 | [](int bypass_filtering, int no_fancy_upsampling, int use_cropping, | 185 | 4 | int crop_left, int crop_top, int crop_width, int crop_height, | 186 | 4 | int use_scaling, int scaled_width, int scaled_height, int use_threads, | 187 | 4 | int dithering_strength, int flip, | 188 | 4 | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { | 189 | 4 | WebPDecoderOptions options; | 190 | 4 | options.bypass_filtering = bypass_filtering; | 191 | 4 | options.no_fancy_upsampling = no_fancy_upsampling; | 192 | 4 | options.use_cropping = use_cropping; | 193 | 4 | options.crop_left = crop_left; | 194 | 4 | options.crop_top = crop_top; | 195 | 4 | options.crop_width = crop_width; | 196 | 4 | options.crop_height = crop_height; | 197 | 4 | options.use_scaling = use_scaling; | 198 | 4 | options.scaled_width = scaled_width; | 199 | 4 | options.scaled_height = scaled_height; | 200 | 4 | options.use_threads = use_threads; | 201 | 4 | options.dithering_strength = dithering_strength; | 202 | 4 | options.flip = flip; | 203 | 4 | options.alpha_dithering_strength = alpha_dithering_strength; | 204 | 4 | WebPDecoderConfig config; | 205 | 4 | if (!WebPInitDecoderConfig(&config)) assert(false); | 206 | 4 | config.options = options; | 207 | 4 | if (!WebPValidateDecoderConfig(&config)) assert(false); | 208 | 4 | WebPDecoderOptionsCpp options_cpp; | 209 | 4 | std::memcpy(&options_cpp, &options, sizeof(options)); | 210 | 4 | return options_cpp; | 211 | 4 | }, | 212 | 4 | /*bypass_filtering=*/fuzztest::InRange<int>(0, 1), | 213 | 4 | /*no_fancy_upsampling=*/fuzztest::InRange<int>(0, 1), | 214 | 4 | /*use_cropping=*/fuzztest::InRange<int>(0, 1), | 215 | 4 | /*crop_left=*/fuzztest::InRange<int>(0, 10), | 216 | 4 | /*crop_top=*/fuzztest::InRange<int>(0, 10), | 217 | 4 | /*crop_width=*/fuzztest::InRange<int>(1, 10), | 218 | 4 | /*crop_height=*/fuzztest::InRange<int>(1, 10), | 219 | 4 | /*use_scaling=*/fuzztest::InRange<int>(0, 1), | 220 | 4 | /*scaled_width=*/fuzztest::InRange<int>(1, 10), | 221 | 4 | /*scaled_height=*/fuzztest::InRange<int>(1, 10), | 222 | 4 | /*use_threads=*/fuzztest::InRange<int>(0, 1), | 223 | 4 | /*dithering_strength=*/fuzztest::InRange<int>(0, 100), | 224 | 4 | /*flip=*/fuzztest::InRange<int>(0, 1), | 225 | 4 | /*alpha_dithering_strength=*/fuzztest::InRange<int>(0, 100)); | 226 | 4 | } |
Unexecuted instantiation: animencoder_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() advanced_api_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() Line | Count | Source | 182 | 2 | static inline auto ArbitraryValidWebPDecoderOptions() { | 183 | 2 | return fuzztest::Map( | 184 | 2 | [](int bypass_filtering, int no_fancy_upsampling, int use_cropping, | 185 | 2 | int crop_left, int crop_top, int crop_width, int crop_height, | 186 | 2 | int use_scaling, int scaled_width, int scaled_height, int use_threads, | 187 | 2 | int dithering_strength, int flip, | 188 | 2 | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { | 189 | 2 | WebPDecoderOptions options; | 190 | 2 | options.bypass_filtering = bypass_filtering; | 191 | 2 | options.no_fancy_upsampling = no_fancy_upsampling; | 192 | 2 | options.use_cropping = use_cropping; | 193 | 2 | options.crop_left = crop_left; | 194 | 2 | options.crop_top = crop_top; | 195 | 2 | options.crop_width = crop_width; | 196 | 2 | options.crop_height = crop_height; | 197 | 2 | options.use_scaling = use_scaling; | 198 | 2 | options.scaled_width = scaled_width; | 199 | 2 | options.scaled_height = scaled_height; | 200 | 2 | options.use_threads = use_threads; | 201 | 2 | options.dithering_strength = dithering_strength; | 202 | 2 | options.flip = flip; | 203 | 2 | options.alpha_dithering_strength = alpha_dithering_strength; | 204 | 2 | WebPDecoderConfig config; | 205 | 2 | if (!WebPInitDecoderConfig(&config)) assert(false); | 206 | 2 | config.options = options; | 207 | 2 | if (!WebPValidateDecoderConfig(&config)) assert(false); | 208 | 2 | WebPDecoderOptionsCpp options_cpp; | 209 | 2 | std::memcpy(&options_cpp, &options, sizeof(options)); | 210 | 2 | return options_cpp; | 211 | 2 | }, | 212 | 2 | /*bypass_filtering=*/fuzztest::InRange<int>(0, 1), | 213 | 2 | /*no_fancy_upsampling=*/fuzztest::InRange<int>(0, 1), | 214 | 2 | /*use_cropping=*/fuzztest::InRange<int>(0, 1), | 215 | 2 | /*crop_left=*/fuzztest::InRange<int>(0, 10), | 216 | 2 | /*crop_top=*/fuzztest::InRange<int>(0, 10), | 217 | 2 | /*crop_width=*/fuzztest::InRange<int>(1, 10), | 218 | 2 | /*crop_height=*/fuzztest::InRange<int>(1, 10), | 219 | 2 | /*use_scaling=*/fuzztest::InRange<int>(0, 1), | 220 | 2 | /*scaled_width=*/fuzztest::InRange<int>(1, 10), | 221 | 2 | /*scaled_height=*/fuzztest::InRange<int>(1, 10), | 222 | 2 | /*use_threads=*/fuzztest::InRange<int>(0, 1), | 223 | 2 | /*dithering_strength=*/fuzztest::InRange<int>(0, 100), | 224 | 2 | /*flip=*/fuzztest::InRange<int>(0, 1), | 225 | 2 | /*alpha_dithering_strength=*/fuzztest::InRange<int>(0, 100)); | 226 | 2 | } |
Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions() |
227 | | |
228 | 4 | static inline auto ArbitraryWebPDecoderOptions() { |
229 | 4 | return fuzztest::Map( |
230 | 4 | [](int bypass_filtering, int no_fancy_upsampling, int use_cropping, |
231 | 4 | int crop_left, int crop_top, int crop_width, int crop_height, |
232 | 4 | int use_scaling, int scaled_width, int scaled_height, int use_threads, |
233 | 4 | int dithering_strength, int flip, |
234 | 6.54k | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { |
235 | 6.54k | WebPDecoderOptions options; |
236 | 6.54k | options.bypass_filtering = bypass_filtering; |
237 | 6.54k | options.no_fancy_upsampling = no_fancy_upsampling; |
238 | 6.54k | options.use_cropping = use_cropping; |
239 | 6.54k | options.crop_left = crop_left; |
240 | 6.54k | options.crop_top = crop_top; |
241 | 6.54k | options.crop_width = crop_width; |
242 | 6.54k | options.crop_height = crop_height; |
243 | 6.54k | options.use_scaling = use_scaling; |
244 | 6.54k | options.scaled_width = scaled_width; |
245 | 6.54k | options.scaled_height = scaled_height; |
246 | 6.54k | options.use_threads = use_threads; |
247 | 6.54k | options.dithering_strength = dithering_strength; |
248 | 6.54k | options.flip = flip; |
249 | 6.54k | options.alpha_dithering_strength = alpha_dithering_strength; |
250 | 6.54k | WebPDecoderOptionsCpp options_cpp; |
251 | 6.54k | std::memcpy(&options_cpp, &options, sizeof(options)); |
252 | 6.54k | return options_cpp; |
253 | 6.54k | }, |
254 | 4 | /*bypass_filtering=*/fuzztest::Arbitrary<int>(), |
255 | 4 | /*no_fancy_upsampling=*/fuzztest::Arbitrary<int>(), |
256 | 4 | /*use_cropping=*/fuzztest::Arbitrary<int>(), |
257 | 4 | /*crop_left=*/fuzztest::Arbitrary<int>(), |
258 | 4 | /*crop_top=*/fuzztest::Arbitrary<int>(), |
259 | 4 | /*crop_width=*/fuzztest::Arbitrary<int>(), |
260 | 4 | /*crop_height=*/fuzztest::Arbitrary<int>(), |
261 | 4 | /*use_scaling=*/fuzztest::Arbitrary<int>(), |
262 | 4 | /*scaled_width=*/fuzztest::Arbitrary<int>(), |
263 | 4 | /*scaled_height=*/fuzztest::Arbitrary<int>(), |
264 | 4 | /*use_threads=*/fuzztest::Arbitrary<int>(), |
265 | 4 | /*dithering_strength=*/fuzztest::Arbitrary<int>(), |
266 | 4 | /*flip=*/fuzztest::Arbitrary<int>(), |
267 | 4 | /*alpha_dithering_strength=*/fuzztest::Arbitrary<int>()); |
268 | 4 | } Unexecuted instantiation: mux_demux_api_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: imageio_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: fuzz_utils.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: huffman_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: enc_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: animdecoder_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: animation_api_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: dec_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Line | Count | Source | 228 | 4 | static inline auto ArbitraryWebPDecoderOptions() { | 229 | 4 | return fuzztest::Map( | 230 | 4 | [](int bypass_filtering, int no_fancy_upsampling, int use_cropping, | 231 | 4 | int crop_left, int crop_top, int crop_width, int crop_height, | 232 | 4 | int use_scaling, int scaled_width, int scaled_height, int use_threads, | 233 | 4 | int dithering_strength, int flip, | 234 | 4 | int alpha_dithering_strength) -> WebPDecoderOptionsCpp { | 235 | 4 | WebPDecoderOptions options; | 236 | 4 | options.bypass_filtering = bypass_filtering; | 237 | 4 | options.no_fancy_upsampling = no_fancy_upsampling; | 238 | 4 | options.use_cropping = use_cropping; | 239 | 4 | options.crop_left = crop_left; | 240 | 4 | options.crop_top = crop_top; | 241 | 4 | options.crop_width = crop_width; | 242 | 4 | options.crop_height = crop_height; | 243 | 4 | options.use_scaling = use_scaling; | 244 | 4 | options.scaled_width = scaled_width; | 245 | 4 | options.scaled_height = scaled_height; | 246 | 4 | options.use_threads = use_threads; | 247 | 4 | options.dithering_strength = dithering_strength; | 248 | 4 | options.flip = flip; | 249 | 4 | options.alpha_dithering_strength = alpha_dithering_strength; | 250 | 4 | WebPDecoderOptionsCpp options_cpp; | 251 | 4 | std::memcpy(&options_cpp, &options, sizeof(options)); | 252 | 4 | return options_cpp; | 253 | 4 | }, | 254 | 4 | /*bypass_filtering=*/fuzztest::Arbitrary<int>(), | 255 | 4 | /*no_fancy_upsampling=*/fuzztest::Arbitrary<int>(), | 256 | 4 | /*use_cropping=*/fuzztest::Arbitrary<int>(), | 257 | 4 | /*crop_left=*/fuzztest::Arbitrary<int>(), | 258 | 4 | /*crop_top=*/fuzztest::Arbitrary<int>(), | 259 | 4 | /*crop_width=*/fuzztest::Arbitrary<int>(), | 260 | 4 | /*crop_height=*/fuzztest::Arbitrary<int>(), | 261 | 4 | /*use_scaling=*/fuzztest::Arbitrary<int>(), | 262 | 4 | /*scaled_width=*/fuzztest::Arbitrary<int>(), | 263 | 4 | /*scaled_height=*/fuzztest::Arbitrary<int>(), | 264 | 4 | /*use_threads=*/fuzztest::Arbitrary<int>(), | 265 | 4 | /*dithering_strength=*/fuzztest::Arbitrary<int>(), | 266 | 4 | /*flip=*/fuzztest::Arbitrary<int>(), | 267 | 4 | /*alpha_dithering_strength=*/fuzztest::Arbitrary<int>()); | 268 | 4 | } |
Unexecuted instantiation: animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: advanced_api_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions() |
269 | | |
270 | | struct CropOrScaleParams { |
271 | | bool alter_input; |
272 | | bool crop_or_scale; |
273 | | int width_ratio; |
274 | | int height_ratio; |
275 | | int left_ratio; |
276 | | int top_ratio; |
277 | | }; |
278 | | |
279 | 12 | static inline auto ArbitraryCropOrScaleParams() { |
280 | 12 | return fuzztest::Map( |
281 | 12 | [](const std::optional<std::pair<int, int>>& width_height_ratio, |
282 | 12 | const std::optional<std::pair<int, int>>& left_top_ratio) |
283 | 35.2k | -> CropOrScaleParams { |
284 | 35.2k | CropOrScaleParams params; |
285 | 35.2k | params.alter_input = width_height_ratio.has_value(); |
286 | 35.2k | if (params.alter_input) { |
287 | 16.9k | params.width_ratio = width_height_ratio->first; |
288 | 16.9k | params.height_ratio = width_height_ratio->second; |
289 | 16.9k | params.crop_or_scale = left_top_ratio.has_value(); |
290 | 16.9k | if (params.crop_or_scale) { |
291 | 5.44k | params.left_ratio = left_top_ratio->first; |
292 | 5.44k | params.top_ratio = left_top_ratio->second; |
293 | 5.44k | } |
294 | 16.9k | } |
295 | 35.2k | return params; |
296 | 35.2k | }, enc_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()::{lambda(std::__1::optional<std::__1::pair<int, int> > const&, std::__1::optional<std::__1::pair<int, int> > const&)#1}::operator()(std::__1::optional<std::__1::pair<int, int> > const&, std::__1::optional<std::__1::pair<int, int> > const&) constLine | Count | Source | 283 | 8.88k | -> CropOrScaleParams { | 284 | 8.88k | CropOrScaleParams params; | 285 | 8.88k | params.alter_input = width_height_ratio.has_value(); | 286 | 8.88k | if (params.alter_input) { | 287 | 3.06k | params.width_ratio = width_height_ratio->first; | 288 | 3.06k | params.height_ratio = width_height_ratio->second; | 289 | 3.06k | params.crop_or_scale = left_top_ratio.has_value(); | 290 | 3.06k | if (params.crop_or_scale) { | 291 | 602 | params.left_ratio = left_top_ratio->first; | 292 | 602 | params.top_ratio = left_top_ratio->second; | 293 | 602 | } | 294 | 3.06k | } | 295 | 8.88k | return params; | 296 | 8.88k | }, |
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()::{lambda(std::__1::optional<std::__1::pair<int, int> > const&, std::__1::optional<std::__1::pair<int, int> > const&)#1}::operator()(std::__1::optional<std::__1::pair<int, int> > const&, std::__1::optional<std::__1::pair<int, int> > const&) constLine | Count | Source | 283 | 12.9k | -> CropOrScaleParams { | 284 | 12.9k | CropOrScaleParams params; | 285 | 12.9k | params.alter_input = width_height_ratio.has_value(); | 286 | 12.9k | if (params.alter_input) { | 287 | 8.03k | params.width_ratio = width_height_ratio->first; | 288 | 8.03k | params.height_ratio = width_height_ratio->second; | 289 | 8.03k | params.crop_or_scale = left_top_ratio.has_value(); | 290 | 8.03k | if (params.crop_or_scale) { | 291 | 2.89k | params.left_ratio = left_top_ratio->first; | 292 | 2.89k | params.top_ratio = left_top_ratio->second; | 293 | 2.89k | } | 294 | 8.03k | } | 295 | 12.9k | return params; | 296 | 12.9k | }, |
animencoder_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()::{lambda(std::__1::optional<std::__1::pair<int, int> > const&, std::__1::optional<std::__1::pair<int, int> > const&)#1}::operator()(std::__1::optional<std::__1::pair<int, int> > const&, std::__1::optional<std::__1::pair<int, int> > const&) constLine | Count | Source | 283 | 13.4k | -> CropOrScaleParams { | 284 | 13.4k | CropOrScaleParams params; | 285 | 13.4k | params.alter_input = width_height_ratio.has_value(); | 286 | 13.4k | if (params.alter_input) { | 287 | 5.85k | params.width_ratio = width_height_ratio->first; | 288 | 5.85k | params.height_ratio = width_height_ratio->second; | 289 | 5.85k | params.crop_or_scale = left_top_ratio.has_value(); | 290 | 5.85k | if (params.crop_or_scale) { | 291 | 1.94k | params.left_ratio = left_top_ratio->first; | 292 | 1.94k | params.top_ratio = left_top_ratio->second; | 293 | 1.94k | } | 294 | 5.85k | } | 295 | 13.4k | return params; | 296 | 13.4k | }, |
|
297 | 12 | fuzztest::OptionalOf( |
298 | 12 | fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))), |
299 | 12 | fuzztest::OptionalOf( |
300 | 12 | fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8)))); |
301 | 12 | } Unexecuted instantiation: mux_demux_api_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Unexecuted instantiation: imageio_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Unexecuted instantiation: fuzz_utils.cc:fuzz_utils::ArbitraryCropOrScaleParams() Unexecuted instantiation: huffman_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() enc_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Line | Count | Source | 279 | 2 | static inline auto ArbitraryCropOrScaleParams() { | 280 | 2 | return fuzztest::Map( | 281 | 2 | [](const std::optional<std::pair<int, int>>& width_height_ratio, | 282 | 2 | const std::optional<std::pair<int, int>>& left_top_ratio) | 283 | 2 | -> CropOrScaleParams { | 284 | 2 | CropOrScaleParams params; | 285 | 2 | params.alter_input = width_height_ratio.has_value(); | 286 | 2 | if (params.alter_input) { | 287 | 2 | params.width_ratio = width_height_ratio->first; | 288 | 2 | params.height_ratio = width_height_ratio->second; | 289 | 2 | params.crop_or_scale = left_top_ratio.has_value(); | 290 | 2 | if (params.crop_or_scale) { | 291 | 2 | params.left_ratio = left_top_ratio->first; | 292 | 2 | params.top_ratio = left_top_ratio->second; | 293 | 2 | } | 294 | 2 | } | 295 | 2 | return params; | 296 | 2 | }, | 297 | 2 | fuzztest::OptionalOf( | 298 | 2 | fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))), | 299 | 2 | fuzztest::OptionalOf( | 300 | 2 | fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8)))); | 301 | 2 | } |
Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Unexecuted instantiation: animdecoder_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Unexecuted instantiation: animation_api_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Unexecuted instantiation: dec_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() enc_dec_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Line | Count | Source | 279 | 8 | static inline auto ArbitraryCropOrScaleParams() { | 280 | 8 | return fuzztest::Map( | 281 | 8 | [](const std::optional<std::pair<int, int>>& width_height_ratio, | 282 | 8 | const std::optional<std::pair<int, int>>& left_top_ratio) | 283 | 8 | -> CropOrScaleParams { | 284 | 8 | CropOrScaleParams params; | 285 | 8 | params.alter_input = width_height_ratio.has_value(); | 286 | 8 | if (params.alter_input) { | 287 | 8 | params.width_ratio = width_height_ratio->first; | 288 | 8 | params.height_ratio = width_height_ratio->second; | 289 | 8 | params.crop_or_scale = left_top_ratio.has_value(); | 290 | 8 | if (params.crop_or_scale) { | 291 | 8 | params.left_ratio = left_top_ratio->first; | 292 | 8 | params.top_ratio = left_top_ratio->second; | 293 | 8 | } | 294 | 8 | } | 295 | 8 | return params; | 296 | 8 | }, | 297 | 8 | fuzztest::OptionalOf( | 298 | 8 | fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))), | 299 | 8 | fuzztest::OptionalOf( | 300 | 8 | fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8)))); | 301 | 8 | } |
animencoder_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Line | Count | Source | 279 | 2 | static inline auto ArbitraryCropOrScaleParams() { | 280 | 2 | return fuzztest::Map( | 281 | 2 | [](const std::optional<std::pair<int, int>>& width_height_ratio, | 282 | 2 | const std::optional<std::pair<int, int>>& left_top_ratio) | 283 | 2 | -> CropOrScaleParams { | 284 | 2 | CropOrScaleParams params; | 285 | 2 | params.alter_input = width_height_ratio.has_value(); | 286 | 2 | if (params.alter_input) { | 287 | 2 | params.width_ratio = width_height_ratio->first; | 288 | 2 | params.height_ratio = width_height_ratio->second; | 289 | 2 | params.crop_or_scale = left_top_ratio.has_value(); | 290 | 2 | if (params.crop_or_scale) { | 291 | 2 | params.left_ratio = left_top_ratio->first; | 292 | 2 | params.top_ratio = left_top_ratio->second; | 293 | 2 | } | 294 | 2 | } | 295 | 2 | return params; | 296 | 2 | }, | 297 | 2 | fuzztest::OptionalOf( | 298 | 2 | fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))), | 299 | 2 | fuzztest::OptionalOf( | 300 | 2 | fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8)))); | 301 | 2 | } |
Unexecuted instantiation: advanced_api_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams() |
302 | | |
303 | | // Crops or scales a picture according to the given params. |
304 | | int CropOrScale(WebPPicture* pic, const CropOrScaleParams& params); |
305 | | |
306 | | // Imposes a level of optimization among one of the kMaxOptimizationIndex+1 |
307 | | // possible values: OnlyC, ForceSlowSSSE3, NoSSE41, NoAVX, default. |
308 | | static constexpr uint32_t kMaxOptimizationIndex = 4; |
309 | | void SetOptimization(VP8CPUInfo default_VP8GetCPUInfo, uint32_t index); |
310 | | |
311 | | //------------------------------------------------------------------------------ |
312 | | |
313 | | // See https://developers.google.com/speed/webp/docs/riff_container. |
314 | | static constexpr size_t kMaxWebPFileSize = (1ull << 32) - 2; // 4 GiB - 2 |
315 | | |
316 | | std::vector<std::string> GetDictionaryFromFiles( |
317 | | const std::vector<std::string_view>& file_paths); |
318 | | |
319 | | // Checks whether the binary blob containing a JPEG or WebP is too big for the |
320 | | // fuzzer. |
321 | | bool IsImageTooBig(const uint8_t* data, size_t size); |
322 | | |
323 | | } // namespace fuzz_utils |
324 | | |
325 | | #endif // WEBP_TESTS_FUZZER_FUZZ_UTILS_H_ |