Browse Source

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>
tags/n3.4
Michael Niedermayer 8 years ago
parent
commit
dec2fa8cc7
2 changed files with 15 additions and 3 deletions
  1. +1
    -1
      tools/Makefile
  2. +14
    -2
      tools/target_dec_fuzzer.c

+ 1
- 1
tools/Makefile View File

@@ -2,7 +2,7 @@ TOOLS = qt-faststart trasher uncoded_frame
TOOLS-$(CONFIG_ZLIB) += cws2fws TOOLS-$(CONFIG_ZLIB) += cws2fws


tools/target_dec_%_fuzzer.o: tools/target_dec_fuzzer.c tools/target_dec_%_fuzzer.o: tools/target_dec_fuzzer.c
$(COMPILE_C) -DFFMPEG_CODEC=AV_CODEC_ID_$*
$(COMPILE_C) -DFFMPEG_DECODER=$*


OBJDIRS += tools OBJDIRS += tools




+ 14
- 2
tools/target_dec_fuzzer.c View File

@@ -66,7 +66,7 @@ static AVCodec *c = NULL;
static AVCodec *AVCodecInitialize(enum AVCodecID codec_id) static AVCodec *AVCodecInitialize(enum AVCodecID codec_id)
{ {
AVCodec *res; AVCodec *res;
avcodec_register_all();
av_log_set_level(AV_LOG_PANIC); av_log_set_level(AV_LOG_PANIC);
res = avcodec_find_decoder(codec_id); res = avcodec_find_decoder(codec_id);
if (!res) if (!res)
@@ -140,8 +140,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
int *got_picture_ptr, int *got_picture_ptr,
const AVPacket *avpkt) = NULL; 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. c = AVCodecInitialize(FFMPEG_CODEC); // Done once.
#endif
}


switch (c->type) { switch (c->type) {
case AVMEDIA_TYPE_AUDIO : decode_handler = avcodec_decode_audio4; break; case AVMEDIA_TYPE_AUDIO : decode_handler = avcodec_decode_audio4; break;


Loading…
Cancel
Save