36 static void error(
const char *err)
38 fprintf(stderr,
"%s", err);
52 memcpy(buf, c->
fuzz, size);
65 if (whence == SEEK_CUR) {
66 if (offset > INT64_MAX - c->
pos)
69 }
else if (whence == SEEK_END) {
70 if (offset > INT64_MAX - c->
filesize)
76 if (offset < 0 || offset > c->
filesize)
85 static const uint64_t
FUZZ_TAG = 0x4741542D5A5A5546ULL;
92 char filename[1025] = {0};
95 int io_buffer_size = 32768;
110 error(
"Failed avformat_alloc_context()");
114 memcpy (filename, data + size - 1024, 1024);
118 io_buffer_size = bytestream2_get_le32(&gbc) & 0xFFFFFFF;
119 seekable = bytestream2_get_byte(&gbc) & 1;
120 filesize = bytestream2_get_le64(&gbc) & 0x7FFFFFFFFFFFFFFF;
124 error(
"Failed to allocate io_buffer");
133 error(
"avio_alloc_context failed");
135 avfmt->
pb = fuzzed_pb;
void av_log_set_level(int level)
Set the log level.
const uint32_t maxiteration
unsigned char * buffer
Start of the buffer.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static int io_read(void *opaque, uint8_t *buf, int buf_size)
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
static av_cold int end(AVCodecContext *avctx)
static const uint64_t FUZZ_TAG
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
#define AVERROR_EOF
End of file.
void avcodec_register_all(void)
Register all the codecs, parsers and bitstream filters which were enabled at configuration time...
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
simple assert() macros that are a bit more flexible than ISO C assert().
static const uint8_t offset[127][2]
Libavcodec external API header.
AVIOContext * pb
I/O context.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
static void error(const char *err)
This structure stores compressed data.
static int64_t io_seek(void *opaque, int64_t offset, int whence)