From patchwork Sun Dec 29 19:23:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 17044 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6113A44AFA7 for ; Sun, 29 Dec 2019 21:27:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 525DB68AC62; Sun, 29 Dec 2019 21:27:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-1.mx.upcmail.net (vie01a-dmta-pe03-1.mx.upcmail.net [62.179.121.160]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D515A68A877 for ; Sun, 29 Dec 2019 21:27:05 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1ileDQ-0005rR-0e for ffmpeg-devel@ffmpeg.org; Sun, 29 Dec 2019 20:27:04 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id leCSiQVtpwlysleCSis002; Sun, 29 Dec 2019 20:26:04 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=E5OzWpVl c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=8YUH2e0Ys_Mie9xma7wA:9 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 29 Dec 2019 20:23:37 +0100 Message-Id: <20191229192339.5809-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191229192339.5809-1-michael@niedermayer.cc> References: <20191229192339.5809-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfAFCDSsnNoo/MMGGEUeuVGh/1zOtRnbu2jHcX07Ibs5KbpaLFIaju6H2g+1O/cyKXdFExGS8ohuE4MeZL+pxws29sIjeVLWcI/isda2rik2HxqiGLtmK 1cXd5ZPnW5DhAqwHvb6lrz1QrqoaIT/pBzPv6dzSk/KMgdafdrHU1h+C Subject: [FFmpeg-devel] [PATCH 3/5] tools/target_dec_fuzzer: Fuzz private options of AC3/E-AC3 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This should improve AC-3 coverage Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 3f77ceac52..42dd36e2af 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -147,7 +147,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { const AVPacket *avpkt) = NULL; AVCodecParserContext *parser = NULL; uint64_t keyframes = 0; - + AVDictionary *opts = NULL; if (!c) { #ifdef FFMPEG_DECODER @@ -253,6 +253,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { ctx->idct_algo = bytestream2_get_byte(&gbc) % 25; + if (flags & 0x20) { + switch (ctx->codec_id) { + case AV_CODEC_ID_AC3: + case AV_CODEC_ID_EAC3: + av_dict_set_int(&opts, "cons_noisegen", bytestream2_get_byte(&gbc) & 1, 0); + av_dict_set_int(&opts, "heavy_compr", bytestream2_get_byte(&gbc) & 1, 0); + av_dict_set_int(&opts, "target_level", (int)(bytestream2_get_byte(&gbc) % 32) - 31, 0); + av_dict_set_int(&opts, "dmix_mode", (int)(bytestream2_get_byte(&gbc) % 4) - 1, 0); + break; + } + } + + if (extradata_size < size) { ctx->extradata = av_mallocz(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (ctx->extradata) { @@ -265,11 +278,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { ctx->width = ctx->height = 0; } - int res = avcodec_open2(ctx, c, NULL); + int res = avcodec_open2(ctx, c, &opts); if (res < 0) { avcodec_free_context(&ctx); av_free(parser_avctx); av_parser_close(parser); + av_dict_free(&opts); return 0; // Failure of avcodec_open2() does not imply that a issue was found } parser_avctx->codec_id = ctx->codec_id; @@ -374,5 +388,6 @@ maximums_reached: avcodec_free_context(&parser_avctx); av_parser_close(parser); av_packet_unref(&parsepkt); + av_dict_free(&opts); return 0; }