Coverage Report

Created: 2026-02-26 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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 <algorithm>
21
#include <array>
22
#include <cassert>
23
#include <cstddef>
24
#include <cstdint>
25
#include <cstdlib>
26
#include <cstring>
27
#include <optional>
28
#include <string>
29
#include <string_view>
30
#include <utility>
31
#include <vector>
32
33
#include "./img_alpha.h"
34
#include "./img_grid.h"
35
#include "./img_peak.h"
36
#include "fuzztest/fuzztest.h"
37
#include "src/dsp/cpu.h"
38
#include "src/webp/decode.h"
39
#include "src/webp/encode.h"
40
#include "src/webp/types.h"
41
42
namespace fuzz_utils {
43
44
//------------------------------------------------------------------------------
45
// Arbitrary limits to prevent OOM, timeout, or slow execution.
46
47
// The decoded image size, and for animations additionally the canvas size.
48
// Enabling some sanitizers slow down runtime significantly.
49
// Use a very low threshold in this case to avoid timeouts.
50
#if defined(__SANITIZE_ADDRESS__)  // GCC
51
static const size_t kFuzzPxLimit = 1024 * 1024 / 10;
52
#elif !defined(__has_feature)  // Clang
53
static const size_t kFuzzPxLimit = 1024 * 1024;
54
#elif __has_feature(address_sanitizer) || __has_feature(memory_sanitizer)
55
static const size_t kFuzzPxLimit = 1024 * 1024 / 18;
56
#else
57
static const size_t kFuzzPxLimit = 1024 * 1024;
58
#endif
59
60
// Demuxed or decoded animation frames.
61
static const int kFuzzFrameLimit = 3;
62
63
// Reads and sums (up to) 128 spread-out bytes.
64
12.8k
static WEBP_INLINE uint8_t FuzzHash(const uint8_t* const data, size_t size) {
65
12.8k
  uint8_t value = 0;
66
12.8k
  size_t incr = size / 128;
67
12.8k
  if (!incr) incr = 1;
68
549k
  for (size_t i = 0; i < size; i += incr) value += data[i];
69
12.8k
  return value;
70
12.8k
}
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_dec_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long)
Unexecuted instantiation: animencoder_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: enc_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)
advanced_api_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long)
Line
Count
Source
64
7.92k
static WEBP_INLINE uint8_t FuzzHash(const uint8_t* const data, size_t size) {
65
7.92k
  uint8_t value = 0;
66
7.92k
  size_t incr = size / 128;
67
7.92k
  if (!incr) incr = 1;
68
349k
  for (size_t i = 0; i < size; i += incr) value += data[i];
69
7.92k
  return value;
70
7.92k
}
simple_api_fuzzer.cc:fuzz_utils::FuzzHash(unsigned char const*, unsigned long)
Line
Count
Source
64
4.90k
static WEBP_INLINE uint8_t FuzzHash(const uint8_t* const data, size_t size) {
65
4.90k
  uint8_t value = 0;
66
4.90k
  size_t incr = size / 128;
67
4.90k
  if (!incr) incr = 1;
68
199k
  for (size_t i = 0; i < size; i += incr) value += data[i];
69
4.90k
  return value;
70
4.90k
}
71
72
#ifdef __cplusplus
73
extern "C" VP8CPUInfo VP8GetCPUInfo;
74
#else
75
extern VP8CPUInfo VP8GetCPUInfo;
76
#endif
77
78
//------------------------------------------------------------------------------
79
80
constexpr const uint8_t* kImagesData[] = {kImgAlphaData, kImgGridData,
81
                                          kImgPeakData};
82
constexpr size_t kNumSourceImages =
83
    sizeof(kImagesData) / sizeof(kImagesData[0]);
84
85
WebPPicture GetSourcePicture(int image_index, bool use_argb);
86
87
// Struct to use in a unique_ptr to free the memory.
88
struct UniquePtrDeleter {
89
56.0k
  void operator()(WebPMemoryWriter* writer) const {
90
56.0k
    WebPMemoryWriterClear(writer);
91
56.0k
  }
92
0
  void operator()(WebPPicture* pic) const { WebPPictureFree(pic); }
93
56.0k
  void operator()(WebPDecoderConfig* config) const {
94
56.0k
    WebPFreeDecBuffer(&config->output);
95
56.0k
  }
96
};
97
98
// Like WebPPicture but with no C array.
99
// This can be removed once b/294098900 is fixed.
100
struct WebPPictureCpp {
101
  inline WebPPictureCpp(int use_argb, WebPEncCSP colorspace, int width,
102
                        int height, uint8_t* y, uint8_t* u, uint8_t* v,
103
                        int y_stride, int uv_stride, uint8_t* a, int a_stride,
104
                        uint32_t* argb, int argb_stride, void* memory,
105
108k
                        void* memory_argb) {
106
108k
    pic.reset(new WebPPicture(), [](WebPPicture* pic) {
107
108k
      WebPPictureFree(pic);
108
108k
      delete pic;
109
108k
    });
110
108k
    if (!WebPPictureInit(pic.get())) assert(false);
111
108k
    pic->use_argb = use_argb;
112
108k
    pic->colorspace = colorspace;
113
108k
    pic->width = width;
114
108k
    pic->height = height;
115
108k
    pic->y = y;
116
108k
    pic->u = u;
117
108k
    pic->v = v;
118
108k
    pic->a = a;
119
108k
    pic->y_stride = y_stride;
120
108k
    pic->uv_stride = uv_stride;
121
108k
    pic->a_stride = a_stride;
122
108k
    pic->argb = argb;
123
108k
    pic->argb_stride = argb_stride;
124
108k
    pic->memory_ = memory;
125
108k
    pic->memory_argb_ = memory_argb;
126
108k
  }
127
108k
  WebPPicture& ref() const { return const_cast<WebPPicture&>(*pic); }
128
  std::shared_ptr<WebPPicture> pic;
129
};
130
131
22
static inline auto ArbitraryWebPPicture() {
132
22
  return fuzztest::FlatMap(
133
      // colorspace of 0 is use_argb, 1 is YUV420, 2 is YUV420A.
134
248k
      [](int colorspace, int width, int height) {
135
248k
        const int uv_width = (int)(((int64_t)width + 1) >> 1);
136
248k
        const int uv_height = (int)(((int64_t)height + 1) >> 1);
137
        // Create a domain for the vector that strictly obeys w * h * 4.
138
248k
        size_t size = width * height;
139
248k
        if (colorspace == 0) size *= 4;
140
248k
        if (colorspace == 1) size += 2 * uv_width * uv_height;
141
248k
        if (colorspace == 2) size += 2 * uv_width * uv_height + size;
142
248k
        auto DataDomain =
143
248k
            fuzztest::VectorOf(fuzztest::Arbitrary<uint8_t>()).WithSize(size);
144
145
        // Map the vector domain back into our Image struct, injecting w and h
146
248k
        return fuzztest::Map(
147
248k
            [colorspace, width,
148
248k
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
82.3k
              WebPPicture pic;
150
82.3k
              if (!WebPPictureInit(&pic)) assert(false);
151
82.3k
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
82.3k
              pic.colorspace = static_cast<WebPEncCSP>(
153
82.3k
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
82.3k
              pic.width = width;
155
82.3k
              pic.height = height;
156
82.3k
              if (!WebPPictureAlloc(&pic)) assert(false);
157
82.3k
              size_t size = width * height;
158
82.3k
              if (pic.use_argb) {
159
8.57k
                std::copy(data.begin(), data.begin() + size,
160
8.57k
                          (uint32_t*)pic.argb);
161
73.7k
              } else {
162
                // Y.
163
73.7k
                auto iter = data.begin();
164
73.7k
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
73.7k
                iter += size;
166
                // A.
167
73.7k
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
28.8k
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
28.8k
                  iter += size;
170
28.8k
                }
171
                // U and V.
172
73.7k
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
73.7k
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
73.7k
                size = uv_width * uv_height;
175
73.7k
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
73.7k
                iter += size;
177
73.7k
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
73.7k
              }
179
82.3k
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
82.3k
                                    pic.height, pic.y, pic.u, pic.v,
181
82.3k
                                    pic.y_stride, pic.uv_stride, pic.a,
182
82.3k
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
82.3k
                                    pic.memory_, pic.memory_argb_);
184
82.3k
            },
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()::{lambda(int, int, int)#1}::operator()(int, int, int) const::{lambda(std::__1::vector<unsigned char, {lambda(int, int, int)#1}::allocator<unsigned char> > const&)#1}::operator()(std::__1::vector<unsigned char, {lambda(int, int, int)#1}::allocator<unsigned char> > const) const
Line
Count
Source
148
43.1k
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
43.1k
              WebPPicture pic;
150
43.1k
              if (!WebPPictureInit(&pic)) assert(false);
151
43.1k
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
43.1k
              pic.colorspace = static_cast<WebPEncCSP>(
153
43.1k
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
43.1k
              pic.width = width;
155
43.1k
              pic.height = height;
156
43.1k
              if (!WebPPictureAlloc(&pic)) assert(false);
157
43.1k
              size_t size = width * height;
158
43.1k
              if (pic.use_argb) {
159
4.07k
                std::copy(data.begin(), data.begin() + size,
160
4.07k
                          (uint32_t*)pic.argb);
161
39.0k
              } else {
162
                // Y.
163
39.0k
                auto iter = data.begin();
164
39.0k
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
39.0k
                iter += size;
166
                // A.
167
39.0k
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
11.2k
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
11.2k
                  iter += size;
170
11.2k
                }
171
                // U and V.
172
39.0k
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
39.0k
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
39.0k
                size = uv_width * uv_height;
175
39.0k
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
39.0k
                iter += size;
177
39.0k
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
39.0k
              }
179
43.1k
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
43.1k
                                    pic.height, pic.y, pic.u, pic.v,
181
43.1k
                                    pic.y_stride, pic.uv_stride, pic.a,
182
43.1k
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
43.1k
                                    pic.memory_, pic.memory_argb_);
184
43.1k
            },
animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()::{lambda(int, int, int)#1}::operator()(int, int, int) const::{lambda(std::__1::vector<unsigned char, {lambda(int, int, int)#1}::allocator<unsigned char> > const&)#1}::operator()(std::__1::vector<unsigned char, {lambda(int, int, int)#1}::allocator<unsigned char> > const) const
Line
Count
Source
148
24.4k
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
24.4k
              WebPPicture pic;
150
24.4k
              if (!WebPPictureInit(&pic)) assert(false);
151
24.4k
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
24.4k
              pic.colorspace = static_cast<WebPEncCSP>(
153
24.4k
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
24.4k
              pic.width = width;
155
24.4k
              pic.height = height;
156
24.4k
              if (!WebPPictureAlloc(&pic)) assert(false);
157
24.4k
              size_t size = width * height;
158
24.4k
              if (pic.use_argb) {
159
2.42k
                std::copy(data.begin(), data.begin() + size,
160
2.42k
                          (uint32_t*)pic.argb);
161
22.0k
              } else {
162
                // Y.
163
22.0k
                auto iter = data.begin();
164
22.0k
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
22.0k
                iter += size;
166
                // A.
167
22.0k
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
12.9k
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
12.9k
                  iter += size;
170
12.9k
                }
171
                // U and V.
172
22.0k
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
22.0k
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
22.0k
                size = uv_width * uv_height;
175
22.0k
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
22.0k
                iter += size;
177
22.0k
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
22.0k
              }
179
24.4k
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
24.4k
                                    pic.height, pic.y, pic.u, pic.v,
181
24.4k
                                    pic.y_stride, pic.uv_stride, pic.a,
182
24.4k
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
24.4k
                                    pic.memory_, pic.memory_argb_);
184
24.4k
            },
enc_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()::{lambda(int, int, int)#1}::operator()(int, int, int) const::{lambda(std::__1::vector<unsigned char, {lambda(int, int, int)#1}::allocator<unsigned char> > const&)#1}::operator()(std::__1::vector<unsigned char, {lambda(int, int, int)#1}::allocator<unsigned char> > const) const
Line
Count
Source
148
14.7k
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
14.7k
              WebPPicture pic;
150
14.7k
              if (!WebPPictureInit(&pic)) assert(false);
151
14.7k
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
14.7k
              pic.colorspace = static_cast<WebPEncCSP>(
153
14.7k
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
14.7k
              pic.width = width;
155
14.7k
              pic.height = height;
156
14.7k
              if (!WebPPictureAlloc(&pic)) assert(false);
157
14.7k
              size_t size = width * height;
158
14.7k
              if (pic.use_argb) {
159
2.07k
                std::copy(data.begin(), data.begin() + size,
160
2.07k
                          (uint32_t*)pic.argb);
161
12.6k
              } else {
162
                // Y.
163
12.6k
                auto iter = data.begin();
164
12.6k
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
12.6k
                iter += size;
166
                // A.
167
12.6k
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
4.57k
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
4.57k
                  iter += size;
170
4.57k
                }
171
                // U and V.
172
12.6k
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
12.6k
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
12.6k
                size = uv_width * uv_height;
175
12.6k
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
12.6k
                iter += size;
177
12.6k
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
12.6k
              }
179
14.7k
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
14.7k
                                    pic.height, pic.y, pic.u, pic.v,
181
14.7k
                                    pic.y_stride, pic.uv_stride, pic.a,
182
14.7k
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
14.7k
                                    pic.memory_, pic.memory_argb_);
184
14.7k
            },
