Patent Publication Number: US-2022217350-A1

Title: Encoder, decoder, encoding method, and decoding method

Description:
BACKGROUND 
     1. Technical Field 
     The present disclosure relates to an encoder, a decoder, an encoding method, and a decoding method. 
     2. Description of the Related Art 
     A video coding standard called high-efficiency video coding (HEVC) has been standardized by Joint Collaborative Team on Video Coding (JCT-VC). 
     CITATION LIST 
     Non-Patent Literature 
     [NPL] H.265 (ISO/IEC 23008-2 HEVC)/HEVC (High Efficiency Video Coding) 
     SUMMARY 
     An encoder according to an aspect of the present disclosure is an encoder which encodes a current block to be encoded in an image, the encoder includes circuitry and memory. Using the memory, the circuitry: performs a primary transform from residuals of the current block to primary coefficients; determines whether a secondary transform is to be applied to the current block; (i) calculates quantized primary coefficients by performing a first quantization on the primary coefficients when the secondary transform is not to be applied, (ii) performs a secondary transform from the primary coefficients to secondary coefficients, and calculates quantized secondary coefficients by performing a secondary quantization on the secondary coefficients when the secondary transform is to be applied, the secondary quantization being different from the first quantization; and generates an encoded bitstream by encoding either the quantized primary coefficients or the quantized secondary coefficients. 
     It is to be noted that these general and specific aspects may be implemented using a system, a method, an integrated circuit, a computer program, or a non-transitory computer-readable recording medium such as a CD-ROM, or any combination of systems, methods, integrated circuits, computer programs, or computer-readable recording media. 
    
    
     
       BRIEF DESCRIPTION OF DRAWINGS 
       These and other objects, advantages and features of the disclosure will become apparent from the following description thereof taken in conjunction with the accompanying drawings that illustrate a specific embodiment of the present disclosure. 
         FIG. 1  is a block diagram illustrating a functional configuration of an encoder according to Embodiment 1. 
         FIG. 2  illustrates one example of block splitting according to Embodiment 1. 
         FIG. 3  is a chart indicating transform basis functions for each transform type. 
         FIG. 4A  illustrates one example of a filter shape used in ALF. 
         FIG. 4B  illustrates another example of a filter shape used in ALF. 
         FIG. 4C  illustrates another example of a filter shape used in ALF. 
         FIG. 5A  illustrates 67 intra prediction modes used in intra prediction. 
         FIG. 5B  is a flow chart for illustrating an outline of a prediction image correction process performed via OBMC processing. 
         FIG. 5C  is a conceptual diagram for illustrating an outline of a prediction image correction process performed via OBMC processing. 
         FIG. 5D  illustrates one example of FRUC. 
         FIG. 6  is for illustrating pattern matching (bilateral matching) between two blocks along a motion trajectory. 
         FIG. 7  is for illustrating pattern matching (template matching) between a template in the current picture and a block in a reference picture. 
         FIG. 8  is for illustrating a model assuming uniform linear motion. 
         FIG. 9A  is for illustrating deriving a motion vector of each sub-block based on motion vectors of neighboring blocks. 
         FIG. 9B  is for illustrating an outline of a process for deriving a motion vector via merge mode. 
         FIG. 9C  is a conceptual diagram for illustrating an outline of DMVR processing. 
         FIG. 9D  is for illustrating an outline of a prediction image generation method using a luminance correction process performed via LIC processing. 
         FIG. 10  is a block diagram illustrating a functional configuration of a decoder according to Embodiment 1. 
         FIG. 11  is a flow chart indicating one example of a transform process, a quantization process, and an encoding process according to Embodiment 1. 
         FIG. 12  is a diagram indicating examples of positions of quantization matrices in an encoded bitstream according to Embodiment 1. 
         FIG. 13  is a flow chart indicating one example of a decoding process, an inverse quantization process, and an inverse transform process according to Embodiment 1. 
         FIG. 14  is a flow chart indicating one example of a transform process, a quantization process, and an encoding process according to Embodiment 2. 
         FIG. 15  is a flow chart indicating one example of a decoding process, an inverse quantization process, and an inverse transform process according to Embodiment 2. 
         FIG. 16  is a flow chart indicating one example of a process for deriving a second quantization matrix according to a variation of Embodiment 2. 
         FIG. 17  is a flow chart indicating one example of a transform process, a quantization process, and an encoding process according to Embodiment 3. 
         FIG. 18  is a flow chart indicating one example of a decoding process, an inverse quantization process, and an inverse transform process according to Embodiment 3. 
         FIG. 19  is a flow chart indicating one example of a transform process, a quantization process, and an encoding process according to Embodiment 4. 
         FIG. 20  is a diagram for explaining one example of a secondary transform according to Embodiment 4. 
         FIG. 21  is a flow chart indicating one example of a decoding process, an inverse quantization process, and an inverse transform process according to Embodiment 4. 
         FIG. 22  is a diagram for explaining one example of an inverse secondary transform according to Embodiment 4. 
         FIG. 23  is a flow chart indicating one example of a transform process, a quantization process, and an encoding process according to Embodiment 5. 
         FIG. 24  is a flow chart indicating one example of a decoding process, an inverse quantization process, and an inverse transform process according to Embodiment 5. 
         FIG. 25  illustrates an overall configuration of a content providing system for implementing a content distribution service. 
         FIG. 26  illustrates one example of an encoding structure in scalable encoding. 
         FIG. 27  illustrates one example of an encoding structure in scalable encoding. 
         FIG. 28  illustrates an example of a display screen of a web page. 
         FIG. 29  illustrates an example of a display screen of a web page. 
         FIG. 30  illustrates one example of a smartphone. 
         FIG. 31  is a block diagram illustrating a configuration example of a smartphone. 
     
    
    
     DETAILED DESCRIPTION OF THE EMBODIMENTS 
     (Underlying Knowledge Forming Basis of the Present Disclosure) 
     In the next-generation video compression standard, a secondary transform of coefficients obtained by performing a primary transform of residuals has been considered in order to further remove spatial redundancy. It is desired that coding efficiency is improved while reducing decrease in subjective image quality even when such a secondary transform is performed. 
     In view of this, an encoder according to an aspect of the present disclosure is an encoder which encodes a current block to be encoded in an image, the encoder includes circuitry and memory. Using the memory, the circuitry: performs a primary transform from residuals of the current block to primary coefficients; determines whether a secondary transform is to be applied to the current block; (i) calculates quantized primary coefficients by performing a first quantization on the primary coefficients when the secondary transform is not to be applied, (ii) performs a secondary transform from the primary coefficients to secondary coefficients, and calculates quantized secondary coefficients by performing a secondary quantization on the secondary coefficients when the secondary transform is to be applied, the secondary quantization being different from the first quantization; and generates an encoded bitstream by encoding either the quantized primary coefficients or the quantized secondary coefficients. 
     According to this, it is possible to perform a different quantization depending on application/non-application of a secondary transform on the current block. The secondary coefficients obtained by performing a secondary transform of primary coefficients represented in a primary space are to be represented in a secondary space which is not the primary space. For this reason, it is difficult to increase coding efficiency while reducing decrease in subjective image quality even when a quantization for the primary coefficients is applied to the secondary coefficients. For example, a quantization for reducing losses of low-frequency components to reduce decrease in subjective image quality and increases losses of high-frequency components to increase coding efficiency is different between the primary space and the secondary space. In view of this, it is possible to increase coding efficiency while reducing decrease in subjective image quality compared with the case of performing a common quantization by performing a different quantization depending on application/non-application of a secondary transform on the current block. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the first quantization may be a weighted quantization using a first quantization matrix, and the second quantization may be a weighted quantization using a second quantization matrix different from the first quantization matrix. 
     According to this, it is possible to perform a weighted quantization using the first quantization matrix, as the first quantization. Furthermore, it is possible to perform a weighted quantization using the second quantization matrix different from the first quantization matrix, as the second quantization. Accordingly, it is possible to use the first quantization matrix corresponding to the primary space in the quantization for the primary coefficients, and to use the second quantization matrix corresponding to the secondary space in the quantization for the secondary coefficients. Accordingly, in both the application and non-application of a secondary transform, it is possible to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the circuitry may write the first quantization matrix and the second quantization matrix into the encoded bitstream. 
     According to this, it is possible to include the first quantization matrix and the second quantization matrix into the encoded bitstream. Accordingly, it is possible to adaptively determine the first quantization matrix and the second quantization matrix according to an original image, and to further increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the primary coefficients may include one or more first primary coefficients and one or more second primary coefficients, the secondary transform may be applied to the one or more first primary coefficients and may not be applied to the one or more second primary coefficients, the second quantization matrix may have one or more first component values corresponding to the one or more first primary coefficients and one or more second component values corresponding to the one or more second primary coefficients, each of the one or more second component values of the second quantization matrix may match a corresponding one of component values of the first quantization matrix, and when the circuitry writes the second quantization matrix, the circuitry may write, into the encoded bitstream, only the one or more first component values among the one or more first component values and the one or more second component values. 
     According to this, it is possible to match each of the one or more second component values of the second quantization matrix with the corresponding component value of the first quantization matrix. Accordingly, the necessity of writing the one or more second component values of the second quantization matrix is eliminated, which makes it possible to increase coding efficiency. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, in the secondary transform, a plurality of bases which has been determined may be selectively used, the encoded bitstream may include a plurality of second quantization matrices corresponding to the plurality of bases, and in the second quantization, a second quantization matrix corresponding to a basis used for the second transform may be selected from the plurality of second quantization matrices. 
     According to this, it is possible to perform a second quantization using the second quantization matrix corresponding to a basis to be used in the secondary transform. Features of the secondary space which represents the secondary coefficients are different depending on the basis to be used for the secondary transform. Accordingly, by performing the second quantization using the second quantization matrix corresponding to the basis to be used for the secondary transform, it is possible to perform a second quantization using the quantization matrix more suitable for the secondary space, and to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the first quantization matrix and the second quantization matrix may be defined in advance in a standard. 
     According to this, the first quantization matrix and the second quantization matrix are defined in advance in the standard. Accordingly, it is not always necessary that the first quantization matrix and the second quantization matrix are included in the encoded bitstream, and thus it is possible to reduce the coding amount for the first quantization matrix and the second quantization matrix. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the circuitry may derive the second quantization matrix from the first quantization matrix. 
     According to this, it is possible to derive the second quantization matrix from the first quantization matrix. This eliminates the necessity of transmitting the second quantization matrix to the decoder, which makes it possible to increase coding efficiency. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the primary coefficients may include one or more first primary coefficients and one or more second primary coefficients, the secondary transform may be applied to the one or more first primary coefficients and may not be applied to the one or more second primary coefficients, the second quantization matrix may have one or more first component values corresponding to the one or more first primary coefficients and one or more second component values corresponding to the one or more second primary coefficients, each of the one or more second component values of the second quantization matrix may match a corresponding one of component values of the first quantization matrix, and when the circuitry derives the second quantization matrix, the circuitry may derive the one or more first component values of the second quantization matrix from the first quantization matrix. 
     According to this, it is possible to match each of the one or more second component values of the second quantization matrix with the corresponding component value of the first quantization matrix. This eliminates the necessity of deriving the one or more second component values of the second quantization matrix, which enables reduction in processing load. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the second quantization matrix may be derived by applying the secondary transform to the first quantization matrix. 
     According to this, it is possible to derive the second quantization matrix by applying a secondary transform on the first quantization matrix. Accordingly, it is possible to transform the first quantization matrix corresponding to the primary space into the second quantization matrix corresponding to the secondary transform, which makes it possible to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the circuitry may: derive a third quantization matrix from the first quantization matrix, the third quantization matrix having component values which are greater when corresponding component values of the first quantization matrix are smaller; derive a fourth quantization matrix by applying the secondary transform to the third quantization matrix; and derive, as the second quantization matrix, a fifth quantization matrix from the fourth quantization matrix, the fifth quantization matrix having component values which are greater when corresponding component values of the fourth quantization matrix are smaller. 
     According to this, it is possible to reduce influence of rounding error at the time of a secondary transform for components having a relatively small value included in the first quantization matrix. In other words, it is possible to reduce the influence of the rounding error on the component values to be applied to coefficients for which losses are desired to be small in order to reduce decrease in subjective image quality. Accordingly, it is possible to further reduce decrease in subjective image quality. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the component values of the third quantization matrix may be reciprocals of the corresponding component values of the first quantization matrix, and the component values of the fifth quantization matrix may be reciprocals of the corresponding component values of the fourth quantization matrix. 
     According to this, the reciprocals of the corresponding component values of the first quantization matrix/the fourth quantization matrix can be used as the component values of the third quantization matrix/the fifth quantization matrix. Accordingly, it is possible to derive the component values by a simple calculation, which makes it possible to reduce processing load and processing time to derive the second quantization matrix. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the first quantization may be a weighted quantization in which a quantization matrix is used, and the second quantization may be a non-weighted quantization in which no quantization matrix is used. 
     According to this, it is possible to use the non-weighted quantization in which no quantization matrix is used can be used as the second quantization. Accordingly, it is possible to reduce or skip the coding amount of or a process for deriving a quantization matrix for the second quantization while reducing decrease in subjective image quality due to use of the first quantization matrix for the first quantization as the second quantization. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the first quantization may be a weighted quantization using a first quantization matrix, in the secondary transform, (i) weighted primary coefficients may be calculated by multiplying each of the primary coefficients by a corresponding component value of a weighting matrix, and (ii) the weighted primary coefficients may be transformed into secondary coefficients, and in the second quantization, each of the secondary coefficients may be divided by a quantization step common between the secondary coefficients. 
     According to this, it is possible to calculate weighted primary coefficients by multiplying each of the primary coefficients by a corresponding component value of the weighting matrix. The weighting related to the quantization can be performed on the primary coefficients before being subjected to the secondary transform. Accordingly, it is possible to perform a quantization equivalent to a weighted quantization without newly preparing a quantization matrix corresponding to the secondary space when the secondary transform is to be performed. As a result, it is possible to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the circuitry may derive the weighting matrix from the first quantization matrix. 
     According to this, it is possible to derive the weighting matrix from the first quantization matrix. Accordingly, it is possible to reduce the coding amount for the weighting matrix, which makes it possible to reduce coding efficiency while reducing decrease in subjective image quality. 
     In addition, in an encoder according to an aspect of the present disclosure, for example, the circuitry may derive the common quantization step from a quantization parameter for the current block. 
     According to this, it is possible to derive the common quantization step between the secondary coefficients of the current block from the quantization parameter. Accordingly, new information for the common quantization step may be included in an encoded stream, which makes it possible to reduce the coding amount for the common quantization step. 
     An encoding method according to an aspect of the present disclosure is an encoding method for encoding a current block to be encoded in an image, the encoding method includes: performing a primary transform from residuals of the current block to primary coefficients; determining whether a secondary transform is to be applied to the current block; (i) calculating quantized primary coefficients by performing a first quantization on the primary coefficients when the secondary transform is not to be applied, (ii) performing a secondary transform from the primary coefficients to secondary coefficients, and calculating quantized secondary coefficients by performing a secondary quantization on the secondary coefficients when the secondary transform is to be applied, the secondary quantization being different from the first quantization; and generating an encoded bitstream by encoding either the quantized primary coefficients or the quantized secondary coefficients. 
     According to this, it is possible to achieve the similar effects as provided by the encoder. 
     An encoder according to an aspect of the present disclosure is an encoder which encodes a current block to be encoded in an image, the encoder includes circuitry and memory. Using the memory, the circuitry: performs a primary transform on residuals of the current block to primary coefficients; determines whether a secondary transform is to be applied to the current block; (i) calculates first quantized primary coefficients by performing a first quantization on the primary coefficients when the secondary transform is not to be applied, (ii) calculates second quantized primary coefficients by performing a second quantization on the first coefficients, and performs a secondary transform from second quantized primary coefficients to quantized secondary coefficients when the secondary transform is to be applied; and generates an encoded bitstream by encoding either the quantized primary coefficients or the quantized secondary coefficients. 
     According to this, since the quantization can be performed before the secondary transform, a secondary transform can be excluded from the prediction process loop when the secondary transform process is a loss-less process. Accordingly, the load for the processing pipeline can be reduced. In addition, performing the quantization before the secondary transform eliminates the necessity of selectively using the first quantization matrix and the second quantization matrix, which makes it possible to simplify the process. 
     An encoding method according to an aspect of the present disclosure is an encoding method for encoding a current block to be encoded in an image, the encoding method includes: performing a primary transform on residuals of the current block to primary coefficients; determining whether a secondary transform is to be applied to the current block; (i) calculating first quantized primary coefficients by performing a first quantization on the primary coefficients when the secondary transform is not to be applied, (ii) calculating second quantized primary coefficients by performing a second quantization on the first coefficients, and performing a secondary transform from second quantized primary coefficients to quantized secondary coefficients when the secondary transform is to be applied; and generating an encoded bitstream by encoding either the quantized primary coefficients or the quantized secondary coefficients. 
     According to this, it is possible to achieve the similar effects as provided by the encoder. 
     A decoder according to an aspect of the present disclosure is a decoder which decodes a current block to be decoded, the decoder includes circuitry and memory. Using the memory, the circuitry: decodes quantized coefficients of a current block to be decoded from an encoded bitstream; determines whether an inverse secondary transform is to be applied to the current block; calculates primary coefficients by performing a first inverse quantization on the quantized coefficients, and performs an inverse primary transform from the primary coefficients to residuals of the current block when the inverse secondary transform is not to be applied; and calculates secondary coefficients by performing a second inverse quantization on the quantized coefficients, performs an inverse secondary transform from the secondary coefficients to primary coefficients, and performs an inverse primary transform from the primary coefficients to residuals of the current block when the inverse secondary transform is to be applied. 
     According to this, it is possible to perform a different inverse quantization depending on application/non-application of an inverse secondary transform on the current block. The secondary coefficients obtained by performing a secondary transform of primary coefficients represented in a primary space are to be represented in a secondary space which is not the primary space. For this reason, it is difficult to increase coding efficiency while reducing decrease in subjective image quality even when an inverse quantization for the primary coefficients is applied to the secondary coefficients. For example, a quantization for reducing losses of low-frequency components to reduce decrease in subjective image quality and increasing losses of high-frequency components to increase coding efficiency is different between the primary space and the secondary space. In view of this, it is possible to increase coding efficiency while reducing decrease in subjective image quality compared with the case of performing a common inverse quantization by performing an inverse quantization different depending on application/non-application of an inverse secondary transform on the current block. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the first inverse quantization may be a weighted inverse quantization using a first quantization matrix, and the second inverse quantization may be a weighted inverse quantization using a second quantization matrix different from the first quantization matrix. 
     According to this, it is possible to perform a weighted inverse quantization using the first quantization matrix, as the first inverse quantization. Furthermore, it is possible to perform a weighted inverse quantization using the second quantization matrix different from the first quantization matrix, as the second inverse quantization. Accordingly, it is possible to use the first quantization matrix corresponding to the primary space in the inverse quantization for the primary coefficients, and to use the second quantization matrix corresponding to the secondary space in the inverse quantization for the secondary coefficients. Accordingly, in both the application and non-application of an inverse secondary transform, it is possible to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the circuitry may parse the first quantization matrix and the second quantization matrix from the encoded bitstream. 
     According to this, it is possible to include the first quantization matrix and the second quantization matrix into the encoded bitstream. Accordingly, it is possible to adaptively determine the first quantization matrix and the second quantization matrix according to an original image, and to further increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the secondary coefficients may include one or more first secondary coefficients and one or more second secondary coefficients, the inverse secondary transform may be applied to the one or more first secondary coefficients and may not be applied to the one or more second secondary coefficients, the second quantization matrix may have one or more first component values corresponding to the one or more first secondary coefficients and one or more second component values corresponding to the one or more second secondary coefficients, each of the one or more second component values of the second quantization matrix may match a corresponding one of component values of the first quantization matrix, and when the circuitry parses the second quantization matrix, the circuitry may parse, from the encoded bitstream, only the one or more first component values among the one or more first component values and the one or more second component values. 
     According to this, it is possible to match each of the one or more second component values of the second quantization matrix with the corresponding component value of the first quantization matrix. Accordingly, the necessity of parsing the one or more second component values of the second quantization matrix from the encoded bitstream is eliminated, which makes it possible to increase coding efficiency. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, in the inverse secondary transform, a plurality of bases which has been determined may be selectively used, the encoded bitstream may include a plurality of second quantization matrices corresponding to the plurality of bases, and in the second inverse quantization, a second quantization matrix corresponding to a basis used for the inverse secondary transform may be selected from the plurality of second quantization matrices. 
     Features of the secondary space which represents the secondary coefficients are different depending on the basis to be used for the inverse secondary transform. Accordingly, by performing the second inverse quantization using the second quantization matrix corresponding to the basis to be used for the inverse secondary transform, it is possible to perform a second inverse quantization using the quantization matrix more suitable for the secondary space, and to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the first quantization matrix and the second quantization matrix may be defined in advance in a standard. 
     According to this, the first quantization matrix and the second quantization matrix are defined in advance in the standard. Accordingly, it is not always necessary that the first quantization matrix and the second quantization matrix are included in the encoded bitstream, and thus it is possible to reduce the coding amount for the first quantization matrix and the second quantization matrix. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the circuitry may derive the second quantization matrix from the first quantization matrix. 
     According to this, it is possible to derive the second quantization matrix from the first quantization matrix. This eliminates the necessity of receiving the second quantization matrix from the encoder, which makes it possible to increase coding efficiency. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the secondary coefficients may include one or more first primary coefficients and one or more second primary coefficients, the inverse secondary transform may be applied to the one or more first secondary coefficients and may not be applied to the one or more second secondary coefficients, the second quantization matrix may have one or more first component values corresponding to the one or more first secondary coefficients and one or more second component values corresponding to the one or more second secondary coefficients, each of the one or more second component values of the second quantization matrix may match a corresponding one of component values of the first quantization matrix, and when the circuitry derives the second quantization matrix, the circuitry may derive only the one or more first component values from the first quantization matrix. 
     According to this, it is possible to match each of the one or more second component values of the second quantization matrix with the corresponding component value of the first quantization matrix. This eliminates the necessity of deriving the one or more second component values of the second quantization matrix, which enables reduction in processing load. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the second quantization matrix may be derived by applying a secondary transform to the first quantization matrix. 
     According to this, it is possible to derive the second quantization matrix by applying a secondary transform on the first quantization matrix. Accordingly, it is possible to transform the first quantization matrix corresponding to the primary space into the second quantization matrix corresponding to the secondary transform, which makes it possible to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the circuitry may: derive a third quantization matrix from the first quantization matrix, the third quantization matrix having component values which are greater when corresponding component values of the first quantization matrix are smaller; derive a fourth quantization matrix by applying a secondary transform to the third quantization matrix, and derive, as the second quantization matrix, a fifth quantization matrix from the fourth quantization matrix, the fifth quantization matrix having component values which are greater when corresponding component values of the fourth quantization matrix are smaller. 
     According to this, it is possible to reduce influence of rounding error at the time of a secondary transform for components having a relatively small value included in the first quantization matrix. In other words, it is possible to reduce the influence of the rounding error on the component values to be applied to coefficients for which losses are desired to be small in order to reduce decrease in subjective image quality. Accordingly, it is possible to further reduce decrease in subjective image quality. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the component values of the third quantization matrix may be reciprocals of the corresponding component values of the first quantization matrix, and the component values of the fifth quantization matrix may be reciprocals of the corresponding component values of the fourth quantization matrix. 
     According to this, the reciprocals of the corresponding component values of the first quantization matrix/the fourth quantization matrix can be used as the component values of the third quantization matrix/the fifth quantization matrix. Accordingly, it is possible to derive the component values by a simple calculation, which makes it possible to reduce processing load and processing time to derive the second quantization matrix. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the first inverse quantization may be a weighted inverse quantization in which a quantization matrix is used, and the second inverse quantization may be a non-weighted inverse quantization in which no quantization matrix is used. 
     According to this, it is possible to use the non-weighted inverse quantization in which no quantization matrix is used can be used as the second inverse quantization. Accordingly, it is possible to reduce or skip the coding amount of or a process for deriving a quantization matrix for the second quantization while reducing decrease in subjective image quality due to use of the first quantization matrix for the first inverse quantization as the second inverse quantization. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the first inverse quantization may be a weighted inverse quantization using a first quantization matrix, in the second inverse transform, the secondary coefficients may be calculated by multiplying each of the quantized coefficients by a quantization step common between the quantized coefficients, and in the inverse second quantization, the primary coefficients may be calculated by (i) performing an inverse transform on the secondary coefficients to weighted primary coefficients, and (ii) dividing each of the weighted primary coefficients by a corresponding component value of a weighting matrix. 
     According to this, it is possible to calculate primary coefficients by dividing each of the weighted primary coefficients with a corresponding component value of the weighting matrix. In other words, the weighting related to the quantization can be performed on the primary coefficients before being subjected to the secondary transform. Accordingly, it is possible to perform an inverse quantization equivalent to a weighted inverse quantization without newly preparing a quantization matrix corresponding to the secondary space when the inverse secondary transform is to be performed. As a result, it is possible to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the circuitry may derive the weighting matrix from the first quantization matrix. 
     According to this, it is possible to derive the weighting matrix from the first quantization matrix. Accordingly, it is possible to reduce the coding amount for the weighting matrix, which makes it possible to reduce coding efficiency while reducing decrease in subjective image quality. 
     In addition, in a decoder according to an aspect of the present disclosure, for example, the circuitry may derive the common quantization step from a quantization parameter for the current block. 
     According to this, it is possible to derive the common quantization step between the secondary coefficients of the current block from the quantization parameter. Accordingly, new information for the common quantization step may not be included in an encoded stream, which makes it possible to reduce the coding amount for the common quantization step. 
     A decoding method according to an aspect of the present disclosure is a decoding method for decoding a current block to be decoded in an image, the decoding method including: decoding quantized coefficients of the current block from an encoded bitstream; determining whether an inverse secondary transform is to be applied to the current block; calculating primary coefficients by performing a first inverse quantization on the quantized coefficients, and performing an inverse primary transform from the primary coefficients to residuals of the current block when the inverse secondary transform is not to be applied; and calculating secondary coefficients by performing a second inverse quantization on the quantized coefficients, performing an inverse secondary transform from the secondary coefficients to primary coefficients, and performing an inverse primary transform from the primary coefficients to residuals of the current block when the inverse secondary transform is to be applied. 
     According to this, it is possible to achieve the similar effects as provided by the decoder. 
     A decoder according to an aspect of the present disclosure is a decoder which decodes a current block to be decoded in an image, the decoder includes circuitry and memory. Using the memory, the circuitry: decodes quantized coefficients of the current block from an encoded bitstream; determines whether an inverse secondary transform is to be applied to the current block; calculates primary coefficients by performing a first inverse quantization on the quantized coefficients, and performs an inverse primary transform from the primary coefficients to residuals of the current block when the inverse secondary transform is not to be applied; and performs an inverse secondary transform from the quantized coefficients to quantized primary coefficients, calculates primary coefficients by performing a secondary inverse quantization on the quantized primary coefficients, and performs an inverse primary transform from the primary coefficients to residuals of the current block when the inverse secondary transform is to be applied. 
     According to this, since the quantization can be performed before the secondary transform, a secondary transform can be excluded from the prediction process loop in the encoder when the secondary transform process is a loss-less process. Accordingly, the load for the processing pipeline can be reduced. In addition, performing a quantization before the secondary transform eliminates the necessity of selectively using the first quantization matrix and the second quantization matrix, which makes it possible to simplify the process. 
     A decoding method according to an aspect of the present disclosure is a decoding method for decoding a current block to be decoded in an image, the decoding method includes: decoding quantized coefficients of a current block to be decoded from an encoded bitstream; determining whether an inverse secondary transform is to be applied to the current block; calculating primary coefficients by performing a first inverse quantization on the quantized coefficients, and performing an inverse primary transform from the primary coefficients to residuals of the current block when the inverse secondary transform is not to be applied; and performing an inverse secondary transform from the quantized coefficients to quantized primary coefficients, calculating primary coefficients by performing a second inverse quantization on the quantized primary coefficients, and performing an inverse primary transform from the primary coefficients to residuals of the current block when the inverse secondary transform is to be applied. 
     According to this, it is possible to achieve the similar effects as provided by the decoder. 
     It is to be noted that these general and specific aspects may be implemented using a system, an integrated circuit, a computer program, or a computer-readable recording medium such as a CD-ROM, or any combination of systems, methods, integrated circuits, computer programs, or computer-readable recording media. 
     Hereinafter, embodiments are described in detail with reference to the drawings. 
     It is to be noted that the embodiments described below each show a general or specific example. The numerical values, shapes, materials, constituent elements, the arrangement and connection of the constituent elements, steps, order of the steps, etc., indicated in the following embodiments are mere examples, and therefore are not intended to limit the scope of the claims. Therefore, among the constituent elements in the following embodiments, those not recited in any of the independent claims defining the most generic inventive concepts are described as optional constituent elements. 
     Embodiment 1 
     First, an outline of Embodiment 1 will be presented. Embodiment 1 is one example of an encoder and a decoder to which the processes and/or configurations presented in subsequent description of aspects of the present disclosure are applicable. Note that Embodiment 1 is merely one example of an encoder and a decoder to which the processes and/or configurations presented in the description of aspects of the present disclosure are applicable. The processes and/or configurations presented in the description of aspects of the present disclosure can also be implemented in an encoder and a decoder different from those according to Embodiment 1. 
     When the processes and/or configurations presented in the description of aspects of the present disclosure are applied to Embodiment 1, for example, any of the following may be performed. 
     (1) regarding the encoder or the decoder according to Embodiment 1, among components included in the encoder or the decoder according to Embodiment 1, substituting a component corresponding to a component presented in the description of aspects of the present disclosure with a component presented in the description of aspects of the present disclosure; 
     (2) regarding the encoder or the decoder according to Embodiment 1, implementing discretionary changes to functions or implemented processes performed by one or more components included in the encoder or the decoder according to Embodiment 1, such as addition, substitution, or removal, etc., of such functions or implemented processes, then substituting a component corresponding to a component presented in the description of aspects of the present disclosure with a component presented in the description of aspects of the present disclosure; 
     (3) regarding the method implemented by the encoder or the decoder according to Embodiment 1, implementing discretionary changes such as addition of processes and/or substitution, removal of one or more of the processes included in the method, and then substituting a processes corresponding to a process presented in the description of aspects of the present disclosure with a process presented in the description of aspects of the present disclosure; 
     (4) combining one or more components included in the encoder or the decoder according to Embodiment 1 with a component presented in the description of aspects of the present disclosure, a component including one or more functions included in a component presented in the description of aspects of the present disclosure, or a component that implements one or more processes implemented by a component presented in the description of aspects of the present disclosure; 
     (5) combining a component including one or more functions included in one or more components included in the encoder or the decoder according to Embodiment 1, or a component that implements one or more processes implemented by one or more components included in the encoder or the decoder according to Embodiment 1 with a component presented in the description of aspects of the present disclosure, a component including one or more functions included in a component presented in the description of aspects of the present disclosure, or a component that implements one or more processes implemented by a component presented in the description of aspects of the present disclosure; 
     (6) regarding the method implemented by the encoder or the decoder according to Embodiment 1, among processes included in the method, substituting a process corresponding to a process presented in the description of aspects of the present disclosure with a process presented in the description of aspects of the present disclosure; and 
     (7) combining one or more processes included in the method implemented by the encoder or the decoder according to Embodiment 1 with a process presented in the description of aspects of the present disclosure. 
     Note that the implementation of the processes and/or configurations presented in the description of aspects of the present disclosure is not limited to the above examples. For example, the processes and/or configurations presented in the description of aspects of the present disclosure may be implemented in a device used for a purpose different from the moving picture/picture encoder or the moving picture/picture decoder disclosed in Embodiment 1. Moreover, the processes and/or configurations presented in the description of aspects of the present disclosure may be independently implemented. Moreover, processes and/or configurations described in different aspects may be combined. 
     [Encoder Outline] 
     First, the encoder according to Embodiment 1 will be outlined.  FIG. 1  is a block diagram illustrating a functional configuration of encoder  100  according to Embodiment 1. Encoder  100  is a moving picture/picture encoder that encodes a moving picture/picture block by block. 
     As illustrated in  FIG. 1 , encoder  100  is a device that encodes a picture block by block, and includes splitter  102 , subtractor  104 , transformer  106 , quantizer  108 , entropy encoder  110 , inverse quantizer  112 , inverse transformer  114 , adder  116 , block memory  118 , loop filter  120 , frame memory  122 , intra predictor  124 , inter predictor  126 , and prediction controller  128 . 
     Encoder  100  is realized as, for example, a generic processor and memory. In this case, when a software program stored in the memory is executed by the processor, the processor functions as splitter  102 , subtractor  104 , transformer  106 , quantizer  108 , entropy encoder  110 , inverse quantizer  112 , inverse transformer  114 , adder  116 , loop filter  120 , intra predictor  124 , inter predictor  126 , and prediction controller  128 . Alternatively, encoder  100  may be realized as one or more dedicated electronic circuits corresponding to splitter  102 , subtractor  104 , transformer  106 , quantizer  108 , entropy encoder  110 , inverse quantizer  112 , inverse transformer  114 , adder  116 , loop filter  120 , intra predictor  124 , inter predictor  126 , and prediction controller  128 . 
     Hereinafter, each component included in encoder  100  will be described. 
     [Splitter] 
     Splitter  102  splits each picture included in an input moving picture into blocks, and outputs each block to subtractor  104 . For example, splitter  102  first splits a picture into blocks of a fixed size (for example, 128×128). The fixed size block is also referred to as coding tree unit (CTU). Splitter  102  then splits each fixed size block into blocks of variable sizes (for example, 64×64 or smaller), based on recursive quadtree and/or binary tree block splitting. The variable size block is also referred to as a coding unit (CU), a prediction unit (PU), or a transform unit (TU). Note that in this embodiment, there is no need to differentiate between CU, PU, and TU; all or some of the blocks in a picture may be processed per CU, PU, or TU. 
       FIG. 2  illustrates one example of block splitting according to Embodiment 1. In  FIG. 2 , the solid lines represent block boundaries of blocks split by quadtree block splitting, and the dashed lines represent block boundaries of blocks split by binary tree block splitting. 
     Here, block  10  is a square 128×128 pixel block (128×128 block). This 128×128 block  10  is first split into four square 64×64 blocks (quadtree block splitting). 
     The top left 64×64 block is further vertically split into two rectangle 32×64 blocks, and the left 32×64 block is further vertically split into two rectangle 16×64 blocks (binary tree block splitting). As a result, the top left 64×64 block is split into two 16×64 blocks  11  and  12  and one 32×64 block  13 . 
     The top right 64×64 block is horizontally split into two rectangle 64×32 blocks  14  and  15  (binary tree block splitting). 
     The bottom left 64×64 block is first split into four square 32×32 blocks (quadtree block splitting). The top left block and the bottom right block among the four 32×32 blocks are further split. The top left 32×32 block is vertically split into two rectangle 16×32 blocks, and the right 16×32 block is further horizontally split into two 16×16 blocks (binary tree block splitting). The bottom right 32×32 block is horizontally split into two 32×16 blocks (binary tree block splitting). As a result, the bottom left 64×64 block is split into 16×32 block  16 , two 16×16 blocks  17  and  18 , two 32×32 blocks  19  and  20 , and two 32×16 blocks  21  and  22 . 
     The bottom right 64×64 block  23  is not split. 
     As described above, in  FIG. 2 , block  10  is split into 13 variable size blocks  11  through  23  based on recursive quadtree and binary tree block splitting. This type of splitting is also referred to as quadtree plus binary tree (QTBT) splitting. 
     Note that in  FIG. 2 , one block is split into four or two blocks (quadtree or binary tree block splitting), but splitting is not limited to this example. For example, one block may be split into three blocks (ternary block splitting). Splitting including such ternary block splitting is also referred to as multi-type tree (MBT) splitting. 
     [Subtractor] 
     Subtractor  104  subtracts a prediction signal (prediction sample) from an original signal (original sample) per block split by splitter  102 . In other words, subtractor  104  calculates prediction errors (also referred to as residuals) of a block to be encoded (hereinafter referred to as a current block). Subtractor  104  then outputs the calculated prediction errors to transformer  106 . 
     The original signal is a signal input into encoder  100 , and is a signal representing an image for each picture included in a moving picture (for example, a luma signal and two chroma signals). Hereinafter, a signal representing an image is also referred to as a sample. 
     [Transformer] 
     Transformer  106  transforms spatial domain prediction errors into frequency domain transform coefficients, and outputs the transform coefficients to quantizer  108 . More specifically, transformer  106  applies, for example, a predefined discrete cosine transform (DCT) or discrete sine transform (DST) to spatial domain prediction errors. 
     Note that transformer  106  may adaptively select a transform type from among a plurality of transform types, and transform prediction errors into transform coefficients by using a transform basis function corresponding to the selected transform type. This sort of transform is also referred to as explicit multiple core transform (EMT) or adaptive multiple transform (AMT). 
     The transform types include, for example, DCT-II, DCT-V, DCT-VIII, DST-I, and DST-VII.  FIG. 3  is a chart indicating transform basis functions for each transform type. In  FIG. 3 , N indicates the number of input pixels. For example, selection of a transform type from among the plurality of transform types may depend on the prediction type (intra prediction and inter prediction), and may depend on intra prediction mode. 
     Information indicating whether to apply such EMT or AMT (referred to as, for example, an AMT flag) and information indicating the selected transform type is signalled at the CU level. Note that the signaling of such information need not be performed at the CU level, and may be performed at another level (for example, at the sequence level, picture level, slice level, tile level, or CTU level). 
     Moreover, transformer  106  may apply a secondary transform to the transform coefficients (transform result). Such a secondary transform is also referred to as adaptive secondary transform (AST) or non-separable secondary transform (NSST). For example, transformer  106  applies a secondary transform to each sub-block (for example, each 4×4 sub-block) included in the block of the transform coefficients corresponding to the intra prediction errors. Information indicating whether to apply NSST and information related to the transform matrix used in NSST are signalled at the CU level. Note that the signaling of such information need not be performed at the CU level, and may be performed at another level (for example, at the sequence level, picture level, slice level, tile level, or CTU level). 
     Here, a separable transform is a method in which a transform is performed a plurality of times by separately performing a transform for each direction according to the number of dimensions input. A non-separable transform is a method of performing a collective transform in which two or more dimensions in a multidimensional input are collectively regarded as a single dimension. 
     In one example of a non-separable transform, when the input is a 4×4 block, the 4×4 block is regarded as a single array including 16 components, and the transform applies a 16×16 transform matrix to the array. 
     Moreover, similar to above, after an input 4×4 block is regarded as a single array including 16 components, a transform that performs a plurality of Givens rotations on the array (i.e., a Hypercube-Givens Transform) is also one example of a non-separable transform. 
     [Quantizer] 
     Quantizer  108  quantizes the transform coefficients output from transformer  106 . More specifically, quantizer  108  scans, in a predetermined scanning order, the transform coefficients of the current block, and quantizes the scanned transform coefficients based on quantization parameters (QP) corresponding to the transform coefficients. Quantizer  108  then outputs the quantized transform coefficients (hereinafter referred to as quantized coefficients) of the current block to entropy encoder  110  and inverse quantizer  112 . 
     A predetermined order is an order for quantizing/inverse quantizing transform coefficients. For example, a predetermined scanning order is defined as ascending order of frequency (from low to high frequency) or descending order of frequency (from high to low frequency). 
     A quantization parameter is a parameter defining a quantization step size (quantization width). For example, if the value of the quantization parameter increases, the quantization step size also increases. In other words, if the value of the quantization parameter increases, the quantization error increases. 
     [Entropy Encoder] 
     Entropy encoder  110  generates an encoded signal (encoded bitstream) by variable length encoding quantized coefficients, which are inputs from quantizer  108 . More specifically, entropy encoder  110 , for example, binarizes quantized coefficients and arithmetic encodes the binary signal. 
     [Inverse Quantizer] 
     Inverse quantizer  112  inverse quantizes quantized coefficients, which are inputs from quantizer  108 . More specifically, inverse quantizer  112  inverse quantizes, in a predetermined scanning order, quantized coefficients of the current block. Inverse quantizer  112  then outputs the inverse quantized transform coefficients of the current block to inverse transformer  114 . 
     [Inverse Transformer] 
     Inverse transformer  114  restores prediction errors by inverse transforming transform coefficients, which are inputs from inverse quantizer  112 . More specifically, inverse transformer  114  restores the prediction errors of the current block by applying an inverse transform corresponding to the transform applied by transformer  106  on the transform coefficients. Inverse transformer  114  then outputs the restored prediction errors to adder  116 . 
     Note that since information is lost in quantization, the restored prediction errors do not match the prediction errors calculated by subtractor  104 . In other words, the restored prediction errors include quantization errors. 
     [Adder] 
     Adder  116  reconstructs the current block by summing prediction errors, which are inputs from inverse transformer  114 , and prediction samples, which are inputs from prediction controller  128 . Adder  116  then outputs the reconstructed block to block memory  118  and loop filter  120 . A reconstructed block is also referred to as a local decoded block. 
     [Block Memory] 
     Block memory  118  is storage for storing blocks in a picture to be encoded (hereinafter referred to as a current picture) for reference in intra prediction. More specifically, block memory  118  stores reconstructed blocks output from adder  116 . 
     [Loop Filter] 
     Loop filter  120  applies a loop filter to blocks reconstructed by adder  116 , and outputs the filtered reconstructed blocks to frame memory  122 . A loop filter is a filter used in an encoding loop (in-loop filter), and includes, for example, a deblocking filter (DF), a sample adaptive offset (SAO), and an adaptive loop filter (ALF). 
     In ALF, a least square error filter for removing compression artifacts is applied. For example, one filter from among a plurality of filters is selected for each 2×2 sub-block in the current block based on direction and activity of local gradients, and is applied. 
     More specifically, first, each sub-block (for example, each 2×2 sub-block) is categorized into one out of a plurality of classes (for example, 15 or 25 classes). The classification of the sub-block is based on gradient directionality and activity. For example, classification index C is derived based on gradient directionality D (for example, 0 to 2 or 0 to 4) and gradient activity A (for example, 0 to 4) (for example, C=5D+A). Then, based on classification index C, each sub-block is categorized into one out of a plurality of classes (for example, 15 or 25 classes). 
     For example, gradient directionality D is calculated by comparing gradients of a plurality of directions (for example, the horizontal, vertical, and two diagonal directions). Moreover, for example, gradient activity A is calculated by summing gradients of a plurality of directions and quantizing the sum. 
     The filter to be used for each sub-block is determined from among the plurality of filters based on the result of such categorization. 
     The filter shape to be used in ALF is, for example, a circular symmetric filter shape.  FIG. 4A  through  FIG. 4C  illustrate examples of filter shapes used in ALF.  FIG. 4A  illustrates a 5×5 diamond shape filter,  FIG. 4B  illustrates a 7×7 diamond shape filter, and  FIG. 4C  illustrates a 9×9 diamond shape filter. Information indicating the filter shape is signalled at the picture level. Note that the signaling of information indicating the filter shape need not be performed at the picture level, and may be performed at another level (for example, at the sequence level, slice level, tile level, CTU level, or CU level). 
     The enabling or disabling of ALF is determined at the picture level or CU level. For example, for luma, the decision to apply ALF or not is done at the CU level, and for chroma, the decision to apply ALF or not is done at the picture level. Information indicating whether ALF is enabled or disabled is signalled at the picture level or CU level. Note that the signaling of information indicating whether ALF is enabled or disabled need not be performed at the picture level or CU level, and may be performed at another level (for example, at the sequence level, slice level, tile level, or CTU level). 
     The coefficients set for the plurality of selectable filters (for example, 15 or 25 filters) is signalled at the picture level. Note that the signaling of the coefficients set need not be performed at the picture level, and may be performed at another level (for example, at the sequence level, slice level, tile level, CTU level, CU level, or sub-block level). 
     [Frame Memory] 
     Frame memory  122  is storage for storing reference pictures used in inter prediction, and is also referred to as a frame buffer. More specifically, frame memory  122  stores reconstructed blocks filtered by loop filter  120 . 
     [Intra Predictor] 
     Intra predictor  124  generates a prediction signal (intra prediction signal) by intra predicting the current block with reference to a block or blocks in the current picture and stored in block memory  118  (also referred to as intra frame prediction). More specifically, intra predictor  124  generates an intra prediction signal by intra prediction with reference to samples (for example, luma and/or chroma values) of a block or blocks neighboring the current block, and then outputs the intra prediction signal to prediction controller  128 . 
     For example, intra predictor  124  performs intra prediction by using one mode from among a plurality of predefined intra prediction modes. The intra prediction modes include one or more non-directional prediction modes and a plurality of directional prediction modes. 
     The one or more non-directional prediction modes include, for example, planar prediction mode and DC prediction mode defined in the H.265/high-efficiency video coding (HEVC) standard (see NPL 1). 
     The plurality of directional prediction modes include, for example, the 33 directional prediction modes defined in the H.265/HEVC standard. Note that the plurality of directional prediction modes may further include 32 directional prediction modes in addition to the 33 directional prediction modes (for a total of 65 directional prediction modes).  FIG. 5A  illustrates 67 intra prediction modes used in intra prediction (two non-directional prediction modes and 65 directional prediction modes). The solid arrows represent the 33 directions defined in the H.265/HEVC standard, and the dashed arrows represent the additional 32 directions. 
     Note that a luma block may be referenced in chroma block intra prediction. In other words, a chroma component of the current block may be predicted based on a luma component of the current block. Such intra prediction is also referred to as cross-component linear model (CCLM) prediction. Such a chroma block intra prediction mode that references a luma block (referred to as, for example, CCLM mode) may be added as one of the chroma block intra prediction modes. 
     Intra predictor  124  may correct post-intra-prediction pixel values based on horizontal/vertical reference pixel gradients. Intra prediction accompanied by this sort of correcting is also referred to as position dependent intra prediction combination (PDPC). Information indicating whether to apply PDPC or not (referred to as, for example, a PDPC flag) is, for example, signalled at the CU level. Note that the signaling of this information need not be performed at the CU level, and may be performed at another level (for example, on the sequence level, picture level, slice level, tile level, or CTU level). 
     [Inter Predictor] 
     Inter predictor  126  generates a prediction signal (inter prediction signal) by inter predicting the current block with reference to a block or blocks in a reference picture, which is different from the current picture and is stored in frame memory  122  (also referred to as inter frame prediction). Inter prediction is performed per current block or per sub-block (for example, per 4×4 block) in the current block. For example, inter predictor  126  performs motion estimation in a reference picture for the current block or sub-block. Inter predictor  126  then generates an inter prediction signal of the current block or sub-block by motion compensation by using motion information (for example, a motion vector) obtained from motion estimation. Inter predictor  126  then outputs the generated inter prediction signal to prediction controller  128 . 
     The motion information used in motion compensation is signalled. A motion vector predictor may be used for the signaling of the motion vector. In other words, the difference between the motion vector and the motion vector predictor may be signalled. 
     Note that the inter prediction signal may be generated using motion information for a neighboring block in addition to motion information for the current block obtained from motion estimation. More specifically, the inter prediction signal may be generated per sub-block in the current block by calculating a weighted sum of a prediction signal based on motion information obtained from motion estimation and a prediction signal based on motion information for a neighboring block. Such inter prediction (motion compensation) is also referred to as overlapped block motion compensation (OBMC). 
     In such an OBMC mode, information indicating sub-block size for OBMC (referred to as, for example, OBMC block size) is signalled at the sequence level. Moreover, information indicating whether to apply the OBMC mode or not (referred to as, for example, an OBMC flag) is signalled at the CU level. Note that the signaling of such information need not be performed at the sequence level and CU level, and may be performed at another level (for example, at the picture level, slice level, tile level, CTU level, or sub-block level). 
     Hereinafter, the OBMC mode will be described in further detail.  FIG. 5B  is a flowchart and  FIG. 5C  is a conceptual diagram for illustrating an outline of a prediction image correction process performed via OBMC processing. 
     First, a prediction image (Pred) is obtained through typical motion compensation using a motion vector (MV) assigned to the current block. 
     Next, a prediction image (Pred_L) is obtained by applying a motion vector (MV_L) of the encoded neighboring left block to the current block, and a first pass of the correction of the prediction image is made by superimposing the prediction image and Pred_L. 
     Similarly, a prediction image (Pred_U) is obtained by applying a motion vector (MV_U) of the encoded neighboring upper block to the current block, and a second pass of the correction of the prediction image is made by superimposing the prediction image resulting from the first pass and Pred_U. The result of the second pass is the final prediction image. 
     Note that the above example is of a two-pass correction method using the neighboring left and upper blocks, but the method may be a three-pass or higher correction method that also uses the neighboring right and/or lower block. 
     Note that the region subject to superimposition may be the entire pixel region of the block, and, alternatively, may be a partial block boundary region. 
     Note that here, the prediction image correction process is described as being based on a single reference picture, but the same applies when a prediction image is corrected based on a plurality of reference pictures. In such a case, after corrected prediction images resulting from performing correction based on each of the reference pictures are obtained, the obtained corrected prediction images are further superimposed to obtain the final prediction image. 
     Note that the unit of the current block may be a prediction block and, alternatively, may be a sub-block obtained by further dividing the prediction block. 
     One example of a method for determining whether to implement OBMC processing is by using an obmc_flag, which is a signal that indicates whether to implement OBMC processing. As one specific example, the encoder determines whether the current block belongs to a region including complicated motion. The encoder sets the obmc_flag to a value of “1” when the block belongs to a region including complicated motion and implements OBMC processing when encoding, and sets the obmc_flag to a value of “0” when the block does not belong to a region including complication motion and encodes without implementing OBMC processing. The decoder switches between implementing OBMC processing or not by decoding the obmc_flag written in the stream and performing the decoding in accordance with the flag value. 
     Note that the motion information may be derived on the decoder side without being signalled. For example, a merge mode defined in the H.265/HEVC standard may be used. Moreover, for example, the motion information may be derived by performing motion estimation on the decoder side. In this case, motion estimation is performed without using the pixel values of the current block. 
     Here, a mode for performing motion estimation on the decoder side will be described. A mode for performing motion estimation on the decoder side is also referred to as pattern matched motion vector derivation (PMMVD) mode or frame rate up-conversion (FRUC) mode. 
     One example of FRUC processing is illustrated in  FIG. 5D . First, a candidate list (a candidate list may be a merge list) of candidates each including a motion vector predictor is generated with reference to motion vectors of encoded blocks that spatially or temporally neighbor the current block. Next, the best candidate MV is selected from among a plurality of candidate MVs registered in the candidate list. For example, evaluation values for the candidates included in the candidate list are calculated and one candidate is selected based on the calculated evaluation values. 
     Next, a motion vector for the current block is derived from the motion vector of the selected candidate. More specifically, for example, the motion vector for the current block is calculated as the motion vector of the selected candidate (best candidate MV), as-is. Alternatively, the motion vector for the current block may be derived by pattern matching performed in the vicinity of a position in a reference picture corresponding to the motion vector of the selected candidate. In other words, when the vicinity of the best candidate MV is searched via the same method and an MV having a better evaluation value is found, the best candidate MV may be updated to the MV having the better evaluation value, and the MV having the better evaluation value may be used as the final MV for the current block. Note that a configuration in which this processing is not implemented is also acceptable. 
     The same processes may be performed in cases in which the processing is performed in units of sub-blocks. 
     Note that an evaluation value is calculated by calculating the difference in the reconstructed image by pattern matching performed between a region in a reference picture corresponding to a motion vector and a predetermined region. Note that the evaluation value may be calculated by using some other information in addition to the difference. 
     The pattern matching used is either first pattern matching or second pattern matching. First pattern matching and second pattern matching are also referred to as bilateral matching and template matching, respectively. 
     In the first pattern matching, pattern matching is performed between two blocks along the motion trajectory of the current block in two different reference pictures. Therefore, in the first pattern matching, a region in another reference picture conforming to the motion trajectory of the current block is used as the predetermined region for the above-described calculation of the candidate evaluation value. 
       FIG. 6  is for illustrating one example of pattern matching (bilateral matching) between two blocks along a motion trajectory. As illustrated in  FIG. 6 , in the first pattern matching, two motion vectors (MV 0 , MV 1 ) are derived by finding the best match between two blocks along the motion trajectory of the current block (Cur block) in two different reference pictures (Ref 0 , Ref 1 ). More specifically, a difference between (i) a reconstructed image in a specified position in a first encoded reference picture (Ref 0 ) specified by a candidate MV and (ii) a reconstructed picture in a specified position in a second encoded reference picture (Ref 1 ) specified by a symmetrical MV scaled at a display time interval of the candidate MV may be derived, and the evaluation value for the current block may be calculated by using the derived difference. The candidate MV having the best evaluation value among the plurality of candidate MVs may be selected as the final MV. 
     Under the assumption of continuous motion trajectory, the motion vectors (MV 0 , MV 1 ) pointing to the two reference blocks shall be proportional to the temporal distances (TD 0 , TD 1 ) between the current picture (Cur Pic) and the two reference pictures (Ref 0 , Ref 1 ). For example, when the current picture is temporally between the two reference pictures and the temporal distance from the current picture to the two reference pictures is the same, the first pattern matching derives a mirror based bi-directional motion vector. 
     In the second pattern matching, pattern matching is performed between a template in the current picture (blocks neighboring the current block in the current picture (for example, the top and/or left neighboring blocks)) and a block in a reference picture. Therefore, in the second pattern matching, a block neighboring the current block in the current picture is used as the predetermined region for the above-described calculation of the candidate evaluation value. 
       FIG. 7  is for illustrating one example of pattern matching (template matching) between a template in the current picture and a block in a reference picture. As illustrated in  FIG. 7 , in the second pattern matching, a motion vector of the current block is derived by searching a reference picture (Ref 0 ) to find the block that best matches neighboring blocks of the current block (Cur block) in the current picture (Cur Pic). More specifically, a difference between (i) a reconstructed image of an encoded region that is both or one of the neighboring left and neighboring upper region and (ii) a reconstructed picture in the same position in an encoded reference picture (Ref 0 ) specified by a candidate MV may be derived, and the evaluation value for the current block may be calculated by using the derived difference. The candidate MV having the best evaluation value among the plurality of candidate MVs may be selected as the best candidate MV. 
     Information indicating whether to apply the FRUC mode or not (referred to as, for example, a FRUC flag) is signalled at the CU level. Moreover, when the FRUC mode is applied (for example, when the FRUC flag is set to true), information indicating the pattern matching method (first pattern matching or second pattern matching) is signalled at the CU level. Note that the signaling of such information need not be performed at the CU level, and may be performed at another level (for example, at the sequence level, picture level, slice level, tile level, CTU level, or sub-block level). 
     Here, a mode for deriving a motion vector based on a model assuming uniform linear motion will be described. This mode is also referred to as a bi-directional optical flow (BIO) mode. 
       FIG. 8  is for illustrating a model assuming uniform linear motion. In  FIG. 8 , (v x , v y ) denotes a velocity vector, and τ 0  and τ 1  denote temporal distances between the current picture (Cur Pic) and two reference pictures (Ref 0 , Ref 1 ). (MVx 0 , MVy 0 ) denotes a motion vector corresponding to reference picture Ref 0 , and (MVx 1 , MVy 1 ) denotes a motion vector corresponding to reference picture Ref 1 . 
     Here, under the assumption of uniform linear motion exhibited by velocity vector (v x , v y ), (MVx 0 , MVy 0 ) and (MVx 1 , MVy 1 ) are represented as (v x τ 0 , v y τ 0 ) and (−v x τ 1 , −v y τ 1 ), respectively, and the following optical flow equation is given. 
       MATH. 1 
       ∫ I   (k)   /∂t+v   x   ∂I   (k)   /∂x+v   y   ∂I   (k)   /∂y= 0.  (1)
 
     Here, I (k)  denotes a luma value from reference picture k (k=0, 1) after motion compensation. This optical flow equation shows that the sum of (i) the time derivative of the luma value, (ii) the product of the horizontal velocity and the horizontal component of the spatial gradient of a reference picture, and (iii) the product of the vertical velocity and the vertical component of the spatial gradient of a reference picture is equal to zero. A motion vector of each block obtained from, for example, a merge list is corrected pixel by pixel based on a combination of the optical flow equation and Hermite interpolation. 
     Note that a motion vector may be derived on the decoder side using a method other than deriving a motion vector based on a model assuming uniform linear motion. For example, a motion vector may be derived for each sub-block based on motion vectors of neighboring blocks. 
     Here, a mode in which a motion vector is derived for each sub-block based on motion vectors of neighboring blocks will be described. This mode is also referred to as affine motion compensation prediction mode. 
       FIG. 9A  is for illustrating deriving a motion vector of each sub-block based on motion vectors of neighboring blocks. In  FIG. 9A , the current block includes 16 4×4 sub-blocks. Here, motion vector v 0  of the top left corner control point in the current block is derived based on motion vectors of neighboring sub-blocks, and motion vector v 1  of the top right corner control point in the current block is derived based on motion vectors of neighboring blocks. Then, using the two motion vectors v 0  and v 1 , the motion vector (v x , v y ) of each sub-block in the current block is derived using Equation 2 below. 
     
       
         
           
             MATH 
             . 
             
                 
             
             ⁢ 
             2 
           
         
       
       
         
           
             
               
                 
                   { 
                   
                     
                       
                         
                           
                             v 
                             x 
                           
                           = 
                           
                             
                               
                                 
                                   ( 
                                   
                                     
                                       v 
                                       
                                         1 
                                         ⁢ 
                                         x 
                                       
                                     
                                     - 
                                     
                                       v 
                                       
                                         0 
                                         ⁢ 
                                         x 
                                       
                                     
                                   
                                   ) 
                                 
                                 w 
                               
                               ⁢ 
                               x 
                             
                             - 
                             
                               
                                 
                                   ( 
                                   
                                     
                                       v 
                                       
                                         1 
                                         ⁢ 
                                         y 
                                       
                                     
                                     - 
                                     
                                       v 
                                       
                                         0 
                                         ⁢ 
                                         y 
                                       
                                     
                                   
                                   ) 
                                 
                                 w 
                               
                               ⁢ 
                               y 
                             
                             + 
                             
                               v 
                               
                                 0 
                                 ⁢ 
                                 x 
                               
                             
                           
                         
                       
                     
                     
                       
                         
                           
                             v 
                             y 
                           
                           = 
                           
                             
                               
                                 
                                   ( 
                                   
                                     
                                       v 
                                       
                                         1 
                                         ⁢ 
                                         y 
                                       
                                     
                                     - 
                                     
                                       v 
                                       
                                         0 
                                         ⁢ 
                                         y 
                                       
                                     
                                   
                                   ) 
                                 
                                 w 
                               
                               ⁢ 
                               x 
                             
                             + 
                             
                               
                                 
                                   ( 
                                   
                                     
                                       v 
                                       
                                         1 
                                         ⁢ 
                                         x 
                                       
                                     
                                     - 
                                     
                                       v 
                                       
                                         0 
                                         ⁢ 
                                         x 
                                       
                                     
                                   
                                   ) 
                                 
                                 w 
                               
                               ⁢ 
                               y 
                             
                             + 
                             
                               v 
                               
                                 0 
                                 ⁢ 
                                 y 
                               
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   2 
                   ) 
                 
               
             
           
         
       
     
     Here, x and y are the horizontal and vertical positions of the sub-block, respectively, and w is a predetermined weighted coefficient. 
     Such an affine motion compensation prediction mode may include a number of modes of different methods of deriving the motion vectors of the top left and top right corner control points. Information indicating such an affine motion compensation prediction mode (referred to as, for example, an affine flag) is signalled at the CU level. Note that the signaling of information indicating the affine motion compensation prediction mode need not be performed at the CU level, and may be performed at another level (for example, at the sequence level, picture level, slice level, tile level, CTU level, or sub-block level). 
     [Prediction Controller] 
     Prediction controller  128  selects either the intra prediction signal or the inter prediction signal, and outputs the selected prediction signal to subtractor  104  and adder  116 . 
     Here, an example of deriving a motion vector via merge mode in a current picture will be given.  FIG. 9B  is for illustrating an outline of a process for deriving a motion vector via merge mode. 
     First, an MV predictor list in which candidate MV predictors are registered is generated. Examples of candidate MV predictors include: spatially neighboring MV predictors, which are MVs of encoded blocks positioned in the spatial vicinity of the current block; a temporally neighboring MV predictor, which is an MV of a block in an encoded reference picture that neighbors a block in the same location as the current block; a combined MV predictor, which is an MV generated by combining the MV values of the spatially neighboring MV predictor and the temporally neighboring MV predictor; and a zero MV predictor, which is an MV whose value is zero. 
     Next, the MV of the current block is determined by selecting one MV predictor from among the plurality of MV predictors registered in the MV predictor list. 
     Furthermore, in the variable-length encoder, a merge_idx, which is a signal indicating which MV predictor is selected, is written and encoded into the stream. 
     Note that the MV predictors registered in the MV predictor list illustrated in  FIG. 9B  constitute one example. The number of MV predictors registered in the MV predictor list may be different from the number illustrated in  FIG. 9B , the MV predictors registered in the MV predictor list may omit one or more of the types of MV predictors given in the example in  FIG. 9B , and the MV predictors registered in the MV predictor list may include one or more types of MV predictors in addition to and different from the types given in the example in  FIG. 9B . 
     Note that the final MV may be determined by performing DMVR processing (to be described later) by using the MV of the current block derived via merge mode. 
     Here, an example of determining an MV by using DMVR processing will be given. 
       FIG. 9C  is a conceptual diagram for illustrating an outline of DMVR processing. 
     First, the most appropriate MVP set for the current block is considered to be the candidate MV, reference pixels are obtained from a first reference picture, which is a picture processed in the L0 direction in accordance with the candidate MV, and a second reference picture, which is a picture processed in the L1 direction in accordance with the candidate MV, and a template is generated by calculating the average of the reference pixels. 
     Next, using the template, the surrounding regions of the candidate MVs of the first and second reference pictures are searched, and the MV with the lowest cost is determined to be the final MV. Note that the cost value is calculated using, for example, the difference between each pixel value in the template and each pixel value in the regions searched, as well as the MV value. 
     Note that the outlines of the processes described here are fundamentally the same in both the encoder and the decoder. 
     Note that processing other than the processing exactly as described above may be used, so long as the processing is capable of deriving the final MV by searching the surroundings of the candidate MV. 
     Here, an example of a mode that generates a prediction image by using LIC processing will be given. 
       FIG. 9D  is for illustrating an outline of a prediction image generation method using a luminance correction process performed via LIC processing. 
     First, an MV is extracted for obtaining, from an encoded reference picture, a reference image corresponding to the current block. 
     Next, information indicating how the luminance value changed between the reference picture and the current picture is extracted and a luminance correction parameter is calculated by using the luminance pixel values for the encoded left neighboring reference region and the encoded upper neighboring reference region, and the luminance pixel value in the same location in the reference picture specified by the MV. 
     The prediction image for the current block is generated by performing a luminance correction process by using the luminance correction parameter on the reference image in the reference picture specified by the MV. 
     Note that the shape of the surrounding reference region illustrated in  FIG. 9D  is just one example; the surrounding reference region may have a different shape. 
     Moreover, although a prediction image is generated from a single reference picture in this example, in cases in which a prediction image is generated from a plurality of reference pictures as well, the prediction image is generated after performing a luminance correction process, via the same method, on the reference images obtained from the reference pictures. 
     One example of a method for determining whether to implement LIC processing is by using an lic_flag, which is a signal that indicates whether to implement LIC processing. As one specific example, the encoder determines whether the current block belongs to a region of luminance change. The encoder sets the lic_flag to a value of “1” when the block belongs to a region of luminance change and implements LIC processing when encoding, and sets the lic_flag to a value of “0” when the block does not belong to a region of luminance change and encodes without implementing LIC processing. The decoder switches between implementing LIC processing or not by decoding the lic_flag written in the stream and performing the decoding in accordance with the flag value. 
     One example of a different method of determining whether to implement LIC processing is determining so in accordance with whether LIC processing was determined to be implemented for a surrounding block. In one specific example, when merge mode is used on the current block, whether LIC processing was applied in the encoding of the surrounding encoded block selected upon deriving the MV in the merge mode processing may be determined, and whether to implement LIC processing or not can be switched based on the result of the determination. Note that in this example, the same applies to the processing performed on the decoder side. 
     [Decoder Outline] 
     Next, a decoder capable of decoding an encoded signal (encoded bitstream) output from encoder  100  will be described.  FIG. 10  is a block diagram illustrating a functional configuration of decoder  200  according to Embodiment 1. Decoder  200  is a moving picture/picture decoder that decodes a moving picture/picture block by block. 
     As illustrated in  FIG. 10 , decoder  200  includes entropy decoder  202 , inverse quantizer  204 , inverse transformer  206 , adder  208 , block memory  210 , loop filter  212 , frame memory  214 , intra predictor  216 , inter predictor  218 , and prediction controller  220 . 
     Decoder  200  is realized as, for example, a generic processor and memory. In this case, when a software program stored in the memory is executed by the processor, the processor functions as entropy decoder  202 , inverse quantizer  204 , inverse transformer  206 , adder  208 , loop filter  212 , intra predictor  216 , inter predictor  218 , and prediction controller  220 . Alternatively, decoder  200  may be realized as one or more dedicated electronic circuits corresponding to entropy decoder  202 , inverse quantizer  204 , inverse transformer  206 , adder  208 , loop filter  212 , intra predictor  216 , inter predictor  218 , and prediction controller  220 . 
     Hereinafter, each component included in decoder  200  will be described. 
     [Entropy Decoder] 
     Entropy decoder  202  entropy decodes an encoded bitstream. More specifically, for example, entropy decoder  202  arithmetic decodes an encoded bitstream into a binary signal. Entropy decoder  202  then debinarizes the binary signal. With this, entropy decoder  202  outputs quantized coefficients of each block to inverse quantizer  204 . 
     [Inverse Quantizer] 
     Inverse quantizer  204  inverse quantizes quantized coefficients of a block to be decoded (hereinafter referred to as a current block), which are inputs from entropy decoder  202 . More specifically, inverse quantizer  204  inverse quantizes quantized coefficients of the current block based on quantization parameters corresponding to the quantized coefficients. Inverse quantizer  204  then outputs the inverse quantized coefficients (i.e., transform coefficients) of the current block to inverse transformer  206 . 
     [Inverse Transformer] 
     Inverse transformer  206  restores prediction errors by inverse transforming transform coefficients, which are inputs from inverse quantizer  204 . 
     For example, when information parsed from an encoded bitstream indicates application of EMT or AMT (for example, when the AMT flag is set to true), inverse transformer  206  inverse transforms the transform coefficients of the current block based on information indicating the parsed transform type. 
     Moreover, for example, when information parsed from an encoded bitstream indicates application of NSST, inverse transformer  206  applies a secondary inverse transform to the transform coefficients. 
     [Adder] 
     Adder  208  reconstructs the current block by summing prediction errors, which are inputs from inverse transformer  206 , and prediction samples, which is an input from prediction controller  220 . Adder  208  then outputs the reconstructed block to block memory  210  and loop filter  212 . 
     [Block Memory] 
     Block memory  210  is storage for storing blocks in a picture to be decoded (hereinafter referred to as a current picture) for reference in intra prediction. More specifically, block memory  210  stores reconstructed blocks output from adder  208 . 
     [Loop Filter] 
     Loop filter  212  applies a loop filter to blocks reconstructed by adder  208 , and outputs the filtered reconstructed blocks to frame memory  214  and, for example, a display device. 
     When information indicating the enabling or disabling of ALF parsed from an encoded bitstream indicates enabled, one filter from among a plurality of filters is selected based on direction and activity of local gradients, and the selected filter is applied to the reconstructed block. 
     [Frame Memory] 
     Frame memory  214  is storage for storing reference pictures used in inter prediction, and is also referred to as a frame buffer. More specifically, frame memory  214  stores reconstructed blocks filtered by loop filter  212 . 
     [Intra Predictor] 
     Intra predictor  216  generates a prediction signal (intra prediction signal) by intra prediction with reference to a block or blocks in the current picture and stored in block memory  210 . More specifically, intra predictor  216  generates an intra prediction signal by intra prediction with reference to samples (for example, luma and/or chroma values) of a block or blocks neighboring the current block, and then outputs the intra prediction signal to prediction controller  220 . 
     Note that when an intra prediction mode in which a chroma block is intra predicted from a luma block is selected, intra predictor  216  may predict the chroma component of the current block based on the luma component of the current block. 
     Moreover, when information indicating the application of PDPC is parsed from an encoded bitstream, intra predictor  216  corrects post-intra-prediction pixel values based on horizontal/vertical reference pixel gradients. 
     [Inter Predictor] 
     Inter predictor  218  predicts the current block with reference to a reference picture stored in frame memory  214 . Inter prediction is performed per current block or per sub-block (for example, per 4×4 block) in the current block. For example, inter predictor  218  generates an inter prediction signal of the current block or sub-block by motion compensation by using motion information (for example, a motion vector) parsed from an encoded bitstream, and outputs the inter prediction signal to prediction controller  220 . 
     Note that when the information parsed from the encoded bitstream indicates application of OBMC mode, inter predictor  218  generates the inter prediction signal using motion information for a neighboring block in addition to motion information for the current block obtained from motion estimation. 
     Moreover, when the information parsed from the encoded bitstream indicates application of FRUC mode, inter predictor  218  derives motion information by performing motion estimation in accordance with the pattern matching method (bilateral matching or template matching) parsed from the encoded bitstream. Inter predictor  218  then performs motion compensation using the derived motion information. 
     Moreover, when BIO mode is to be applied, inter predictor  218  derives a motion vector based on a model assuming uniform linear motion. Moreover, when the information parsed from the encoded bitstream indicates that affine motion compensation prediction mode is to be applied, inter predictor  218  derives a motion vector of each sub-block based on motion vectors of neighboring blocks. 
     [Prediction Controller] 
     Prediction controller  220  selects either the intra prediction signal or the inter prediction signal, and outputs the selected prediction signal to adder  208 . 
     [A Transform Process, a Quantization Process, an Encoding Process in an Encoder] 
     Next, a transform process, a quantization process, and an encoding process performed by transformer  106 , quantizer  108 , and entropy encoder  110  of encoder  100  configured as described above are specifically described with reference to the drawings. 
       FIG. 11  is a flow chart indicating one example of a transform process, a quantization process, and an encoding process according to Embodiment 1. Each of the steps indicated in  FIG. 11  is performed by transformer  106 , quantizer  108 , or entropy encoder  110  of encoder  100  according to Embodiment 1. 
     First, transformer  106  performs a primary transform of a current block to be encoded from residuals to primary coefficients (S 101 ). The primary transform is, for example, a separable transform. Specifically, the primary transform is, for example, one of DCT and DST. 
     Next, transformer  106  determines whether to perform a secondary transform on the primary coefficients (S 102 ). In other words, transformer  106  determines whether to apply a secondary transform on the current block. For example, transformer  106  determines whether to perform a secondary transform based on cost based on a difference between an original image and a reconstructed image and/or a coding amount. It is to be noted that determinations on whether to perform a secondary transform is not limited to such a determination based on cost. For example, whether to perform a secondary transform may be determined based on a prediction mode, a block size, a picture type, or any combination of these. 
     Here, when it is determined that a secondary transform is not performed (No in S 102 ), quantizer  108  calculates quantized primary coefficients by performing a first quantization on the primary coefficients (S 103 ). The primary quantization is a weighted quantization using a first quantization matrix. In the first quantization, a quantization step in which weighting is performed for each coefficient by the first quantization matrix is used. The first quantization matrix is a weighting matrix for adjusting the magnitude of the quantization step for each coefficient. The size of the first quantization matrix matches the size of the current block. In other words, the number of components of the first quantization matrix matches the number of coefficients of the current block. 
     When it is determined that a secondary transform is to be performed (Yes in S 102 ), transformer  106  performs a secondary transform from the primary coefficients to the secondary coefficients (S 104 ). In the secondary transform, a basis different from the basis in the primary transform is used. For example, the secondary transform is a non-separable transform. The bases for use in a secondary transform are defined in advance, for example, in a standard. 
     Quantizer  108  then calculates quantized secondary coefficients by performing a second quantization different from a first quantization on the secondary coefficients (S 105 ). The second quantization different from the first quantization means that either parameters or quantization approaches for use in quantization are different between the first quantization and the second quantization. The parameters for use in quantization are, for example, quantization matrices or quantization parameters. 
     In this embodiment, the second quantization is different from the first quantization in quantization parameter used for quantization. Specifically, the second quantization is a weighted quantization using a second quantization matrix different from a first quantization matrix. In the second quantization, a quantization step in which weighting is performed for each coefficient by the second quantization matrix is used. 
     The second quantization matrix is a weighting matrix for adjusting the magnitude of the quantization step for each coefficient. The second quantization matrix has component values different from those of the first quantization matrix. The size of the second quantization matrix matches the size of the current block. In other words, the number of components of the second quantization matrix matches the number of coefficients of the current block. 
     Entropy encoder  110  generates an encoded bitstream by entropy encoding either quantized primary coefficients or quantized secondary coefficients (S 106 ). At this time, entropy encoder  110  writes the first quantization matrix and the second quantization matrix into an encoded bitstream. 
     When a secondary transform is performed on only one or more first primary coefficients included in primary coefficients in a current block, it is to be noted that only one or more first component values of the second quantization matrix corresponding to the one or more first primary coefficients on which the secondary transform is performed may be written into an encoded bitstream, and each of one or more second component values of the second quantization matrix corresponding to the one or more second primary coefficients on which a secondary transform is not performed may be common with the component values corresponding to those of the first quantization matrix without being written into the encoded bitstream. In other words, each of the one or more second component values of the second quantization matrix may match the corresponding component values of the first quantization matrix. It is to be noted that the one or more first primary coefficients are, for example, coefficients in a low-frequency region, and the one or more second primary coefficients are, for example, y coefficients in a high-frequency region. 
     In addition, entropy encoder  110  may write information indicating whether to apply a secondary transform to the current block into the encoded bitstream. 
     It is to be noted that the positions of the first quantization matrix and the second quantization matrix are not particularly limited. For example, as indicated in  FIG. 12 , the first quantization matrix and the second quantization matrix may be written in (i) a video parameter set (VPS), (ii) a sequence parameter set (SPS), (iii) a picture parameter set (PPS), (iv) a slice header, or (v) a video system setting parameter. 
     In this way, in this embodiment, a different quantization is performed between the case in which a secondary transform is performed and the other case. In other words, quantizer  108  switches between a first quantization and a second quantization based on application/non-application of a secondary transform on the current block. In particular, in this embodiment, different quantization matrices are used between the case in which a secondary transform is performed and the other case. In other words, in this embodiment, quantizer  108  performs a quantization while switching between the first quantization matrix and the second quantization matrix based on application/non-application of a secondary transform on the current block. 
     [A Decoding Process, an Inverse Quantization Process, and an Inverse Transform Process in a Decoder] 
     Next, a decoding process, an inverse quantization process, and an inverse transform process performed by entropy decoder  202 , inverse quantizer  204 , and inverse transformer  206  of decoder  200  according to this embodiment are specifically described with reference to the drawings. 
       FIG. 13  is a flow chart indicating one example of a decoding process, an inverse quantization process, and an inverse transform process according to Embodiment 1. Each of the steps indicated in  FIG. 13  is performed by entropy decoder  202 , inverse quantizer  204 , or inverse transformer  206 . 
     First, entropy decoder  202  entropy decodes encoded quantized coefficients of a current block to be decoded from an encoded bitstream (S 201 ). The quantized coefficients decoded here are quantized primary coefficients or quantized secondary coefficients. In addition, here, entropy decoder  202  parses the first quantization matrix and the second quantization matrix from the encoded bitstream. When an inverse secondary transform is performed on only one or more first secondary coefficients included in secondary coefficients in the current block, it is to be noted that only one or more first component values of the second quantization matrix corresponding to the one or more first secondary coefficients on which the inverse secondary transform is performed may be parsed from an encoded bitstream, and each of one or more second component values of the second quantization matrix corresponding to the one or more second secondary coefficients on which an inverse secondary transform is not performed may be common with the component values corresponding to those of the first quantization value. In other words, each of the one or more second component values of the second quantization matrix may match the corresponding component values of the first quantization matrix. Furthermore, entropy decoder  202  may parse information indicating whether to apply an inverse secondary transform on the current block from the encoded bitstream. 
     Inverse transformer  206  determines whether to perform an inverse secondary transform based on the encoded bitstream (S 202 ). In other words, inverse transformer  206  determines whether to apply an inverse secondary transform on the current block. For example, inverse transformer  206  determines whether to perform an inverse secondary transform based on information indicating whether to apply the inverse secondary transform parsed from the encoded bitstream. 
     Here, when it is determined that the inverse secondary transform is not to be performed (No in S 202 ), inverse quantizer  204  calculates primary coefficients by performing a first inverse quantization on the decoded quantized coefficients (S 203 ). The first inverse quantization is a quantization inverse to the first quantization in encoder  100 . In this embodiment, the first inverse quantization is a weighted inverse quantization using the first quantization matrix. 
     When it is determined that the inverse secondary transform is to be performed (Yes in S 202 ), inverse quantizer  204  calculates secondary coefficients by performing a second inverse quantization different from the first inverse quantization on the decoded quantized coefficients (S 204 ). The second inverse quantization is a quantization inverse to the second quantization in encoder  100 . In this embodiment, the second inverse quantization is a weighted inverse quantization using the second quantization matrix. Inverse transformer  206  then performs an inverse secondary transform from the secondary coefficients calculated through the second inverse quantization to primary coefficients (S 205 ). The inverse secondary transform is a transform inverse to the secondary transform in encoder  100 . 
     Inverse transformer  206  performs an inverse primary transform from the primary coefficients obtained through either an inverse secondary transform or a first inverse quantization to residuals of the current block (S 206 ). The inverse primary transform is a transform inverse to the primary transform in encoder  100 . 
     In this way, in this embodiment, different inverse quantization processes are performed between the case in which an inverse secondary transform is performed and the other case. In other words, inverse quantizer  204  switches between the first inverse quantization and the second inverse quantization based on application/non-application of the inverse secondary transform on the current block. In particular, in this embodiment, different quantization matrices are used between the case in which the inverse secondary transform is performed and the other case. In other words, in this embodiment, inverse quantizer  204  performs inverse quantization processes while switching between the first quantization matrix and the second quantization matrix based on application/non-application of an inverse secondary transform. 
     [Effects, etc.] 
     As described above, encoder  100  and decoder  200  according to this embodiment are capable of performing a different quantization/inverse quantization depending on application/non-application of a secondary transform/an inverse secondary transform on a current block. The secondary coefficients obtained by performing a secondary transform of primary coefficients represented in a primary space are to be represented in a secondary space which is not the primary space. For this reason, it is difficult to increase coding efficiency while reducing decrease in subjective image quality even when a quantization/inverse quantization for the primary coefficients is applied to the secondary coefficients. For example, a quantization for reducing losses of components in a low-frequency region to reduce decrease in subjective image quality and increases losses of components in a high-frequency region to increase coding efficiency is different between the primary space and the secondary space. In view of this, it is possible to increase coding efficiency while reducing decrease in subjective image quality compared with the case of performing a common quantization/inverse quantization by performing a quantization/inverse quantization different depending on application/non-application of a secondary transform/inverse secondary transform on the current block. 
     In addition, encoder  100  and decoder  200  according to this embodiment are capable of performing a weighted quantization/inverse quantization using the first quantization matrix as the first quantization/first inverse quantization. Furthermore, it is possible to perform a weighted quantization/inverse quantization using the second quantization matrix different from the first quantization matrix, as the second quantization/second inverse quantization. Accordingly, it is possible to use the first quantization matrix corresponding to the first space in the quantization/inverse quantization for the primary coefficients, and to use the second quantization matrix corresponding to the secondary space in the quantization/inverse quantization for the secondary coefficients. Accordingly, in both the application and non-application of a secondary transform/inverse secondary transform, it is possible to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, encoder  100  and decoder  200  according to this embodiment are capable of including the first quantization matrix and the second quantization matrix in the encoded bitstream. Accordingly, it is possible to adaptively determine the first quantization matrix and the second quantization matrix according to an original image, and to further increase coding efficiency while reducing decrease in subjective image quality. 
     Although the first quantization matrix and the second quantization matrix are included in the encoded bitstream in this embodiment, this is a non-limiting example. For example, the first quantization matrix and the second quantization matrix may be transmitted from the encoder to the decoder separately from the encoded bitstream. In addition, for example, the first quantization matrix and the second quantization matrix may be defined in advance by a standard. At this time, the first quantization matrix and the second quantization matrix may be referred to as default matrices. In addition, for example, the first quantization matrix and the second quantization matrix may be selected from a plurality of default matrices based on a given profile, level, or the like. 
     In this way, it is not always necessary that the first quantization matrix and the second quantization matrix are included in the encoded bitstream, and thus it is possible to reduce the coding amount for the first quantization matrix and the second quantization matrix. 
     Although this embodiment describes the case where a single basis is fixedly used in the secondary transform/inverse secondary transform, this is a non-limiting example. For example, a plurality of predefined bases may be selectively used in the secondary transform/inverse secondary transform. In this case, for example, the encoded bitstream may include a plurality of second quantization matrices corresponding to a plurality of bases. Then, in the second quantization/second inverse quantization, the second quantization matrix corresponding to the bases which is used in the secondary transform/inverse secondary transform may be selected from the plurality of second quantization matrix. 
     In this way, it is possible to perform the second quantization/second inverse quantization using the second quantization matrix corresponding to a basis to be used in the secondary transform/inverse secondary transform. Features of the secondary space which represents the secondary coefficients are different depending on the basis to be used for the secondary transform/inverse secondary transform. Accordingly, by performing the second quantization/second inverse quantization using the second quantization matrix corresponding to the basis to be used for the secondary transform/inverse secondary transform, it is possible to perform the second quantization/second inverse quantization using the quantization matrix more suitable for the secondary space, and to increase coding efficiency while reducing subjective image quality. 
     Embodiment 2 
     Next, Embodiment 2 is described. This embodiment is different from Embodiment 1 in that a second quantization matrix to be used in a second quantization is derived from a first quantization matrix which is used in a first quantization. Hereinafter, this embodiment is described in detail with reference to the drawings, focusing on differences from Embodiment 1. 
     [A Transform Process, a Quantization Process, an Encoding Process in an Encoder] 
     A transform process, a quantization process, and an encoding process performed by transformer  106 , quantizer  108 , and entropy encoder  110  of encoder  100  according to Embodiment 2 are specifically described with reference to the drawings. 
       FIG. 14  is a flow chart indicating one example of a transform process, a quantization process, and an encoding process according to Embodiment 2. In  FIG. 14 , substantially the same processes as in  FIG. 11  are assigned with the same reference marks, and descriptions thereof are omitted as appropriate. 
     In this embodiment, after a secondary transform is performed (S 104 ), quantizer  108  derives a second quantization matrix from a first quantization matrix (S 111 ). For example, quantizer  108  derives the second quantization matrix by applying a secondary transform on the first quantization matrix. In other words, quantizer  108  transforms the first quantization matrix using a basis used in the secondary transform of a current block to be encoded. 
     When a secondary transform is performed on only one or more first primary coefficients included in primary coefficients in a current block, it is to be noted that one or more first component values of the second quantization matrix corresponding to the one or more first primary coefficients on which the secondary transform is performed may be derived from the first quantization matrix, and each of one or more second component values of the second quantization matrix corresponding to the one or more second primary coefficients on which a secondary transform is not performed may be common with the component values corresponding to those of the first quantization matrix. In other words, each of the one or more second component values of the second quantization matrix may match the corresponding component values of the first quantization matrix. 
     Quantizer  108  then calculates quantized secondary coefficients by performing a second quantization on the secondary coefficients (S 105 ). In this second quantization, the second quantization matrix derived in Step S 111  is used. 
     Entropy encoder  110  generates an encoded bitstream by entropy encoding either quantized primary coefficients or quantized secondary coefficients (S 112 ). Furthermore, in this embodiment, entropy encoder  110  writes the first quantization matrix into an encoded bitstream. On the other hand, entropy encoder  110  does not write the second quantization matrix into the encoded bitstream. 
     In this way, quantizer  108  performs quantization processes while switching between the first quantization matrix and the second quantization matrix based on application/non-application of a secondary transform on the current block. At this time, quantizer  108  derives the second quantization matrix from the first quantization matrix. 
     [A Decoding Process, an Inverse Quantization Process, and an Inverse Transform Process in a Decoder] 
     Next, a decoding process, an inverse quantization process, and an inverse transform process performed by entropy decoder  202 , inverse quantizer  204 , and inverse transformer  206  of decoder  200  according to this embodiment are specifically described with reference to the drawings. 
       FIG. 15  is a flow chart indicating one example of a decoding process, an inverse quantization process, and an inverse transform process according to Embodiment 2. In  FIG. 15 , substantially the same processes as in  FIG. 13  are assigned with the same reference marks, and descriptions thereof are omitted as appropriate. 
     First, entropy decoder  202  decodes encoded quantized coefficients included in an encoded bitstream (S 211 ). At this time, entropy decoder  202  parses a first quantization matrix from the encoded bitstream. 
     Inverse transformer  206  determines whether to perform an inverse secondary transform based on the encoded bitstream as in Embodiment 1 (S 202 ). Here, in the case where it is determined that the inverse secondary transform is not to be performed (No in S 202 ), inverse quantizer  204  performs a first inverse quantization on the decoded quantized coefficients as in Embodiment 1 (S 203 ). 
     In the other case where it is determined that the inverse secondary transform is to be performed (Yes in S 202 ), inverse quantizer  204  derives a second quantization matrix from the first quantization matrix (S 212 ). Specifically, inverse quantizer  204  derives the second quantization matrix using the same method as used by encoder  100 . For example, inverse quantizer  204  derives the second quantization matrix by applying a secondary transform on the first quantization matrix. In other words, inverse quantizer  204  transforms the first quantization matrix using a basis used in the secondary transform of a current block to be decoded. When an inverse secondary transform is performed on only one or more first secondary coefficients included in secondary coefficients in the current block, it is to be noted that only one or more first component values of the second quantization matrix corresponding to the one or more first secondary coefficients on which the inverse secondary transform is performed may be derived from the first quantization matrix, and each of one or more second component values of the second quantization matrix corresponding to the one or more second secondary coefficients on which the inverse secondary transform is not performed may be common with the component values corresponding to those of the first quantization matrix. In other words, each of the one or more second component values of the second quantization matrix may match the corresponding component values of the first quantization matrix. 
     Subsequently, the process in Step S 204  and the following steps are performed. 
     In this way, inverse quantizer  204  performs an inverse quantization while switching between the first quantization matrix and the second quantization matrix based on application/non-application of an inverse secondary transform on the current block. At this time, inverse quantizer  204  derives the second quantization matrix from the first quantization matrix. Accordingly, decoder  200  is capable of performing the second inverse quantization even when the second quantization matrix is not included in an encoded bitstream. 
     [Effects, etc.] 
     As described above, encoder  100  and decoder  200  according to this embodiment is capable of deriving the second quantization matrix from the first quantization matrix. This eliminates the necessity of transmitting the second quantization matrix to the decoder, which makes it possible to increase coding efficiency. 
     According to this, it is possible to derive the second quantization matrix by applying a secondary transform on the first quantization matrix. Accordingly, it is possible to transform the first quantization matrix corresponding to a primary space into the second quantization matrix corresponding to a secondary space, which makes it possible to increase coding efficiency while reducing decrease in subjective image quality. 
     Variation of Embodiment 2 
     Although an example of directly applying a secondary transform to the first quantization matrix as a method for deriving the second quantization matrix has been described in this embodiment, it is to be noted that this is a non-limiting example. Hereinafter, another example of a method for deriving a second quantization matrix is described with reference to  FIG. 16 . 
       FIG. 16  is a flow chart indicating one example of a process for deriving the second quantization matrix according to a variation of Embodiment 2. This flow chart indicates one example of the process in Step S 111  in  FIG. 14  and the process in Step S 212  in  FIG. 15 . 
     In  FIG. 16 , quantizer  108  and inverse quantizer  204  derive a third quantization matrix from a first quantization matrix (S 301 ). At this time, each of the component values of a third quantization matrix is greater when a corresponding component value in the first quantization matrix is smaller. In other words, the component value of the third quantization matrix decreases with increase in corresponding component value of the first quantization matrix. In other words, the component values of the first quantization matrix and the component values of the third quantization matrix have a monotonous decrease relationship. For example, each of the component values of the third quantization matrix is a reciprocal of the corresponding component value in the first quantization matrix. 
     Next, one of quantizer  108  and inverse quantizer  204  derives a fourth quantization matrix by applying a secondary transform to a third quantization matrix (S 302 ). In other words, one of quantizer  108  and inverse quantizer  204  transforms the third quantization matrix using a basis used in the secondary transform of a current block. 
     Lastly, one of quantizer  108  and inverse quantizer  204  derives a fifth quantization matrix from the fourth quantization matrix as the second quantization matrix (S 303 ). At this time, each of the component values of the fifth quantization matrix is greater when a corresponding component value of the fourth quantization matrix is smaller. In other words, the component value in the fourth quantization matrix decreases with increase in corresponding component value of the fifth quantization matrix. In other words, the component values of the fourth quantization matrix and the component values of the fifth quantization matrix have a monotonous decrease relationship. For example, each of the component values of the fifth quantization matrix is a reciprocal of the corresponding component value in the fourth quantization matrix. 
     By deriving the second quantization matrix as described above, it is possible to reduce influence of rounding error at the time of a secondary transform for components having a relatively small value included in the first quantization matrix. In other words, it is possible to reduce the influence of the rounding error on the component values to be applied to coefficients for which losses are desired to be small in order to reduce decrease in subjective image quality. Accordingly, it is possible to further reduce decrease in subjective image quality. 
     In addition, the reciprocals of the corresponding component values of the first quantization matrix/the fourth quantization matrix can be used as the component values of the third quantization matrix/the fifth quantization matrix. Accordingly, it is possible to derive the component values by simple calculation, which makes it possible to reduce processing load and processing time to derive the second quantization matrix. 
     Embodiment 3 
     Next, Embodiment 3 is described. This embodiment is different from Embodiment 1 in that secondary coefficients are quantized without using a quantization matrix when a secondary transform has been performed. Hereinafter, this embodiment is described in detail with reference to the drawings, focusing on differences from Embodiment 1. 
     [A Transform Process, a Quantization Process, an Encoding Process in an Encoder] 
     A transform process, a quantization process, and an encoding process performed by transformer  106 , quantizer  108 , and entropy encoder  110  of encoder  100  according to Embodiment 3 are specifically described with reference to the drawings. 
       FIG. 17  is a flow chart indicating one example of the transform process, the quantization process, and the encoding process according to Embodiment 3. In  FIG. 17 , substantially the same processes as in  FIG. 11  are assigned with the same reference marks, and descriptions thereof are omitted as appropriate. 
     After a secondary transform from primary coefficients to secondary coefficients is performed (S 104 ), quantizer  108  calculates quantized secondary coefficients by performing a second quantization different from a first quantization on secondary coefficients (S 121 ). In this embodiment, a second quantization is a non-weighted quantization in which no quantization matrix is used. In other words, the second quantization is intended to divide each of secondary coefficients of a current block to be encoded, using a quantization step common between the secondary coefficients. The common quantization step is derived from a quantization parameter for the current block. Specifically, the common quantization step is a single constant fixed for all the secondary coefficients of the current block. In other words, the common quantization step is a constant which does not depend on the positions or orders of the secondary coefficients. 
     In this way, in this embodiment, quantizer  108  switches between a weighted quantization and a non-weighted quantization, based on application/non-application of a secondary transform on the current block. 
     [A Decoding Process, an Inverse Quantization Process, and an Inverse Transform Process in a Decoder] 
     Next, a decoding process, an inverse quantization process, and an inverse transform process performed by entropy decoder  202 , inverse quantizer  204 , and inverse transformer  206  of decoder  200  according to Embodiment 3 are specifically described with reference to the drawings. 
       FIG. 18  is a flow chart indicating one example of the decoding process, the inverse quantization process, and the inverse transform process according to Embodiment 3. In  FIG. 18 , substantially the same processes as in  FIG. 13  are assigned with the same reference marks, and descriptions thereof are omitted as appropriate. 
     When it is determined that the inverse secondary transform is to be performed (Yes in S 202 ), inverse quantizer  204  calculates secondary coefficients by performing a second inverse quantization different from the first inverse quantization on the decoded quantized coefficients (S 221 ). The second inverse quantization is a quantization inverse to the second quantization in encoder  100 . In this embodiment, the second quantization is a non-weighted quantization in which no quantization matrix is used. 
     In this way, in this embodiment, inverse quantizer  204  switches between a weighted inverse quantization and a non-weighted inverse quantization, based on application/non-application of the inverse secondary transform on a current block to be decoded. 
     [Effects, etc.] 
     As described above, encoder  100  and decoder  200  according to this embodiment are capable of using the non-weighted quantization/inverse quantization as the second quantization/second inverse quantization. Accordingly, it is possible to skip a process for encoding and a process for deriving a quantization matrix for the second quantization while reducing decrease in subjective image quality due to use of the first quantization matrix for the first quantization/first inverse quantization as the second quantization/second inverse quantization. 
     Embodiment 4 
     Next, Embodiment 4 is described. This embodiment is different from Embodiment 3 in that a transform is performed after multiplying each of primary coefficients obtained through a primary transform by a corresponding component value of a weighting matrix. Hereinafter, this embodiment is described in detail with reference to the drawings, focusing on differences from Embodiment 3. 
     [A Transform Process, a Quantization Process, an Encoding Process in an Encoder] 
     A transform process, a quantization process, and an encoding process performed by transformer  106 , quantizer  108 , and entropy encoder  110  of encoder  100  according to Embodiment 4 are specifically described with reference to the drawings. 
       FIG. 19  is a flow chart indicating one example of the transform process, the quantization process, and the encoding process according to Embodiment 4.  FIG. 20  is a diagram for explaining one example of a secondary transform according to Embodiment 4. In  FIG. 19 , substantially the same processes as in  FIG. 17  are assigned with the same reference marks, and descriptions thereof are omitted as appropriate. 
     When it is determined that a secondary transform is to be performed (Yes in S 102 ), transformer  106  performs a secondary transform from primary coefficients to secondary coefficients (S 130 ). Specifically, as indicated in  FIG. 20 , in a secondary transform, transformer  106  calculates weighted primary coefficients by multiplying each of the primary coefficients by a corresponding component value of a weighting matrix (S 131 ). The weighting matrix is a matrix for performing weighting on the primary coefficients. Transformer  106  then transforms the weighted primary coefficients to secondary coefficients (S 132 ). This transform is substantially the same as the secondary transform in each of the above embodiments, and the weighted primary coefficients are transformed instead of the primary coefficients. 
     The weighting matrix may be derived from a first quantization matrix. In this case, for example, the component values of the weighting matrix and the component values of the first quantization matrix may have a monotonous decrease relationship. Specifically, for example, each of the component values of the weighting matrix may be a reciprocal of the corresponding component value of the first quantization matrix. In this way, it is possible to use the first quantization matrix for weighting with a quantization step to a weighting matrix for weighting coefficients. 
     In addition, the weighting matrix may be included in an encoded bitstream, or may be defined in advance in a standard. In addition, in a standard, a plurality of weighed matrices may be defined. In this case, a weighting matrix may be selected from the plurality of weighing matrices defined in advance, based on a given profile, level, or the like. 
     Quantizer  108  then calculates quantized secondary coefficients by performing a second quantization different from first quantization on the secondary coefficients (S 121 ). In this embodiment, a second quantization is a non-weighted quantization in which no quantization matrix is used. In other words, the second quantization is intended to divide each of secondary coefficients of a current block to be encoded, using a quantization step common between the secondary coefficients. At this time, for example, a common quantization step may be derived from a quantization parameter for a current block to be encoded, by quantizer  108 . 
     [A Decoding Process, an Inverse Quantization Process, and an Inverse Transform Process in a Decoder] 
     Next, a decoding process, an inverse quantization process, and an inverse transform process performed by entropy decoder  202 , inverse quantizer  204 , and inverse transformer  206  of decoder  200  according to Embodiment 4 are specifically described with reference to the drawings. 
       FIG. 21  is a flow chart indicating one example of the decoding process, the inverse quantization process, and the inverse transform process according to Embodiment 4.  FIG. 22  is a diagram for explaining one example of an inverse secondary transform according to Embodiment 4. In  FIG. 21 , substantially the same processes as in  FIG. 18  are assigned with the same reference marks, and descriptions thereof are omitted as appropriate. 
     When it is determined that the inverse secondary transform is to be performed (Yes in S 202 ), inverse quantizer  204  calculates secondary coefficients by performing a second inverse quantization different from the first inverse quantization on the decoded quantized coefficients (S 221 ). The second inverse quantization is a quantization inverse to the second quantization in encoder  100 . In this embodiment, the second quantization is a non-weighted quantization in which no quantization matrix is used. In other words, as indicated in  FIG. 22 , inverse quantizer  204  calculates secondary coefficients by multiplying each of quantized coefficients of a current block to be decoded by a quantization step common between the quantized coefficients. At this time, for example, the common quantization step may be derived from a quantization parameter for the current block. 
     Next, inverse transformer  206  performs an inverse secondary transform from secondary coefficients to primary coefficients (S 230 ). Specifically, as indicated in  FIG. 22 , inverse transformer  206  performs an inverse transform from secondary coefficients to weighted primary coefficients (S 231 ). This inverse transform is an inverse transform from weighed primary coefficients to secondary coefficients in encoder  100  (S 132 ). 
     Furthermore, inverse transformer  206  calculates primary coefficients by dividing each of weighted primary coefficients by a corresponding component value in a weighting matrix (S 232 ). This weighting matrix matches a weighting matrix used in encoder  100 . 
     The weighting matrix may be derived from a first quantization matrix by inverse quantizer  204 . In this case, for example, the component values of the weighting matrix and the component values of the first quantization matrix may have a monotonous decrease relationship. Specifically, for example, each of the component values of the weighting matrix may be a reciprocal of a corresponding component value of the first quantization matrix. 
     In addition, the weighting matrix may be included in an encoded bitstream, or may be defined in advance in a standard. In addition, a plurality of weighting matrices may be defined in advance in a standard. In this case, a weighting matrix may be selected from the plurality of weighing matrices defined in advance, based on a given profile, level, or the like. 
     [Effects, etc.] 
     As described above, encoder  100  according to this embodiment is capable of calculating weighted primary coefficients by multiplying each of the primary coefficients by a corresponding component value of the weighting matrix. In addition, decoder  200  according to this embodiment is capable of calculating primary coefficients by dividing each of the weighted primary coefficients with a corresponding component value of the weighting matrix. In other words, encoder  100  and decoder  200  according to this embodiment are capable of performing the weighting related to the quantization on the primary coefficients before being subjected to the secondary transform. Accordingly, it is possible to perform the quantization/inverse quantization equivalent to the weighted quantization/inverse quantization without newly preparing a quantization matrix corresponding to the secondary space when the secondary transform/inverse secondary transform is to be performed. As a result, it is possible to increase coding efficiency while reducing decrease in subjective image quality. 
     In addition, encoder  100  and decoder  200  according to this embodiment are capable of deriving the weighting matrix from the first quantization matrix. Accordingly, it is possible to reduce the coding amount for the weighting matrix, which makes it possible to reduce coding efficiency while reducing decrease in subjective image quality. 
     In addition, encoder  100  and decoder  200  according to this embodiment are capable of deriving a quantization step common between the secondary coefficients in a current block from a quantization parameter. Accordingly, new information for the common quantization step may be included in an encoded stream, which makes it possible to reduce the coding amount for the common quantization step. 
     Embodiment 5 
     Next, Embodiment 5 is described. This embodiment is different from each of the above embodiments in that a quantization is performed on primary coefficients before a secondary transform when a secondary transform is applied. Hereinafter, this embodiment is described in detail with reference to the drawings, focusing on differences from each of the above embodiments. 
     [A Transform Process, a Quantization Process, an Encoding Process in an Encoder] 
     A transform process, a quantization process, and an encoding process performed by transformer  106 , quantizer  108 , and entropy encoder  110  of encoder  100  according to Embodiment 5 are specifically described with reference to the drawings. 
       FIG. 23  is a flow chart indicating one example of the transform process, the quantization process, and the encoding process according to Embodiment 5. In  FIG. 23 , substantially the same processes as in  FIG. 11  are assigned with the same reference marks, and descriptions thereof are omitted as appropriate. 
     Here, in the case where it is determined that a secondary transform is not to be performed (No in S 102 ), quantizer  108  calculates quantized primary coefficients by performing a first quantization on the primary coefficients (S 141 ). 
     In the other case where it is determined that the secondary transform is to be performed (Yes in S 102 ), quantizer  108  calculates second quantized primary coefficients by performing a second quantization on primary coefficients (S 142 ). In this embodiment, a first quantization and a second quantization may be different from each other as in Embodiments 1 to 4 or may be the same. In other words, in this embodiment, the same processes may be performed using the same quantization matrix in the first quantization and the second quantization. Subsequently, transformer  106  performs a secondary transform from second quantized primary coefficients to quantized secondary coefficients (S 143 ). 
     Entropy encoder  110  generates an encoded bitstream by entropy encoding either first quantized primary coefficients or quantized secondary coefficients (S 106 ). 
     In this way, in this embodiment, the second quantization is performed before the secondary transform when the secondary transform is applied on the current block. In other words, the second quantization is performed on the primary coefficients. 
     [A Decoding Process, an Inverse Quantization Process, and an Inverse Transform Process in a Decoder] 
     Next, a decoding process, an inverse quantization process, and an inverse transform process performed by entropy decoder  202 , inverse quantizer  204 , and inverse transformer  206  of decoder  200  according to Embodiment 5 are specifically described with reference to the drawings. 
       FIG. 24  is a flow chart indicating one example of the decoding process, the inverse quantization process, and the inverse transform process according to Embodiment 5. In  FIG. 24 , substantially the same processes as in  FIG. 13  are assigned with the same reference marks, and descriptions thereof are omitted as appropriate. 
     Here, in the case where it is determined that an inverse secondary transform is not to be performed (No in S 202 ), inverse quantizer  204  calculates primary coefficients by performing a first inverse quantization on the decoded quantized coefficients (S 241 ). The first inverse quantization is a quantization inverse to the first quantization in encoder  100 . 
     In the other case where it is determined that an inverse secondary transform is to be performed (Yes in S 202 ), inverse transformer  206  performs an inverse secondary transform from decoded quantized coefficients to quantized primary coefficients (S 242 ). The inverse secondary transform is a transform inverse to the secondary transform in encoder  100 . Subsequently, inverse quantizer  204  calculates primary coefficients by performing a second inverse quantization on quantized primary coefficients (S 243 ). The second inverse quantization is a quantization inverse to the second quantization in encoder  100 . Accordingly, the second inverse quantization is the same as the first inverse quantization when the second quantization is the same as the first quantization. 
     In this way, in this embodiment, the second inverse quantization is performed after the inverse secondary transform when the inverse secondary transform is performed on a current block to be decoded. In other words, the second inverse quantization is performed on the quantized primary coefficients. 
     [Effects, etc.] 
     According to this, since encoder  100  and decoder  200  according to this embodiment are capable of performing the quantization before the secondary transform, a secondary transform can be excluded from the prediction process loop when the secondary transform process is a loss-less process. Accordingly, the load for the processing pipeline can be reduced. In addition, performing the quantization before the secondary transform eliminates the necessity of selectively using the first quantization matrix and the second quantization matrix, which makes it possible to simplify the process. 
     Variation 
     Although one or more encoders and decoders according to the one or more aspects of the present disclosure have been described based on the embodiments, the present disclosure is not limited to the embodiments. The one or more aspects of the present disclosure may encompass embodiments obtainable by adding various kinds of modifications that any person skilled in the art would arrive at to the embodiments and embodiments configurable by combining constituent elements in different embodiments within the scope of the present disclosure. 
     For example, although the second quantization matrix is derived after the secondary transform or after the determination of an inverse secondary transform in Embodiment 2, this is a non-limiting example. A second quantization matrix may be derived anytime in a period after a first quantization matrix is obtained and before a second quantization/inverse quantization. For example, a second quantization matrix may be derived at the time of starting encoding or decoding of a current picture including a current block. In this case, a second quantization matrix does not always need to be derived for each block. 
     Although encoding/decoding of a single current block to be encoded/decoded has been mainly described in each of the embodiments, it is to be noted that (i) the transform process, the quantization process, and the encoding process, or (ii) the decoding process, the inverse quantization process, and the inverse transform process described above can be applied to a plurality of blocks included in the current picture to be encoded/a plurality of blocks included in the current picture to be decoded. In this case, a first quantization matrix and a second quantization matrix corresponding to the following may be used: a prediction mode (for example, intra prediction or inter prediction), the type of a pixel value (for example, luminance or chrominance), a block size, or any combination of these. 
     It is to be noted that a quantization switching process based on application/non-application of a secondary transform in each embodiment may be on/off at a slice level, a tile level, a CTU level, or a CU level. In addition, on/off may be determined according to a frame type (I-frame, P-frame, or B-frame) and/or a prediction mode. 
     In addition, a quantization switching process based on application/non-application in each embodiment may be performed one or both of a luminance block and a chrominance block. 
     Although whether to perform the secondary transform is made after the primary transform in each of the above embodiments, this is a non-limiting example. Whether to perform a secondary transform may be made in advance before processing a current block to be encoded. 
     In addition, a first quantization matrix and a second quantization matrix do not always need to be different from each other. 
     Embodiment 6 
     As described in each of the above embodiments, each functional block can typically be realized as an MPU and memory, for example. Moreover, processes performed by each of the functional blocks are typically realized by a program execution unit, such as a processor, reading and executing software (a program) recorded on a recording medium such as ROM. The software may be distributed via, for example, downloading, and may be recorded on a recording medium such as semiconductor memory and distributed. Note that each functional block can, of course, also be realized as hardware (dedicated circuit). 
     Moreover, the processing described in each of the embodiments may be realized via integrated processing using a single apparatus (system), and, alternatively, may be realized via decentralized processing using a plurality of apparatuses. Moreover, the processor that executes the above-described program may be a single processor or a plurality of processors. In other words, integrated processing may be performed, and, alternatively, decentralized processing may be performed. 
     Embodiments of the present disclosure are not limited to the above exemplary embodiments; various modifications may be made to the exemplary embodiments, the results of which are also included within the scope of the embodiments of the present disclosure. 
     Next, application examples of the moving picture encoding method (image encoding method) and the moving picture decoding method (image decoding method) described in each of the above embodiments and a system that employs the same will be described. The system is characterized as including an image encoder that employs the image encoding method, an image decoder that employs the image decoding method, and an image encoder/decoder that includes both the image encoder and the image decoder. Other configurations included in the system may be modified on a case-by-case basis. 
     Usage Examples 
       FIG. 25  illustrates an overall configuration of content providing system ex 100  for implementing a content distribution service. The area in which the communication service is provided is divided into cells of desired sizes, and base stations ex 106 , ex 107 , ex 108 , ex 109 , and ex 110 , which are fixed wireless stations, are located in respective cells. 
     In content providing system ex 100 , devices including computer ex 111 , gaming device ex 112 , camera ex 113 , home appliance ex 114 , and smartphone ex 115  are connected to internet ex 101  via internet service provider ex 102  or communications network ex 104  and base stations ex 106  through ex 110 . Content providing system ex 100  may combine and connect any combination of the above elements. The devices may be directly or indirectly connected together via a telephone network or near field communication rather than via base stations ex 106  through ex 110 , which are fixed wireless stations. Moreover, streaming server ex 103  is connected to devices including computer ex 111 , gaming device ex 112 , camera ex 113 , home appliance ex 114 , and smartphone ex 115  via, for example, internet ex 101 . Streaming server ex 103  is also connected to, for example, a terminal in a hotspot in airplane ex 117  via satellite ex 116 . 
     Note that instead of base stations ex 106  through ex 110 , wireless access points or hotspots may be used. Streaming server ex 103  may be connected to communications network ex 104  directly instead of via internet ex 101  or internet service provider ex 102 , and may be connected to airplane ex 117  directly instead of via satellite ex 116 . 
     Camera ex 113  is a device capable of capturing still images and video, such as a digital camera. Smartphone ex 115  is a smartphone device, cellular phone, or personal handyphone system (PHS) phone that can operate under the mobile communications system standards of the typical 2G, 3G, 3.9G, and 4G systems, as well as the next-generation 5G system. 
     Home appliance ex 118  is, for example, a refrigerator or a device included in a home fuel cell cogeneration system. 
     In content providing system ex 100 , a terminal including an image and/or video capturing function is capable of, for example, live streaming by connecting to streaming server ex 103  via, for example, base station ex 106 . When live streaming, a terminal (e.g., computer ex 111 , gaming device ex 112 , camera ex 113 , home appliance ex 114 , smartphone ex 115 , or airplane ex 117 ) performs the encoding processing described in the above embodiments on still-image or video content captured by a user via the terminal, multiplexes video data obtained via the encoding and audio data obtained by encoding audio corresponding to the video, and transmits the obtained data to streaming server ex 103 . In other words, the terminal functions as the image encoder according to one aspect of the present disclosure. 
     Streaming server ex 103  streams transmitted content data to clients that request the stream. Client examples include computer ex 111 , gaming device ex 112 , camera ex 113 , home appliance ex 114 , smartphone ex 115 , and terminals inside airplane ex 117 , which are capable of decoding the above-described encoded data. Devices that receive the streamed data decode and reproduce the received data. In other words, the devices each function as the image decoder according to one aspect of the present disclosure. 
     [Decentralized Processing] 
     Streaming server ex 103  may be realized as a plurality of servers or computers between which tasks such as the processing, recording, and streaming of data are divided. For example, streaming server ex 103  may be realized as a content delivery network (CDN) that streams content via a network connecting multiple edge servers located throughout the world. In a CDN, an edge server physically near the client is dynamically assigned to the client. Content is cached and streamed to the edge server to reduce load times. In the event of, for example, some kind of an error or a change in connectivity due to, for example, a spike in traffic, it is possible to stream data stably at high speeds since it is possible to avoid affected parts of the network by, for example, dividing the processing between a plurality of edge servers or switching the streaming duties to a different edge server, and continuing streaming. 
     Decentralization is not limited to just the division of processing for streaming; the encoding of the captured data may be divided between and performed by the terminals, on the server side, or both. In one example, in typical encoding, the processing is performed in two loops. The first loop is for detecting how complicated the image is on a frame-by-frame or scene-by-scene basis, or detecting the encoding load. The second loop is for processing that maintains image quality and improves encoding efficiency. For example, it is possible to reduce the processing load of the terminals and improve the quality and encoding efficiency of the content by having the terminals perform the first loop of the encoding and having the server side that received the content perform the second loop of the encoding. In such a case, upon receipt of a decoding request, it is possible for the encoded data resulting from the first loop performed by one terminal to be received and reproduced on another terminal in approximately real time. This makes it possible to realize smooth, real-time streaming. 
     In another example, camera ex 113  or the like extracts a feature amount from an image, compresses data related to the feature amount as metadata, and transmits the compressed metadata to a server. For example, the server determines the significance of an object based on the feature amount and changes the quantization accuracy accordingly to perform compression suitable for the meaning of the image. Feature amount data is particularly effective in improving the precision and efficiency of motion vector prediction during the second compression pass performed by the server. Moreover, encoding that has a relatively low processing load, such as variable length coding (VLC), may be handled by the terminal, and encoding that has a relatively high processing load, such as context-adaptive binary arithmetic coding (CABAC), may be handled by the server. 
     In yet another example, there are instances in which a plurality of videos of approximately the same scene are captured by a plurality of terminals in, for example, a stadium, shopping mall, or factory. In such a case, for example, the encoding may be decentralized by dividing processing tasks between the plurality of terminals that captured the videos and, if necessary, other terminals that did not capture the videos and the server, on a per-unit basis. The units may be, for example, groups of pictures (GOP), pictures, or tiles resulting from dividing a picture. This makes it possible to reduce load times and achieve streaming that is closer to real-time. 
     Moreover, since the videos are of approximately the same scene, management and/or instruction may be carried out by the server so that the videos captured by the terminals can be cross-referenced. Moreover, the server may receive encoded data from the terminals, change reference relationship between items of data or correct or replace pictures themselves, and then perform the encoding. This makes it possible to generate a stream with increased quality and efficiency for the individual items of data. 
     Moreover, the server may stream video data after performing transcoding to convert the encoding format of the video data. For example, the server may convert the encoding format from MPEG to VP, and may convert H.264 to H.265. 
     In this way, encoding can be performed by a terminal or one or more servers. Accordingly, although the device that performs the encoding is referred to as a “server” or “terminal” in the following description, some or all of the processes performed by the server may be performed by the terminal, and likewise some or all of the processes performed by the terminal may be performed by the server. This also applies to decoding processes. 
     [3D, Multi-Angle] 
     In recent years, usage of images or videos combined from images or videos of different scenes concurrently captured or the same scene captured from different angles by a plurality of terminals such as camera ex 113  and/or smartphone ex 115  has increased. Videos captured by the terminals are combined based on, for example, the separately-obtained relative positional relationship between the terminals, or regions in a video having matching feature points. 
     In addition to the encoding of two-dimensional moving pictures, the server may encode a still image based on scene analysis of a moving picture either automatically or at a point in time specified by the user, and transmit the encoded still image to a reception terminal. Furthermore, when the server can obtain the relative positional relationship between the video capturing terminals, in addition to two-dimensional moving pictures, the server can generate three-dimensional geometry of a scene based on video of the same scene captured from different angles. Note that the server may separately encode three-dimensional data generated from, for example, a point cloud, and may, based on a result of recognizing or tracking a person or object using three-dimensional data, select or reconstruct and generate a video to be transmitted to a reception terminal from videos captured by a plurality of terminals. 
     This allows the user to enjoy a scene by freely selecting videos corresponding to the video capturing terminals, and allows the user to enjoy the content obtained by extracting, from three-dimensional data reconstructed from a plurality of images or videos, a video from a selected viewpoint. Furthermore, similar to with video, sound may be recorded from relatively different angles, and the server may multiplex, with the video, audio from a specific angle or space in accordance with the video, and transmit the result. 
     In recent years, content that is a composite of the real world and a virtual world, such as virtual reality (VR) and augmented reality (AR) content, has also become popular. In the case of VR images, the server may create images from the viewpoints of both the left and right eyes and perform encoding that tolerates reference between the two viewpoint images, such as multi-view coding (MVC), and, alternatively, may encode the images as separate streams without referencing. When the images are decoded as separate streams, the streams may be synchronized when reproduced so as to recreate a virtual three-dimensional space in accordance with the viewpoint of the user. 
     In the case of AR images, the server superimposes virtual object information existing in a virtual space onto camera information representing a real-world space, based on a three-dimensional position or movement from the perspective of the user. The decoder may obtain or store virtual object information and three-dimensional data, generate two-dimensional images based on movement from the perspective of the user, and then generate superimposed data by seamlessly connecting the images. Alternatively, the decoder may transmit, to the server, motion from the perspective of the user in addition to a request for virtual object information, and the server may generate superimposed data based on three-dimensional data stored in the server in accordance with the received motion, and encode and stream the generated superimposed data to the decoder. Note that superimposed data includes, in addition to RGB values, an α value indicating transparency, and the server sets the a value for sections other than the object generated from three-dimensional data to, for example, 0, and may perform the encoding while those sections are transparent. Alternatively, the server may set the background to a predetermined RGB value, such as a chroma key, and generate data in which areas other than the object are set as the background. 
     Decoding of similarly streamed data may be performed by the client (i.e., the terminals), on the server side, or divided therebetween. In one example, one terminal may transmit a reception request to a server, the requested content may be received and decoded by another terminal, and a decoded signal may be transmitted to a device having a display. It is possible to reproduce high image quality data by decentralizing processing and appropriately selecting content regardless of the processing ability of the communications terminal itself. In yet another example, while a TV, for example, is receiving image data that is large in size, a region of a picture, such as a tile obtained by dividing the picture, may be decoded and displayed on a personal terminal or terminals of a viewer or viewers of the TV. This makes it possible for the viewers to share a big-picture view as well as for each viewer to check his or her assigned area or inspect a region in further detail up close. 
     In the future, both indoors and outdoors, in situations in which a plurality of wireless connections are possible over near, mid, and far distances, it is expected to be able to seamlessly receive content even when switching to data appropriate for the current connection, using a streaming system standard such as MPEG-DASH. With this, the user can switch between data in real time while freely selecting a decoder or display apparatus including not only his or her own terminal, but also, for example, displays disposed indoors or outdoors. Moreover, based on, for example, information on the position of the user, decoding can be performed while switching which terminal handles decoding and which terminal handles the displaying of content. This makes it possible to, while in route to a destination, display, on the wall of a nearby building in which a device capable of displaying content is embedded or on part of the ground, map information while on the move. Moreover, it is also possible to switch the bit rate of the received data based on the accessibility to the encoded data on a network, such as when encoded data is cached on a server quickly accessible from the reception terminal or when encoded data is copied to an edge server in a content delivery service. 
     [Scalable Encoding] 
     The switching of content will be described with reference to a scalable stream, illustrated in  FIG. 26 , that is compression coded via implementation of the moving picture encoding method described in the above embodiments. The server may have a configuration in which content is switched while making use of the temporal and/or spatial scalability of a stream, which is achieved by division into and encoding of layers, as illustrated in  FIG. 26 . Note that there may be a plurality of individual streams that are of the same content but different quality. In other words, by determining which layer to decode up to based on internal factors, such as the processing ability on the decoder side, and external factors, such as communication bandwidth, the decoder side can freely switch between low resolution content and high resolution content while decoding. For example, in a case in which the user wants to continue watching, at home on a device such as a TV connected to the internet, a video that he or she had been previously watching on smartphone ex 115  while on the move, the device can simply decode the same stream up to a different layer, which reduces server side load. 
     Furthermore, in addition to the configuration described above in which scalability is achieved as a result of the pictures being encoded per layer and the enhancement layer is above the base layer, the enhancement layer may include metadata based on, for example, statistical information on the image, and the decoder side may generate high image quality content by performing super-resolution imaging on a picture in the base layer based on the metadata. Super-resolution imaging may be improving the SN ratio while maintaining resolution and/or increasing resolution. Metadata includes information for identifying a linear or a non-linear filter coefficient used in super-resolution processing, or information identifying a parameter value in filter processing, machine learning, or least squares method used in super-resolution processing. 
     Alternatively, a configuration in which a picture is divided into, for example, tiles in accordance with the meaning of, for example, an object in the image, and on the decoder side, only a partial region is decoded by selecting a tile to decode, is also acceptable. Moreover, by storing an attribute about the object (person, car, ball, etc.) and a position of the object in the video (coordinates in identical images) as metadata, the decoder side can identify the position of a desired object based on the metadata and determine which tile or tiles include that object. For example, as illustrated in  FIG. 27 , metadata is stored using a data storage structure different from pixel data such as an SEI message in HEVC. This metadata indicates, for example, the position, size, or color of the main object. 
     Moreover, metadata may be stored in units of a plurality of pictures, such as stream, sequence, or random access units. With this, the decoder side can obtain, for example, the time at which a specific person appears in the video, and by fitting that with picture unit information, can identify a picture in which the object is present and the position of the object in the picture. 
     [Web Page Optimization] 
       FIG. 28  illustrates an example of a display screen of a web page on, for example, computer ex 111 .  FIG. 29  illustrates an example of a display screen of a web page on, for example, smartphone ex 115 . As illustrated in  FIG. 28  and  FIG. 29 , a web page may include a plurality of image links which are links to image content, and the appearance of the web page differs depending on the device used to view the web page. When a plurality of image links are viewable on the screen, until the user explicitly selects an image link, or until the image link is in the approximate center of the screen or the entire image link fits in the screen, the display apparatus (decoder) displays, as the image links, still images included in the content or I pictures, displays video such as an animated gif using a plurality of still images or I pictures, for example, or receives only the base layer and decodes and displays the video. 
     When an image link is selected by the user, the display apparatus decodes giving the highest priority to the base layer. Note that if there is information in the HTML code of the web page indicating that the content is scalable, the display apparatus may decode up to the enhancement layer. Moreover, in order to guarantee real time reproduction, before a selection is made or when the bandwidth is severely limited, the display apparatus can reduce delay between the point in time at which the leading picture is decoded and the point in time at which the decoded picture is displayed (that is, the delay between the start of the decoding of the content to the displaying of the content) by decoding and displaying only forward reference pictures (I picture, P picture, forward reference B picture). Moreover, the display apparatus may purposely ignore the reference relationship between pictures and coarsely decode all B and P pictures as forward reference pictures, and then perform normal decoding as the number of pictures received over time increases. 
     [Autonomous Driving] 
     When transmitting and receiving still image or video data such two- or three-dimensional map information for autonomous driving or assisted driving of an automobile, the reception terminal may receive, in addition to image data belonging to one or more layers, information on, for example, the weather or road construction as metadata, and associate the metadata with the image data upon decoding. Note that metadata may be assigned per layer and, alternatively, may simply be multiplexed with the image data. 
     In such a case, since the automobile, drone, airplane, etc., including the reception terminal is mobile, the reception terminal can seamlessly receive and decode while switching between base stations among base stations ex 106  through ex 110  by transmitting information indicating the position of the reception terminal upon reception request. Moreover, in accordance with the selection made by the user, the situation of the user, or the bandwidth of the connection, the reception terminal can dynamically select to what extent the metadata is received or to what extent the map information, for example, is updated. 
     With this, in content providing system ex 100 , the client can receive, decode, and reproduce, in real time, encoded information transmitted by the user. 
     [Streaming of Individual Content] 
     In content providing system ex 100 , in addition to high image quality, long content distributed by a video distribution entity, unicast or multicast streaming of low image quality, short content from an individual is also possible. Moreover, such content from individuals is likely to further increase in popularity. The server may first perform editing processing on the content before the encoding processing in order to refine the individual content. This may be achieved with, for example, the following configuration. 
     In real-time while capturing video or image content or after the content has been captured and accumulated, the server performs recognition processing based on the raw or encoded data, such as capture error processing, scene search processing, meaning analysis, and/or object detection processing. Then, based on the result of the recognition processing, the server—either when prompted or automatically—edits the content, examples of which include: correction such as focus and/or motion blur correction; removing low-priority scenes such as scenes that are low in brightness compared to other pictures or out of focus; object edge adjustment; and color tone adjustment. The server encodes the edited data based on the result of the editing. It is known that excessively long videos tend to receive fewer views. Accordingly, in order to keep the content within a specific length that scales with the length of the original video, the server may, in addition to the low-priority scenes described above, automatically clip out scenes with low movement based on an image processing result. Alternatively, the server may generate and encode a video digest based on a result of an analysis of the meaning of a scene. 
     Note that there are instances in which individual content may include content that infringes a copyright, moral right, portrait rights, etc. Such an instance may lead to an unfavorable situation for the creator, such as when content is shared beyond the scope intended by the creator. Accordingly, before encoding, the server may, for example, edit images so as to blur faces of people in the periphery of the screen or blur the inside of a house, for example. Moreover, the server may be configured to recognize the faces of people other than a registered person in images to be encoded, and when such faces appear in an image, for example, apply a mosaic filter to the face of the person. Alternatively, as pre- or post-processing for encoding, the user may specify, for copyright reasons, a region of an image including a person or a region of the background be processed, and the server may process the specified region by, for example, replacing the region with a different image or blurring the region. If the region includes a person, the person may be tracked in the moving picture, and the head region may be replaced with another image as the person moves. 
     Moreover, since there is a demand for real-time viewing of content produced by individuals, which tends to be small in data size, the decoder first receives the base layer as the highest priority and performs decoding and reproduction, although this may differ depending on bandwidth. When the content is reproduced two or more times, such as when the decoder receives the enhancement layer during decoding and reproduction of the base layer and loops the reproduction, the decoder may reproduce a high image quality video including the enhancement layer. If the stream is encoded using such scalable encoding, the video may be low quality when in an unselected state or at the start of the video, but it can offer an experience in which the image quality of the stream progressively increases in an intelligent manner. This is not limited to just scalable encoding; the same experience can be offered by configuring a single stream from a low quality stream reproduced for the first time and a second stream encoded using the first stream as a reference. 
     Other Usage Examples 
     The encoding and decoding may be performed by LSI ex 500 , which is typically included in each terminal. LSI ex 500  may be configured of a single chip or a plurality of chips. Software for encoding and decoding moving pictures may be integrated into some type of a recording medium (such as a CD-ROM, a flexible disk, or a hard disk) that is readable by, for example, computer ex 111 , and the encoding and decoding may be performed using the software. Furthermore, when smartphone ex 115  is equipped with a camera, the video data obtained by the camera may be transmitted. In this case, the video data is coded by LSI ex 500  included in smartphone ex 115 . 
     Note that LSI ex 500  may be configured to download and activate an application. In such a case, the terminal first determines whether it is compatible with the scheme used to encode the content or whether it is capable of executing a specific service. When the terminal is not compatible with the encoding scheme of the content or when the terminal is not capable of executing a specific service, the terminal first downloads a codec or application software then obtains and reproduces the content. 
     Aside from the example of content providing system ex 100  that uses internet ex 101 , at least the moving picture encoder (image encoder) or the moving picture decoder (image decoder) described in the above embodiments may be implemented in a digital broadcasting system. The same encoding processing and decoding processing may be applied to transmit and receive broadcast radio waves superimposed with multiplexed audio and video data using, for example, a satellite, even though this is geared toward multicast whereas unicast is easier with content providing system ex 100 . 
     [Hardware Configuration] 
       FIG. 30  illustrates smartphone ex 115 .  FIG. 31  illustrates a configuration example of smartphone ex 115 . Smartphone ex 115  includes antenna ex 450  for transmitting and receiving radio waves to and from base station ex 110 , camera ex 465  capable of capturing video and still images, and display ex 458  that displays decoded data, such as video captured by camera ex 465  and video received by antenna ex 450 . Smartphone ex 115  further includes user interface ex 466  such as a touch panel, audio output unit ex 457  such as a speaker for outputting speech or other audio, audio input unit ex 456  such as a microphone for audio input, memory ex 467  capable of storing decoded data such as captured video or still images, recorded audio, received video or still images, and mail, as well as decoded data, and slot ex 464  which is an interface for SIM ex 468  for authorizing access to a network and various data. Note that external memory may be used instead of memory ex 467 . 
     Moreover, main controller ex 460  which comprehensively controls display ex 458  and user interface ex 466 , power supply circuit ex 461 , user interface input controller ex 462 , video signal processor ex 455 , camera interface ex 463 , display controller ex 459 , modulator/demodulator ex 452 , multiplexer/demultiplexer ex 453 , audio signal processor ex 454 , slot ex 464 , and memory ex 467  are connected via bus ex 470 . 
     When the user turns the power button of power supply circuit ex 461  on, smartphone ex 115  is powered on into an operable state by each component being supplied with power from a battery pack. 
     Smartphone ex 115  performs processing for, for example, calling and data transmission, based on control performed by main controller ex 460 , which includes a CPU, ROM, and RAM. When making calls, an audio signal recorded by audio input unit ex 456  is converted into a digital audio signal by audio signal processor ex 454 , and this is applied with spread spectrum processing by modulator/demodulator ex 452  and digital-analog conversion and frequency conversion processing by transmitter/receiver ex 451 , and then transmitted via antenna ex 450 . The received data is amplified, frequency converted, and analog-digital converted, inverse spread spectrum processed by modulator/demodulator ex 452 , converted into an analog audio signal by audio signal processor ex 454 , and then output from audio output unit ex 457 . In data transmission mode, text, still-image, or video data is transmitted by main controller ex 460  via user interface input controller ex 462  as a result of operation of, for example, user interface ex 466  of the main body, and similar transmission and reception processing is performed. In data transmission mode, when sending a video, still image, or video and audio, video signal processor ex 455  compression encodes, via the moving picture encoding method described in the above embodiments, a video signal stored in memory ex 467  or a video signal input from camera ex 465 , and transmits the encoded video data to multiplexer/demultiplexer ex 453 . Moreover, audio signal processor ex 454  encodes an audio signal recorded by audio input unit ex 456  while camera ex 465  is capturing, for example, a video or still image, and transmits the encoded audio data to multiplexer/demultiplexer ex 453 . Multiplexer/demultiplexer ex 453  multiplexes the encoded video data and encoded audio data using a predetermined scheme, modulates and converts the data using modulator/demodulator (modulator/demodulator circuit) ex 452  and transmitter/receiver ex 451 , and transmits the result via antenna ex 450 . 
     When video appended in an email or a chat, or a video linked from a web page, for example, is received, in order to decode the multiplexed data received via antenna ex 450 , multiplexer/demultiplexer ex 453  demultiplexes the multiplexed data to divide the multiplexed data into a bitstream of video data and a bitstream of audio data, supplies the encoded video data to video signal processor ex 455  via synchronous bus ex 470 , and supplies the encoded audio data to audio signal processor ex 454  via synchronous bus ex 470 . Video signal processor ex 455  decodes the video signal using a moving picture decoding method corresponding to the moving picture encoding method described in the above embodiments, and video or a still image included in the linked moving picture file is displayed on display ex 458  via display controller ex 459 . Moreover, audio signal processor ex 454  decodes the audio signal and outputs audio from audio output unit ex 457 . Note that since real-time streaming is becoming more and more popular, there are instances in which reproduction of the audio may be socially inappropriate depending on the user&#39;s environment. Accordingly, as an initial value, a configuration in which only video data is reproduced, i.e., the audio signal is not reproduced, is preferable. Audio may be synchronized and reproduced only when an input, such as when the user clicks video data, is received. 
     Although smartphone ex 115  was used in the above example, three implementations are conceivable: a transceiver terminal including both an encoder and a decoder; a transmitter terminal including only an encoder; and a receiver terminal including only a decoder. Further, in the description of the digital broadcasting system, an example is given in which multiplexed data obtained as a result of video data being multiplexed with, for example, audio data, is received or transmitted, but the multiplexed data may be video data multiplexed with data other than audio data, such as text data related to the video. Moreover, the video data itself rather than multiplexed data maybe received or transmitted. 
     Although main controller ex 460  including a CPU is described as controlling the encoding or decoding processes, terminals often include GPUs. Accordingly, a configuration is acceptable in which a large area is processed at once by making use of the performance ability of the GPU via memory shared by the CPU and GPU or memory including an address that is managed so as to allow common usage by the CPU and GPU. This makes it possible to shorten encoding time, maintain the real-time nature of the stream, and reduce delay. In particular, processing relating to motion estimation, deblocking filtering, sample adaptive offset (SAO), and transformation/quantization can be effectively carried out by the GPU instead of the CPU in units of, for example pictures, all at once. 
     Although only some exemplary embodiments of the present disclosure have been described in detail above, those skilled in the art will readily appreciate that many modifications are possible in the exemplary embodiments without materially departing from the novel teachings and advantages of the present disclosure. Accordingly, all such modifications are intended to be included within the scope of the present disclosure. 
     INDUSTRIAL APPLICABILITY 
     The present disclosure is applicable to, for example, television receivers, digital video recorders, car navigation systems, mobile phones, digital cameras, digital video cameras, etc.