diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-04-30 11:44:51 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-04-30 14:24:51 +0200 |
commit | a9b5b6a97f4f4c0a9e06ea1485c02e3de58cc0b1 (patch) | |
tree | 26042eec8a6dd3c3e708b46258b614237b24171d | |
parent | 7796f290653349a4126f2d448d11bb4440b9f257 (diff) | |
download | ffmpeg-a9b5b6a97f4f4c0a9e06ea1485c02e3de58cc0b1.tar.gz |
tools: Eliminate codec_type complexity from fuzzer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | tools/Makefile | 11 | ||||
-rw-r--r-- | tools/target_dec_fuzzer.c | 19 |
2 files changed, 11 insertions, 19 deletions
diff --git a/tools/Makefile b/tools/Makefile index 2b9432bcc2..c4d9e90dea 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,15 +1,8 @@ TOOLS = qt-faststart trasher uncoded_frame TOOLS-$(CONFIG_ZLIB) += cws2fws -tools/target_dec_video_%_fuzzer.o: tools/target_dec_fuzzer.c - $(COMPILE_C) -DFFMPEG_CODEC=AV_CODEC_ID_$* -DFUZZ_FFMPEG_VIDEO - -tools/target_dec_audio_%_fuzzer.o: tools/target_dec_fuzzer.c - $(COMPILE_C) -DFFMPEG_CODEC=AV_CODEC_ID_$* -DFUZZ_FFMPEG_AUDIO - -tools/target_dec_subtitle_%_fuzzer.o: tools/target_dec_fuzzer.c - $(COMPILE_C) -DFFMPEG_CODEC=AV_CODEC_ID_$* -DFUZZ_FFMPEG_SUBTITLE - +tools/target_dec_%_fuzzer.o: tools/target_dec_fuzzer.c + $(COMPILE_C) -DFFMPEG_CODEC=AV_CODEC_ID_$* OBJDIRS += tools diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index e6a942cb30..ce58fe5eaf 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -74,11 +74,6 @@ static AVCodec *AVCodecInitialize(enum AVCodecID codec_id) return res; } -#if defined(FUZZ_FFMPEG_VIDEO) -#define decode_handler avcodec_decode_video2 -#elif defined(FUZZ_FFMPEG_AUDIO) -#define decode_handler avcodec_decode_audio4 -#elif defined(FUZZ_FFMPEG_SUBTITLE) static int subtitle_handler(AVCodecContext *avctx, void *frame, int *got_sub_ptr, AVPacket *avpkt) { @@ -89,11 +84,6 @@ static int subtitle_handler(AVCodecContext *avctx, void *frame, return ret; } -#define decode_handler subtitle_handler -#else -#error "Specify encoder type" // To catch mistakes -#endif - // Class to handle buffer allocation and resize for each frame typedef struct FuzzDataBuffer { size_t size_; @@ -146,10 +136,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { const uint8_t *last = data; const uint8_t *end = data + size; uint32_t it = 0; + int (*decode_handler)(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + const AVPacket *avpkt) = NULL; if (!c) c = AVCodecInitialize(FFMPEG_CODEC); // Done once. + switch (c->type) { + case AVMEDIA_TYPE_AUDIO : decode_handler = avcodec_decode_audio4; break; + case AVMEDIA_TYPE_VIDEO : decode_handler = avcodec_decode_video2; break; + case AVMEDIA_TYPE_SUBTITLE: decode_handler = subtitle_handler ; break; + } + AVCodecContext* ctx = avcodec_alloc_context3(NULL); if (!ctx) error("Failed memory allocation"); |