185
248k
            DataDomain);
186
248k
      },
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()::{lambda(int, int, int)#1}::operator()(int, int, int) const
Line
Count
Source
134
130k
      [](int colorspace, int width, int height) {
135
130k
        const int uv_width = (int)(((int64_t)width + 1) >> 1);
136
130k
        const int uv_height = (int)(((int64_t)height + 1) >> 1);
137
        // Create a domain for the vector that strictly obeys w * h * 4.
138
130k
        size_t size = width * height;
139
130k
        if (colorspace == 0) size *= 4;
140
130k
        if (colorspace == 1) size += 2 * uv_width * uv_height;
141
130k
        if (colorspace == 2) size += 2 * uv_width * uv_height + size;
142
130k
        auto DataDomain =
143
130k
            fuzztest::VectorOf(fuzztest::Arbitrary<uint8_t>()).WithSize(size);
144
145
        // Map the vector domain back into our Image struct, injecting w and h
146
130k
        return fuzztest::Map(
147
130k
            [colorspace, width,
148
130k
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
130k
              WebPPicture pic;
150
130k
              if (!WebPPictureInit(&pic)) assert(false);
151
130k
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
130k
              pic.colorspace = static_cast<WebPEncCSP>(
153
130k
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
130k
              pic.width = width;
155
130k
              pic.height = height;
156
130k
              if (!WebPPictureAlloc(&pic)) assert(false);
157
130k
              size_t size = width * height;
158
130k
              if (pic.use_argb) {
159
130k
                std::copy(data.begin(), data.begin() + size,
160
130k
                          (uint32_t*)pic.argb);
161
130k
              } else {
162
                // Y.
163
130k
                auto iter = data.begin();
164
130k
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
130k
                iter += size;
166
                // A.
167
130k
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
130k
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
130k
                  iter += size;
170
130k
                }
171
                // U and V.
172
130k
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
130k
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
130k
                size = uv_width * uv_height;
175
130k
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
130k
                iter += size;
177
130k
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
130k
              }
179
130k
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
130k
                                    pic.height, pic.y, pic.u, pic.v,
181
130k
                                    pic.y_stride, pic.uv_stride, pic.a,
182
130k
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
130k
                                    pic.memory_, pic.memory_argb_);
184
130k
            },
185
130k
            DataDomain);
186
130k
      },
animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()::{lambda(int, int, int)#1}::operator()(int, int, int) const
Line
Count
Source
134
73.7k
      [](int colorspace, int width, int height) {
135
73.7k
        const int uv_width = (int)(((int64_t)width + 1) >> 1);
136
73.7k
        const int uv_height = (int)(((int64_t)height + 1) >> 1);
137
        // Create a domain for the vector that strictly obeys w * h * 4.
138
73.7k
        size_t size = width * height;
139
73.7k
        if (colorspace == 0) size *= 4;
140
73.7k
        if (colorspace == 1) size += 2 * uv_width * uv_height;
141
73.7k
        if (colorspace == 2) size += 2 * uv_width * uv_height + size;
142
73.7k
        auto DataDomain =
143
73.7k
            fuzztest::VectorOf(fuzztest::Arbitrary<uint8_t>()).WithSize(size);
144
145
        // Map the vector domain back into our Image struct, injecting w and h
146
73.7k
        return fuzztest::Map(
147
73.7k
            [colorspace, width,
148
73.7k
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
73.7k
              WebPPicture pic;
150
73.7k
              if (!WebPPictureInit(&pic)) assert(false);
151
73.7k
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
73.7k
              pic.colorspace = static_cast<WebPEncCSP>(
153
73.7k
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
73.7k
              pic.width = width;
155
73.7k
              pic.height = height;
156
73.7k
              if (!WebPPictureAlloc(&pic)) assert(false);
157
73.7k
              size_t size = width * height;
158
73.7k
              if (pic.use_argb) {
159
73.7k
                std::copy(data.begin(), data.begin() + size,
160
73.7k
                          (uint32_t*)pic.argb);
161
73.7k
              } else {
162
                // Y.
163
73.7k
                auto iter = data.begin();
164
73.7k
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
73.7k
                iter += size;
166
                // A.
167
73.7k
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
73.7k
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
73.7k
                  iter += size;
170
73.7k
                }
171
                // U and V.
172
73.7k
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
73.7k
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
73.7k
                size = uv_width * uv_height;
175
73.7k
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
73.7k
                iter += size;
177
73.7k
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
73.7k
              }
179
73.7k
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
73.7k
                                    pic.height, pic.y, pic.u, pic.v,
181
73.7k
                                    pic.y_stride, pic.uv_stride, pic.a,
182
73.7k
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
73.7k
                                    pic.memory_, pic.memory_argb_);
184
73.7k
            },
185
73.7k
            DataDomain);
186
73.7k
      },
enc_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()::{lambda(int, int, int)#1}::operator()(int, int, int) const
Line
Count
Source
134
44.4k
      [](int colorspace, int width, int height) {
135
44.4k
        const int uv_width = (int)(((int64_t)width + 1) >> 1);
136
44.4k
        const int uv_height = (int)(((int64_t)height + 1) >> 1);
137
        // Create a domain for the vector that strictly obeys w * h * 4.
138
44.4k
        size_t size = width * height;
139
44.4k
        if (colorspace == 0) size *= 4;
140
44.4k
        if (colorspace == 1) size += 2 * uv_width * uv_height;
141
44.4k
        if (colorspace == 2) size += 2 * uv_width * uv_height + size;
142
44.4k
        auto DataDomain =
143
44.4k
            fuzztest::VectorOf(fuzztest::Arbitrary<uint8_t>()).WithSize(size);
144
145
        // Map the vector domain back into our Image struct, injecting w and h
146
44.4k
        return fuzztest::Map(
147
44.4k
            [colorspace, width,
148
44.4k
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
44.4k
              WebPPicture pic;
150
44.4k
              if (!WebPPictureInit(&pic)) assert(false);
151
44.4k
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
44.4k
              pic.colorspace = static_cast<WebPEncCSP>(
153
44.4k
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
44.4k
              pic.width = width;
155
44.4k
              pic.height = height;
156
44.4k
              if (!WebPPictureAlloc(&pic)) assert(false);
157
44.4k
              size_t size = width * height;
158
44.4k
              if (pic.use_argb) {
159
44.4k
                std::copy(data.begin(), data.begin() + size,
160
44.4k
                          (uint32_t*)pic.argb);
161
44.4k
              } else {
162
                // Y.
163
44.4k
                auto iter = data.begin();
164
44.4k
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
44.4k
                iter += size;
166
                // A.
167
44.4k
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
44.4k
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
44.4k
                  iter += size;
170
44.4k
                }
171
                // U and V.
172
44.4k
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
44.4k
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
44.4k
                size = uv_width * uv_height;
175
44.4k
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
44.4k
                iter += size;
177
44.4k
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
44.4k
              }
179
44.4k
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
44.4k
                                    pic.height, pic.y, pic.u, pic.v,
181
44.4k
                                    pic.y_stride, pic.uv_stride, pic.a,
182
44.4k
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
44.4k
                                    pic.memory_, pic.memory_argb_);
184
44.4k
            },
185
44.4k
            DataDomain);
186
44.4k
      },
187
22
      /*colorspace=*/fuzztest::InRange<int>(0, 2),
188
22
      /*width=*/fuzztest::InRange<int>(1, 128),
189
22
      /*height=*/fuzztest::InRange<int>(1, 128));
