Go to the documentation of this file.
64 static void error(
const char *err)
66 fprintf(stderr,
"%s", err);
77 error(
"Failed to find decoder");
86 if (
ret >= 0 && *got_sub_ptr)
99 static const uint64_t
FUZZ_TAG = 0x4741542D5A5A5546ULL;
106 uint64_t ec_pixels = 0;
107 uint64_t nb_samples = 0;
109 int *got_picture_ptr,
112 uint64_t keyframes = 0;
116 #ifdef FFMPEG_DECODER
117 #define DECODER_SYMBOL0(CODEC) ff_##CODEC##_decoder
118 #define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC)
119 extern AVCodec DECODER_SYMBOL(FFMPEG_DECODER);
120 codec_list[0] = &DECODER_SYMBOL(FFMPEG_DECODER);
123 #if FFMPEG_DECODER == tiff || FFMPEG_DECODER == tdsc
124 extern AVCodec DECODER_SYMBOL(mjpeg);
129 c = &DECODER_SYMBOL(FFMPEG_DECODER);
188 if (!
ctx || !parser_avctx)
189 error(
"Failed memory allocation");
193 ctx->refcounted_frames = 1;
203 ctx->width = bytestream2_get_le32(&gbc);
204 ctx->height = bytestream2_get_le32(&gbc);
206 ctx->bits_per_coded_sample = bytestream2_get_le32(&gbc);
208 flags = bytestream2_get_byte(&gbc);
224 extradata_size = bytestream2_get_le32(&gbc);
226 ctx->sample_rate = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
228 ctx->block_align = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
229 ctx->codec_tag = bytestream2_get_le32(&gbc);
235 keyframes = bytestream2_get_le64(&gbc);
236 ctx->request_channel_layout = bytestream2_get_le64(&gbc);
238 ctx->idct_algo = bytestream2_get_byte(&gbc) % 25;
241 switch (
ctx->codec_id) {
253 if (extradata_size <
size) {
255 if (
ctx->extradata) {
256 ctx->extradata_size = extradata_size;
262 ctx->width =
ctx->height = 0;
278 error(
"Failed memory allocation");
286 while (
data +
sizeof(fuzz_tag) <
end) {
291 if (
data +
sizeof(fuzz_tag) >
end)
296 error(
"Failed memory allocation");
297 memcpy(parsepkt.
data, last,
data - last);
299 keyframes = (keyframes >> 2) + (keyframes<<62);
300 data +=
sizeof(fuzz_tag);
303 while (parsepkt.
size > 0) {
309 parsepkt.
pts, parsepkt.
dts, parsepkt.
pos);
313 error(
"Failed memory allocation");
316 error(
"Failed memory allocation");
335 int ret = decode_handler(
ctx,
frame, &got_frame, &avpkt);
337 ec_pixels += (
ctx->width + 32LL) * (
ctx->height + 32LL);
338 if (
it > 20 || ec_pixels > 4 *
ctx->max_pixels)
339 ctx->error_concealment = 0;
341 goto maximums_reached;
343 nb_samples +=
frame->nb_samples;
345 goto maximums_reached;
347 if (ret <= 0 || ret > avpkt.
size)
365 decode_handler(
ctx,
frame, &got_frame, &avpkt);
368 fprintf(stderr,
"pixels decoded: %"PRId64
", samples decoded: %"PRId64
", iterations: %d\n", ec_pixels, nb_samples,
it);
@ AV_CODEC_ID_TRUEMOTION2
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
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 strict_std_compliance
Allow non-standard and experimental extension.
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.
@ AV_CODEC_ID_SCREENPRESSO
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
#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)
@ AV_CODEC_ID_FFWAVESYNTH
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.
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.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define FF_CODEC_TAGS_END
AVCodec.codec_tags termination value.
static AVCodec * AVCodecInitialize(enum AVCodecID codec_id)
const uint64_t maxpixels_per_frame
static const uint64_t FUZZ_TAG
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
@ AV_CODEC_ID_MOTIONPIXELS
#define AV_CODEC_FLAG2_FAST
Allow non spec compliant speedup tricks.
@ AV_PICTURE_TYPE_I
Intra.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
#define AV_EF_EXPLODE
abort decoding on minor error detection
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
static void error(const char *err)
#define AV_EF_CAREFUL
consider things that violate the spec, are fast to calculate and have not been seen in the wild as er...
AVCodecID
Identify the syntax and semantics of the bitstream.
static int subtitle_handler(AVCodecContext *avctx, void *frame, int *got_sub_ptr, AVPacket *avpkt)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
int flags
A combination of AV_PKT_FLAG values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and 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.
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
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
#define AV_INPUT_BUFFER_PADDING_SIZE
const uint32_t * codec_tags
List of supported codec_tags, terminated by FF_CODEC_TAGS_END.
main external API structure.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AV_EF_AGGRESSIVE
consider things that a sane encoder should not do as an error
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it.
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
This structure stores compressed data.
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)
#define flags(name, subs,...)
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...
#define FF_SANE_NB_CHANNELS
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.
uint64_t maxsamples_per_frame