ENCODER, DECODER, ENCODING METHOD, AND DECODING METHOD
An encoder that encodes a video includes a processor and memory. Using the memory, the processor: derives a prediction error of an image included in the video, by subtracting a prediction image of the image from the image; determines a secondary transform basis based on a primary transform basis, the primary transform basis being a transform basis for a primary transform to be performed on the prediction error, the secondary transform basis being a transform basis for a secondary transform to be performed on a result of the primary transform; performs the primary transform on the prediction error using the primary transform basis; performs the secondary transform on a result of the primary transform using the secondary transform basis; performs quantization on a result of the secondary transform; and encodes a result of the quantization as data of the image.
1 . An encoder that encodes a video, the encoder comprising:
a processor; and
memory,
wherein using the memory, the processor:
derives a prediction error of an image included in the video, by subtracting a prediction image of the image from the image;
determines a secondary transform basis based on a primary transform basis, the primary transform basis being a transform basis for a primary transform to be performed on the prediction error, the secondary transform basis being a transform basis for a secondary transform to be performed on a result of the primary transform;
performs the primary transform on the prediction error using the primary transform basis;
performs the secondary transform on a result of the primary transform using the secondary transform basis;
performs quantization on a result of the secondary transform; and
encodes a result of the quantization as data of the image.
2 . The encoder according to claim 1 ,
wherein the processor determines the secondary transform basis based on the primary transform basis and a parameter encoded when the processor encodes the video.
3 . The encoder according to claim 2 ,
wherein the parameter indicates an intra prediction mode, and
the processor determines the secondary transform basis based on the primary transform basis and the intra prediction mode indicated by the parameter.
4 . The encoder according to claim 1 ,
wherein the processor:
determines the primary transform basis from among a plurality of primary transform basis candidates; and
determines the secondary transform basis from among at least one secondary transform basis candidate associated with a primary transform basis candidate determined as the primary transform basis among the plurality of primary transform basis candidates.
5 . The encoder according to claim 4 ,
wherein at least two of the plurality of primary transform basis candidates are associated with a common secondary transform basis candidate.
6 . The encoder according to claim 4 ,
wherein a total number of the at least one secondary transform basis candidate associated with the primary transform basis candidate depends on the primary transform basis candidate.
7 . The encoder according to claim 1 ,
wherein the secondary transform basis determined when the primary transform basis is a combination of a first transform basis for a vertical direction and a second transform basis for a horizontal direction is identical to the secondary transform basis determined when the primary transform basis is a combination of the second transform basis for the vertical direction and the first transform basis for the horizontal direction.
8 . The encoder according to claim 1 ,
wherein the secondary transform basis determined when the primary transform basis is a combination of a first transform basis for a vertical direction and a second transform basis for a horizontal direction is a transform basis obtained by transposing the secondary transform basis determined when the primary transform basis is a combination of the second transform basis for the vertical direction and the first transform basis for the horizontal direction.
9 . The encoder according to claim 1 ,
wherein when the secondary transform basis is a combination of a transform basis for a vertical direction and a transform basis for a horizontal direction, the transform basis for the vertical direction and the transform basis for the horizontal direction are identical.
10 . The encoder according to claim 1 ,
wherein when there is only one secondary transform basis candidate associated with a primary transform basis candidate determined as the primary transform basis, the processor avoids encoding information indicating the secondary transform basis determined.
11 . The encoder according to claim 1 ,
wherein when a total number of transform basis candidates for one of information indicating the primary transform basis and information indicating the secondary transform basis is limited to one, the processor encodes only the other of the information indicating the primary transform basis and the information indicating the secondary transform basis.
12 . The encoder according to claim 1 ,
wherein the secondary transform basis is a transform basis learned based on the primary transform basis.
13 . The encoder according to claim 1 ,
wherein when the secondary transform basis is a separable transform basis, the processor performs a separable transform as the secondary transform, and when the secondary transform basis is a non-separable transform basis, the processor performs a non-separable transform as the secondary transform.
14 . The encoder according to claim 1 ,
wherein the processor determines whether to perform the secondary transform, and the secondary transform basis when the secondary transform is performed, based on the primary transform basis.
15 . The encoder according to claim 1 ,
wherein each of the primary transform and the secondary transform is a separable transform or a non-separable transform, and
the processor:
(i) separates the primary transform into a plurality of directional primary transforms, and performs the primary transform by performing the plurality of directional primary transforms, or (ii) performs the primary transform without separating the primary transform into the plurality of directional primary transforms; and
(i) separates the secondary transform into a plurality of directional secondary transforms, and performs the secondary transform by performing the plurality of directional secondary transforms, or (ii) performs the secondary transform without separating the secondary transform into the plurality of directional secondary transforms.
16 . A decoder that decodes a video, the decoder comprising:
a processor; and
memory,
wherein using the memory, the processor:
decodes data of an image included in the video;
performs inverse quantization on the data;
determines an inverse secondary transform basis based on an inverse primary transform basis, the inverse primary transform basis being a transform basis for an inverse primary transform to be performed on a result of an inverse secondary transform, the inverse secondary transform basis being a transform basis for the inverse secondary transform to be performed on a result of the inverse quantization;
performs the inverse secondary transform on a result of the inverse quantization using the inverse secondary transform basis;
performs the inverse primary transform on a result of the inverse secondary transform using the inverse primary transform basis; and
derives the image by adding a result of the inverse primary transform as a prediction error of the image to a prediction image of the image.
17 . The decoder according to claim 16 ,
wherein the processor determines the inverse secondary transform basis based on the inverse primary transform basis and a parameter decoded when the processor decodes the video.
18 . The decoder according to claim 17 ,
wherein the parameter indicates an intra prediction mode, and
the processor determines the inverse secondary transform basis based on the inverse primary transform basis and the intra prediction mode indicated by the parameter.
19 . The decoder according to claim 16 ,
wherein the processor:
determines the inverse primary transform basis from among a plurality of inverse primary transform basis candidates; and
determines the inverse secondary transform basis from among at least one inverse secondary transform basis candidate associated with an inverse primary transform basis candidate determined as the inverse primary transform basis among the plurality of inverse primary transform basis candidates.
20 . The decoder according to claim 19 ,
wherein at least two of the plurality of inverse primary transform basis candidates are associated with a common inverse secondary transform basis candidate.
21 . The decoder according to claim 19 ,
wherein a total number of the at least one inverse secondary transform basis candidate associated with the inverse primary transform basis candidate depends on the inverse primary transform basis candidate.
22 . The decoder according to claim 16 ,
wherein the inverse secondary transform basis determined when the inverse primary transform basis is a combination of a first transform basis for a vertical direction and a second transform basis for a horizontal direction is identical to the inverse secondary transform basis determined when the inverse primary transform basis is a combination of the second transform basis for the vertical direction and the first transform basis for the horizontal direction.
23 . The decoder according to claim 16 ,
wherein the inverse secondary transform basis determined when the inverse primary transform basis is a combination of a first transform basis for a vertical direction and a second transform basis for a horizontal direction is a transform basis obtained by transposing the inverse secondary transform basis determined when the inverse primary transform basis is a combination of the second transform basis for the vertical direction and the first transform basis for the horizontal direction.
24 . The decoder according to claim 16 ,
wherein when the inverse secondary transform basis is a combination of a transform basis for a vertical direction and a transform basis for a horizontal direction, the transform basis for the vertical direction and the transform basis for the horizontal direction are identical.
25 . The decoder according to claim 16 ,
wherein when there is only one inverse secondary transform basis candidate associated with an inverse primary transform basis candidate determined as the inverse primary transform basis, the processor avoids decoding information indicating the inverse secondary transform basis determined.
26 . The decoder according to claim 16 ,
wherein when a total number of transform basis candidates for one of information indicating the inverse primary transform basis and information indicating the inverse secondary transform basis is limited to one, the processor decodes only the other of the information indicating the inverse primary transform basis and the information indicating the inverse secondary transform basis.
27 . The decoder according to claim 16 ,
wherein the inverse secondary transform basis is a transform basis learned based on the inverse primary transform basis.
28 . The decoder according to claim 16 ,
wherein when the inverse secondary transform basis is a separable inverse transform basis, the processor performs a separable inverse transform as the inverse secondary transform, and when the inverse secondary transform basis is a non-separable inverse transform basis, the processor performs a non-separable inverse transform as the inverse secondary transform.
29 . The decoder according to claim 16 ,
wherein the processor determines whether to perform the inverse secondary transform, and the inverse secondary transform basis when the inverse secondary transform is performed, based on the inverse primary transform basis.
30 . The decoder according to claim 16 ,
wherein each of the inverse primary transform and the inverse secondary transform is a separable inverse transform or a non-separable inverse transform, and
the processor:
(i) separates the inverse primary transform into a plurality of directional inverse primary transforms, and performs the inverse primary transform by performing the plurality of directional inverse primary transforms, or (ii) performs the inverse primary transform without separating the inverse primary transform into the plurality of directional inverse primary transforms; and
(i) separates the inverse secondary transform into a plurality of directional inverse secondary transforms, and performs the inverse secondary transform by performing the plurality of directional inverse secondary transforms, or (ii) performs the inverse secondary transform without separating the inverse secondary transform into the plurality of directional inverse secondary transforms.
31 . An encoding method of encoding a video, the encoding method comprising:
deriving a prediction error of an image included in the video, by subtracting a prediction image of the image from the image;
determining a secondary transform basis based on a primary transform basis, the primary transform basis being a transform basis for a primary transform to be performed on the prediction error, the secondary transform basis being a transform basis for a secondary transform to be performed on a result of the primary transform;
performing the primary transform on the prediction error using the primary transform basis;
performing the secondary transform on a result of the primary transform using the secondary transform basis;
performing quantization on a result of the secondary transform; and
encoding a result of the quantization as data of the image.
32 . A decoding method of decoding a video, the decoding method comprising:
decoding data of an image included in the video;
performing inverse quantization on the data;
determining an inverse secondary transform basis based on an inverse primary transform basis, the inverse primary transform basis being a transform basis for an inverse primary transform to be performed on a result of an inverse secondary transform, the inverse secondary transform basis being a transform basis for the inverse secondary transform to be performed on a result of the inverse quantization;
performing the inverse secondary transform on a result of the inverse quantization using the inverse secondary transform basis;
performing the inverse primary transform on a result of the inverse secondary transform using the inverse primary transform basis; and
deriving the image by adding a result of the inverse primary transform as a prediction error of the image to a prediction image of the image.