190
22
}
Unexecuted instantiation: mux_demux_api_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Unexecuted instantiation: imageio_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Unexecuted instantiation: fuzz_utils.cc:fuzz_utils::ArbitraryWebPPicture()
Unexecuted instantiation: huffman_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Line
Count
Source
131
16
static inline auto ArbitraryWebPPicture() {
132
16
  return fuzztest::FlatMap(
133
      // colorspace of 0 is use_argb, 1 is YUV420, 2 is YUV420A.
134
16
      [](int colorspace, int width, int height) {
135
16
        const int uv_width = (int)(((int64_t)width + 1) >> 1);
136
16
        const int uv_height = (int)(((int64_t)height + 1) >> 1);
137
        // Create a domain for the vector that strictly obeys w * h * 4.
138
16
        size_t size = width * height;
139
16
        if (colorspace == 0) size *= 4;
140
16
        if (colorspace == 1) size += 2 * uv_width * uv_height;
141
16
        if (colorspace == 2) size += 2 * uv_width * uv_height + size;
142
16
        auto DataDomain =
143
16
            fuzztest::VectorOf(fuzztest::Arbitrary<uint8_t>()).WithSize(size);
144
145
        // Map the vector domain back into our Image struct, injecting w and h
146
16
        return fuzztest::Map(
147
16
            [colorspace, width,
148
16
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
16
              WebPPicture pic;
150
16
              if (!WebPPictureInit(&pic)) assert(false);
151
16
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
16
              pic.colorspace = static_cast<WebPEncCSP>(
153
16
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
16
              pic.width = width;
155
16
              pic.height = height;
156
16
              if (!WebPPictureAlloc(&pic)) assert(false);
157
16
              size_t size = width * height;
158
16
              if (pic.use_argb) {
159
16
                std::copy(data.begin(), data.begin() + size,
160
16
                          (uint32_t*)pic.argb);
161
16
              } else {
162
                // Y.
163
16
                auto iter = data.begin();
164
16
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
16
                iter += size;
166
                // A.
167
16
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
16
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
16
                  iter += size;
170
16
                }
171
                // U and V.
172
16
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
16
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
16
                size = uv_width * uv_height;
175
16
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
16
                iter += size;
177
16
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
16
              }
179
16
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
16
                                    pic.height, pic.y, pic.u, pic.v,
181
16
                                    pic.y_stride, pic.uv_stride, pic.a,
182
16
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
16
                                    pic.memory_, pic.memory_argb_);
184
16
            },
185
16
            DataDomain);
186
16
      },
187
16
      /*colorspace=*/fuzztest::InRange<int>(0, 2),
188
16
      /*width=*/fuzztest::InRange<int>(1, 128),
189
16
      /*height=*/fuzztest::InRange<int>(1, 128));
190
16
}
animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Line
Count
Source
131
4
static inline auto ArbitraryWebPPicture() {
132
4
  return fuzztest::FlatMap(
133
      // colorspace of 0 is use_argb, 1 is YUV420, 2 is YUV420A.
134
4
      [](int colorspace, int width, int height) {
135
4
        const int uv_width = (int)(((int64_t)width + 1) >> 1);
136
4
        const int uv_height = (int)(((int64_t)height + 1) >> 1);
137
        // Create a domain for the vector that strictly obeys w * h * 4.
138
4
        size_t size = width * height;
139
4
        if (colorspace == 0) size *= 4;
140
4
        if (colorspace == 1) size += 2 * uv_width * uv_height;
141
4
        if (colorspace == 2) size += 2 * uv_width * uv_height + size;
142
4
        auto DataDomain =
143
4
            fuzztest::VectorOf(fuzztest::Arbitrary<uint8_t>()).WithSize(size);
144
145
        // Map the vector domain back into our Image struct, injecting w and h
146
4
        return fuzztest::Map(
147
4
            [colorspace, width,
148
4
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
4
              WebPPicture pic;
150
4
              if (!WebPPictureInit(&pic)) assert(false);
151
4
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
4
              pic.colorspace = static_cast<WebPEncCSP>(
153
4
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
4
              pic.width = width;
155
4
              pic.height = height;
156
4
              if (!WebPPictureAlloc(&pic)) assert(false);
157
4
              size_t size = width * height;
158
4
              if (pic.use_argb) {
159
4
                std::copy(data.begin(), data.begin() + size,
160
4
                          (uint32_t*)pic.argb);
161
4
              } else {
162
                // Y.
163
4
                auto iter = data.begin();
164
4
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
4
                iter += size;
166
                // A.
167
4
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
4
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
4
                  iter += size;
170
4
                }
171
                // U and V.
172
4
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
4
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
4
                size = uv_width * uv_height;
175
4
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
4
                iter += size;
177
4
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
4
              }
179
4
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
4
                                    pic.height, pic.y, pic.u, pic.v,
181
4
                                    pic.y_stride, pic.uv_stride, pic.a,
182
4
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
4
                                    pic.memory_, pic.memory_argb_);
184
4
            },
185
4
            DataDomain);
186
4
      },
187
4
      /*colorspace=*/fuzztest::InRange<int>(0, 2),
188
4
      /*width=*/fuzztest::InRange<int>(1, 128),
189
4
      /*height=*/fuzztest::InRange<int>(1, 128));
