Rate Control Parameters - 2020.2 English

H.264/H.265 Video Codec Unit v1.2 Solutions LogiCORE IP Product Guide (PG252)

Document ID
PG252
Release Date
2020-11-24
Version
2020.2 English
Table 1. Encoder Rate Control Section Parameters
Parameter Description and Possible Values
RateCtrlMode Selects the way the bit rate is controlled
  • CONST_QP: No rate control, all pictures use the same QP defined by the SliceQP parameter.
  • CBR: Use constant bit rate control.
  • VBR: Use variable bit rate control.
  • LOW_LATENCY: Use variable bit rate for low latency application.
  • CAPPED_VBR, PLUGIN

Default value: CONST_QP

BitRate Target bit rate in Kb/s. Not used when RateCtrlMode = CONST_QP

Default value: 4000

MaxBitRate Target bit rate in Kb/s. Not used when RateCtrlMode = CONST_QP

Default value: 4000

Note: When RateCtrlMode is CBR, MaxBitRate shall be set to the same value as BitRate.
FrameRate Number of frames per second

Default value: 30

SliceQP Quantization parameter. When RateCtrlMode = CONST_QP the specified QP is applied to all slices. When RateCtrlMode = CBR the specified QP is used as initial QP.

Allowed values: from 0 to 51

Default value: 30

MinQP 1 Minimum QP value allowed. This parameter is especially useful when using VBR rate control. In VBR rate control the value AUTO can be used to let the encoder select the MinQP according to SliceQP.

Allowed values: from 0 to SliceQP

Default value: 10

MaxQP Maximum QP value allowed.

Allowed values: from SliceQP to 51

Default value: 51

InitialDelay Specifies the initial removal delay as specified in the HRD model, in seconds. Not used when RateCtrlMode = CONST_QP.
Note: If this value is set too low (less than 1 frame period), you may see reduced visual quality.

Default value: 1.5

CPBSize Specifies the size of the Coded Picture Buffer as specified in the HRD model, in seconds. Not used when RateCtrlMode = CONST_QP.

Default value: 3.0

IPDelta Specifies the QP difference between I frames and P frames.

Allowed values: AUTO or positive value (≥ 0)

Default value: AUTO

PBDelta Specifies the QP difference between P frames and B frames.

Allowed values: AUTO or positive value (≥ 0)

Default value: AUTO

ScnChgResilience Specifies the scene change resilience handling during encode process. Improves quality during scene changes.

ENABLE, DISABLE, TRUE, FALSE

Default value: TRUE

MaxPictureSize 2 Maximum frame size allowed in Kb/s. If only MaxPictureSize is provided, it sets MaxPictureSize for all I, P, and B frames. To set MaxPictureSize individually, refer MaxPictureSize.I, MaxPictureSize.P, and MaxPictureSize.B

MaxPictureSize = TargetBitrate(in Kbits/s) / FrameRate * AllowedPeakMargin

Recommend a 10%AllowedPeakMargin.

That is, MaxPictureSize = (100Mb/s / 60 fps) * 1.1 = 1834 Kbits per frame

EnableSkip Enabling frameskip feature. available values: DISABLE, ENABLE, FALSE, TRUE

Default value: FALSE

MaxConsecutiveSkip Specifies the maximum number of consecutive skipped frames if EnableSkip is enabled.

Default value: 4294967295

MaxPictureSize.B Specifies a coarse size (in Kbits) for B-frame that should not be exceeded.

Default value: DISABLE

MaxPictureSize.I Specifies a coarse size (in Kbits) for I-frame that should not be exceeded.

Default value: DISABLE

MaxPictureSize.P Specifies a coarse size (in Kbits) for P-frame that should not be exceeded.

Default value: DISABLE

MaxQuality Max quality target.

