# US 2021/0084329 A1 · Video codec using template matching prediction

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0084329 A1
- Document ID: US20210084329A1
- Status: Published application
- Kind: A1
- Application number: 17/107,043
- Filed: 2020-11-30
- Published: 2021-03-18
- Earliest claimed: 2018-06-01
- Assignees: Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- Applicants: Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- Inventors: Gayathri VENUGOPAL; Detlev MARPE; Thomas WIEGAND
- Web page: https://patentgrep.com/patent/US20210084329A1

## CPC

- H04N 19/57: Motion estimation characterised by a search window with variable size or shape
- H04N 19/105: Selection of the reference unit for prediction within a chosen coding or prediction mode, e.g. adaptive choice of position and number of pixels used for prediction
- H04N 19/119: Adaptive subdivision aspects, e.g. subdivision of a picture into rectangular or non-rectangular coding blocks
- H04N 19/134: characterised by the element, parameter or criterion affecting or controlling the adaptive coding
- H04N 19/172: the region being a picture, frame or field
- H04N 19/176: the region being a block, e.g. a macroblock
- H04N 19/1887: {the unit being a variable length codeword}
- H04N 19/46: Embedding additional information in the video signal during the compression process (H04N19/517, H04N19/68, H04N19/70 take precedence)
- H04N 19/51: Motion estimation or motion compensation
- H04N 19/52: by predictive encoding
- H04N 19/533: Motion estimation using multistep search, e.g. two-dimensional [2D]-log search or one-at-a-time search [OTS]
- H04N 19/56: Motion estimation with initialisation of the vector search, e.g. estimating a good candidate to initiate a search
- H04N: PICTORIAL COMMUNICATION, e.g. TELEVISION

## Abstract

Video decoder and/or video encoder, configured to determine a set of search area location candidates in a reference picture of a video; match the set of search area location candidates with a current template area adjacent to a current block of a current picture to obtain a best matching search area location candidate; select, out of a search area positioned in the reference picture at the best matching search area location candidate, a set of one or more predictor blocks by matching the current template area against the search area; and predictively decode/encode the current block from/into a data stream based on the set of one or more predictor blocks.

## Claims

### Claim 1

A video decoder, configured to
determine a set of search area location candidates in a reference picture of a video;
match the set of search area location candidates with a current template area adjacent to a current block of a current picture to acquire a best matching search area location candidate;
select, out of a search area positioned in the reference picture at the best matching search area location candidate or a predetermined search region within the search area, a set of one or more predictor blocks by matching the current template area against the search area or the predetermined search region within the search area; and
predictively decode the current block from a data stream based on the set of one or more predictor blocks.

### Claim 2 (depends on 1)

The video decoder of claim 1, configured to determine the set of search area location candidates using one or more motion vector predictors spatially and/or temporally predicted for the current block.

### Claim 3 (depends on 2)

The video decoder of claim 2, configured to round the one or more motion vector predictors to integer-sample positions in order to acquire the set of search area location candidates.

### Claim 4 (depends on 1)

The video decoder of claim 1, configured to check whether a predicted search area location in the reference picture, colocated to the current template area of the current block, is contained in the set of search area location candidates, if not, add the predicted search area location to the set of search area location candidates.

### Claim 5 (depends on 1)

The video decoder of claim 1, configured to, in matching the set of search area location candidates with a current template area,
for each of the set of search area location candidates, determining a similarity of the reference picture, at one or more positions, at and/or around, the respective search area location candidate, to the current template area,
appoint a search area location candidate the best matching search area location candidate for which the similarity is highest.

### Claim 6 (depends on 5)

The video decoder of claim 5, configured to determine the similarity by way of a sum of squared sample differences.

### Claim 7 (depends on 6)

The video decoder of claim 6, configured to
determine the similarity at the one or more positions by determining the sum of squared sample differences between the current template area and a coshaped candidate template area at the one or more positions in the reference picture,
wherein the best matching search area location candidate is associated with a least sum of squared sample differences out of a set of sum of squared differences.

### Claim 8 (depends on 1)

The video decoder of claim 1, wherein the search area is subdivided into search regions, and the video decoder is configured to
select the predetermined search region out of the search regions based on a signalization in the data stream; and
restrict the selection of the set of one or more predictor blocks, by matching the current template area against the search area, to the predetermined search region.

### Claim 9 (depends on 8)

The video decoder of claim 8,
wherein the search area is subdivided into the search regions so that a first search region is arranged in a middle of the search area and further search regions are in a manner surrounding the first search region, and
wherein the signalization comprises a search region index indexing the predetermined search region out of the search regions, and
wherein the video decoder is configured to decode the search region index from the data stream using a variable length code which assigns a first codeword of a shortest codeword length of the variable length code to the first search region.

### Claim 10 (depends on 9)

The video decoder of claim 9,
wherein the search area is subdivided into the search regions so that each of the further search regions extends circumferentially around the first region in an incomplete manner and
wherein the variable length code assigns second codewords to the further search regions which are of mutually equal length.

### Claim 11 (depends on 1)