190
4
}
Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
enc_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Line
Count
Source
131
2
static inline auto ArbitraryWebPPicture() {
132
2
  return fuzztest::FlatMap(
133
      // colorspace of 0 is use_argb, 1 is YUV420, 2 is YUV420A.
134
2
      [](int colorspace, int width, int height) {
135
2
        const int uv_width = (int)(((int64_t)width + 1) >> 1);
136
2
        const int uv_height = (int)(((int64_t)height + 1) >> 1);
137
        // Create a domain for the vector that strictly obeys w * h * 4.
138
2
        size_t size = width * height;
139
2
        if (colorspace == 0) size *= 4;
140
2
        if (colorspace == 1) size += 2 * uv_width * uv_height;
141
2
        if (colorspace == 2) size += 2 * uv_width * uv_height + size;
142
2
        auto DataDomain =
143
2
            fuzztest::VectorOf(fuzztest::Arbitrary<uint8_t>()).WithSize(size);
144
145
        // Map the vector domain back into our Image struct, injecting w and h
146
2
        return fuzztest::Map(
147
2
            [colorspace, width,
148
2
             height](const std::vector<uint8_t>& data) -> WebPPictureCpp {
149
2
              WebPPicture pic;
150
2
              if (!WebPPictureInit(&pic)) assert(false);
151
2
              pic.use_argb = colorspace == 0 ? 1 : 0;
152
2
              pic.colorspace = static_cast<WebPEncCSP>(
153
2
                  colorspace <= 1 ? WEBP_YUV420 : WEBP_YUV420A);
154
2
              pic.width = width;
155
2
              pic.height = height;
156
2
              if (!WebPPictureAlloc(&pic)) assert(false);
157
2
              size_t size = width * height;
158
2
              if (pic.use_argb) {
159
2
                std::copy(data.begin(), data.begin() + size,
160
2
                          (uint32_t*)pic.argb);
161
2
              } else {
162
                // Y.
163
2
                auto iter = data.begin();
164
2
                std::copy(iter, iter + size, (uint8_t*)pic.y);
165
2
                iter += size;
166
                // A.
167
2
                if ((int)pic.colorspace & WEBP_CSP_ALPHA_BIT) {
168
2
                  std::copy(iter, iter + size, (uint8_t*)pic.a);
169
2
                  iter += size;
170
2
                }
171
                // U and V.
172
2
                const int uv_width = (int)(((int64_t)width + 1) >> 1);
173
2
                const int uv_height = (int)(((int64_t)height + 1) >> 1);
174
2
                size = uv_width * uv_height;
175
2
                std::copy(iter, iter + size, (uint8_t*)pic.u);
176
2
                iter += size;
177
2
                std::copy(iter, iter + size, (uint8_t*)pic.v);
178
2
              }
179
2
              return WebPPictureCpp(pic.use_argb, pic.colorspace, pic.width,
180
2
                                    pic.height, pic.y, pic.u, pic.v,
181
2
                                    pic.y_stride, pic.uv_stride, pic.a,
182
2
                                    pic.a_stride, pic.argb, pic.argb_stride,
183
2
                                    pic.memory_, pic.memory_argb_);
184
2
            },
185
2
            DataDomain);
186
2
      },
187
2
      /*colorspace=*/fuzztest::InRange<int>(0, 2),
188
2
      /*width=*/fuzztest::InRange<int>(1, 128),
189
2
      /*height=*/fuzztest::InRange<int>(1, 128));
190
2
}
Unexecuted instantiation: animdecoder_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Unexecuted instantiation: animation_api_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Unexecuted instantiation: dec_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Unexecuted instantiation: advanced_api_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryWebPPicture()
191
192
20
static inline auto ArbitraryWebPPictureFromIndex() {
193
20
  return fuzztest::Map(
194
25.8k
      [](int index, bool use_argb) -> WebPPictureCpp {
195
        // Map the vector domain back into our Image struct, injecting w and h
196
25.8k
        WebPPicture pic = fuzz_utils::GetSourcePicture(index, use_argb);
197
25.8k
        return WebPPictureCpp(use_argb, pic.colorspace, pic.width, pic.height,
198
25.8k
                              pic.y, pic.u, pic.v, pic.y_stride, pic.uv_stride,
199
25.8k
                              pic.a, pic.a_stride, pic.argb, pic.argb_stride,
200
25.8k
                              pic.memory_, pic.memory_argb_);
201
25.8k
      },
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()::{lambda(int, bool)#1}::operator()(int, bool) const
Line
Count
Source
194
12.8k
      [](int index, bool use_argb) -> WebPPictureCpp {
195
        // Map the vector domain back into our Image struct, injecting w and h
196
12.8k
        WebPPicture pic = fuzz_utils::GetSourcePicture(index, use_argb);
197
12.8k
        return WebPPictureCpp(use_argb, pic.colorspace, pic.width, pic.height,
198
12.8k
                              pic.y, pic.u, pic.v, pic.y_stride, pic.uv_stride,
199
12.8k
                              pic.a, pic.a_stride, pic.argb, pic.argb_stride,
200
12.8k
                              pic.memory_, pic.memory_argb_);
201
12.8k
      },
animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()::{lambda(int, bool)#1}::operator()(int, bool) const
Line
Count
Source
194
12.9k
      [](int index, bool use_argb) -> WebPPictureCpp {
195
        // Map the vector domain back into our Image struct, injecting w and h
196
12.9k
        WebPPicture pic = fuzz_utils::GetSourcePicture(index, use_argb);
197
12.9k
        return WebPPictureCpp(use_argb, pic.colorspace, pic.width, pic.height,
198
12.9k
                              pic.y, pic.u, pic.v, pic.y_stride, pic.uv_stride,
199
12.9k
                              pic.a, pic.a_stride, pic.argb, pic.argb_stride,
200
12.9k
                              pic.memory_, pic.memory_argb_);
201
12.9k
      },
202
20
      /*index=*/fuzztest::InRange<int>(0, fuzz_utils::kNumSourceImages - 1),
203
20
      /*use_argb=*/fuzztest::Arbitrary<bool>());
204
20
}
Unexecuted instantiation: mux_demux_api_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: imageio_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: fuzz_utils.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: huffman_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Line
Count
Source
192
16
static inline auto ArbitraryWebPPictureFromIndex() {
193
16
  return fuzztest::Map(
194
16
      [](int index, bool use_argb) -> WebPPictureCpp {
195
        // Map the vector domain back into our Image struct, injecting w and h
196
16
        WebPPicture pic = fuzz_utils::GetSourcePicture(index, use_argb);
197
16
        return WebPPictureCpp(use_argb, pic.colorspace, pic.width, pic.height,
198
16
                              pic.y, pic.u, pic.v, pic.y_stride, pic.uv_stride,
199
16
                              pic.a, pic.a_stride, pic.argb, pic.argb_stride,
200
16
                              pic.memory_, pic.memory_argb_);
201
16
      },
202
16
      /*index=*/fuzztest::InRange<int>(0, fuzz_utils::kNumSourceImages - 1),
203
16
      /*use_argb=*/fuzztest::Arbitrary<bool>());
204
16
}
animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Line
Count
Source
192
4
static inline auto ArbitraryWebPPictureFromIndex() {
193
4
  return fuzztest::Map(
194
4
      [](int index, bool use_argb) -> WebPPictureCpp {
195
        // Map the vector domain back into our Image struct, injecting w and h
196
4
        WebPPicture pic = fuzz_utils::GetSourcePicture(index, use_argb);
197
4
        return WebPPictureCpp(use_argb, pic.colorspace, pic.width, pic.height,
198
4
                              pic.y, pic.u, pic.v, pic.y_stride, pic.uv_stride,
199
4
                              pic.a, pic.a_stride, pic.argb, pic.argb_stride,
200
4
                              pic.memory_, pic.memory_argb_);
201
4
      },
202
4
      /*index=*/fuzztest::InRange<int>(0, fuzz_utils::kNumSourceImages - 1),
203
4
      /*use_argb=*/fuzztest::Arbitrary<bool>());
204
4
}
Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: enc_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: animdecoder_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: animation_api_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: dec_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: advanced_api_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryWebPPictureFromIndex()
205
206
42
static inline auto ArbitraryWebPConfig() {
207
42
  return fuzztest::Map(
208
42
      [](int lossless, int quality, int method, int image_hint, int segments,
209
42
         int sns_strength, int filter_strength, int filter_sharpness,
210
42
         int filter_type, int autofilter, int alpha_compression,
211
42
         int alpha_filtering, int alpha_quality, int pass, int preprocessing,
212
42
         int partitions, int partition_limit, int emulate_jpeg_size,
213
42
         int thread_level, int low_memory, int near_lossless, int exact,
214
108k
         int use_delta_palette, int use_sharp_yuv) -> WebPConfig {
215
108k
        WebPConfig config;
216
108k
        if (!WebPConfigInit(&config)) assert(false);
217
108k
        config.lossless = lossless;
218
108k
        config.quality = quality;
219
108k
        config.method = method;
220
108k
        config.image_hint = (WebPImageHint)image_hint;
221
108k
        config.segments = segments;
222
108k
        config.sns_strength = sns_strength;
223
108k
        config.filter_strength = filter_strength;
224
108k
        config.filter_sharpness = filter_sharpness;
225
108k
        config.filter_type = filter_type;
226
108k
        config.autofilter = autofilter;
227
108k
        config.alpha_compression = alpha_compression;
228
108k
        config.alpha_filtering = alpha_filtering;
229
108k
        config.alpha_quality = alpha_quality;
230
108k
        config.pass = pass;
231
108k
        config.show_compressed = 1;
232
108k
        config.preprocessing = preprocessing;
233
108k
        config.partitions = partitions;
234
108k
        config.partition_limit = 10 * partition_limit;
235
108k
        config.emulate_jpeg_size = emulate_jpeg_size;
236
108k
        config.thread_level = thread_level;
237
108k
        config.low_memory = low_memory;
238
108k
        config.near_lossless = 20 * near_lossless;
239
108k
        config.exact = exact;
240
108k
        config.use_delta_palette = use_delta_palette;
241
108k
        config.use_sharp_yuv = use_sharp_yuv;
242
108k
        if (!WebPValidateConfig(&config)) assert(false);
243
108k
        return config;
244
108k
      },
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) const
Line
Count
Source
214
56.0k
         int use_delta_palette, int use_sharp_yuv) -> WebPConfig {
215
56.0k
        WebPConfig config;
216
56.0k
        if (!WebPConfigInit(&config)) assert(false);
217
56.0k
        config.lossless = lossless;
218
56.0k
        config.quality = quality;
219
56.0k
        config.method = method;
220
56.0k
        config.image_hint = (WebPImageHint)image_hint;
221
56.0k
        config.segments = segments;
222
56.0k
        config.sns_strength = sns_strength;
223
56.0k
        config.filter_strength = filter_strength;
224
56.0k
        config.filter_sharpness = filter_sharpness;
225
56.0k
        config.filter_type = filter_type;
226
56.0k
        config.autofilter = autofilter;
227
56.0k
        config.alpha_compression = alpha_compression;
228
56.0k
        config.alpha_filtering = alpha_filtering;
229
56.0k
        config.alpha_quality = alpha_quality;
230
56.0k
        config.pass = pass;
231
56.0k
        config.show_compressed = 1;
232
56.0k
        config.preprocessing = preprocessing;
233
56.0k
        config.partitions = partitions;
234
56.0k
        config.partition_limit = 10 * partition_limit;
235
56.0k
        config.emulate_jpeg_size = emulate_jpeg_size;
236
56.0k
        config.thread_level = thread_level;
237
56.0k
        config.low_memory = low_memory;
238
56.0k
        config.near_lossless = 20 * near_lossless;
239
56.0k
        config.exact = exact;
240
56.0k
        config.use_delta_palette = use_delta_palette;
241
56.0k
        config.use_sharp_yuv = use_sharp_yuv;
242
56.0k
        if (!WebPValidateConfig(&config)) assert(false);
243
56.0k
        return config;
244
56.0k
      },
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) const
Line
Count
Source
214
37.4k
         int use_delta_palette, int use_sharp_yuv) -> WebPConfig {
215
37.4k
        WebPConfig config;
216
37.4k
        if (!WebPConfigInit(&config)) assert(false);
217
37.4k
        config.lossless = lossless;
218
37.4k
        config.quality = quality;
219
37.4k
        config.method = method;
220
37.4k
        config.image_hint = (WebPImageHint)image_hint;
221
37.4k
        config.segments = segments;
222
37.4k
        config.sns_strength = sns_strength;
223
37.4k
        config.filter_strength = filter_strength;
224
37.4k
        config.filter_sharpness = filter_sharpness;
225
37.4k
        config.filter_type = filter_type;
226
37.4k
        config.autofilter = autofilter;
227
37.4k
        config.alpha_compression = alpha_compression;
228
37.4k
        config.alpha_filtering = alpha_filtering;
229
37.4k
        config.alpha_quality = alpha_quality;
230
37.4k
        config.pass = pass;
231
37.4k
        config.show_compressed = 1;
232
37.4k
        config.preprocessing = preprocessing;
233
37.4k
        config.partitions = partitions;
234
37.4k
        config.partition_limit = 10 * partition_limit;
235
37.4k
        config.emulate_jpeg_size = emulate_jpeg_size;
236
37.4k
        config.thread_level = thread_level;
237
37.4k
        config.low_memory = low_memory;
238
37.4k
        config.near_lossless = 20 * near_lossless;
239
37.4k
        config.exact = exact;
240
37.4k
        config.use_delta_palette = use_delta_palette;
241
37.4k
        config.use_sharp_yuv = use_sharp_yuv;
242
37.4k
        if (!WebPValidateConfig(&config)) assert(false);
243
37.4k
        return config;
244
37.4k
      },
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) const
Line
Count
Source
214
14.7k
         int use_delta_palette, int use_sharp_yuv) -> WebPConfig {
215
14.7k
        WebPConfig config;
216
14.7k
        if (!WebPConfigInit(&config)) assert(false);
217
14.7k
        config.lossless = lossless;
218
14.7k
        config.quality = quality;
219
14.7k
        config.method = method;
220
14.7k
        config.image_hint = (WebPImageHint)image_hint;
221
14.7k
        config.segments = segments;
222
14.7k
        config.sns_strength = sns_strength;
223
14.7k
        config.filter_strength = filter_strength;
224
14.7k
        config.filter_sharpness = filter_sharpness;
225
14.7k
        config.filter_type = filter_type;
226
14.7k
        config.autofilter = autofilter;
227
14.7k
        config.alpha_compression = alpha_compression;
228
14.7k
        config.alpha_filtering = alpha_filtering;
229
14.7k
        config.alpha_quality = alpha_quality;
230
14.7k
        config.pass = pass;
231
14.7k
        config.show_compressed = 1;
232
14.7k
        config.preprocessing = preprocessing;
233
14.7k
        config.partitions = partitions;
234
14.7k
        config.partition_limit = 10 * partition_limit;
235
14.7k
        config.emulate_jpeg_size = emulate_jpeg_size;
236
14.7k
        config.thread_level = thread_level;
237
14.7k
        config.low_memory = low_memory;
238
14.7k
        config.near_lossless = 20 * near_lossless;
239
14.7k
        config.exact = exact;
240
14.7k
        config.use_delta_palette = use_delta_palette;
241
14.7k
        config.use_sharp_yuv = use_sharp_yuv;
242
14.7k
        if (!WebPValidateConfig(&config)) assert(false);
243
14.7k
        return config;
244
14.7k
      },
245
42
      /*lossless=*/fuzztest::InRange<int>(0, 1),
246
42
      /*quality=*/fuzztest::InRange<int>(0, 100),
247
42
      /*method=*/fuzztest::InRange<int>(0, 6),
248
42
      /*image_hint=*/fuzztest::InRange<int>(0, WEBP_HINT_LAST - 1),
249
42
      /*segments=*/fuzztest::InRange<int>(1, 4),
250
42
      /*sns_strength=*/fuzztest::InRange<int>(0, 100),
251
42
      /*filter_strength=*/fuzztest::InRange<int>(0, 100),
252
42
      /*filter_sharpness=*/fuzztest::InRange<int>(0, 7),
253
42
      /*filter_type=*/fuzztest::InRange<int>(0, 1),
254
42
      /*autofilter=*/fuzztest::InRange<int>(0, 1),
255
42
      /*alpha_compression=*/fuzztest::InRange<int>(0, 1),
256
42
      /*alpha_filtering=*/fuzztest::InRange<int>(0, 2),
257
42
      /*alpha_quality=*/fuzztest::InRange<int>(0, 100),
258
42
      /*pass=*/fuzztest::InRange<int>(1, 10),
259
42
      /*preprocessing=*/fuzztest::InRange<int>(0, 2),
260
42
      /*partitions=*/fuzztest::InRange<int>(0, 3),
261
42
      /*partition_limit=*/fuzztest::InRange<int>(0, 10),
262
42
      /*emulate_jpeg_size=*/fuzztest::InRange<int>(0, 1),
