59 static void error(
const char *err)
61 fprintf(stderr,
"%s", err);
72 error(
"Failed to find decoder");
81 if (ret >= 0 && *got_sub_ptr)
96 error(
"Failed memory allocation");
104 if (needed > FDB->
size_) {
109 error(
"Failed memory allocation");
117 memcpy(FDB->
data_, data, size);
121 memset(FDB->
data_ + size, 0, padd);
130 static const uint64_t
FUZZ_TAG = 0x4741542D5A5A5546ULL;
139 int *got_picture_ptr,
143 #ifdef FFMPEG_DECODER
144 #define DECODER_SYMBOL0(CODEC) ff_##CODEC##_decoder
145 #define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC)
146 extern AVCodec DECODER_SYMBOL(FFMPEG_DECODER);
149 c = &DECODER_SYMBOL(FFMPEG_DECODER);
169 error(
"Failed memory allocation");
176 ctx->
width = bytestream2_get_le32(&gbc);
177 ctx->
height = bytestream2_get_le32(&gbc);
178 ctx->
bit_rate = bytestream2_get_le64(&gbc);
195 error(
"Failed memory allocation");
201 while (data +
sizeof(fuzz_tag) < end) {
202 if (data[0] == (fuzz_tag & 0xFF) &&
AV_RN64(data) == fuzz_tag)
206 if (data +
sizeof(fuzz_tag) > end)
209 FDBPrepare(&buffer, &avpkt, last, data - last);
210 data +=
sizeof(fuzz_tag);
216 int ret = decode_handler(ctx, frame, &got_frame, &avpkt);
221 if (ret <= 0 || ret > avpkt.
size)
236 decode_handler(ctx, frame, &got_frame, &avpkt);
const uint32_t maxiteration
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
int64_t bit_rate
the average bitrate
void av_log_set_level(int level)
Set the log level.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
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.
static void FDBCreate(FuzzDataBuffer *FDB)
void avcodec_register_all(void)
Register all the codecs, parsers and bitstream filters which were enabled at configuration time...
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
#define FF_INPUT_BUFFER_PADDING_SIZE
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
static av_cold int end(AVCodecContext *avctx)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
#define AV_CODEC_CAP_HWACCEL_VDPAU
Codec can export data for HW decoding (VDPAU).
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static const uint64_t FUZZ_TAG
AVCodecID
Identify the syntax and semantics of the bitstream.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int error_concealment
error concealment flags
int capabilities
Codec capabilities.
simple assert() macros that are a bit more flexible than ISO C assert().
int64_t max_pixels
The number of pixels per image to maximally accept.
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...
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
static AVCodec * AVCodecInitialize(enum AVCodecID codec_id)
int width
picture width / height.
static void error(const char *err)
static int subtitle_handler(AVCodecContext *avctx, void *frame, int *got_sub_ptr, AVPacket *avpkt)
Libavcodec external API header.
enum AVMediaType codec_type
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.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
static void FDBPrepare(FuzzDataBuffer *FDB, AVPacket *dst, const uint8_t *data, size_t size)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
void avcodec_register(AVCodec *codec)
Register the codec codec and initialize libavcodec.
static void FDBDesroy(FuzzDataBuffer *FDB)
static void FDBRealloc(FuzzDataBuffer *FDB, size_t size)
This structure stores compressed data.