10 RATE CONTROL AND QUANTIZATION CONTROL

This section describes the procedure for controlling the bit-rate of the Test Model by adapting the macroblock quantization parameter quantizer_scale. The algorithm works in three-steps:

1 Target bit allocation: this step estimates the number of bits available to code the next picture. It is performed before coding the picture.

2 Rate control: by means of a "virtual buffer", this step sets the reference value of the quantization parameter for each macroblock.

3 Adaptive quantization: this step modulates the reference value of the quantization parameter according to the spatial activity in the macroblock to derive the value of the quantization parameter, mquant, that is used to quantize the macroblock.

Step 1 - Bit Allocation

Complexity estimation

After a picture of a certain type (I, P, or B) is encoded, the respective "global complexity measure" (Xi, Xp, or Xb) is updated as:

where Si, Sp, Sb are the number of bits generated by encoding this picture and Qi, Qp and Qb are the average quantization parameter computed by averaging the actual quantization values used during the encoding of the all the macroblocks, including the skipped macroblocks.

Initial values

Xi = (160 * bit_rate) / 115

Xp = (60 * bit_rate) / 115

Xb = (42 * bit_rate) / 115

bit_rate is measured in bits/s.

Picture Target Setting

The target number of bits for the next picture in the Group of pictures (Ti, Tp, or Tb) is computed as:









Where:

Kp and Kb are "universal" constants dependent on the quantization matrices. For the matrices specified in sections 7.1 and 7.2 Kp = 1.0 and Kb = 1.4.

R is the remaining number of bits assigned to the GROUP OF PICTURES. R is updated as follows:

After encoding a picture , R = R - Si,p,b

Where is Si,p,b is the number of bits generated in the picture just encoded (picture type is I, P or B).

Before encoding the first picture in a GROUP OF PICTURES (an I-picture):

R = G + R

G = bit_rate * N / picture_rate

N is the number of pictures in the GROUP OF PICTURES.

At the start of the sequence R = 0.

Np and Nb are the number of P-pictures and B-pictures remaining in the current GROUP OF PICTURES in the encoding order.

I
B
B
P
B
B
P
B
B
P
B
B
P
R-bits
Np = 3
Nb = 4

Figure 10.1 - Example of Remaining pictures in GOP at frame 7

Step 2 - Rate Control


Figure 10.2 : Rate Control for P-pictures

Before encoding macroblock j (j >= 1), compute the fullness of the appropriate virtual buffer:

or

or

…depending on the picture type.

where

are initial fullnesses of virtual buffers - one for each picture type.

Bj is the number of bits generated by encoding all macroblocks in the picture up to and including j.

MB_cnt is the number of macroblocks in the picture.

are the fullnesses of virtual buffers at macroblock j- one for each picture type.

The final fullness of the virtual buffer (: j = MB_cnt) is used as for encoding the next picture of the same type.

Next compute the reference quantization parameter Qj for macroblock j as follows:

where the "reaction parameter" r is given by


and dj is the fullness of the appropriate virtual buffer.

The initial value for the virtual buffer fullness is:

Step 3 - Adaptive Quantization

Compute a spatial activity measure for the macroblock j from the four luminance frame-organised sub-blocks (n=1..4) and the four luminance field-organised sub-blocks (n=5..8) using the intra (i.e. original) pixel values:

where

and


and Pk are the sample values in the n-th original 8*8 block.

Normalise actj:


avg_act is the average value of actj the last picture to be encoded. On the first picture, avg_act = 400.

Obtain mquantj as:

where Qj is the reference quantization parameter obtained in step 2. The final value of mquantj is clipped to the range [1..31] and is used and coded as described in sections 7, 8 and 9 in either the slice or macroblock layer.

Known Limitations


  • Back to Contents