Bug 880260 - sox mcompand: bad clipping due to overflow of band summing
Summary: sox mcompand: bad clipping due to overflow of band summing
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: sox
Version: 17
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Frantisek Kluknavsky
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-11-26 15:17 UTC by Guido Aulisi
Modified: 2013-08-02 22:08 UTC (History)
3 users (show)

Fixed In Version: sox-14.4.0-3.fc18
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-01 20:06:19 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Proposed patch (1.01 KB, patch)
2012-11-26 15:17 UTC, Guido Aulisi
no flags Details | Diff

Description Guido Aulisi 2012-11-26 15:17:19 UTC
Created attachment 652003 [details]
Proposed patch

Description of problem:
When using mcompand with many bands (I tried with 3 bands), it's possible to get clipping due to integer sum wrapping. The clipping isn't reported by sox. I wrote a patch that seems to solve the problem.

Version-Release number of selected component (if applicable):
sox-14.3.2-3.fc17.x86_64

How reproducible:
Always with same audio and same sox parameters
Use sox mcompand with many bands, use gain to get some clipping, reduce gain till sox reports no clipping

Steps to Reproduce:
1. Use sox mcompand with many bands, use gain to get some clipping
2. Reduce gain till sox reports no clipping.
3. Some clipping occurs.

Actual results:
Some clipping occurs, samples are wrapped from positive to negative and/or viceversa

Expected results:
If clipping occurs, sox reports it and sample are at their max positive or min negative values


Additional info:
This is my proposed patch, the problem is interger overflow before being converted to double. I also sent this upstream. Sorry, but English is not my language!

diff --git a/src/mcompand.c b/src/mcompand.c
index ce5dc0b..8add94b 100644
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -390,7 +390,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_sample_t *obu
     (void)sox_mcompand_flow_1(effp, c,l,bbuf,abuf,len, (size_t)effp->out_signal.channels);
     for (i=0;i<len;++i)
     {
-      out = obuf[i] + abuf[i];
+      out = (double)obuf[i] + (double)abuf[i];
       SOX_SAMPLE_CLIP_COUNT(out, effp->clips);
       obuf[i] = out;
     }

Comment 1 Fedora Update System 2013-02-15 11:42:17 UTC
sox-14.4.0-3.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/sox-14.4.0-3.fc18

Comment 2 Fedora Update System 2013-02-15 12:00:54 UTC
sox-14.3.2-4.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/sox-14.3.2-4.fc17

Comment 3 Fedora Update System 2013-02-16 00:53:13 UTC
Package sox-14.4.0-3.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing sox-14.4.0-3.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-2506/sox-14.4.0-3.fc18
then log in and leave karma (feedback).

Comment 4 Fedora End Of Life 2013-07-04 07:43:17 UTC
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '17'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 17's end of life.

Bug Reporter:  Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 17 is end of life. If you 
would still like  to see this bug fixed and are able to reproduce it 
against a later version  of Fedora, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2013-08-01 20:06:23 UTC
Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 6 Fedora Update System 2013-08-02 22:08:47 UTC
sox-14.4.0-3.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.