Default value: 14.000000

  1. In VBR the MinQP is computed based on the InitialQP. For example, MinQP = InitialQP - 8. When set to AUTO, the InitialQP is computed based on the video resolution, frame rate, and the target bit-rate. MinQP value less than 10 can generate a very huge picture in case of scene change, and the rate controller may take a longer time with low quality, to recover and achieve the target bit-rate. When InitialQP is 8 (less than 10), the automatic MinQP is always set to 10. When the value of MinQP is AUTO, it should have the same behavior in AVC as in HEVC. When the value of RateCtrlMode is LOW_LATENCY, it enables the HW rate-control of the VCU. This means the QP is adapted within the frame, thus preventing a huge frame. So MinQP does need to be constrained as in frame level ratecontrol.
  2. When user set MaxPictureSize parameter, MCU firmware enables the hardware rate control module to keep track of encoding frame size, It adjusts the QPs with in the frame to make sure encoded picture sizes honor the provided max-picture-size. Initial statistics is based on the start of the frame (first few macro block (MB) rows), and the rate control algorithm further modulates the QP as the picture progresses to restrict the maximum picture size with the limit specified by the MaxPictureSize, as much as possible. This is different from than the normal rate control (CBR/VBR), without the MaxPIctureSize parameters enabled, since the rate control only receives feedback after the picture is encoded. This means that the QP withing a frame is manipulated to curtail the frame size to the specified limit (MaxPictureSize). When the MaxPictureSize is enabled, it uses the hardware (VCU Encoder IP, has hardware rate control module in it, which is generally used for low-latency application (low-latency rcmode)) statistics to restrict maximum picture size with in the limit as much as possible.

The CPBSize default value is set to 3 sec in the VCU software (if allowed by the defined encoding level and bit rate parameters), with an option to change this value based on the application requirements. The encoder CBR rate control tries to reach the target bit rate over the period of the GOP length but the main constraint is that it must avoid buffer underflows/overflows as defined by the standard Hypothetical Reference Decoder (HRD) model. A larger CPBSize allows the Encoder rate control to distribute the encoded bits over a larger number of frames so that it can handle larger bit rate variations among consecutive frames and increase video quality. Setting the CPBSize so a smaller value can reduce the bit rate peaks but can also impact the video quality.

Important: CPB size tuning must be done based on the application.
  • Video recording and storage applications, where instantaneous bit rate fluctuations are unimportant, and can support larger buffering, and should set the CPBSize to larger values (~1s-3s).
  • It is recommended to set the CPBSize to a value that is greater than the GOP length duration (for example, for a 60 fps setting, the GOP length could be set to 60 frames and the CPBSize to more than 1s.)
  • Applications that require smaller bit rate variations can reduce the CPBSize but it is recommended to set a value larger than ~6 frame periods. It is also recommended in such cases to enable the low-latency rate control mode.
  • Low-latency applications should use a "low-delay" GOP type (or intra-only GOP type) and then can reduce the CPBSize down to ~1-2 frame periods.
  • For applications that require lower bit-rates like one Mb/s and minimal variation expected in the instantaneous bit-rate, it is recommended to have smaller CPBSize, which makes it easier for the VCU to keep a constant bit-rate. The only reason to scale the CPBSize between very high rates and very low rates is to trade-off quality versus instantaneous bit-rate fluctuations.
  • If your use case does bother about instantaneous bit-rate fluctuations (which can cause high CPU usage resulting in dropped frames), then its recommended to increase the CPBSize, which gives the rate algorithm a bit more flexibility to allocate more bits to specific frames, which can improve the quality. For very high bitrates like 100 Mb/s, the quality difference should be negligible, but it might make a difference as the bit-rate decreases.
  • Ensure to update InitialDelay whenever you change the CPBSize. InitialDelay can be any value less than or equal to the CPBSize.
  • The InitialDelay should have a very minimal effect on the frame-bits consumption. Xilinx recommends that you use half of the CPBSize, but for a small CPBSize (approximately 6 frames), set CPBSize=InitialDelay. The default InitialDelay parameter is 1.5s (half of the default CPBSize of 3s).
  • The CPBSize and InitialDelay parameters are generally used to verify the hypothetical reference decoder (HDF) buffer model conformance. The InitialDelay parameter specifies the time at which the first picture data needs to be removed from the buffer. It does not refer to the physical buffers, but it helps in verifying the HRD conformance. For more details, see the H264 standard Annex C.
  • It is not recommended to have the CPBSize smaller than 6 frames (approximately). This can result in cases where the bits, allocated to each frame, are not as expected because the algorithm does not have enough frames for adjusting the quantization.