Closed Bug 1144087 Opened 9 years ago Closed 9 years ago

Audio glitches on OpenBSD caused by rounding errors.

Categories

(Core :: Audio/Video, defect)

x86_64
OpenBSD
defect
Not set
trivial

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: alex, Assigned: alex, Mentored)

Details

Attachments

(2 files)

Audio decoders may produce samples slightly outside the [-1:1] interval (eg while decoding sound of youtube videos). This causes integer overflows during convertion from floats to signed integers. In turn this produces audible
glitches.

The attached diff fixes glitches by clipping samples to avoid overflows.
Attachment #8578598 - Flags: review?(cpearce)
Comment on attachment 8578598 [details] [diff] [review]
diff to fix glitches

Review of attachment 8578598 [details] [diff] [review]:
-----------------------------------------------------------------

Matthew should handle this.
Attachment #8578598 - Flags: review?(cpearce) → review?(kinetik)
Comment on attachment 8578598 [details] [diff] [review]
diff to fix glitches

Review of attachment 8578598 [details] [diff] [review]:
-----------------------------------------------------------------

Clamping during the conversion is definitely a good idea.  Thanks for the patch.
Attachment #8578598 - Flags: review?(kinetik) → review+
the rounding from float to int introduces unnecessary noise.
float -> int cast works as ceil on negative number and floor on positive number rather than rounding to the nearest int.

use lrintf on the result of the float multiplication and then clip.
Alternatively, it could compile with MOZ_SAMPLE_TYPE_S16 instead of MOZ_SAMPLE_TYPE_FLOAT32.
(In reply to Jean-Yves Avenard [:jya] from comment #3)
> 
> use lrintf on the result of the float multiplication and then clip.

i agree, thanks for the tip
New diff, with call to lrintf() to reduce quatization noise, as Jean-Yves suggested. This is an independent problem, but let's improve the noise level as we're at it. Tested on OpenBSD/amd64.
Comment on attachment 8579545 [details] [diff] [review]
version 2 diff, with call to lrintf

Thanks for updating the patch, looks good!
Attachment #8579545 - Flags: review+
(In reply to Alexandre Ratchov from comment #6)
> Created attachment 8579545 [details] [diff] [review]
> version 2 diff, with call to lrintf
> 
> New diff, with call to lrintf() to reduce quatization noise, as Jean-Yves
> suggested. This is an independent problem, but let's improve the noise level
> as we're at it. Tested on OpenBSD/amd64.

Also tested on OpenBSD/amd64, OK for me. Thanks!
https://hg.mozilla.org/mozilla-central/rev/535571bc0164
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: