1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <fuzzer/FuzzedDataProvider.h>
6
7 #include "testing/libfuzzer/fuzzers/libyuv_scale_fuzzer.h"
8 #include "third_party/libyuv/include/libyuv.h"
9
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)10 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
11 FuzzedDataProvider provider(data, size);
12
13 // Limit width and height for performance.
14 int src_width = provider.ConsumeIntegralInRange<int>(1, 256);
15 int src_height = provider.ConsumeIntegralInRange<int>(1, 256);
16
17 int filter_num =
18 provider.ConsumeIntegralInRange<int>(0, libyuv::FilterMode::kFilterBox);
19
20 int dst_width = provider.ConsumeIntegralInRange<int>(1, 256);
21 int dst_height = provider.ConsumeIntegralInRange<int>(1, 256);
22
23 std::string seed = provider.ConsumeRemainingBytesAsString();
24
25 Scale(true, src_width, src_height, dst_width, dst_height, filter_num, seed);
26 Scale(false, src_width, src_height, dst_width, dst_height, filter_num, seed);
27
28 return 0;
29 }
30