IPB

Welcome Guest ( Log In | Register )

2 Pages V   1 2 >  
Reply to this topicStart new topic
CBR, VBR and bit reservoir
drrat
post Nov 20 2006, 14:32
Post #1





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



I'm a bit confused... I've read several documents concerning the MP3 standard but I'm not sure I inderstood well:

The MP3 ISO standard does not support VBR encoding. Which means that the uncompressed signal is devided into equal frames (1152 samples). Using VBR encoding would involve deviding the signal to unequal frames.

Instead of doing that, MP3 uses CBR frame deviding but during quantization it allocates more bits to frames that are more complex by using the bit reservoir.

In addition there are MP3 encoders which do not strictly follow the ISO standard. These encoders devide the uncompressed signal into unequal frames and therefore use VBR encoding. And if this is right, do these non-standarised encoder also use the bit reservoir?

Are all the above correct?
Thank you in advance!
Go to the top of the page
+Quote Post
Sebastian Mares
post Nov 20 2006, 15:42
Post #2





Group: Members
Posts: 3633
Joined: 14-May 03
From: Bad Herrenalb
Member No.: 6613



Wait, are you saying VBR would not be legal? If yes, that is wrong - VBR IS legal and every MP3 player is required to support decoding of VBR MP3s. As far as I know, VBR also uses bit reservoir, especially for 320 kbps frames where the bitrate cannot go higher.


--------------------
http://listening-tests.hydrogenaudio.org/sebastian/
Go to the top of the page
+Quote Post
benski
post Nov 20 2006, 16:08
Post #3


Winamp Developer


Group: Developer
Posts: 670
Joined: 17-July 05
From: Brooklyn, NY
Member No.: 23375



I think you are confusing compressed and uncompressed frame sizes. MP3 frames always decode to 1152 samples, regardless of the bitrate. However, the amount of compressed bits can vary from frame to frame (within the selectable bitrates) This is what VBR means.

This post has been edited by benski: Nov 20 2006, 16:08
Go to the top of the page
+Quote Post
halb27
post Nov 20 2006, 16:11
Post #4





Group: Members
Posts: 2441
Joined: 9-October 05
From: Dormagen, Germany
Member No.: 25015



Each mp3 file can be imagined as a stream of audio frames and transport frames which are moving pretty much - but not entirely - synchroneously.

An audio frame always consists of the encoding of 1152 samples.
A transport frame is what consecutively makes up for the mp3 file.

Using CBR means each transport frame consists of the same number of bits according to one of the standardized frame bitrates (320 kbps, 256 kbps, 224 kbps, ...).
In it's easiest form one transport frame takes up exactly one audio frame.
However the mp3 concept is more flexible. If the encoder decides that a transport frame has more space than is needed for the actual audio frame, it can use the remaining space for the next audio frame.
This way audio frames need not be of constant size, audio data bitrate can vary (within the limits that this bit reservoir concept puts and which make sure that audio frames are moving pretty synchroneously with transport frames).

For a higher degree of audio data bitrate variation transport frame bitrate can vary as well, and this is what we call VBR. This is well within the standard.

When people say that an encoder does not obey the standard this usually has to do with certain buffer sizes and with bit reservoir usage on 320 kbps frames. The standard isn't very clear in this respect.

From a more practical viewpoint it's not the standard or encoders not obeying the standard that is of concern but implementation details of certain decoders. Unfortunately there are decoders out there which don't allow for VBR or even high bitrate frames at all. Usually this has nothing to do with the standard.

If you have to care about such things, you can take care of bad decoders on the encoding side: use CBR 224 as well as Lame's strict-iso option.

This post has been edited by halb27: Nov 20 2006, 16:19


--------------------
lame3100m -V1 --insane-factor 0.75
Go to the top of the page
+Quote Post
drrat
post Nov 20 2006, 16:43
Post #5





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



Halb27, I'm not sure I understand the difference between audio frames and transport frames. So, let me be more specific:

As far as I know the first step of an MP3 encoder is the segmentation into frames of samples. Is this frame size constant or variable? (I understand that it is constant - 1152 samples). And does this has to do with the encoding being CBR or VBR? The bit reservoir is used in CBR, VBR or in both??

And another question... From what you're saying the MP3 ISO standard includes VBR. What about Layers I and II. Do they support VBR?
Go to the top of the page
+Quote Post
stephanV
post Nov 20 2006, 16:56
Post #6