The video decoder of claim 1, configured to decode the current block by determining a linear combination of the set of one or more predictor blocks.

### Claim 12 (depends on 1)

The video decoder of claim 1, configured to decode the current block based on an average, such as a normal average, a weighted average, or a combination of both, of the set of one or more predictor blocks, or based on an average of a subset out of the set of one or more predictor blocks with the subset excluding predictor blocks from the set of one or more predictor blocks whose reference template area matches with the current template area more than a predetermined threshold worse than that for a best matching predictor block in the set of one or more predictor blocks.

### Claim 13 (depends on 1)

The video decoder of claim 1, configured to, in predictively decoding the current block from the data stream based on the set of one or more predictor blocks,
sort and weight the set of one or more predictor blocks based on a similarity of a reference template area of each of the predictor blocks and the current template area, and
determine the current block Pfinal according to
P
final
=
Σ
i
=
1
n

P
i

w
il
Σ
i
=
1
n

w
il
,
wherein Pi is a predictor block of the sorted set of one or more predictor blocks P1 to Pn,
wherein wil is a weighing factor applied to the predictor block Pi,
wherein i is an index associated with a position of the predictor block Pi in the sorted set of one or more predictor blocks P1 to Pn,
wherein n is an index associated with a total number of predictor block Pi in the sorted set of one or more predictor blocks P1 to Pn, and
wherein 1 is an index associated with the number of predictor blocks Pi in the sorted set of one or more predictor blocks P1 to Pn, whose reference template area matches with the current template area more than a predetermined threshold,
wherein the predetermined threshold is based on the highest similarity.

### Claim 14 (depends on 1)

The video decoder of claim 1, configured to
read a merge flag from the data stream,
if the merge flag is in a first state, decode a motion vector from the data stream for the current block and predictively decode the current block using the motion vector by motion compensated prediction,
if the merge flag is in a second state, read a region-based template matching merge flag from the data stream,
if the region-based template matching merge flag is in a first state, read a merge index from the data stream, use the merge index to select a merge candidate out of a merge candidate list and predictively decode the current block using motion information associated with the selected merge candidate by motion compensated prediction,
if the region-based template matching merge flag is in a second state, perform the determination of the set of search area location candidates, the matching of the set of search area location candidates with the current template area, the selection of the set of one or more predictor blocks and the predictively decoding of the current block from the data stream based on the set of one or more predictor blocks.

### Claim 15

A method for video decoding, comprising
determining a set of search area location candidates in a reference picture of a video;
matching the set of search area location candidates with a current template area adjacent to a current block of a current picture to acquire a best matching search area location candidate;
selecting, out of a search area positioned in the reference picture at the best matching search area location candidate or a predetermined search region within the search area, a set of one or more predictor blocks by matching the current template area against the search area or the predetermined search region within the search area; and
predictively decoding the current block from a data stream based on the set of one or more predictor blocks.

### Claim 16

A non-transitory digital storage medium having a computer program stored thereon to perform the method for video decoding, comprising
determining a set of search area location candidates in a reference picture of a video;
matching the set of search area location candidates with a current template area adjacent to a current block of a current picture to acquire a best matching search area location candidate;
selecting, out of a search area positioned in the reference picture at the best matching search area location candidate or a predetermined search region within the search area, a set of one or more predictor blocks by matching the current template area against the search area or the predetermined search region within the search area; and
predictively decoding the current block from a data stream based on the set of one or more predictor blocks,
when said computer program is run by a computer.

### Claim 17

A video encoder, configured to
determine a set of search area location candidates in a reference picture of a video;
match the set of search area location candidates with a current template area adjacent to a current block of a current picture to acquire a best matching search area location candidate;
select, out of a search area positioned in the reference picture at the best matching search area location candidate or a predetermined search region within the search area, a set of one or more predictor blocks by matching the current template area against the search area or the predetermined search region within the search area; and
predictively encode the current block into a data stream based on the set of one or more predictor blocks.

### Claim 18 (depends on 17)

The video encoder of claim 17, configured to determine the set of search area location candidates using one or more motion vector predictors spatially and/or temporally predicted for the current block.

### Claim 19 (depends on 18)

The video encoder of claim 18, configured to round the one or more motion vector predictors to integer-sample positions in order to acquire the set of search area location candidates.

### Claim 20 (depends on 17)

The video encoder of claim 17, configured to check whether a predicted search area location in the reference picture, colocated to the current template area of the current block, is contained in the set of search area location candidates, if not, add the predicted search area location to the set of search area location candidates.

### Claim 21 (depends on 17)

The video encoder of claim 17, configured to, in matching the set of search area location candidates with a current template area,
for each of the set of search area location candidates, determining a similarity of the reference picture, at one or more positions, at and/or around, the respective search area location candidate, to the current template area,
appoint a search area location candidate the best matching search area location candidate for which the similarity is highest.

### Claim 22 (depends on 21)

The video encoder of claim 21, configured to determine the similarity by way of a sum of squared sample differences.

### Claim 23 (depends on 22)

The video encoder of claim 22, configured to determine the similarity at the one or more positions by determining differences between the current template area and a coshaped candidate template area at the one or more positions in the reference picture.

