Go to the documentation of this file.
36 static void error(
const char *err)
38 fprintf(stderr,
"%s", err);
48 c->filesize =
FFMIN(
c->pos,
c->filesize);
52 memcpy(buf,
c->fuzz,
size);
56 c->filesize =
FFMAX(
c->filesize,
c->pos);
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;
96 int64_t filesize =
size;
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_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AVERROR_EOF
End of file.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
static av_cold int end(AVCodecContext *avctx)
#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)
void avcodec_register_all(void)
Register all the codecs, parsers and bitstream filters which were enabled at configuration time.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
static int io_read(void *opaque, uint8_t *buf, int buf_size)
static const uint64_t FUZZ_TAG
AVIOContext * pb
I/O context.
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.
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
void av_log_set_level(int level)
Set the log level.
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
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.
static void error(const char *err)
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
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)
const uint32_t maxiteration
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.