Go to the documentation of this file.
61 static void error(
const char *err)
63 fprintf(stderr,
"%s", err);
74 error(
"Failed to find decoder");
83 if (
ret >= 0 && *got_sub_ptr)
98 error(
"Failed memory allocation");
111 error(
"Failed memory allocation");
132 static const uint64_t
FUZZ_TAG = 0x4741542D5A5A5546ULL;
140 uint64_t ec_pixels = 0;
142 int *got_picture_ptr,
148 #ifdef FFMPEG_DECODER
149 #define DECODER_SYMBOL0(CODEC) ff_##CODEC##_decoder
150 #define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC)
151 extern AVCodec DECODER_SYMBOL(FFMPEG_DECODER);
152 codec_list[0] = &DECODER_SYMBOL(FFMPEG_DECODER);
155 c = &DECODER_SYMBOL(FFMPEG_DECODER);
171 if (!
ctx || !parser_avctx)
172 error(
"Failed memory allocation");
174 ctx->max_pixels = 4096 * 4096;
181 ctx->width = bytestream2_get_le32(&gbc);
182 ctx->height = bytestream2_get_le32(&gbc);
184 ctx->bits_per_coded_sample = bytestream2_get_le32(&gbc);
186 if (bytestream2_get_byte(&gbc) & 1)
189 extradata_size = bytestream2_get_le32(&gbc);
190 if (extradata_size <
size) {
192 if (
ctx->extradata) {
193 ctx->extradata_size = extradata_size;
199 ctx->width =
ctx->height = 0;
215 error(
"Failed memory allocation");
221 while (
data +
sizeof(fuzz_tag) <
end) {
226 if (
data +
sizeof(fuzz_tag) >
end)
230 data +=
sizeof(fuzz_tag);
233 while (parsepkt.
size > 0) {
239 parsepkt.
pts, parsepkt.
dts, parsepkt.
pos);
258 int ret = decode_handler(
ctx,
frame, &got_frame, &avpkt);
260 ec_pixels +=
ctx->width *
ctx->height;
261 if (
it > 20 || ec_pixels > 4 *
ctx->max_pixels)
262 ctx->error_concealment = 0;
264 if (ret <= 0 || ret > avpkt.
size)
280 decode_handler(
ctx,
frame, &got_frame, &avpkt);
attribute_deprecated int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
#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_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
void avcodec_register_all(void)
Register all the codecs, parsers and bitstream filters which were enabled at configuration time.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
AVCodecParserContext * av_parser_init(int codec_id)
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
static void FDBCreate(FuzzDataBuffer *FDB)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
static AVCodec * AVCodecInitialize(enum AVCodecID codec_id)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const uint64_t FUZZ_TAG
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
@ AV_PICTURE_TYPE_I
Intra.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
static void error(const char *err)
AVCodecID
Identify the syntax and semantics of the bitstream.
static int subtitle_handler(AVCodecContext *avctx, void *frame, int *got_sub_ptr, AVPacket *avpkt)
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int flags
A combination of AV_PKT_FLAG values.
void av_log_set_level(int level)
Set the log level.
int64_t pos
Byte position of currently parsed frame in stream.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
av_cold void avcodec_register(AVCodec *codec)
Register the codec codec and initialize libavcodec.
attribute_deprecated int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt)
Decode the video frame of size avpkt->size from avpkt->data into picture.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is needed
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_INPUT_BUFFER_PADDING_SIZE
main external API structure.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts, int64_t pos)
Parse a packet.
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
static void FDBPrepare(FuzzDataBuffer *FDB, AVPacket *dst, const uint8_t *data, size_t size)
This structure stores compressed data.
static void FDBRealloc(FuzzDataBuffer *FDB, size_t size)
int64_t pos
byte position in stream, -1 if unknown
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
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...
const uint32_t maxiteration
void av_parser_close(AVCodecParserContext *s)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
static void FDBDesroy(FuzzDataBuffer *FDB)