1 / 23

H.264 Rate-Distortion Optimization and Rate Control

H.264 Rate-Distortion Optimization and Rate Control. MC Course, 2009 Ref: Siwei Ma, Wen Gao, and Yan Lu,

kevyn-lucas
Download Presentation

H.264 Rate-Distortion Optimization and Rate Control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. H.264 Rate-Distortion Optimization and Rate Control MC Course, 2009 Ref: Siwei Ma, Wen Gao, and Yan Lu, “Rate-Distortion Analysis for H.264/AVC Video Coding and its Application to Rate Control,”IEEE TRANSACTIONS ON CIRCUITS AND SYSTEMS FOR VIDEO TECHNOLOGY, VOL. 15, NO. 12, pp. 1533-1544, DECEMBER 2005.

  2. Rate-distortion Optimization • Minimize distortion D, subject to a constraint Rd, on the number of bits used Rd. min {D}, subject to R < Rd. • Rate-distortion optimized selection, given target rate • Minimize the distortion, subject to the target rate constraint • Dn(mn):distortion of the nthMB using mode mn • The optimal mode is such that each MB working at the same RD slope: • The optimal mode in each MB is such that the resulting RD slope is the same among different MBs. MC 2009

  3. H.264 Rate Control • H.264/AVC test model: Draft ISO/IEC 14 496-5:2002/PDAM6, ISO IEC TC JTC 1/SC29 N5821, 2003. • based on the R-D model in VM8 • Recommendation H.264 does not (at present) specify a rate control algorithm • Ma, Gao, and Lu: the quantization scheme in H.264/AVC has been significantly changed, which leads to the nonlinear relation between the quantization parameter and the true quantization stepsize. Therefore, it is highly desirable to develop a more efficient R-D model for the rate control in H.264/AVC encoder. MC 2009

  4. Hypothetical Reference Decoder • H.264 hypothetical reference decoder (HRD): guarantee that the buffers never overflow or underflow • rate allocation: allocate proper bits to each coding unit according to the buffer status • quantization parameter adjustment: how to adjust the encoder parameters to properly encode each unit with the allocated bits • Find the relation between the rate and the quantization parameter MC 2009

  5. The Relation between QSTEP and QP • In H.264/AVC, the relation between QSTEPandQPis QSTEP =2 (QP-4)/6. MC 2009

  6. The Relation between PSNR and the quantization parameterQP • The Relation between PSNR and the quantization parameterQP is where l and b are the constants. MC 2009

  7. The Relation between PSNR and the quantization parameterQP, Ma, Gao, and Lu • is the estimated number of coded bits of a macroblock • SADiis the SAD of a motion-compensated macroblock • t = I, P, B • The first item reflects the bits used to code the transform coefficients. • The second item is the bits used to code the header information of a macroblock. MC 2009

  8. Some Rate Control Models • TM5: R(QP) = X/QP, X is a constant • VM8: • TMN8: • MADiis the mean absolute difference of a residual macroblock • Xi:mode parameters • A, K, and C:constants • i2is the variance of residual coefficients in a macroblock. MC 2009

  9. MPEG-4 Scalable Rate Control • MPEG-4 Annex • based on VM8 • appropriate for a single video object (a rectangle VO that covers the entire frame) and a range of bit rates and spatial/temporal resolutions • target bit rate for a certain number of frames, (long delay of course) • Q: quantizer step size • S: is the mean absolute difference of a residual frame MC 2009

  10. SRC Algorithm • Rate control process • Calculate the target bit rate Ri, based on the number of frames, the number of available bits, the maximum acceptable buffer contents and the estimated complexity of frame i. • Compute the quantizer step size Q, (to be applied to the whole frame). Calculate S for the complete residual frame and solve (*) to find Q. • Encode the frame • Update the model parameters X1 and X2 based on the actual number of bits generated for frame i. • The MB level version of SRC (low delay) MC 2009

  11. TMN8 Algorithm • Rate control process • Measure i, the variance of residual coefficients in amacroblock. • Calculate QPi • Encode MBi • Update the model parameters K and C based on the actual number of bits generated for MBi. • TMN8 is effective at maintaining good visual quality with a small encoder output buffer, keeping coding delay to a minimum. MC 2009

  12. H.264 RDO and HRD • H.264: RDO and HRD closely related to rate control • RDO • MB modes: INTRA 44, INTRA 1616, INTER 1616, INTER 168, INTER 816, INTER 88, INTER 84, INTER 48, INTER 44, SKIP and DIRECT. • Lagrangian method: • Optimal mvs for inter (or intra) and optimal coding modes for blocks • Optimal bit allocation for mvs and residuals MC 2009

  13. H.264 R-D Optimization, Ma, Gao, and Lu For a block in an inter frame, the rate-constrained motion estimation is first done to find the optimal motion vector by minimizing s: the original video signal, c: the coded video signal Multiple-reference prediction MC 2009

  14. H.264 R-D Optimization, Ma, Gao, and Lu • Afterwards, the rate-constrained mode selection is performed to choose the optimal coding mode by minimizing • Langrage multipliers s have the following relation with QP, m:constant • With the different QP, the different motion vectors and modes might be selected. MC 2009

  15. H.264 Hypothetical Reference Decoder • Terminology • CPB: Coded Picture Buffer • b(n): the size in bits of picture n • tai (n): the time when the first bit of picture n enters the CPB, the initial arrival time of picture n • taf (n): the time when the last bit of picture n enters the CPB, the final arrival time of picture n, and • tr(n): is the time when the picture n is removed from the CPB R: the bit rate at which the CPB is filled. MC 2009

  16. H.264 Hypothetical Reference Decoder Packetization, and others One packet per frame this case tc: time of a clock tick : the earliest time when picture n can reach the buffer initial_CPB_removal_delay represents the delay between the time when the first bit of the coded data arrives in the CPB and the time when the first time removal of coded data from the CPB. MC 2009

  17. H.264 Hypothetical Reference Decoder • access unit: onecoded picture or slice data partition MC 2009

  18. H.264 Hypothetical Reference Decoder To ensure that the CPB does not overflow or underflow, Ln: the lower bound of rate This means that picture n must be in the buffer when it is removed from the buffer. MC 2009

  19. H.264 Hypothetical Reference Decoder R: the bit rate at which the CPB is filled. CPB should neither overflow nor underflow if Where be[t] and te[t] denote the bit equivalent of a time t and the time equivalent of a number of bits b, respectively, and Usually the bits allocated to a picture are clipped to [Ln, Un], where   1.0and   0.9. MC 2009

  20. Rate-control Algorithm, Ma, Gao, and Lu • Bit allocation: In this step, a target bit is allocated to each picture in a group of pictures (GOP) • Initialization for the current macroblock • where X0t is global complexity measure for a picture as defined in TM5, R0t is the coded bits of the picture, SAD0t is the average SAD of all macroblocks in the picture, BHead is the average header bits for a macroblock, including motion and mode information, and BCoeff is the bits used to code luminance and chrominance coefficients. TM5: R(QP) = X/QP QSTEP = 2 (QP-4)/6 MC 2009

  21. Rate-control Algorithm, Ma, Gao, and Lu (2) • First RDO-based coding mode selection • If the current macroblock is the first MB in the frame, QP is set to be the average quantization parameter of the previous frame QPprev; otherwise, we use • Second RDO-based coding mode selection • Calculate SADi’ in terms of the selected coding mode and then compute a new quantization parameter QP’ using SADi’ in the same way as Step 3. • Counter updating • R-D model parameter updating Mi: the number of remaining uncoded MBs Ti: the number of available bits for encoding the remaining uncoded MBs MC 2009

  22. Rate-control Algorithm, Ma, Gao, and Lu (3) • new R-D model: the relationship between the quantization parameter and the true quantization stepsize is no longer linear. • proposed a new rate-distortion (R-D) model by utilizing the true quantization stepsize and then develop an improved rate-control scheme for the H.264/AVC encoder based on this new R-D model. • The algorithm performs one-pass operation at frame level and a partial two-pass operation at the macroblock level. Since the second RDO-based coding model selection in Step 4 is a conditional operation, the percentage of such macroblocks can be controlled by parameter ; consequently, the computing complexity is controllable as well. MC 2009

  23. MC 2009

More Related