Early termination for optical flow refinement
It is provided a method of video coding implemented in a decoding device or an encoding device, the method comprising: obtaining initial motion vectors for a current block; obtaining first predictions for a sample value in the current block based on the initial motion vectors; calculating a first matching cost according to the first predictions; determining whether an optical flow refinement process should be performed or not, according to at least one preset condition, the at least one preset condition comprising a condition of whether the calculated first matching cost is equal to or larger than a threshold value; and performing an optical flow refinement process for obtaining a final inter prediction for the sample value in the current block, when it is determined that the optical flow refinement process should be performed.
1 . A method of video coding implemented in an encoding device, the method comprising:
obtaining a pair of initial motion vectors for a current block, wherein the current block is a sub-block;
obtaining two first prediction blocks for the current block based on the pair of initial motion vectors;
calculating a first matching cost according to the two first prediction blocks, wherein the first matching cost is a sum of absolute differences (SAD) between the two first prediction blocks;
obtaining a pair of refined motion vectors based on the pair of initial motion vectors;
obtaining two second prediction blocks for the current block according to the pair of refined motion vectors;
obtaining a second matching cost corresponding to the two second prediction blocks;
determining whether an optical flow refinement process is to be performed or not, according to at least one preset condition, the at least one preset condition comprising a condition of whether the second matching cost is less than a threshold;
performing an optical flow refinement process on the two second prediction blocks for obtaining a final prediction block for the current block, when it is determined that the optical flow refinement process is to be performed;
obtaining the final prediction block by a weighted sum of the two second prediction blocks when it is determined that the optical flow refinement process is not to be performed;
obtaining a residual block based on the current block and the final prediction block; and
encoding the residual block into a bitstream.
2 . The method of claim 1 , further comprising:
determining whether the current block is eligible to perform motion vector refinement (MVR);
if the current block is determined to be eligible to perform MVR, obtaining the pair of refined motion vectors based on the pair of initial motion vectors.
3 . The method of claim 1 , wherein the at least one preset condition further comprises the condition that whether the current block is allowed to be predicted by decoder-side motion vector refinement.
4 . The method of claim 1 , wherein it is determined that the optical flow refinement process is not to be performed, when it is determined that the second matching cost is less than a threshold and the current block is allowed to be predicted by decoder-side motion vector refinement.
5 . The method of claim 1 , wherein it is determined that the optical flow refinement process is to be performed, when it is determined that the second matching cost is not less than a threshold or the current block is not allowed to be predicted by decoder-side motion vector refinement.
6 . The method of claim 1 , wherein the two first prediction blocks for the current block are obtained based on a bilinear interpolation filter.
7 . The method of claim 1 , wherein the two second prediction blocks for the current block are obtained according to an 8-tap interpolation filter.
8 . The method of claim 1 , wherein a value of the threshold is obtained according to a size of the current block.
9 . An encoder comprising: a memory configured to store instructions; and
a processor coupled to the memory, wherein the instructions when executed cause the processor to be configured for:
obtaining a pair of initial motion vectors for a current block, wherein the current block is a sub-block;
obtaining two first prediction blocks for the current block based on the pair of initial motion vectors;
calculating a first matching cost according to the two first prediction blocks, wherein the first matching cost is a sum of absolute differences (SAD) between the two first prediction blocks;
obtaining a pair of refined motion vectors based on the pair of initial motion vectors;
obtaining two second prediction blocks for the current block according to the pair of refined motion vectors;
obtaining a second matching cost corresponding to the two second prediction blocks;
determining whether an optical flow refinement process is to be performed or not, according to at least one preset condition, the at least one preset condition comprising a condition of whether the second matching cost is less than a threshold;
performing an optical flow refinement process on the two second prediction blocks for obtaining a final prediction block for the current block, when it is determined that the optical flow refinement process is to be performed;
obtaining the final prediction block by a weighted sum of the two second prediction blocks when it is determined that the optical flow refinement process is not to be performed;
obtaining a residual block based on the current block and the final prediction block; and
encoding the residual block into a bitstream.
10 . The encoder of claim 9 , further comprising:
determining whether the current block is eligible to perform motion vector refinement (MVR);
if the current block is determined to be eligible to perform MVR, obtaining the pair of refined motion vectors based on the pair of initial motion vectors.
11 . The encoder of claim 9 , wherein the at least one preset condition further comprises the condition that whether the current block is allowed to be predicted by decoder-side motion vector refinement.
12 . The encoder of claim 9 , wherein it is determined that the optical flow refinement process is not to be performed, when it is determined that the second matching cost is less than a threshold and the current block is allowed to be predicted by decoder-side motion vector refinement.
13 . The encoder of claim 9 , wherein it is determined that the optical flow refinement process is to be performed, when it is determined that the second matching cost is not less than a threshold or the current block is not allowed to be predicted by decoder-side motion vector refinement.
14 . The encoder of claim 9 , wherein the two first prediction blocks for the current block are obtained based on a bilinear interpolation filter.
15 . The encoder of claim 9 , wherein the two second prediction blocks for the current block are obtained according to an 8-tap interpolation filter.
16 . The encoder of claim 9 , wherein a value of the threshold is obtained according to a size of the current block.
17 . A non-transitory computer readable storage medium storing instructions, wherein when the instructions are performed by one or more processors, the one or more processors are configured to perform:
obtaining a pair of initial motion vectors for a current block, wherein the current block is a sub-block;
obtaining two first prediction blocks for the current block based on the pair of initial motion vectors;
calculating a first matching cost according to the two first prediction blocks, wherein the first matching cost is a sum of absolute differences (SAD) between the two first prediction blocks;
obtaining a pair of refined motion vectors based on the pair of initial motion vectors;
obtaining two second prediction blocks for the current block according to the pair of refined motion vectors;
obtaining a second matching cost corresponding to the two second prediction blocks;
determining whether an optical flow refinement process is to be performed or not, according to at least one preset condition, the at least one preset condition comprising a condition of whether the second matching cost is less than a threshold;
performing an optical flow refinement process on the two second prediction blocks for obtaining a final prediction block for the current block, when it is determined that the optical flow refinement process is to be performed;
obtaining the final prediction block by a weighted sum of the two second prediction blocks when it is determined that the optical flow refinement process is not to be performed;
obtaining a residual block based on the current block and the final prediction block; and
encoding the residual block into the bitstream.
18 . The computer readable storage medium of claim 17 , wherein it is determined that the optical flow refinement process is to be performed, when it is determined that the second matching cost is not less than a threshold or the current block is not allowed to be predicted by decoder-side motion vector refinement.
19 . The computer readable storage medium of claim 17 , wherein the two first prediction blocks for the current block are obtained based on a bilinear interpolation filter.
20 . The computer readable storage medium of claim 17 , wherein the two second prediction blocks for the current block are obtained according to an 8-tap interpolation filter.