public class Reservoir
extends java.lang.Object
1. The following rule can be used to calculate the maximum
number of bits used for one granule [^W frame]:
At the highest possible bitrate of Layer III (320 kbps
per stereo signal [^W^W^W], 48 kHz) the frames must be of
[^W^W^W are designed to have] constant length, i.e.
one buffer [^W^W the frame] length is:
320 kbps * 1152/48 kHz = 7680 bit = 960 byte
This value is used as the maximum buffer per channel [^W^W] at
lower bitrates [than 320 kbps]. At 64 kbps mono or 128 kbps
stereo the main granule length is 64 kbps * 576/48 kHz = 768 bit
[per granule and channel] at 48 kHz sampling frequency.
This means that there is a maximum deviation (short time buffer
[= reservoir]) of 7680 - 2*2*768 = 4608 bits is allowed at 64 kbps.
The actual deviation is equal to the number of bytes [with the
meaning of octets] denoted by the main_data_end offset pointer.
The actual maximum deviation is (2^9-1)*8 bit = 4088 bits
[for MPEG-1 and (2^8-1)*8 bit for MPEG-2, both are hard limits].
... The xchange of buffer bits between the left and right channel
is allowed without restrictions [exception: dual channel].
Because of the [constructed] constraint on the buffer size
main_data_end is always set to 0 in the case of bit_rate_index==14,
i.e. data rate 320 kbps per stereo signal [^W^W^W]. In this case
all data are allocated between adjacent header [^W sync] words
[, i.e. there is no buffering at all].
| Constructor and Description |
|---|
Reservoir() |
| Modifier and Type | Method and Description |
|---|---|
void |
ResvAdjust(LameInternalFlags gfc,
GrInfo gi)
Called after a granule's bit allocation.
|
int |
ResvFrameBegin(LameGlobalFlags gfp,
MeanBits mean_bits) |
void |
ResvFrameEnd(LameInternalFlags gfc,
int mean_bits)
Called after all granules in a frame have been allocated.
|
int |
ResvMaxBits(LameGlobalFlags gfp,
int mean_bits,
MeanBits targ_bits,
int cbr)
returns targ_bits: target number of bits to use for 1 granule
extra_bits: amount extra available from reservoir Mark Taylor 4/99 |
void |
setModules(BitStream bs) |
public final void setModules(BitStream bs)
public final int ResvFrameBegin(LameGlobalFlags gfp, MeanBits mean_bits)
public final int ResvMaxBits(LameGlobalFlags gfp, int mean_bits, MeanBits targ_bits, int cbr)
public final void ResvAdjust(LameInternalFlags gfc, GrInfo gi)
public final void ResvFrameEnd(LameInternalFlags gfc, int mean_bits)