263
42
      /*thread_level=*/fuzztest::InRange<int>(0, 1),
264
42
      /*low_memory=*/fuzztest::InRange<int>(0, 1),
265
42
      /*near_lossless=*/fuzztest::InRange<int>(0, 5),
266
42
      /*exact=*/fuzztest::InRange<int>(0, 1),
267
42
      /*use_delta_palette=*/fuzztest::InRange<int>(0, 1),
268
42
      /*use_sharp_yuv=*/fuzztest::InRange<int>(0, 1));
269
42
}
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_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()
Line
Count
Source
206
32
static inline auto ArbitraryWebPConfig() {
207
32
  return fuzztest::Map(
208
32
      [](int lossless, int quality, int method, int image_hint, int segments,
209
32
         int sns_strength, int filter_strength, int filter_sharpness,
210
32
         int filter_type, int autofilter, int alpha_compression,
211
32
         int alpha_filtering, int alpha_quality, int pass, int preprocessing,
212
32
         int partitions, int partition_limit, int emulate_jpeg_size,
213
32
         int thread_level, int low_memory, int near_lossless, int exact,
214
32
         int use_delta_palette, int use_sharp_yuv) -> WebPConfig {
215
32
        WebPConfig config;
216
32
        if (!WebPConfigInit(&config)) assert(false);
217
32
        config.lossless = lossless;
218
32
        config.quality = quality;
219
32
        config.method = method;
220
32
        config.image_hint = (WebPImageHint)image_hint;
221
32
        config.segments = segments;
222
32
        config.sns_strength = sns_strength;
223
32
        config.filter_strength = filter_strength;
224
32
        config.filter_sharpness = filter_sharpness;
225
32
        config.filter_type = filter_type;
226
32
        config.autofilter = autofilter;
227
32
        config.alpha_compression = alpha_compression;
228
32
        config.alpha_filtering = alpha_filtering;
229
32
        config.alpha_quality = alpha_quality;
230
32
        config.pass = pass;
231
32
        config.show_compressed = 1;
232
32
        config.preprocessing = preprocessing;
233
32
        config.partitions = partitions;
234
32
        config.partition_limit = 10 * partition_limit;
235
32
        config.emulate_jpeg_size = emulate_jpeg_size;
236
32
        config.thread_level = thread_level;
237
32
        config.low_memory = low_memory;
238
32
        config.near_lossless = 20 * near_lossless;
239
32
        config.exact = exact;
240
32
        config.use_delta_palette = use_delta_palette;
241
32
        config.use_sharp_yuv = use_sharp_yuv;
242
32
        if (!WebPValidateConfig(&config)) assert(false);
243
32
        return config;
244
32
      },
245
32
      /*lossless=*/fuzztest::InRange<int>(0, 1),
246
32
      /*quality=*/fuzztest::InRange<int>(0, 100),
247
32
      /*method=*/fuzztest::InRange<int>(0, 6),
248
32
      /*image_hint=*/fuzztest::InRange<int>(0, WEBP_HINT_LAST - 1),
249
32
      /*segments=*/fuzztest::InRange<int>(1, 4),
250
32
      /*sns_strength=*/fuzztest::InRange<int>(0, 100),
251
32
      /*filter_strength=*/fuzztest::InRange<int>(0, 100),
252
32
      /*filter_sharpness=*/fuzztest::InRange<int>(0, 7),
253
32
      /*filter_type=*/fuzztest::InRange<int>(0, 1),
254
32
      /*autofilter=*/fuzztest::InRange<int>(0, 1),
255
32
      /*alpha_compression=*/fuzztest::InRange<int>(0, 1),
256
32
      /*alpha_filtering=*/fuzztest::InRange<int>(0, 2),
257
32
      /*alpha_quality=*/fuzztest::InRange<int>(0, 100),
258
32
      /*pass=*/fuzztest::InRange<int>(1, 10),
259
32
      /*preprocessing=*/fuzztest::InRange<int>(0, 2),
260
32
      /*partitions=*/fuzztest::InRange<int>(0, 3),
261
32
      /*partition_limit=*/fuzztest::InRange<int>(0, 10),
262
32
      /*emulate_jpeg_size=*/fuzztest::InRange<int>(0, 1),
263
32
      /*thread_level=*/fuzztest::InRange<int>(0, 1),
264
32
      /*low_memory=*/fuzztest::InRange<int>(0, 1),
265
32
      /*near_lossless=*/fuzztest::InRange<int>(0, 5),
266
32
      /*exact=*/fuzztest::InRange<int>(0, 1),
267
32
      /*use_delta_palette=*/fuzztest::InRange<int>(0, 1),
268
32
      /*use_sharp_yuv=*/fuzztest::InRange<int>(0, 1));
269
32
}
animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()
Line
Count
Source
206
8
static inline auto ArbitraryWebPConfig() {
207
8
  return fuzztest::Map(
208
8
      [](int lossless, int quality, int method, int image_hint, int segments,
209
8
         int sns_strength, int filter_strength, int filter_sharpness,
210
8
         int filter_type, int autofilter, int alpha_compression,
211
8
         int alpha_filtering, int alpha_quality, int pass, int preprocessing,
212
8
         int partitions, int partition_limit, int emulate_jpeg_size,
213
8
         int thread_level, int low_memory, int near_lossless, int exact,
214
8
         int use_delta_palette, int use_sharp_yuv) -> WebPConfig {
215
8
        WebPConfig config;
216
8
        if (!WebPConfigInit(&config)) assert(false);
217
8
        config.lossless = lossless;
218
8
        config.quality = quality;
219
8
        config.method = method;
220
8
        config.image_hint = (WebPImageHint)image_hint;
221
8
        config.segments = segments;
222
8
        config.sns_strength = sns_strength;
223
8
        config.filter_strength = filter_strength;
224
8
        config.filter_sharpness = filter_sharpness;
225
8
        config.filter_type = filter_type;
226
8
        config.autofilter = autofilter;
227
8
        config.alpha_compression = alpha_compression;
228
8
        config.alpha_filtering = alpha_filtering;
229
8
        config.alpha_quality = alpha_quality;
230
8
        config.pass = pass;
231
8
        config.show_compressed = 1;
232
8
        config.preprocessing = preprocessing;
233
8
        config.partitions = partitions;
234
8
        config.partition_limit = 10 * partition_limit;
235
8
        config.emulate_jpeg_size = emulate_jpeg_size;
236
8
        config.thread_level = thread_level;
237
8
        config.low_memory = low_memory;
238
8
        config.near_lossless = 20 * near_lossless;
239
8
        config.exact = exact;
240
8
        config.use_delta_palette = use_delta_palette;
241
8
        config.use_sharp_yuv = use_sharp_yuv;
242
8
        if (!WebPValidateConfig(&config)) assert(false);
243
8
        return config;
244
8
      },
245
8
      /*lossless=*/fuzztest::InRange<int>(0, 1),
246
8
      /*quality=*/fuzztest::InRange<int>(0, 100),
247
8
      /*method=*/fuzztest::InRange<int>(0, 6),
248
8
      /*image_hint=*/fuzztest::InRange<int>(0, WEBP_HINT_LAST - 1),
249
8
      /*segments=*/fuzztest::InRange<int>(1, 4),
250
8
      /*sns_strength=*/fuzztest::InRange<int>(0, 100),
251
8
      /*filter_strength=*/fuzztest::InRange<int>(0, 100),
252
8
      /*filter_sharpness=*/fuzztest::InRange<int>(0, 7),
253
8
      /*filter_type=*/fuzztest::InRange<int>(0, 1),
254
8
      /*autofilter=*/fuzztest::InRange<int>(0, 1),
255
8
      /*alpha_compression=*/fuzztest::InRange<int>(0, 1),
256
8
      /*alpha_filtering=*/fuzztest::InRange<int>(0, 2),
257
8
      /*alpha_quality=*/fuzztest::InRange<int>(0, 100),
258
8
      /*pass=*/fuzztest::InRange<int>(1, 10),
259
8
      /*preprocessing=*/fuzztest::InRange<int>(0, 2),
260
8
      /*partitions=*/fuzztest::InRange<int>(0, 3),
261
8
      /*partition_limit=*/fuzztest::InRange<int>(0, 10),
262
8
      /*emulate_jpeg_size=*/fuzztest::InRange<int>(0, 1),
263
8
      /*thread_level=*/fuzztest::InRange<int>(0, 1),
264
8
      /*low_memory=*/fuzztest::InRange<int>(0, 1),
265
8
      /*near_lossless=*/fuzztest::InRange<int>(0, 5),
266
8
      /*exact=*/fuzztest::InRange<int>(0, 1),
267
8
      /*use_delta_palette=*/fuzztest::InRange<int>(0, 1),
268
8
      /*use_sharp_yuv=*/fuzztest::InRange<int>(0, 1));
269
8
}
Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()
enc_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()
Line
Count
Source
206
2
static inline auto ArbitraryWebPConfig() {
207
2
  return fuzztest::Map(
208
2
      [](int lossless, int quality, int method, int image_hint, int segments,
209
2
         int sns_strength, int filter_strength, int filter_sharpness,
210
2
         int filter_type, int autofilter, int alpha_compression,
211
2
         int alpha_filtering, int alpha_quality, int pass, int preprocessing,
212
2
         int partitions, int partition_limit, int emulate_jpeg_size,
213
2
         int thread_level, int low_memory, int near_lossless, int exact,
214
2
         int use_delta_palette, int use_sharp_yuv) -> WebPConfig {
215
2
        WebPConfig config;
216
2
        if (!WebPConfigInit(&config)) assert(false);
217
2
        config.lossless = lossless;
218
2
        config.quality = quality;
219
2
        config.method = method;
220
2
        config.image_hint = (WebPImageHint)image_hint;
221
2
        config.segments = segments;
222
2
        config.sns_strength = sns_strength;
223
2
        config.filter_strength = filter_strength;
224
2
        config.filter_sharpness = filter_sharpness;
225
2
        config.filter_type = filter_type;
226
2
        config.autofilter = autofilter;
227
2
        config.alpha_compression = alpha_compression;
228
2
        config.alpha_filtering = alpha_filtering;
229
2
        config.alpha_quality = alpha_quality;
230
2
        config.pass = pass;
231
2
        config.show_compressed = 1;
232
2
        config.preprocessing = preprocessing;
233
2
        config.partitions = partitions;
234
2
        config.partition_limit = 10 * partition_limit;
235
2
        config.emulate_jpeg_size = emulate_jpeg_size;
236
2
        config.thread_level = thread_level;
237
2
        config.low_memory = low_memory;
238
2
        config.near_lossless = 20 * near_lossless;
239
2
        config.exact = exact;
240
2
        config.use_delta_palette = use_delta_palette;
241
2
        config.use_sharp_yuv = use_sharp_yuv;
242
2
        if (!WebPValidateConfig(&config)) assert(false);
243
2
        return config;
244
2
      },
245
2
      /*lossless=*/fuzztest::InRange<int>(0, 1),
246
2
      /*quality=*/fuzztest::InRange<int>(0, 100),
247
2
      /*method=*/fuzztest::InRange<int>(0, 6),
248
2
      /*image_hint=*/fuzztest::InRange<int>(0, WEBP_HINT_LAST - 1),
249
2
      /*segments=*/fuzztest::InRange<int>(1, 4),
250
2
      /*sns_strength=*/fuzztest::InRange<int>(0, 100),
251
2
      /*filter_strength=*/fuzztest::InRange<int>(0, 100),
252
2
      /*filter_sharpness=*/fuzztest::InRange<int>(0, 7),
253
2
      /*filter_type=*/fuzztest::InRange<int>(0, 1),
254
2
      /*autofilter=*/fuzztest::InRange<int>(0, 1),
255
2
      /*alpha_compression=*/fuzztest::InRange<int>(0, 1),
256
2
      /*alpha_filtering=*/fuzztest::InRange<int>(0, 2),
257
2
      /*alpha_quality=*/fuzztest::InRange<int>(0, 100),
258
2
      /*pass=*/fuzztest::InRange<int>(1, 10),
259
2
      /*preprocessing=*/fuzztest::InRange<int>(0, 2),
260
2
      /*partitions=*/fuzztest::InRange<int>(0, 3),
261
2
      /*partition_limit=*/fuzztest::InRange<int>(0, 10),
262
2
      /*emulate_jpeg_size=*/fuzztest::InRange<int>(0, 1),
263
2
      /*thread_level=*/fuzztest::InRange<int>(0, 1),
264
2
      /*low_memory=*/fuzztest::InRange<int>(0, 1),
265
2
      /*near_lossless=*/fuzztest::InRange<int>(0, 5),
266
2
      /*exact=*/fuzztest::InRange<int>(0, 1),
267
2
      /*use_delta_palette=*/fuzztest::InRange<int>(0, 1),
268
2
      /*use_sharp_yuv=*/fuzztest::InRange<int>(0, 1));
269
2
}
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()
Unexecuted instantiation: advanced_api_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()
Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryWebPConfig()
270
271
// Like WebPDecoderOptions but with no C array.
272
// This can be removed once b/294098900 is fixed.
273
struct WebPDecoderOptionsCpp {
274
  int bypass_filtering;
275
  int no_fancy_upsampling;
276
  int use_cropping;
277
  int crop_left, crop_top;
278
279
  int crop_width, crop_height;
280
  int use_scaling;
281
  int scaled_width, scaled_height;
282
283
  int use_threads;
284
  int dithering_strength;
285
  int flip;
286
  int alpha_dithering_strength;
287
288
  std::array<uint32_t, 5> pad;
289
};
290
291
22
static inline auto ArbitraryValidWebPDecoderOptions() {
292
22
  return fuzztest::Map(
293
22
      [](int bypass_filtering, int no_fancy_upsampling, int use_cropping,
294
22
         int crop_left, int crop_top, int crop_width, int crop_height,
295
22
         int use_scaling, int scaled_width, int scaled_height, int use_threads,
296
22
         int dithering_strength, int flip,
297
40.2k
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
298
40.2k
        WebPDecoderOptions options;
299
40.2k
        options.bypass_filtering = bypass_filtering;
300
40.2k
        options.no_fancy_upsampling = no_fancy_upsampling;
301
40.2k
        options.use_cropping = use_cropping;
302
40.2k
        options.crop_left = crop_left;
303
40.2k
        options.crop_top = crop_top;
304
40.2k
        options.crop_width = crop_width;
305
40.2k
        options.crop_height = crop_height;
306
40.2k
        options.use_scaling = use_scaling;
307
40.2k
        options.scaled_width = scaled_width;
308
40.2k
        options.scaled_height = scaled_height;
309
40.2k
        options.use_threads = use_threads;
310
40.2k
        options.dithering_strength = dithering_strength;
311
40.2k
        options.flip = flip;
312
40.2k
        options.alpha_dithering_strength = alpha_dithering_strength;
313
40.2k
        WebPDecoderConfig config;
314
40.2k
        if (!WebPInitDecoderConfig(&config)) assert(false);
315
40.2k
        config.options = options;
316
40.2k
        if (!WebPValidateDecoderConfig(&config)) assert(false);
317
40.2k
        WebPDecoderOptionsCpp options_cpp;
318
40.2k
        std::memcpy(&options_cpp, &options, sizeof(options));
319
40.2k
        return options_cpp;
320
40.2k
      },
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) const
Line
Count
Source
297
27.8k
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
298
27.8k
        WebPDecoderOptions options;
299
27.8k
        options.bypass_filtering = bypass_filtering;
300
27.8k
        options.no_fancy_upsampling = no_fancy_upsampling;
301
27.8k
        options.use_cropping = use_cropping;
302
27.8k
        options.crop_left = crop_left;
303
27.8k
        options.crop_top = crop_top;
304
27.8k
        options.crop_width = crop_width;
305
27.8k
        options.crop_height = crop_height;
306
27.8k
        options.use_scaling = use_scaling;
307
27.8k
        options.scaled_width = scaled_width;
308
27.8k
        options.scaled_height = scaled_height;
309
27.8k
        options.use_threads = use_threads;
310
27.8k
        options.dithering_strength = dithering_strength;
311
27.8k
        options.flip = flip;
312
27.8k
        options.alpha_dithering_strength = alpha_dithering_strength;
313
27.8k
        WebPDecoderConfig config;
314
27.8k
        if (!WebPInitDecoderConfig(&config)) assert(false);
315
27.8k
        config.options = options;
316
27.8k
        if (!WebPValidateDecoderConfig(&config)) assert(false);
317
27.8k
        WebPDecoderOptionsCpp options_cpp;
318
27.8k
        std::memcpy(&options_cpp, &options, sizeof(options));
319
27.8k
        return options_cpp;
320
27.8k
      },
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) const
Line
Count
Source
297
4.40k
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
298
4.40k
        WebPDecoderOptions options;
