Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
translations translations
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Audio Playback, Database and Playlists
| | |-+  Distortion near peak level, specific to OGG, OPUS and AAC
« previous next »
  • Print
Pages: [1]

Author Topic: Distortion near peak level, specific to OGG, OPUS and AAC  (Read 1540 times)

Offline mayreg

  • Member
  • *
  • Posts: 4
Distortion near peak level, specific to OGG, OPUS and AAC
« on: November 17, 2022, 08:34:28 AM »
I noticed that some tracks converted to Vorbis, OPUS and AAC will become distorted at higher volume levels, especially when used with compressor and makeup gain (default compressor settings with Threshold -24 dB). Other formats (tested: WAV (pcm_s16le), FLAC, MP3, AC3, MP2) are OK and have no distortion at all with the same volume and compressor setting.

More details and audio samples in my bug report: https://www.rockbox.org/tracker/task/13375

Anyone experienced the same?
Logged

Offline dconrad

  • Developer
  • Member
  • *
  • Posts: 273
Re: Distortion near peak level, specific to OGG, OPUS and AAC
« Reply #1 on: November 17, 2022, 10:43:19 AM »
I noticed in your bug report you're using 3.15, this is really pretty old at this point and I think the standard first step is to try a development build from here https://www.rockbox.org/daily.shtml, try that and see if you have any change in behavior.

I haven't noticed any distortion issues, though I don't typically use any of your problematic formats. It seems likely to me that the difference is just in how those formats compress the data results in a slightly louder way maybe? Just speculating.
« Last Edit: November 17, 2022, 11:03:55 AM by dconrad »
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 9369
Re: Distortion near peak level, specific to OGG, OPUS and AAC
« Reply #2 on: November 17, 2022, 02:30:38 PM »
Lossy audio is expected to clip somewhat if you decode near-peak value waveforms, so testing with Ogg or OPUS is not so informative.  Some distortion is expected, so it is hard to know if what you hear is a bug or normal.  More interesting would be if you could replicate the problem with a lossless format, which will decode to exactly the same PCM values and so should not clip.  If that clips, then probably something is not setting the gain correctly (maybe compressor plugin?). 
Logged

Offline mayreg

  • Member
  • *
  • Posts: 4
Re: Distortion near peak level, specific to OGG, OPUS and AAC
« Reply #3 on: November 18, 2022, 08:52:11 AM »
The same OGG, OPUS and AAC audio samples don't clip when played back on another player (e.g. VLC, mplayer, MPC-HC, etc.).

It doesn't clip either when the compressed file loaded into Audacity and checked visually (see attachment: noclipping.jpg). The peak is exactly at -1 dB, as generated.

It doesn't clip either when decoded with oggdec to WAV and played back by Rockbox+Compressor. That's why I suspect that something nasty is happening between the OGG/OPUS/AAC decoder and the compressor but not with other decoders.

As dconrad recommended, I also tried with build 38687821b2-221117 instead of 3.15. Same result.

* noclipping.jpg (83.27 kB, 1375x664 - viewed 95 times.)
« Last Edit: November 18, 2022, 09:04:57 AM by mayreg »
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 9369
Re: Distortion near peak level, specific to OGG, OPUS and AAC
« Reply #4 on: November 18, 2022, 10:13:33 AM »
Quote from: mayreg on November 18, 2022, 08:52:11 AM
It doesn't clip either when decoded with oggdec to WAV and played back by Rockbox+Compressor. That's why I suspect that something nasty is happening between the OGG/OPUS/AAC decoder and the compressor but not with other decoders.

If you think the problem is the decoders themselves rather than the compressor, you can compile a build with the test_codec plugin enabled (or run the uisim which I believe has it by default) and output the decoded audio to .wav.  Then you can compare to the floating point decoder on PC. 
Logged

Offline mayreg

  • Member
  • *
  • Posts: 4
Re: Distortion near peak level, specific to OGG, OPUS and AAC
« Reply #5 on: December 16, 2024, 09:51:50 AM »
Sorry for this 2-year delay. ;) I only had so much spare time now to set up a Rockbox build & test environment and do the experiments saratoga suggested.

I successfully reproduced the issue on the simulator during regular playback. I built rockbox from HEAD 8f5128da16 and tried test_codec in both Write WAV and Write WAV with DSP modes.

The pure WAV output isn't distorted but the one with DSP is. So it's now more obvious that there's something going wrong in the compressor or between the decoder and the compressor within the DSP chain, but not inside the decoder.

The clipping occurs when the compressor attacks and there seems to be something wrong with the Makeup Gain because when I turn it off, the distortion goes away. Playing around with attack time is also interesting, the higher the attack time, the longer the distortion.

Attached samples and demonstration video in the bug report: https://www.rockbox.org/tracker/task/13375#comment44819

One more question should be answered: Why just OGG/Vorbis, OPUS and AAC? Someone could answer this who's an expert in this part of Rockbox, which I'm not. Maybe the decoders of OGG and OPUS codecs send out a "little bit more" gain to the Compressor than other codecs or something may go wrong in the resample part as the decoders of these formats all produce 24-bit output but Sansa output is 16-bit.
« Last Edit: December 22, 2024, 10:08:38 PM by mayreg »
Logged

Offline Bilgus

  • Developer
  • Member
  • *
  • Posts: 1192
Re: Distortion near peak level, specific to OGG, OPUS and AAC
« Reply #6 on: December 27, 2024, 03:51:49 PM »
Do you think perhaps those tracks had more than 4 audio channels?

I fixed a buffer overflow bug in the compressor yesterday

https://gerrit.rockbox.org/r/c/rockbox/+/6268/4/lib/rbcodec/dsp/compressor.c#459
Logged

Offline bahus

  • Member
  • *
  • Posts: 208
Re: Distortion near peak level, specific to OGG, OPUS and AAC
« Reply #7 on: December 27, 2024, 04:03:50 PM »
Quote from: Bilgus on December 27, 2024, 03:51:49 PM
Do you think perhaps those tracks had more than 4 audio channels?

AAC(faad/alac) decoding is limited to 2 channels:
https://github.com/Rockbox/rockbox/blob/bfef0a2d6cf88ab99f267acce2d015602cb3860c/lib/rbcodec/codecs/libfaad/structs.h#L40

So not the case for AAC... Maybe the same limitation is applied for ogg and opus I didn't really check.
Logged

Offline mayreg

  • Member
  • *
  • Posts: 4
Re: Distortion near peak level, specific to OGG, OPUS and AAC
« Reply #8 on: January 05, 2025, 10:39:05 AM »
Quote from: Bilgus on December 27, 2024, 03:51:49 PM
Do you think perhaps those tracks had more than 4 audio channels?
Definitely not. The samples I provided have 2 channels and all the media on my Sansa have max. 2 channels.

Quote from: Bilgus on December 27, 2024, 03:51:49 PM
I fixed a buffer overflow bug in the compressor yesterday
I tried the latest build with your patch on but it didn't fix the distortion issue. It must be something related to the resampler or the compressor. Looking at the code, at least OGG must be resampled from 24-bit to 16-bit as its decoder provides PCM data with higher bit depth.
« Last Edit: January 05, 2025, 07:08:43 PM by mayreg »
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Audio Playback, Database and Playlists
| | |-+  Distortion near peak level, specific to OGG, OPUS and AAC
 

  • SMF 2.0.19 | SMF © 2021, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.173 seconds with 21 queries.