Debian Codegraph @

fuzzing/stream_fuzzer.cc

raw
1 /*
2 * H.265 video codec.
3 * Copyright (c) 2026 Dirk Farin <[email protected]>
4 *
5 * This file is part of libde265.
6 *
7 * libde265 is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * libde265 is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with libde265. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "de265.h"
22 #include <stdint.h>
23 #include <stddef.h>
24
25 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
26 {
27 de265_decoder_context* ctx = de265_new_decoder();
28 if (!ctx) {
29 return 0;
30 }
31
32 de265_set_parameter_bool(ctx, DE265_DECODER_PARAM_BOOL_SEI_CHECK_HASH, 0);
33 de265_set_parameter_bool(ctx, DE265_DECODER_PARAM_SUPPRESS_FAULTY_PICTURES, 0);
34 de265_set_parameter_int(ctx, DE265_DECODER_PARAM_ACCELERATION_CODE, de265_acceleration_SCALAR);
35
36 de265_push_data(ctx, data, size, 0, nullptr);
37 de265_flush_data(ctx);
38
39 int more = 1;
40 while (more) {
41 de265_error err = de265_decode(ctx, &more);
42 if (!more || (err != DE265_OK && err != DE265_ERROR_WAITING_FOR_INPUT_DATA)) {
43 break;
44 }
45
46 while (const de265_image* img = de265_get_next_picture(ctx)) {
47 (void)img;
48 }
49 }
50
51 de265_free_decoder(ctx);
52 return 0;
53 }