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 1309 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.