From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.4 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C69A41F66E for ; Sat, 5 Sep 2020 11:16:47 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kEWBR-0000bj-KO; Sat, 05 Sep 2020 11:16:37 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEWBO-0000av-I0 for sox-devel@lists.sourceforge.net; Sat, 05 Sep 2020 11:16:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YdT8PmU4I/WZzE5FP0rZfdbOPvQRwLrSdPVDGk8tU+o=; b=Vw9Ro2TFEpEK1SPioUkkfVk11i Hml8j/qsZngdelSDNuLQ3hoBM8WsR0UNC20+iWZV1ckz7vLE0+PuolXUa3N/uEgCfzTz3OF4gomM7 hXDqxwvrw4qXYdrXO5ZOw06Aici0m7ZY40O6Z/4hJqQS8iglUYHJv/d4nDMBziqHfo/o=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YdT8PmU4I/WZzE5FP0rZfdbOPvQRwLrSdPVDGk8tU+o=; b=PRz3A1NuNuePzhla4ivYREkG1X tSBaxrXlN45ZIgUs1c3pp1UcCjL1PpXGcB/U7b3xSTN/Ub6W6Npd7EVmYgGVRAeegKzIwlMLrvqMo VsuolGh+Lm+Am+MgIUpoYlSnseltNkWgnRPc7Lgi0Ec/bRN7ggnzbEw9cE1sCtTOS2LA=; Received: from [81.2.72.234] (helo=unicorn.mansr.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kEWBK-00DCtl-TN for sox-devel@lists.sourceforge.net; Sat, 05 Sep 2020 11:16:33 +0000 Received: from raven.mansr.com (raven.mansr.com [81.2.72.235]) by unicorn.mansr.com (Postfix) with ESMTPS id 6826A15360; Sat, 5 Sep 2020 12:16:07 +0100 (BST) Received: by raven.mansr.com (Postfix, from userid 51770) id 4002421A6FE; Sat, 5 Sep 2020 12:16:07 +0100 (BST) From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: fbk-qriry@zacglen.net References: <202009050159.0851xmCt004755.mail.zacglen.com@localhost> Date: Sat, 05 Sep 2020 12:16:07 +0100 In-Reply-To: <202009050159.0851xmCt004755.mail.zacglen.com@localhost> (fbk-qriry@zacglen.net's message of "Sat, 5 Sep 2020 11:59:48 +1000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Headers-End: 1kEWBK-00DCtl-TN Subject: Re: silence patch X-BeenThere: sox-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sox-devel@lists.sourceforge.net Cc: sox-devel@lists.sourceforge.net Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: sox-devel-bounces@lists.sourceforge.net fbk-qriry@zacglen.net writes: > There is a bug in the "silence" effect that appears to > have been introduced in 2009 with commit bbb403. > > In function aboveThreshold() the value being scaled > is effectively the result of a sqrt but when it > gets scaled the value is not rounded but coarsely truncated instead. > Truncation is wrong. Rounding is right. > > Prior to this commit the value was effectively > rounded to the nearest whole value (according to > the precision). Without the following patch the "silence" > results are considerably different to earlier versions. > > For example: > > value old masked current > ----- ---------- ------- > 0x009bd6ae 0x0000009c 0x009b0000 > 0x00a170b8 0x000000a1 0x00a10000 > > The 0x009bd6ae used to be correctly rounded to 0x9c whereas > the current version effectively truncates the value to 0x9b. > > That is a serious flaw that should have been picked up > during testing. But better discovered 11 years later by a > random member of the public than never. The only serious flaw I see here is your condescending tone. > The patch: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- sox-downstream-sox-14.4.2.0.modified/src/silence.c.jw > +++ sox-downstream-sox-14.4.2.0.modified/src/silence.c > @@ -277,9 +277,15 @@ > { > /* When scaling low bit data, noise values got scaled way up */ > /* Only consider the original bits when looking for silence */ > - sox_sample_t masked_value =3D value & (-1 << (32 - effp->in_signal.pre= cision)); > + double scaled_value; > + sox_sample_t rounded_value =3D value; > > - double scaled_value =3D (double)masked_value / SOX_SAMPLE_MAX; > + /* before we mask we should round the value */ > + if (effp->in_signal.precision < 32) > + rounded_value +=3D (1 << (32 - effp->in_signal.precision - 1)); > + rounded_value &=3D (-1 << (32 - effp->in_signal.precision)); > + > + scaled_value =3D (double)rounded_value / SOX_SAMPLE_MAX; > > if (unit =3D=3D '%') > scaled_value *=3D 100; > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > :JW > -- = M=E5ns Rullg=E5rd _______________________________________________ SoX-devel mailing list SoX-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sox-devel