45static void error(
const char *err)
47 fprintf(stderr,
"%s", err);
51static int io_read(
void *opaque, uint8_t *buf,
int buf_size)
57 c->filesize =
FFMIN(
c->pos,
c->filesize);
60 if (
c->pos > INT64_MAX -
size)
63 memcpy(buf,
c->fuzz,
size);
67 c->filesize =
FFMAX(
c->filesize,
c->pos);
76 if (whence == SEEK_CUR) {
77 if (
offset > INT64_MAX -
c->pos)
80 }
else if (whence == SEEK_END) {
81 if (
offset > INT64_MAX -
c->filesize)
105 char filename[1025] = {0};
108 int io_buffer_size = 32768;
116#define DEMUXER_SYMBOL0(DEMUXER) ff_##DEMUXER##_demuxer
117#define DEMUXER_SYMBOL(DEMUXER) DEMUXER_SYMBOL0(DEMUXER)
119 fmt = &DEMUXER_SYMBOL(FFMPEG_DEMUXER).
p;
128 error(
"Failed avformat_alloc_context()");
132 io_buffer_size =
size;
133 }
else if (
size > 2048) {
138 memcpy (filename,
data +
size - 1024, 1024);
142 io_buffer_size = bytestream2_get_le32(&gbc) & 0xFFFFFFF;
143 flags = bytestream2_get_byte(&gbc);
144 seekable =
flags & 1;
145 filesize = bytestream2_get_le64(&gbc) & 0x7FFFFFFFFFFFFFFF;
147 if ((
flags & 2) && strlen(filename) <
sizeof(filename) / 2) {
149 void *avif_iter =
NULL;
155 avif_count = bytestream2_get_le32(&gbc) % avif_count;
164 if (strchr(extension,
','))
165 *strchr(extension,
',') = 0;
166 av_strlcatf(filename,
sizeof(filename),
".%s", extension);
174 if (fmt && !strcmp(fmt->
name,
"hls"))
178 io_buffer_size =
size;
182 error(
"Failed to allocate pkt");
198 error(
"avio_alloc_context failed");
200 avfmt->
pb = fuzzed_pb;
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
Libavcodec external API header.
#define AVSEEK_SIZE
Passing this as the "whence" parameter to a seek function causes it to return the filesize without se...
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, const 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.
void avio_context_free(AVIOContext **s)
Free the supplied IO context and everything associated with it.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
static int64_t filesize(AVIOContext *pb)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
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_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
#define AVERROR_EOF
End of file.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
void av_log_set_level(int level)
Set the log level.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Memory handling functions.
AVIOContext * pb
I/O context.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
unsigned char * buffer
Start of the buffer.
This structure stores compressed data.
const uint32_t maxiteration
static int64_t io_seek(void *opaque, int64_t offset, int whence)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
static void error(const char *err)
static int interrupt_cb(void *ctx)
int64_t interrupt_counter
static int io_read(void *opaque, uint8_t *buf, int buf_size)