### Claim 24 (depends on 17)

The video encoder of claim 17, wherein the search area is subdivided into search regions, and the video encoder is configured to
select the predetermined search region out of the search regions and signal the selected search region into the data stream; and
restrict the selection of the set of one or more predictor blocks, by matching the current template area against the search area, to the predetermined search region.

### Claim 25 (depends on 24)

The video encoder of claim 24,
wherein the search area is subdivided into the search regions so that a first search region is arranged in a middle of the search area and further search regions are in a manner surrounding the first search region, and
wherein the signalization comprises a search region index indexing the predetermined search region out of the search regions, and
wherein the video encoder is configured to encode the search region index into the data stream using a variable length code which assigns a first codeword of a shortest codeword length of the variable length code to the first search region.

### Claim 26 (depends on 25)

The video encoder of claim 25,
wherein the search area is subdivided into the search regions so that each of the further search regions extends circumferentially around the first region in an incomplete manner and
wherein the variable length code assigns second codewords to the further search regions which are of mutually equal length.

### Claim 27 (depends on 17)

The video encoder of claim 17, configured to encode the current block by determining a linear combination of the set of one or more predictor blocks.

### Claim 28 (depends on 17)

The video encoder of claim 17, configured to encode the current block based on an average, such as a normal average, a weighted average, or a combination of both, of the set of one or more predictor blocks, or based on an average of a subset out of the set of one or more predictor blocks with the subset excluding predictor blocks from the set of one or more predictor blocks whose reference template area matches with the current template area more than a predetermined threshold worse than that for a best matching predictor block in the set of one or more predictor blocks.

### Claim 29 (depends on 17)

The video encoder of claim 17, configured to, in predictively encoding the current block into a data stream based on the set of one or more predictor blocks,
sort and weight the set of one or more predictor blocks based on a similarity of a reference template area of each of the predictor blocks and the current template area, and
determine the current block Pfinal according to
P
final
=
Σ
i
=
1
n

P
i

w
il
Σ
i
=
1
n

w
il
,
wherein Pi is a predictor block of the sorted set of one or more predictor blocks P1 to Pn,
wherein wil is a weighing factor applied to the predictor block Pi,
wherein i is an index associated with a position of the predictor block Pi in the sorted set of one or more predictor blocks P1 to Pn,
wherein n is an index associated with a total number of predictor block Pi in the sorted set of one or more predictor blocks P1 to Pn, and
wherein 1 is an index associated with the number of predictor blocks Pi in the sorted set of one or more predictor blocks P1 to Pn, whose reference template area matches with the current template area more than a predetermined threshold,
wherein the predetermined threshold is based on the highest similarity.

### Claim 30 (depends on 17)

The video encoder of claim 17, configured to
write a merge flag into the data stream
if the merge flag is in a first state, predictively encode the current block into the data stream using a motion vector by motion compensated prediction and encode the motion vector into the data stream for the current block,
if the merge flag is in a second state, write a region-based template matching merge flag into the data stream,
if the region-based template matching merge flag is in a first state, select a merge candidate out of a merge candidate list, predictively encode the current block using motion information associated with the selected merge candidate by motion compensated prediction and write a merge index into the data stream, associated with the merge candidate,
if the region-based template matching merge flag is in a second state, perform the determination of the set of search area location candidates, the matching of the set of search area location candidates with the current template area, the selection of the set of one or more predictor blocks and the predictively encoding of the current block into the data stream based on the set of one or more predictor blocks.

### Claim 31

A method for video encoding, comprising
determining a set of search area location candidates in a reference picture of a video;
matching the set of search area location candidates with a current template area adjacent to a current block of a current picture to acquire a best matching search area location candidate;
selecting, out of a search area positioned in the reference picture at the best matching search area location candidate or a predetermined search region within the search area, a set of one or more predictor blocks by matching the current template area against the search area or the predetermined search region within the search area; and
predictively encoding the current block into a data stream based on the set of one or more predictor blocks.

### Claim 32

A non-transitory digital storage medium having a computer program stored thereon to perform the method for video encoding, comprising
determining a set of search area location candidates in a reference picture of a video;
matching the set of search area location candidates with a current template area adjacent to a current block of a current picture to acquire a best matching search area location candidate;
selecting, out of a search area positioned in the reference picture at the best matching search area location candidate or a predetermined search region within the search area, a set of one or more predictor blocks by matching the current template area against the search area or the predetermined search region within the search area; and
predictively encoding the current block into a data stream based on the set of one or more predictor blocks,
when said computer program is run by a computer.

### Claim 33

Data stream acquired by a method for video encoding, comprising
determining a set of search area location candidates in a reference picture of a video;
matching the set of search area location candidates with a current template area adjacent to a current block of a current picture to acquire a best matching search area location candidate;
selecting, out of a search area positioned in the reference picture at the best matching search area location candidate or a predetermined search region within the search area, a set of one or more predictor blocks by matching the current template area against the search area or the predetermined search region within the search area; and
predictively encoding the current block into a data stream based on the set of one or more predictor blocks.
