Skip to main content
Topic: Why does LAME cut off frequencies differently for CBR and VBR ? (Read 1783 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Why does LAME cut off frequencies differently for CBR and VBR ?

This is mostly out of curiosity. I'll leave some screenies from Spek.

The original FLAC:
Spoiler (click to show/hide)
CBR 320kbps (-lowpass 20.5):
Spoiler (click to show/hide)
V0 (-lowpass 22.1):
Spoiler (click to show/hide)
I'm mainly interested in the difference between CBR and VBR from 0:00 to 0:50, I'd appreciate it if someone could explain this (preferably noob-friendly).

I just realised I've posted in the wrong section, sorry. Could a moderator please move this ?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #1
There are also different lowpass values, not only CBR vs VBR.

Anyway, CBR has 320 kilobits for every second of audio data, so it can waste a lot of them to encode even the weakest high frequency content.
VBR first measures how many bits would be enough to encode a frame at given quality level - it decided that the beginning of the song is easy enough to encode at lower bitrates, so it did, but to fit in that lower bitrates it discarded the weakest high frequency content to save bits for the stronger and lower frequency content which you can actually hear.

Altered lowpass values are also important - to encode with 320 kilobits a 22.1 kHz wide band you have to discard more data than if you had to encode with that 320 kilobits only a 20.5 kHz wide band. What gets discarded first? Weak high frequency content which you can't hear anyway.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #2
Quote
Altered lowpass values are also important - to encode with 320 kilobits a 22.1 kHz wide band you have to discard more data than if you had to encode with that 320 kilobits only a 20.5 kHz wide band. What gets discarded first? Weak high frequency content which you can't hear anyway.
In other words - Better looking spectrum and (potentially) worse sound.

 

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #3
V0 has lower bitrate than 320. As 320 is max, "variable" would have to mean less.

Think of CBR as "Here is a number n and a task T. Hire the n best people to do T!" and VBR as "Here is a task T. Hire the N best people for the task T, where you choose N high if necessary for the task in question, and low if not!".

Evidently, VBR requires more smartness, as you outsource to it to determine N as well. If you feed a VBR encoder a signal with a sine tone at full volume over some ambient noise at -90 dB, it should choose to produce a small file. If you feed a CBR encoder the same thing, it will use the "n" you told it to.

But then you cannot compare V0 and CBR 320.  You should compare V0 with CBR at, kinda, "what would you expect to be enough?".
Memento: this is Hydrogenaudio. Do not assume good faith.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #4
@rutra80
Thanks for the explanation, but could you please elaborate more on the last part ?

@DVDdoug
I know that one cannot judge the quality based on how the spectrum looks, I just wanted to know how it works.

@Porcus
Do you mean VBR and CBR basically are the same, but VBR employs a smart technique to keep the file size small and CBR is just wasteful ?

One thing I don't yet understand is why VBR has a higher lowpass value, because those higher frequencies can't be heard anyway.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #5
Different parts of the sentence:

Do you mean VBR and CBR basically are the same

No ... not really.


but VBR employs a smart technique

I meant to say that a VBR algorithm has "an additional task to do", and if you want to outsource that judgement to an algorithm, it must be "smart enough".
(Whether LAME VBR has succeeded in being smart enough for it to be sensible - I don't think is very controversial to claim "yes!".)



to keep the file size small

To let bitrate (and thus filesize) vary according to need. Larger files for "difficult" material, smaller files otherwise. (One obvious example: if you encode a mono recording - a CD has two channels, but let's say they are bit-identical - you would normally need less.)

LAME V0 is said to average around 250. That means it will spend 300 on hard stuff and 128 on some mono recordings (reported herein): it will try to allocate filesize where it is needed.
If you have a lot of noise music your collection might average well above 250. If you have a lot of mono speech and - for the sake of the argument - choose V0, you could see way lower averages.


But if we compare to 320 - which is the maximum - then average of something variable will be less.


and CBR is just wasteful ?

Loosely speaking: If you want the same number of artifacts with CBR, you must increase bitrate above the material's VBR average, because VBR will increase it when needed. And in order to increase it "when needed" AND keep constant, you need to increase also when not needed.
This assumes that the VBR does its job properly.

CBR can hardly avoid a certain waste - suppose that you have a fadeout with silence in the end, what then? CBR 320 will use 320, silence or not.
(There are compatibility reasons to use CBR in certain applications, though.)
Memento: this is Hydrogenaudio. Do not assume good faith.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #6
@rutra80
Thanks for the explanation, but could you please elaborate more on the last part ?
Generally, lower lowpass = more efficient encoding (more bits are available for frequencies we hear best), of course as long as you don't cut out clearly audible frequencies.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #7
Somewhat related :

Encode a stereo file with lame --preset cbr 160 :
Code: [Select]
Using polyphase lowpass filter, transition band: 17226 Hz - 17806 Hz

Encode a mono file with lame --preset cbr 80, which has the same bitrate per channel and should get the same or a lower lowpass (because of the loss of efficiency of the joint stereo) :
Code: [Select]
Using polyphase lowpass filter, transition band: 20323 Hz - 20903 Hz

Note that I already reported this bug a few years ago, and proposed a fix, but it has not been merged.


Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #8
Why is joint stereo less efficient than dual mono.  They are mathematically identical.
Is 24-bit/192kHz good enough for your lo-fi vinyl, or do you need 32/384?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #9
@greynol I'm not sure I understand your sentence. He is talking about single channel mono, not dual channel mono. I guess you were talking about a two channel mono track encoded with joint stereo or in single channel mono. (dual mono would actually be a lot less efficient, because it would actually be generating two independent streams)

Anyway, in his sentence, I assume he worded it incorrectly, but pretended to say "loss of efficiency compared to" not "of".

What is true is that 20Khz for 80kbps mono might look less than ideal, and that, from what I read in the other post, the logic on choosing the bandwidth for a mono track is not based on the mono performance, but assuming a constant offset versus what a stereo file would do at that bitrate.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #10
Sorry, just mono compared to joint stereo.  The transform of mono to joint stereo frames is identical to mono (all mid with no side). Is this correct?
Is 24-bit/192kHz good enough for your lo-fi vinyl, or do you need 32/384?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #11
@greynol I am not sure I understand you either, especially your last message.

What I meant was that joint-stereo encoding usually provides an efficiency gain per channel compared to mono, therefore mono compared to joint-stereo loses the efficiency of joint stereo, hence the "loss of efficiency of the joint stereo" wording.

Back to my lowpass example, I would expect the lowpass to be identical, or a bit lower if it takes into account that channel coupling efficiency difference, but certainly not 2.5 KHz higher for mono.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #12
Of doesn't mean compared to.

Again, mono deried from mono and the joint stereo derived from mono should be mathematically identical because the mid channel is the same as mono and there is no side channel information to encode.
Is 24-bit/192kHz good enough for your lo-fi vinyl, or do you need 32/384?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #13
Of doesn't mean compared to.
The second "of" in "loss of efficiency of the joint stereo" refers to the efficiency, not the loss. But I admit that was ambiguous. "loss of efficiency that joint stereo provides" would maybe have been better.

... and the joint stereo derived from mono

That is where you lost me. You can't encode mono (1 channel) to joint-stereo (efficient encoding of 2 channels), or do you mean dual mono to joint stereo ?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #14
Two channels with the same content in each channel, or did you mean something else?

I'm having a difficult time understanding what you're getting at.
Is 24-bit/192kHz good enough for your lo-fi vinyl, or do you need 32/384?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #15
Technically, what is visible on the VBR spectrogram, is probably LAME dealing with scalefactor band 21 problem.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #16
@dutch109 ouch! I believe we all have the ideas right in our mind, but we are all fighting with the language. ;)

Greynol's assertion that given a mono file A, if one encodes it in mono B' and joint stereo B'', the actual audio of those files should be identical, as the joint stereo would be making the decision of mid = input, "side = 0". The actual bits of the track would not be identical (channel mode indicator aside), and in fact, the joint stereo file B'' should be slightly bigger than the single channel B'. This was asserted once by one of the developers, basically because joint stereo still represents two streams, whereas single mono is just one stream.

If it was encoded to dual mono B''' as my initial confusion, then the audibly content should still be the same, but the file B''' would be twice as big as B'. (dual mono was intended for Dual audio as in a film with two languages. As such, it is composed of two independent streams).

Then, your assertion that a joint stereo file is more efficient in terms of bitrate against dual mono, and also against simple stereo is true. (That's the whole point of using joint stereo).
As such, you are making the connection than..  2 * bitrate of single mono > bitrate of joint stereo  (so, joint stereo being more efficient)

And from that connection, you assert your original bug report that   x kbps mono should be using a lower bandwidth than 2x kbps joint stereo, not higher.



@rutra80 You're probably right, although if that is the case, the pictures are reversed ( CBR <-> VBR ). That, or really that it is not encoding them because to do so accurately would require more bits that what it is available. (strange...)

Quote
-Y
Allows -V2, -V1 and -V0 to not to encode the highest frequencies accurately, if doing so causes disproportional increases in bitrate. This is the same that CBR and ABR modes do.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #17
FWIW, I was thinking that the channel information (M/S, L/R, etc.) was calculated before being encoded. That the encoder might leave something in the S channel is something I had considered but didn't know either way.

Clearly 160kb for joint stereo encoding of mono content would apply 2x the data over 80kb for mono used for mono encoding.

Anyway, back to the initial concern of difference in frequency response.
Is 24-bit/192kHz good enough for your lo-fi vinyl, or do you need 32/384?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #18
doh!!! My mistake.. obviously CBR is CBR... My comment about joint being slightly bigger in that specific case would apply to VBR.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #19
Since a moderator has posted without moving the thread, I assume it's OK to continue the discussion here.

@Porcus

If I've understood this correctly VBR goes for a target quality (Taking bits from the parts that are unimportant according to human hearing and distributing them over the parts that are more important) for a given bitrate whereas CBR only goes for the given bitrate. (I hope I've got it this time)

But @rutra80's sentence contradicts with VBR being more efficient because -V0 has a higher -lowpass value compared to CBR 320. Why should VBR distribute bits over 20KHz as those frequencies are inaudible and not save them for lower frequencies that are audible ?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #20
VBR is tuned separately from CBR, if I'm understanding the problem correctly.  To be honest, I can't be bothered to pull up those images, with spoilers, no less. They should have been included in the post.

I apologize for the off-topic tangent. When I see stuff that I think is incorrect I'll usually interject, though I should have moved it after it got protracted, especially since I was mistaken about what was said as well as being incorrect with what I had said.
Is 24-bit/192kHz good enough for your lo-fi vinyl, or do you need 32/384?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #21
By default V0 has possibility to encode full bandwidth, it doesn't mean that it has to. As can be seen on your spectrograms (I assume they're not mixed up, made with non-buggy lame version and without additional switches) VBR discarded more high frequency content than CBR, despite lack of lowpass preprocessing.

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #22
@greynol

Not a problem really, just me trying to understand how MP3s work. The reasoning behind it is that I didn't want to waste the bandwidth of everyone visiting this thread so I just put the links, then I thought the forum software might just wrap them in [IMG] tags and display them anyway, a problem which I used spoiler tags for, but I admit I should have just put the images.
You don't have to, I was the one who'd posted in the wrong subforum in the 1st place.
I'm including the images for easier access for anyone who isn't comfortable with the method in post #1.

@rutra80

So that is to give VBR the possibility of full bandwidth encoding, but being a smart algorithm (As stated by @Porcus) it'll allocate bits more where it's more likely to affect human perception, am I right ?
I encoded them using fb2k default settings and LAME 3.100. Sorry, but I don't see that, instead it seems VBR has distributed high frequency content differently not discarded them more. VBR stretches beyond 20kHz so I can't say how much it's discarded high frequencies compared to CBR which is under 20kHz.
One more question:
What are the use cases of being able to encode full bandwidth ?

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #23
On spectrogram of your V0 encoding everything above 16kHz is darker than in original and CBR encoding, or rather, darks are darker, which means that very weak HF content was discarded. By the colours it seems that the affected HF content is mostly on the edge of 16bit noise floor (~-96dBFS), which means that even if it was in the mid range we hear best, you would have to listen to it unrealistically loud to hear it at all - that's how weak the discarded content is.
V0 is designed to give the best quality/size ratio possible in mp3 format. It doesn't do any blind preprocessing as resampling or lowpass filtering, to give psychoacoustic model a chance to deal with all the original content. V modes higher than 0 do lowpass filtering or even resample.
If I was in charge, I would design CDs to have 32 kHz sampling rate :>

Re: Why does LAME cut off frequencies differently for CBR and VBR ?

Reply #24
@rutra80

But shouldn't it be even darker ?
According to your post earlier (#6) that would save more bits for the frequencies that we can actually hear. Instead V0 has allocated some bits over 20kHz that we can't hear (Even if they were strong HF content).
Yeah, and you would've gotten away with it :D

 
SimplePortal 1.0.0 RC1 © 2008-2018