HEVC之码流K0103研究

来源:互联网 发布:c语言volatile 寄存器 编辑:程序博客网 时间:2024/04/29 21:01

码率控制算法主要解决的问题:

视频图像在经过编码器编码后,在到达解码器之前码率控制主要是为了在有限的缓冲区容量和信道带宽下的传输高质量的视频序列。

 

K0103主要讲了R-λ的模型建立,以及这个模型上的码率控制算法。

在这之前,主要提议的两个R-D模型是

exponential function:   (1

 

Hyperbolic function:     (2

  

R是以bpp的形式表示,D是以MSE的形式表示:    ,f是帧率的意思,R表示码率,w,h分别表示图像的宽高,N是一个图片的总的像素数,rec与org分别表示重建帧的值和原始帧的值。

 

接下来通过实验去导出bpp与MSE的关系,然后去适应上面两个模型,发现Hyperbolic模型的效果更好,系数相关性更高。

 

如上图所示,实线为hyperbolic模型,虚线表示另外一种,最后发现实线的相关系数都比0.99大,所以,选择实线所代表的hyperbolic模型。

 

又根据 λ 为R-D的斜率,所以

    (3

此式子经过转换得:         

       (4

由此,R λ 的关系确立,如(4)式所示。

接下来,便是,在实际中通过R确立 λ 的事了。具体请详细参考提案K0103

 

1.   Rate control via R-λ model

The proposed rate control algorithm can be dividedinto two parts. The first part is bit allocation, and the second part is toadjusting encoding parameters to achieve the allocated bits. Only the secondpart relates to the proposed R-λ model.

1.    

1.   Bit Allocation

Suppose that the target bitrate is tar,the frame rate is f. Thus, the average target bits per picture is

Denote the number of pictures already beencoded coded, and the bit cost on thosepictures Rcoded.

1.   GOP level bit allocation

Suppose there are NGOP picturesin the current GOP. SW is the size of a smooth window, whichis used to make the bitrate change smoother. The SW used inthis contribution is 40. The target bits in a GOP are determined by

    (7)

               (8)

The aim of the smooth window is to achieve thetarget bitrate R after SW pictures, ifthese SW pictures cost exactly TAvgPic bitsper picture. The current buffer status and the target bitrate are jointlyconsidered in (7). (7) can be written in another form

The first item () is the target bitrate, and thesecond item ( ) is the buffer status.

2.   Picture level bit allocation

Denote TGOP is thetarget bits of the current GOP, determined by (8). Coded GOP isthe coded bits of the current GOP. ω is the bitallocation weight of every picture in the current GOP. Thus, the target bit ofthe current picture is determined by

  (9)

The purpose of (9) is to allocate the left bitsaccording to the weight of different pictures.ω is determined by Table 1 and 2.

Table 1 ω of low delay encoding

Coding order

Example POC

Equal allocation

Hierarchical allocation

 

 

 

bpp>0.2

0.2≥ bpp>0.1

0.1≥ bpp>0.05

Others

1

1

1

2

2

2

2

2

2

1

3

3

3

3

3

3

1

2

2

2

2

4

4

1

6

10

12

14

Table 2 ω of random access encoding

Coding order

Example POC

Equal allocation

Hierarchical allocation

 

 

 

bpp>0.2

0.2≥ bpp>0.1

0.1≥ bpp>0.05

Others

1

8

1

15

20

25

30

2

4

1

5

6

7

8

3

2

1

4

4

4

4

4

1

1

1

1

1

1

5

3

1

1

1

1

1

6

6

1

4

4

4

4

7

5

1

1

1

1

1

8

7

1

1

1

1

1

Both the equal bit allocation and hierarchical bitallocation are supported in the proposed rate control algorithm.

In the experiments, hierarchical bit allocation isused for both low delay and random access coding structure. Additionally, theresults of equal bit allocation are also provided for low delay cases, as wethink it does not make much sense of applying equal bit allocation tohierarchical-B coding structure.

There is a special case, the bit allocation forintra pictures. When the QP and λ of intra pictures are not specified (in our simulation, the QP andλ values of intra pictures are fixed, using the values of HEVC anchorwithout rate control), the allocated bits (TCurrPic) arerefined according to bpp, as shown in Table 3.

Table 3 Intra bit allocation refinement

bpp

bpp>0.2

0.2≥ bpp>0.1

Others

Final TCurrPic

5 x TCurrPic

7 x TCurrPic

10 x TCurrPic

It should be noticed that, the refinement specifiedin Table 3 is not used when targeting the bitrate of HM-8.0 anchor (withoutrate control).

And as the intra pictures will cost much more bitsthan inter picture, which may result in the bit cost of intra picture is morethan the bit allocated for the entire GOP. Thus, the bit cost of intra pictureis not used to update CodedGOP (bit cost inside thecurrent GOP), it is only used to update Rcoded (bitcost of the whole sequence). TCurrPic beforerefinement is used to update the current CodedGOP.

3.   LCU level bit allocation

When LCU level rate control is enabled, the targetbits of each LCU is determined by

The Bitheader is the estimated bits of allheaders, including slice header (and maybe APS if it comes back). Bitheader isestimated according to the actual header bits of previous coded picturesbelonging to the same level.

Here ω is the weight of each LCU, estimated by the prediction error(in form of MAD) of collocated picture in the previous coded picture belongingto the same level.

2.    

2.   Achieve the allocated bit

As shown in Section 2, R and λ have strong relationship. Toachieve a target R, we only need to determine a corresponding λ . λ can be determined according to(5), as the target R is known here. We should determine α and β value here. As shown in Fig. 2,different sequences have quite different values. A simple solution is topre-encode some pictures and fit the R-λ curve so asto get α and β values for a specified sequence. Butit will introduce additional encoding complexity and greatly increase thedelay. In addition, when the characteristic of the video sequence changes(e.g., scene changes), the predetermined α and β values will be no longervalid. To adapt to various video sequence with differentcharacteristic, we design the following algorithms.

       (10)(利用此公式通过R更新LCU和图片层次的λ,更新λ,通过公式11和13更新α and β

We use (10) to derive λ value from target R fora picture level or LCU level, but the model may have different α and β values for different cases. Inaddition, different picture level also has different model parameters ifhierarchical bit allocation is applied. For instance, if GOP size is equal to4, there exists three picture levels; and the three picture levels may havetheir different pairs of α and β values. At last, different LCUsalso have different α and β values; however, it is assumedthat collocated LCUs in different pictures but belong to the same picture levelmay share the same parameters α and β. The initial values of α and β used in (10) are 3.2003 and −1.367respectively, (初始值,之后会随着编码更新)obtained fromexperience and observation. It should be noticed that the initial values of α and β are not critical, as they willkeep updating with the encoding.

The QP value can be determined by multiple-QPoptimization, which may result in the best performance but increase theencoding complexity significantly. Instead, we use the followingequation to determine the QP value according to the λ value, asproposed in [2] and [3].

(通过λ获得QP参数来调节)

To keep the quality consistency, the λ value and thedetermined QP value will be clipped in a narrow range.

For picture level, the estimated λ is guaranteedthat

For picture level, the QP is guaranteed that

For LCU level, the estimatedλ is guaranteedthat

For LCU level, the QP is guaranteed that

After encoding one LCU or one picture, we use thereal encoded bpp (bppreal ) and realused λ value (λreal) to update the values of α and β of the model. In a picture, each LCU hasits own λ value, and we need to use theaverage value. It should be noticed that when referring to the average valuesin the rest of this document, it means arithmetic mean value for QP, while itmeans geometric mean value for λ The α and β are updated by (11) to (13)(更新α and β. In our implementation, δα and δ β are set to be 0.1 and 0.05,respectively.

                      (11)

          (12)

   (13)

It should be noticed that, for some special case,such as the actual encoding bpp is too small (e.g. skip modefor a LCU or too many skip mode for a picture), the updating process isperformed as

No matter which method is used to update α and β, the final values are clipped ina predetermined range. α is clipped into [0.05, 20] and β is clipped into [−3.0,−0.1].

0 0