HydrogenAudio

Lossy Audio Compression => Opus => Topic started by: pr0m3th3u5 on 2019-10-04 10:53:38

Title: How does the opus encoder deal with a 24-bit source?
Post by: pr0m3th3u5 on 2019-10-04 10:53:38
I know opusenc can take a 24-bit audio file as an input.

But I want to know if the source audio file will be converted to 16-bit first and then be encoded into an opus file.
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: Fairy on 2019-10-04 11:35:02
As far as I know everything is converted to 16/48 before it's encoded. Also if you need to keep the 24 bit depth I suggest to use a lossless codec instead of a lossy codec. In practice the bitdepth can get lower than 16 bit theoretically.
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: pr0m3th3u5 on 2019-10-04 11:38:38
As far as I know everything is converted to 16/48 before it's encoded. Also if you need to keep the 24 bit depth I suggest to use a lossless codec instead of a lossy codec.

I don't prefer 24-bit over 16-bit (can't hear the difference), I am just curious.

In practice the bitdepth can get lower than 16 bit theoretically.

Could explain what does that mean?
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: Case on 2019-10-04 12:42:21
Actually all input is converted to 32-bit floating point and processed in that format.
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: jmvalin on 2019-10-04 16:40:45
Actually all input is converted to 32-bit floating point and processed in that format.

Correct. It still means you won't be keeping the (theoretically) very low noise of your 24-bit recording (for that you need lossless). However, you *will* be keeping all of the dynamic range. Opus is capable of representing the full 24-bit dynamic range, and then some.
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: saratoga on 2019-10-04 17:27:06
But I want to know if the source audio file will be converted to 16-bit first and then be encoded into an opus file.

Almost all practical PC lossy encoders use floating point, so everything gets converted to 32 bit. 
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: magicgoose on 2019-10-04 23:04:17
except fdk-aac, I think
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: kode54 on 2019-10-05 01:37:36
fdk-aac must deal with clipped integer samples, and is hard coded to specific integer precision. I even tried decoupling that a bit, to support fixed point that exceeds ±1.0, but the SBC and/or PS code break horribly if the input and output aren't clipped first.
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: Pipfrosch on 2019-11-30 13:50:10
Actually all input is converted to 32-bit floating point and processed in that format.

Correct. It still means you won't be keeping the (theoretically) very low noise of your 24-bit recording (for that you need lossless). However, you *will* be keeping all of the dynamic range. Opus is capable of representing the full 24-bit dynamic range, and then some.

I thought low noise and high dynamic range were the same thing - dynamic range being the decibels between the quietest intentional sound above the noise floor and the loudest sound. So the only way to have high dynamic range is to have a low noise floor.

And that 16 bits already provides enough at listening levels where the peak won't cause hearing damage (or be distorted by speakers), 24-bits only being of real value during mastering.
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: Phanton_13 on 2019-11-30 16:22:48
I thought low noise and high dynamic range were the same thing - dynamic range being the decibels between the quietest intentional sound above the noise floor and the loudest sound. So the only way to have high dynamic range is to have a low noise floor.

And that 16 bits already provides enough at listening levels where the peak won't cause hearing damage (or be distorted by speakers), 24-bits only being of real value during mastering.
Actually they are not the same thing and this is made clear with float point numbers, there are various definitions for snr and dr. On definition being: "Dynamic range in dB is the sum of the signal-to-noise ratio in dB plus the headroom in dB", with this definition:

16bit integer:
snr= 6 x number of bits= 6 x 16 = 96db
headroom = 0db
dynamic range = 96+0 = 96db

16bit IEEE half precision float
snr=6 x 2^(bits in exponent)= 6 x 2^5 = 192db
headroom= 6 x (2 + bits in mantissa) = 6 x (2 + 10) = 72db
dynamic range= 192+72 = 264db
altrough in floats I actually like to consider the precission as the real snr and in this case is 6 x (1 + bits in mantissa) = 66db.

PD. I'm not sure of the float point calculation but at worst the error is no more than 12db.
Title: Re: How does the opus encoder deal with a 24-bit source?
Post by: magicgoose on 2019-11-30 23:33:00
fdk-aac must deal with clipped integer samples, and is hard coded to specific integer precision. I even tried decoupling that a bit, to support fixed point that exceeds ±1.0, but the SBC and/or PS code break horribly if the input and output aren't clipped first.
A bit sad result, but still pretty interesting experiment
I thought low noise and high dynamic range were the same thing - dynamic range being the decibels between the quietest intentional sound above the noise floor and the loudest sound. So the only way to have high dynamic range is to have a low noise floor.
The thing is, noise floor doesn't have to be constant. Lossy codecs, if grossly oversimplified, can be said to work by hiding noise under the signal in such a way that when the signal is quiet, noise is also quiet, and so we don't hear the presence of that noise, but it can be pretty loud (when the signal is even louder).