HydrogenAudio

Lossy Audio Compression => Opus => Topic started by: j7n on 2018-06-14 13:13:49

Title: Highpass filter and DC offset click
Post by: j7n on 2018-06-14 13:13:49
Opus has a highpass filter for removing DC offset. As tracks are normally encoded one at a time, the filter is unaware of the DC history from the previous track. A discontinuity click is created at the track boundary. Ideally, this offset should be removed on the disk image as a whole. But I may not have noticed it in continuous or quiet listening of the album. Typical users won't do it.

1) Can you somehow extrapolate the audio backwards enough for the filter to settle? Probably not reliable, because around 1/3 seconds are required for 3 hz.

2) Make the HPF defeatable?

No other encoder has an implicit HPF, or it is optionally selectable with a checkbox (ac3, itunes). What benefit does the HPF bring to encoding, and does it remain significant at transparent bitrates?
Title: Re: Highpass filter and DC offset click
Post by: magicgoose on 2018-06-14 16:10:43
Sub-sonic frequencies are cheap to encode, so they're unlikely to make a big difference to the efficiency at transparent quality levels.

Anyway, the easiest solution IMO is to encode the album in one go, and split to tracks after encoding (without transcoding of course, as that'd be pointless). The accuracy of track splitting would be not ideal (at least 20 ms, unless you also use sub-optimal frame sizes when encoding), but if you optimize for full album listening, it won't matter.
Title: Re: Highpass filter and DC offset click
Post by: j7n on 2018-06-16 23:27:07
An extra pass of splitting is inconvenient, not possible to integrate with existing encoder frontends, and I'm concerned that the split tracks might get rejected by some players. Which Opus splitter would you recommend? I prefer to pre-process the source files, which can be edited precisely, and only deal with compressed file splitters as a last resort if I don't have the uncompressed files anymore.

Clicks also occur with vinyl rumble, which is probably more common than CDs with offset. Other gapless codecs - Lame, FhG AAC, Musepack, Vorbis - encode flawlessly without clicks. Lame has a very low amplitude and duration clicks, which I wouldn't notice without focusing on the particular time position, and cranking the volume, effectively a clean encoding. Only Opus shows a problem. Filtering the vinyl sample below 10 Hz is sufficient to eliminate the clicks with Opus (3 Hz is not enough).

Integrating a filter on disk image is unfortunately not possible in Foobar2000, and a temporary file with cue sheet must be used. If I select "Don't reset DSP between tracks", then the track splits will be offset by a seemingly random amount, which looks like a bug.

I'm not providing a sample, as this is easy to replicate, and occurs any time a HPF is toggled on/off with audio running.
Title: Re: Highpass filter and DC offset click
Post by: lvqcl on 2018-06-16 23:45:08
From https://people.xiph.org/~xiphmont/demo/opus/demo3.shtml

Quote
DC Rejection

The 1.1 encoder now uses a built-in DC rejection filter (3Hz cutoff) for all modes. The effect of the filter itself is inaudible, but it prevents DC energy from polluting the masking and energy analysis of the lowest frequency bands.

I think OP knows this already, so I posted it for those who (like me) didn't know this peculiarity of Opus encoder.
Title: Re: Highpass filter and DC offset click
Post by: Rollin on 2020-08-29 15:43:57
It seems that utility for gaplless opus encoding (https://hydrogenaud.io/index.php?topic=116605.msg984924#msg984924) solves this problem too.