Group: Members
Posts: 394
Joined: 6-May 04
Member No.: 13932



QUOTE
As far as I know the first step of an MP3 encoder is the segmentation into frames of samples. Is this frame size constant or variable? (I understand that it is constant - 1152 samples).

It is always 1152 samples.

QUOTE
And does this has to do with the encoding being CBR or VBR?

It doesn't. CBR or VBR is related to the size of the compressed frames in bits (not samples!). The size of the compressed frames in bits is allowed to vary in which case we speak of VBR.

QUOTE
The bit reservoir is used in CBR, VBR or in both??

Bit reservoir can be used in both.

QUOTE
From what you're saying the MP3 ISO standard includes VBR. What about Layers I and II. Do they support VBR?

Layer II supports VBR for encoding (not really in a good way, but still), but it is not mandatory for layer II decoders to support this.


--------------------
"We cannot win against obsession. They care, we don't. They win."
Go to the top of the page
+Quote Post
Sebastian Mares
post Nov 20 2006, 17:00
Post #7





Group: Members
Posts: 3633
Joined: 14-May 03
From: Bad Herrenalb
Member No.: 6613



Bit reservoir can be used in both CBR and VBR mode; it's up to the encoder. You can even tell LAME not to use a bit reservoir at all.

As far as I know, frame size is constant and is 1152 samples for MPEG 1 Layer II and III and MPEG 2(.5) Layer II. For MPEG 1 Layer I it's 384, for MPEG 2(.5) Layer I it's 192 and for MPEG 2(.5) Layer III it's 576. These figures are based on a PDF I read years ago. Edit: Anyways, the size should remain constant over the whole stream.

Layer I does not support VBR, Layer II can support VBR and Layer III has to support VBR as far as I know.

This post has been edited by Sebastian Mares: Nov 20 2006, 17:01


--------------------
http://listening-tests.hydrogenaudio.org/sebastian/
Go to the top of the page
+Quote Post
drrat
post Nov 20 2006, 17:17
Post #8





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



QUOTE (stephanV @ Nov 20 2006, 17:56) *
QUOTE
And does this has to do with the encoding being CBR or VBR?

It doesn't. CBR or VBR is related to the size of the compressed frames in bits (not samples!). The size of the compressed frames in bits is allowed to vary in which case we speak of VBR.


When you say "compressed frame" what exactly do you mean? Do you mean the compressed (quantized, coded) representation of an input frame?
Go to the top of the page
+Quote Post
halb27
post Nov 20 2006, 22:44
Post #9





Group: Members
Posts: 2441
Joined: 9-October 05
From: Dormagen, Germany
Member No.: 25015



QUOTE (drrat @ Nov 20 2006, 18:17) *
When you say "compressed frame" what exactly do you mean? Do you mean the compressed (quantized, coded) representation of an input frame?

stephanV certainly was talking about the encoded representation of an input frame.


--------------------
lame3100m -V1 --insane-factor 0.75
Go to the top of the page
+Quote Post
drrat
post Nov 21 2006, 16:40
Post #10





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



QUOTE (halb27 @ Nov 20 2006, 23:44) *
QUOTE (drrat @ Nov 20 2006, 18:17) *

When you say "compressed frame" what exactly do you mean? Do you mean the compressed (quantized, coded) representation of an input frame?

stephanV certainly was talking about the encoded representation of an input frame.


So... if I understand well, in CBR mode there is a constant size for every compressed frame. How can that happen when the bit reservoir is used in CBR mode?

QUOTE (halb27 @ Nov 20 2006, 23:44) *
QUOTE (drrat @ Nov 20 2006, 18:17) *

When you say "compressed frame" what exactly do you mean? Do you mean the compressed (quantized, coded) representation of an input frame?

stephanV certainly was talking about the encoded representation of an input frame.


So... if I understand well, in CBR mode there is a constant size for every compressed frame. How can that happen when the bit reservoir is used in CBR mode?

QUOTE (halb27 @ Nov 20 2006, 23:44) *
QUOTE (drrat @ Nov 20 2006, 18:17) *

When you say "compressed frame" what exactly do you mean? Do you mean the compressed (quantized, coded) representation of an input frame?

stephanV certainly was talking about the encoded representation of an input frame.


