32static void error(
const char *err)
34 fprintf(stderr,
"%s", err);
40static const uint64_t
FUZZ_TAG = 0x4741542D5A5A5546ULL;
44 const uint8_t *last =
data;
48 uint64_t keyframes = 0;
49 uint64_t flushpattern = -1;
54#define BSF_SYMBOL0(BSF) ff_##BSF##_bsf
55#define BSF_SYMBOL(BSF) BSF_SYMBOL0(BSF)
57 f = &BSF_SYMBOL(FFMPEG_BSF);
64 error(
"Failed memory allocation");
81 id =
f->codec_ids[bytestream2_get_byte(&gbc) %
i];
86 extradata_size = bytestream2_get_le32(&gbc);
91 keyframes = bytestream2_get_le64(&gbc);
92 flushpattern = bytestream2_get_le64(&gbc);
93 flags = bytestream2_get_byte(&gbc);
96 if (!strcmp(
f->name,
"av1_metadata"))
98 else if (!strcmp(
f->name,
"h264_metadata") || !strcmp(
f->name,
"hevc_metadata") ||
99 !strcmp(
f->name,
"vvc_metadata"))
101 else if (!strcmp(
f->name,
"extract_extradata"))
105 if (extradata_size <
size) {
125 error(
"Failed memory allocation");
129 while (
data +
sizeof(fuzz_tag) < end) {
134 if (
data +
sizeof(fuzz_tag) > end)
139 error(
"Failed memory allocation");
140 memcpy(
pkt->data, last,
data - last);
142 keyframes = (keyframes >> 2) + (keyframes<<62);
143 data +=
sizeof(fuzz_tag);
146 if (!(flushpattern & 7))
148 flushpattern = (flushpattern >> 3) + (flushpattern << 61);
Libavcodec external API header.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
int av_bsf_get_null_filter(AVBSFContext **bsf)
Get null/pass-through bitstream filter.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
void av_log_set_level(int level)
Set the log level.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
common internal api header.
#define FF_SANE_NB_CHANNELS
Memory handling functions.
The bitstream filter state.
void * priv_data
Opaque filter-specific private data.
AVCodecParameters * par_in
Parameters of the input stream.
const struct AVBitStreamFilter * filter
The bitstream filter this context is an instance of.
int nb_channels
Number of channels in this layout.
int extradata_size
Size of the extradata content in bytes.
int height
The height of the video frame in pixels.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
int block_align
The number of bytes per coded audio frame, required by some formats.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
This structure stores compressed data.
static const uint64_t FUZZ_TAG
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
static void error(const char *err)