opus icon indicating copy to clipboard operation
opus copied to clipboard

Opus amplification of background tone/noise.

Open bateyejoe opened this issue 1 year ago • 5 comments

I'm running into an issue where a very low volume (pretty much inaudible) tone present in the background is being amplified and distorted into a loud screech. The tone in the 8kHz input signal is composed of a repeating pattern of five zero samples followed by a single sample at positive 8 on the linear-16 scale. So essentially a 1333Hz very low hum. It just seems to always be there in audio received from a specific VOIP carrier.

In the following screen cap, the top waveform is the input signal (mostly silence with a few background noises) and the bottom waveform is the output after compressing to Opus and decompressing to 48kHz linear-16. Input_and_output_waveforms

I was able to reproduce this with the Opus 1.5.2 distribution compiled under/for Windows using cmake with the following configuration: cmake .. -DOPUS_DRED=OFF -DOPUS_PLC=ON -DOPUS_OSCE=ON

In the attached zip I've included a source file of a simple app that reads raw u-law/8kHz from a file, compresses to opus, decompresses to linear-16 at 48kHz. I've also included an example file containing the troublesome input signal. This code, and the provided input file are what produced the waveforms above. Consult the source file to see how the encoder and decoder are configured.

The system these were built/run on was Core i9-13900 running Windows 11 (10.0.26100.2314) and both Opus and the executable were built using MSVC 19.40.33812 (Visual Studio 2022).

opus_gain_bug.zip

bateyejoe avatar Dec 11 '24 21:12 bateyejoe

I've revised this example a little bit to simplify it and narrow down the circumstances. The key to reproducing the issue is to enable DTX on the encoder, No other options on the encoder or decoder need to be set. Also, I removed the microsoft-specific fopen_s so this easily compiles and runs under Linux.

The input file is now 8k linear and I removed the mu-law conversion from the code. The decoder output is 48k, but I have also tried with 8k and got the same results.

One other small difference, which shouldn't matter, is if a DTX packet is encountered and it is at least 1 byte in length, the previous code passed it to the decoder. Now, if the encoder returns a buffer of length 2 bytes or less, the decoder is run with a null input buffer (but the correct frame size). This is probably the more real world behavior, but the output looks identical whether nullptr is passed for DTX packets, or if the 1-2 byte encoder output is passed for DTX packets.

opus-gain-bug2.zip

bateyejoe avatar Jan 28 '25 18:01 bateyejoe

so do i, are you fixed it?

qw225967 avatar Jun 07 '25 04:06 qw225967

so do i, are you fixed it?

Nope. The only workaround is to disable DTX which really sucks for RTP usage. Posted here and the mailing list and there's been little to no interest from the Opus devs and not even an indication they're aware of the issue.

bateyejoe avatar Jun 11 '25 17:06 bateyejoe

Yes, we're aware of the issue and fixing it is on the todo list

jmvalin avatar Jun 11 '25 17:06 jmvalin

Yes, we're aware of the issue and fixing it is on the todo list

That's great to hear. Thank you.

bateyejoe avatar Jun 11 '25 20:06 bateyejoe