From patchwork Sun Jan 26 16:12:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 17563 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 8D0CF44B04F for ; Sun, 26 Jan 2020 18:13:02 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7066B68AFC8; Sun, 26 Jan 2020 18:13:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from qq.com (out203-205-221-157.mail.qq.com [203.205.221.157]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9210468AF8C for ; Sun, 26 Jan 2020 18:12:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1580055170; bh=UkhWteQs6qXNZlJXh/CLP0hqC553axkw3R7R0nlA2Yo=; h=From:To:Cc:Subject:Date; b=MT98deim3l+ns2h05Yd3hDHwqBp7TLoyCV7AtRE7SmnY3C8CWI4IWyRVSIKiwMzkj gxhSxDB4ek3FYQZKuY6CTWa06gOvmyNshIw6KW6vSrFLKs3gxRIAfsmIRMHbbqiIgW iEb/95j7pn65QOhfWur2riQfcHa3QXy7Ex01BNs0= Received: from localhost.localdomain ([27.38.244.196]) by newxmesmtplogicsvrszb1.qq.com (NewEsmtp) with SMTP id 330342AF; Mon, 27 Jan 2020 00:12:48 +0800 X-QQ-mid: xmsmtpt1580055168t5d3gyipk X-QQ-XMAILINFO: M3Tg4wIwI+1kF4qllrvrt/BvQLMLH9o2Z1/wu6MbC22foFaEm7ve4y4FLK8VDM jvkmGvI6bTx8TPZB/1lunQaBgx7UzqKfjV3tLx5SUhC5GzpB9PyjVfBvrsw3HPg6UYljt2aWS7aP OtqItQcy60xYXZkCbUcSFXgbxTx5fb6vwpzJ8X0wd6HIglXc9wcbG3do8afzidhupv8IeOfDuQlz c/SehvKi33o8jRQXXke4uhfIn4TbqXD4BbTNj4FY6BUmfgKzSRskMq5LrZFik+r3o/fsLfN+aKZ7 nX/42rKv8foPoHxZmRhbViE26yJribSDu+9g6s6uYBo7smkNUr143G6+FyCLOV6LTl9Kn9wEdUqe hxR7WYExvP2hm8B4C5ctSoHaneHTvpN/75DmjPHd1Kcq30qgGt7cA9IlMyLwHGFuhNaonoms1oAn TSq146FlfB/GWGkUEwHjk7DOKEXFHs5+J9/PFUD2aKYop1dn7UkuI2R/E7J9omu1XoeKNCzXU2df S+o/+pfcXa1cHhbG+QMrHrvbJsVYRwn+abJapUidIIqI7Fw0WpuSjJP09PEa8i0SdXJTRk From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Jan 2020 00:12:46 +0800 Message-Id: <20200126161246.45779-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] af_volume: fix integer clip 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 Cc: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- Or specify an upper limit on volume. What do you think? libavfilter/af_volume.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c index 213c57195a..029925cbfb 100644 --- a/libavfilter/af_volume.c +++ b/libavfilter/af_volume.c @@ -200,7 +200,7 @@ static inline void scale_samples_s16(uint8_t *dst, const uint8_t *src, int16_t *smp_dst = (int16_t *)dst; const int16_t *smp_src = (const int16_t *)src; for (i = 0; i < nb_samples; i++) - smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8); + smp_dst[i] = (int16_t)av_clip64(((int64_t)smp_src[i] * volume + 128) >> 8, INT16_MIN, INT16_MAX); } static inline void scale_samples_s16_small(uint8_t *dst, const uint8_t *src,