| 40 | static const uint64_t FUZZ_TAG = 0x4741542D5A5A5546ULL; |
| 41 | |
| 42 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
| 43 | const uint64_t fuzz_tag = FUZZ_TAG; |
| 44 | const uint8_t *last = data; |
| 45 | const uint8_t *end = data + size; |
| 46 | AVBSFContext *bsf = NULL; |
| 47 | AVPacket *pkt; |
| 48 | uint64_t keyframes = 0; |
| 49 | uint64_t flushpattern = -1; |
| 50 | int res; |
| 51 | |
| 52 | if (!f) { |
| 53 | #ifdef FFMPEG_BSF |
| 54 | #define BSF_SYMBOL0(BSF) ff_##BSF##_bsf |
| 55 | #define BSF_SYMBOL(BSF) BSF_SYMBOL0(BSF) |
| 56 | extern const AVBitStreamFilter BSF_SYMBOL(FFMPEG_BSF); |
| 57 | f = &BSF_SYMBOL(FFMPEG_BSF); |
| 58 | #endif |
| 59 | av_log_set_level(AV_LOG_PANIC); |
| 60 | } |
| 61 | |
| 62 | res = f ? av_bsf_alloc(f, &bsf) : av_bsf_get_null_filter(&bsf); |
| 63 | if (res < 0) |
| 64 | error("Failed memory allocation"); |
| 65 | f = bsf->filter; |
| 66 | |
| 67 | if (size > 1024) { |
| 68 | GetByteContext gbc; |
| 69 | int extradata_size; |
| 70 | int flags; |
| 71 | size -= 1024; |
| 72 | bytestream2_init(&gbc, data + size, 1024); |
| 73 | bsf->par_in->width = bytestream2_get_le32(&gbc); |
| 74 | bsf->par_in->height = bytestream2_get_le32(&gbc); |
| 75 | bsf->par_in->bit_rate = bytestream2_get_le64(&gbc); |
| 76 | bsf->par_in->bits_per_coded_sample = bytestream2_get_le32(&gbc); |
| 77 | |
| 78 | if (f->codec_ids) { |
| 79 | int i, id; |
| 80 | for (i = 0; f->codec_ids[i] != AV_CODEC_ID_NONE; i++); |
| 81 | id = f->codec_ids[bytestream2_get_byte(&gbc) % i]; |
| 82 | bsf->par_in->codec_id = id; |
| 83 | bsf->par_in->codec_tag = bytestream2_get_le32(&gbc); |
| 84 | } |
| 85 | |
| 86 | extradata_size = bytestream2_get_le32(&gbc); |
| 87 | |
| 88 | bsf->par_in->sample_rate = bytestream2_get_le32(&gbc); |
| 89 | bsf->par_in->ch_layout.nb_channels = (unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS; |
| 90 | bsf->par_in->block_align = bytestream2_get_le32(&gbc); |
| 91 | keyframes = bytestream2_get_le64(&gbc); |
| 92 | flushpattern = bytestream2_get_le64(&gbc); |
| 93 | flags = bytestream2_get_byte(&gbc); |
| 94 | |
| 95 | if (flags & 0x20) { |
| 96 | if (!strcmp(f->name, "av1_metadata")) |
| 97 | av_opt_set_int(bsf->priv_data, "td", bytestream2_get_byte(&gbc) % 3, 0); |
| 98 | else if (!strcmp(f->name, "h264_metadata") || !strcmp(f->name, "hevc_metadata") || |
| 99 | !strcmp(f->name, "vvc_metadata")) |
nothing calls this directly
no test coverage detected