OUTPinged_
21st March 2002, 00:12
:/
It isnt written anywhere. Some time ago it was mentioned xvid doesnt use gauge-like rate control, so it would be nice if somebody posted here a brief explanation of how quantizer is calculated.
More understanding on codec's work = better rips, as always :-)
For an egzample, a good old post of Waldo himself on Nandub's drf selection(from an old forum):
----------------------------------------------------------------
vV nn
Moderator
Posts: 509
(6/30/01 12:42:38 am)
Re: gauge/br vs drf, pls, explain
--------------------------------------------------------------------------------
Well, let's try in simple words.
To achieve its bitrate control, the codec uses mainly 2 parameters :
* The Bits Reservoir (BR) is simply the number of bits that the codec may use for 5 seconds of video. Obviously, it is directly proportional to the bitrate (R). And a bitrate change is equivalent to a scaling of this variable and all those who are related to it, like the gauge.
* The Gauge (G) is the marker (from 0 up to BR) that the codec uses to 'know' how it is consuming bits. Since Nandub changes the bitrate while encoding, it is more practical to consider it as a %age of the BR.
G is updated after each encoded frame. Let's call F the amount of bits allocated for one single frame at a specific bitrate (divide the bitrate expressed in bits/s by the framerate expressed in frames/s). Now, let's call S the actual size of the encoded frame. Then G is updated like this :
G = G + F - S
Simple, uh? You can easily see that if S>F (if the encoded frame is bigger than what the bitrate prescribes), G gets lower.
How does all this relate to compression levels (CL) ? Well, there's a rather complex algorythm which looks approximately like this :
- look at the gauge
- look at the frame
- look at the bitrate
- look at the previous CL
- chew a bit
- spit a CL
- check it against to min/max
- encode
- update the gauge
(of course, Nandub adds a bit salt here, since it can change many things between frames)
There's a special 'level' of the gauge (35%) at which the codec starts to be nasty with CLs. If the gauge gets lower than this value, the codec starts seriously increasing CLs. And of course, the lower it gets, the greatest the CLs. And naturally, when the gauge is over this 35% mark, the codec tends to use more bits than prescribed by the bitrate.
It isnt written anywhere. Some time ago it was mentioned xvid doesnt use gauge-like rate control, so it would be nice if somebody posted here a brief explanation of how quantizer is calculated.
More understanding on codec's work = better rips, as always :-)
For an egzample, a good old post of Waldo himself on Nandub's drf selection(from an old forum):
----------------------------------------------------------------
vV nn
Moderator
Posts: 509
(6/30/01 12:42:38 am)
Re: gauge/br vs drf, pls, explain
--------------------------------------------------------------------------------
Well, let's try in simple words.
To achieve its bitrate control, the codec uses mainly 2 parameters :
* The Bits Reservoir (BR) is simply the number of bits that the codec may use for 5 seconds of video. Obviously, it is directly proportional to the bitrate (R). And a bitrate change is equivalent to a scaling of this variable and all those who are related to it, like the gauge.
* The Gauge (G) is the marker (from 0 up to BR) that the codec uses to 'know' how it is consuming bits. Since Nandub changes the bitrate while encoding, it is more practical to consider it as a %age of the BR.
G is updated after each encoded frame. Let's call F the amount of bits allocated for one single frame at a specific bitrate (divide the bitrate expressed in bits/s by the framerate expressed in frames/s). Now, let's call S the actual size of the encoded frame. Then G is updated like this :
G = G + F - S
Simple, uh? You can easily see that if S>F (if the encoded frame is bigger than what the bitrate prescribes), G gets lower.
How does all this relate to compression levels (CL) ? Well, there's a rather complex algorythm which looks approximately like this :
- look at the gauge
- look at the frame
- look at the bitrate
- look at the previous CL
- chew a bit
- spit a CL
- check it against to min/max
- encode
- update the gauge
(of course, Nandub adds a bit salt here, since it can change many things between frames)
There's a special 'level' of the gauge (35%) at which the codec starts to be nasty with CLs. If the gauge gets lower than this value, the codec starts seriously increasing CLs. And of course, the lower it gets, the greatest the CLs. And naturally, when the gauge is over this 35% mark, the codec tends to use more bits than prescribed by the bitrate.