xiph / vorbis

Reference implementation of the Ogg Vorbis audio format.
BSD 3-Clause "New" or "Revised" License
450 stars 183 forks source link

2pass? #68

Open zvezdochiot opened 4 years ago

zvezdochiot commented 4 years ago

2- and more- pass coding, like nero?

rillian commented 4 years ago

I don't know of anyone working on 2-pass rate control for Vorbis.

Can you share a use case for this? Usually two-pass is used to maximize quality within a strictly limited number of bytes, but vorbis is transparent at any current media readout or broadband streaming bitrate.

zvezdochiot commented 4 years ago

It is not so easy to answer your question.

Additional regulators (multipliers) are introduced into the coding system, initially equal to 1. Depending on where they are entered, the corresponding statistics are collected on the first pass. There is also a flag system that determines which regulatorswill be enabled. Based on statistics, the values of the regulators are calculated. In general, this system is empirical in nature and cannot be fully described using a certain theory.

PS: For stability, the values of the regulators are usually calculated by delta-functions:

regulator =  (freg) ? (1.0f + min(abs(f(stat)),deltaMax)*sign(f(stat))) : 1.0f;
zvezdochiot commented 4 years ago

:information_source: The general meaning of multi-pass coding: to partially transfer control of the coding process to the sound itself (feedback).

PS: Multi-pass is no magic.

rillian commented 4 years ago

I understand what 2-pass encoding is. I do not understand why you want it for vorbis. Can you explain why it would be good?

zvezdochiot commented 4 years ago

Encoding, in which nothing is known about the encoded signal, in no way can have little bad. Only the encoding of a known signal (statistics accumulated) can have little bad.

PS: little bad != best || good

rillian commented 4 years ago

Well yes, but as you say, multi-pass encoding is not magic. It doesn't make every encoding better.

Two passes are only helpful to adjust the bitrate for different sections to meet some external constraint. That's typically only useful for video because video data is so large, so one might want either to avoid overwhelming someone's network bandwidth, or to exactly fill some distribution medium like a video disk. Those constraints mean video is often compressed so heavily that it's visible. You really are trying to spread around the bad so it's less noticeable.

What the current vorbis encoder does instead is just to make the file a little bigger for every piece that is harder to encode. This works fine since audio is so much smaller. Why doesn't that work for you?

zvezdochiot commented 4 years ago

This "good" only works at high bitrates.