Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Harmonic coding issues of Opus(from THD-N test)  (Read 3234 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Harmonic coding issues of Opus(from THD-N test)

Hello everyone.
 
These days I'm evaluating objective tests as to the two codecs, one is LC3 plus, another is Opus. I found out that THD-N test of Opus failed since the harmonic distortion is around 2%, which is much higher than LC3 plus. Test signal is simply the harmonic signal (1khz, attached) and also the script using opus_demo pasted as following. I also attached the snaps of the output signal. There are clear fluctuations of the amplitude.   
opus_demo -e audio 48000 1 128000 -cbr -bandwidth FB -framesize 2.5 -max_payload 40 1kHz.pcm out.ops
opus_demo -d 48000 1 out.ops out1Khz.pcm

Anybody  noticed this issue? 

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #1
I found out that THD-N test of Opus failed since the harmonic distortion is around 2%, which is much higher than LC3 plus.
Opus is designed to minimize audible distortion, not overall distortion. THD+N doesn't measure audible distortion.

opus_demo -e audio 48000 1 128000 -cbr -bandwidth FB -framesize 2.5 -max_payload 40 1kHz.pcm out.ops
How did you choose these particular options?

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #2
Actually these distortions are audible. I also attached a real signal sample with sinusoids, and also the output of opus. You can hear the distortion clearly. 

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #3
Yes, that's because of the encoder settings you're using. Opus is typically not transparent with that combination of encoding options.

Again, how did you choose those settings?

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #4
The purppose is for low latency. But distortion is still there even in other frame duration.

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #5
Opus, using VBR and 20ms frames, is transparent for most listeners starting at around 128kbps. (Actually a bit less than that since you're encoding mono instead of stereo.)

Using CBR instead of VBR, you need a higher bitrate to achieve transparency. Exactly how much higher depends on the audio you're encoding; the average seems to be around 10% but for some audio you need more.

Using 2.5ms frames instead of 20ms frames, you need about 75% higher bitrate to achieve the same quality.

The Opus developers might be able to give you better advice, but I think this means you'll need around 256kbps to achieve transparency with CBR and 2.5ms frames. If you can use CVBR instead of CBR, or use larger frames, that will help reduce the bitrate requirement.

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #6
This is mono, so 2.5ms at 128 kb/s should sound pretty good. The main issue here is music vs synthetic signals. Opus performs a sort of implicit bitrate allocation across bands that helps with coding efficiency because almost all signals have energy at all frequency and so all bands are audible and require bits to code. That assumption is true for speech and almost all music. However, it is not true of test tones. Fortunately, most people prefer listening to music rather than test tones. It's probably possible to create a "tone mode" for the Opus encoder, but I'm not sure I see the point. For more on that, see Section 4.2 of https://jmvalin.ca/papers/aes135_opus_celt.pdf

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #7
Yes, you are right for most signals the energy located everywhere. But there are lot of instruments, some of them produce sinusoidal signals, in this case, opus introduce clear distortion. I checked it with LC3 plus codec, the sinusoidal distortion is much lower. I mean, anybody can help to check if opus could be improved for instrumental applications. 

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #8
Can you share samples of the music where Opus introduces distortion?

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #9
I mean I'm all for improving Opus on very tonal instruments as long as it doesn't cause regressions in the more common cases. If that's something you'd like to try, the first place I'd look is dynalloc_analysis() at https://gitlab.xiph.org/xiph/opus/-/blob/main/celt/celt_encoder.c?ref_type=heads#L981
Basically, you want to detect and boost the bands that have strong tones, but without starving the other bands that are still audible in most non-pathological cases.

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #10
Yeah, you did great job, Valin. Thank you so much for keeping this internet codec ever strong. I will keeping check it and feedback when I find something new. "Basically, you want to detect and boost the bands that have strong tones, but without starving the other bands that are still audible in most non-pathological cases.", this is a paradox, when I compare opus vs LC3P in common music coding,   PEAQ gives higher score for opus at similiar rate. The only issue here is the critical pursuit from the manaufactors with instruments  those only produce sinusoid signal coding quality preffering instead of multi harmonics like piano , violin.    

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #11
I was wondering about another closely related topic until I ended up reading this post. Let me say what I was thinking about.
When I make MP3s using Lame, I'm able to preserve extremely low frequencies (like 3 Hz or so) adding fewer artifacts than Opus, even with catastrophically low bitrates like 32 kbps or similar. The reason why I thought about it many years ago is that in some situations the source recording may possibly include frequencies as low as 16 Hz even though the harmonics are not particularly loud. In most cases, this can occur with pipe organs when just the lowest register is being used.
The main question here is not how often one comes across such a recording or if there's a point in coding inaudible stuff but rather how on earth it's possible that the old MP3 adds less noise to infrasound even at such crazy low bitrates. If MP3 can do it, then I think Opus might as well.
With Opusenc, I tried two different settings. In one case I didn't change anything, in another I set "--bitrate 510". To test the mid/side differences, I left one input signal entirely monophonic while another was inverted mono.
If someone here wants to know the uncompressed PCM signal I tested, the link is here.
https://1drv.ms/u/s!Ap_EgwEX00SDhHokv-R1kur4noBo


Re: Harmonic coding issues of Opus(from THD-N test)

Reply #12
The main question here is not how often one comes across such a recording or if there's a point in coding inaudible stuff but rather how on earth it's possible that the old MP3 adds less noise to infrasound even at such crazy low bitrates.

The period of those frequencies is much longer than the transform length of both MP3 and Opus, so they are not being analyzed in the same way as audio frequencies would be.  I think the choice of codec is not so important and rather it comes down to how the specific encoder handles periodic changes in total energy between transform blocks, if it high pass filters, etc.  Since this is not something that would usually matter the behavior probably varies a lot between encoders. 

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #13
An actual harmonic coding issue of Opus (Celt) is trying to encode all the bands when bits are not enough. At low bitrates this causes several hissing noise and artifacts. I think it's better to reduce bandwidth like other codecs rather than allow this to happen.

 

Re: Harmonic coding issues of Opus(from THD-N test)

Reply #14
Opus is not trying to encode all bands, it uses bandwidth extension called "folding" which uses significantly  less than 1 kbps on upper frequency range. It's similar to HE-AAC SBR tool.

What you're describing as several hissing noise and artifacts on harmonics comes from the fact that Opus is low-delay audio codec and uses low-overlap window what causes leakage. https://arxiv.org/pdf/1602.04845