Go to the documentation of this file.
44 static void error(
const char *err)
46 fprintf(stderr,
"%s", err);
50 static int io_read(
void *opaque, uint8_t *buf,
int buf_size)
56 c->filesize =
FFMIN(
c->pos,
c->filesize);
59 if (
c->pos > INT64_MAX -
size)
62 memcpy(buf,
c->fuzz,
size);
66 c->filesize =
FFMAX(
c->filesize,
c->pos);
75 if (whence == SEEK_CUR) {
76 if (
offset > INT64_MAX -
c->pos)
79 }
else if (whence == SEEK_END) {
80 if (
offset > INT64_MAX -
c->filesize)
86 if (offset < 0 || offset >
c->filesize)
100 static const uint64_t
FUZZ_TAG = 0x4741542D5A5A5546ULL;
107 char filename[1025] = {0};
110 int io_buffer_size = 32768;
117 #ifdef FFMPEG_DEMUXER
118 #define DEMUXER_SYMBOL0(DEMUXER) ff_##DEMUXER##_demuxer
119 #define DEMUXER_SYMBOL(DEMUXER) DEMUXER_SYMBOL0(DEMUXER)
121 fmt = &DEMUXER_SYMBOL(FFMPEG_DEMUXER);
130 error(
"Failed avformat_alloc_context()");
134 io_buffer_size =
size;
135 }
else if (
size > 2048) {
140 memcpy (filename,
data +
size - 1024, 1024);
144 io_buffer_size = bytestream2_get_le32(&gbc) & 0xFFFFFFF;
145 flags = bytestream2_get_byte(&gbc);
146 seekable =
flags & 1;
147 filesize = bytestream2_get_le64(&gbc) & 0x7FFFFFFFFFFFFFFF;
149 if ((
flags & 2) && strlen(filename) <
sizeof(filename) / 2) {
151 void *avif_iter =
NULL;
157 avif_count = bytestream2_get_le32(&gbc) % avif_count;
166 if (strchr(extension,
','))
167 *strchr(extension,
',') = 0;
168 av_strlcatf(filename,
sizeof(filename),
".%s", extension);
176 if (fmt && !strcmp(fmt->
name,
"hls"))
180 io_buffer_size =
size;
184 error(
"Failed to allocate pkt");
188 error(
"Failed to allocate io_buffer");
197 error(
"avio_alloc_context failed");
199 avfmt->
pb = fuzzed_pb;
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AVERROR_EOF
End of file.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
void avio_context_free(AVIOContext **s)
Free the supplied IO context and everything associated with it.
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.
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
static int64_t io_seek(void *opaque, int64_t offset, int whence)
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
static int io_read(void *opaque, uint8_t *buf, int buf_size)
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static const uint64_t FUZZ_TAG
AVIOContext * pb
I/O context.
static int interrupt_cb(void *ctx)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
static int64_t filesize(AVIOContext *pb)
void av_log_set_level(int level)
Set the log level.
static void error(const char *err)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
int64_t interrupt_counter
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s it
unsigned char * buffer
Start of the buffer.
This structure stores compressed data.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
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.
const uint32_t maxiteration