So... if I understand well, in CBR mode there is a constant size for every compressed frame. How can that happen when the bit reservoir is used in CBR mode?
Go to the top of the page
+Quote Post
Sebastian Mares
post Nov 21 2006, 16:45
Post #11





Group: Members
Posts: 3633
Joined: 14-May 03
From: Bad Herrenalb
Member No.: 6613



Bit reservoir uses unused space from previous frames.


--------------------
http://listening-tests.hydrogenaudio.org/sebastian/
Go to the top of the page
+Quote Post
drrat
post Nov 21 2006, 16:49
Post #12





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



QUOTE (Sebastian Mares @ Nov 21 2006, 17:45) *
Bit reservoir uses unused space from previous frames.

But if a previous frame leaves some space unused then its size will not be equal to the sizes of the other frames. Which means the encoding is not CBR
Go to the top of the page
+Quote Post
Sebastian Mares
post Nov 21 2006, 16:59
Post #13





Group: Members
Posts: 3633
Joined: 14-May 03
From: Bad Herrenalb
Member No.: 6613



If a 30x30x30 cm box is full and another 30x30x30 cm one is not, it doesn't mean that one box is smaller.

This post has been edited by Sebastian Mares: Nov 21 2006, 17:01


--------------------
http://listening-tests.hydrogenaudio.org/sebastian/
Go to the top of the page
+Quote Post
drrat
post Nov 21 2006, 17:05
Post #14





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



QUOTE (Sebastian Mares @ Nov 21 2006, 17:59) *
If a 30x30x30 cm box is full and another 30x30x30 cm one is not, it doesn't mean that one box is smaller.


If the box you are saying is a compressed frame then there is no bit saving since "empty" means zero-valued bits.

pffff..... i'm mixed up!!!
Go to the top of the page
+Quote Post
benski
post Nov 21 2006, 17:19
Post #15


Winamp Developer


Group: Developer
Posts: 670
Joined: 17-July 05
From: Brooklyn, NY
Member No.: 23375



drrat,
The bit reservoir uses part of the current compressed frame to provide data for the next frame. Each frame is going to be the same size, just that the data isn't evenly distributed between the frames.

This post has been edited by benski: Nov 21 2006, 17:22
Go to the top of the page
+Quote Post
halb27
post Nov 21 2006, 17:35
Post #16





Group: Members
Posts: 2441
Joined: 9-October 05
From: Dormagen, Germany
Member No.: 25015