299
4.40k
        options.bypass_filtering = bypass_filtering;
300
4.40k
        options.no_fancy_upsampling = no_fancy_upsampling;
301
4.40k
        options.use_cropping = use_cropping;
302
4.40k
        options.crop_left = crop_left;
303
4.40k
        options.crop_top = crop_top;
304
4.40k
        options.crop_width = crop_width;
305
4.40k
        options.crop_height = crop_height;
306
4.40k
        options.use_scaling = use_scaling;
307
4.40k
        options.scaled_width = scaled_width;
308
4.40k
        options.scaled_height = scaled_height;
309
4.40k
        options.use_threads = use_threads;
310
4.40k
        options.dithering_strength = dithering_strength;
311
4.40k
        options.flip = flip;
312
4.40k
        options.alpha_dithering_strength = alpha_dithering_strength;
313
4.40k
        WebPDecoderConfig config;
314
4.40k
        if (!WebPInitDecoderConfig(&config)) assert(false);
315
4.40k
        config.options = options;
316
4.40k
        if (!WebPValidateDecoderConfig(&config)) assert(false);
317
4.40k
        WebPDecoderOptionsCpp options_cpp;
318
4.40k
        std::memcpy(&options_cpp, &options, sizeof(options));
319
4.40k
        return options_cpp;
320
4.40k
      },
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) const
Line
Count
Source
297
8.01k
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
298
8.01k
        WebPDecoderOptions options;
299
8.01k
        options.bypass_filtering = bypass_filtering;
300
8.01k
        options.no_fancy_upsampling = no_fancy_upsampling;
301
8.01k
        options.use_cropping = use_cropping;
302
8.01k
        options.crop_left = crop_left;
303
8.01k
        options.crop_top = crop_top;
304
8.01k
        options.crop_width = crop_width;
305
8.01k
        options.crop_height = crop_height;
306
8.01k
        options.use_scaling = use_scaling;
307
8.01k
        options.scaled_width = scaled_width;
308
8.01k
        options.scaled_height = scaled_height;
309
8.01k
        options.use_threads = use_threads;
310
8.01k
        options.dithering_strength = dithering_strength;
311
8.01k
        options.flip = flip;
312
8.01k
        options.alpha_dithering_strength = alpha_dithering_strength;
313
8.01k
        WebPDecoderConfig config;
314
8.01k
        if (!WebPInitDecoderConfig(&config)) assert(false);
315
8.01k
        config.options = options;
316
8.01k
        if (!WebPValidateDecoderConfig(&config)) assert(false);
317
8.01k
        WebPDecoderOptionsCpp options_cpp;
318
8.01k
        std::memcpy(&options_cpp, &options, sizeof(options));
319
8.01k
        return options_cpp;
320
8.01k
      },
321
22
      /*bypass_filtering=*/fuzztest::InRange<int>(0, 1),
322
22
      /*no_fancy_upsampling=*/fuzztest::InRange<int>(0, 1),
323
22
      /*use_cropping=*/fuzztest::InRange<int>(0, 1),
324
22
      /*crop_left=*/fuzztest::InRange<int>(0, 10),
325
22
      /*crop_top=*/fuzztest::InRange<int>(0, 10),
326
22
      /*crop_width=*/fuzztest::InRange<int>(1, 10),
327
22
      /*crop_height=*/fuzztest::InRange<int>(1, 10),
328
22
      /*use_scaling=*/fuzztest::InRange<int>(0, 1),
329
22
      /*scaled_width=*/fuzztest::InRange<int>(1, 10),
330
22
      /*scaled_height=*/fuzztest::InRange<int>(1, 10),
331
22
      /*use_threads=*/fuzztest::InRange<int>(0, 1),
332
22
      /*dithering_strength=*/fuzztest::InRange<int>(0, 100),
333
22
      /*flip=*/fuzztest::InRange<int>(0, 1),
334
22
      /*alpha_dithering_strength=*/fuzztest::InRange<int>(0, 100));
