Constrained template matching
Aspects of the disclosure provide a method and an apparatus for video decoding. The apparatus includes processing circuitry. The processing circuitry determines whether at least one sample in a first template of the current block is included in an intra coded block that is a spatial neighboring block of the current block. The first template includes one or more samples of top neighboring block(s) and left neighboring block(s) of the current block. If the at least one sample in the first template is included in the intra coded block and a template matching (TM) mode is applied to the current block, the at least one sample is excluded from the first template to generate a second template for the current block. The processing circuitry determines a motion vector (MV) of the current block based on the second template for the current block.
1. A method for video decoding in a video decoder, comprising:
decoding prediction information of a current block in a current picture from a video bitstream, the prediction information indicating a template matching (TM) mode for the current block;
determining whether at least one sample of a plurality of samples in a first template of the current block is included in an intra coded block that is a spatial neighboring block of the current block, the first template of the current block including one or more samples of (1) top neighboring blocks of the current block and ( 2 ) left neighboring blocks of the current block;
in response to (i) a determination that the at least one sample in the first template is included in the intra coded block and (ii) the TM mode being applied to the current block, excluding the at least one sample of the plurality of samples from the first template to generate a second template for the current block;
determining a motion vector (MV) of the current block based on the second template for the current block; and
reconstructing the current block based on the determined MV.
2. The method of claim 1 , wherein
the at least one sample in the first template of the current block is determined to be included in the intra coded block; and
the determining the MV includes determining the MV based on an initial MV of the current block without applying the TM mode.
3. The method of claim 1 , wherein
the first template of the current block includes an initial top template including samples of the top neighboring blocks and an initial left template including samples of the left neighboring blocks;
the at least one sample in the first template of the current block is determined to be included in the intra coded block;
in response to the left neighboring blocks of the current block not including the intra coded block, the determining the MV includes determining the MV of the current block using the TM mode that is based on an initial MV and the second template consisting of the initial left template; and
in response to the top neighboring blocks of the current block not including the intra coded block, the determining the MV includes determining the MV of the current block using the TM mode that is based on the initial MV and the second template consisting of the initial top template.
4. The method of claim 1 , wherein
the at least one sample in the first template of the current block is determined to be included in the intra coded block; and
the determining the MV includes determining the MV of the current block using the TM mode that is based on an initial MV and the second template of the current block.
5. The method of claim 4 , wherein
the method includes generating at least one interpolated sample by interpolation based on one or more samples in the second template, the at least one interpolated sample corresponding to the at least one sample in the first template that is included in the intra coded block; and
the second template of the current block further includes the at least one interpolated sample.
6. The method of claim 4 , wherein
reference samples in a reference template that corresponds to the second template of the current block are located at sub-pixel positions in a reference picture;
the method further includes generating an interpolated reference template in the reference picture using an interpolation with a filter having less than four taps on the reference template; and
the determining the MV includes determining the MV of the current block using the TM mode that is based on the initial MV, the second template of the current block, and the interpolated reference template.
7. The method of claim 6 , wherein
the reference template in the reference picture omits at least one reference sample in the reference picture that corresponds to the at least one sample in the first template of the current block that is included in the intra coded block;
the method includes generating a padded sample that corresponds to one of the omitted at least one reference sample in the reference picture by copying a closest reference sample in the reference picture; and
the generating the interpolated reference template includes generating the interpolated reference template in the reference picture by the interpolation based on the padded sample.
8. The method of claim 6 , wherein
the reference template in the reference picture omits at least one reference sample in the reference picture that corresponds to the at least one sample in the first template of the current block that is included in the intra coded block; and
the generating the interpolated reference template includes generating the interpolated reference template in the reference picture by the interpolation based on the omitted at least one reference sample in the reference picture.
9. The method of claim 4 , wherein
reference samples in an initial reference template that corresponds to the first template of the current block are located at sub-pixel positions in a reference picture; and
the method further includes:
generating an intermediate reference template in the reference picture using an interpolation on the initial reference template; and
generating a reference template that corresponds to the second template of the current block based on the intermediate reference template and a mask, a shape of the mask being determined based on the second template of the current block.
10. The method of claim 4 , wherein
the at least one sample in the first template included in the intra coded block includes (i) one or more left samples of samples of the left neighboring blocks or (ii) one or more top samples of samples of the top neighboring blocks,
in response to the at least one sample in the first template including the one or more left samples, the second template further includes one or more extended left samples that are adjacent to the samples of the left neighboring blocks included in the second template, the one or more extended left samples not being included in an intra coded block in the current picture, and
in response to the at least one sample in the first template including the one or more top samples, the second template further includes one or more extended top samples that are adjacent to the samples of the top neighboring blocks included in the second template, the one or more extended top samples not being included in an intra coded block in the current picture.
11. The method of claim 10 , wherein a number of samples in the second template is 150% of a number of samples in the first template.
12. The method of claim 10 , wherein a number of samples in the second template is 200% of a number of samples in the first template.
13. An apparatus for video decoding, comprising:
processing circuitry configured to:
decode prediction information of a current block in a current picture from a video bitstream, the prediction information indicating a template matching (TM) mode for the current block;
determine whether at least one sample of a plurality of samples in a first template of the current block is included in an intra coded block that is a spatial neighboring block of the current block, the first template of the current block including one or more samples of (1) top neighboring blocks of the current block and ( 2 ) left neighboring blocks of the current block;
in response to (i) a determination that the at least one sample in the first template is included in the intra coded block and (ii) the TM mode being applied to the current block, exclude the at least one sample of the plurality of samples from the first template to generate a second template for the current block;
determine a motion vector (MV) of the current block based on the second template for the current block; and
reconstruct the current block based on the determined MV.
14. The apparatus of claim 13 , wherein
the at least one sample in the first template of the current block is determined to be included in the intra coded block; and
the processing circuitry is configured to determine the MV based on an initial MV of the current block without applying the TM mode.
15. The apparatus of claim 13 , wherein
the first template of the current block includes an initial top template including samples of the top neighboring blocks and an initial left template including samples of the left neighboring blocks;
the at least one sample in the first template of the current block is determined to be included in the intra coded block;
in response to the left neighboring blocks of the current block not including the intra coded block, the processing circuitry is configured to determine the MV of the current block using the TM mode that is based on an initial MV and the second template consisting of the initial left template; and
in response to the top neighboring blocks of the current block not including the intra coded block, the processing circuitry is configured to determine the MV of the current block using the TM mode that is based on the initial MV and the second template consisting of the initial top template.
16. The apparatus of claim 13 , wherein
the at least one sample in the first template of the current block is determined to be included in the intra coded block; and
the processing circuitry is configured to determine the MV of the current block using the TM mode that is based on an initial MV and the second template of the current block.
17. The apparatus of claim 16 , wherein
the processing circuitry is configured to generate at least one interpolated sample by interpolation based on one or more samples in the second template, the at least one interpolated sample corresponding to the at least one sample in the first template that is included in the intra coded block; and
the second template of the current block further includes the at least one interpolated sample.
18. The apparatus of claim 16 , wherein
reference samples in a reference template that corresponds to the second template of the current block are located at sub-pixel positions in a reference picture; and
the processing circuitry is configured to:
generate an interpolated reference template in the reference picture using an interpolation with a filter having less than four taps on the reference template; and
determine the MV of the current block using the TM mode that is based on the initial MV, the second template of the current block, and the interpolated reference template.
19. The apparatus of claim 16 , wherein
the at least one sample in the first template included in the intra coded block includes (i) one or more left samples of samples of the left neighboring blocks or (ii) one or more top samples of samples of the top neighboring blocks,
in response to the at least one sample in the first template including the one or more left samples, the second template further includes one or more extended left samples that are adjacent to the samples of the left neighboring blocks included in the second template, the one or more extended left samples not being included in an intra coded block in the current picture, and
in response to the at least one sample in the first template including the one or more top samples, the second template further includes one or more extended top samples that are adjacent to the samples of the top neighboring blocks included in the second template, the one or more extended top samples not being included in an intra coded block in the current picture.
20. A non-transitory computer-readable storage medium storing a program executable by at least one processor to perform:
decoding prediction information of a current block in a current picture from a video bitstream, the prediction information indicating a template matching (TM) mode for the current block;
determining whether at least one sample of a plurality of samples in a first template of the current block is included in an intra coded block that is a spatial neighboring block of the current block, the first template of the current block including one or more samples of (1) top neighboring blocks of the current block and (2) left neighboring blocks of the current block;
in response to (i) a determination that the at least one sample in the first template is included in the intra coded block and (ii) the TM mode being applied to the current block, excluding the at least one sample of the plurality of samples from the first template to generate a second template for the current block;
determining a motion vector (MV) of the current block based on the second template for the current block; and
reconstructing the current block based on the determined MV.