Video signal encoding / decoding method and device therefor
Patent Information
- Application Number
- JP2025058428
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2019-02-26
- Filing Date
- 2025-03-31
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2039-09-20
AI Technical Summary
The increasing demand for high-resolution video services has led to a significant increase in data volume, and existing video compression standards like HEVC have reached their performance limits, necessitating improved methods for encoding and decoding residual coefficients to enhance compression efficiency.
A method for encoding and decoding residual coefficients using flags to compare their magnitude with threshold values and determine parity, even-odd status, and absolute values, allowing for efficient encoding and decoding by analyzing non-zero flags and absolute value information in bitstreams.
This approach enables efficient encoding and decoding of residual coefficients, improving video compression efficiency by utilizing flags to compare residual coefficients with threshold values and determine parity and even-odd status, thereby enhancing data compression.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a video signal encoding / decoding method and an apparatus therefor.
Background Art
[0002] With the tendency for display panels to become increasingly large, higher-quality video services are being demanded. The biggest problem with high-resolution video services is the significant increase in data volume. To solve this problem, research to improve the video compression ratio has been actively carried out. As a typical example, in 2009, MPEG (Motion Picture Experts Group) and VCEG (Video Coding Experts Group) under ITU-T (International Telecommunication Union-Telecommunication) established JCT-VC (Joint Collaborative Team on Video Coding). JCT-VC proposed HEVC (High Efficiency Video Coding), a video compression standard having a compression performance approximately twice that of H.264 / AVC, which was approved on January 25, 2013. With the rapid development of high-resolution video services, the performance of HEVC has gradually reached its limit.
Summary of the Invention
Problems to be Solved by the Invention
[0003] An object of the present invention is to provide a method for encoding / decoding a residual coefficient and an apparatus therefor when encoding / decoding a video signal.
[0004] An object of the present invention is to provide a method for encoding / decoding a residual coefficient using a flag that compares the magnitude of the residual coefficient with a threshold value and an apparatus therefor when encoding / decoding a video signal.
[0005] An object of the present invention is to provide a method for encoding / decoding a residual coefficient using a flag indicating whether the residual coefficient is even or odd when encoding / decoding a video signal, and an apparatus for the method.
[0006] The technical problem to be solved by the present invention is not limited to the above technical problem, and those skilled in the art to which the present invention pertains can clearly understand other technical problems not mentioned in the present invention through the following description.
Means for Solving the Problem
[0007] The video signal decoding method of the present invention includes analyzing a non-zero flag indicating whether the residual coefficient is non-zero from a bitstream, and when the non-zero flag indicates that the residual coefficient is not non-zero, analyzing absolute value information from the bitstream, where the absolute value information is used to determine the absolute value of the residual coefficient, and determining the absolute value of the residual coefficient based on the absolute value information. Here, the absolute value information may include a residual coefficient comparison flag indicating whether the residual coefficient exceeds a first value, and only when the residual coefficient exceeds the first value, further analyzing a parity flag from the bitstream.
[0008] The video signal encoding method of the present invention may include encoding a non-zero flag indicating whether the residual coefficient is non-zero, and when the residual coefficient is not non-zero, encoding absolute value information, where the absolute value information is used to determine the absolute value of the residual coefficient. The absolute value information may include a residual coefficient comparison flag indicating whether the residual coefficient exceeds a first value, and only when the residual coefficient exceeds the first value, further encoding the parity flag of the residual coefficient.
[0009] In the video signal decoding / encoding method of the present invention, the parity flag may indicate whether the value of the residual coefficient is even or odd.
[0010] In the video signal decoding / encoding method of the present invention, when the residual coefficient exceeds the first value, the first adjusted residual coefficient comparison flag can be further analyzed, and the first adjusted residual coefficient comparison flag indicates whether the adjusted residual coefficient derived by shifting the residual coefficient one bit to the right exceeds a second value.
[0011] In the video signal decoding / encoding method of the present invention, when the adjusted residual coefficient is less than or equal to the second value, according to the value of the parity flag, it can be determined that the residual coefficient is 2N or 2N + 1.
[0012] In the video signal decoding / encoding method of the present invention, when the adjusted residual coefficient exceeds the second value, the second adjusted residual coefficient comparison flag can be further analyzed, and the second adjusted residual coefficient comparison flag indicates whether the adjusted residual coefficient exceeds a third value.
[0013] In the video signal decoding / encoding method of the present invention, when the adjusted residual coefficient exceeds the second value, the residual value information can be further analyzed, and the residual value information is a value obtained by subtracting the second value from the adjusted residual coefficient.
[0014] The above briefly summarized features of the present invention are merely exemplary embodiments of the detailed description of the present invention to be described later, and do not limit the scope of the present invention.
Effects of the Invention
[0015] According to the present invention, the residual coefficient can be efficiently encoded / decoded.
[0016] According to the present invention, by using a flag for comparing the magnitude of the residual coefficient with a threshold value, the residual coefficient can be efficiently encoded / decoded.
[0017] According to the present invention, by using a flag indicating whether the residual coefficient is even or odd, the residual coefficient can be efficiently encoded / decoded.
[0018] The effects obtained by the present invention are not limited to the above effects, and those skilled in the technical field to which the present invention pertains can clearly understand other effects not mentioned in the present invention through the following description.
Brief Description of the Drawings
[0019]
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10
Figure 11
Figure 12
Figure 13
Figure 14
Figure 15
Figure 16
Figure 17
Figure 18
Figure 19
Figure 20
Figure 21
Figure 22
Figure 23
Figure 24
Figure 25
Figure 26
Figure 27
Figure 28
Figure 29
Figure 30
Figure 31
Figure 32
Figure 33
Figure 34
Figure 35
Figure 36
Figure 37
Figure 38
Figure 39
Figure 40
Figure 41
Figure 42
Figure 43
Figure 44
Figure 45
Figure 46
Figure 47
Figure 48
Figure 49
Embodiments for Carrying Out the Invention
[0020] Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
[0021] Video encoding and decoding are performed in block units. For example, for an encoding block, a transform block, or a prediction block, encoding / decoding processes such as transformation, quantization, prediction, in-loop filtering, or restoration can be executed.
[0022] Hereinafter, the block to be encoded / decoded is referred to as the "current block". For example, according to the current encoding / decoding process, the current block can indicate an encoding block, a transform block, or a prediction block.
[0023] Furthermore, the term "unit" used in this specification represents a basic unit for executing a specific encoding / decoding process, and "block" can be understood to indicate an array of samples of a predetermined size. Unless otherwise explained, "block" and "unit" can be used interchangeably. For example, in the embodiments described below, the encoding block and the encoding unit can be understood to have equivalent meanings.
[0024] FIG. 1 is a block diagram of a video encoder according to an embodiment of the present invention.
[0025] Referring to FIG. 1, the video encoding device 100 may include an image segmentation unit 110, prediction units 120, 125, a transform unit 130, a quantization unit 135, a reordering unit 160, an entropy encoding unit 165, an inverse quantization unit 140, an inverse transform unit 145, a filter unit 150, and a memory 155.
[0026] Each component shown in FIG. 1 is illustrated independently to show different characteristic functions in a video encoding device, and it does not mean that each component is composed of separate hardware or a single software component. That is, for each component, for the convenience of explanation, at least two components can be combined into one component, or one component can be divided into multiple components to execute functions. Without departing from the essence of the present invention, both the embodiment of integrating these components and the embodiment of separating these components are included in the protection scope of the present invention.
[0027] Also, some of the components may not be components necessary to execute the essential functions of the present invention, but may be optional structural elements merely for improving performance. The present invention may include only the components necessary to realize the essence of the present invention other than the components merely for improving performance, and the structure including only the necessary structural elements other than the components merely for improving performance is also included in the protection scope of the present invention.
[0028] The image division unit 110 can divide the input image into at least one processing unit. In this case, the processing unit may be a prediction unit (PU), a transform unit (TU), or a coding unit (CU). The image division unit 110 can divide one image into a combination of multiple coding units, prediction units, and transform units, and select a combination of one coding unit, prediction unit, and transform unit based on a predetermined standard (such as a cost function) to encode the image.
[0029] For example, one image can be divided into a plurality of coding units. To divide an image into coding units, a recursive tree structure such as a quad tree structure can be used. Using one video or the largest coding unit as the root, the coding units to be divided into other coding units can be divided with the number of sub-nodes of the divided coding units. The coding units that are not further divided according to specific restrictions become leaf nodes. That is, assuming that only square division is possible for one coding unit, one coding unit can be divided into at most four other coding units.
[0030] Hereinafter, in the embodiments of the present invention, the coding unit may mean a unit that performs encoding or a unit that performs decoding.
[0031] The prediction unit within one coding unit can be divided into at least one of a square and a rectangle of the same size, or the prediction units within one coding unit can be divided such that any of the prediction units has a different shape and / or size from another prediction unit.
[0032] When the prediction unit that performs intra prediction based on the coding unit is not the smallest coding unit, intra prediction can be performed without dividing into a plurality of prediction units N×N.
[0033] The prediction units 120 and 125 can include an inter-prediction unit 120 that performs inter-prediction and an intra-prediction unit 125 that performs intra-prediction. For the prediction unit, it can be determined whether to perform inter-prediction or intra-prediction, and specific information (e.g., intra-prediction mode, motion vector, reference image, etc.) can be determined based on each prediction method. In this case, the processing unit that performs the prediction may be different from the processing unit that determines the prediction method and the specific content. For example, the prediction unit can determine the prediction method and prediction mode, etc., and the conversion unit can perform the prediction. The residual value (residual block) between the generated prediction block and the original block can be input to the conversion unit 130. Also, the prediction mode information, motion vector information, etc. used for the prediction can be encoded by the entropy encoding unit 165 together with the residual value and transmitted to the decoder. When using a specific encoding mode, instead of generating the blocks predicted by the prediction units 120 and 125, the original blocks can be directly encoded and transmitted to the decoder.
[0034] The inter-prediction unit 120 can predict the prediction unit based on the information of at least one of the previous image or subsequent images of the current image, and in some cases, can also predict the prediction unit based on the information of a part of the encoded region within the current image. The inter-prediction unit 120 may include a reference image interpolation unit, a motion prediction unit, and a motion compensation unit.
[0035] The reference image interpolation unit can receive the reference image information from the memory 155 and generate pixel information below integer pixels from the reference image. In the case of luminance pixels, a DCT-based 8-tap interpolation filter with different filter coefficients can be used to generate pixel information below integer pixels in units of 1 / 4 pixels. In the case of chrominance signals, a DCT-based 4-tap interpolation filter with different filter coefficients can be used to generate pixel information below integer pixels in units of 1 / 8 pixels.
[0036] The motion prediction unit can perform motion prediction based on the reference image interpolated by the reference image interpolation unit. Regarding the method for calculating the motion vector, various methods are possible, such as the full search-based block matching algorithm (FBMA), the three-step search method (TSS), the new three-step search algorithm (NTS), etc. The motion vector can have a motion vector value with 1 / 2 pixel or 1 / 4 pixel as a unit based on the interpolated pixels. By adopting different motion prediction methods in the motion prediction unit, the current prediction unit can be predicted. Regarding the motion prediction method, various methods can be used, such as the skip method, the merge method, the advanced motion vector prediction (AMVP) method, the intra block copy method, etc.
[0037] The intra prediction unit 125 can generate a prediction unit based on the reference pixel information around the current block, which is the pixel information in the current image. When the adjacent block of the current prediction unit is a block where inter prediction has been performed and the reference pixel is a pixel where inter prediction has been performed, the reference pixel included in the block where inter prediction has been performed can be used as the reference pixel information of the surrounding blocks where intra prediction has been performed. That is, when the reference pixel is not available, at least one of the available reference pixels can be used to replace the unavailable reference pixel information.
[0038] In intra prediction, the prediction mode can have a directional prediction mode that uses reference pixel information according to the prediction direction and a non-directional mode that does not use direction information when performing prediction. The mode for predicting luminance information and the mode for predicting chroma information can be different, and in order to predict chroma information, the intra prediction mode information used to predict luminance information or the predicted luminance signal information can be utilized.
[0039] When performing intra prediction, if the size of the prediction unit is the same as the size of the conversion unit, intra prediction can be performed on the prediction unit based on the pixels existing on the left side, the upper left side, and the upper side of the prediction unit. However, when performing intra prediction, if the size of the prediction unit is different from the size of the conversion unit, intra prediction can be performed using the reference pixels based on the conversion unit. Also, N×N partition intra prediction can be used only for the minimum coding unit.
[0040] The intra prediction method can generate a prediction block after applying an Adaptive Intra Smoothing (AIS) filter to the reference pixels according to the prediction mode. The type of AIS filter applied to the reference pixels may be different. In order to execute the intra prediction method, the intra prediction mode of the current prediction unit can be predicted from the intra prediction modes of the prediction units existing around the current prediction unit. When predicting the prediction mode of the current prediction unit using the mode information predicted from the surrounding prediction units, if the intra prediction modes of the current prediction unit and the surrounding prediction units are the same, information indicating that the prediction modes of the current prediction unit and the surrounding prediction units are the same can be transmitted using predetermined flag information, and if the prediction modes of the current prediction unit and the surrounding prediction units are different, entropy coding can be performed to encode the prediction mode information of the current block.
[0041] Also, a residual block including residual value information, which is the difference between the prediction unit for prediction based on the prediction units generated by the prediction units 120 and 125 and the original block of the prediction unit, can be generated. The generated residual block can be input to the conversion unit 130.
[0042] The conversion unit 130 can convert the original block and the residual block including the residual coefficient information of the prediction units generated by the prediction units 120 and 125 by using a conversion method such as discrete cosine transform (DCT), discrete sine transform (DST), or Karhunen–Loève transform (KLT). Whether to apply DCT, DST, or KLT to convert the residual block can be determined according to the intra prediction mode information of the prediction unit used to generate the residual block.
[0043] The quantization unit 135 can quantize the values converted to the frequency domain by the conversion unit 130. The quantization coefficient can be converted according to the importance of the block or video. The values calculated by the quantization unit 135 can be provided to the inverse quantization unit 140 and the reordering unit 160.
[0044] The reordering unit 160 can perform reordering of the coefficient values for the quantized residual values.
[0045] The rearrangement unit 160 can change the two-dimensional block shape coefficients into a one-dimensional vector form by a coefficient scanning method. For example, the rearrangement unit 160 can use a Zig-Zag Scan method to scan from the DC coefficient to the coefficients in the high-frequency region and change it into a one-dimensional vector form. According to the size of the conversion unit and the intra prediction mode, instead of the Zig-Zag scan, a vertical scan that scans the two-dimensional block shape coefficients in the column direction and a horizontal scan that scans the two-dimensional block shape coefficients in the row direction can also be used. That is, according to the size of the conversion unit and the intra prediction mode, it is possible to determine which scanning method among the Zig-Zag scan, the vertical direction scan, and the horizontal direction scan to use.
[0046] The entropy encoding unit 165 can perform entropy encoding based on the value calculated by the rearrangement unit 160. For example, for entropy encoding, various encoding methods such as Exponential Golomb encoding, Context-Adaptive Variable Length Coding (CAVLC), and Context-Adaptive Binary Arithmetic Coding (CABAC) can be used.
[0047] The entropy encoding unit 165 can encode various information such as the residual value coefficients information and block type information, prediction mode information, split unit information, prediction unit information, and transmission unit information, motion vector information, reference frame information, block interpolation information, filtering information, etc. of the encoding unit from the rearrangement unit 160 and the prediction units 120, 125.
[0048] The entropy encoding unit 165 can perform entropy encoding on the coefficient values of the encoding unit input from the rearrangement unit 160.
[0049] The inverse quantization unit 140 and the inverse transformation unit 145 inverse quantize a plurality of values quantized by the quantization unit 135 and inverse transform the values transformed by the transformation unit 130. The residual values generated by the inverse quantization unit 140 and the inverse transformation unit 145 can be merged with the prediction units predicted by the motion prediction unit, the motion compensation unit, and the intra prediction unit included in the prediction units 120 and 125 to generate a reconstructed block.
[0050] The filter unit 150 may include at least one of a deblocking filter, an offset correction unit, and an adaptive loop filter (ALF).
[0051] The deblocking filter can remove the block distortion generated at the boundary between blocks in the restored image. To determine whether to perform deblocking, it is possible to decide whether to apply the deblocking filter to the current block based on the pixels included in some columns or rows included in the block. When applying the deblocking filter to the block, a strong filter or a weak filter can be applied according to the required deblocking filter strength. Also, in the process of using the deblocking filter, when performing vertical filtering and horizontal filtering, the horizontal direction filtering and the vertical direction filtering can be processed in parallel.
[0052] The offset correction unit can correct the offset from the original video for each pixel of the deblocked video. To perform offset correction for a specific image, after dividing the pixels included in the video into a certain number of regions, a method of determining the region to perform the offset and applying the offset to the corresponding region, or a method of applying the offset in consideration of the edge information of each pixel can be used.
[0053] An Adaptive Loop Filtering (ALF) can be executed based on a value obtained by comparing a filtered restored image with an original video. After dividing pixels included in a video into predetermined groups, differential filtering can be performed for each group by determining one filter to be used for a corresponding group. Information regarding whether to apply the ALF and a luminance signal can be transmitted in a Coding Unit (CU), and the shape and filter coefficients of the ALF filter applied according to each block may be different. Also, an ALF filter of the same type (fixed type) can be applied regardless of the characteristics of a block to be applied.
[0054] The memory 155 can store a restored block or image calculated by the filter unit 150, and can provide the stored restored block or image to the prediction units 120 and 125 when performing inter prediction.
[0055] FIG. 2 is a block diagram of a video decoder according to an embodiment of the present invention.
[0056] Referring to FIG. 2, the video decoder 200 may include an entropy decoding unit 210, a reordering unit 215, an inverse quantization unit 220, an inverse transform unit 225, a prediction unit 230, a prediction unit 235, a filter unit 240, and a memory 245.
[0057] When inputting a video bitstream to a video encoder, the input bitstream can be decoded in steps reverse to those of the video encoder.
[0058] The entropy decoding unit 210 can perform entropy decoding in a step opposite to the step of performing entropy encoding in the entropy encoding unit of the video encoder. For example, corresponding to the method executed by the video encoder, various methods such as Exponential Golomb coding, Context-Adaptive Variable Length Coding (CAVLC), and Context-Adaptive Binary Arithmetic Coding (CABAC) are applicable.
[0059] The entropy decoding unit 210 can decode information regarding intra prediction and inter prediction executed by the encoder.
[0060] The reordering unit 215 can perform reordering based on the method of reordering the bit stream entropy decoded by the entropy decoding unit 210 in the encoder. A plurality of coefficients represented in the form of a one-dimensional vector can be restored and reordered into two-dimensional block-shaped coefficients again. The reordering unit 215 can receive information regarding coefficient scanning executed by the encoder and perform reordering by an inverse scanning method based on the scanning order executed by the corresponding encoder.
[0061] The inverse quantization unit 220 can perform inverse quantization based on the quantization parameter provided by the encoder and the coefficient values of the reordered blocks.
[0062] Regarding the quantization result executed by the video encoder, the inverse conversion unit 225 can execute an inverse conversion (i.e., inverse DCT, inverse DST, and inverse KLT) for the conversion executed by the conversion unit, that is, DCT, DST, and KLT. The inverse conversion can be executed based on the transmission unit determined by the video encoder. In the inverse conversion unit 225 of the video decoder, the conversion method (e.g., DCT, DST, KLT) can be selectively executed based on a plurality of information such as the prediction method, the size of the current block, and the prediction direction.
[0063] The prediction units 230 and 235 can generate a prediction block based on the information regarding the generation of the prediction block provided by the entropy decoding unit 210 and the information regarding the previously decoded block or image provided by the memory 245.
[0064] As described above, when performing intra prediction in the same manner as the operation in the video encoder, if the size of the prediction unit is the same as the size of the conversion unit, intra prediction is performed on the prediction unit based on the pixels existing on the left side, upper left side, and upper side of the prediction unit. If the size of the prediction unit when performing intra prediction is different from the size of the conversion unit, intra prediction can be executed using the reference pixels based on the conversion unit. Also, only for the minimum coding unit, N×N split intra prediction can be used.
[0065] The prediction units 230 and 235 can include a prediction unit discrimination unit, an inter-prediction unit, and an intra-prediction unit. The prediction unit discrimination unit receives various information such as prediction unit information input from the entropy decoding unit 210, prediction mode information of the intra-prediction method, and motion prediction related information of the inter-prediction method, and classifies the prediction unit according to the current coding unit, so as to determine whether the prediction unit executes inter-prediction or intra-prediction. The inter-prediction unit 230 uses the information necessary for the inter-prediction of the current prediction unit provided by the video encoder, and based on the information included in at least one of the previous image or the subsequent image of the current image to which the current prediction unit belongs, can execute inter-prediction on the current prediction unit. Alternatively, inter-prediction can also be executed based on a part of the information of the restored area within the current image to which the current prediction unit belongs.
[0066] To execute inter-prediction, it is possible to determine which mode among the skip mode, merge mode, advanced motion vector prediction mode (AMVP mode), and intra block copy mode is the motion prediction method of the prediction unit included in the corresponding coding unit based on the coding unit.
[0067] The intra prediction unit 235 can generate a prediction block based on the pixel information in the current image. When the prediction unit is a prediction unit that has performed intra prediction, intra prediction can be executed based on the intra prediction mode information of the prediction unit provided by the video encoder. The intra prediction unit 235 may include an Adaptive Intra Smoothing (AIS) filter, a reference pixel interpolation unit, and a DC filter. The AIS filter is an element that performs filtering on the reference pixels of the current block and can determine whether to apply the filter according to the prediction mode of the current prediction unit. Using the prediction mode of the prediction unit and the AIS filter information provided by the video encoder, AIS filtering can be performed on the reference pixels of the current block. When the prediction mode of the current block is a mode that does not perform AIS filtering, the AIS filter cannot be applied.
[0068] When the prediction mode of the prediction unit is a prediction unit that performs intra prediction based on the pixel values of the interpolated reference pixels, the reference pixel interpolation unit can generate reference pixels in pixel units of integer values or fractional values by interpolating the reference pixels. When the prediction mode of the current prediction unit is a prediction mode that generates a prediction block without interpolating the reference pixels, it is not necessary to interpolate the reference pixels. When the prediction mode of the current block is the DC mode, the DC filter can generate a prediction block by filtering.
[0069] The restored block or image can be provided to the filter unit 240. The filter unit 240 may include a deblocking filter, an offset correction unit, and an ALF.
[0070] From the video encoder, information regarding whether to apply a deblocking filter to a block or an image, and information regarding whether to apply strong filtering or weak filtering when applying the deblocking filter can be received. From the deblocking filter of the video decoder, related information of the deblocking filter provided by the video encoder can be received, and in the video decoder, deblocking filtering can be performed on the corresponding block.
[0071] The offset correction unit can perform offset correction on the restored video based on the type of offset correction and offset amount information used for the video during encoding.
[0072] Based on information regarding whether to apply ALF provided by the encoder, ALF coefficient information, etc., ALF can be applied to the encoding unit. Such ALF information can be provided by being included in a specific parameter set.
[0073] The memory 245 can store the restored image or block, use the image or block as a reference image or reference block, and provide the restored image to the output unit.
[0074] FIG. 3 is a diagram showing a basic encoding tree unit according to an embodiment of the present invention.
[0075] The coding block of the maximum size can be defined as a coding tree block. One image can be divided into a plurality of coding tree units (CTU: Coding Tree Unit). The coding tree unit is the coding unit of the maximum size and can also be called the largest coding unit (LCU: Largest Coding Unit). FIG. 3 shows an example in which one image is divided into a plurality of coding tree units.
[0076] The size of the coding tree unit can be defined at the image level or the sequence level. Therefore, the information indicating the size of the coding tree unit can be signaled via an image parameter set or a sequence parameter set.
[0077] For example, the size of the coding tree unit for the entire image within a sequence can be set to 128×128. Alternatively, either 128×128 or 256×256 can be determined as the size of the coding tree unit at the image level. For example, the size of the coding tree unit can be set to 128×128 for the first image and 256×256 for the second image.
[0078] Coding blocks can be generated by splitting the coding tree unit. The coding block represents a basic unit for performing encoding / decoding processing. For example, prediction or transformation can be performed according to different coding blocks, or a prediction coding mode can be determined according to different coding blocks. Here, the prediction coding mode represents a method for generating a predicted image. For example, the prediction coding mode can include intra prediction, inter prediction, current picture referencing (CPR) or intra block copy (IBC), or combined prediction. For a coding block, a prediction block related to the coding block can be generated using at least one of the prediction coding modes of intra prediction, inter prediction, current picture referencing, or combined prediction.
[0079] Information indicating the prediction coding mode of the current block can be signaled via a bitstream. For example, the information can be a 1-bit flag indicating whether the prediction coding mode is an intra mode or an inter prediction mode. The current picture reference or composite prediction can be used only when it is determined that the prediction coding mode of the current block is an inter prediction mode.
[0080] The current picture reference is used to set the current picture as a reference picture and obtain a predicted block of the current block from the encoded / decoded regions within the current picture. Here, the current picture means the picture containing the current block. Information indicating whether to apply the current picture reference to the current block can be signaled via a bitstream. For example, the information can be a 1-bit flag. When the flag is true, the prediction coding mode of the current block can be determined as the current picture reference, and when the flag is false, the prediction mode of the current block can be determined as an inter prediction.
[0081] Alternatively, the prediction coding mode of the current block can be determined based on a reference picture index. For example, when the reference picture index points to the current picture, the prediction coding mode of the current block can be determined as the current picture reference. When the reference picture index points to another picture rather than the current picture, the prediction coding mode of the current block can be determined as an inter prediction. That is, the current picture reference is a prediction method that uses information of the encoded / decoded regions within the current picture, and the inter prediction is a prediction method that uses information of other encoded / decoded pictures.
[0082] Compound prediction indicates an encoding mode that combines two or more of intra prediction, inter prediction, and current picture reference. For example, when applying compound prediction, a first prediction block can be generated based on any one of intra prediction, inter prediction, or current picture reference, and a second prediction block can be generated based on another one. When generating the first prediction block and the second prediction block, the final prediction block can be generated through the average operation or weighted sum operation of the first prediction block and the second prediction block. Information indicating whether to apply compound prediction can be signaled through a bitstream. The information can be a 1-bit flag.
[0083] Figure 4 is a diagram showing various splitting forms of an encoding block.
[0084] Based on quadtree splitting, binary tree splitting, or ternary tree splitting, an encoding block can be split into a plurality of encoding blocks. Based on quadtree splitting, binary tree splitting, or ternary tree splitting, the split encoding blocks can also be split into a plurality of encoding blocks again.
[0085] Quadtree splitting refers to a splitting method that splits the current block into four blocks. As a result of quadtree splitting, the current block can be split into four square partitions (see "SPLIT_QT" in Figure 4(a)).
[0086] Binary tree splitting refers to a splitting method that splits the current block into two blocks. Splitting the current block into two blocks along the vertical direction (i.e., using a vertical line across the current block) can be called vertical binary tree splitting, and splitting the current block into two blocks along the horizontal direction (i.e., using a horizontal line across the current block) can be called horizontal binary tree splitting. By binary tree splitting, the current block can be split into two non-square partitions. "SPLIT_BT_VER" in Figure 4(b) shows the result of vertical binary tree splitting, and "SPLIT_BT_HOR" in Figure 4(c) shows the result of horizontal binary tree splitting.
[0087] Trinary tree splitting refers to a splitting method that divides the current block into three blocks. Splitting the current block into three blocks along the vertical direction (i.e., using two vertical lines that cross the current block) can be called vertical trinary tree splitting, and splitting the current block into three blocks along the horizontal direction (i.e., using two horizontal lines that cross the current block) can be called horizontal trinary tree splitting. By trinary tree splitting, the current block can be divided into three non-square partitions. In this case, the width / height of the partition located at the center of the current block can be twice that of the other partitions. "SPLIT_TT_VER" in Fig. 4(d) shows the vertical trinary tree splitting result, and "SPLIT_TT_HOR" in Fig. 4(e) shows the horizontal trinary tree splitting result.
[0088] The number of times of splitting of the coding tree unit can be defined as the partitioning depth. The maximum partitioning depth of the coding tree unit can be determined by the sequence or image level. Thus, the maximum partitioning depth of the coding tree unit can be different for different sequences or images.
[0089] Alternatively, the maximum partitioning depth of each of a plurality of splitting methods can be determined individually. For example, the maximum partitioning depth allowed for quadtree splitting can be different from the maximum partitioning depth allowed for binary tree splitting and / or trinary tree splitting.
[0090] The encoder can signal, via the bitstream, information indicating at least one of the splitting shape or the partitioning depth of the current block. The decoder can determine the splitting shape and the partitioning depth of the coding tree unit based on the information parsed from the bitstream.
[0091] Fig. 5 is a diagram showing an example of splitting of the coding tree unit.
[0092] The division of an encoding block using a division method such as a quadtree division, a binary tree division, and / or a ternary tree division can be called a multi-tree partitioning.
[0093] A plurality of encoding blocks generated by applying the multi-tree partitioning to an encoding block can be called sub-encoding blocks. When the division depth of the encoding block is k, the division depth of the plurality of sub-encoding blocks is set to k + 1.
[0094] On the other hand, for a plurality of encoding blocks with a division depth of k + 1, the encoding block with a division depth of k can be called a super-encoding block.
[0095] The division type of the current encoding block can be determined based on at least one of the division shape of the super-encoding block or the division type of the adjacent encoding block. Here, the adjacent encoding block is adjacent to the current encoding block, and the adjacent encoding block can include at least one of the upper adjacent block, the left adjacent block, or the adjacent block adjacent to the upper left corner of the current encoding block. Here, the division type can include at least one of whether to perform a quadtree division, whether to perform a binary tree division, the division direction of the binary tree, whether to perform a ternary tree division, or the division direction of the ternary tree.
[0096] To determine the division shape of the encoding block, information indicating whether the encoding block is divided can be signaled via a bitstream. The information is a 1-bit flag "split_cu_flag", and when the current flag is true, the encoding block can be divided by the multi-tree partitioning method.
[0097] When 「split_cu_flag」 is true, information indicating whether the encoded block is to be quadtree split can be signaled via a bitstream. The information is a 1-bit flag 「split_qt_flag」, and when the flag is true, the encoded block can be split into four blocks.
[0098] For example, in the example shown in FIG. 5, it is shown that an encoding tree unit generates four encoded blocks with a split depth of 1 by quadtree splitting. Also, it is shown that quadtree splitting is applied again to the first and fourth encoded blocks among the four encoded blocks generated as a result of the quadtree splitting. As a result, four encoded blocks with a split depth of 2 can be generated.
[0099] Also, by applying quadtree splitting again to an encoded block with a split depth of 2, an encoded block with a split depth of 3 can be generated.
[0100] When quadtree splitting is not applied to the encoded block, it is possible to determine whether to perform binary tree splitting or ternary tree splitting on the encoded block in consideration of at least one of the size of the encoded block, whether the encoded block is located at the image boundary, the maximum split depth, or the split shape of adjacent blocks. When it is determined to perform binary tree splitting or ternary tree splitting on the encoded block, information indicating the split direction can be signaled via a bitstream. The information can be a 1-bit flag 「mtt_split_cu_vertical_flag」. Based on the flag, it is possible to determine whether the split direction is vertical or horizontal. Further, information indicating whether binary tree splitting or ternary tree splitting is applied to the encoded block can be signaled via a bitstream. The information can be a 1-bit flag 「mtt_split_cu_binary_flag」. Based on the flag, it is possible to determine whether to apply binary tree splitting or ternary tree splitting to the encoded block.
[0101] For example, in the example shown in FIG. 5, vertical binary tree splitting is applied to an encoded block with a splitting depth of 1, and among the encoded blocks generated as the splitting result, vertical ternary tree splitting is applied to the left encoded block, and vertical binary tree splitting is applied to the right encoded block.
[0102] When dividing an image into coding tree units, blocks smaller than a predefined size can exist in an area adjacent to the right or bottom boundary of the image. When the block is a coding tree unit, a coding tree unit smaller than a predefined size can be generated at the right or bottom boundary of the image. In this case, the size of the coding tree unit can be determined based on information signaled via a sequence parameter set or an image parameter set.
[0103] FIG. 6 is a diagram showing an example in which a block smaller than a coding tree unit of a preset size appears at the image boundary.
[0104] As in the example shown in FIG. 6, when dividing an image of size 1292×1080 into coding tree units of size 128×128, blocks smaller than 128×128 will exist at the right and bottom boundaries of the image. In the embodiments described later, blocks of coding tree units smaller than a predefined size generated at the image boundary are called boundary blocks of non-standard boundaries.
[0105] For boundary blocks of non-standard boundaries, only predefined splitting methods can be permitted. Here, the predefined splitting method may include at least one of quadtree splitting, ternary tree splitting, or binary tree splitting.
[0106] For example, for boundary blocks with irregular boundaries, only quadtree splitting can be permitted. In this case, quadtree splitting can be repeated until the blocks at the image boundary reach the minimum quadtree splitting size. Here, the minimum quadtree splitting size can be predefined by the encoder and decoder. Alternatively, information indicating the minimum quadtree splitting size can be signaled via the bitstream.
[0107] FIG. 7 is a diagram showing an example of performing quadtree splitting on a boundary block with an irregular boundary. For the sake of convenience of explanation, it is assumed that the size of the minimum quadtree splitting is 4×4.
[0108] The splitting for boundary blocks with irregular boundaries can be performed based on square blocks. The square block can be derived based on the larger of the width or height of the boundary block with an irregular boundary. For example, the power of 2 that is larger than the reference value and closest to the reference value can be regarded as the length of one side of the square block. For example, the 12×20 block shown in FIG. 7 can be regarded as belonging to a 32×32 block, and the 32×32 splitting result can be applied to the 12×20 block.
[0109] When performing quadtree splitting on a 12×20 block, the block can be split into a 12×16-sized block and a 12×4-sized block. When performing quadtree splitting on each of them again, the 12×16 block is split into two 8×8 blocks and two 4×8 blocks, and the 12×4-sized block is split into an 8×4-sized block and a 4×4-sized block.
[0110] Performing quadtree splitting again on the 4×8 block located at the image boundary can generate two 4×4-sized blocks as a result. Similarly, performing quadtree splitting again on the 8×4 block located at the image boundary can generate two 4×4-sized blocks as a result.
[0111] Alternatively, when at least one of the width or height of the block is the same as or smaller than the minimum quadtree division size, binary tree division can also be performed. Here, the minimum quadtree division size can indicate the minimum quadtree division width or the minimum quadtree division height. For example, when the minimum quadtree division size is 4×4, the minimum quadtree division width and the minimum quadtree division height can be 4.
[0112] In this case, when the width of the block is the same as or smaller than the minimum quadtree division size, vertical binary tree division can be performed, and when the height of the block is the same as or smaller than the minimum quadtree division height, horizontal binary tree division can be performed.
[0113] On the other hand, when the width or height of the block is larger than the minimum quadtree division size, quadtree division can be performed. For example, when the upper right position and the lower left position of the block go out of the image and the width or height of the block is larger than the minimum quadtree division size, quadtree division can be applied to the corresponding block.
[0114] FIG. 8 is a diagram showing an example of performing quadtree division on a block adjacent to both the right boundary and the lower boundary of an image. For the sake of convenience of explanation, it is assumed that the size of the minimum quadtree division is 4×4.
[0115] In the example shown in FIG. 8, when performing quadtree division on a 32×32 - sized block including a 12×20 - sized block, four 16×16 - sized blocks are generated. Quadtree division can be performed again on two 16×16 - sized blocks including these texture data. As a result, the x - axis coordinates and y - axis coordinates go out of the image boundary, and an 8×8 - sized block including 4×4 - sized texture data can be generated. Since the width and height of the 8×8 - sized block are larger than the minimum quadtree division size, quadtree division can be performed on the block.
[0116] When performing quadtree splitting on a 12×20 block, the block can be split into a 12×16 block and a 12×4 block. When performing quadtree splitting on each of them again, the 12×16 block is split into two 8×8 blocks and two 4×8 blocks, and the 12×4 block is split into an 8×4 block and a 4×4 block.
[0117] Since the width of the 4×8 block located at the image boundary is the same as the minimum quadtree splitting size, binary splitting can be performed on the 4×8 block. Specifically, based on the square block (i.e., 8×8) containing the 4×8 block, vertical binary splitting can be performed.
[0118] Also, since the width of the 8×4 block located at the image boundary is the same as the minimum quadtree splitting size, binary splitting can be performed on the 8×4 block. Specifically, based on the square block (i.e., 8×8) containing the 4×8 block, horizontal binary splitting can be performed.
[0119] In the splitting result, blocks of size 8×4, 4×4, and 4×8 can be arranged adjacent to the image boundary.
[0120] Alternatively, binary splitting can be performed when at least one of the width or height of the block is smaller than or equal to a threshold, and quadtree splitting can be performed otherwise. Here, the threshold can be derived based on the minimum quadtree splitting size. For example, when the minimum quadtree splitting size is minQTsize, the threshold can be set to "minQTsize<<1". Alternatively, the information for determining the threshold can be signaled via a bitstream.
[0121] Figure 9 is a diagram showing the splitting pattern of the blocks adjacent to the image boundary. For the sake of convenience of explanation, it is assumed that the size of the minimum quadtree splitting is 4×4. The threshold can be set to 8.
[0122] First, perform quadtree splitting on the 12×20 block. As a result, the block can be split into a 12×16 - sized block and a 12×4 - sized block. Since both the width and height of the 12×16 - sized block exceed the threshold, quadtree splitting can be applied to the block. Thereby, the block can be split into two 8×8 blocks and two 4×8 blocks.
[0123] The width of the 12×4 - sized block exceeds the threshold. Thereby, quadtree splitting can be applied to the 12×4 - sized block. As a result, the block can be split into an 8×4 - sized block and a 4×4 - sized block.
[0124] After that, since both the width and height of the 4×8 - sized blocks and 8×4 - sized blocks located at the image boundary are smaller than or equal to the threshold, binary tree splitting can be applied to these blocks.
[0125] Conversely to the above - mentioned example, when at least one of the width or height of the block exceeds the threshold, binary tree splitting can be performed; otherwise, quadtree splitting can be performed.
[0126] Alternatively, only quadtree splitting or only binary tree splitting can be applied to the boundary blocks of the non - standard boundary. For example, quadtree splitting can be repeatedly performed until the blocks located at the image boundary have the minimum size, or binary tree splitting can be repeatedly performed until the blocks located at the image boundary have the minimum size.
[0127] Specify a boundary block of an irregular boundary as an encoding unit. For a boundary block of an irregular boundary, the skip mode can be fixedly applied, or all transform coefficients can be set to 0. As a result, the value of a coded block flag (CBF) indicating whether there are non-zero transform coefficients in the boundary block of the irregular boundary can be set to 0. An encoded unit encoded in the skip mode or an encoded unit with transform coefficients set to 0 can be called a boundary zero-encoded unit.
[0128] Alternatively, at least one of the width or height of an encoded block generated by dividing a boundary block of an irregular boundary can be compared with a threshold value to determine whether to set the encoding unit as a boundary zero-encoded unit. For example, an encoded block with at least one of the width or height less than the threshold value can be encoded in the skip mode, or the transform coefficients of the encoded block can be set to 0.
[0129] FIG. 10 is a diagram showing an encoding pattern of a block adjacent to an image boundary. Assume that the threshold value is 8.
[0130] Among the encoded blocks generated by dividing a boundary block of an irregular boundary, an encoded block with at least one of the width or height less than the threshold value can be set as a boundary zero-encoded unit.
[0131] For example, in the example shown in FIG. 10, an encoded block of 4×16 size, an encoded block of 8×4 size, and an encoded block of 4×4 size can be set as boundary zero-encoded units. As a result, the block can be encoded in the skip mode, or the transform coefficients of the block can be set to 0.
[0132] For coded blocks whose width and height are greater than or equal to a threshold, it is possible to selectively determine whether to apply the skip mode or set the transform coefficient to 0. Therefore, a flag indicating whether to apply the skip mode to the coded block or a flag indicating whether to set the transform coefficient to 0 can be coded and signaled.
[0133] Alternatively, it is possible to allow only coded units generated by binary tree partitioning to be set as boundary zero coded units. Alternatively, it is possible to allow only coded units generated by quadtree partitioning to be set as boundary zero coded units.
[0134] Inter prediction is a predictive coding mode that uses information from the previous image to predict the current block. For example, a block at the same position as the current block in the previous image (hereinafter referred to as a collocated block) can be set as the prediction block of the current block. Hereinafter, a prediction block generated based on a block at the same position as the current block is referred to as a collocated prediction block.
[0135] On the other hand, when an object that existed in the previous image has moved to another position in the current image, the movement of the object can be used to effectively predict the current block. For example, when the movement direction and size of the object can be known by comparing the previous image and the current image, a prediction block (or prediction image) of the current block can be generated in consideration of the movement information of the object. Hereinafter, a prediction block generated using movement information can be referred to as a motion prediction block.
[0136] A residual block can be generated by subtracting a predicted block from the current block. In this case, when there is movement of an object, by using a motion prediction block instead of a co-located prediction block, the energy of the residual block can be reduced, thereby improving the compression performance of the residual block.
[0137] As described above, generating a prediction block using motion information can be called motion-compensated prediction. In most inter-predictions, a prediction block can be generated based on motion-compensated prediction.
[0138] The motion information may include at least one of a motion vector, a reference picture index, a prediction direction, or a bi-directional weight index. The motion vector represents the moving direction and size of an object. The reference picture index specifies the reference picture of the current block among a plurality of reference pictures included in the reference picture list. The prediction direction refers to either uni-directional L0 prediction, uni-directional L1 prediction, or bi-directional prediction (L0 prediction and L1 prediction). According to the prediction direction of the current block, at least one of the motion information in the L0 direction or the motion information in the L1 direction can be used. The bi-directional weight index specifies the weight value applied to the L0 prediction block and the weight value applied to the L1 prediction block.
[0139] FIG. 11 is a flowchart of an inter-prediction method according to an embodiment of the present invention.
[0140] Referring to FIG. 11, the inter-prediction method includes determining an inter-prediction mode of the current block (S1101), obtaining motion information of the current block according to the determined inter-prediction mode (S1102), and performing motion-compensated prediction of the current block based on the obtained motion information (S1103).
[0141] Here, the inter prediction mode represents various methods for determining the motion information of the current block, and may include an inter prediction mode that uses translational motion information and an inter prediction mode that uses affine motion information. For example, the inter prediction mode that uses translational motion information may include a merge mode and a high-level motion vector prediction mode, and the inter prediction mode that uses affine motion information may include an affine merge mode and an affine motion vector prediction mode. According to the inter prediction mode, the motion information of the current block can be determined based on the information analyzed from adjacent blocks adjacent to the current block or from the bitstream.
[0142] Hereinafter, the inter prediction method using translational motion information will be described in detail.
[0143] The motion information of the current block can be derived from the motion information of other blocks of the current block. Here, the other block may be a block that has been encoded / decoded by inter prediction earlier than the current block. It can be defined that the merge mode is to set the motion information of the current block to be the same as the motion information of the other block. Also, it can be defined that the motion vector prediction mode is to set the motion vector of the other block to be the predicted value of the motion vector of the current block.
[0144] FIG. 12 is a flowchart of a process for deriving the motion information of the current block in the merge mode.
[0145] The merge candidates of the current block can be derived (S1201). The merge candidates of the current block can be derived from blocks that have been encoded / decoded by inter prediction earlier than the current block.
[0146] FIG. 13 is a diagram showing candidate blocks for deriving merge candidates.
[0147] The candidate block may include at least one of an adjacent block including samples adjacent to the current block or a non - adjacent block including samples not adjacent to the current block. Hereinafter, the samples used to determine the candidate block are designated as reference samples. Also, the reference samples adjacent to the current block are called adjacent reference samples, and the reference samples not adjacent to the current block are called non - adjacent reference samples.
[0148] The adjacent reference samples can be included in the adjacent column of the left - most column of the current block or in the adjacent row of the top - most row of the current block. For example, if the coordinates of the upper - left sample of the current block are (0, 0), at least one of the blocks including the reference sample at the position (-1, H - 1), the block including the reference sample at the position (W - 1, -1), the block including the reference sample at the position (W, -1), the block including the reference sample at the position (-1, H), or the block including the reference sample at the position (-1, -1) can be used as the candidate block. Referring to the drawings, the adjacent blocks with indexes 0 - 4 can be used as candidate blocks.
[0149] The non - adjacent reference samples indicate samples in which at least one of the x - axis distance or the y - axis distance from the reference samples adjacent to the current block has a predefined value. For example, at least one of the blocks including a reference sample whose x - axis distance from the left - hand reference sample is a predefined value, the block of non - adjacent samples whose y - axis distance from the upper reference sample is a predefined value, or the block of non - adjacent samples whose x - axis distance and y - axis distance from the upper - left reference sample are predefined values can be used as the candidate block. The predefined value can be an integer such as 4, 8, 12, 16, etc. Referring to the drawings, at least one of the blocks with indexes 5 - 26 can be used as the candidate block.
[0150] Samples not located on the same vertical line, horizontal line, or diagonal line as the adjacent reference samples can be set as non - adjacent reference samples.
[0151] FIG. 14 is a diagram showing the positions of reference samples.
[0152] As shown in the example illustrated in FIG. 14, the x - coordinate of the upper non - adjacent reference sample can be set to be different from the x - coordinate of the upper adjacent reference sample. For example, when the position of the upper adjacent reference sample is (W - 1, - 1), the position of the upper non - adjacent reference sample that is N away from the upper adjacent reference sample along the y - axis can be set to ((W / 2) - 1, - 1 - N), and the position of the upper non - adjacent reference sample that is 2N away from the upper adjacent reference sample along the y - axis can be set to (0, - 1 - 2N). That is, the position of the non - adjacent reference sample can be determined based on the position of the adjacent reference sample and the distance from the adjacent reference sample.
[0153] Hereinafter, a candidate block including an adjacent reference sample among candidate blocks is referred to as an adjacent block, and a block including a non - adjacent reference sample is referred to as a non - adjacent block.
[0154] When the distance between the current block and the candidate block is greater than or equal to a threshold value, the candidate block can be set as not usable as a merge candidate. The threshold value can be determined based on the size of the coding tree unit. For example, the threshold value can be set to the height of the coding tree unit (ctu_height), or can be set to a value obtained by adding or subtracting an offset value from the height of the coding tree unit (for example, ctu_height±N). The offset value N is a value predefined in the encoder and decoder, and can be set to 4, 8, 16, 32, or ctu_height.
[0155] When the difference between the y - axis coordinate of the current block and the y - axis coordinate of the sample included in the candidate block exceeds the threshold value, it can be determined that the candidate block cannot be used as a merge candidate.
[0156] Alternatively, candidate blocks that do not belong to the same coding tree unit as the current block can be set as not usable as merge candidates. For example, if the reference sample does not exceed the upper boundary of the coding tree unit to which the current block belongs, the candidate block including the reference sample can be set as not usable as a merge candidate.
[0157] When the upper boundary of the current block is adjacent to the upper boundary of the coding tree unit, a plurality of candidate blocks are set as not usable as merge candidates, thereby reducing the coding / decoding efficiency of the current block. To solve the above problem, by setting candidate blocks, the number of candidate blocks located above the current block can be set to be larger than the number of candidate blocks on the left side of the current block.
[0158] FIG. 15 is a diagram showing candidate blocks for deriving merge candidates.
[0159] As shown in the example shown in FIG. 15, the upper blocks belonging to the upper N block columns of the current block and the left blocks belonging to the left M block columns of the current block can be set as candidate blocks. In this case, by setting M to be larger than N, the number of left candidate blocks can be set to be larger than the number of upper candidate blocks.
[0160] For example, the difference between the y-axis coordinate of the reference sample in the current block and the y-axis coordinate of the upper block that can be used as a candidate block can be set not to exceed N times the height of the current block. Also, the difference between the x-axis coordinate of the reference sample in the current block and the x-axis coordinate of the left block that can be used as a candidate block can be set not to exceed M times the width of the current block.
[0161] For example, in the example shown in FIG. 15, it shows that the blocks belonging to the upper two block columns of the current block and the blocks belonging to the left five block columns of the current block are set as candidate blocks.
[0162] As another example, when the candidate block does not belong to the same coding tree unit as the current block, instead of the candidate block, a block belonging to the same coding tree unit as the current block, or a block including a reference sample adjacent to the boundary of the coding tree unit can be used to derive a merge candidate.
[0163] FIG. 16 is a diagram showing an example of changing the position of a reference sample.
[0164] When the reference sample is included in a coding tree unit different from the current block and the reference sample is not adjacent to the coding tree unit boundary, instead of the reference sample, a reference sample adjacent to the coding tree unit boundary can be used to determine a candidate block.
[0165] For example, in the examples shown in FIGS. 16(a) and 16(b), when the upper boundary of the current block is in contact with the upper boundary of the coding tree unit, the reference sample at the upper part of the current block will belong to a coding tree unit different from the current block. Using the sample adjacent to the upper boundary of the coding tree unit, among the reference samples belonging to a coding tree unit different from the current block, the reference sample not adjacent to the upper boundary of the coding tree unit can be replaced.
[0166] For example, as in the example shown in FIG. 16(a), the reference sample at position 6 is replaced with the sample at position 6' of the upper boundary of the coding tree unit, and as in the example shown in FIG. 16(b), the reference sample at position 15 is replaced with the sample at position 15' of the upper boundary of the coding tree unit. In this case, the y coordinate of the replacement sample can be changed to an adjacent position of the coding tree unit, and the x coordinate of the replacement sample can be set the same as that of the reference sample. For example, the sample at position 6' may have the same x coordinate as the sample at position 6, and the sample at position 15' may have the same x coordinate as the sample at position 15.
[0167] Alternatively, a value obtained by adding or subtracting an offset value from the x - coordinate of the reference sample can be set as the x - coordinate of the replacement sample. For example, when the x - coordinates of the adjacent reference sample above the current block and the non - adjacent reference sample are the same, a value obtained by adding or subtracting an offset value from the x - coordinate of the reference sample can be set as the x - coordinate of the replacement sample. This is to prevent the replacement sample that replaces the non - adjacent reference sample from being in the same position as another non - adjacent reference sample or an adjacent reference sample.
[0168] FIG. 17 is a diagram showing an example of changing the position of the reference sample.
[0169] When replacing a reference sample that is included in a different coding tree unit from the current block and is not adjacent to the boundary of the coding tree unit, using a sample located at the boundary of the coding tree unit, a value obtained by adding or subtracting an offset value from the x - coordinate of the reference sample can be set as the x - coordinate of the replacement sample.
[0170] For example, in the example shown in FIG. 17, the reference sample at position 6 and the reference sample at position 15 can be replaced with the sample at position 6’ and the sample at position 15’ respectively, which have the same y - coordinate as the row adjacent to the upper boundary of the coding tree unit. In this case, the x - coordinate of the sample at position 6’ can be set to the value obtained by subtracting W / 2 from the x - coordinate of the reference sample at position 6, and the x - coordinate of the sample at position 15’ can be set to the value obtained by subtracting W - 1 from the x - coordinate of the reference sample at position 15.
[0171] Different from the examples shown in FIGS. 16 and 17, the y - coordinate of the row located above the top - most row of the current block or the y - coordinate of the upper boundary of the coding tree unit can also be set as the y - coordinate of the replacement sample.
[0172] Although not shown, a sample for replacing a reference sample can be determined based on the left boundary of the coding tree unit. For example, if the reference sample is not included in the same coding tree unit as the current block and is not adjacent to the left boundary of the coding tree unit, the reference sample can be replaced with a sample adjacent to the left boundary of the coding tree unit. In this case, the replacement sample may have the same y coordinate as the reference sample, or may have a y coordinate obtained by adding or subtracting an offset value from the y coordinate of the reference sample.
[0173] Thereafter, a block including the replacement sample can be set as a candidate block, and a merge candidate for the current block can be derived based on the candidate block.
[0174] A merge candidate can also be derived from temporally adjacent blocks included in an image different from the current block. For example, a merge candidate can be derived from co-located blocks included in a co-located image.
[0175] The motion information of the merge candidate can be set in the same manner as the motion information of the candidate block. For example, at least one of the motion vector, reference image index, prediction direction, or bidirectional weight value index of the candidate block can be set as the motion information of the merge candidate.
[0176] A merge candidate list including the merge candidates can be generated (S1202). The merge candidates can be classified into adjacent merge candidates derived from adjacent blocks adjacent to the current block and non-adjacent merge candidates derived from non-adjacent blocks.
[0177] Indices of a plurality of merge candidates in the merge candidate list can be assigned according to a predetermined order. For example, the index assigned to an adjacent merge candidate can have a smaller value than the index assigned to a non-adjacent merge candidate. Alternatively, an index can be assigned to each merge candidate based on the index of each block shown in FIG. 13 or FIG. 15.
[0178] When a plurality of merge candidates are included in the merge candidate list, at least one of the plurality of merge candidates can be selected (S1203). In this case, information indicating whether the motion information of the current block is derived from an adjacent merge candidate can be signaled via a bitstream. The information can be a 1-bit flag. For example, a syntax element isAdjancentMergeFlag indicating whether the motion information of the current block is derived from an adjacent merge candidate can be signaled via a bitstream. When the value of the syntax element isAdjancentMergeFlag is 1, the motion information of the current block can be derived based on the adjacent merge candidate. On the other hand, when the value of the syntax element isAdjancentMergeFlag is 0, the motion information of the current block can be derived based on a non-adjacent merge candidate.
[0179] Table 1 shows a syntax table including the syntax element isAdjancentMergeFlag.
Table 1
[0180] Information for specifying any one of a plurality of merge candidates can be signaled via a bitstream. For example, information indicating an index of any one of the merge candidates included in the merge candidate list can be signaled via a bitstream.
[0181] When isAdjacentMergeflag is 1, a syntax element merge_idx for determining any one of the adjacent merge candidates can be signaled. The maximum value of the syntax element merge_idx can be set to a value obtained by subtracting 1 from the number of adjacent merge candidates.
[0182] When isAdjacentMergeflag is 0, the syntax element NA_merge_idx for determining any of the non - adjacent merge candidates can be signaled. The syntax element NA_merge_idx indicates a value obtained by subtracting the number of adjacent merge candidates from the index of the non - adjacent merge candidate. The decoder can select a non - adjacent merge candidate by adding the number of adjacent merge candidates to the index determined by NA_merge_idx.
[0183] When the number of merge candidates included in the merge candidate list is less than the maximum value, the merge candidates included in the inter - region motion information table can be added to the merge candidate list. The inter - region motion information table may include merge candidates derived based on the blocks encoded / decoded before the current block.
[0184] The inter - region motion information table includes merge candidates derived from the blocks encoded / decoded based on inter - prediction within the current image. For example, the motion information of the merge candidates included in the inter - region motion information table can be set to be the same as the motion information of the blocks encoded / decoded based on inter - prediction. Here, the motion information may include at least one of a motion vector, a reference picture index, a prediction direction, or a bi - direction weight value index.
[0185] For the sake of convenience of explanation, the merge candidates included in the inter - region motion information table are called inter - region merge candidates.
[0186] The encoder and decoder can pre - define the maximum number of merge candidates that can be included in the inter - region motion information table. For example, the maximum number of merge candidates that can be included in the inter - region motion information table can be 1, 2, 3, 4, 5, 6, 7, 8 or more (e.g., 16, etc.).
[0187] Alternatively, information indicating the maximum number of merge candidates in the inter-region motion information table can be signaled via a bitstream. The said information can be signaled at the sequence level, picture level or slice level.
[0188] Alternatively, the maximum number of merge candidates in the inter-region motion information table can be determined according to the size of the picture, the size of the slice or the size of the coding tree unit.
[0189] The inter-region motion information table can be initialized in units of a picture, a slice, a tile, a block, a coding tree unit or a coding tree unit line (row or column). For example, when a slice is initialized, the inter-region motion information table is also initialized, and the inter-region motion information table may not contain any merge candidates.
[0190] Alternatively, information indicating whether to initialize the inter-region motion information table can be signaled via a bitstream. The said information can be signaled at the slice level, tile level, block level or block level. The configured inter-region motion information table can be used until the said information instructs to initialize the inter-region motion information table.
[0191] Alternatively, information regarding inter-region merge candidates can be signaled via a picture parameter set or a slice header. Even if a slice is initialized, the inter-region motion information table may include initial inter-region merge candidates. Thereby, inter-region merge candidates can also be used for the first coded / decoded block in the slice.
[0192] Blocks are coded / decoded according to the coding / decoding order, and a plurality of blocks coded / decoded based on inter prediction can be sequentially set as inter-region merge candidates according to the coding / decoding order.
[0193] FIG. 18 is a diagram for explaining an example of updating an inter-region motion information table.
[0194] When performing inter prediction on the current block (S1801), an inter-region merge candidate can be derived based on the current block (S1802). The motion information of the inter-region merge candidate can be set in the same manner as the motion information of the current block.
[0195] When the inter-region motion information table is empty (S1803), the inter-region merge candidate derived based on the current block can be added to the inter-region motion information table (S1804).
[0196] When the inter-region motion information table already contains the inter-region merge candidate (S1803), a redundancy check can be performed on the motion information of the current block (or the inter-region merge candidate derived based on the current block) (S1805). The redundancy check is used to determine whether the motion information of the inter-region merge candidate stored in the inter-region motion information table is the same as the motion information of the current block. The redundancy check can be performed using all the inter-region merge candidates stored in the inter-region motion information table as objects. Alternatively, the redundancy check can be performed using, as objects, the inter-region merge candidates whose indexes are greater than or equal to a threshold or less than or equal to the threshold among the inter-region merge candidates stored in the inter-region motion information table.
[0197] When the inter-region motion information table does not include an inter-region merge candidate having the same motion information as the current block, the inter-region merge candidate derived based on the current block can be added to the inter-region motion information table (S1808). It is possible to determine whether the inter-region merge candidates are the same based on whether the motion information (e.g., motion vector and / or reference picture index, etc.) of the inter-region merge candidates is the same.
[0198] In this case, when the maximum number of inter-region merge candidates is already stored in the inter-region motion information table (S1806), the oldest inter-region merge candidate is deleted (S1807), and the inter-region merge candidate derived based on the current block can be added to the inter-region motion information table (S1808).
[0199] According to each index, a plurality of inter-region merge candidates can be identified. When adding the inter-region merge candidate derived from the current block to the inter-region motion information table, the lowest index (such as 0) can be assigned to the inter-region merge candidate, and the index of the stored inter-region merge candidate can be incremented by 1. In this case, when the maximum number of inter-region merge candidates is already stored in the inter-region motion information table, the inter-region merge candidate with the maximum index is removed.
[0200] Alternatively, when adding the inter-region merge candidate derived from the current block to the inter-region motion information table, the maximum index can be assigned to the inter-region merge candidate. For example, when the number of inter-region merge candidates stored in the inter-region motion information table is less than the maximum value, an index equal to the number of the stored inter-region merge candidates can be assigned to the inter-region merge candidate. Alternatively, when the number of inter-region merge candidates stored in the inter-region motion information table is equal to the maximum value, an index obtained by subtracting 1 from the maximum value can be assigned to the inter-region merge candidate. Also, the inter-region merge candidate with the smallest index is removed, and the indices of the remaining plurality of stored inter-region merge candidates are decremented by 1.
[0201] FIG. 19 is a diagram showing an example of updating the inter-region merge candidate table.
[0202] Assume that an inter-region merge candidate derived from the current block is added to the inter-region merge candidate table, and the largest index is assigned to the said inter-region merge candidate. Further assume that the inter-region merge candidate table already stores the maximum number of inter-region merge candidates.
[0203] When adding the inter-region merge candidate HmvpCand[n + 1] derived from the current block to the inter-region merge candidate table HmvpCandList, the inter-region merge candidate HmvpCand[0] with the smallest index can be deleted from the stored inter-region merge candidates, and the indices of the multiple remaining inter-region merge candidates can be decreased by one. Also, the index of the inter-region merge candidate HmvpCand[n + 1] derived from the current block can be set to the maximum value (n in the example shown in FIG. 19).
[0204] If an inter-region merge candidate that is the same as the inter-region merge candidate derived based on the current block is stored (S1805), the inter-region merge candidate derived based on the current block cannot be added to the inter-region motion information table (S1809).
[0205] Alternatively, while adding the inter-region merge candidate derived based on the current block to the inter-region motion information table, the stored inter-region merge candidate that is the same as the said inter-region merge candidate can also be deleted. In this case, the same effect as when the index of the stored inter-region merge candidate is newly updated occurs.
[0206] FIG. 20 is a diagram showing an example in which the index of the stored inter-region merge candidate is updated.
[0207] If the index hIdx of the stored inter-region merge candidate that is the same as the inter-region merge candidate mvCand derived based on the current block is present, the stored inter-region merge candidate is deleted, and the indexes of the inter-region merge candidates whose indexes exceed hIdx can be decreased by one. For example, in the example shown in FIG. 20, the same HmvpCand[2] as mvCand is deleted from the inter-region motion information table HvmpCandList, indicating that the indexes from HmvpCand[3] to HmvpCand[n] are decreased by one.
[0208] Furthermore, the inter-region merge candidate mvCand derived based on the current block can be added to the end of the inter-region motion information table.
[0209] Alternatively, the index of the stored inter-region merge candidate that is the same as the inter-region merge candidate derived based on the current block can be updated. For example, the index of the stored inter-region merge candidate can be changed to the minimum value or the maximum value.
[0210] The motion information of the blocks included in a predetermined region can be set to those that cannot be added to the inter-region motion information table. For example, the inter-region merge candidate derived based on the motion information of the blocks included in the parallel merge region cannot be added to the inter-region motion information table. Since the encoding / decoding order of the blocks included in the parallel merge region is not specified, it is inappropriate to use the motion information of any of the blocks when performing inter prediction on other blocks. Thus, the inter-region merge candidate derived based on the blocks included in the parallel merge region cannot be added to the inter-region motion information table.
[0211] When performing motion compensation prediction using sub-block units, an inter-region merge candidate can be derived based on the motion information of a representative sub-block among a plurality of sub-blocks included in the current block. For example, for the current block, when a sub-block merge candidate is used, an inter-region merge candidate can be derived based on the motion information of a representative sub-block among the sub-blocks.
[0212] The motion vectors of the sub-blocks can be derived in the following order. First, any one of the merge candidates included in the merge candidate list of the current block can be selected, and an initial shift vector (shVector) can be derived based on the motion vector of the selected merge candidate. Further, the initial shift vector can be added to the positions (xSb, ySb) of the reference samples (e.g., the upper-left sample or the middle-position sample) of each sub-block within the coded block to derive a shifted sub-block whose reference sample positions are (xColSb, yColSb). The following Equation 1 shows the mathematical formula for deriving the shifted sub-block.
Equation
[0213] Next, the motion vector of the equivalent position block corresponding to the center position of the sub-block including (xColSb, yColSb) is set as the motion vector of the sub-block including (xSb, ySb).
[0214] The representative sub-block can mean a sub-block including the upper-left sample or the central sample including the current block.
[0215] Figure 21 is a diagram showing the position of the representative sub-block.
[0216] FIG. 21(a) shows an example where a sub-block located at the upper left of the current block is set as the representative sub-block, and FIG. 21(b) shows an example where a sub-block located at the center of the current block is set as the representative sub-block. When motion compensation prediction is performed in units of sub-blocks, an inter-region merge candidate for the current block can be derived based on the motion vector of the sub-block including the upper left sample of the current block or the sub-block including the center sample of the current block.
[0217] Based on the inter prediction mode of the current block, it is also possible to determine whether to use the current block as an inter-region merge candidate. For example, a block encoded / decoded based on an affine motion model can be set as not usable as an inter-region merge candidate. Thereby, even if the current block is encoded / decoded by inter prediction, when the inter prediction mode of the current block is the affine prediction mode, the inter-region motion information table is not updated based on the current block.
[0218] Alternatively, an inter-region merge candidate can be derived based on at least one sub-block vector among the sub-blocks included in a block encoded / decoded based on an affine motion model. For example, an inter-region merge candidate can be derived using a sub-block located at the upper left, center, or upper right of the current block. Alternatively, the average value of the sub-block vectors of a plurality of sub-blocks can be set as the motion vector of the inter-region merge candidate.
[0219] Alternatively, an inter-region merge candidate can be derived based on the average value of the affine seed vectors of a block encoded / decoded based on an affine motion model. For example, the average value of at least one of the first affine seed vector, the second affine seed vector, or the third affine seed vector of the current block can be set as the motion vector of the inter-region merge candidate.
[0220] Alternatively, an inter-region motion information table can be configured for each inter-prediction mode. For example, at least one of an inter-region motion information table for a block encoded / decoded by intra-block copy, an inter-region motion information table for a block encoded / decoded based on a translational motion model, or an inter-region motion information table for a block encoded / decoded based on an affine motion model can be defined. According to the inter-prediction mode of the current block, any one of a plurality of inter-region motion information tables can be selected.
[0221] FIG. 22 is a diagram showing an example of generating an inter-region motion information table for each inter-prediction mode.
[0222] When encoding / decoding a block based on a non-affine motion model, an inter-region merge candidate mvCand derived based on the block can be added to an inter-region non-affine motion information table HmvpCandList. On the other hand, when encoding / decoding a block based on an affine motion model, an inter-region merge candidate mvAfCand derived based on the block can be added to an inter-region affine motion information table HmvpAfCandList.
[0223] The affine seed vector of a block can be stored in an inter-region merge candidate derived from a block encoded / decoded based on an affine motion model. Thereby, the inter-region merge candidate can be used as a merge candidate for deriving the affine seed vector of the current block.
[0224] In addition to the described inter-region motion information table, another inter-region motion information table can also be defined. In addition to the inter-region motion information table described above (hereinafter referred to as the first inter-region motion information table), a long-term motion information table (hereinafter referred to as the second inter-region motion information table) can also be defined. Here, the long-term motion information table includes long-term merge candidates.
[0225] If both the first inter-region motion information table and the second inter-region motion information table are empty, first, the inter-region merge candidates can be added to the second inter-region motion information table. The inter-region merge candidates can be added to the first inter-region motion information table only after the number of available inter-region merge candidates in the second inter-region motion information table reaches the maximum number.
[0226] Alternatively, one inter-region merge candidate can be added to both the second inter-region motion information table and the first inter-region motion information table.
[0227] In this case, the configured second inter-region motion information table can no longer be updated. Alternatively, if the decoded region is above a predetermined ratio of the slice, the second inter-region motion information table can be updated. Alternatively, the second inter-region motion information table can be updated for every N coded tree unit lines.
[0228] On the other hand, every time a block encoded / decoded by inter prediction is generated, the first inter-region motion information table can be updated. However, the inter-region merge candidates added to the second inter-region motion information table can also be set so as not to be used for updating the first inter-region motion information table.
[0229] Information for selecting either the first inter-region motion information table or the second inter-region motion information table can be signaled via a bitstream. When the number of merge candidates included in the merge candidate list is less than the maximum value, the merge candidates included in the inter-region motion information table indicated by the information can be added to the merge candidate list.
[0230] Alternatively, the inter-region motion information table can be selected based on the size, shape, inter prediction mode, whether to perform bi-directional prediction, whether to refine the motion vector, or whether to perform triangular partitioning of the current block.
[0231] Alternatively, if adding the inter-region merge candidates included in the first inter-region motion information table does not cause the number of merge candidates included in the merge candidate list to exceed the maximum number of merges, the inter-region merge candidates included in the second inter-region motion information table can be added to the merge candidate list.
[0232] FIG. 23 is a diagram showing an example of adding the inter-region merge candidates included in the long-term motion information table to the merge candidate list.
[0233] When the number of merge candidates included in the merge candidate list is less than the maximum number, the inter-region merge candidates included in the first inter-region motion information table HmvpCandList can be added to the merge candidate list. Even if the inter-region merge candidates included in the first inter-region motion information table are added to the merge candidate list and the number of merge candidates included in the merge candidate list is less than the maximum number, the inter-region merge candidates included in the long-term motion information table HmvpLTCandList can be added to the merge candidate list.
[0234] Table 2 shows the process of adding the inter-region merge candidates included in the long-term motion information table to the merge candidate list.
Table 2
[0235] The inter-region merge candidate can be set to include additional information in addition to the motion information. For example, the size, shape, or block division information of the block of the inter-region merge candidate can be additionally stored. When constructing the merge candidate list of the current block, only the inter-region merge candidates among the inter-region merge candidates whose size, shape, or division information is the same as or similar to that of the current block are used, or the inter-region merge candidates whose size, shape, or division information is the same as or similar to that of the current block can be preferentially added to the merge candidate list.
[0236] Alternatively, an inter-region motion information table can be generated for each block size, shape, or division information. Among the multiple inter-region motion information tables, the inter-region motion information table corresponding to the shape, size, or division information of the current block can be used to generate the merge candidate list of the current block.
[0237] Alternatively, an inter-region motion information table can be generated for each resolution of the motion vector. For example, when the motion vector of the current block has a resolution of 1 / 4 pixel, the inter-region merge candidate derived from the current block can be added to the 1 / 4 pixel motion information list of the inter-prediction region. When the motion vector of the current block has a resolution of one integer pixel, the inter-region merge candidate derived from the current block can be added to the integer pixel motion information list of the inter-prediction region. When the motion vector of the current block has a resolution of four integer pixels, the inter-region merge candidate derived from the current block can be added to the 4 integer pixel motion information list of the inter-prediction region. Depending on the motion vector resolution of the encoding / decoding object block, any one of the multiple inter-motion information lists can be selected.
[0238] When applying the merge offset vector encoding method to the current block, instead of adding the inter-region merge candidate derived based on the current block to the inter-region motion information table HmvpCandList, it can be added to the inter-prediction region merge offset motion information table HmvpHMVDCandList. In this case, the inter-region merge candidate may include the motion vector offset information of the current block. HmvpHMVDCandList can be used to derive the offset of the block to which the merge offset vector encoding method is applied.
[0239] When the number of merge candidates included in the merge candidate list of the current block is not the maximum value, the inter-region merge candidates included in the inter-region motion information table can be added to the merge candidate list. The above addition process is executed in ascending or descending order of the index. For example, the inter-region merge candidate with the maximum index can be added to the merge candidate list.
[0240] When adding the inter-region merge candidates included in the inter-region motion information table to the merge candidate list, a redundancy check can be performed between the inter-region merge candidates and the multiple merge candidates stored in the merge candidate list.
[0241] For example, Table 3 shows the process of adding the inter-region merge candidates to the merge candidate list.
Table 3
[0242] The redundancy check can also be performed only on a part of the inter-region merge candidates included in the inter-region motion information table. For example, the redundancy check can be performed only on the inter-region merge candidates whose index is greater than or equal to the threshold or less than or equal to the threshold.
[0243] Alternatively, the redundancy check can be performed only on a part of the merge candidates stored in the merge candidate list. For example, the redundancy check can be performed only on merge candidates whose index is greater than or equal to a threshold value or less than or equal to the threshold value, or merge candidates derived from blocks at specific positions. Here, the specific position may include at least one of the left adjacent block, upper adjacent block, upper right adjacent block, or lower left adjacent block of the current block.
[0244] FIG. 24 is a diagram showing an example of performing a redundancy check only on a part of the merge candidates.
[0245] When adding the inter-region merge candidate HmvpCand[j] to the merge candidate list, a redundancy check can be performed on the inter-region merge candidate for the two merge candidates mergeCandList[NumMerge - 2] and mergeCandList[NumMerge - 1] with the largest indices. Here, NumMerge indicates the number of available spatial merge candidates and temporal merge candidates.
[0246] When the same merge candidate as the first inter-region merge candidate is found, when performing a redundancy check on the second inter-region merge candidate, the redundancy check with the same merge candidate as the first inter-region merge candidate can be omitted.
[0247] FIG. 25 is a diagram showing an example of omitting a redundancy check for a specific merge candidate.
[0248] When adding the inter-region merge candidate HmvpCand[i] with index i to the merge candidate list, a redundancy check can be performed between the inter-region merge candidate and the merge candidates stored in the merge candidate list. In this case, if the same merge candidate mergeCandList[j] as the inter-region merge candidate HmvpCand[i] is found, instead of adding the inter-region merge candidate HmvpCand[i] to the merge candidate list, a redundancy check can be performed between the inter-region merge candidate HmvpCand[i-1] with index i-1 and the merge candidate. In this case, the redundancy check between the inter-region merge candidate HmvpCand[i-1] and the merge candidate mergeCandList[j] can be omitted.
[0249] For example, in the example shown in FIG. 25, it is determined that HmvpCand[i] and mergeCandList[2] are the same. Thereby, HmvpCand[i] is not added to the merge candidate list, and a redundancy check for HmvpCand[i-1] can be performed. In this case, the redundancy check between HvmpCand[i-1] and mergeCandList[2] can be omitted.
[0250] When the number of merge candidates included in the current block merge candidate list is less than the maximum value, in addition to the inter-region merge candidate, at least one of the pairwise merge candidate or the zero merge candidate can also be included. The pairwise merge candidate refers to a merge candidate with the average value of the motion vectors of two or more merge candidates as the motion vector, and the zero merge candidate refers to a merge candidate with a motion vector of 0.
[0251] The merge candidate list of the current block can add merge candidates in the following order.
[0252] Spatial merge candidate - Temporal merge candidate - Inter-region merge candidate - (Inter-prediction affine merge candidate) - Pairwise merge candidate - Zero merge candidate A spatial merge candidate refers to a merge candidate derived from at least one of adjacent blocks or non-adjacent blocks, and a temporal merge candidate refers to a merge candidate derived from a previous reference picture. An inter-prediction affine merge candidate refers to an inter-region merge candidate derived from a block encoded / decoded with an affine motion model.
[0253] The inter-region motion information table can also be used in the high-level motion vector prediction mode. For example, when the number of motion vector prediction candidates included in the motion vector prediction candidate list of the current block is less than the maximum value, the inter-region merge candidates included in the inter-region motion information table can be set as the motion vector prediction candidates of the current block. Specifically, the motion vector of the inter-region merge candidate can be set as the motion vector prediction candidate.
[0254] When any one of the motion vector prediction candidates included in the motion vector prediction candidate list of the current block is selected, the selected candidate can be set as the motion vector predictor of the current block. Then, after decoding the motion vector residual value of the current block, the motion vector of the current block can be obtained by adding the motion vector prediction value and the motion vector residual value.
[0255] The motion vector prediction candidate list of the current block can be configured in the following order.
[0256] Spatial motion vector prediction candidates - Temporal motion vector prediction candidates - Inter-decoded region merge candidates - (Inter-decoded region affine merge candidates) - Zero motion vector prediction candidates The spatial motion vector prediction candidate refers to a motion vector prediction candidate derived from at least one of adjacent blocks or non-adjacent blocks, and the temporal motion vector prediction candidate refers to a motion vector prediction candidate derived from a previous reference image. The inter prediction affine merge candidate refers to an inter prediction motion vector prediction candidate derived from a block encoded / decoded by an affine motion model. The zero motion vector prediction candidate refers to a candidate whose motion vector value is 0.
[0257] A merge processing region with a size larger than that of the encoded block can be specified. The encoded blocks included in the merge processing region can be processed in parallel without being sequentially encoded / decoded. Here, not being sequentially encoded / decoded means not specifying the encoding / decoding order. Thereby, the encoding / decoding processes of the blocks included in the merge processing region can be processed independently. Alternatively, the blocks included in the merge processing region can share merge candidates. Here, the merge candidates can be derived based on the merge processing region.
[0258] According to the above-described features, the merge processing region can also be referred to as a parallel processing region, a shared merge region (SMR), or a merge estimation region (MER).
[0259] The merge candidates for the current block can be derived based on the encoded block. However, when the current block is included in a parallel merge region with a size larger than that of the current block, the candidate blocks included in the same parallel merge region as the current block can be set to be unusable as merge candidates.
[0260] FIG. 26 is a diagram showing an example in which candidate blocks included in the same parallel merge region as the current block are set to be unusable as merge candidates.
[0261] In the example shown in FIG. 26(a), when encoding / decoding CU5, a block including reference samples adjacent to CU5 can be set as a candidate block. In this case, candidate blocks X3 and X4 included in the same parallel merge region as CU5 can be set as those that cannot be used as merge candidates for CU5. On the other hand, candidate blocks X0, X1, and X2 not included in the same parallel merge region as CU5 can be set as those that can be used as merge candidates.
[0262] In the example shown in FIG. 26(b), when encoding / decoding CU8, a block including reference samples adjacent to CU8 can be set as a candidate block. In this case, candidate blocks X6, X7, and X8 included in the same parallel merge region as CU8 can be set as those that cannot be used as merge candidates. On the other hand, candidate blocks X5 and X9 not included in the same parallel merge region as CU5 can be set as those that can be used as merge candidates.
[0263] The parallel merge region can be square or non-square. Information for determining the parallel merge region can be signaled via a bitstream. The information can include at least one of information indicating the shape of the parallel merge region and information indicating the size of the parallel merge region. When the parallel merge region is non-square, at least one of information indicating the size of the parallel merge region, information indicating the width and / or height of the parallel merge region, or information indicating the ratio of the width to the height of the parallel merge region can be signaled via the bitstream.
[0264] The size of the parallel merge region can be determined based on at least one of information signaled via the bitstream, the image resolution, the size of a slice, or the size of a tile.
[0265] When performing motion compensation prediction on blocks included in the parallel merge region, an inter-region merge candidate derived based on the motion information of the block on which the motion compensation prediction has been performed can be added to the inter-prediction motion information table.
[0266] However, when adding an inter-region merge candidate derived from a block included in the parallel merge region to the inter-region motion information table, when the actual encoding / decoding lags behind that of the block and encodes / decodes other blocks within the parallel merge region, the inter-region merge candidate derived from the above block may be used. That is, it is necessary to eliminate the dependency between blocks when encoding / decoding the blocks included in the parallel merge region, but motion prediction compensation may be executed using the motion information of other blocks included in the parallel merge region. To solve such a problem, even after the encoding / decoding of the blocks included in the parallel merge region is completed, the motion information of the encoded / decoded blocks cannot be added to the inter-region motion information table.
[0267] Alternatively, when performing motion compensation prediction on the blocks included in the parallel merge region, the inter-region merge candidates derived from the above blocks can be added to the inter-region motion information table in a predefined order. Here, the predefined order can be determined based on the scanning order of the encoded blocks within the parallel merge region or the coding tree unit. The scanning order can be at least one of raster scanning, horizontal scanning, vertical scanning, or zigzag scanning. Alternatively, the predefined order can be determined based on the motion information of each block or the number of blocks having the same motion information.
[0268] Alternatively, an inter-region merge candidate including one-way motion information can be added to the inter-prediction region merge list before an inter-region merge candidate including bidirectional motion information. Conversely, an inter-region merge candidate including bidirectional motion information can be added to the inter-region merge candidate table before an inter-region merge candidate including one-way motion information.
[0269] Alternatively, the inter-region merge candidates can be added to the inter-region motion information table in descending or ascending order of the usage frequency within the parallel merge region or the coding tree unit.
[0270] If the current block is included in the parallel merge region and the number of merge candidates included in the merge candidate list of the current block is less than the maximum number, the inter-region merge candidates included in the inter-region motion information table can be added to the merge candidate list. In this case, it can be set not to add the inter-region merge candidates derived from the blocks included in the same parallel merge region as the current block to the merge candidate list of the current block.
[0271] Alternatively, if the current block is included in the parallel merge region, it can be set not to use the inter-region merge candidates included in the inter-region motion information table. That is, even if the number of merge candidates included in the merge candidate list of the current block is less than the maximum number, the inter-region merge candidates included in the inter-region motion information table can be prevented from being added to the merge candidate list.
[0272] The inter-region motion information table of the parallel merge region or the coding tree unit can be configured. The inter-region motion information table serves to temporarily store the motion information of the blocks included in the parallel merge region. To distinguish between a general inter-region motion information table and the inter-region motion information table for the parallel merge region or the coding tree unit, the inter-region motion information table for the parallel merge region or the coding tree unit is called a temporary motion information table. Furthermore, the inter-region merge candidates stored in the temporary motion information table are called temporary merge candidates.
[0273] FIG. 27 is a diagram showing the temporary motion information table.
[0274] A temporary motion information table for a symbolized tree unit or a parallel merge area can be configured. When motion compensation prediction of the current block included in the symbolized tree unit or the parallel merge area is performed, the motion information of the block cannot be added to the inter-region motion information table HmvpCandList. Instead, a temporary merge candidate derived from the block can be added to the temporary motion information table HmvpMERCandList. That is, the temporary merge candidate added to the temporary motion information table can be not added to the inter-region motion information table. Thereby, the inter-region motion information table may not include an inter-region merge candidate derived based on the motion information of the block included in the symbolized tree unit or the parallel merge area including the current block.
[0275] The maximum number of merge candidates that the temporary motion information table can include can be set to be the same as the maximum number of merge candidates that the inter-region motion information table can include. Alternatively, the maximum number of merge candidates that the temporary motion information table can include can be determined according to the size of the symbolized tree unit or the parallel merge area.
[0276] The current block included in the symbolized tree unit or the parallel merge area can be set not to use the temporary motion information table of the symbolized tree unit or the parallel merge area. That is, when the number of merge candidates included in the merge candidate list of the current block is less than the maximum value, the inter-region merge candidates included in the inter-region motion information table can be added to the merge candidate list, and the temporary merge candidates included in the temporary motion information table can be not added to the merge candidate list. Thereby, the motion information of other blocks included in the same symbolized tree unit or parallel merge area as the current block can be not used for the motion compensation prediction of the current block.
[0277] When the encoding / decoding of all blocks included in the symbolic tree unit or the parallel merge area is completed, the inter-region motion information table and the temporary motion information table can be merged.
[0278] FIG. 28 is a diagram showing an example of merging the inter-prediction motion information table and the temporary motion information table.
[0279] When the encoding / decoding of all blocks included in the symbolic tree unit or the parallel merge area is completed, as shown in FIG. 28, the temporary merge candidates included in the temporary motion information table can be updated to the inter-region motion information table.
[0280] In this case, the temporary merge candidates included in the temporary motion information table can be added to the inter-frame motion information table according to the order in which they are inserted into the temporary motion information table (i.e., in ascending or descending order of index values).
[0281] As another example, the temporary merge candidates included in the temporary motion information table can be added to the inter-region motion information table according to a predefined order.
[0282] Here, the predefined order can be determined based on the scanning order of the encoded blocks in the parallel merge area or the symbolic tree unit. The scanning order can be at least one of raster scanning, horizontal scanning, vertical scanning, or zigzag scanning. Alternatively, the predefined order can be determined based on the motion information of each block or the number of blocks having the same motion information.
[0283] Alternatively, the temporary merge candidates including one-directional motion information can be added to the inter-prediction merge list before the temporary merge candidates including bi-directional motion information. On the other hand, the temporary merge candidates including bi-directional motion information can be added to the inter-region merge candidate list before the temporary merge candidates including one-directional motion information.
[0284] Alternatively, temporary merge candidates can be added to the inter-region motion information table in order of decreasing or increasing usage frequency within the parallel merge region or the coding tree unit.
[0285] When adding the temporary merge candidates included in the temporary motion information table to the inter-region motion information table, a redundancy check can be performed on the temporary merge candidates. For example, if the same inter-region merge candidate as the temporary merge candidate included in the temporary motion information table is stored in the inter-region motion information table, the temporary merge candidate cannot be added to the inter-region motion information table. In this case, a redundancy check can be performed on some of the inter-region merge candidates included in the inter-region motion information table. For example, a redundancy check can be performed on inter-region merge candidates whose index is greater than or equal to a threshold value. For example, if the temporary merge candidate is identical to an inter-region merge candidate whose index is greater than or equal to a pre-defined value, the temporary merge candidate cannot be added to the inter-region motion information table.
[0286] Intra prediction is to predict the current block by using the restored samples for which the encoding / decoding around the current block has been completed. In this case, the intra prediction of the current block can use the restored samples before the in-loop filter is applied.
[0287] The intra prediction technique includes intra prediction based on a matrix and general intra prediction considering the directionality with the surrounding restored samples. Information indicating the intra prediction technique of the current block can be signaled via a bitstream. The information can be a 1-bit flag. Alternatively, based on at least one of the position, size, shape of the current block, or the intra prediction technique of the adjacent blocks, the intra prediction technique of the current block can be determined. For example, if the current block exists across the image boundary, the current block can be set so that intra prediction based on a matrix is not applied to the current block.
[0288] Intra prediction based on a matrix is a method for obtaining a predicted block of a current block based on the matrix product between the matrix stored in an encoder and a decoder and the restored samples around the current block. Information for specifying any one of a plurality of stored matrices can be signaled via a bitstream. The decoder can determine the matrix used for intra prediction of the current block based on the information and the size of the current block.
[0289] General intra prediction is a method for obtaining a predicted block regarding a current block based on a non-directional intra prediction mode or a directional intra prediction mode. Hereinafter, with reference to the drawings, a process for performing intra prediction based on general intra prediction will be described in detail.
[0290] FIG. 29 is a flowchart of an intra prediction method according to an embodiment of the present invention.
[0291] A reference sample line of the current block can be determined (S2901). The reference sample line refers to a set of reference samples included in the line that is K lines away from the upper part and / or the left side of the current block. The reference samples can be derived from the restored samples for which encoding / decoding around the current block has been completed.
[0292] Index information for identifying the reference sample line of the current block within a plurality of reference sample lines can be signaled via a bitstream. The plurality of reference sample lines may include at least one of the first row / column, the second row / column, the third row / column, or the fourth row / column above and / or to the left of the current block. Table 4 shows the indexes assigned to each of the respective reference sample lines. In Table 4, it is assumed that the first row / column, the second row / column, and the fourth row / column are used as candidates for the reference sample lines. [Table 4]
[0293] Based on at least one of the position, size, shape of the current block, or the predicted coding mode of adjacent blocks, the reference sample line of the current block can be determined. For example, if the current block is adjacent to the boundary of an image, tile, slice, or coding tree unit, the first reference sample line can be determined as the reference sample line of the current block.
[0294] The reference sample line may include an upper reference sample located above the current block and a left reference sample located to the left of the current block. The upper reference sample and the left reference sample can be derived from the restored samples around the current block. The restored samples can be in a state before the in-loop filter is applied.
[0295] FIG. 30 is a diagram showing the reference samples included in each reference sample line.
[0296] According to the intra prediction mode of the current block, at least one of the reference samples belonging to the reference sample line can be used to obtain a predicted sample.
[0297] Next, the intra prediction mode of the current block can be determined (S2902). In the case of the intra prediction mode of the current block, at least one of a non-directional intra prediction mode or a directional intra prediction mode can be determined as the intra prediction mode of the current block. The non-directional intra prediction mode includes Planar (planer) and DC, and the directional intra prediction mode includes 33 or 65 modes from the lower left diagonal direction to the upper right diagonal direction.
[0298] FIG. 31 is a diagram showing the intra prediction mode.
[0299] FIG. 31(a) shows 35 intra prediction modes, and FIG. 31(b) shows 67 intra prediction modes.
[0300] A greater or smaller number of intra prediction modes than that shown in FIG. 31 can be defined.
[0301] Based on the intra prediction modes of adjacent blocks adjacent to the current block, the most probable mode (MPM) can be set. Here, the adjacent blocks may include a left adjacent block adjacent to the left side of the current block and an upper adjacent block adjacent to the upper side of the current block. When the coordinates of the top left sample of the current block are (0, 0), the left adjacent block may include samples at positions (-1, 0), (-1, H - 1), or (-1, (H - 1) / 2). Here, H represents the height of the current block. The upper adjacent block may include samples at positions (0, -1), (W - 1, -1), or ((W - 1) / 2, -1). Here, W represents the width of the current block.
[0302] When encoding adjacent blocks with general intra prediction, the MPM can be derived based on the intra prediction modes of the adjacent blocks. Specifically, the intra prediction mode of the left adjacent block can be set to the variable candIntraPredModeA, and the intra prediction mode of the upper adjacent block can be set to the variable candIntraPredModeB.
[0303] In this case, when the adjacent block is unavailable (for example, when the adjacent block has not been encoded / decoded yet, or when the position of the adjacent block is far from the image boundary), when the adjacent block is encoded with matrix-based intra prediction, and when the adjacent block is encoded with inter prediction or the adjacent block is included in a different coding tree unit from the current block, the variable candIntraPredModeX (where X is A or B) derived based on the intra prediction mode of the adjacent block can be set as the default mode. Here, the default mode may include at least one of the Planar mode, the DC mode, the vertical direction mode, or the horizontal direction mode.
[0304] Alternatively, when encoding adjacent blocks with intra prediction based on a matrix, the intra prediction mode corresponding to the index value for specifying any of the matrices can be set to candIntraPredModeX. To that end, a lookup table showing the mapping relationship between the index value for specifying the matrix and the intra prediction mode can be stored in advance in the encoder and the decoder.
[0305] The MPM can be derived based on the variables candIntraPredModeA and candIntraPredModeB. The number of MPMs included in the MPM list can be predefined in the encoder and the decoder. For example, the number of MPMs can be 3, 4, 5, or 6. Alternatively, information indicating the number of MPMs can be signaled via the bitstream. Alternatively, the number of MPMs can be determined based on at least one of the prediction coding mode of the adjacent block, the size or shape of the current block.
[0306] In the embodiments described later, it is assumed that the number of MPMs is 3, and these three MPMs are referred to as MPM[0], MPM[1], and MPM[2]. When the number of MPMs exceeds 3, the MPM may include the three MPMs described in the embodiments described later.
[0307] When candIntraPredA and candIntraPredB are equal and candIntraPredA is in the Planar mode or the DC mode, MPM[0] and MPM[1] can be set to the Planar mode and the DC mode, respectively. MPM[2] can be set to the vertical intra prediction mode, the horizontal intra prediction mode, or the diagonal direction intra prediction mode. The diagonal direction intra prediction mode can be the lower left diagonal direction intra prediction mode, the upper left direction intra prediction mode, or the upper right direction intra prediction mode.
[0308] When candIntraPredA and candIntraPredB are equal and candIntraPredA is in a directional intra prediction mode, MPM[0] can be set in the same way as candIntraPredA. MPM[1] and MPM[2] can be set as intra prediction modes similar to candIntraPredA. The intra prediction modes similar to candIntraPredA can be intra prediction modes where the index difference value of candIntraPredA is ±1 or ±2. The modulo operation (%) and an offset amount can be used to derive an intra prediction mode similar to candIntraPredA.
[0309] When candIntraPredA and candIntraPredB are different, MPM[0] can be set in the same way as candIntraPredA and MPM[1] can be set in the same way as candIntraPredB. In this case, when both candIntraPredA and candIntraPredB are in non-directional intra prediction modes, MPM[2] can be set to a vertical intra prediction mode, a horizontal intra prediction mode, or a diagonal direction intra prediction mode. Alternatively, when at least one of candIntraPredA and candIntraPredB is in a directional intra prediction mode, MPM[2] can be set to an intra prediction mode derived by adding or subtracting an offset value to Planar, DC, or the one with a larger value among candIntraPredA or candIntraPredB. Here, the offset value can be 1 or 2.
[0310] An MPM list including a plurality of MPMs can be generated, and information indicating whether the same MPM as the intra prediction mode of the current block is included in the MPM list can be signaled via a bitstream. The said information is a 1-bit flag and can be called an MPM flag. When the MPM flag indicates that the same MPM as the current block is included in the MPM list, index information for identifying any one of the MPMs can be signaled via the bitstream. The MPM specified by the said index information can be set as the intra prediction mode of the current block. When the MPM flag indicates that the same MPM as the current block is not included in the MPM list, residual mode information indicating any one of the remaining intra prediction modes excluding the MPM can be signaled via the bitstream. The residual mode information indicates an index value corresponding to the intra prediction mode of the current block when reassigning an index to the remaining intra prediction modes excluding the MPM. The decoder can determine the intra prediction mode of the current block by sorting the MPMs in ascending order and comparing the residual mode information with the MPMs. For example, when the residual mode information is less than or equal to the MPM, 1 can be added to the residual mode information to derive the intra prediction mode of the current block.
[0311] Instead of setting the default mode to MPM, information indicating whether the intra prediction mode of the current block is the default mode can be signaled via the bitstream. The said information is a 1-bit flag, which can be called the default mode flag. The default mode flag can be signaled only when the MPM flag indicates that the same MPM as the current block is included in the MPM list. As described above, the default mode may include at least one of Planar, DC, vertical mode or horizontal mode. For example, when Planar is set as the default mode, the default mode flag can indicate whether the intra prediction mode of the current block is Planar. When the default mode flag indicates that the intra prediction mode of the current block is not the default mode, any one of the MPMs indicated by the index information can be set as the intra prediction mode of the current block.
[0312] When setting a plurality of intra prediction modes to the default mode, index information indicating any one of the default modes can be signaled. The intra prediction mode of the current block can be set as the default mode indicated by the index information.
[0313] When the index of the reference sample line of the current block is not available, the default mode can be set to be unavailable. Thereby, when the index of the reference sample line is not 0, the value of the default mode flag can be set to a predefined value (i.e., false) without signaling the default mode flag.
[0314] When the intra prediction mode of the current block is determined, based on the determined intra prediction mode, the predicted samples of the current block can be obtained (S2903).
[0315] When the DC mode is selected, prediction samples for the current block can be generated based on the average value of the reference samples. Specifically, based on the average value of the reference samples, the values of all the samples within the prediction block can be generated. The average value can be derived using at least one of the upper reference sample located above the current block and the left reference sample located to the left of the current block.
[0316] Depending on the shape of the current block, the number or range of reference samples used to derive the average value may vary. For example, if the current block is a non-square block with a width greater than its height, the average value can be calculated using only the upper reference sample. On the other hand, if the current block is a non-square block with a width less than its height, the average value can be calculated using only the left reference sample. That is, when the width and height of the current block are different, the average value can be calculated using only the reference sample adjacent to the longer side. Alternatively, based on the ratio of the width to the height of the current block, it can be determined whether to calculate the average value using only the upper reference sample or only the left reference sample.
[0317] When the Planar mode is selected, prediction samples can be obtained using horizontal prediction samples and vertical prediction samples. Here, based on the left reference sample and the right reference sample located on the same horizontal line as the prediction sample, a horizontal prediction sample is obtained, and based on the upper reference sample and the lower reference sample located on the same vertical line as the prediction sample, a vertical prediction sample is obtained. Here, a reference sample adjacent to the upper right corner of the current block can be copied to generate a right reference sample, and a reference sample adjacent to the lower left corner of the current block can be copied to generate a lower reference sample. Based on the weighted superposition operation of the left reference sample and the right reference sample, a horizontal prediction sample can be obtained, and based on the weighted superposition operation of the upper reference sample and the lower reference sample, a vertical prediction sample can be obtained. In this case, based on the position of the prediction sample, the weight value assigned to each reference sample can be determined. Based on the average operation or weighted superposition operation of the horizontal prediction sample and the vertical prediction sample, a prediction sample can be obtained. When performing the weighted superposition operation, based on the position of the prediction sample, the weight values assigned to the horizontal prediction sample and the vertical prediction sample can be determined.
[0318] When the directional prediction mode is selected, a parameter representing the prediction direction (or prediction angle) of the selected directional prediction mode can be determined. Table 5 below shows the intra prediction parameter intraPredAng for each intra prediction mode.
Table 5
[0319] Table 5 shows the intra direction parameters of each intra prediction mode whose index is any one of 2 to 34 when 35 intra prediction modes are defined. When more than 33 directional intra prediction modes are defined, Table 5 can be further refined to set the intra direction parameters of each directional intra prediction mode.
[0320] After arranging the upper reference sample and the left reference sample of the current block in a row, a prediction sample can be obtained based on the value of the intra-direction parameter. In this case, when the value of the intra-direction parameter is a negative number, the left reference sample and the upper reference sample can be arranged in a row.
[0321] FIGS. 32 and 33 are diagrams showing examples of one-dimensional arrays in which reference samples are arranged in a row.
[0322] FIG. 32 shows an example of a one-dimensional array in the vertical direction in which reference samples are arranged vertically, and FIG. 33 shows an example of a one-dimensional array in the horizontal direction in which reference samples are arranged horizontally. Assuming that 35 intra prediction modes are defined, the examples of FIGS. 32 and 33 will be described.
[0323] When the intra prediction mode index is any one of 11 to 18, a one-dimensional horizontal array obtained by rotating the upper reference sample counterclockwise can be applied, and when the in-frame prediction mode index is any one of 19 to 25, a one-dimensional vertical array obtained by rotating the left reference sample clockwise can be applied. When arranging the reference samples in a row, the angle of the intra prediction mode can be considered.
[0324] Based on the intra-direction parameter, a reference sample determination parameter can be determined. The reference sample determination parameter may include a reference sample index for specifying a reference sample and a weight value parameter for determining a weight value applied to the reference sample.
[0325] The reference sample index iIdx and the weight parameter ifact can be obtained through the following Expressions 2 and 3, respectively.
Equation
Equation
[0326] In Equations 2 and 3, Pang represents an intra-direction parameter. The reference sample specified by the reference sample index iIdx corresponds to an integer pel.
[0327] To derive a prediction sample, at least one or more reference samples can be specified. Specifically, considering the slope of the prediction mode, the position of the reference sample used to derive the prediction sample can be specified. For example, the reference sample used to derive the prediction sample can be specified using the reference sample index iIdx.
[0328] In this case, if the slope of the intra prediction mode cannot be represented by one reference sample, a plurality of reference samples can be interpolated to generate a prediction sample. For example, if the slope of the intra prediction mode is a value between the slope between the prediction sample and the first reference sample and the slope between the prediction sample and the second reference sample, the first reference sample and the second reference sample can be interpolated to obtain a prediction sample. That is, when the angular line according to the intra prediction angle does not pass through the reference sample located at an integer pel, the reference samples adjacent to the left and right or above and below the position through which the angular line passes can be interpolated to obtain a prediction sample.
[0329] The following Equation 4 shows an example of obtaining a prediction sample based on a reference sample.
Equation
[0330] In Equation 4, P represents a prediction sample, and Ref_1D represents any of the one-dimensional arrayed reference samples. In this case, the position of the reference sample can be determined based on the position (x, y) of the prediction sample and the reference sample index iIdx.
[0331] When the slope of the intra prediction mode can be represented by one reference sample, the weight value parameter ifact can be set to 0. Therefore, Equation 4 can be simplified as the following Equation 5.
Number
[0332] Based on multiple intra prediction modes, intra prediction can be performed on the current block. For example, an intra prediction mode can be derived for each prediction sample, and a prediction sample can be derived based on the intra prediction mode assigned to each prediction sample.
[0333] Alternatively, an intra prediction mode can be derived for each region, and intra prediction can be performed on each region based on the intra prediction mode assigned to each region. Here, the region may include at least one sample. Based on at least one of the size, shape, or intra prediction mode of the current block, at least one of the size or shape of the region can be adaptively determined. Alternatively, the encoder and decoder can pre-define at least one of the size or shape of the region regardless of the size or shape of the current block.
[0334] Alternatively, an intra prediction can be performed based on each of a plurality of intra predictions, and a final prediction sample can be derived based on an average operation or a weighted sum operation of a plurality of prediction samples obtained through the plurality of intra predictions. For example, an intra prediction can be performed based on a first intra prediction mode to obtain a first prediction sample, and an intra prediction can be performed based on a second intra prediction mode to obtain a second prediction sample. Thereafter, a final prediction sample can be obtained based on an average operation or a weighted sum operation between the first prediction sample and the second prediction sample. In this case, considering whether the first intra prediction mode is a non-directional / directional prediction mode, whether the second intra prediction mode is a non-directional / directional prediction mode, or at least one of the intra prediction modes of adjacent blocks, weight values assigned to each of the first prediction sample and the second prediction sample can be determined.
[0335] The plurality of intra prediction modes can be a combination of a non-directional intra prediction mode and a directional prediction mode, a combination of directional prediction modes, or a combination of non-directional prediction modes.
[0336] FIG. 34 is a diagram showing an angle formed between a directional intra prediction mode and a straight line parallel to the x-axis.
[0337] As shown in FIG. 34, the directional prediction mode can exist between the lower left diagonal direction and the upper right diagonal direction. Explained in terms of the angle formed by the x-axis and the directional prediction mode, the directional prediction mode can exist between 45 degrees (lower left diagonal direction) and -135 degrees (upper right diagonal direction).
[0338] When the current block is non-square in shape, based on the intra prediction mode of the current block, among the reference samples located on the angular line following the intra prediction angle, instead of the reference sample close to the prediction sample, a reference sample located farther from the reference sample is used to derive the prediction sample.
[0339] FIG. 35 is a diagram showing an example of obtaining a prediction sample when the current block is non-square.
[0340] For example, as shown in FIG. 35(a), assume that the current block is a non-square with a width greater than its height, and the intra prediction mode of the current block is a directional intra prediction mode having an angle between 0 degrees and 45 degrees. In this case, when deriving the prediction sample A near the right column of the current block, among the reference samples located on the angle mode according to the angle, instead of the upper reference sample T close to the prediction sample, there may be a case of using the left reference sample L far from the prediction sample.
[0341] As another example, as shown in FIG. 35(b), assume that the current block is a non-square with a height greater than its width, and the intra prediction mode of the current block is a directional intra prediction mode having an angle between -90 degrees and -135 degrees. In this case, when deriving the prediction sample A near the lower part of the current block, among the reference samples located on the angle mode according to the angle, instead of the left reference sample L close to the prediction sample, there may be a case of using the upper reference sample T far from the prediction sample.
[0342] To solve the above problem, when the current block is non-square, the intra prediction mode of the current block can be replaced with an intra prediction mode in the reverse direction. Thereby, for non-square blocks, a directional prediction mode having an angle larger or smaller than the directional prediction mode shown in FIG. 31 can be used. Such a directional intra prediction mode can be defined as a wide-angle intra prediction mode. The wide-angle intra prediction mode indicates a directional intra prediction mode not belonging to the range from 45 degrees to -135 degrees.
[0343] FIG. 36 is a diagram showing the wide-angle intra prediction mode.
[0344] In the example shown in FIG. 36, the intra prediction modes with indexes from -1 to -14 and the intra prediction modes with indexes from 67 to 80 indicate the wide-angle intra prediction modes.
[0345] In FIG. 36, 14 wide-angle intra prediction modes (-1 to -14) having an angle greater than 45 degrees and 14 wide-angle intra prediction modes (67 to 80) having an angle less than -135 degrees are illustrated, but a larger or smaller number of wide-angle intra prediction modes can be defined.
[0346] When using the wide-angle intra prediction mode, the length of the upper reference sample can be set to 2W + 1, and the length of the left reference sample can be set to 2H + 1.
[0347] When using the wide-angle intra prediction mode, the sample A shown in FIG. 35(a) can be predicted using the reference sample T, and the sample A shown in FIG. 35(b) can be predicted using the reference sample L.
[0348] The existing intra prediction modes and N wide-angle intra prediction modes can be added, and a total of 67 + N intra prediction modes can be used. For example, Table 6 shows the intra-direction parameters of the intra prediction modes when 20 wide-angle intra prediction modes are defined.
Table 6
[0349] The intra-direction parameter can be set to be different based on at least one of the size, shape, or reference sample line of the current block. For example, in the case where the current block is square and the case where the current block is non-square, the intra-direction parameter of a specific intra prediction mode can be different. For example, the intra-direction parameter intraPredAngle of intra prediction mode 15 can have a larger value when the current block is square than when the current block is non-square.
[0350] Alternatively, the intra-direction parameter intraPredAngle of intra prediction mode 75 can have a larger value when the index of the reference sample line of the current block is 1 or more than when the index of the reference sample line of the current block is 0.
[0351] When the current block is non-square and the intra prediction mode of the current block obtained in step S2902 belongs to the conversion range, the intra prediction mode of the current block can be converted to a wide-angle intra prediction mode. The conversion range can be determined based on at least one of the size, shape, or ratio of the current block. Here, the ratio can indicate the ratio between the width and height of the current block.
[0352] When the current block is a non-square with a width larger than the height, the conversion range can be set from the intra prediction mode index in the upper right diagonal direction (for example, 66) to (the intra prediction mode index in the upper right diagonal direction - N). Here, N can be determined based on the ratio of the current block. When the intra prediction mode of the current block belongs to the conversion range, the intra prediction mode can be converted to a wide-angle intra prediction mode. The conversion can be performed by subtracting a predefined value from the intra prediction mode, and the predefined value can be the total number of intra prediction modes excluding the wide-angle intra prediction mode (for example, 67).
[0353] Based on the above embodiments, the intra prediction modes between No. 66 and No. 53 can be respectively converted into the wide-angle intra prediction modes between No. -1 and No. -14.
[0354] When the current block is a non-square with a height greater than the width, the conversion range can be set from the intra prediction mode index in the lower left diagonal direction (for example, 2) to (the index of the intra prediction mode in the lower left diagonal direction + M). Here, M can be determined based on the ratio of the current block. When the intra prediction mode of the current block belongs to the conversion range, the intra prediction mode can be converted into the wide-angle intra prediction mode. The conversion can be performed by adding a pre-defined value to the intra prediction mode, and the pre-defined value can be the total number of directional intra prediction modes excluding the wide-angle intra prediction mode (for example, 65).
[0355] Based on the above embodiments, the intra prediction modes between No. 2 and No. 15 can be respectively converted into the wide-angle intra prediction modes between No. 67 and No. 80.
[0356] Hereinafter, the intra prediction mode belonging to the conversion range is referred to as the wide-angle intra alternative prediction mode.
[0357] The conversion range can be determined based on the ratio of the current block. For example, Table 7 and Table 8 respectively show the conversion ranges when 35 intra prediction modes excluding the wide-angle intra prediction mode are defined and when 67 intra prediction modes are defined.
Table 7
Table 8
[0358] As shown in Table 7 and Table 8, depending on the ratio of the current block, the number of wide-angle intra alternative prediction modes included in the conversion range can be different.
[0359] In addition to the existing intra prediction mode, using the wide-angle intra prediction mode may increase the resources required to encode the wide-angle intra prediction mode, resulting in a potential decrease in encoding efficiency. Therefore, instead of directly encoding the wide-angle intra prediction mode, the encoding efficiency can be improved by encoding an alternative intra prediction mode for the wide-angle intra prediction mode.
[0360] For example, when encoding the current block using the wide-angle intra prediction mode No. 67, the alternative intra prediction mode No. 2 for the wide-angle intra prediction mode No. 67 can be encoded as the intra prediction mode of the current block. Further, when encoding the current block using the wide-angle intra prediction mode No. -1, the alternative intra prediction mode No. 66 for the wide-angle intra prediction mode No. -1 can be encoded as the intra prediction mode of the current block.
[0361] The decoder can decode the intra prediction mode of the current block and determine whether the decoded intra prediction mode is within the conversion range. If the decoded intra prediction mode is the wide-angle alternative intra prediction mode, the intra prediction mode can be converted to the wide-angle intra prediction mode.
[0362] Alternatively, when encoding the current block in the wide-angle intra prediction mode, the wide-angle intra prediction mode can also be directly encoded.
[0363] The encoding of the intra prediction mode can be realized based on the MPM list. Specifically, when encoding an adjacent block in the wide-angle intra prediction mode, the MPM can be set based on the wide-angle alternative intra prediction mode corresponding to the wide-angle intra prediction mode. For example, when encoding an adjacent block in the wide-angle intra prediction mode, the variable candIntraPredX (X is A or B) can be set as the wide-angle alternative intra prediction mode.
[0364] When a prediction block is generated as a result of performing intra prediction, the prediction samples can be updated based on the positions of the respective prediction samples included in the prediction block. The update method as described above can be referred to as an intra weighted prediction method based on sample positions (or a combination of position-dependent predictions (PDPC: Position Dependent Prediction Combination)).
[0365] It is possible to determine whether to use PDPC in consideration of the intra prediction mode of the current block, the reference sample line of the current block, the size of the current block, or the color component. For example, PDPC can be used when the intra prediction mode of the current block is at least one of the Planar mode, DC mode, vertical direction mode, horizontal direction mode, a mode with an index value smaller than the vertical direction, or a mode with an index value larger than the horizontal direction. Alternatively, PDPC can be used only when at least one of the width or height of the current block exceeds 4. Alternatively, PDPC can be used only when the index of the reference picture line of the current block is 0. Alternatively, PDPC can be used only when the index of the reference picture line of the current block is greater than or equal to a predefined value. Alternatively, PDPC can be used only for the luminance component. Alternatively, it is possible to determine whether to use PDPC according to whether two or more of the enumerated conditions are satisfied.
[0366] As another example, information indicating whether PDPC is applied can be signaled via a bitstream.
[0367] When obtaining a prediction sample via an intra prediction sample, a reference sample used to correct the prediction sample can be determined based on the position of the obtained prediction sample. For convenience of explanation, in the embodiments described later, the reference sample used to correct the prediction sample is referred to as a PDPC reference sample. Further, the prediction sample obtained via intra prediction is referred to as a first prediction sample, and the prediction sample obtained by correcting the first prediction sample is referred to as a second prediction sample.
[0368] FIG. 37 is a diagram showing the application of PDPC.
[0369] The first prediction sample can be corrected using at least one PDPC reference sample. The PDPC reference sample may include at least one of a reference sample adjacent to the upper left corner of the current block, an upper reference sample located above the current block, or a left reference sample located on the left side of the current block.
[0370] At least one of the reference samples belonging to the reference sample line of the current block can be set as the PDPC reference sample. Alternatively, regardless of the reference sample line of the current block, at least one of the reference samples belonging to the reference sample line of index 0 can be set as the PDPC reference sample. For example, even when the first prediction sample is obtained using the reference samples included in the reference sample line of index 1 or index 2, the second prediction sample can be obtained using the reference samples included in the reference sample line of index 0.
[0371] Considering at least one of the intra prediction mode of the current block, the size of the current block, the shape of the current block, or the position of the first prediction sample, the number or position of the PDPC reference samples used to correct the first prediction sample can be determined.
[0372] For example, when the intra prediction mode of the current block is the Planar mode or the DC mode, the second prediction sample can be obtained using the upper reference sample and the left reference sample. In this case, the upper reference sample can be a reference sample perpendicular to the first prediction sample (e.g., a reference sample with the same x coordinate), and the left reference sample can be a reference sample horizontal to the first prediction sample (e.g., a reference sample with the same y coordinate).
[0373] When the intra prediction mode of the current block is the horizontal intra prediction mode, the second prediction sample can be obtained using the upper reference sample. In this case, the upper reference sample can be a reference sample perpendicular to the first prediction sample.
[0374] When the intra prediction mode of the current block is the vertical intra prediction mode, the second prediction sample can be obtained using the left reference sample. In this case, the left reference sample can be a reference sample horizontal to the first prediction sample.
[0375] When the intra prediction mode of the current block is the lower left diagonal intra prediction mode or the upper right diagonal intra prediction mode, the second prediction sample can be obtained based on the upper left reference sample, the upper reference sample, and the left reference sample. The upper left reference sample can be a reference sample adjacent to the upper left corner of the current block (e.g., a reference sample at the (-1, -1) position). The upper reference sample can be a reference sample located in the upper right diagonal direction of the first prediction sample, and the left reference sample can be a reference sample located in the lower left diagonal direction of the first prediction sample.
[0376] In summary, when the position of the first prediction sample is (x, y), R(-1, -1) can be set as the upper left reference sample, and R(x + y + 1, -1) or R(x, -1) can be set as the upper reference sample. Also, R(-1, x + y + 1) or R(-1, y) can be set as the left reference sample.
[0377] As another example, the position of the left reference sample or the upper reference sample can be determined in consideration of at least one of the shape of the current block or whether the wide-angle intra mode is applied.
[0378] Specifically, when the intra prediction mode of the current block is the wide-angle intra prediction mode, a reference sample that is offset by about an offset value from a reference sample located in the diagonal direction of the first prediction sample can be set as the PDPC reference sample. For example, the upper reference sample R(x + y + k + 1, -1) and the left reference sample R(-1, x + y - k + 1) can be set as the PDPC reference samples.
[0379] In this case, the offset value k can be determined based on the wide-angle intra prediction mode. Expressions 6 and 7 show examples of deriving the offset value based on the wide-angle intra prediction mode.
Equation
Equation
[0380] The second prediction sample can be determined based on the weighted addition operation between the first prediction sample and the PDPC reference sample. For example, the second prediction sample can be obtained based on the following Expression 8.
Equation
[0381] In Equation 8, RL represents the left reference sample, RT represents the top reference sample, and RTL represents the top-left reference sample. pred(x, y) represents the predicted sample at the position (x, y). wL represents the weight value assigned to the left reference sample, wT represents the weight value assigned to the top reference sample, and wTL represents the weight value assigned to the top-left reference sample. The weight value assigned to the first predicted sample can be derived by subtracting the weight value assigned to the reference sample from the maximum value. For convenience of explanation, the weight value assigned to the PDPC reference sample is referred to as the PDPC weight value.
[0382] Based on at least one of the intra prediction mode of the current block or the position of the first predicted sample, the weight value assigned to each reference sample can be determined.
[0383] For example, at least one of wL, wT, or wTL and at least one of the x-axis coordinate value or y-axis coordinate value of the predicted sample may be in a proportional relationship or an inverse proportional relationship. Alternatively, at least one of wL, wT, or wTL and at least one of the width or height of the current block may be in a proportional relationship or an inverse proportional relationship.
[0384] When the intra prediction mode of the current block is the DC mode, the PDPC weight value can be determined as shown in Equation 9 below.
Equation
[0385] In Equation 9, x and y represent the position of the first predicted sample.
[0386] In Equation 9, based on the width or height of the current block, the variable shift used for the bit shift operation can be determined. For example, the variable shift can be derived based on Equation 10 or Equation 11 below.
Equation
Number
[0387] Alternatively, considering the intra-direction parameter of the current block, the variable shift can be derived.
[0388] The number and type of parameters used to derive the variable shift can be determined to vary according to the intra prediction mode of the current block. For example, when the intra prediction mode of the current block is the Planar mode, the DC mode, the vertical direction mode, or the horizontal direction mode, as shown in Equation 10 or Equation 11, the variable shift can be derived using the width and height of the current block. When the intra prediction mode of the current block is an intra prediction mode having an index larger than the vertical intra prediction mode, the variable shift can be derived using the height and the intra-direction parameter of the current block. When the intra prediction mode of the current block is an intra prediction mode having an index smaller than the horizontal intra prediction mode, the variable shift can be derived using the width and the intra-direction parameter of the current block.
[0389] When the intra prediction mode of the current block is the Planar mode, the value of wTL can be set to 0. wL and wT can be derived based on the following Equation 12.
Number
[0390] When the intra prediction mode of the current block is the horizontal intra prediction mode, wT can be set to 0, and wTL and wL can be set to the same value. On the other hand, when the intra prediction mode of the current block is the vertical intra prediction mode, wL can be set to 0, and wTL and wT can be set to the same value.
[0391] When the intra prediction mode of the current block is an intra prediction mode directed diagonally upward that has an index value larger than the vertical intra prediction mode, the PDPC weight value can be derived as in Equation 13 below.
Number
[0392] On the other hand, when the intra prediction mode of the current block is an intra prediction mode directed diagonally downward that has an index value smaller than the horizontal intra prediction mode, the PDPC weight value can be derived as in Equation 14 below.
Number
[0393] As in the above-described embodiments, the PDPC weight value can be determined based on the positions x and y of the prediction samples.
[0394] As another example, the weight value assigned to each PDPC reference sample can be determined in units of sub-blocks. The prediction samples included in the sub-block can share the same PDPC weight value.
[0395] The size of the sub-block, which is the basic unit used to determine the weight value in the encoder and decoder, can be predefined. For example, the weight value can be determined for each sub-block of size 2×2 or 4×4.
[0396] Alternatively, the size, shape, or number of sub-blocks can be determined according to the size or shape of the current block. For example, regardless of the size of the coding block, the coding block can be divided into four sub-blocks. Alternatively, based on the size of the coding block, the coding block can be divided into four or sixteen sub-blocks.
[0397] Alternatively, based on the current block's intra prediction mode, the size, shape, or number of sub - blocks can also be determined. For example, when the current block's intra prediction mode is the horizontal mode, N columns (or N rows) can be set as one sub - block. Conversely, when the current block's intra prediction mode is the vertical mode, N rows (or N columns) can be set as one sub - block.
[0398] Equations 15 - 17 show examples of determining the PDPC weight values of 2×2 - sized sub - blocks. Equation 15 shows an example when the current block's intra prediction mode is the DC mode. [Number]
[0399] In Equation 15, K can be a value determined based on the size of the sub - block or the intra prediction mode.
[0400] Equation 16 shows an example when the current block's intra prediction mode is an intra prediction mode that goes in the upper - right direction and has an index value larger than the vertical intra prediction mode. [Number]
[0401] Equation 17 shows an example when the current block's intra prediction mode is an intra prediction mode that goes in the lower - left direction and has an index value smaller than the horizontal intra prediction mode. [Number]
[0402] In Equations 15 to 17, x and y indicate the positions of reference samples within a sub-block. The reference sample can be any one of the sample located at the upper left of the sub-block, the sample located at the center of the sub-block, or the sample located at the lower right of the sub-block.
[0403] Equations 18 to 20 show examples of determining the PDPC weight values for a 4×4 size sub-block. Equation 18 shows an example when the intra prediction mode of the current block is the DC mode.
Equation
[0404] Equation 19 shows an example when the intra prediction mode of the current block is an intra prediction mode directed diagonally upward with an index value greater than that of the vertical intra prediction mode.
Equation
[0405] Equation 20 shows an example when the intra prediction mode of the current block is an intra prediction mode directed diagonally downward with an index value less than that of the horizontal intra prediction mode.
Equation
[0406] In the above-described embodiments, determination of the PDPC weight value has been described in consideration of the position of the first prediction sample or the prediction samples included in the sub-block. The PDPC weight value can also be determined in further consideration of the shape of the current block.
[0407] For example, in the case of the DC mode, the method of deriving the PDPC weight value can be different depending on whether the current block is a non-square with a width greater than the height or a non-square with a height greater than the width.
[0408] Equation 21 shows an example of deriving PDPC weight values when the current block is a non-square with a width greater than its height, and Equation 22 shows an example of deriving PDPC weight values when the current block is a non-square with a height greater than its width. [Number] [Number]
[0409] When the current block is non-square, the current block can be predicted using the wide-angle intra prediction mode. Thus, even when the wide-angle intra prediction mode is applied, PDPC can be applied to update the first prediction sample.
[0410] When wide-angle intra prediction is applied to the current block, the PDPC weight value can be determined in consideration of the shape of the coded block.
[0411] For example, when the current block is a non-square with a width greater than its height, based on the position of the first prediction sample, the upper reference sample located above and to the right of the first prediction sample may be closer to the first prediction sample than the left reference sample located below and to the left of the first prediction sample. Thus, when correcting the first prediction sample, the weight value applied to the upper reference sample can be set to have a larger value than the weight value applied to the left reference sample.
[0412] On the other hand, when the current block is a non-square with a height greater than its width, based on the position of the first prediction sample, the left reference sample located below and to the left of the first prediction sample may be closer to the first prediction sample than the upper reference sample located above and to the right of the first prediction sample. Thus, when correcting the first prediction sample, the weight value applied to the left reference sample can be set to have a larger value than the weight value applied to the upper reference sample.
[0413] Equation 23 shows an example of deriving a PDPC weight value when the intra prediction mode of the current block is a wide-angle intra prediction mode with an index greater than 66.
Number
[0414] Equation 24 shows an example of deriving a PDPC weight value when the intra prediction mode of the current block is a wide-angle intra prediction mode with an index less than 0.
Number
[0415] The PDPC weight value can also be determined based on the ratio of the current block. The ratio of the current block indicates the ratio of the width to the height of the current block and can be defined as in Equation 25 below.
Number
[0416] Based on the intra prediction mode of the current block, a method for deriving the PDPC weight value can be variably determined.
[0417] For example, Equations 26 and 27 show examples of deriving a PDPC weight value when the intra prediction mode of the current block is the DC mode. Specifically, Equation 26 is an example when the current block is a non-square with a width greater than the height, and Equation 27 is an example when the current block is a non-square with a height greater than the width.
Number
Number
[0418] Equation 28 shows an example of deriving PDPC weight values when the intra prediction mode of the current block is a wide-angle intra prediction mode with an index greater than 66.
Number
[0419] Equation 29 shows an example of deriving PDPC weight values when the intra prediction mode of the current block is a wide-angle intra prediction mode with an index less than 0.
Number
[0420] A predicted image can be subtracted from the original image to derive a derived residual image. In this case, when the residual image is in the frequency domain, even if high-frequency components among the frequency components are removed, the video quality is not significantly degraded. As a result, if the values of the high-frequency components are slightly changed and the values of the high-frequency components are set to 0, there is an effect that the compression efficiency can be improved without generating obvious visual distortion. Reflecting the above characteristics, the current block can be transformed to decompose the residual image into two-dimensional frequency components. The transformation can be performed using a transformation method such as a discrete cosine transform (DCT: Discrete Cosine Transform) or a discrete sine transform (DST: Discrete Sine Tranform).
[0421] The DCT uses the cosine transform to decompose (or transform) the residual image into two-dimensional frequency components, and the DST uses the sine transform to decompose (or transform) the residual image into two-dimensional frequency components. The conversion result of the residual image, the frequency components, can be represented by the base image. For example, when performing DCT conversion on a block of size N×N, N2 basic pattern components can be obtained. Through the conversion, the size of each basic pattern component included in the N×N-sized block can be obtained. Based on the conversion technology used, the size of the basic pattern component can be called the DCT coefficient or the DST coefficient.
[0422] The conversion technology DCT is mainly used to convert images with a large distribution of low-frequency components other than 0. The conversion technology DST is mainly used for images with a large distribution of high-frequency components.
[0423] It is also possible to convert the residual image using a conversion technology other than DCT or DST.
[0424] Hereinafter, converting the residual image into two-dimensional frequency components is called two-dimensional image conversion. Furthermore, the size of the basic pattern component obtained from the conversion result is called the conversion coefficient. For example, the conversion coefficient can refer to the DCT coefficient or the DST coefficient. When applying the primary conversion and the secondary conversion described later simultaneously, the conversion coefficient can represent the size of the basic pattern component generated by the result of the secondary conversion.
[0425] The conversion technology can be determined in block units. Based on at least one of the prediction coding mode of the current block, the size of the current block, or the shape of the current block, the conversion technology can be determined. For example, when encoding the current block in the intra prediction mode and the size of the current block is smaller than N×N, the conversion technology DST can be used to perform the conversion. On the other hand, when the above conditions are not met, the conversion technology DCT can be used to perform the conversion.
[0426] In the residual image, two-dimensional image transformation may not be performed on some blocks. Not performing two-dimensional image transformation can be called transform skip. When transform skip is applied, quantization can be applied to the residual values for which the transformation has not been performed.
[0427] After transforming the current block using DCT or DST, the transformed current block can be re-transformed. In this case, the transformation based on DCT or DST can be defined as the primary transformation, and re-transforming the block to which the primary transformation has been applied can be defined as the secondary transformation.
[0428] The primary transformation can be performed using any of a plurality of transform core candidates. For example, the primary transformation can be performed using any of DCT2, DCT8, or DCT7.
[0429] For the horizontal and vertical directions, different transform cores can also be used. Information indicating the combination of the horizontal transform core and the vertical transform core can also be signaled via the bitstream.
[0430] The execution units of the primary transformation and the secondary transformation may be different. For example, the primary transformation can be performed on an 8×8 block, and the secondary transformation can be performed on a 4×4-sized sub-block among the transformed 8×8 blocks. In this case, the transform coefficients of the remaining regions where the secondary transformation is not performed can also be set to 0.
[0431] Alternatively, the primary transformation can be performed on a 4×4 block, and the secondary transformation can be performed on an 8×8-sized region including the transformed 4×4 block.
[0432] Information indicating whether to perform the secondary transformation can be signaled via the bitstream.
[0433] Alternatively, it is possible to determine whether to perform the secondary transformation based on whether the horizontal transformation core and the vertical transformation core are the same. For example, the secondary transformation can be executed only when the horizontal transformation core and the vertical transformation core are identical. Alternatively, the secondary transformation can be executed only when the horizontal transformation core and the vertical transformation core are different.
[0434] Alternatively, the secondary transformation can be enabled only when the horizontal transformation and the vertical transformation use a pre-defined transformation core. For example, when the DCT2 transformation core is used for the horizontal transformation and the vertical transformation, the secondary transformation can be enabled.
[0435] Alternatively, it is possible to determine whether to perform the secondary transformation based on the number of non-zero transformation coefficients of the current block. For example, when the number of non-zero transformation coefficients of the current block is less than or equal to a threshold, the secondary transformation can be set not to be used, and when the number of non-zero transformation coefficients of the current block exceeds the threshold, the secondary transformation can be set to be used. It is also possible to set the secondary transformation to be used only when the current block is encoded by intra prediction.
[0436] Based on the shape of the current block, it is possible to determine the size and shape of the sub-block for which the secondary transformation is to be performed.
[0437] FIGs. 38 and 39 are diagrams showing the sub-blocks for which the secondary transformation is performed.
[0438] When the current block is square, after performing the primary transformation, the secondary transformation can be performed on the N×N size sub-block in the upper left corner of the current block. For example, when the current block is an 8×8 size encoded block, after performing the primary transformation on the current block, the secondary transformation can be performed on the 4×4 size sub-block in the upper left corner of the current block (see FIG. 38).
[0439] If the current block is a non-square where the width is more than four times the height, after performing the primary transformation, a secondary transformation can be performed on the (kN) × (4kN) - sized sub - block in the upper - left corner of the current block. For example, if the current block is a non - square of size 16×4, after performing the primary transformation on the current block, a secondary transformation can be performed on the 2×8 - sized sub - block in the upper - left corner of the current block (see Fig. 39(a)).
[0440] If the current block is a non - square where the height is more than four times the width, after performing the primary transformation, a secondary transformation can be performed on the (4kN) × (kN) - sized sub - block in the upper - left corner of the current block. For example, if the current block is a non - square of size 16×4, after performing the primary transformation on the current block, a secondary transformation can be performed on the 2×8 - sized sub - block in the upper - left corner of the current block (see Fig. 39(b)).
[0441] The decoder can perform the inverse transformation of the secondary transformation (the second inverse transformation) and then perform the inverse transformation of the primary transformation (the first inverse transformation) on the execution result. The execution results of the second inverse transformation and the first inverse transformation and the residual signal of the current block can be obtained.
[0442] Quantization is used to reduce the energy of the block, and the quantization process includes a process of dividing the transformation coefficient by a specific constant. The constant can be derived from the quantization parameter, and the quantization parameter can be defined as a value from 1 to 63.
[0443] When the encoder performs transformation and quantization, the decoder can obtain the residual block through inverse quantization and inverse transformation. In the decoder, the predicted block and the residual block can be added to obtain the restored block of the current block.
[0444] Information indicating the conversion type of the current block can be signaled via the bitstream. The information can be index information tu_mts_idx indicating one of the combinations of the horizontal conversion type and the vertical conversion type.
[0445] Based on the candidate conversion types specified by the index information tu_mts_idx, the vertical conversion core and the horizontal conversion core can be determined. Tables 9 and 10 show the combinations of conversion types by tu_mts_idx.
Table 9
Table 10
[0446] The conversion type can be determined as either DCT2, DST7, DCT8, or conversion skip. Alternatively, excluding conversion skip, only the conversion cores can be used to form candidates for combinations of conversion types.
[0447] When using Table 9, if tu_mts_idx is 0, conversion skip can be applied both horizontally and vertically. If tu_mts_idx is 1, DCT2 can be applied both horizontally and vertically. If tu_mts_idx is 3, DCT8 can be applied horizontally and DCT7 can be applied vertically.
[0448] When using Table 10, if tu_mts_idx is 0, DCT2 can be applied both horizontally and vertically. If tu_mts_idx is 1, conversion skip can be applied both horizontally and vertically. If tu_mts_idx is 3, DCT8 can be applied horizontally and DCT7 can be applied vertically.
[0449] Based on at least one of the current block size, shape, or number of non-zero coefficients, it is possible to determine whether to encode the index information. For example, if the number of non-zero coefficients is less than or equal to a threshold, the default conversion type can be applied to the current block without signaling the index information. Here, the default conversion type can be DST7. Alternatively, the default mode can be different according to the current block size, shape, or intra prediction mode.
[0450] A threshold can be determined based on the current block size or shape. For example, if the current block size is less than or equal to 32×32, the threshold can be set to 2, and if the current block size exceeds 32×32 (for example, if the current block is an encoded block of size 32×64 or 64×32), the threshold can be set to 4.
[0451] Multiple look-up tables can be pre-stored in the encoder / decoder. In the multiple look-up tables, at least one of the index values assigned to the candidate combinations of conversion types, the types of candidate combinations of conversion types, or the number of candidate combinations of conversion types may be different.
[0452] Based on at least one of the current block size, shape, predictive coding mode, intra prediction mode, whether to apply secondary conversion, or whether to apply conversion skip to adjacent blocks, the look-up table for the current block can be selected.
[0453] For example, if the current block size is less than or equal to 4×4, or if the current block is encoded using inter prediction, the look-up table in Table 9 can be used, and if the current block size exceeds 4×4, or if the current block is encoded using intra-block prediction, the look-up table in Table 10 can be used.
[0454] Alternatively, information indicating any one of a plurality of look-up tables can be signaled via a bit stream. The decoder can select the look-up table for the current block based on the information.
[0455] As another example, an index assigned to a combination candidate of transform types can be adaptively determined based on at least one of the size, shape, predictive coding mode, intra prediction mode, whether to apply secondary transformation, or whether to apply transform skip to adjacent blocks of the current block. For example, when the size of the current block is 4×4, the index value assigned to transform skip can be smaller than the index value assigned to transform skip when the size of the current block exceeds 4×4. Specifically, when the size of the current block is 4×4, index 0 can be assigned to transform skip, and when the current block is larger than 4×4 and 16×16 or less, an index larger than 0 (for example, index 1) can be assigned to transform skip. When the current block exceeds 16×16, the maximum value (for example, 5) can be assigned to the index of transform skip.
[0456] Alternatively, when the current block is encoded in inter prediction, index 0 can be assigned to transform skip. When the current block is encoded in intra prediction, an index larger than 0 (for example, index 1) can be assigned to transform skip.
[0457] Alternatively, when the current block is a 4×4 size block encoded in inter prediction, index 0 can be assigned to transform skip. On the other hand, when the current block is not encoded in inter prediction or the current block exceeds 4×4, an index larger than 0 (for example, index 1) can be assigned to transform skip.
[0458] It is also possible to define and use candidate combinations of conversion types that are different from the candidate combinations of conversion types listed in Tables 9 and 10. For example, a candidate combination of conversion types can be used for one of the horizontal or vertical conversions where a conversion skip is applied, and a conversion core such as DCT7, DCT8, or DST2 is applied for the other. In this case, based on at least one of the current block size (e.g., width and / or height), shape, predictive coding mode, or intra prediction mode, it is possible to determine whether to use a conversion skip as a candidate for the horizontal or vertical conversion type.
[0459] Alternatively, information indicating whether a specific conversion type candidate can be used can be signaled via a bitstream. For example, a flag indicating whether horizontal and vertical conversion skips can be used as candidates for the conversion type can be signaled. Based on the flag, it is possible to determine whether a specific candidate combination of conversion types is included in a plurality of candidate combinations of conversion types.
[0460] Alternatively, information indicating whether a candidate of a specific conversion type is applied to the current block can be signaled via a bitstream. For example, a flag cu_mts_flag indicating whether to apply DCT2 in the horizontal and vertical directions can be signaled. When the value of cu_mts_flag is 1, DCT2 can be set as the conversion core in the vertical and horizontal directions. When the value of cu_mts_flag is 0, DCT8 or DST7 can be set as the conversion core in the vertical and horizontal directions. Alternatively, when the value of cu_mts_flag is 0, information tu_mts_idx specifying one of a plurality of candidate combinations of conversion types can be signaled.
[0461] When the current block is a non-square where the width is greater than the height or a non-square where the height is greater than the width, the encoding of cu_mts_flag can be omitted and the value of cu_mts_flag can be regarded as 0.
[0462] Depending on the size, shape, or intra prediction mode of the current block, the number of candidate combinations of available transform types can be set differently. For example, when the current block is square, three or more candidate combinations of transform types can be used, and when the current block is non-square, two candidate combinations of transform types can be used. Alternatively, when the current block is square, only candidate combinations of transform types in which the horizontal transform type and the vertical transform type are different among the candidate combinations of transform types can be used.
[0463] When there are three or more candidate combinations of transform types available for the current block, index information tu_mts_idx indicating one of the candidate combinations of transform types can be signaled. On the other hand, when there are two candidate combinations of transform types available for the current block, a flag mts_flag indicating either of the candidate combinations of transform types can be signaled. Table 11 below shows the process of encoding information for specifying candidate combinations of transform types according to the shape of the current block.
Table 11
[0464] According to the shape of the current block, the indexes of the candidate combinations of transform types can be rearranged (or reordered). For example, the index assigned to the candidate combination of transform types when the current block is square can be different from the index assigned to the candidate combination of transform types when the current block is non-square. For example, when the current block is square, the combination of transform types can be selected based on Table 12 below, and when the current block is non-square, the combination of transform types can be selected based on Table 13 below.
Table 12
Table 13
[0465] Based on the number of non-zero coefficients in the horizontal direction or the number of non-zero coefficients in the vertical direction of the current block, the conversion type can be determined. Here, the number of non-zero coefficients in the horizontal direction indicates the number of non-zero coefficients included in 1×N (where N is the width of the current block), and the number of non-zero coefficients in the vertical direction indicates the number of non-zero coefficients included in N×1 (where N is the height of the current block). If the maximum value of the non-zero coefficients in the horizontal direction is less than or equal to the threshold value, a primary conversion type is applied in the horizontal direction. If the maximum value of the non-zero coefficients in the horizontal direction exceeds the threshold value, a secondary conversion type can be applied in the horizontal direction. If the maximum value of the non-zero coefficients in the vertical direction is less than or equal to the threshold value, a primary conversion type is applied in the vertical direction. If the maximum value of the non-zero coefficients in the vertical direction exceeds the threshold value, a secondary conversion type can be applied in the vertical direction.
[0466] FIG. 40 is a diagram for explaining an example of determining the conversion type of the current block.
[0467] For example, when encoding the current block by intra prediction, if the maximum value of the non-zero coefficients in the horizontal direction of the current block is less than or equal to 2 (see FIG. 40(a)), DST7 can be determined as the conversion type in the horizontal direction.
[0468] When encoding the current block by intra prediction, if the maximum value of the non-zero coefficients in the vertical direction of the current block exceeds 2 (see FIG. 40(b)), DCT2 or DCT8 can be determined as the conversion type in the vertical direction.
[0469] The residual coefficients can be encoded by a conversion unit or a sub-conversion unit. Here, the residual coefficients refer to the conversion coefficients generated by conversion, the conversion skip coefficients generated by conversion skip, or the quantized coefficients generated by quantizing the conversion coefficients or coefficients.
[0470] The conversion unit can indicate a block on which primary conversion or secondary conversion has been performed. The sub-conversion unit indicates a block smaller than the conversion unit. For example, the sub-conversion unit can be a block of size 4×4, 2×8, or 8×2.
[0471] Based on the size or shape of the current block, at least one of the size or shape of the sub-conversion unit can be determined. For example, if the current block is a non-square where the width is greater than the height, the sub-conversion unit can also be set to a non-square where the width is greater than the height (e.g., 8×2). If the current block is a non-square where the height is greater than the width, the sub-conversion unit can also be set to a non-square where the height is greater than the width (e.g., 2×8). If the current block is a square, the sub-conversion unit can also be set to a square (e.g., 4×4).
[0472] If the current block contains a plurality of sub-conversion units, the sub-conversion units can be sequentially encoded / decoded. Entropy coding such as Arithmetic Coding can be used to encode the residual coefficients. Hereinafter, with reference to the drawings, the encoding / decoding method of the residual coefficients will be described in detail.
[0473] FIG. 41 is a flowchart of a method for encoding residual coefficients.
[0474] In this embodiment, it is assumed that the current block contains one or more sub-conversion units. Further, it is assumed that the size of the sub-conversion unit is 4×4. However, this embodiment can be directly applied even if the size of the sub-conversion unit is different from this, or if the shape of the sub-conversion unit is different from this.
[0475] It is possible to determine whether there is a non-zero coefficient in the current block (S4101). The non-zero coefficient indicates a residual coefficient whose absolute value exceeds 0. Information indicating whether there is a non-zero coefficient in the current block can be encoded and signaled. For example, the information can be a 1-bit flag CBF (Coded Block Flag).
[0476] If there is a non-zero coefficient in the current block, it is possible to determine whether there is a non-zero coefficient in each sub-transformation unit (S4102). Information indicating whether there is a non-zero coefficient in each sub-transformation unit can be encoded and signaled. For example, the information can be a 1-bit flag, the coded sub-block flag (CSBF: Coded SubBlock Flag). The sub-transformation unit can be encoded according to the selected scanning order.
[0477] If there is a non-zero coefficient in the sub-transformation unit, in order to encode the residual coefficients of the sub-transformation unit, the residual coefficients in the sub-transformation unit can be arranged one-dimensionally (S4103). The residual coefficients can be arranged one-dimensionally according to the selected scanning order.
[0478] The scanning order can include at least one of diagonal scanning, horizontal scanning, vertical scanning, or the reverse of these.
[0479] Figures 42 and 43 are diagrams showing the arrangement order of residual coefficients in different scanning orders.
[0480] Figures 42(a) to 42(c) show diagonal scanning, horizontal scanning, and vertical scanning, and Figures 43(a) to 43(c) show the reverse of these.
[0481] The residual coefficients can be arranged one-dimensionally according to the selected scanning order.
[0482] The scanning order can be determined in consideration of at least one of the current block size, shape, intra prediction mode, the transform core used for primary transform, or whether to apply secondary transform. For example, if the current block is a non-square with a width greater than its height, reverse horizontal scanning can be used to encode the residual coefficients. On the other hand, if the current block is a non-square with a height greater than its width, reverse vertical scanning can be used to encode the residual coefficients.
[0483] Alternatively, the rate distortion optimization (RDO) of each of a plurality of scanning orders can be calculated, and the scanning order with the lowest RDO can be determined as the scanning order of the current block. In this case, the information indicating the scanning order of the current block can be encoded and signaled.
[0484] The scanning order candidates available when encoding the transform skip coefficient can be different from the scanning order candidates available when encoding the transform coefficient. For example, the reverse direction of the scanning order candidates available when encoding the transform coefficient can be set as the scanning order candidates available when encoding the transform skip coefficient.
[0485] For example, when the transform coefficient is encoded using any of reverse diagonal scanning, reverse horizontal scanning, or reverse vertical scanning, the transform skip coefficient can be encoded using any of diagonal scanning, horizontal scanning, or vertical scanning.
[0486] Thereafter, the position of the last non-zero coefficient in the scanning order within the transform block can be encoded (S4103). The x-axis position and y-axis position of the last non-zero coefficient can be encoded respectively.
[0487] FIG. 44 is a diagram showing an example of encoding the position of the last non-zero coefficient.
[0488] As shown in FIG. 44, in the case of diagonal scanning, the residual coefficient located at the upper right corner of the conversion block can be set as the last non-zero coefficient. The x-axis coordinate LastX of the residual coefficient is 3, and the y-axis coordinate LastY is 0. LastX can be separated into a prefix part last_sig_coeff_x_prefix and a suffix part last_sig_coeff_x_suffix and encoded. LastY can also be separated into a prefix part last_sig_coeff_y_prefix and a suffix part last_sig_coeff_y_suffix and encoded.
[0489] When the position of the last non-zero coefficient is determined, for each residual coefficient whose scanning order precedes that of the last non-zero coefficient, information indicating whether the residual coefficient is a non-zero coefficient can be encoded (S4104). The information can be a 1-bit flag, sig_coeff_flag. When the residual coefficient is 0, the value of the non-zero coefficient flag sig_coeff_flag can be set to 0, and when the residual coefficient is 1, the value of the non-zero coefficient flag sig_coeff_flag can be set to 1. For the last non-zero coefficient, the encoding of the non-zero coefficient flag sig_coeff_flag can be omitted. When the encoding of the non-zero coefficient flag sig_coeff_flag is omitted, the residual coefficient is considered to be non-zero.
[0490] Regarding the conversion skip coefficient, information regarding the position of the last non-zero coefficient can be not encoded. In this case, for all conversion skip coefficients within the block, the non-zero coefficient flag sig_coeff_flag can be encoded.
[0491] Alternatively, information indicating whether information on the position of the last non-zero coefficient is encoded can be encoded and signaled. The information can be a 1-bit flag. The decoder can determine whether to decode information on the position of the last non-zero coefficient based on the value of the flag. If the position of the last non-zero coefficient is not decoded, for all transform skip coefficients, the flag of the non-zero coefficient can be decoded. On the other hand, if the position of the last non-zero coefficient is decoded, for each transform skip coefficient whose scan order precedes that of the last non-zero coefficient, information indicating whether the transform skip coefficient is a non-zero coefficient can be encoded.
[0492] The DC component of the transform coefficient or the transform skip coefficient can be set not to be zero. Here, the DC component can indicate a sample located at the upper left of the sample or block whose scan order is last. For the DC component, encoding of the residual coefficient as the non-zero coefficient flag sig_coeff_flag can be omitted. When encoding of the non-zero coefficient flag sig_coeff_flag is omitted, the residual coefficient is considered not to be 0.
[0493] When the residual coefficient is not 0, information indicating the absolute value of the residual coefficient and information indicating the sign of the residual coefficient can be encoded (S4105). The encoding process of the information indicating the absolute value of the residual coefficient will be described in more detail with reference to FIG. 45.
[0494] For all residual coefficients after the last non-zero coefficient and for each sub-transform unit included in the current block, encoding of the residual coefficient can be sequentially performed (S4106, S4107).
[0495] FIG. 45 is a flowchart of a process for encoding the absolute value of the residual coefficient.
[0496] When the absolute value of the residual coefficient exceeds 0, it is possible to encode the residual coefficient or information indicating whether the residual coefficient is even or odd (S4501). Here, the residual coefficient can be defined as the value obtained by subtracting 1 from the absolute value of the residual coefficient. The information may be a 1-bit parity flag. For example, a value of 0 for the syntax element par_level_flag indicates that the residual coefficient or the remaining coefficient is even, and a value of 1 for the syntax element par_level_flag indicates that the residual coefficient or the remaining coefficient is odd. The value of the syntax element par_level_flag can be determined based on the following formula 30.
Number
[0497] In formula 30, Tcoeff represents the residual coefficient, and abs() represents the absolute value function.
[0498] It is possible to divide the residual coefficient or the remaining coefficient by 2, or apply a bit shift operation to the residual coefficient or the remaining coefficient to derive an adjusted remaining coefficient (S4502). Specifically, the quotient obtained by dividing the residual coefficient by 2 can be set as the adjusted remaining coefficient, or the value obtained by shifting the remaining coefficient 1 bit to the right can be set as the adjusted remaining coefficient.
[0499] For example, the adjusted remaining coefficient can be derived based on the following formula 31.
Number
[0500] In formula 31, ReRemLevel represents the adjusted remaining coefficient, and RemLevel represents the remaining coefficient.
[0501] Thereafter, it is possible to encode information indicating the size of the adjusted remaining coefficient. The information indicating the size of the adjusted remaining coefficient may include information indicating whether the adjusted remaining coefficient is greater than N. Here, N can be an integer such as 1, 2, 3, 4, etc.
[0502] For example, information indicating whether the value of the adjustment residual coefficient is greater than 1 can be encoded (S4503). The information can be a 1-bit flag rem_abs_gt1_flag.
[0503] When the residual coefficient is 0 or 1, the value of rem_abs_gt1_flag can be set to 0. That is, when the residual coefficient is 1 or 2, the value of rem_abs_gt1_flag can be set to 0. In this case, when the residual coefficient is 0, par_level_flag can be set to 0, and when the residual coefficient is 1, par_level_flag can be set to 1.
[0504] When the adjustment residual coefficient is 2 or more (S4504), the value of rem_abs_gt1_flag can be set to 1, and information indicating whether the value of the adjustment residual coefficient is greater than 2 can be encoded (S4505). The information can be a 1-bit flag rem_abs_gt2_flag.
[0505] When the residual coefficient is 1 or 2, the value of rem_abs_gt2_flag can be set to 0. That is, when the residual coefficient is 3 or 4, the value of rem_abs_gt2_flag can be set to 0. In this case, when the residual coefficient is 2, par_level_flag can be set to 0, and when the residual coefficient is 3, par_level_flag can be set to 1.
[0506] When the adjustment residual coefficient exceeds 2, the residual value information obtained by subtracting 2 from the adjustment residual coefficient can be encoded (S4506). That is, after subtracting 5 from the absolute value of the residual coefficient, the result value divided by 2 can be encoded as the residual value information.
[0507] Although not shown, a flag indicating whether the adjusted residual coefficient exceeds 3 (e.g., rem_abs_gt3_flag) or a flag indicating whether the adjusted residual coefficient exceeds 4 (rem_abs_gt4_flag) can be further used to encode the residual coefficient. In this case, the value obtained by subtracting the maximum value from the adjusted residual coefficient can be set as the residual value. The maximum value indicates the maximum N values among the rem_abs_gtN_flag.
[0508] Instead of using a flag that compares the value of the adjusted residual coefficient with a specified value, a flag that compares the absolute value of the adjustment coefficient or the residual coefficient with a specified value can also be used. For example, instead of rem_abs_gt1_flag, a gr2_flag indicating whether the absolute value of the residual coefficient exceeds 2 can be used, and instead of rem_abs_gt2_flag, a gr4_flag indicating whether the absolute value of the residual coefficient exceeds 4 can be used.
[0509] Table 14 briefly shows the process of encoding the residual coefficient using syntax elements.
Table 14
[0510] As in the above example, the residual coefficient can be encoded using par_level_flag and at least one rem_abs_gtN_flag (where N is an integer such as 1, 2, 3, 4, etc.).
[0511] The rem_abs_gtN_flag indicates whether the residual coefficient exceeds 2N. For residual coefficients of 2N - 1 or 2N, set rem_abs_gt(N - 1)_flag to true and rem_abs_gtN_flag to false. Also, for a residual coefficient of 2N - 1, the par_level_flag value can be set to 0, and for a residual coefficient of 2N, the par_level_flag value can be set to 1. That is, for residual coefficients of 2N or less, they can be encoded using rem_abs_gtN_flag and par_level_flag.
[0512] For residual coefficients greater than or equal to 2MAX + 1, residual value information obtained by dividing the difference value from 2MAX by 2 can be encoded. Here, MAX represents the maximum value of N. For example, when using rem_abs_gt1_flag and rem_abs_gt2_flag, MAX can be 2.
[0513] The decoder can also decode the residual coefficients according to the order shown in FIG. 45. Specifically, the decoder can determine the position of the last non-zero coefficient and decode the sig_coeff_flag for each residual coefficient whose scanning order precedes that of the last non-zero coefficient.
[0514] When the sig_coeff_flag is true, the par_level_flag of the residual coefficient can be decoded. Further, the rem_abs_gt1_flag of the residual coefficient can be decoded. In this case, based on the value of rem_abs_gt(N - 1)_flag, rem_abs_gtN_flag can be further decoded. For example, when the value of rem_abs_gt(N - 1)_flag is 1, rem_abs_gtN_flag can be decoded. For example, when the value of rem_abs_gt1_flag of the residual coefficient is 1, the rem_abs_gt2_flag of the residual coefficient can be further analyzed. When the value of rem_abs_gt(MAX)_flag is 1, the residual value information can be decoded.
[0515] When the value of rem_abs_gtN_flag of the residual coefficient is 0, based on the value of par_level_flag, the value of the residual coefficient can be determined as 2N - 1 or 2N. Specifically, when par_level_flag is 0, the residual coefficient is set to 2N - 1, and when par_level_flag is 1, the residual coefficient can be set to 2N.
[0516] For example, when rem_abs_gt1_flag is 0, based on the par_level_flag value, the absolute value of the residual coefficient can be set to 1 or 2. Specifically, when the par_level_flag value is 0, the absolute value of the residual coefficient is 1, and when the par_level_flag value is 1, the absolute value of the residual coefficient is 2.
[0517] For example, when rem_abs_gt2_flag is 0, based on the par_level_flag value, the absolute value of the residual coefficient can be set to 3 or 4. Specifically, when the par_level_flag value is 0, the absolute value of the residual coefficient is 3, and when the par_level_flag value is 1, the absolute value of the residual coefficient is 4.
[0518] When decoding the residual value information, based on the value of par_level_flag, the residual coefficient can be set to 2(MAX + R) - 1 or 2(MAX + R). Here, R represents the value indicated by the residual value information. For example, when par_level_flag is 0, the residual coefficient is set to 2(MAX + R) - 1, and when par_level_flag is 1, the residual coefficient can be set to 2(MAX + R). For example, when MAX is 2, the residual coefficient can be derived based on the following formula 32.
Number
[0519] When encoding the residual coefficient based on the example shown in FIG. 45, it is necessary to encode the parity flags of all non-zero coefficients. For example, even when the residual coefficient is 1, it is necessary to encode par_level_flag and rem_abs_gt1_flag. The encoding method as described above causes a problem of increasing the number of bits required to encode a residual coefficient whose absolute value is 1. In order to avoid such a problem, after first encoding the information indicating whether the residual coefficient exceeds 1, when the residual coefficient exceeds 1, the parity flag can be encoded.
[0520] FIG. 46 is a flowchart of a process for encoding the absolute value of the residual coefficient.
[0521] For non-zero residual coefficients, information gr1_flag indicating whether the absolute value of the residual coefficient exceeds 1 can be encoded (S4601). When the residual coefficient is 1, gr1_flag can be set to 0, and when the residual coefficient exceeds 1, gr1_flag can be set to 1.
[0522] When the absolute value of the residual coefficient exceeds 1, a parity flag indicating whether the residual coefficient or the residual is even or odd can be encoded (S4602, S4603). Here, the residual coefficient can be set to a value obtained by subtracting 2 from the residual coefficient. For example, par_level_flag can be derived based on the following Equation 33.
Equation
[0523] The residual coefficient or the residual can be divided by 2, or the residual coefficient or the residual can be right-shifted by 1 bit to derive an adjusted residual, and information indicating whether the adjusted residual exceeds 1 can be encoded (S4604). For example, for a residual coefficient where gr1_flag is 1, rem_abs_gt1_flag indicating whether the adjusted residual exceeds 1 can be encoded.
[0524] When the residual coefficient is 0 or 1, the value of rem_abs_gt1_flag can be set to 0. That is, when the residual coefficient is 2 or 3, the value of rem_abs_gt1_flag can be set to 0. In this case, when the adjusted residual coefficient is 0, par_level_flag can be set to 0, and when the residual coefficient is 1, par_level_flag can be set to 1.
[0525] When the adjusted residual coefficient is 2 or more (S4605), the value of rem_abs_gt1_flag can be set to 1, and information indicating whether the adjusted residual coefficient exceeds 2 can be encoded (S4606). For example, for a residual coefficient with rem_abs_gt1_flag being 1, rem_abs_gt2_flag indicating whether the adjusted residual coefficient exceeds 2 can be encoded.
[0526] When the residual coefficient is 2 or 3, the value of rem_abs_gt2_flag can be set to 1. That is, when the residual coefficient is 4 or 5, the value of rem_abs_gt2_flag can be set to 0. In this case, when the residual coefficient is 2, par_level_flag can be set to 0, and when the residual coefficient is 3, par_level_flag can be set to 1.
[0527] When the adjusted residual coefficient exceeds 2 (S4607), the residual value information obtained by subtracting 2 from the adjusted residual coefficient can be encoded (S4608). That is, after subtracting 6 from the absolute value of the residual coefficient, the result value divided by 2 can be encoded as the residual value information.
[0528] The residual coefficient can be further encoded by using a flag indicating whether the adjusted residual coefficient exceeds 3 (for example, rem_abs_gt3_flag) or a flag indicating whether the adjusted residual coefficient exceeds 4 (rem_abs_gt4_flag), etc. In this case, the value obtained by subtracting the maximum value from the adjusted residual coefficient can be set as the residual value. The maximum value indicates the maximum N values among rem_abs_gtN_flag.
[0529] Instead of a flag that compares the value of an adjustment residual coefficient with a specified value, a flag that compares the absolute value of an adjustment coefficient or a residual coefficient with the specified value can also be used. For example, instead of rem_abs_gt1_flag, a gr3_flag indicating whether the absolute value of the residual coefficient exceeds 3 can be used, and instead of rem_abs_gt2_flag, a gr5_flag indicating whether the absolute value of the residual coefficient exceeds 5 can be used.
[0530] Table 15 briefly shows the process of encoding residual coefficients using syntax elements.
Table 15
[0531] The decoder can also decode the residual coefficients according to the order shown in FIG. 46. Specifically, the decoder can determine the position of the last non-zero coefficient and decode the sig_coeff_flag for each residual coefficient whose scan order precedes that of the last non-zero coefficient.
[0532] When sig_coeff_flag is true, the gr1_flag of the residual coefficient can be decoded. When gr1_flag is 0, the absolute value of the residual coefficient is determined to be 1, and when gr1_flag is 1, the par_level_flag of the residual coefficient can be decoded. Then, the rem_abs_gt1_flag of the residual coefficient can be decoded. In this case, based on the value of rem_abs_gt(N - 1)_flag, rem_abs_gtN_flag can be further decoded. For example, when the value of rem_abs_gt(N - 1)_flag is 1, rem_abs_gtN_flag can be decoded. For example, when the value of rem_abs_gt1_flag of the residual coefficient is 1, the rem_abs_gt2_flag of the residual coefficient can be further analyzed. When the value of rem_abs_gt(MAX)_flag is 1, the residual value information can be decoded.
[0533] When the value of rem_abs_gtN_flag of the residual coefficient is 0, based on the value of par_level_flag, the value of the residual coefficient can be determined as 2N - 1 or 2N. Specifically, when par_level_flag is 0, the residual coefficient is set to 2N, and when par_level_flag is 1, the residual coefficient can be set to 2N + 1.
[0534] For example, when rem_abs_gt1_flag is 0, based on the par_level_flag value, the absolute value of the residual coefficient can be set to 2 or 3. Specifically, when the par_level_flag value is 0, the absolute value of the residual coefficient is 2, and when the par_level_flag value is 1, the absolute value of the residual coefficient is 3.
[0535] For example, when rem_abs_gt2_flag is 0, based on the par_level_flag value, the absolute value of the residual coefficient can be set to 4 or 5. Specifically, when the par_level_flag value is 0, the absolute value of the residual coefficient is 4, and when the par_level_flag value is 1, the absolute value of the residual coefficient is 5.
[0536] When decoding the residual value information, based on the value of par_level_flag, the residual coefficient can be set to 2(MAX + R) or 2(MAX + R) + 1. Here, R represents the value of the residual value information. For example, when par_level_flag is 0, the residual coefficient is set to 2(MAX + R), and when par_level_flag is 1, the residual coefficient can be set to 2(MAX + R) + 1.
[0537] As another example, the parity flag can be encoded only when the value of the residual coefficient exceeds 2. For example, after encoding the information indicating whether the value of the residual coefficient exceeds 1 and the information indicating whether the value of the residual coefficient exceeds 2, if it is determined that the value of the residual coefficient exceeds 2, the parity flag for the residual coefficient can be encoded.
[0538] FIG. 47 is a flowchart of a process for encoding the absolute value of a residual coefficient.
[0539] For non-zero residual coefficients, information gr1_flag indicating whether the absolute value of the residual coefficient exceeds 1 can be encoded (S4701). When the residual coefficient is 1, gr1_flag can be set to 0, and when the residual coefficient exceeds 1, gr1_flag can be set to 1.
[0540] For residual coefficients whose absolute value exceeds 1, information gr2_flag indicating whether the absolute value of the residual coefficient exceeds 2 can be encoded (S4702, S4703). When the residual coefficient is 2, gr2_flag can be set to 0, and when the residual coefficient exceeds 2, gr2_flag can be set to 1.
[0541] When the absolute value exceeds 2, a parity flag indicating whether the residual coefficient or the residual sum is even or odd can be encoded (S4704, S4705). Here, the residual coefficient can be set to the value obtained by subtracting 3 from the residual coefficient. For example, par_level_flag can be derived based on the following Equation 34.
Equation
[0542] It is possible to divide the residual coefficient or the residual sum by 2, or shift the residual coefficient or the residual sum 1 bit to the right to derive an adjusted residual sum, and encode information indicating whether the adjusted residual sum exceeds 1. For example, for a residual coefficient with gr1_flag being 1, rem_abs_gt1_flag indicating whether the adjusted residual sum exceeds 1 can be encoded (S4706).
[0543] When the residual coefficient is 0 or 1, the value of rem_abs_gt1_flag can be set to 0. That is, when the residual coefficient is 3 or 4, the value of rem_abs_gt1_flag can be set to 0. In this case, when the adjusted residual coefficient is 0, par_level_flag can be set to 0, and when the residual coefficient is 1, par_level_flag can be set to 1.
[0544] When the adjusted residual coefficient is 2 or more (S4707), the value of rem_abs_gt1_flag can be set to 1, and information indicating whether the adjusted residual coefficient exceeds 2 can be encoded (S4708). For example, for the residual coefficient where rem_abs_gt1_flag is 1, rem_abs_gt2_flag indicating whether the adjusted residual coefficient exceeds 2 can be encoded.
[0545] When the residual coefficient is 2 or 3, the value of rem_abs_gt2_flag can be set to 1. That is, when the residual coefficient is 5 or 6, the value of rem_abs_gt2_flag can be set to 0. In this case, when the residual coefficient is 2, par_level_flag can be set to 0, and when the residual coefficient is 3, par_level_flag can be set to 1.
[0546] When the adjusted residual coefficient exceeds 2, the residual value obtained by subtracting 2 from the adjusted residual coefficient can be encoded (S4709, S4710). That is, after subtracting 7 from the absolute value of the residual coefficient, the result value divided by 2 can be encoded as the residual value.
[0547] The residual coefficient can be further encoded using a flag indicating whether the adjusted residual coefficient exceeds 3 (for example, rem_abs_gt3_flag) or a flag indicating whether the adjusted residual coefficient exceeds 4 (rem_abs_gt4_flag), etc. In this case, the value obtained by subtracting the maximum value from the adjusted residual coefficient can be set as the residual value. The maximum value indicates the maximum N values among rem_abs_gtN_flag.
[0548] Instead of a flag that compares the value of an adjustment residual coefficient with a specified value, a flag that compares the absolute value of an adjustment coefficient or a residual coefficient with a specified value can also be used. For example, instead of rem_abs_gt1_flag, a gr4_flag indicating whether the absolute value of the residual coefficient exceeds 4 can be used, and instead of rem_abs_gt2_flag, a gr6_flag indicating whether the absolute value of the residual coefficient exceeds 6 can be used.
[0549] The decoder can also decode the residual coefficients in the same order as shown in FIG. 47. Specifically, the decoder can determine the position of the last non-zero coefficient and decode the sig_coeff_flag for each residual coefficient whose scanning order precedes that of the last non-zero coefficient.
[0550] When sig_coeff_flag is true, the gr1_flag of the residual coefficient can be decoded. When gr1_flag is 0, the absolute value of the residual coefficient is determined to be 1, and when gr1_flag is 1, gr2_flag can be decoded. When gr2_flag is 0, the absolute value of the residual coefficient is determined to be 2, and when gr2_flag is 1, the par_level_flag of the residual coefficient can be decoded. Thereafter, the rem_abs_gt1_flag of the residual coefficient can be decoded. In this case, based on the value of rem_abs_gt(N - 1)_flag, rem_abs_gtN_flag can be further decoded. For example, when the value of rem_abs_gt(N - 1)_flag is 1, rem_abs_gtN_flag can be decoded. For example, when the value of rem_abs_gt1_flag of the residual coefficient is 1, the rem_abs_gt2_flag of the residual coefficient can be further analyzed. When the value of rem_abs_gt(MAX)_flag is 1, the residual value information can be decoded.
[0551] When the value of rem_abs_gtN_flag of the residual coefficient is 0, based on the value of par_level_flag, the value of the residual coefficient can be determined to be 2N + 1 or 2(N + 1). Specifically, when par_level_flag is 0, the residual coefficient is set to 2N + 1, and when par_level_flag is 1, the residual coefficient can be set to 2(N + 1).
[0552] For example, when rem_abs_gt1_flag is 0, based on the par_level_flag value, the absolute value of the residual coefficient can be set to 3 or 4. Specifically, when the par_level_flag value is 0, the absolute value of the residual coefficient is 3, and when the par_level_flag value is 1, the absolute value of the residual coefficient is 4.
[0553] For example, when rem_abs_gt2_flag is 0, based on the par_level_flag value, the absolute value of the residual coefficient can be set to 5 or 6. Specifically, when the par_level_flag value is 0, the absolute value of the residual coefficient is 5, and when the par_level_flag value is 1, the absolute value of the residual coefficient is 6.
[0554] When decoding the residual value information, based on the value of par_level_flag, the residual coefficient can be set to 2(MAX + R) or 2(MAX + R) + 1. Here, R represents the value of the residual value information. For example, when par_level_flag is 0, the residual coefficient is set to 2(MAX + R), and when par_level_flag is 1, the residual coefficient can be set to 2(MAX + R) + 1.
[0555] Based on at least one of the current block size, shape, whether to skip transformation, transformation core, number of non-zero coefficients, or position of the last non-zero coefficient, at least one of the number or type of comparison flags for comparing the adjusted residual coefficients with a specified value can be determined. For example, when encoding transform coefficients, only rem_abs_gt1_flag can be used. On the other hand, when encoding transform skip coefficients, rem_abs_gt1_flag and rem_abs_gt2_flag can be used.
[0556] Alternatively, within a 4×4 size sub-transformation unit, the number of rem_abs_gt1_flag can be set to a maximum of 8, and the number of rem_abs_gt2_flag can be set to a maximum of 1. Alternatively, when the number of non-zero coefficient flags is (16 - N), the number of rem_abs_gt1_flag can be set to a maximum of 8+(N / 2), and the number of rem_abs_gt2_flag can be set to a maximum of 1+(N-(N / 2)).
[0557] When the restored block of the current block is obtained, the loss of information generated in the quantization and encoding process can be reduced through in-loop filtering. The in-loop filter may include at least one of a deblocking filter, a sample adaptive offset filter (SAO), or an adaptive loop filter (ALF). Hereinafter, the restored block before the in-loop filter is applied is called the first restored block, and the restored block after the in-loop filter is applied is called the second restored block.
[0558] At least one of the deblocking filter, SAO, or ALF can be applied to the first restored block to obtain the second restored block. In this case, SAO or ALF can be applied after the deblocking filter is applied.
[0559] The deblocking filter is used to reduce the degradation of image quality (blocking artifact) that occurs at the block boundary when quantization is performed in block units. In order to apply the deblocking filter, the blocking strength (BS) between the first restored block and the adjacent restored block can be determined.
[0560] Figure 48 is a flowchart of a process for determining the block strength.
[0561] In the example shown in Figure 48, P represents the first restored block and Q represents the adjacent restored block. Here, the adjacent restored block can be a block adjacent to the left or top of the current block.
[0562] In the example shown in Figure 48, it shows that the block strength is determined in consideration of the prediction coding mode of P and Q, whether non-zero transform coefficients are included, whether inter prediction is performed using the same reference image, or whether the difference value of the motion vector is greater than or equal to the threshold.
[0563] Based on the block strength, it is possible to determine whether to apply the deblocking filter. For example, when the block strength is 0, filtering may not be performed.
[0564] SAO is used to reduce the ringing artifact that occurs when quantization is performed in the frequency domain. SAO can be performed by adding or subtracting an offset determined in consideration of the pattern of the first restored image. The method of determining the offset includes an edge offset (EO) or a band offset (BO). EO indicates a method of determining the offset of the current sample based on the pattern of surrounding pixels. BO indicates a method of applying a common offset to a group of pixels having similar luminance values within a region. Specifically, the pixel luminance can be divided into 32 equal intervals, and pixels having similar luminance values can be set as one group. For example, among the 32 bands, four adjacent bands can be set as one group, and the same offset value can be applied to the samples belonging to the four bands.
[0565] ALF is a method of generating a second restored image by applying a filter of a predefined size / shape to the first restored image or the restored image to which a deblocking filter has been applied. The following formula 35 shows an application example of ALF.
Equation
[0566] Any of the predefined filter candidates can be selected in units of an image, a coding tree unit, a coding block, a prediction block, or a transform block. The size or shape of each filter candidate can be different.
[0567] Figure 49 is a diagram showing predefined filter candidates.
[0568] In the example shown in Figure 49, at least one of the rhombuses of 5×5, 7×7, and 9×9 sizes can be selected.
[0569] For the chroma component, only a 5×5 size rhombus can be used.
[0570] Applying the embodiments described with focus on the decoding process or the encoding process to the encoding process or the decoding process is within the scope of the present invention. Changing the embodiments described in a predetermined order to an order different from the described order is also within the scope of the present invention.
[0571] Although the above-described embodiments have been described based on a series of steps or flowcharts, this does not limit the chronological order of the present invention, and the steps can be executed simultaneously or in other orders as necessary. Also, in the above-described embodiments, each component (e.g., unit, module, etc.) constituting the block diagram can be implemented by a hardware device or software, and a plurality of components can be combined and implemented as a single hardware device or software. The above-described embodiments can be implemented in the form of program instructions executable by various computer components, and the program instructions can be stored in a computer-readable storage medium. The computer-readable storage medium can include program instructions, data files, data structures, etc. alone or in combination. Examples of computer-readable storage media include magnetic media such as hard disks, floppy disks, and magnetic tapes, optical storage media such as CD-ROMs, DVDs, magneto-optical media such as floptical disks, and hardware devices specially configured to store and execute program instructions such as ROM, RAM, and flash memory. The hardware device can be configured to operate as one or more software modules for executing the processing according to the present invention, and vice versa.
Industrial Applicability
[0572] The present invention can be applied to electronic devices that encode / decrypt video.
Claims
1. 1. A video decoding method comprising: parsing a non-zero flag from the bitstream indicating whether a residual coefficient is non-zero; if the non-zero flag indicates that the residual coefficient is non-zero, parsing magnitude information from the bitstream, the magnitude information being used to determine the magnitude of the residual coefficient; determining absolute values of the residual coefficients based on the absolute value information; the absolute value information includes a residual coefficient comparison flag indicating whether the residual coefficient exceeds a first value; further analyzing a parity flag from the bitstream only if the residual coefficient exceeds the first value, the parity flag indicating whether the value of the residual coefficient is even or odd; If the residual coefficient exceeds the first value, further analyze a first adjusted residual coefficient comparison flag, the first adjusted residual coefficient comparison flag indicating whether an adjusted residual coefficient derived by shifting the residual coefficient one bit right exceeds a second value; If the adjusted residual coefficient is less than or equal to a second value, determining that the residual coefficient is 2N or 2N+1 (N is the second value) according to a value of the parity flag.
2. If the adjusted residual coefficient exceeds the second value, further analyze a second adjusted residual coefficient comparison flag, wherein the second adjusted residual coefficient comparison flag indicates whether the adjusted residual coefficient exceeds a third value; 10. The video decoding method of claim 1.
3. If the adjusted residual coefficient exceeds the second value, further analyze the residual value information; the residual value information is a value obtained by subtracting the second value from the adjusted residual coefficient; 10. The video decoding method of claim 1.
4. 1. A video encoding method comprising: encoding a non-zero flag indicating whether the residual coefficient is non-zero; if the residual coefficient is non-zero, encoding absolute value information, the absolute value information being used to determine the absolute value of the residual coefficient; the absolute value information includes a residual coefficient comparison flag indicating whether the residual coefficient exceeds a first value; further encoding a parity flag of the residual coefficient only if the residual coefficient exceeds the first value, the parity flag indicating whether the value of the residual coefficient is even or odd; If the residual coefficient exceeds the first value, further encode a first adjusted residual coefficient comparison flag, the first adjusted residual coefficient comparison flag indicating whether an adjusted residual coefficient derived by shifting the residual coefficient one bit right exceeds a second value; If the adjusted residual coefficient is less than or equal to the second value, determining that the residual coefficient is 2N or 2N+1 according to a value of the parity flag.
5. If the adjusted residual coefficient exceeds the second value, further encode a second adjusted residual coefficient comparison flag, the second adjusted residual coefficient comparison flag indicating whether the adjusted residual coefficient exceeds a third value.
5. The video encoding method of claim 4.
6. If the adjusted residual coefficient exceeds the second value, further encoding residual value information; the residual value information is a value obtained by subtracting the second value from the adjusted residual coefficient; 5. The video encoding method of claim 4.
7. 1. A video decoding device, comprising: means for parsing a non-zero flag from the bitstream, which indicates whether a residual coefficient is non-zero; means for parsing absolute value information from the bitstream if the non-zero flag indicates that the residual coefficient is non-zero, the absolute value information being used to determine an absolute value of the residual coefficient; and means for determining absolute values of the residual coefficients based on the absolute value information; the absolute value information includes a residual coefficient comparison flag indicating whether the residual coefficient exceeds a first value; further analyzing a parity flag from the bitstream only if the residual coefficient exceeds the first value, the parity flag indicating whether the value of the residual coefficient is even or odd; If the residual coefficient exceeds the first value, further analyze a first adjusted residual coefficient comparison flag, the first adjusted residual coefficient comparison flag indicating whether an adjusted residual coefficient derived by shifting the residual coefficient one bit right exceeds a second value; If the adjusted residual coefficient is less than or equal to a second value, the video decoding device determines that the residual coefficient is 2N or 2N+1 (N is the second value) according to a value of the parity flag.
8. 1. A video encoding device, comprising: means for encoding a non-zero flag indicating whether the residual coefficient is non-zero; means for encoding absolute value information if the residual coefficient is non-zero, the absolute value information being used to determine the absolute value of the residual coefficient; the absolute value information includes a residual coefficient comparison flag indicating whether the residual coefficient exceeds a first value; further encoding a parity flag of the residual coefficient only if the residual coefficient exceeds the first value, the parity flag indicating whether the value of the residual coefficient is even or odd; If the residual coefficient exceeds the first value, further encode a first adjusted residual coefficient comparison flag, the first adjusted residual coefficient comparison flag indicating whether an adjusted residual coefficient derived by shifting the residual coefficient one bit right exceeds a second value; If the adjusted residual coefficient is less than or equal to the second value, the video encoding device determines that the residual coefficient is 2N or 2N+1 according to a value of the parity flag.
9. 1. A video decoding device, comprising: a memory storing instructions; and a processor, the processor executing the instructions to parsing a non-zero flag from the bitstream indicating whether a residual coefficient is non-zero; if the non-zero flag indicates that the residual coefficient is non-zero, parsing magnitude information from the bitstream, the magnitude information being used to determine the magnitude of the residual coefficient; determining the absolute values of the residual coefficients based on the absolute value information; the absolute value information includes a residual coefficient comparison flag indicating whether the residual coefficient exceeds a first value; further analyzing a parity flag from the bitstream only if the residual coefficient exceeds the first value, the parity flag indicating whether the value of the residual coefficient is even or odd; If the residual coefficient exceeds the first value, further analyze a first adjusted residual coefficient comparison flag, the first adjusted residual coefficient comparison flag indicating whether an adjusted residual coefficient derived by shifting the residual coefficient one bit right exceeds a second value; If the adjusted residual coefficient is less than or equal to a second value, the video decoding device determines that the residual coefficient is 2N or 2N+1 (N is the second value) according to a value of the parity flag.
10. 1. A video encoding device, comprising: a memory storing instructions; and a processor, the processor executing the instructions to encoding a non-zero flag indicating whether the residual coefficient is non-zero; if the residual coefficient is non-zero, encoding absolute value information, the absolute value information being used to determine the absolute value of the residual coefficient; the absolute value information includes a residual coefficient comparison flag indicating whether the residual coefficient exceeds a first value; further encoding a parity flag of the residual coefficient only if the residual coefficient exceeds the first value, the parity flag indicating whether the value of the residual coefficient is even or odd; If the residual coefficient exceeds the first value, further encode a first adjusted residual coefficient comparison flag, the first adjusted residual coefficient comparison flag indicating whether an adjusted residual coefficient derived by shifting the residual coefficient one bit right exceeds a second value; If the adjusted residual coefficient is less than or equal to the second value, the video encoding device determines that the residual coefficient is 2N or 2N+1 according to a value of the parity flag.
11. A computer-readable storage medium storing a computer program and a bitstream, comprising: The computer-readable storage medium, wherein the computer program causes a processor to perform the decoding method of any one of claims 1 to 3 in order to decode the bitstream to generate a video or image.
12. A computer-readable storage medium storing a computer program and a bitstream, comprising: The computer-readable storage medium, wherein the computer program causes a processor to perform the encoding method of any one of claims 4 to 6 to generate the bitstream.