Switch audio to 24-bit precision on platforms using sndio
Categories
(Core :: Audio/Video: cubeb, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox112 | --- | fixed |
People
(Reporter: alex, Assigned: padenot)
References
()
Details
Attachments
(4 files)
User Agent: Mozilla/5.0 (X11; OpenBSD amd64; rv:109.0) Gecko/20100101 Firefox/109.0
Steps to reproduce:
Play or record audio.
Actual results:
If the sndio backend of libcubeb is used, the resulting audio is converted from float to 16-bit integers.
Expected results:
The resulting audio should be 24-bit. Both firefox and sndiod use greater precision internally, so there's no point converting back and forth to 16-bit. Firefox uses 'float' for sample representation (which has 24-bit precision at full dynamic range) and the sndiod server uses 24-bit fixed-point numbers.
The proposed patch simply changes the precision to 24-bit. It converts floats from/to the format used internally by the sndiod server. This not only improves the precision, but also saves few CPU cycles as sndiod server doesn't need the extra conversion from/to 16-bit anymore.
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video: cubeb' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•1 year ago
|
||
setting platform to OpenBSD but that might be of interest for other sndio users on linux and FreeBSD ?
Comment 3•1 year ago
|
||
before doing a PR on the github repo, what do you think of the intent paul ?
Assignee | ||
Comment 4•1 year ago
|
||
Yeah this is the right thing to do I think, thanks for the patch. Other cubeb backends on desktop platforms use float32 internally (and then the OS decides what it prefers later in the pipeline, this depends on the OS, OS version, configuration and what hardware is hooked up to it). If this is an option for sndio, it's something we could consider as well.
Android still uses int16 everywhere for historical reasons (because we used to run Firefox on Android devices that have very poor fpu), but I'm thinking of changing that, because it's a bit of a pain to maintain two paths. Mobile devices have had very capable CPUs for a long time now.
All that to say, please send this as a PR upstream, and I'll get it merged there + imported in Firefox shortly.
Updated•1 year ago
|
Reporter | ||
Comment 5•1 year ago
|
||
(In reply to Paul Adenot (:padenot) from comment #4)
Yeah this is the right thing to do I think, thanks for the patch. Other cubeb backends on desktop platforms use float32 internally (and then the OS decides what it prefers later in the pipeline, this depends on the OS, OS version, configuration and what hardware is hooked up to it). If this is an option for sndio, it's something we could consider as well.
The sndio API doesn't support floats, but note taken for the future.
Comment 6•1 year ago
|
||
the patch is now shipping to OpenBSD users backported to 110. Can we get cubeb upgraded in firefox ?
Assignee | ||
Comment 7•1 year ago
|
||
Updated•1 year ago
|
Assignee | ||
Comment 8•1 year ago
|
||
Depends on D170347
Assignee | ||
Comment 9•1 year ago
|
||
Depends on D170348
Assignee | ||
Comment 10•1 year ago
|
||
Sorry for the delay, here it is (and also fixing an unrelated issue in our vendoring system).
Comment 11•1 year ago
|
||
Pushed by padenot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7026280c2b03 Add a missing patch statement in cubeb's moz.yaml, fix path in patch file. r=cubeb-reviewers,kinetik https://hg.mozilla.org/integration/autoland/rev/f857110d7111 Update libcubeb to revision 70b4e3db. r=cubeb-reviewers,kinetik https://hg.mozilla.org/integration/autoland/rev/84d4a4e7dab6 Reapply in-tree patch for libcubeb. r=cubeb-reviewers,kinetik
Comment 12•1 year ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/7026280c2b03
https://hg.mozilla.org/mozilla-central/rev/f857110d7111
https://hg.mozilla.org/mozilla-central/rev/84d4a4e7dab6
Description
•