From patchwork Sun Jun 3 00:44:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9230 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp2382834jad; Sat, 2 Jun 2018 17:45:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJkjHpH0HVwpqbP/IHWdI/D1bXJYEmkys5haiNDtzg/UriOagCmEIk7KeoKb+gAMFnt1E0p X-Received: by 2002:adf:dfc2:: with SMTP id q2-v6mr10591931wrn.113.1527986734215; Sat, 02 Jun 2018 17:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527986734; cv=none; d=google.com; s=arc-20160816; b=dwIAwunyKF84a8v9YNmPEQyfLcrCY7DWgqJgHDpbHvKR9i+8EzsmM2plvkPklFzT1P d2I8e3ga8N5B4U1jOKL0wnV/ToGx/K2WuetbAeMXOteKnOuivYvi4rxyR1165u9KnWqh +O2jzlhGZJmklZuC/gWeKUMT86W8l/nywnLg5YeDZnc7R+fnoCUXrvge1l8ym1r+x44U mlW4lzwfOWTyMp/GDfZr0wsNPPsgMZR+M1KIBtg+04v/NTa+SrLP4KLzp+W3SP4E5/LH mLVcuGmVL27S+ZgaeDEdhORWu3L6/+ScPsRrOqf1WdcMA+ejGo3vsxnaeT5MiBEhtiln WE/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=TEbVbwpIGuEhN/tMlwmF35gxfxKuVTl1sKROZq/FrYY=; b=Ocb/hDEyjiBf9Edo8CnaX2TMvjt0TB+41FgjdBJtaUDB4EVEws+5JC+gTx05Ayma09 HKEpP77/rmynNChWh3INxDawdmgl5X8Gnkw68Py+W1mDedGiN02jkqnbxfWCYHe/fwTK VgZ6goZPtXXd197mOb9eiQDdYlxQzDMSWd8296SEIlhZxs4DAXNlQpKQuxpirjYvGTKu xBrVp2IvA5zLmXrvUEfktIFyM55ti+zGIgDDajBFEuWBQ/jPE9JOL4uF4ch45zG9JJRS CnGtBPvLHQsRdDSfVaxe7Dqh3hw+4XhYEcBTzWS00JPHYdEH7LLQYiqO7c8b99F7G1mq YaWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z30-v6si25185003wrz.226.2018.06.02.17.45.33; Sat, 02 Jun 2018 17:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DE232689E1D; Sun, 3 Jun 2018 03:44:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-3.mx.upcmail.net (vie01a-qmta-pe02-3.mx.upcmail.net [62.179.121.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0379E689DED for ; Sun, 3 Jun 2018 03:44:31 +0300 (EEST) Received: from [172.31.218.53] (helo=vie01a-dmta-pe08-2.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fPH92-0006vt-Mp for ffmpeg-devel@ffmpeg.org; Sun, 03 Jun 2018 02:45:16 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe08.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fPH8x-0004Mi-4i for ffmpeg-devel@ffmpeg.org; Sun, 03 Jun 2018 02:45:11 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id u0l01x0100S5wYM010l1Sa; Sun, 03 Jun 2018 02:45:02 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 3 Jun 2018 02:44:45 +0200 Message-Id: <20180603004446.10158-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/amrwbdec: Fix division by 0 in find_hb_gain() 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This restructures the code slightly toward D_UTIL_dec_synthesis() Fixes: 7420/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-6577305112543232 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/amrwbdec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index 7f2874d35f..47fe7eb55e 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -862,15 +862,20 @@ static float find_hb_gain(AMRWBContext *ctx, const float *synth, { int wsp = (vad > 0); float tilt; + float tmp; if (ctx->fr_cur_mode == MODE_23k85) return qua_hb_gain[hb_idx] * (1.0f / (1 << 14)); - tilt = ctx->celpm_ctx.dot_productf(synth, synth + 1, AMRWB_SFR_SIZE - 1) / - ctx->celpm_ctx.dot_productf(synth, synth, AMRWB_SFR_SIZE); + tmp = ctx->celpm_ctx.dot_productf(synth, synth + 1, AMRWB_SFR_SIZE - 1); + + if (tmp > 0) { + tilt = tmp / ctx->celpm_ctx.dot_productf(synth, synth, AMRWB_SFR_SIZE); + } else + tilt = 0; /* return gain bounded by [0.1, 1.0] */ - return av_clipf((1.0 - FFMAX(0.0, tilt)) * (1.25 - 0.25 * wsp), 0.1, 1.0); + return av_clipf((1.0 - tilt) * (1.25 - 0.25 * wsp), 0.1, 1.0); } /**