QUOTE (drrat @ Nov 21 2006, 17:40) *
[So... if I understand well, in CBR mode there is a constant size for every compressed frame. How can that happen when the bit reservoir is used in CBR mode?

The "compressed frame" or (my words:) audio frame is the encoded data representation of 1152 samples.
Even with CBR the amount of bits used for an audio frame can vary from frame to frame depending on what the encoder does.
An mp3 stream consist of a sequence of frames (I called them transport frames) each of which carries the same amount of bits when using CBR.
Now the encoder has to put the audio frames into the equal sized frames. Because of the variable sized audio frames there may be space left in a frame. This free space need not be left free but can be partially used for the next audio frame. This mechanism is the bit reservoir.

Of course the encoder doesn't do these things by chance. If the current music is easy to encode (temporary silence for instance) it can represent the current 1152 samples with a small audio frame. It will do so and use the space left in the current (transport) frame for the next audio frame. This way the encoder can save up space for more complex musical parts.

By this audio frame bitrate can be much higher then 320 kbps as space from the previous transport frame can be used.


--------------------
lame3100m -V1 --insane-factor 0.75
Go to the top of the page
+Quote Post
Klyith
post Nov 22 2006, 01:08
Post #17





Group: Members (Donating)
Posts: 352
Joined: 10-July 04
From: Albany NY USA
Member No.: 15259



Time for instructional images by Klyith! In these pictures, the line at the bottom shows time and each box above it is an mp3 frame. Each tick is 1152 samples, but how much actual time that represents would depend on the sample rate of the audio.

This is CBR

Each frame is the same size.

This is VBR

Same number of frames in each unit of time, but the frames have a variable amount of bits contained.

This is a bit reservoir on a CBR mp3.

It's hard to explain with words, but easy to see in a picture. The blue frame is taking some unused space from the red frame, which would otherwise be wasted, and using it to effectively add "space" to it's own frame. So while the frames are a fixed size, the data that they contain is a bit variable.

Edits: I got the vbr screwed up the first time. There's nothing like trying to explain something to understand it better yourself!

This post has been edited by Klyith: Nov 22 2006, 01:21
Go to the top of the page
+Quote Post
drrat
post Nov 28 2006, 16:02
Post #18





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



QUOTE (Klyith @ Nov 22 2006, 02:08) *
Time for instructional images by Klyith! In these pictures, the line at the bottom shows time and each box above it is an mp3 frame.


Klyith! Very nice explanation! I get the point!

But:
Since in VBR you have variable size of frames, which means you don't waste any bits, why use the bit reservoir on a VBR stream? What I mean, what advantage does the bit reservoir add to VBR?
Go to the top of the page
+Quote Post
pdq
post Nov 28 2006, 16:06
Post #19





Group: Members
Posts: 3443
Joined: 1-September 05
From: SE Pennsylvania
Member No.: 24233



Even in VBR the frames must all be one of the defined sizes. If the bit reservoir were not used then some space would be wasted each time the number of bits needed was not equal to exactly one of these sizes.
Go to the top of the page
+Quote Post
drrat
post Nov 28 2006, 16:09
Post #20





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



QUOTE (pdq @ Nov 28 2006, 17:06) *
Even in VBR the frames must all be one of the defined sizes. If the bit reservoir were not used then some space would be wasted each time the number of bits needed was not equal to exactly one of these sizes.


OK! Now it's clear. Thanx to all

Just one more question: Other CODECs in CBR mode, do they use anything like the bit reservoir?
Go to the top of the page
+Quote Post
Sebastian Mares
post Nov 28 2006, 17:31
Post #21





Group: Members
Posts: 3633
Joined: 14-May 03
From: Bad Herrenalb
Member No.: 6613



AAC does and maybe MusePack, not sure.


--------------------
http://listening-tests.hydrogenaudio.org/sebastian/
Go to the top of the page
+Quote Post
drrat
post Nov 28 2006, 17:52
Post #22





Group: Members
Posts: 15
Joined: 21-September 06
Member No.: 35460



QUOTE (Sebastian Mares @ Nov 28 2006, 18:31) *
AAC does and maybe MusePack, not sure.


What about OGG?
Go to the top of the page
+Quote Post
[JAZ]
post Nov 28 2006, 18:25
Post #23





Group: Members
Posts: 1797
Joined: 24-June 02
From: Catalunya(Spain)
Member No.: 2383



QUOTE (drrat @ Nov 28 2006, 17:52) *
QUOTE (Sebastian Mares @ Nov 28 2006, 18:31) *

AAC does and maybe MusePack, not sure.


What about OGG?


OGG is not CBR. it only works in CBR when forcing the VBR engine to not fluctuate.
Go to the top of the page
+Quote Post
Klyith
post Nov 28 2006, 18:28
Post #24





Group: Members (Donating)
Posts: 352
Joined: 10-July 04
From: Albany NY USA
Member No.: 15259



QUOTE (drrat @ Nov 28 2006, 11:52) *
What about OGG?

Yes Vorbis (technically ogg is the container, vorbis is the codec) has a reservoir.

It is variable, defaulting to 2 seconds of audio data at the average encoding bitrate, so actual size is dependent on what quality value you use. None of the standard encoders expose the setting to change the reservoir, but it can be altered at compile.

Edit:
QUOTE
' date='Nov 28 2006, 12:25' post='452816']OGG is not CBR. it only works in CBR when forcing the VBR engine to not fluctuate.
VBR codecs have reservoirs too, as was mentioned above.

This post has been edited by Klyith: Nov 28 2006, 18:29
Go to the top of the page
+Quote Post
ThyBzi
post Dec 9 2006, 06:01
Post #25





Group: Members
Posts: 33
Joined: 29-November 06
From: Novosibirsk
Member No.: 38186



QUOTE (Sebastian Mares @ Nov 20 2006, 20:42) *
VBR also uses bit reservoir, especially for 320 kbps frames where the bitrate cannot go higher.

Hm, i like that! So the quality of VBR mp3 could be even higher than of 320 kbps CBR (aka "insane" in LAME)? huh.gif I wasn't thinking about that before!

This post has been edited by ThyBzi: Dec 9 2006, 06:03
Go to the top of the page
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 28th November 2014 - 14:46