335
22
}
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()
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions()
Line
Count
Source
291
16
static inline auto ArbitraryValidWebPDecoderOptions() {
292
16
  return fuzztest::Map(
293
16
      [](int bypass_filtering, int no_fancy_upsampling, int use_cropping,
294
16
         int crop_left, int crop_top, int crop_width, int crop_height,
295
16
         int use_scaling, int scaled_width, int scaled_height, int use_threads,
296
16
         int dithering_strength, int flip,
297
16
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
298
16
        WebPDecoderOptions options;
299
16
        options.bypass_filtering = bypass_filtering;
300
16
        options.no_fancy_upsampling = no_fancy_upsampling;
301
16
        options.use_cropping = use_cropping;
302
16
        options.crop_left = crop_left;
303
16
        options.crop_top = crop_top;
304
16
        options.crop_width = crop_width;
305
16
        options.crop_height = crop_height;
306
16
        options.use_scaling = use_scaling;
307
16
        options.scaled_width = scaled_width;
308
16
        options.scaled_height = scaled_height;
309
16
        options.use_threads = use_threads;
310
16
        options.dithering_strength = dithering_strength;
311
16
        options.flip = flip;
312
16
        options.alpha_dithering_strength = alpha_dithering_strength;
313
16
        WebPDecoderConfig config;
314
16
        if (!WebPInitDecoderConfig(&config)) assert(false);
315
16
        config.options = options;
316
16
        if (!WebPValidateDecoderConfig(&config)) assert(false);
317
16
        WebPDecoderOptionsCpp options_cpp;
318
16
        std::memcpy(&options_cpp, &options, sizeof(options));
319
16
        return options_cpp;
320
16
      },
321
16
      /*bypass_filtering=*/fuzztest::InRange<int>(0, 1),
322
16
      /*no_fancy_upsampling=*/fuzztest::InRange<int>(0, 1),
323
16
      /*use_cropping=*/fuzztest::InRange<int>(0, 1),
324
16
      /*crop_left=*/fuzztest::InRange<int>(0, 10),
325
16
      /*crop_top=*/fuzztest::InRange<int>(0, 10),
326
16
      /*crop_width=*/fuzztest::InRange<int>(1, 10),
327
16
      /*crop_height=*/fuzztest::InRange<int>(1, 10),
328
16
      /*use_scaling=*/fuzztest::InRange<int>(0, 1),
329
16
      /*scaled_width=*/fuzztest::InRange<int>(1, 10),
330
16
      /*scaled_height=*/fuzztest::InRange<int>(1, 10),
331
16
      /*use_threads=*/fuzztest::InRange<int>(0, 1),
332
16
      /*dithering_strength=*/fuzztest::InRange<int>(0, 100),
333
16
      /*flip=*/fuzztest::InRange<int>(0, 1),
334
16
      /*alpha_dithering_strength=*/fuzztest::InRange<int>(0, 100));
335
16
}
Unexecuted instantiation: animencoder_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions()
Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions()
Unexecuted instantiation: enc_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
291
4
static inline auto ArbitraryValidWebPDecoderOptions() {
292
4
  return fuzztest::Map(
293
4
      [](int bypass_filtering, int no_fancy_upsampling, int use_cropping,
294
4
         int crop_left, int crop_top, int crop_width, int crop_height,
295
4
         int use_scaling, int scaled_width, int scaled_height, int use_threads,
296
4
         int dithering_strength, int flip,
297
4
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
298
4
        WebPDecoderOptions options;
299
4
        options.bypass_filtering = bypass_filtering;
300
4
        options.no_fancy_upsampling = no_fancy_upsampling;
301
4
        options.use_cropping = use_cropping;
302
4
        options.crop_left = crop_left;
303
4
        options.crop_top = crop_top;
304
4
        options.crop_width = crop_width;
305
4
        options.crop_height = crop_height;
306
4
        options.use_scaling = use_scaling;
307
4
        options.scaled_width = scaled_width;
308
4
        options.scaled_height = scaled_height;
309
4
        options.use_threads = use_threads;
310
4
        options.dithering_strength = dithering_strength;
311
4
        options.flip = flip;
312
4
        options.alpha_dithering_strength = alpha_dithering_strength;
313
4
        WebPDecoderConfig config;
314
4
        if (!WebPInitDecoderConfig(&config)) assert(false);
315
4
        config.options = options;
316
4
        if (!WebPValidateDecoderConfig(&config)) assert(false);
317
4
        WebPDecoderOptionsCpp options_cpp;
318
4
        std::memcpy(&options_cpp, &options, sizeof(options));
319
4
        return options_cpp;
320
4
      },
321
4
      /*bypass_filtering=*/fuzztest::InRange<int>(0, 1),
322
4
      /*no_fancy_upsampling=*/fuzztest::InRange<int>(0, 1),
323
4
      /*use_cropping=*/fuzztest::InRange<int>(0, 1),
324
4
      /*crop_left=*/fuzztest::InRange<int>(0, 10),
325
4
      /*crop_top=*/fuzztest::InRange<int>(0, 10),
326
4
      /*crop_width=*/fuzztest::InRange<int>(1, 10),
327
4
      /*crop_height=*/fuzztest::InRange<int>(1, 10),
328
4
      /*use_scaling=*/fuzztest::InRange<int>(0, 1),
329
4
      /*scaled_width=*/fuzztest::InRange<int>(1, 10),
330
4
      /*scaled_height=*/fuzztest::InRange<int>(1, 10),
331
4
      /*use_threads=*/fuzztest::InRange<int>(0, 1),
332
4
      /*dithering_strength=*/fuzztest::InRange<int>(0, 100),
333
4
      /*flip=*/fuzztest::InRange<int>(0, 1),
334
4
      /*alpha_dithering_strength=*/fuzztest::InRange<int>(0, 100));
335
4
}
advanced_api_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions()
Line
Count
Source
291
2
static inline auto ArbitraryValidWebPDecoderOptions() {
292
2
  return fuzztest::Map(
293
2
      [](int bypass_filtering, int no_fancy_upsampling, int use_cropping,
294
2
         int crop_left, int crop_top, int crop_width, int crop_height,
295
2
         int use_scaling, int scaled_width, int scaled_height, int use_threads,
296
2
         int dithering_strength, int flip,
297
2
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
298
2
        WebPDecoderOptions options;
299
2
        options.bypass_filtering = bypass_filtering;
300
2
        options.no_fancy_upsampling = no_fancy_upsampling;
301
2
        options.use_cropping = use_cropping;
302
2
        options.crop_left = crop_left;
303
2
        options.crop_top = crop_top;
304
2
        options.crop_width = crop_width;
305
2
        options.crop_height = crop_height;
306
2
        options.use_scaling = use_scaling;
307
2
        options.scaled_width = scaled_width;
308
2
        options.scaled_height = scaled_height;
309
2
        options.use_threads = use_threads;
310
2
        options.dithering_strength = dithering_strength;
311
2
        options.flip = flip;
312
2
        options.alpha_dithering_strength = alpha_dithering_strength;
313
2
        WebPDecoderConfig config;
314
2
        if (!WebPInitDecoderConfig(&config)) assert(false);
315
2
        config.options = options;
316
2
        if (!WebPValidateDecoderConfig(&config)) assert(false);
317
2
        WebPDecoderOptionsCpp options_cpp;
318
2
        std::memcpy(&options_cpp, &options, sizeof(options));
319
2
        return options_cpp;
320
2
      },
321
2
      /*bypass_filtering=*/fuzztest::InRange<int>(0, 1),
322
2
      /*no_fancy_upsampling=*/fuzztest::InRange<int>(0, 1),
323
2
      /*use_cropping=*/fuzztest::InRange<int>(0, 1),
324
2
      /*crop_left=*/fuzztest::InRange<int>(0, 10),
325
2
      /*crop_top=*/fuzztest::InRange<int>(0, 10),
326
2
      /*crop_width=*/fuzztest::InRange<int>(1, 10),
327
2
      /*crop_height=*/fuzztest::InRange<int>(1, 10),
328
2
      /*use_scaling=*/fuzztest::InRange<int>(0, 1),
329
2
      /*scaled_width=*/fuzztest::InRange<int>(1, 10),
330
2
      /*scaled_height=*/fuzztest::InRange<int>(1, 10),
331
2
      /*use_threads=*/fuzztest::InRange<int>(0, 1),
332
2
      /*dithering_strength=*/fuzztest::InRange<int>(0, 100),
333
2
      /*flip=*/fuzztest::InRange<int>(0, 1),
334
2
      /*alpha_dithering_strength=*/fuzztest::InRange<int>(0, 100));
335
2
}
Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryValidWebPDecoderOptions()
336
337
16
static inline auto ArbitraryWebPDecoderOptions() {
338
16
  return fuzztest::Map(
339
16
      [](int bypass_filtering, int no_fancy_upsampling, int use_cropping,
340
16
         int crop_left, int crop_top, int crop_width, int crop_height,
341
16
         int use_scaling, int scaled_width, int scaled_height, int use_threads,
342
16
         int dithering_strength, int flip,
343
28.1k
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
344
28.1k
        WebPDecoderOptions options;
345
28.1k
        options.bypass_filtering = bypass_filtering;
346
28.1k
        options.no_fancy_upsampling = no_fancy_upsampling;
347
28.1k
        options.use_cropping = use_cropping;
348
28.1k
        options.crop_left = crop_left;
349
28.1k
        options.crop_top = crop_top;
350
28.1k
        options.crop_width = crop_width;
351
28.1k
        options.crop_height = crop_height;
352
28.1k
        options.use_scaling = use_scaling;
353
28.1k
        options.scaled_width = scaled_width;
354
28.1k
        options.scaled_height = scaled_height;
355
28.1k
        options.use_threads = use_threads;
356
28.1k
        options.dithering_strength = dithering_strength;
357
28.1k
        options.flip = flip;
358
28.1k
        options.alpha_dithering_strength = alpha_dithering_strength;
359
28.1k
        WebPDecoderOptionsCpp options_cpp;
360
28.1k
        std::memcpy(&options_cpp, &options, sizeof(options));
361
28.1k
        return options_cpp;
362
28.1k
      },
363
16
      /*bypass_filtering=*/fuzztest::Arbitrary<int>(),
364
16
      /*no_fancy_upsampling=*/fuzztest::Arbitrary<int>(),
365
16
      /*use_cropping=*/fuzztest::Arbitrary<int>(),
366
16
      /*crop_left=*/fuzztest::Arbitrary<int>(),
367
16
      /*crop_top=*/fuzztest::Arbitrary<int>(),
368
16
      /*crop_width=*/fuzztest::Arbitrary<int>(),
369
16
      /*crop_height=*/fuzztest::Arbitrary<int>(),
370
16
      /*use_scaling=*/fuzztest::Arbitrary<int>(),
371
16
      /*scaled_width=*/fuzztest::Arbitrary<int>(),
372
16
      /*scaled_height=*/fuzztest::Arbitrary<int>(),
373
16
      /*use_threads=*/fuzztest::Arbitrary<int>(),
374
16
      /*dithering_strength=*/fuzztest::Arbitrary<int>(),
375
16
      /*flip=*/fuzztest::Arbitrary<int>(),
376
16
      /*alpha_dithering_strength=*/fuzztest::Arbitrary<int>());
377
16
}
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()
enc_dec_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions()
Line
Count
Source
337
16
static inline auto ArbitraryWebPDecoderOptions() {
338
16
  return fuzztest::Map(
339
16
      [](int bypass_filtering, int no_fancy_upsampling, int use_cropping,
340
16
         int crop_left, int crop_top, int crop_width, int crop_height,
341
16
         int use_scaling, int scaled_width, int scaled_height, int use_threads,
342
16
         int dithering_strength, int flip,
343
16
         int alpha_dithering_strength) -> WebPDecoderOptionsCpp {
344
16
        WebPDecoderOptions options;
345
16
        options.bypass_filtering = bypass_filtering;
346
16
        options.no_fancy_upsampling = no_fancy_upsampling;
347
16
        options.use_cropping = use_cropping;
348
16
        options.crop_left = crop_left;
349
16
        options.crop_top = crop_top;
350
16
        options.crop_width = crop_width;
351
16
        options.crop_height = crop_height;
352
16
        options.use_scaling = use_scaling;
353
16
        options.scaled_width = scaled_width;
354
16
        options.scaled_height = scaled_height;
355
16
        options.use_threads = use_threads;
356
16
        options.dithering_strength = dithering_strength;
357
16
        options.flip = flip;
358
16
        options.alpha_dithering_strength = alpha_dithering_strength;
359
16
        WebPDecoderOptionsCpp options_cpp;
360
16
        std::memcpy(&options_cpp, &options, sizeof(options));
361
16
        return options_cpp;
362
16
      },
363
16
      /*bypass_filtering=*/fuzztest::Arbitrary<int>(),
364
16
      /*no_fancy_upsampling=*/fuzztest::Arbitrary<int>(),
365
16
      /*use_cropping=*/fuzztest::Arbitrary<int>(),
366
16
      /*crop_left=*/fuzztest::Arbitrary<int>(),
367
16
      /*crop_top=*/fuzztest::Arbitrary<int>(),
368
16
      /*crop_width=*/fuzztest::Arbitrary<int>(),
369
16
      /*crop_height=*/fuzztest::Arbitrary<int>(),
370
16
      /*use_scaling=*/fuzztest::Arbitrary<int>(),
371
16
      /*scaled_width=*/fuzztest::Arbitrary<int>(),
372
16
      /*scaled_height=*/fuzztest::Arbitrary<int>(),
373
16
      /*use_threads=*/fuzztest::Arbitrary<int>(),
374
16
      /*dithering_strength=*/fuzztest::Arbitrary<int>(),
375
16
      /*flip=*/fuzztest::Arbitrary<int>(),
376
16
      /*alpha_dithering_strength=*/fuzztest::Arbitrary<int>());
377
16
}
Unexecuted instantiation: animencoder_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions()
Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions()
Unexecuted instantiation: enc_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()
Unexecuted instantiation: advanced_api_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions()
Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryWebPDecoderOptions()
378
379
struct CropOrScaleParams {
380
  bool alter_input;
381
  bool crop_or_scale;
382
  int width_ratio;
383
  int height_ratio;
384
  int left_ratio;
385
  int top_ratio;
386
};
387
388
42
static inline auto ArbitraryCropOrScaleParams() {
389
42
  return fuzztest::Map(
390
42
      [](const std::optional<std::pair<int, int>>& width_height_ratio,
391
42
         const std::optional<std::pair<int, int>>& left_top_ratio)
392
108k
          -> CropOrScaleParams {
393
108k
        CropOrScaleParams params;
394
108k
        params.alter_input = width_height_ratio.has_value();
395
108k
        if (params.alter_input) {
396
43.0k
          params.width_ratio = width_height_ratio->first;
397
43.0k
          params.height_ratio = width_height_ratio->second;
398
43.0k
          params.crop_or_scale = left_top_ratio.has_value();
399
43.0k
          if (params.crop_or_scale) {
400
9.82k
            params.left_ratio = left_top_ratio->first;
401
9.82k
            params.top_ratio = left_top_ratio->second;
402
9.82k
          }
403
43.0k
        }
404
108k
        return params;
405
108k
      },
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&) const
Line
Count
Source
392
56.0k
          -> CropOrScaleParams {
393
56.0k
        CropOrScaleParams params;
394
56.0k
        params.alter_input = width_height_ratio.has_value();
395
56.0k
        if (params.alter_input) {
396
21.7k
          params.width_ratio = width_height_ratio->first;
397
21.7k
          params.height_ratio = width_height_ratio->second;
398
21.7k
          params.crop_or_scale = left_top_ratio.has_value();
399
21.7k
          if (params.crop_or_scale) {
400
3.67k
            params.left_ratio = left_top_ratio->first;
401
3.67k
            params.top_ratio = left_top_ratio->second;
402
3.67k
          }
403
21.7k
        }
404
56.0k
        return params;
405
56.0k
      },
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&) const
Line
Count
Source
392
37.4k
          -> CropOrScaleParams {
393
37.4k
        CropOrScaleParams params;
394
37.4k
        params.alter_input = width_height_ratio.has_value();
395
37.4k
        if (params.alter_input) {
396
14.7k
          params.width_ratio = width_height_ratio->first;
397
14.7k
          params.height_ratio = width_height_ratio->second;
398
14.7k
          params.crop_or_scale = left_top_ratio.has_value();
399
14.7k
          if (params.crop_or_scale) {
400
5.46k
            params.left_ratio = left_top_ratio->first;
401
5.46k
            params.top_ratio = left_top_ratio->second;
402
5.46k
          }
403
14.7k
        }
404
37.4k
        return params;
405
37.4k
      },
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&) const
Line
Count
Source
392
14.7k
          -> CropOrScaleParams {
393
14.7k
        CropOrScaleParams params;
394
14.7k
        params.alter_input = width_height_ratio.has_value();
395
14.7k
        if (params.alter_input) {
396
6.54k
          params.width_ratio = width_height_ratio->first;
397
6.54k
          params.height_ratio = width_height_ratio->second;
398
6.54k
          params.crop_or_scale = left_top_ratio.has_value();
399
6.54k
          if (params.crop_or_scale) {
400
683
            params.left_ratio = left_top_ratio->first;
401
683
            params.top_ratio = left_top_ratio->second;
402
683
          }
403
6.54k
        }
404
14.7k
        return params;
405
14.7k
      },
