diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-05-03 16:36:39 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-05-03 17:22:13 +0200 |
commit | dec2fa8cc7089605d1d934d65dd2709cfe8aece2 (patch) | |
tree | 542fefe2a13ca58da2b32d8ca4f4e4ec19ac4df9 /tools/target_dec_fuzzer.c | |
parent | 3f17751eeb7e3348576e2597884d5e5155aadcfb (diff) |
tools/target_dec_fuzzer: Use decoder and not codec_id as argument
This allows fuzzing decoders with the same codec_id
We also avoid register all to allow the linker to prune unused sections and symbols
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'tools/target_dec_fuzzer.c')
-rw-r--r-- | tools/target_dec_fuzzer.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 65e79ebfe0..19423e27f2 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -66,7 +66,7 @@ static AVCodec *c = NULL; static AVCodec *AVCodecInitialize(enum AVCodecID codec_id) { AVCodec *res; - avcodec_register_all(); + av_log_set_level(AV_LOG_PANIC); res = avcodec_find_decoder(codec_id); if (!res) @@ -140,8 +140,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int *got_picture_ptr, const AVPacket *avpkt) = NULL; - if (!c) + if (!c) { +#ifdef FFMPEG_DECODER +#define DECODER_SYMBOL0(CODEC) ff_##CODEC##_decoder +#define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC) + extern AVCodec DECODER_SYMBOL(FFMPEG_DECODER); + avcodec_register(&DECODER_SYMBOL(FFMPEG_DECODER)); + int codec_id = DECODER_SYMBOL(FFMPEG_DECODER).id; + + c = AVCodecInitialize(codec_id); // Done once. +#else + avcodec_register_all(); c = AVCodecInitialize(FFMPEG_CODEC); // Done once. +#endif + } switch (c->type) { case AVMEDIA_TYPE_AUDIO : decode_handler = avcodec_decode_audio4; break; |