HEVC rate control (code control) introduction

Video encoding rate control

  1. Rate control: By selecting a series of encoding parameters, the bit rate after video encoding can meet all required rate limits, and the encoding distortion can be minimized.
  2. Rate control belongs to the category of rate-distortion optimization, and the focus of the rate control algorithm is to determine the quantization parameter (Quantization Parameter, QP) related to the rate.
  3. The main work of rate control is to establish the relationship model between encoding rate and quantization parameter, and determine the quantization parameter in video encoding parameters according to the target bit rate.
  4. The actual coding rate control scheme is usually broken down into two steps:
    ○ Consider the correlation of video in the spatial domain and time domain, and determine the optimal target number of bits for each coding unit according to the total target number of bits, which is called bit allocation ; ○ According to the relational model with quantization parameters of the coding rate, the quantization parameters
    are independently determined for each coding unit according to its target number of bits ;
  5. Since the coding rate of a coding unit is mainly related to the quantization parameter, other coding parameters have little influence, so the coding rate has a relatively definite relationship with the quantization parameter, and the quantization parameter of the coding unit can be directly determined based on this relationship based on the target number of bits of the coding unit.
  6. When the quantization parameter is constant, the higher the space and time domain complexity of the video sequence, the higher the number of coded bits generated.
    insert image description here

buffer mechanism

  1. The encoding rate of video is closely related to many factors such as encoding parameters, encoding structure, and video content, and the rate control algorithm usually cannot guarantee that the actual encoding rate is exactly the same as the target rate;

  2. In order to reduce the difference between the actual encoding rate and the target rate, a data buffer area, called a "buffer mechanism", is usually established between the encoder and the channel to smooth the difference between the encoding rate and the channel rate.
    insert image description here

  3. The buffer mechanism can make the encoding rate better match the channel rate, but its existence will not only consume a certain amount of storage space, but also introduce delay; so the size of the buffer is generally determined by the maximum allowable delay and operating costs .

  4. In order to design a rate control algorithm with a buffer zone, the dynamic change process of the buffer zone is usually represented by a fluid flow model .

  5. In order to effectively play the role of the buffer, the amount of data in the buffer needs to be maintained at a certain level to cope with the change of the channel rate and the matching error between the encoding rate and the target rate;

  6. The basic idea of ​​video encoding rate control using a buffer : if the actual encoding rate is higher than the available channel bandwidth, excess bits will accumulate in the buffer; when the number of bits in the buffer accumulates to a certain height, rate control The algorithm will take certain measures to reduce the actual encoding rate to reduce the buffer fullness; on the contrary, when the buffer fullness is lower than a certain level, the rate control algorithm will increase the actual encoding rate appropriately, so that the buffer fullness rises to certain level.
    insert image description here

Rate Control Technology

  1. First, the target bit allocation is performed for the coding unit, that is, the appropriate target number of bits is allocated to the coding unit according to the video content, buffer status and channel bandwidth; then, the quantization parameter is independently determined for the coding unit to achieve the allocated target bits, and the key is to determine the quantization parameter , so this relief is called quantization parameter determination.
    insert image description here

  2. Target bit allocation
    A video sequence has a large number of coding units, and it is too complicated to directly allocate target bits to coding units. Usually, a hierarchical method is used to simplify the problem of target bit allocation, which can be GOP level, image level, and macroblock level in turn
    ; The distortion of the actual coding unit is not additive, the quality of the video sequence is not the sum or average of the quality of all images, the quality of the image is not the sum or average of the quality of all macroblocks, and the consistency of video quality in time and space It has become an important aspect to measure the performance of the rate control algorithm.

  3. Quantization parameter determination
    ■ The key is to establish the rate-quantization parameter (R-QP) model.

h265 rate control

  1. The rate control algorithm recommended by the previous standards cannot be directly used in h265, mainly because: the time domain prediction technology makes the inter-frame rate-distortion performance relationship complicated; the new intra-frame prediction and the spatial prediction of motion information make the inter-CTU also have complex Rate-distortion performance dependence; the new CABAC technology makes better use of the correlation between transform coefficients, making the RQ relationship more complex.
  2. h265 still adopts the traditional two-step method: target bit allocation and quantization parameter determination; ○ The core
    of target bit allocation is to consider the interdependence between video frame rate distortions to achieve image-level target bit allocation, and consider the CTU-level Target bit allocation; ○ The core of quantization parameters is to establish a relationship model between the number of coding bits and quantization parameters according to the video content;

JCTVC-K0103 Rate Control Algorithm

  1. JCTVC-K0103 is the rate control algorithm of the h265 test model HM10.0. The rate control algorithm is mainly divided into two steps: according to the target code rate to allocate the target number of bits to different coding units; according to R and Lagrangian factor, Lagrange The relationship model between Langer factor and QP determines the quantization parameters of different coding units.
    Target bit allocation: GOP-level target bit allocation, image-level target bit allocation, CTU-level target bit allocation
    Quantization parameter determination: The hyperbolic function can well reflect the relationship between h265 video bit rate and distortion;
    insert image description here

  2. The relationship between the quantization parameter QP and the Lagrange factor:
    insert image description here

  3. After the quantization parameters are determined, the current image can be encoded. After the image encoding is completed, the actual number of encoded bits bpp^ can be obtained. Using bpp^, the parameters Alpha and Baita can be updated for use in rate control of candidate images.
    insert image description here

  4. The determination method of quantization parameters at the CTU level is similar to that at the image level. First, the Lagrangian factor is obtained according to the relationship between the target number of bits and the Lagrangian factor. The Lagrangian factor of the mth CTU is:
    insert image description here

  5. It should be noted that the QP difference between two adjacent CTUs should not be greater than 1, and the QP difference between the current CTU and its image should not be greater than 2.

reference

  1. A New Generation of High Efficiency Video Coding H.265HEVC Principles, Standards and Implementation [Edited by Wan Shuai and Yang Fuzheng] 2014 Edition.

Guess you like

Origin blog.csdn.net/yanceyxin/article/details/132020812