P frame-based multi-hypothesis motion compensation method
10298950 ยท 2019-05-21
Assignee
Inventors
- Ronggang Wang (Shenzhen, CN)
- Lei Chen (Shenzhen, CN)
- Zhenyu WANG (Shenzhen, CN)
- Siwei MA (Shenzhen, CN)
- Wen Gao (Shenzhen, CN)
- Tiejun Huang (Shenzhen, CN)
- Wenmin Wang (Shenzhen, CN)
- Shengfu Dong (Shenzhen, CN)
Cpc classification
H04N19/91
ELECTRICITY
H04N19/159
ELECTRICITY
H04N19/533
ELECTRICITY
H04N19/56
ELECTRICITY
H04N19/157
ELECTRICITY
H04N19/55
ELECTRICITY
H04N19/557
ELECTRICITY
International classification
H04N19/557
ELECTRICITY
H04N19/55
ELECTRICITY
H04N19/56
ELECTRICITY
H04N19/91
ELECTRICITY
Abstract
A P frame-based multi-hypothesis motion compensation method includes: taking an encoded image block adjacent to a current image block as a reference image block and obtaining a first motion vector of the current image block by using a motion vector of the reference image block, the first motion vector pointing to a first prediction block; taking the first motion vector as a reference value and performing joint motion estimation on the current image block to obtain a second motion vector of the current image block, the second motion vector pointing to a second prediction block; and performing weighted averaging on the first prediction block and the second prediction block to obtain a final prediction block of the current image block. The method increases the accuracy of the obtained prediction block of the current image block without increasing the code rate.
Claims
1. A P frame-based multi-hypothesis motion compensation method, comprising: taking an encoded image block adjacent to a current image block as a reference image block and obtaining a first motion vector of the current image block by using a motion vector of the reference image block, the first motion vector pointing to a first prediction block; taking the first motion vector as a reference value and performing joint motion estimation on the current image block to obtain a second motion vector of the current image block, the second motion vector pointing to a second prediction block; and performing weighted averaging on the first prediction block and the second prediction block to obtain a final prediction block of the current image block; wherein: three image blocks of the encoded image block adjacent to the current image block are taken as reference image blocks; and the first motion vector of the current image block is obtained by using a motion vector of the reference image block as follows: if only one reference image block is estimated to have a motion vector among the three reference image blocks, the motion vector is taken as a first motion vector of the current image block; otherwise, the following steps continue to be performed: if, among the three reference image blocks, the horizontal component of the motion vector of one reference image block and the horizontal components of the motion vectors of the other two reference image blocks are estimated to be in opposite directions, it takes the mean of the horizontal components of the motion vectors of the other two reference image blocks as a horizontal component of a first motion vector of the current image block; if, among the three reference image blocks, the vertical component of the motion vector of one reference image block and the vertical components of the motion vectors of the other two reference image blocks are estimated to be in opposite directions, it takes the mean of the vertical components of the motion vectors of the other two reference image blocks as a vertical component of a first motion vector of the current image block; otherwise, the following steps continue to be performed: it calculates the horizontal distance between any two reference image blocks, and takes the mean of the horizontal components of the motion vectors of the two reference image blocks with the shortest distance as a horizontal component of a first motion vector of the current image block; it calculates the vertical distance between any two reference image blocks, and takes the mean of the vertical components of the motion vectors of the two reference image blocks with the shortest distance as a vertical component of a first motion vector of the current image block.
2. The method of claim 1, wherein the weighted sum of the first prediction block and the second prediction block is 1 when the final prediction block of the current image block is obtained by performing weighted averaging on the first prediction block and the second prediction block.
3. The method of claim 2, wherein both weights of the first prediction block and the second prediction block are .
4. The method of claim 1, wherein after the final prediction block of the current image block is obtained, it also adds the residual information of the current image block and the final prediction block and the second motion vector into the encoding code rate of the current image block.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) The invention is described hereinbelow with reference to the accompanying drawings, in which:
(2)
(3)
(4)
(5)
(6)
(7)
(8)
DETAILED DESCRIPTION OF THE EMBODIMENTS
(9) Embodiments of the invention provide a P frame-based multi-hypothesis motion compensation method which is used in the technical field of video encoding. The inventive concept of the invention puts forward a P frame-based multi-hypothesis motion compensation method by taking both advantages and disadvantages of B frame and P frame motion compensation methods into account. The method takes advantage of not only the correlation of time domain between video frames but also the correlation of space domain between video frames to make predication blocks more accurate. However, it only needs to introduce a motion vector to the code rate without increasing the code rate.
(10) Usually, every frame image is divided into macroblocks in video encoding. Every macroblock has a fixed size. Every image block of a frame image is processed from the first image block on the upper-left side in a sequence from left to right, from top to bottom. Please refer to
(11) If the image block P is the current image block, in some embodiments, it calculates the first motion vector of the current image block by taking the motion vector of the reference image block as a reference value while making motion compensation to the current image block P. Since every image block of a frame image is highly similar to the encoded image blocks adjacent to it, generally, the reference image blocks adopt encoded image blocks adjacent to the current image block. As shown in
(12) In some embodiments, the upper, upper-right and left image blocks adjacent to the current image block can also be chosen as reference image blocks in choosing reference image blocks. For example, as shown in
(13) In some embodiments, the image blocks may be further divided into sub-image blocks while the image blocks are encoded. For example, the 1616 pixel image blocks are further divided into 44 pixel sub-image blocks. Please refer to
(14) In the embodiment, when the first motion vector of the current image block is obtained, the invention is explained by an example which takes encoded sub-image blocks adjacent to the current image block as reference image blocks. In order to make it easy to understand the invention, in the embodiment, the encoded sub-image blocks adjacent to the current image block are collectively called the encoded image blocks adjacent to the current image block; as shown in
(15) Please refer to
(16) The invention puts forward improvements in motion estimation and motion compensation. In terms of motion estimation, the derivation of the first motion vector MVL 1 takes advantage of the motion vector information of the encoded image blocks adjacent to the current image block; the second motion vector MVL 2 is searched and obtained by referring to the joint motion estimation mode of the MVL 1. In terms of motion compensation, the final prediction block is obtained by performing weighted averaging on the first prediction block and the second prediction block pointed by the MVL 1 and the MVL 2 respectively. In the embodiment, only a motion vector (MVL 2) and the residual information of the current image block and the final prediction block need to be transmitted in performing entropy encoding.
(17) Please refer to
(18) Step 10: taking an encoded image block adjacent to a current image block as a reference image block and obtaining a first motion vector MVL 1 of the current image block by using a motion vector of the reference image block, the first motion vector MVL 1 pointing to a first prediction block PL 1.
(19) Step 20: taking the first motion vector MVL 1 as a reference value and performing joint motion estimation on the current image block to obtain a second motion vector MVL 2 of the current image block, the second motion vector MVL 2 pointing to a second prediction block PL 2.
(20) Step 30: performing weighted averaging on the first prediction block PL 1 and the second prediction block PL 2 to obtain a final prediction block PL of the current image block.
(21) In the Step 10, since the reference image blocks in the embodiment choose the mode as shown in
(22) In the embodiment, the obtaining of the first motion vector MVL 1 is in relation to the encoded image blocks A, B, C and D (reference image blocks) adjacent to the current image block. The formula for obtaining the first motion vector is shown as the Formula (1):
MVL1=f(MVA,MVB,MVC,MVD)(1),
in which, MVA, MVB, MVC and MVD represent motion vectors of the four reference image blocks and f is a function concerning the four motion vectors.
(23) Please refer to
(24) Step 101: estimating whether there is only one reference image block having a motion vector among the three reference image blocks A, B and C. If there is a motion vector, the reference image block is valid and it goes to the Step 102. If there isn't a motion vector, the reference image block is invalid and it goes to the Step 103. When the reference image block C is invalid, the reference image block D is chosen to replace the reference image block C.
(25) Step 102: taking the motion vector of the valid reference image block as the first motion vector MVL 1 of the current image block.
(26) Step 103: estimating whether the direction of the horizontal/vertical component of the motion vector of one reference image block is opposite to the direction of the horizontal/vertical components of the motion vectors of the other two reference image blocks among the three reference image blocks A, B and C. If they are opposite, it goes to the Step 104. Otherwise, it goes to the Step 105.
(27) Step 104: taking the mean of the horizontal components of the motion vectors of two reference image blocks with the same direction as the horizontal component of the first motion vector MVL 1 of the current image block.
(28) The Steps 103 and 104 can be represented as follows. The horizontal components of the reference image blocks A, B and C are recorded as MVAx, MVBx and MVCx. The vertical components of the reference image blocks A, B and C are recorded as MVAy, MVBy and MVCy. The horizontal and vertical components of the first motion vector MVL 1 are recorded as MVL1x and MVL1y. Then:
(29) if MVAx<0, MVBx>0 and MVCx>0, or MVAx>0, MVBx<0 and MVCx<0, MVL1x=(MVBx+MVCx)/2;
(30) if MVBx<0, MVAx>0 and MVCx>0, or MVBx>0, MVAx<0 and MVCx<0, MVL1x=(MVAx+MVCx)/2;
(31) if MVCx<0, MVAx>0 and MVBx>0, or MVCx>0, MVAx<0 and MVBx<0, MVL1x=(MVAx+MVBx)/2;
(32) if MVAy<0, MVBy>0 and MVCy>0, or MVAy>0, MVBy<0 and MVCy<0, MVL1y=(MVBy+MVCy)/2;
(33) if MVBy<0, MVAy>0 and MVCy>0, or MVBy>0, MVAy<0 and MVCy<0, MVL1y=(MVAy+MVCy)/2; and
(34) if MVCy<0, MVAy>0 and MVBy>0, or MVCy>0, MVAy<0 and MVBy<0, MVL1y=(MVAy+MVBy)/2.
(35) Step 105: calculating the horizontal/vertical distances between any two of the three reference image blocks. The distances are represented as follows. The horizontal/vertical distances between A and B, between B and C, and between A and C are respectively recorded as ABSVABx, ABSVBCx and ABSVCAx/ABSVABy, ABSVBCy and ABSVCAy, that is:
ABSVABx=|MVAxMVBx|,ABSVBCx=|MVBxMVCx|,
ABSVCAx=|MVCxMVAx|,ABSVABy=|MVAyMVBy|,
ABSVBCy=|MVByMVCy|,ABSVCAy=|MVCyMVAy|.
(36) Step 106: taking the mean of the horizontal/vertical components of the motion vectors of two reference image blocks with a minimum distance as the horizontal/vertical components of the first motion vector MVL 1 of the current image block, that is:
(37) if ABSVABx<ABSVBCx and ABSVABx<ABSVCAx, MVL1x=(MVAx+MVBx)/2;
(38) if ABSVBCx<ABSVABx and ABSVBCx<ABSVCAx, MVL1x=(MVBx+MVCx)/2;
(39) if ABSVCAx<ABSVABx and ABSVCAx<ABSVBCx, MVL1x=(MVAx+MVCx)/2;
(40) if ABSVABy<ABSVBCy and ABSVABy<ABSVCAy, MVL1y=(MVAy+MVBy)/2;
(41) if ABSVBCy<ABSVABy and ABSVBCy<ABSVCAy, MVL1y=(MVBy+MVCy)/2; and
(42) if ABSVCAy<ABSVABy and ABSVCAy<ABSVBCy, MVL1y=(MVAy+MVCy)/2.
(43) The second motion vector MVL 2 takes the first motion vector MVL 1 as a reference value and is derived by joint motion estimation. The specific derivation formula is shown as the Formula (2):
MVL2=f(MVL1)(2),
in which, f is a function concerning the first motion vector MVL 1 for joint motion estimation.
(44) In the embodiment, the estimation process of the joint motion estimation used by the second motion vector MVL 2 is the same as the regular motion estimation process (for example, the regular B frame motion estimation process). Therefore, it is unnecessary to go into details. Since the first motion vector MVL 1 is consulted when the second motion vector MVL 2 is derived by joint motion estimation, the motion vector with a minimum Lagrange cost function shown in the Formula (3) within the search range is the second motion vector MVL 2 when the Lagrange cost functions are evaluated:
J(sad,MVL2)=Dsad(S,MVL2,MVL1)+sad*R(MVL2MVL2pred)(3),
in which MVL 2pred represents the prediction value of MVL 2, R (MVL 2MVL 2pred) represents the number of bits of the encoded motion vector residual, sad represents a weight coefficient of R (MVL 2MVL 2pred), and Dsad (S, MVL 2, MVL 1) represents a residual of the current image block S and the prediction block which can be obtained by the Formula (4) as follows:
(45)
in which, x, y represents the corresponding coordinate position of a pixel of the current image block S in the current encoding frame; MVL1x and MVL1y/MVL 2x and MVL 2y separately represent the horizontal and vertical components of MVL 1 and MVL 2; and Sref represents a reference frame.
(46) Please refer to
(47) In the embodiment, after the final prediction block of the current image block is obtained, the method also comprises: adding the residual information of the current image block and the final prediction block and the second motion vector MVL 2 into the encoding code rate of the current image block. Since the code rate only comprises one motion vector MVL 2, the embodiment provides a P frame-based multi-hypothesis motion compensation method which can improve the accuracy of P frame prediction blocks on the premise that the code rate isn't increased.
(48) Please refer to
(49) In a specific encoding process, the multi-hypothesis motion compensation method set forth in the embodiments of the invention can be independently used to encode P frames and can also be added into the mode of encoding P frames as a new encoding mode. Through a decision-making process on modes, finally, an encoding mode with a minimum encoding cost is chosen to encode P frames.
(50) Those skilled in the art can understand that all or part of the steps in the embodiments can be completed by using a program to command relevant hardware. The program can be stored in a readable memory medium of a computer. The memory medium may be read-only memories, random access memories, disks or optical disks.
(51) The above content further explains the invention in detail with embodiments. The embodiments of the invention are not limited to these explanations. On the premise of adhering to the inventive concept of the invention, those skilled in the art can also make a plurality of simple deductions and replacements.