diff options
Diffstat (limited to 'tools/target_dec_fuzzer.c')
-rw-r--r-- | tools/target_dec_fuzzer.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 2fea29a308..288aa63313 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -54,6 +54,7 @@ #include "libavcodec/avcodec.h" #include "libavcodec/bytestream.h" +#include "libavcodec/codec_internal.h" #include "libavformat/avformat.h" //For FF_SANE_NB_CHANNELS, so we dont waste energy testing things that will get instantly rejected @@ -61,7 +62,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); -extern const AVCodec * codec_list[]; +extern const FFCodec * codec_list[]; static void error(const char *err) { @@ -69,15 +70,15 @@ static void error(const char *err) exit(1); } -static const AVCodec *c = NULL; -static const AVCodec *AVCodecInitialize(enum AVCodecID codec_id) +static const FFCodec *c = NULL; +static const FFCodec *AVCodecInitialize(enum AVCodecID codec_id) { const AVCodec *res; res = avcodec_find_decoder(codec_id); if (!res) error("Failed to find decoder"); - return res; + return ffcodec(res); } static int subtitle_handler(AVCodecContext *avctx, void *frame, @@ -127,11 +128,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { #ifdef FFMPEG_DECODER #define DECODER_SYMBOL0(CODEC) ff_##CODEC##_decoder #define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC) - extern AVCodec DECODER_SYMBOL(FFMPEG_DECODER); + extern FFCodec DECODER_SYMBOL(FFMPEG_DECODER); codec_list[0] = &DECODER_SYMBOL(FFMPEG_DECODER); #if FFMPEG_DECODER == tiff || FFMPEG_DECODER == tdsc - extern AVCodec DECODER_SYMBOL(mjpeg); + extern FFCodec DECODER_SYMBOL(mjpeg); codec_list[1] = &DECODER_SYMBOL(mjpeg); #endif @@ -142,17 +143,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { av_log_set_level(AV_LOG_PANIC); } - switch (c->type) { + switch (c->p.type) { case AVMEDIA_TYPE_AUDIO : case AVMEDIA_TYPE_VIDEO : decode_handler = audio_video_handler ; break; case AVMEDIA_TYPE_SUBTITLE: decode_handler = subtitle_handler ; break; } - switch (c->id) { + switch (c->p.id) { case AV_CODEC_ID_APE: maxsamples_per_frame /= 256; break; } maxpixels = maxpixels_per_frame * maxiteration; maxsamples = maxsamples_per_frame * maxiteration; - switch (c->id) { + switch (c->p.id) { case AV_CODEC_ID_AGM: maxpixels /= 1024; break; case AV_CODEC_ID_ARBC: maxpixels /= 1024; break; case AV_CODEC_ID_BINKVIDEO: maxpixels /= 32; break; @@ -231,7 +232,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { maxsamples_per_frame = FFMIN(maxsamples_per_frame, maxsamples); maxpixels_per_frame = FFMIN(maxpixels_per_frame , maxpixels); - AVCodecContext* ctx = avcodec_alloc_context3(c); + AVCodecContext* ctx = avcodec_alloc_context3(&c->p); AVCodecContext* parser_avctx = avcodec_alloc_context3(NULL); if (!ctx || !parser_avctx) error("Failed memory allocation"); @@ -257,7 +258,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { // Try to initialize a parser for this codec, note, this may fail which just means we test without one flags = bytestream2_get_byte(&gbc); if (flags & 1) - parser = av_parser_init(c->id); + parser = av_parser_init(c->p.id); if (flags & 2) ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; if (flags & 4) { @@ -265,7 +266,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (flags & 8) ctx->err_recognition |= AV_EF_EXPLODE; } - if ((flags & 0x10) && c->id != AV_CODEC_ID_H264) + if ((flags & 0x10) && c->p.id != AV_CODEC_ID_H264) ctx->flags2 |= AV_CODEC_FLAG2_FAST; if (flags & 0x80) ctx->flags2 |= AV_CODEC_FLAG2_EXPORT_MVS; @@ -349,7 +350,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { ctx->width = ctx->height = 0; } - int res = avcodec_open2(ctx, c, &opts); + int res = avcodec_open2(ctx, &c->p, &opts); if (res < 0) { avcodec_free_context(&ctx); av_free(parser_avctx); |