Method for optimizing two-pass coding
AssigneeUniversity of Electronic Science and Technology of China
InventorsCe Zhu, Hongwei Guo, Yuyang Liu, Mao Ye
Life of this patent
Estimating the term…
Abstract
A method for optimizing a second coding is provided. The method includes: Setting a quantization parameter of a start frame of a video sequence according to a range of an input quantization parameter QP0 of a coder; performing first coding with a simplified method, and calculating a frame-level temporal impact factor ki of a current frame and a block-level temporal impact factor kB,j of all 16×16 pixel blocks in the current frame; restoring reference list information of the coder after the first coding is completed, and then determining whether a scene is switched; and performing the second coding by setting quantization parameters with different strategies according to whether the scene is switched.
Claims1
A method for optimizing a two-pass coding, comprising the following steps:
- S1:
- setting a start frame of a video sequence as a frame I with a level set to Level 0, wherein the frame I is used as a separate Group of Pictures (GOP);
- optimizing the start frame, wherein the start frame is the frame I, setting a quantization parameter QPI of the frame I according to a range of an input quantization parameter QP0 of a coder:
- Q
-
- P
- I
- =
- {
- Q
-
- P
- 0
- -
- 4
- ,
- QP
- 0
- >
- 34
- Q
-
- P
- 0
- -
- 3
- ,
- 29
- <
- Q
-
- P
- 0
- ≤
- 34
- Q
-
- P
- 0
- -
- 2
-
- ,
- 24
- <
- QP
- 0
- ≤
- 29
- ;
- Q
-
- P
- 0
- -
- 1
- ,
- 19
- <
- Q
-
- P
- 0
- ≤
- 24
- Q
-
- P
- 0
- ,
- Q
-
- P
- 0
- ≤
- 19
- S2:
- reading in a frame to be coded of the GOP by the coder;
- S3:
- a first coding:
- performing the first coding on a current frame by using a default quantization parameter QPHM,i set by an High efficiency video coding (HEVC), and obtaining a frame-level temporal impact factor ki of the current frame and a block-level temporal impact factor kB,j of 16×16 pixel blocks in the current frame:
- k
- i
- =
- D
- i
- D
- i
- MCP
- ;
- k
- B
- ,
- j
- =
- D
- B
- ,
- j
- D
- B
- ,
- j
- MCP
- ;
- wherein Di and DiMCP are respectively a coding distortion and a motion compensation prediction error of the current frame;
- and DB,j and DB,jMCP are respectively a coding distortion and a motion compensation prediction error of a jth 16×16 pixel blocks in the current frame;
- S4:
- restoring reference list information of the coder after the first coding is completed, wherein the first coding does not output a code stream of the current frame or store a reconstructed image;
- after the first coding, resetting a linked image list in the coder to a state before the current frame is coded, comprising restoring a reference frame identifier in the linked image list;
- S5:
- determining whether a scene is switched, if the scene is switched, performing step S6, if the scene is not switched, performing step S7;
- a determination method is:
- if pi>4p and pi>10, a scene switching occurs in the current frame, wherein pi is an average motion compensation prediction absolute error of the current frame, and p is an a mean value of the average motion compensation prediction absolute error of previous six frames;
- S6:
- setting a quantization parameter of the current frame as QPi=QP0, then performing the two-pass coding, and outputting the code stream and storing the reconstructed image in a default way of the coder, entering step S8;
- S7:
- setting the quantization parameter of the current frame as
- Q
-
- P
- i
- =
- {
- QP
- HM
- ,
- i
- +
- Round
-
-
- (
- 10
- ×
- k
- i
- -
- 5
- )
- ,
- k
- i
- >
- 0.75
- QP
- HM
- ,
- i
- ,
-
- else
- ,
- wherein QPHM,i is the quantization parameter of the current frame set in an original coder, and Round(⋅) is a rounding operator;
- after a frame-level Lagrangian multiplier λp is calculated through QPi, obtaining a Lagrangian multiplier λn and a quantization parameter QPn for coding each Coding tree unit (CTU) of the CTUs in the current frame by the following formulas:
- w
- n
- =
- 1
- M
-
- ∑
- j
- =
- 0
- M
-
- (
- 1
- +
- k
- B
- ,
- j
- )
- ;
- w
- ¯
- =
- 1
- N
-
- ∑
- n
- =
- 1
- N
-
- w
- n
- ;
- W
- n
- =
- W
- n
- w
- ¯
- ;
- λ
- n
- =
- λ
- P
- W
- n
- ;
- Q
-
- P
- n
- =
- 4.2005
- ×
- ln
-
-
- (
- λ
- n
- )
- +
- 1
-
- 3
-
- .7122
- ;
- wherein M is a number of the 16×16 pixel blocks comprised in an nth CTU of the CTUs, N is a number of the CTUs in a coded frame, wn, w and Wn are intermediate variables;
- coding the each CTU in the current frame by using the Lagrangian multiplier λn and the quantization parameter QPn, and outputting the code stream and storing the reconstructed image in the default way of the coder;
- S8:
- determining whether the coded frame is a last frame of the video sequence, if the coded frame is the last frame of the video sequence, then ending the two-pass coding;
- if the coded frame is not the last frame of the video sequence, continuing to determine whether the coded frame is the last frame in a current GOP, if the coded frame is the last frame in the current GOP, then performing step S2, if the coded frame is not the last frame in the current GOP, performing step S3.
Dependencies are inferred from the claim text.