406
42
      fuzztest::OptionalOf(
407
42
          fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))),
408
42
      fuzztest::OptionalOf(
409
42
          fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))));
410
42
}
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_dec_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()
Line
Count
Source
388
32
static inline auto ArbitraryCropOrScaleParams() {
389
32
  return fuzztest::Map(
390
32
      [](const std::optional<std::pair<int, int>>& width_height_ratio,
391
32
         const std::optional<std::pair<int, int>>& left_top_ratio)
392
32
          -> CropOrScaleParams {
393
32
        CropOrScaleParams params;
394
32
        params.alter_input = width_height_ratio.has_value();
395
32
        if (params.alter_input) {
396
32
          params.width_ratio = width_height_ratio->first;
397
32
          params.height_ratio = width_height_ratio->second;
398
32
          params.crop_or_scale = left_top_ratio.has_value();
399
32
          if (params.crop_or_scale) {
400
32
            params.left_ratio = left_top_ratio->first;
401
32
            params.top_ratio = left_top_ratio->second;
402
32
          }
403
32
        }
404
32
        return params;
405
32
      },
406
32
      fuzztest::OptionalOf(
407
32
          fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))),
408
32
      fuzztest::OptionalOf(
409
32
          fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))));
410
32
}
animencoder_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()
Line
Count
Source
388
8
static inline auto ArbitraryCropOrScaleParams() {
389
8
  return fuzztest::Map(
390
8
      [](const std::optional<std::pair<int, int>>& width_height_ratio,
391
8
         const std::optional<std::pair<int, int>>& left_top_ratio)
392
8
          -> CropOrScaleParams {
393
8
        CropOrScaleParams params;
394
8
        params.alter_input = width_height_ratio.has_value();
395
8
        if (params.alter_input) {
396
8
          params.width_ratio = width_height_ratio->first;
397
8
          params.height_ratio = width_height_ratio->second;
398
8
          params.crop_or_scale = left_top_ratio.has_value();
399
8
          if (params.crop_or_scale) {
400
8
            params.left_ratio = left_top_ratio->first;
401
8
            params.top_ratio = left_top_ratio->second;
402
8
          }
403
8
        }
404
8
        return params;
405
8
      },
406
8
      fuzztest::OptionalOf(
407
8
          fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))),
408
8
      fuzztest::OptionalOf(
409
8
          fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))));
410
8
}
Unexecuted instantiation: webp_info_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()
enc_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()
Line
Count
Source
388
2
static inline auto ArbitraryCropOrScaleParams() {
389
2
  return fuzztest::Map(
390
2
      [](const std::optional<std::pair<int, int>>& width_height_ratio,
391
2
         const std::optional<std::pair<int, int>>& left_top_ratio)
392
2
          -> CropOrScaleParams {
393
2
        CropOrScaleParams params;
394
2
        params.alter_input = width_height_ratio.has_value();
395
2
        if (params.alter_input) {
396
2
          params.width_ratio = width_height_ratio->first;
397
2
          params.height_ratio = width_height_ratio->second;
398
2
          params.crop_or_scale = left_top_ratio.has_value();
399
2
          if (params.crop_or_scale) {
400
2
            params.left_ratio = left_top_ratio->first;
401
2
            params.top_ratio = left_top_ratio->second;
402
2
          }
403
2
        }
404
2
        return params;
405
2
      },
406
2
      fuzztest::OptionalOf(
407
2
          fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))),
408
2
      fuzztest::OptionalOf(
409
2
          fuzztest::PairOf(fuzztest::InRange(1, 8), fuzztest::InRange(1, 8))));
410
2
}
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()
Unexecuted instantiation: advanced_api_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()
Unexecuted instantiation: simple_api_fuzzer.cc:fuzz_utils::ArbitraryCropOrScaleParams()
411
412
// Crops or scales a picture according to the given params.
413
int CropOrScale(WebPPicture* pic, const CropOrScaleParams& params);
414
415
// Imposes a level of optimization among one of the kMaxOptimizationIndex+1
416
// possible values: OnlyC, ForceSlowSSSE3, NoSSE41, NoAVX, default.
417
static constexpr uint32_t kMaxOptimizationIndex = 4;
418
void SetOptimization(VP8CPUInfo default_VP8GetCPUInfo, uint32_t index);
419
420
//------------------------------------------------------------------------------
421
422
// See https://developers.google.com/speed/webp/docs/riff_container.
423
static constexpr size_t kMaxWebPFileSize = (1ull << 32) - 2;  // 4 GiB - 2
424
425
std::vector<std::string> GetDictionaryFromFiles(
426
    const std::vector<std::string_view>& file_paths);
427
428
// Checks whether the binary blob containing a JPEG or WebP is too big for the
429
// fuzzer.
430
bool IsImageTooBig(const uint8_t* data, size_t size);
431
432
}  // namespace fuzz_utils
433
434
#endif  // WEBP_TESTS_FUZZER_FUZZ_UTILS_H_