Template matching-based motion refinement in video coding
Methods and apparatuses are provided for motion template-matching-based motion refinement. An exemplary method includes: dividing a target coding block into a plurality of subblocks; determining a first plurality of templates associated with the plurality of subblocks; determining a plurality of reference templates based on the first plurality of templates; performing motion compensation to the target coding block based on an affine merge candidate; and refining the motion compensation by matching the first plurality of templates and the plurality of reference templates.
1 . A method of encoding video content, the method comprising:
dividing a target coding block into a plurality of subblocks;
determining a plurality of sub-templates based on the plurality of subblocks; and
refining motion vectors of the plurality of subblocks based on the plurality of sub-templates, wherein refining the motion vectors of the plurality of subblocks comprises:
in response to the target coding block being a bi-predicted block, determining refined motion vectors of the plurality of subblocks associated with a first reference picture list, and determining, based on the determined refined motion vectors associated with the first reference picture list, motion vectors of the plurality of subblocks associated with a second reference picture list.
2 . The method according to claim 1 , wherein refining the motion vectors of the plurality of subblocks comprises matching the plurality of sub-templates to a template of the target coding block.
3 . The method according to claim 1 , wherein determining the plurality of sub-templates comprises:
determining a plurality of motion vectors associated with the plurality of sub-blocks respectively; and
determining the plurality of sub-templates based on the determined plurality of motion vectors.
4 . The method according to claim 1 , wherein determining the plurality of sub-templates comprises:
determining a plurality of motion vectors by invoking an affine model; and
determining the plurality of sub-templates based on the determined plurality of motion vectors.
5 . The method according to claim 1 , wherein the plurality of subblocks comprises left boundary subblocks and top boundary subblocks of the target coding block, and determining the plurality of sub-templates comprises:
determining a plurality of motion vectors associated with at least one of the left boundary subblocks or top boundary subblocks; and
determining the plurality of sub-templates based on the determined plurality of motion vectors.
6 . The method according to claim 1 , wherein refining the motion vectors of the plurality of subblocks further comprises:
refining at least one of a base motion vector of an affine model or a non-translation parameter of the affine model by matching the plurality of sub-templates to a template of the target coding block; and
deriving the refined motion vectors of the plurality of subblocks based on the refined base motion vector of the affine model or the refined non-translation parameter of the affine model.
7 . The method according to claim 1 , wherein refining the motion vectors of the plurality of subblocks further comprises:
refining a control point motion vector (CPMV) by matching the plurality of sub-templates to a template of the target coding block; and
deriving the refined motion vectors of the plurality of subblocks based on the refined CPMV.
8 . The method according to claim 1 , wherein refining the motion vectors of the plurality of subblocks further comprises:
determining a motion vector offset by matching the plurality of sub-templates to a template of the target coding block; and
refining the motion vectors of the plurality of subblocks based on the motion vector offset.
9 . The method according to claim 1 , wherein refining the motion vectors of the plurality of subblocks comprises:
determining template matching costs at a plurality of search positions based on differences between the plurality of sub-templates and a template of the target coding block; and
refining the motion vectors based on a search position with a minimum template matching cost.
10 . The method according to claim 1 , wherein the motion vectors of the plurality of subblocks comprises a first set of motion vectors associated with a reference picture list 0 and a second set of motion vectors associated with a reference picture list 1, wherein the method further comprises:
if the first set of motion vectors producing a larger template matching cost than the second set of motion vectors, refining the first set of motion vectors and refining, based on the refined first set of motion vectors, the second set of motion vectors; or
if the first set of motion vectors producing a smaller template matching cost than the second set of motion vectors, refining the second set of motion vectors and refining, based on the refined second set of motion vectors, the first set of motion vectors.
11 . A method of decoding a bitstream associated with video content, the method comprising:
decoding the bitstream to reconstruct a target coding block, wherein the target coding block is divided into a plurality of subblocks;
determining a plurality of sub-templates based on the plurality of subblocks; and
refining motion vectors of the plurality of subblocks based on the plurality of sub-templates, wherein refining the motion vectors of the plurality of subblocks comprises:
in response to the target coding block being a bi-predicted block, determining refined motion vectors of the plurality of subblocks associated with a first reference picture list, and determining, based on the determined refined motion vectors associated with the first reference picture list, motion vectors of the plurality of subblocks associated with a second reference picture list.
12 . The method according to claim 11 , wherein refining the motion vectors of the plurality of subblocks comprises matching the plurality of sub-templates to a template of the target coding block.
13 . The method according to claim 11 , wherein determining the plurality of sub-templates comprises:
determining a plurality of motion vectors associated with the plurality of sub-blocks respectively; and
determining the plurality of sub-templates based on the determined plurality of motion vectors.
14 . The method according to claim 11 , wherein determining the plurality of sub-templates comprises:
determining a plurality of motion vectors by invoking an affine model; and
determining the plurality of sub-templates based on the determined plurality of motion vectors.
15 . The method according to claim 11 , wherein the plurality of subblocks comprises left boundary subblocks and top boundary subblocks of the target coding block, and determining the plurality of sub-templates comprises:
determining a plurality of motion vectors associated with at least one of the left boundary subblocks or top boundary subblocks; and
determining the plurality of sub-templates based on the determined plurality of motion vectors.
16 . The method according to claim 11 , wherein refining the motion vectors of the plurality of subblocks further comprises:
refining at least one of a base motion vector of an affine model or a non-translation parameter of the affine model by matching the plurality of sub-templates to a template of the target coding block; and
deriving the refined motion vectors of the plurality of subblocks based on the refined base motion vector of the affine model or the refined non-translation parameter of the affine model.
17 . The method according to claim 11 , wherein refining the motion vectors of the plurality of subblocks further comprises:
refining a control point motion vector (CPMV) by matching the plurality of sub-templates to a template of the target coding block; and
deriving the refined motion vectors of the plurality of subblocks based on the refined CPMV.
18 . The method according to claim 11 , wherein refining the motion vectors of the plurality of subblocks further comprises:
determining a motion vector offset by matching the plurality of sub-templates to a template of the target coding block; and
refining the motion vectors of the plurality of subblocks based on the motion vector offset.
19 . A method of storing a bitstream associated with video content, the method comprising:
dividing a target coding block into a plurality of subblocks;
determining a plurality of sub-templates based on the plurality of subblocks;
refining motion vectors of the plurality of subblocks based on the plurality of sub-templates, wherein refining the motion vectors of the plurality of subblocks comprises:
in response to the target coding block being a bi-predicted block, determining refined motion vectors of the plurality of subblocks associated with a first reference picture list, and determining, based on the determined refined motion vectors associated with the first reference picture list, motion vectors of the plurality of subblocks associated with a second reference picture list;
generating the bitstream based on the refined motion vectors; and
storing the bitstream in a non-transitory computer-readable storage medium.