Method for encoding / decoding a video signal and apparatus therefor

By using a motion information table to derive merging candidates, update block motion information, and correct motion vectors during video signal encoding/decoding, the problem of large data volume and low compression efficiency in high-definition video services is solved, achieving more efficient inter-frame prediction.

CN116366840BActive Publication Date: 2025-11-07APPLE INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310512325.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2019-02-26
Filing Date
2020-02-26
Publication Date
2025-11-07
Estimated Expiration
2040-02-26

AI Technical Summary

Technical Problem

Existing video coding technologies suffer from problems such as large data volume and low compression efficiency in high-definition video services, especially the HEVC standard, whose performance has gradually shown limitations.

Method used

By using a motion information table to derive merging candidates, updating the block motion information in the motion information table, correcting the motion vectors derived from the merging candidates, and effectively determining the inter-frame prediction method, the efficiency of inter-frame prediction is improved.

Benefits of technology

It improves the efficiency of inter-frame prediction during video signal encoding/decoding and enhances the compression performance of video signals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116366840B_ABST
    Figure CN116366840B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method for encoding / decoding a video signal and an apparatus thereof. The method for decoding a video according to the present invention can comprise the steps of parsing a first flag indicating whether a merge mode based inter prediction is applied to a current block, parsing a second flag indicating whether a regular merge mode or a merge offset coding mode is applied to the current block if the first flag is true, and parsing a third flag indicating whether the merge offset coding mode is applied to the current block if the second flag is true.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the PCT application which entered the Chinese national phase on February 26, 2020, with international application date of February 26, 2020, national application number of 202080004012.5, and invention title of "Method for encoding / decoding video signal and apparatus therefor". TECHNICAL FIELD

[0002] The disclosure relates to a video signal encoding / decoding method and apparatus thereof. BACKGROUND

[0003] As display panels become larger, higher quality video services are required. The biggest problem of high definition video services is that the amount of data is greatly increased. To solve the above problem, research into improving video compression rate is actively being conducted. As a representative example, the Joint Collaborative Team on Video Coding (JCT-VC) was formed in 2009 by the Moving Picture Experts Group (MPEG) and Video Coding Experts Group (VCEG) under the International Telecommunication Union-Telecommunication (ITU-T). The JCT-VC proposed High Efficiency Video Coding (HEVC), a video compression standard whose compression performance is about twice that of H.264 / AVC and was approved as a standard on January 25, 2013. However, as high definition video services rapidly develop, the performance of HEVC gradually shows its limitations. SUMMARY

[0004] TECHNICAL PROBLEM

[0005] The disclosure aims to provide a method of deriving merge candidates by using a motion information table when encoding / decoding a video signal and an apparatus for performing the same.

[0006] The disclosure aims to provide a method of updating motion information of a block included in a merge processing area in a motion information table when encoding / decoding a video signal and an apparatus for performing the same.

[0007] The disclosure aims to provide a method of correcting a motion vector derived based on a merge candidate when encoding / decoding a video signal and an apparatus for performing the same.

[0008] The disclosure aims to provide a method of efficiently determining an inter prediction method to be applied to a current block when encoding / decoding a video signal and an apparatus for performing the same.

[0009] The technical problems obtainable from the disclosure are not limited to the above-mentioned technical problems, and other technical problems not mentioned can be clearly understood by those skilled in the art to which the disclosure pertains from the following description.

[0010] TECHNICAL SOLUTION

[0011] A video signal decoding method according to the disclosure can include parsing a first flag indicating whether inter prediction based on a merge mode is applied to a current block, parsing a second flag indicating whether a regular merge mode or a merge offset coding mode is applied to the current block when the first flag is true, and parsing a third flag indicating whether the merge offset coding mode is applied to the current block when the second flag is true. In this case, when the third flag is true, the merge offset coding mode can be applied to the current block, and when the third flag is false, the regular merge mode can be applied to the current block.

[0012] A video signal encoding method according to the disclosure can include encoding a first flag indicating whether inter prediction based on a merge mode is applied to a current block, encoding a second flag indicating whether a regular merge mode or a merge offset coding mode is applied to the current block when the first flag is true, and encoding a third flag indicating whether the merge offset coding mode is applied to the current block when the second flag is true. In this case, when the merge offset coding mode is applied to the current block, the third flag can be set to true, and when the regular merge mode is applied to the current block, the third flag can be set to false.

[0013] The video signal decoding / encoding method according to the disclosure can further include parsing / encoding a fourth flag indicating whether a combined prediction mode is applied to the current block when the second flag is false.

[0014] In the video signal decoding / encoding method according to the disclosure, when the fourth flag is false, a coding method based on a prediction unit partition can be applied.

[0015] In the video signal decoding / encoding method according to the disclosure, motion information of the current block can be derived from a merge candidate list of the current block, and when a number of merge candidates derived from neighboring blocks of the current block is equal to or less than a threshold, a motion information candidate included in a motion information table can be added to the merge candidate list as a merge candidate.

[0016] In the video signal decoding / encoding method according to the disclosure, when the current block is included in a merge processing region, a motion information table can not be updated when blocks included in the merge processing region are decoded.

[0017] In the video signal decoding / encoding method according to the disclosure, when the current block is included in a merge processing region, whether to update motion information of the current block in a motion information table can be determined based on a position of the current block in the merge processing region.

[0018] In the video signal decoding / encoding method according to the disclosure, when the current block is in a right lower position in the merge processing region, it can be determined to update the motion information of the current block in the motion information table.

[0019] It is to be understood that the foregoing general description of features is exemplary of the aspects of the disclosure described in more detail below, and not limiting of the scope of the disclosure.

[0020] Technical Effects

[0021] According to the disclosure, inter prediction efficiency can be improved by deriving a merge candidate using a motion information table.

[0022] According to the disclosure, inter prediction efficiency can be improved by providing a method of updating motion information of a block included in a merge processing region in a motion information table.

[0023] According to the disclosure, inter prediction efficiency can be improved by correcting a motion vector derived based on a merge candidate.

[0024] According to the disclosure, an inter prediction method to be applied to a current block can be effectively determined.

[0025] Effects obtainable from the disclosure can not be limited by the above-mentioned effects, and other unmentioned effects can be clearly understood from the following description by those skilled in the art to which the disclosure pertains. BRIEF DESCRIPTION OF DRAWINGS

[0026] FIG. 1 is a diagram illustrating a block diagram of a video encoding apparatus (encoder) according to an embodiment of the disclosure.

[0027] FIG. 2 is a diagram illustrating a block diagram of a video decoding apparatus (decoder) according to an embodiment of the disclosure.

[0028] FIG. 3 is a diagram illustrating a basic coding tree unit according to an embodiment of the disclosure.

[0029] FIG. 4 is a diagram illustrating various partition types of a coding block.

[0030] FIG. 5 is a diagram illustrating an example of aspects of partitioning a CTU.

[0031] FIG. 6 is a flowchart of an inter prediction method according to an embodiment of the disclosure.

[0032] FIG. 7 is a flowchart of a process of deriving current block motion information in a merge mode.

[0033] FIG. 8is a diagram illustrating a candidate block used for deriving a merge candidate.

[0034] FIG. 9 is a diagram illustrating a position of a base sample.

[0035] FIG. 10 is a diagram illustrating a candidate block used for deriving a merge candidate.

[0036] FIG. 11 is a diagram illustrating an example in which a position of a base sample is changed.

[0037] FIG. 12 is a diagram illustrating an example in which a position of a base sample is changed.

[0038] FIG. 13 is a diagram for explaining an update aspect of a motion information table.

[0039] FIG. 14 is a diagram illustrating an update aspect of a motion information table.

[0040] FIG. 15 is a diagram illustrating an example in which an index of a pre-stored motion information candidate is updated.

[0041] FIG. 16 is a diagram illustrating a position of a representative sub-block.

[0042] FIG. 17 illustrates an example of generating a motion information table in an inter prediction mode.

[0043] FIG. 18 illustrates an example of generating a motion information table in a motion vector resolution.

[0044] FIG. 19 illustrates an example in which motion information of a block to which a merge offset coding method is applied is stored in a separate motion information table.

[0045] FIG. 20 is a diagram illustrating an example in which a motion information candidate included in a long-term motion information table is added to a merge candidate list.

[0046] FIG. 21 is a diagram illustrating an example in which a redundancy check is performed only for a part of merge candidates among merge candidates.

[0047] FIG. 22 is a diagram illustrating an example in which a redundancy check for a specific merge candidate is omitted.

[0048] FIG. 23 is a diagram illustrating an example in which a candidate block included in the same merge processing region as a current block is set to be unavailable as a merge candidate.

[0049] FIG. 24 is a diagram illustrating an example of deriving a merge candidate for a current block when the current block is included in a merge processing region.

[0050] FIG. 25 is a diagram illustrating a temporary motion information table.

[0051] FIG. 26 is a diagram illustrating an example of reconciling a motion information table and a temporary motion information table.

[0052] FIG. 27 is a diagram illustrating an example of partitioning a coding block into multiple prediction units by using a diagonal line.

[0053] FIG. 28 is a diagram illustrating an example of partitioning a coding block into two prediction units.

[0054] FIG. 29 illustrates an example of partitioning a coding block into multiple prediction blocks of different sizes.

[0055] FIG. 30 is a diagram illustrating a neighboring block used for deriving a partition mode merge candidate.

[0056] FIG. 31 is a diagram for explaining an example of determining availability of a neighboring block in units of prediction units.

[0057] FIG. 32 and FIG. 33 is a diagram illustrating an example of deriving a prediction sample based on a weighted sum operation of a first prediction sample and a second prediction sample.

[0058] FIG. 34 is a diagram illustrating an offset vector according to values of distance_idx indicating a size of the offset vector and direction_idx indicating a direction of the offset vector.

[0059] FIG. 35 is a diagram illustrating an offset vector according to values of distance_idx indicating a size of the offset vector and direction_idx indicating a direction of the offset vector. DETAILED DESCRIPTION

[0060] Hereinafter, embodiments of the disclosure will be described in detail with reference to the accompanying drawings.

[0061] Image encoding and decoding are performed on a block basis. In an example, for a coding block, a transform block, or a prediction block, encoding / decoding processes such as transform, quantization, prediction, in-loop filtering, reconstruction, etc. can be performed.

[0062] Hereinafter, a coding / decoding target block is referred to as a "current block". In an example, the current block can represent a coding block, a transform block, or a prediction block according to a current processing of coding / decoding.

[0063] Further, the term "unit" used in the present specification indicates a basic unit for performing a certain coding / decoding process, and a "block" can be understood to indicate an array of samples having a predetermined size. Unless otherwise specified, "block" and "unit" can be used interchangeably. In an example, in examples described later, a coding block and a coding unit can be understood to have the same meaning as each other.

[0064] FIG. 1 is a diagram showing a block diagram of an image encoding apparatus (encoder) according to an embodiment of the present disclosure.

[0065] Referring to FIG. 1 , the image encoding apparatus 100 can include a picture partitioning unit 110, prediction units 120 and 125, a transform unit 130, a quantization unit 135, a rearrangement unit 160, an entropy encoding unit 165, a dequantization unit 140, an inverse transform unit 145, a filter unit 150, and a memory 155.

[0066] FIG. 1 The components described in the above are independently shown in order to show different feature functions in the image encoding apparatus, and the drawing does not indicate that each component is constituted of a separate hardware or one software unit. That is, each component is merely listed for convenience of explanation, at least two of the components can constitute one component, or one component can be divided into a plurality of components which can perform its function. Embodiments in which each component is integrated and embodiments in which the components are divided are also included in the scope of the present disclosure, unless they depart from the spirit of the present disclosure.

[0067] Further, some components are not essential parts to perform the necessary functions of the present disclosure, but are optional components for performance improvement only. The present disclosure can be implemented with the necessary components for implementing the spirit of the present disclosure other than the components for performance improvement only, and a structure including only the necessary components other than the optional components for performance improvement only is also included in the scope of the present disclosure.

[0068] The picture partitioning unit 110 can partition an input picture into at least one processing unit. In this regard, the processing unit can be a prediction unit (PU), a transform unit (TU), or a coding unit (CU). In the picture partitioning unit 110, a single picture can be partitioned into a combination of a plurality of coding units, prediction units, and transform units, and the picture can be coded by selecting a combination of coding units, prediction units, and transform units according to a predetermined condition (e.g., a cost function).

[0069] For example, a single picture can be partitioned into a plurality of coding units. To partition a picture into coding units, a recursive tree structure such as a quad-tree structure can be used, and a coding unit originating from a root such as a single picture or a maximum coding unit can be partitioned into other coding units, and can have as many child nodes as the partitioned coding units. A coding unit that is no longer partitioned according to a certain limit becomes a leaf node. That is, when it is assumed that only square partitioning is available for a single coding unit, the single coding unit can be partitioned into a maximum of four other coding units.

[0070] Hereinafter, in embodiments of the disclosure, a coding unit can be used as a unit for encoding or can be used as a unit for decoding.

[0071] A prediction unit can be obtained by partitioning a single coding unit into at least one square or rectangle having the same size, or a single coding unit can be partitioned into prediction units in a manner that one prediction unit can be different in shape and / or size from another prediction unit.

[0072] When a prediction unit is generated based on an encoding block for which intra prediction is being performed, when the coding unit is not a minimum coding unit, intra prediction can be performed without performing partitioning into a plurality of NxN prediction units.

[0073] 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. It can be determined whether to perform inter prediction or intra prediction on a prediction unit, and it can be determined detailed information according to each prediction method (e.g., an intra prediction mode, a motion vector, a reference picture, etc.). In this regard, the processing unit on which prediction is performed can be different from the processing unit that determines the prediction method and its details. For example, the prediction method, prediction mode, etc. can be determined based on a prediction unit, and prediction can be performed based on a transform unit. Residual values (residual blocks) between the generated prediction block and the original block can be input to the transform unit 130. Furthermore, prediction mode information, motion vector information, etc. for prediction can be encoded by the entropy encoding unit 165 using the residual values, and can be transmitted to a decoder. When a certain encoding mode is used, the original block is encoded as is without generating a prediction block through the prediction units 120 or 125 and is transmitted to a decoding unit.

[0074] The inter prediction unit 120 can predict a prediction unit based on information about at least one of a previous picture and a subsequent picture of a current picture, or in some cases, can predict a prediction unit based on information about some encoding regions in the current picture. The inter prediction unit 120 can include a reference picture interpolation unit, a motion prediction unit, and a motion compensation unit.

[0075] The reference picture interpolation unit can receive the reference picture information from the memory 155 and generate pixel information of integer pixels or smaller pixels from the reference picture. In the case of the luminance pixels, an 8-tap DCT-based interpolation filter with different coefficients can be used in order to generate the pixel information about the integer pixels or smaller pixels for 1 / 4-pixel units. In the case of the chrominance signals, a 4-tap DCT-based interpolation filter with different filter coefficients can be used in order to generate the pixel information about the integer pixels or smaller pixels for 1 / 8-pixel units.

[0076] The motion prediction unit can perform motion prediction based on the reference picture interpolated by the reference picture interpolation unit. As a method for calculating a motion vector, various methods such as a full search-based block matching algorithm (FBMA), a three-step search (TSS) algorithm, a new three-step search (NTS) algorithm, etc. can be used. Based on the interpolated pixels, the motion vector can have a motion vector size in units of 1 / 2 pixel or 1 / 4 pixel. The motion prediction unit can predict the current prediction unit by changing the motion prediction method. As the motion prediction method, various methods such as a skip method, a merge method, an advanced motion vector prediction (AMVP) method, an intra block copy method, etc. can be used.

[0077] The intra prediction unit 125 can generate a prediction unit based on information about reference pixels around the current block, which is pixel information in the current picture. When a neighboring block of the current prediction unit is a block for which inter prediction is performed, and thus the reference pixels are pixels for which inter prediction is performed, the reference pixels included in the block for which inter prediction is performed can be replaced with information about the reference pixels of the neighboring block for which intra prediction is performed. In other words, when the reference pixels are not available, the unavailable reference pixel information can be replaced with at least one of the available reference pixels.

[0078] The prediction modes in the intra prediction can include a directional prediction mode using reference pixel information according to a prediction direction and a non-directional mode not using directional information when performing prediction. The modes for predicting the luminance information can be different from the modes for predicting the chrominance information. In order to predict the chrominance information, information about the intra prediction modes for predicting the luminance information or information about the predicted luminance signal can be used.

[0079] When the size of the prediction unit is the same as the transform unit when performing the intra prediction, the prediction unit can be performed based on the pixels located at the left, the upper left, and the upper of the prediction unit. However, when the size of the prediction unit is different from the transform unit when performing the intra prediction, the intra prediction can be performed by using the reference pixels based on the transform unit. In addition, the intra prediction using the NxN partition can be used only for the minimum coding unit.

[0080] In the intra prediction method, a prediction block can be generated after applying an adaptive intra smoothing (AIS) filter to reference pixels according to a prediction mode. The type of the AIS filter applied to the reference pixels can vary. To perform the intra prediction method, an intra prediction mode for a current prediction unit can be predicted from intra prediction modes of prediction units existing around the current prediction unit. When the prediction mode for the current prediction unit is predicted by using mode information predicted from neighboring prediction units, when the intra prediction mode for the current prediction unit is the same as the intra prediction mode of the neighboring prediction units, information indicating that the current prediction unit and the neighboring prediction units have the same prediction mode can be transmitted by using predetermined flag information. When the prediction mode for the current prediction unit is different from the prediction mode of the neighboring prediction units, entropy encoding can be performed to encode information about the prediction mode for the current block.

[0081] Further, a residual block including information about residual values, which are difference values between a prediction unit predicted by the prediction unit 120 or 125 and an original block of the prediction unit, can be generated. The generated residual block can be input to the transform unit 130.

[0082] The transform unit 130 can perform a transform on a residual block including information about residual values between an original block and a prediction unit generated by the prediction unit 120 or 125 by using a transform method such as a discrete cosine transform (DCT) or a discrete sine transform (DST). In this regard, a DCT transform kernel includes at least one of DCT2 or DCT8, and a DST transform kernel includes DST7. Whether to apply DCT or DST to perform a transform on the residual block can be determined based on information about an intra prediction mode of a prediction unit used to generate the residual block. A transform for the residual block can be skipped. A flag indicating whether to skip the transform for the residual block can be encoded. The transform skipping can be allowed for a residual block having a size less than or equal to a threshold, a residual block of a luma component, or a residual block of a chroma component in a 4:4:4 format.

[0083] The quantization unit 135 can perform quantization on values transformed to a frequency domain by the transform unit 130. Quantization coefficients can vary according to importance of a block or an image. Values calculated in the quantization unit 135 can be provided to the inverse quantization unit 140 and the rearrangement unit 160.

[0084] The rearrangement unit 160 can perform rearrangement on coefficient values for quantized residual values.

[0085] The rearrangement unit 160 can change the coefficients in the form of a two-dimensional block into the form of a one-dimensional vector by a coefficient scanning method. For example, the rearrangement unit 160 can change the coefficients into the form of a one-dimensional vector by scanning from a DC coefficient to a coefficient in a high frequency domain using a zigzag scanning method. Depending on the size of the transform unit and the intra prediction mode, a vertical direction scan in which the coefficients in the form of a two-dimensional block are scanned in a column direction or a horizontal direction scan in which the coefficients in the form of a two-dimensional block are scanned in a row direction can be used instead of the zigzag scan. In other words, which scanning method to use among the zigzag scan, the vertical direction scan, and the horizontal direction scan can be determined depending on the size of the transform unit and the intra prediction mode.

[0086] The entropy encoding unit 165 can perform entropy encoding based on the values calculated by the rearrangement unit 160. The entropy encoding can use various encoding methods, such as exponential Golomb encoding, context adaptive variable length coding (CAVLC), or context adaptive binary arithmetic coding (CABAC).

[0087] The entropy encoding unit 165 can encode various types of information obtained from the rearrangement unit 160 and the prediction units 120 and 125, such as information on residual value coefficients and information on block types of coding units, information on prediction modes, information on partition units, information on prediction units, information on partition units, information on prediction units, and information on transmission units, information on motion vectors, information on reference frames, information on block interpolation, filtering information, etc.

[0088] The entropy encoding unit 165 can entropy-encode the coefficients of the coding units input from the rearrangement unit 160.

[0089] The inverse quantization unit 140 can perform inverse quantization on the values quantized in the quantization unit 135, and the inverse transform unit 145 can perform inverse transform on the values transformed in the transform unit 130. The residual values generated by the inverse quantization unit 140 and the inverse transform unit 145 can be added to the prediction units predicted by the motion estimation unit, the motion compensation unit, or the intra prediction unit included in the prediction units 120 and 125, in order to generate a reconstructed block.

[0090] The filter unit 150 can include at least one of a deblocking filter, an offset correction unit, and an adaptive loop filter (ALF).

[0091] A deblocking filter can remove block distortion that occurs due to boundaries between blocks in a reconstructed picture. To determine whether to perform deblocking, whether to apply a deblocking filter to a current block can be determined based on pixels included in a number of rows and a number of columns included in the block. When the deblocking filter is applied to the block, a strong filter or a weak filter is applied according to a required deblocking filter strength. Also, when horizontal direction filtering and vertical direction filtering are performed in applying the deblocking filter, the horizontal direction filtering and the vertical direction filtering can be configured to be processed in parallel.

[0092] The offset correction unit can correct the original image by an offset in units of pixels with respect to the image on which deblocking is performed. To perform offset correction for a specific picture, a method of applying an offset to a region determined after partitioning pixels of the image into a predetermined number of regions or a method of applying an offset according to edge information of each pixel can be used.

[0093] Adaptive loop filtering (ALF) can be performed based on a value obtained by comparing a filtered reconstructed image with an original image. Pixels included in an image can be partitioned into a predetermined group, a filter to be applied to each of the groups can be determined, and filtering can be performed individually for each group. Information about whether to apply ALF can be transmitted for each coding unit (CU) of a luma signal, and a shape of an ALF filter to be applied and filter coefficients can vary based on each block. Alternatively, an ALF filter having the same shape (fixed shape) can be applied regardless of characteristics of a block to which the filter is to be applied.

[0094] In the memory 155, a reconstructed block or picture calculated by the filter unit 150 can be stored. When inter prediction is performed, the stored reconstructed block or picture can be provided to the prediction units 120 or 125.

[0095] FIG. 2 FIG. 1 is a diagram illustrating a block diagram of an image encoding apparatus (encoder) according to an embodiment of the disclosure.

[0096] Referring to FIG. 2 , the image decoding apparatus 200 can include an entropy decoding unit 210, a rearranging unit 215, an inverse quantization unit 220, an inverse transform unit 225, prediction units 230 and 235, a filter unit 240, and a memory 245.

[0097] When an image bitstream is input from an encoder, the input bitstream can be decoded according to inverse processing of the image encoding apparatus.

[0098] The entropy decoding unit 210 can perform entropy decoding according to inverse processing of entropy encoding by the entropy encoding unit of the image encoder. For example, in association with the method performed by the image encoder device, various methods such as exponential Golomb encoding, context adaptive variable length coding (CAVLC), or context adaptive binary arithmetic coding (CABAC) can be applied.

[0099] The entropy decoding unit 210 can decode information about intra prediction and inter prediction performed by the encoder.

[0100] The rearranging unit 215 can perform rearranging on the bitstream entropy decoded by the entropy decoding unit 210 based on a rearranging method used in the encoder. The coefficients represented in the form of a one-dimensional vector can be reconstructed and rearranged into coefficients in the form of a two-dimensional block. The rearranging unit 215 can perform rearranging by receiving information related to the coefficient scanning performed in the encoder and performing inverse scanning based on the scanning order performed in the encoder.

[0101] The inverse quantization unit 220 can perform inverse quantization based on the quantization parameter received from the encoder and the coefficient values of the rearranged block.

[0102] The inverse transform unit 225 can perform inverse transform (i.e., inverse DCT or inverse DST) opposite to the transform (i.e., DCT or DST) performed on the quantized result by the transform unit in the image encoder. In this regard, the DCT transform kernel can include at least one of DCT2 or DCT8, and the DST transform kernel can include DST7. Alternatively, when the transform is skipped in the image encoder, the inverse transform is also not performed in the inverse transform unit 225. The inverse transform can be performed based on the transmission unit determined by the image encoder. The inverse transform unit 225 of the image decoder can selectively perform a transform method (e.g., DCT or DST) according to multiple pieces of information such as a prediction method, a size of a current block, a prediction direction, etc.

[0103] The prediction unit 230 or 235 can generate a prediction block based on information related to the prediction block received from the entropy decoding unit 210 and information about a previously decoded block or picture received from the memory 245.

[0104] As described above, as the operation of the image encoder, when the size of the prediction unit is the same as the size of the transform unit, intra prediction can be performed on the prediction unit based on the pixels located at the left, top-left, and top of the prediction unit when intra prediction is performed. However, when the size of the prediction unit is different from the size of the transform unit, intra prediction can be performed by using reference pixels based on the transform unit. In addition, intra prediction using NxN partitioning can be used only for the minimum coding unit.

[0105] The prediction units 230 and 235 can include a PU determination module, an inter-prediction unit, and an intra-prediction unit. The PU determination unit can receive various types of information input from the entropy decoding unit 210 (such as information on a prediction unit, information on a prediction mode of an intra-prediction method, information on motion prediction of an inter-prediction method, etc.), divide a prediction unit in a current coding unit, and determine whether to perform inter-prediction or intra-prediction on the prediction unit. The inter-prediction unit 230 can perform inter-prediction on a current prediction unit based on information on at least one of a previous picture and a subsequent picture including a current picture of the current prediction unit by using information required for inter-prediction of the current prediction unit received from the image encoder. Alternatively, inter-prediction can be performed based on information on some pre-reconstructed areas in the current picture including the current prediction unit.

[0106] To perform inter-prediction, which method of a skip mode, a merge mode, an AMVP mode, or an intra block copy mode is to be used as a motion prediction method for a prediction unit included in a coding unit can be determined based on the coding unit.

[0107] The intra-prediction unit 235 can generate a prediction block based on information on pixels within a current picture. When the prediction unit is a prediction unit on which intra-prediction has been performed, the intra-prediction can be performed based on information on an intra-prediction mode of the prediction unit received from the image encoder. The intra-prediction unit 235 can include an adaptive intra-smoothing (AIS) filter, a reference pixel interpolation module, or a DC filter. The AIS filter can perform filtering on reference pixels of a current block, and whether to apply the filter can be determined according to a prediction mode for the current prediction unit. When the AIS filtering is performed on the reference pixels of the current block, information on the AIS filter and the prediction mode of the prediction unit received from the image encoder can be used. When the prediction mode for the current block is a mode in which the AIS filtering is not applied, the AIS filter can not be applied.

[0108] When the prediction mode of the prediction unit is a prediction mode in which intra-prediction is performed based on pixel values obtained by interpolating reference pixels, the reference pixel interpolation unit can interpolate the reference pixels so as to generate the reference pixels having a unit of an integer or less. When the prediction mode for the current prediction unit is a prediction mode in which a prediction block is generated without interpolating the reference pixels, the reference pixels can not be interpolated. When the prediction mode for the current block is a DC mode, the DC filter can generate the prediction block by filtering.

[0109] The reconstructed block or the reconstructed picture can be provided to the filter unit 240. The filter unit 240 can include a deblocking filter, an offset correction module, and an ALF.

[0110] The image decoder can receive information about whether a deblocking filter has been applied to a corresponding block or a corresponding picture from the image encoder, and information about whether a strong filter or a weak filter is applied when the deblocking filter is applied. The deblocking filter of the image decoder can receive the information about the deblocking filter from the image encoder, and the image decoder can perform deblocking filtering on the corresponding block.

[0111] The offset correction unit can perform offset correction on the reconstructed picture based on a type of offset correction applied to the picture when encoding is performed, information about an offset value, and the like.

[0112] The ALF can be applied to the coding unit based on information about whether the ALF is applied received from the encoder, information about ALF coefficients, and the like. The above ALF information can be provided by being included in a specific parameter set.

[0113] In the memory 245, the reconstructed picture or the reconstructed block can be stored so as to be used as a reference picture or a reference block, and the reconstructed picture can be provided to the output unit.

[0114] FIG. 3 is a diagram illustrating a basic coding tree unit according to an embodiment of the disclosure.

[0115] The maximum coding block can be defined as a coding tree block. A single picture can be partitioned into a plurality of coding tree units (CTUs). The CTU can be a maximum size coding unit, and can be referred to as a largest coding unit (LCU). FIG. 3 is a diagram illustrating an example of partitioning a single picture into a plurality of CTUs.

[0116] The size of the CTU can be defined at a picture level or a sequence level. Also, information indicating the size of the CTU can be signaled through a picture parameter set or a sequence parameter set.

[0117] In an example, the size of the CTU for the entire picture within a sequence can be set to 128x128. Alternatively, any one of 128x128 or 256x256 can be determined as the size of the CTU at a picture level. In an example, the CTU can be set to have a size of 128x128 at a first picture, and to have a size of 256x256 at a second picture.

[0118] An encoding block can be generated by partitioning a CTU. The encoding block represents a basic unit for performing encoding / decoding. In an example, a prediction or a transform can be performed for each encoding block, or a prediction encoding mode can be determined for each encoding block. In this regard, the prediction encoding mode represents a method of generating a predicted picture. In an example, the prediction encoding mode can include intra prediction, inter prediction, current picture reference (CPR), intra block copy (IBC), or combined prediction. For an encoding block, a prediction block of the encoding block can be generated by using a prediction encoding mode of at least one of intra prediction, inter prediction, current picture reference, or combined prediction.

[0119] Information representing a prediction encoding mode for a current block can be signaled in a bitstream. In an example, the information can be a 1-bit flag representing whether the prediction encoding mode is an intra mode or an inter mode. When the prediction encoding mode for the current block is determined to be the inter mode, the current picture reference or the combined prediction can be available.

[0120] The current picture reference sets a current picture as a reference picture, and obtains a prediction block of a current block from an area within the current picture that has been encoded / decoded. In this regard, the current picture represents a picture including the current block. Information representing whether the current picture reference is applied to the current block can be signaled in a bitstream. In an example, the information can be a 1-bit flag. When the flag is true, the prediction encoding mode for the current block can be determined to be the current picture reference, and when the flag is false, the prediction encoding mode for the current block can be determined to be the inter prediction.

[0121] Optionally, the prediction encoding mode for a current block can be determined based on a reference picture index. In an example, when the reference picture index indicates a current picture, the prediction encoding mode for the current block can be determined to be the current picture reference. When the reference picture index indicates a picture other than the current picture, the prediction encoding mode for the current block can be determined to be the inter prediction. In other words, the current picture reference is a prediction method using information about an area within the current picture that has been encoded / decoded, and the inter prediction is a prediction method using information about another picture that has been encoded / decoded.

[0122] A combined prediction mode combines at least two of intra prediction, inter prediction, and current picture reference to form a combined prediction for a current block. In an example, when combined prediction is applied, a first prediction block can be generated based on any one of the intra prediction, the inter prediction, or the current picture reference, and a second prediction block can be generated based on another one of the intra prediction, the inter prediction, or the current picture reference. When the first prediction block and the second prediction block are generated, a final prediction block can be generated by calculating an average or a weighted sum of the first prediction block and the second prediction block. Information indicating whether the combined prediction is applied to the current block can be signaled in a bitstream. The information can be a 1-bit flag.

[0123] FIG. 4 FIGS. 1 to 3 are diagrams illustrating various partition types of a coding block.

[0124] A coding block can be partitioned into multiple coding blocks based on a quad tree partition, a binary tree partition, or a ternary tree partition. The partitioned coding block can be further partitioned into multiple coding blocks based on the quad tree partition, the binary tree partition, or the ternary tree partition.

[0125] A quad tree partition refers to a method of partitioning a current block into four blocks. As a result of the quad tree partition, the current block can be partitioned into four square partitions (see FIG. 4 (a) "SPLIT_QT").

[0126] A binary tree partition refers to a method of partitioning a current block into two blocks. An operation of partitioning the current block into two blocks along a vertical direction (i.e., using a vertical line passing through the current block) can be referred to as a vertical direction binary tree partition, and an operation of partitioning the current block into two blocks along a horizontal direction (i.e., using a horizontal line passing through the current block) can be referred to as a horizontal direction binary tree partition. As a result of the binary tree partition, the current block can be partitioned into two non-square partitions. FIG. 4 (b) "SPLIT_BT_VER" is a diagram illustrating a result of the vertical direction binary tree partition, and FIG. 4 (c) "SPLIT_BT_HOR" is a diagram illustrating a result of the horizontal direction binary tree partition.

[0127] A ternary tree partition refers to a method of partitioning a current block into three blocks. An operation of partitioning the current block into three blocks along a vertical direction (i.e., using two vertical lines passing through the current block) can be referred to as a vertical direction ternary tree partition, and an operation of partitioning the current block into three blocks along a horizontal direction (i.e., using two horizontal lines passing through the current block) can be referred to as a horizontal direction ternary tree partition. As a result of the ternary tree partition, the current block can be partitioned into three non-square partitions. In this regard, a width / height of a partition located at the center of the current block can be twice a width / height of the other partitions. FIG. 4“SPLIT_TT_HOR” of (e) is a diagram showing a result of the horizontal direction triple tree splitting. FIG. 4 “SPLIT_TT_HOR” of (e) is a diagram showing a result of the horizontal direction triple tree splitting.

[0128] The number of partitions of a CTU can be defined as a partition depth. The maximum partition depth of a CTU can be determined at a sequence level or a picture level. Thus, the maximum partition depth of a CTU can vary based on a sequence or a picture.

[0129] Optionally, the maximum partition depth can be determined independently for each partition method. In an example, the maximum partition depth allowed for quad tree partitioning can be different from the maximum partition depth allowed for binary tree partitioning and / or triple tree partitioning.

[0130] An encoder can signal information representing at least one of a partition type and a partition depth of a current block in a bitstream. A decoder can determine the partition type and the partition depth of a CTU based on the information obtained by parsing the bitstream.

[0131] FIG. 5 is a diagram showing an example of aspects of partitioning a CTU.

[0132] The operation of partitioning a coding block by using quad tree partitioning, binary tree partitioning, and / or triple tree partitioning can be referred to as multi-tree partitioning.

[0133] A coding block generated by partitioning a coding block by applying multi-tree partitioning can be referred to as a sub-coding block. When a partition depth of a coding block is k, a partition depth of a sub-coding block is set to k+1.

[0134] On the contrary, for a coding block having a partition depth of k+1, a coding block having a partition depth of k can be referred to as a parent coding block.

[0135] A partition type of a current coding block can be determined based on at least one of a partition type of a parent coding block and a partition type of a neighboring coding block. In this regard, the neighboring coding block can be a block adjacent to the current coding block, and include at least one of an above neighboring block, a left neighboring block, or a neighboring block adjacent to a top-left corner of the current coding block. In this regard, the partition type can include whether to apply quad tree partitioning, whether to apply binary tree partitioning, a direction of binary tree partitioning, whether to apply triple tree partitioning, or a direction of triple tree partitioning.

[0136] In order to determine a partition type of a coding block, information representing whether the coding block is partitioned or not can be signaled in a bitstream. The information is a 1-bit flag “split_cu_flag”, and when the flag is true, it can represent that the coding block is partitioned by a multi-tree partitioning method.

[0137] When the split_cu_flag is true, information indicating whether the coding block is partitioned by the quad-tree partitioning can be signaled in a bitstream. The information is a 1-bit flag split_qt_flag, and when the flag is true, the coding block can be partitioned into four blocks.

[0138] In an example, in the example shown in FIG. 5 In the example shown in

[0139] In addition, by applying the quad-tree partitioning again to the coding blocks of the partition depth of 2, coding blocks of a partition depth of 3 can be generated.

[0140] When the quad-tree partitioning is not applied to the coding block, whether to perform the binary-tree partitioning or the ternary-tree partitioning for the coding block can be determined according to at least one of a size of the coding block, whether the coding block is located at a picture boundary, a maximum partition depth, or a partition type of a neighboring block. When it is determined to perform the binary-tree partitioning or the ternary-tree partitioning for the coding block, information indicating a partition direction can be signaled in a bitstream. The information can be a 1-bit flag mtt_split_cu_vertical_flag. Whether the partition direction is a vertical direction or a horizontal direction can be determined based on the flag. In addition, information indicating which one of the binary-tree partitioning or the ternary-tree partitioning is applied to the coding block can be signaled in a bitstream. The information can be a 1-bit flag mtt_split_cu_binary_flag. Whether the binary-tree partitioning is applied to the coding block or the ternary-tree partitioning is applied to the coding block can be determined based on the flag.

[0141] In an example, in the example shown in FIG. 5 In the example shown in

[0142] Inter prediction is a kind of prediction encoding mode in which a current block is predicted by using information about a previous picture. In an example, a block at the same position as the current block within the previous picture (hereinafter, a co-located block) can be set as a prediction block of the current block. Hereinafter, a prediction block generated based on a co-located block of a current block can be referred to as a co-located prediction block.

[0143] On the contrary, when an object present in a previous picture has moved to another position in a current picture, the current block can be effectively predicted by using the motion of the object. For example, when a motion direction and a size of the object are determined by comparing the previous picture with the current picture, a prediction block (or a predicted picture) of the current block can be generated according to the motion information of the object. Hereinafter, the prediction block generated by using the motion information can be referred to as a motion prediction block.

[0144] A residual block can be generated by subtracting the prediction block from the current block. In this regard, in the case of object movement, the energy of the residual block can be reduced by using the motion prediction block without using the collocated prediction block, and thus the compression performance of the residual block can be improved.

[0145] As described above, the operation of generating the prediction block by using the motion information can be referred to as motion estimation prediction. In most inter prediction, the prediction block can be generated based on motion-compensated prediction.

[0146] The motion information can include at least one of a motion vector, a reference picture index, a prediction direction, and a bi-directional weighting factor index. The motion vector indicates a motion direction and a size of the object. The reference picture index specifies a reference picture of the current block among reference pictures included in a reference picture list. The prediction direction indicates any one of a uni-prediction L0 prediction, a uni-prediction L1 prediction, or a bi-prediction (L0 prediction and L1 prediction). At least one of L0 direction motion information and L1 direction motion information can be used according to the prediction direction of the current block. The bi-directional weighting factor index specifies a weighting factor applied to an L0 prediction block and a weighting factor applied to an L1 prediction block.

[0147] FIG. 6 is a flowchart of an inter prediction method according to an embodiment of the disclosure.

[0148] Referring to FIG. 6 , the inter prediction method includes determining an inter prediction mode for a current block S601, obtaining motion information of the current block according to the determined inter prediction mode S602, and performing motion-compensated prediction for the current block based on the obtained motion information S603.

[0149] In this regard, the inter prediction mode can indicate various methods for determining the motion information of the current block, and include an inter prediction mode using translational motion information, an inter prediction mode using affine motion information. In an example, the inter prediction mode using translational motion information can include a merge mode and a motion vector prediction mode, and the inter prediction mode using affine motion information can include an affine merge mode and an affine motion vector prediction mode. The motion information about the current block can be determined based on a neighboring block adjacent to the current block or information obtained by parsing a bitstream.

[0150] Motion information of the current block can be derived from motion information of another block. In this regard, the another block can be a block that is coded / decoded before the current block through inter prediction. An operation of setting the motion information of the current block to be the same as the motion information of the another block can be defined as a merge mode. Further, an operation of setting a motion vector of the another block to be a predicted value of a motion vector of the current block can be defined as a motion vector prediction mode.

[0151] FIG. 7 is a flowchart of a process of deriving motion information of a current block in a merge mode.

[0152] A merge candidate S701 of the current block can be derived. The merge candidate of the current block can be derived from a block that is coded / decoded before the current block through inter prediction.

[0153] FIG. 8 is an illustration showing a candidate block used to derive a merge candidate.

[0154] The candidate block can include at least one of a neighboring block including a sample adjacent to the current block or a non-neighboring block including a sample non-adjacent to the current block. Hereinafter, determining a sample of the candidate block is defined as a base sample. Further, a base sample adjacent to the current block is referred to as a neighboring base sample, and a base sample non-adjacent to the current block is referred to as a non-neighboring base sample.

[0155] The neighboring base sample can be included in a neighboring column of a leftmost column of the current block or a neighboring row of a topmost row of the current block. In an example, when a coordinate of a top-left sample of the current block is (0, 0), at least one of blocks including a base sample at a position of (-1, H-1), (W-1, -1), (W, -1), (-1, H), or (-1, -1) can be used as the candidate block. Referring to the illustration, the neighboring blocks of indices 0 to 4 can be used as the candidate block.

[0156] The non-neighboring base sample indicates a sample having at least one of an x-axis distance or a y-axis distance from a base sample adjacent to the current block of a predefined value. In an example, at least one of a block including a base sample having an x-axis distance of a predefined value from a left base sample, a block including a non-neighboring sample having a y-axis distance of a predefined value from an upper base sample, or a block including non-neighboring samples having x-axis and y-axis distances of predefined values from a top-left base sample can be used as the candidate block. The predefined value can be a natural number such as 4, 8, 12, 16, etc. Referring to the drawing, at least one of the blocks of indices 5 to 26 can be used as the candidate block.

[0157] A sample not located on the same vertical line, horizontal line, or diagonal line as the neighboring base sample can be set as the non-neighboring base sample.

[0158] FIG. 9is a diagram showing the positions of the basic samples.

[0159] As in the example shown in FIG. 9 In an example, when the position of the upper neighboring basic sample is (W-1, -1), the position of the upper non-neighboring basic sample spaced by N on the y-axis from the upper neighboring basic sample can be set to ((W / 2)-1, -1-N), and the position of the upper non-neighboring basic sample spaced by 2N on the y-axis from the upper neighboring basic sample can be set to (0, -1-2N). In other words, the position of a non-neighboring basic sample can be determined based on the positions of neighboring basic samples and the distance from the neighboring basic samples.

[0160] Hereinafter, a candidate block including neighboring basic samples among the candidate blocks is referred to as a neighboring block, and a candidate block including non-neighboring basic samples is referred to as a non-neighboring block.

[0161] When the distance between the current block and the candidate block is equal to or greater than a threshold value, the candidate block can be set to be unusable as a merge candidate. The threshold value can be determined based on the size of the coding tree unit. In an example, the threshold value can be set to the height of the coding tree unit (ctu_height) or a value obtained by adding or subtracting an offset to or from the height of the coding tree unit (ctu_height±N). When the offset N is a predefined value in the encoding apparatus and the decoding apparatus, it can be set to 4, 8, 16, 32, or ctu_height.

[0162] 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 is greater than a threshold value, it can be determined that the candidate block is unusable as a merge candidate.

[0163] Alternatively, the candidate block not belonging to the same coding tree unit as the current block can be set to be unusable as a merge candidate. In an example, when a basic sample is outside the upper boundary of the coding tree unit to which the current block belongs, the candidate block including the basic sample can be set to be unusable as a merge candidate.

[0164] When the upper boundary of the current block adjoins the upper boundary of the coding tree unit, it can be determined that a plurality of candidate blocks are unusable as merge candidates, and thus the encoding / decoding efficiency of the current block can be reduced. To solve such a problem, the number of candidate blocks located on the left side of the current block can be set to be greater than the number of candidate blocks located above the current block.

[0165] FIG. 10 is a diagram showing the candidate blocks used to derive the merge candidate.

[0166] As in the example shown in FIG. 10In the example shown in (a), the upper block belonging to the upper two block rows at the upper side of the current block and the left block belonging to the left five block columns at the left side of the current block are set as the candidate blocks. In the example shown in (b), the upper block belonging to the upper two block rows at the upper side of the current block and the left block belonging to the left five block columns at the left side of the current block are set as the candidate blocks.

[0167] In an example, a difference between a y-axis coordinate of a significant sample in the current block and a y-axis coordinate of an upper block that can be used as a candidate block can be set to be not more than N times a height of the current block. Further, a difference between an x-axis coordinate of the significant sample in the current block and an x-axis coordinate of a left block that can be used as a candidate block can be set to be not more than M times a width of the current block.

[0168] In an example, FIG. 10 The example shown in (a) shows blocks belonging to two block rows at the upper side of the current block and blocks belonging to five left block columns at the left side of the current block are set as the candidate blocks.

[0169] In another example, when a candidate block does not belong to the same coding tree unit as the current block, a merge candidate can be derived by using a block belonging to the same coding tree unit as the current block or a block including a significant sample adjacent to a boundary of the coding tree unit instead of the candidate block.

[0170] FIG. 11 is a diagram showing an example of changing a position of a significant sample.

[0171] When a significant sample is included in a coding tree unit different from the current block and the significant sample is not adjacent to a boundary of the coding tree unit, a candidate block can be determined by using a significant sample adjacent to the boundary of the coding tree unit instead of the significant sample.

[0172] In an example, in FIG. 11 In the example shown in (a) and (b), when an upper boundary of the current block adjoins an upper boundary of the coding tree unit, a significant sample at the upper side of the current block belongs to a coding tree unit different from the current block. A significant sample that is not adjacent to the upper boundary of the coding tree unit among the significant samples belonging to the coding tree unit different from the current block can be replaced with a sample adjacent to the upper boundary of the coding tree unit.

[0173] In an example, as FIG. 11 In the example shown in (a), the significant sample at position 6 can be replaced with a sample at position 6' on the upper boundary of the coding tree unit, and as FIG. 11In the example shown in (b), the sample at position 15' on the upper boundary of the coding tree unit can be used to replace the base sample at position 15. In this case, the y-coordinate of the replaced sample is derived to change to the neighboring position of the coding tree unit, and the x-coordinate of the replaced sample can be set to be the same as the base sample. In an example, the sample at position 6' can have the same x-coordinate as the sample at position 6, and the sample at position 15' can have the same x-coordinate as the sample at position 15.

[0174] Alternatively, the x-coordinate of the replaced sample can be set by adding or subtracting the offset from the x-coordinate of the base sample. In an example, when the x-coordinates of the neighboring base sample and the non-neighboring block located above the current block are the same, the x-coordinate of the replaced sample can be set by adding or subtracting the offset from the x-coordinate of the base sample. This is to prevent the replaced sample of a non-neighboring base sample from being at the same position as another non-neighboring base sample or a neighboring base sample.

[0175] FIG. 12 is a diagram showing an example of changing the position of a base sample.

[0176] When a base sample included in a coding tree unit different from the current block and not adjacent to the boundary of the coding tree unit is replaced with a sample located on the boundary of the coding tree unit, the value of adding or subtracting the offset from the x-coordinate of the base sample can be set as the x-coordinate of the replaced sample.

[0177] In an example, in the example shown in FIG. 12 In the example shown in (b), the sample at position 15' on the upper boundary of the coding tree unit can be used to replace the base sample at position 15. In this case, the y-coordinate of the replaced sample is derived to change to the neighboring position of the coding tree unit, and the x-coordinate of the replaced sample can be set to be the same as the base sample. In an example, the sample at position 6' can have the same x-coordinate as the sample at position 6, and the sample at position 15' can have the same x-coordinate as the sample at position 15.

[0178] Unlike the example shown in FIG. 11 and FIG. 12 The y-coordinate of the row located above the topmost row of the current block or the y-coordinate on the upper boundary of the coding tree unit can be set as the y-coordinate of the replaced sample.

[0179] The sample that replaces the base sample is not shown but can be determined based on a left boundary of the coding tree unit. In an example, when the base 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 base sample can be replaced with a sample that is adjacent to the left boundary of the coding tree unit. In this case, the replaced sample can have the same y-coordinate as the base sample or can have a y-coordinate obtained by adding or subtracting an offset to or from the y-coordinate of the base sample.

[0180] Thereafter, the block including the replaced sample can be set as a candidate block, and a merge candidate of the current block can be derived based on the candidate block.

[0181] The merge candidate can be derived from a temporal neighboring block included in a picture different from the current block. In an example, the merge candidate can be derived from a collocated block included in a collocated picture. Any one of the reference pictures included in the reference picture list can be set as the collocated picture. Index information that identifies the collocated picture among the reference pictures can be signaled in the bitstream. Alternatively, a reference picture having a predefined index among the reference pictures can be determined as the collocated picture.

[0182] The motion information of the merge candidate can be set as the same as the motion information of the candidate block. In an example, at least one of a motion vector, a reference picture index, a prediction direction, or a bi-directional weight index of the candidate block can be set as the motion information of the merge candidate.

[0183] A merge candidate list including the merge candidate can be generated S702.

[0184] The index of the merge candidate in the merge candidate list can be assigned according to a predetermined order. In an example, the index can be assigned in an order of a merge candidate derived from a left neighboring block, a merge candidate derived from an above neighboring block, a merge candidate derived from a top-right neighboring block, a merge candidate derived from a bottom-left neighboring block, a merge candidate derived from a top-left neighboring block, and a merge candidate derived from a temporal neighboring block.

[0185] When a plurality of merge candidates are included in the merge candidate, at least one of the plurality of merge candidates can be selected S703. Specifically, information for specifying any one of the plurality of merge candidates can be signaled in the bitstream. In an example, information indicating an index of any one of the merge candidates included in the merge candidate list, merge_idx, can be signaled in the bitstream.

[0186] When the number of merge candidates included in the merge candidate list is less than a threshold, the motion information candidate included in the motion information table can be added to the merge candidate list as a merge candidate. In this regard, the threshold can be the maximum number of merge candidates that can be included in the merge candidate list or a value that is the maximum number of merge candidates minus an offset. The offset can be a natural number such as 1 or 2.

[0187] The motion information table includes motion information candidates derived from blocks in the current picture that are coded / decoded based on inter prediction. In an example, the motion information of the motion information candidate included in the motion information table can be set to be the same as the motion information of the block that is coded / decoded based on inter prediction. In this regard, the motion information can include at least one of a motion vector, a reference picture index, a prediction direction, or a bi-directional weight index.

[0188] The motion information candidate included in the motion information table can also be referred to as an inter-region merge candidate or a prediction-region merge candidate.

[0189] The maximum number of motion information candidates that can be included in the motion information table can be predefined in the encoder and the decoder. In an example, the maximum number of motion information candidates that can be included in the motion information table can be 1, 2, 3, 4, 5, 6, 7, 8, or larger (e.g., 16).

[0190] Optionally, information representing the maximum number of motion information candidates that can be included in the motion information table can be signaled in the bitstream. The information can be signaled at a sequence level, a picture level, or a slice level. The information can represent the maximum number of motion information candidates that can be included in the motion information table. Optionally, the information can represent a difference between the maximum number of motion information candidates that can be included in the motion information table and the maximum number of merge candidates that can be included in the merge candidate list.

[0191] Optionally, the maximum number of motion information candidates that can be included in the motion information table can be determined according to a picture size, a slice size, or a coding tree unit size.

[0192] The motion information table can be initialized in units of a picture, a slice, a tile, a brick, a coding tree unit, or a coding tree unit line (row or column). In an example, when a slice is initialized, the motion information table is also initialized, and thus the motion information table can not include any motion information candidate.

[0193] Optionally, information representing whether the motion information table is to be initialized can be signaled in the bitstream. The information can be signaled at a slice level, a tile level, a brick level, or a block level. A preconfigured motion information table can be used until the information indicates initialization of the motion information table.

[0194] Optionally, the information about the initial motion information candidate can be signaled in a picture parameter set or a slice header. Although the slice is initialized, the motion information table can include the initial motion information candidate. Thus, the initial motion information candidate can be used for a block that is the first encoding / decoding target in the slice.

[0195] Optionally, a motion information candidate included in a motion information table of a previous coding tree unit can be set as the initial motion information candidate. In an example, a motion information candidate with a smallest index or a motion information candidate with a largest index among the motion information candidates included in the motion information table of the previous coding tree unit can be set as the initial motion information candidate.

[0196] The blocks are encoded / decoded in an encoding / decoding order, and the blocks that are encoded / decoded based on inter prediction can be sequentially set as the motion information candidates in the encoding / decoding order.

[0197] FIG. 13 is a diagram for explaining an updating aspect of the motion information table.

[0198] When inter prediction is performed S1301 for the current block, a motion information candidate can be derived based on the current block S1302. The motion information of the motion information candidate can be set as the same as the motion information of the current block.

[0199] When the motion information table is empty S1303, the motion information candidate derived based on the current block can be added to the motion information table S1304.

[0200] When the motion information table already includes a motion information candidate S1303, a redundancy check for the motion information (or the motion information candidate derived based on the current block) of the current block can be performed S1305. The redundancy check is to determine whether the motion information of the pre-stored motion information candidate in the motion information table is the same as the motion information of the current block. The redundancy check can be performed for all the pre-stored motion information candidates in the motion information table. Optionally, the redundancy check can be performed for the motion information candidates whose indices exceed or are lower than a threshold among the pre-stored motion information candidates in the motion information table. Optionally, the redundancy check can be performed for a pre-defined number of motion information candidates. In an example, 2 motion information candidates with the smallest indices or with the largest indices can be determined as the targets for the redundancy check.

[0201] When no motion information candidate with the same motion information as the current block is included, the motion information candidate derived based on the current block can be added to the motion information table S1308. Whether the motion information candidates are the same can be determined based on whether the motion information (e.g., motion vector / reference picture index, etc.) of the motion information candidates is the same.

[0202] In this regard, when the maximum number of motion information candidates has been stored in the motion information table S1306, the oldest motion information candidate can be deleted S1307, and the motion information candidate derived based on the current block can be added to the motion information table S1308. In this regard, the oldest motion information candidate can be the motion information candidate having the largest index or the smallest index.

[0203] The motion information candidate can be identified by a corresponding index. When the motion information candidate derived from the current block is added to the motion information table, the smallest index (e.g., 0) can be assigned to the motion information candidate, and the indices of the pre-stored motion information candidates can be increased by 1. In this regard, when the maximum number of motion information candidates has been stored in the motion information table, the motion information candidate having the largest index is removed.

[0204] Alternatively, when the motion information candidate derived from the current block is added to the motion information table, the largest index can be assigned to the motion information candidate. In an example, when the number of pre-stored motion information candidates in the motion information table is less than the maximum value, an index having the same value as the number of pre-stored motion information candidates can be assigned to the motion information candidate. Alternatively, when the number of pre-stored motion information candidates in the motion information table is equal to the maximum value, an index obtained by subtracting 1 from the maximum value can be assigned to the motion information candidate. Alternatively, the motion information candidate having the smallest index is removed, and the indices of the remaining pre-stored motion information candidates are decreased by 1.

[0205] FIG. 14 is a diagram illustrating an update aspect of a motion information table.

[0206] It is assumed that when the motion information candidate derived from the current block is added to the motion information table, the largest index is assigned to the motion information candidate. Further, it is assumed that the maximum number of motion information candidates has been stored in the motion information table.

[0207] When the motion information candidate HmvpCand[n+1] derived from the current block is added to the motion information table HmvpCandList, the motion information candidate HmvpCand[0] having the smallest index among the pre-stored motion information candidates can be deleted, and the indices of the remaining motion information candidates can be decreased by 1. Further, the index of the motion information candidate HmvpCand[n+1] derived from the current block can be set to the maximum value (for FIG. 14 the example shown in FIG. 13B, n).

[0208] When the same motion information candidate as the motion information candidate derived based on the current block is pre-stored S1305, the motion information candidate derived based on the current block can not be added to the motion information table S1309.

[0209] Optionally, when the motion information candidate derived based on the current block is added to the motion information table, a pre-stored motion information candidate identical to the motion information candidate can be removed. In this case, the same effect as when the index of the pre-stored motion information candidate is re-updated is produced.

[0210] FIG. 15 is a diagram illustrating an example of updating the index of the pre-stored motion information candidate.

[0211] When the index of the pre-stored motion information candidate identical to the motion information candidate mvCand derived from the current block is hIdx, the pre-stored motion information candidate can be removed, and the index of the motion information candidate greater than hIdx can be decreased by 1. In an example, FIG. 15 The example shown in the above equation illustrates that HmvpCand[2] identical to mvCand is deleted in the motion information table HvmpCandList, and the index from HmvpCand[3] to HmvpCand[n] is decreased by 1.

[0212] Also, the motion information candidate mvCand derived based on the current block can be added to the end of the motion information table.

[0213] Optionally, the index assigned to the pre-stored motion information candidate identical to the motion information candidate derived based on the current block can be updated. For example, the index of the pre-stored motion information candidate can be changed to the minimum value or the maximum value.

[0214] The motion information of a block included in a predetermined region can be set not to be added to the motion information table. In an example, a motion information candidate derived based on the motion information of a block included in a merge processing region can not be added to the motion information table. Since the encoding / decoding order for a plurality of blocks included in the merge processing region is not defined, it is not appropriate to use the motion information of any one of the plurality of blocks for inter prediction of another block among the plurality of blocks. Thus, a motion information candidate derived based on a block included in the merge processing region can not be added to the motion information table.

[0215] Optionally, the motion information of a block smaller than a preset size can be set not to be added to the motion information table. In an example, a motion information candidate derived based on the motion information of a coding block having a width or height smaller than 4 or 8 or the motion information of a coding block having a size of 4x4 can not be added to the motion information table.

[0216] When motion compensation prediction is performed based on each sub-block, a motion information 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. In an example, when a sub-block merge candidate is used for the current block, a motion information candidate can be derived based on the motion information of a representative sub-block among the sub-blocks.

[0217] The motion vector of the sub-block 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. Also, a shifted sub-block of a collocated sample (e.g., a top-left sample or a center sample) of each sub-block in the coding block can be derived by adding the initial shift vector to the position (xSb, ySb) of the collocated sample. Equation 1 below shows a formula for deriving the shifted sub-block.

[0218] [Equation 1]

[0219] (xColSb, yColSb) = (xSb + shVector[0] » 4, ySb + shVector[1] » 4)

[0220] Then, the motion vector of the collocated block corresponding to the center position of the sub-block including (xColSb, yColSb) can be set to the motion vector of the sub-block including (xSb, ySb).

[0221] The representative sub-block can denote a sub-block including a top-left sample, a center sample, a bottom-right sample, a top-right sample, or a bottom-left sample of the current block.

[0222] FIG. 16 is a diagram showing the positions of the representative sub-blocks.

[0223] FIG. 16 (a) shows an example in which a sub-block located at the top-left of the current block is set as a representative sub-block, and FIG. 16 (b) shows an example in which a sub-block located at the center of the current block is set as a representative sub-block. When motion-compensated prediction is performed based on a sub-block, a motion information candidate of the current block can be derived based on the motion vector of the sub-block including the top-left sample of the current block or the center sample of the current block.

[0224] Based on the inter prediction mode of the current block, it can be determined whether the current block is to be used as a motion information candidate. In an example, a block encoded / decoded based on an affine motion model can be set as unavailable to be used as a motion information candidate. Thus, although the current block is encoded / decoded by inter prediction, when the inter prediction mode of the current block is an affine prediction mode, the motion information table can not be updated based on the current block.

[0225] Optionally, it can be determined whether the current block will be used as a motion information candidate based on at least one of a motion vector resolution of the current block, whether a merge offset coding method is applied, whether combined prediction is applied, or whether a triangle partition is applied. In an example, the current block can be set as unavailable to be used as a motion information candidate in at least one of a case where a motion information resolution of the current block is equal to or greater than 2 integer pixels, a case where combined prediction is applied to the current block, or a case where a merge offset coding method is applied to the current block.

[0226] Optionally, a motion information candidate can be derived based on at least one sub-block vector of a sub-block included in a block coded / decoded based on an affine motion model. In an example, a motion information candidate can be derived by using a sub-block located at a top-left, center, or top-right of the current block. Optionally, an average of sub-block vectors of a plurality of sub-blocks can be set as a motion vector of the motion information candidate.

[0227] Optionally, a motion information candidate can be derived based on an average of affine seed vectors of a block coded / decoded according to an affine motion model. In an example, at least one average of a first affine seed vector, a second affine seed vector, or a third affine seed vector of the current block can be set as a motion vector of the motion information candidate.

[0228] Optionally, a motion information table can be configured per inter prediction mode. In an example, at least one of a motion information table for a block coded / decoded by intra block copy, a motion information table for a block coded / decoded based on a translational motion model, or a motion information table for a block coded / decoded based on an affine motion model can be defined. Any one of a plurality of motion information tables can be selected according to an inter prediction mode of the current block.

[0229] FIG. 17 An example of generating a motion information table per inter prediction mode is illustrated.

[0230] When a block is coded / decoded based on a non-affine motion model, a motion information candidate mvCand derived based on the block can be added to a non-affine motion information table HmvpCandList. On the other hand, when a block is coded / decoded based on an affine motion model, a motion information candidate mvAfCand derived based on the above model can be added to an affine motion information table HmvpCandList.

[0231] An affine seed vector of the above block can be stored in a motion information candidate derived from a block coded / decoded based on an affine motion model. Accordingly, the motion information candidate can be used as a merge candidate for deriving an affine seed vector of the current block.

[0232] Optionally, the motion information table can be configured in motion vector resolution. In an example, at least one of a motion information table for storing motion information with a motion vector resolution of 1 / 16-pixel, a motion information table for storing motion information with a motion vector resolution of 1 / 4-pixel, a motion information table for storing motion information with a motion vector resolution of 1 / 2-pixel, a motion information table for storing motion information with a motion vector resolution of integer-pixel, or a motion information table for storing motion information with a motion vector resolution of 4 integer-pixels can be defined.

[0233] FIG. 18 An example of generating a motion information table in motion vector resolution is shown.

[0234] When the motion vector resolution of the block has 1 / 4-pixel, the motion information mvCand of the block can be stored in the quarter-pixel motion information table HmvpQPCandList. On the other hand, when the motion vector resolution of the block has integer-pixel, the motion information mvCand of the block can be stored in the integer-pixel motion information table HmvpIPCandList. When the motion vector resolution of the block has 4 integer-pixels, the motion information mvCand of the block can be stored in the 4 integer-pixel motion information table Hmvp4IPCandList.

[0235] Based on the motion vector resolution of the current block, the merge candidate of the current block can be derived by selecting a motion information table. In an example, when the motion vector resolution of the current block is 1 / 4-pixel, the merge candidate of the current block can be derived by using the quarter-pixel motion information table HmvpQPCandList. On the other hand, when the motion vector resolution of the current block is integer-pixel, the merge candidate of the current block can be derived by using the integer-pixel motion information table HmvpIPCandList.

[0236] Optionally, the motion information of a block to which the merge offset encoding method is applied can be stored in a separate motion information table.

[0237] FIG. 19 An example of the motion information of a block to which the merge offset encoding method is applied being stored in a separate motion information table is shown.

[0238] When the merge offset vector encoding method is not applied to the block, the motion information mvCand of the block can be stored in the motion information table HmvpCandList. On the other hand, when the merge offset vector encoding method is applied to the block, the motion information mvCand of the block can not be stored in the motion information table HmvpCandList and can be stored in the merge offset motion information table HmvpMMVDCandList.

[0239] Based on whether the merge offset vector coding method is applied to the current block, a motion information table can be selected. In an example, when the merge offset coding method is not applied to the current block, a merge candidate of the current block can be derived by using a motion information table HmvpCandList. On the other hand, when the merge offset coding method is applied to the current block, a merge candidate of the current block can be derived by using a merge offset motion information table HmvpMMVDCandList.

[0240] In addition to the described motion information tables, additional motion information tables can be defined. In addition to the above-described motion information table (hereinafter, referred to as a first motion information table), a long-term motion information table (hereinafter, referred to as a second motion information table) can be defined. In this regard, the long-term motion information table includes long-term motion information candidates.

[0241] When both the first motion information table and the second motion information table are empty, first, motion information candidates can be added to the second motion information table. After the number of motion information candidates available for the second motion information table reaches a maximum number, motion information candidates can be added to the first motion information table.

[0242] Optionally, one motion information candidate can be added to both the second motion information table and the first motion information table.

[0243] In this regard, the filled second motion information table can no longer perform updating. Optionally, the second motion information table can be updated when the decoded area exceeds a predetermined ratio in a slice. Optionally, the second motion information table can be updated every N lines of coding tree units.

[0244] On the other hand, the first motion information table can be updated every time a coding / decoding block is generated by inter prediction. However, the motion information candidate added to the second motion information table can be set not to be used to update the first motion information table.

[0245] Information for selecting any one of the first motion information table or the second motion information table can be signaled in a bitstream. When the number of merge candidates included in a merge candidate list is less than a threshold value, motion information candidates included in a motion information table indicated by the information can be added to the merge candidate list as merge candidates.

[0246] Optionally, the motion information table can be selected based on a size of the current block, a shape of the current block, an inter prediction mode of the current block, whether bi-prediction is applied to the current block, whether a motion vector is modified, or whether a triangular partition is applied to the current block.

[0247] Optionally, when the number of merge candidates included in the merge candidate list is less than the maximum number even though the motion information candidates included in the first motion information table are added, the motion information candidates included in the second motion information table can also be added to the merge candidate list.

[0248] FIG. 20 FIG. 1 is a diagram illustrating an example of adding the motion information candidates included in the long-term motion information table to the merge candidate list.

[0249] When the number of merge candidates included in the merge candidate list is less than the maximum number, the motion information candidates included in the first motion information table HmvpCandList can be added to the merge candidate list. When the number of merge candidates included in the merge candidate list is less than the maximum number even though the motion information candidates included in the first motion information table are added to the merge candidate list, the motion information candidates included in the long-term motion information table HmvpLTCandList can also be added to the merge candidate list.

[0250] Table 1 illustrates a process of adding the motion information candidates included in the long-term motion information table to the merge candidate list.

[0251]

Table 1

[0252]

[0253]

[0254] The motion information candidate can be set to include additional information other than the motion information. In an example, at least one of the size, shape, or partition information of a block can be additionally stored in the motion information candidate. When configuring the merge candidate list of the current block, only the motion information candidate having the size, shape, or partition information identical or similar to the current block can be used, or the motion information candidate having the size, shape, or partition information identical or similar to the current block can be added to the merge candidate list in advance. Alternatively, the motion information table can be generated per block size, shape, or partition information. The merge candidate list of the current block can be configured by using the motion information table matching the shape, size, or partition information of the current block among a plurality of motion information tables.

[0255] When the number of merge candidates included in the merge candidate list of the current block is less than a threshold value, the motion information candidate included in the motion information table can be added to the merge candidate list as a merge candidate. The addition process can be performed in an order of ascending or descending reflecting the index of the motion information candidate. In an example, the motion information candidate having the largest index can be added first to the merge candidate list of the current block.

[0256] When a motion information candidate included in the motion information table is added to the merge candidate list, a redundancy check between the motion information candidate and a pre-stored merge candidate in the merge candidate list can be performed. As a result of the redundancy check, the motion information candidate having the same motion information as the pre-stored merge candidate can not be added to the merge candidate list.

[0257] In an example, Table 2 illustrates a process of adding a motion information candidate to a merge candidate list.

[0258]

Table 2

[0259]

[0260]

[0261] The redundancy check can be performed only for a part of the motion information candidates included in the motion information table. In an example, the redundancy check can be performed only for the motion information candidates having an index exceeding or being lower than a threshold value. Alternatively, the redundancy check can be performed only for N motion information candidates having a largest index or a smallest index. Alternatively, the redundancy check can be performed only for a part of the pre-stored merge candidates in the merge candidate list. In an example, the redundancy check can be performed only for the merge candidates having an index exceeding or being lower than a threshold value or the merge candidates derived from a block at a specific position. In this regard, the specific position can include at least one of a left neighboring block, an above neighboring block, a top-right neighboring block, or a bottom-left neighboring block of a current block.

[0262] FIG. 21 is a diagram illustrating an example in which the redundancy check is performed only for a part of the merge candidates.

[0263] When the motion information candidate HmvpCand[j] is added to the merge candidate list, a redundancy check for 2 merge candidates having a largest index, mergeCandList[NumMerge-2] and mergeCandList[NumMerge-1], can be performed for the motion information candidate. In this regard, NumMerge can indicate a number of spatial merge candidates and temporal merge candidates available.

[0264] Unlike the illustrated example, when the motion information candidate HmvpCand[j] is added to the merge candidate list, a redundancy check for 2 merge candidates having a smallest index can be performed for the motion information candidate. For example, it can be checked whether mergeCandList[0] and mergeCandList[1] are identical to HmvpCand[j].

[0265] Optionally, the redundancy check can be performed only for merge candidates derived from a specific position. In an example, the redundancy check can be performed for at least one of the merge candidates derived from a neighboring block located at the left side of the current block or above the current block. When there is no merge candidate derived from a specific position in the merge candidate list, the motion information candidate can be added to the merge candidate list without the redundancy check.

[0266] When a motion information candidate HmvpCand[j] is added to the merge candidate list, a redundancy check for 2 merge candidates with the largest index, mergeCandList[NumMerge-2] and mergeCandList[NumMerge-1], can be performed for the motion information candidate. In this regard, NumMerge can show the number of spatial merge candidates and temporal merge candidates available.

[0267] The redundancy check for the merge candidates can be performed only for a part of the motion information candidates. In an example, the redundancy check can be performed only for N motion information candidates with the largest index or the smallest index among the motion information candidates included in the motion information table. In an example, the redundancy check can be performed only for the motion information candidates with an index lower than a threshold value for the number and difference of the motion information candidates included in the motion information table. When the threshold value is 2, the redundancy check can be performed only for 3 motion information candidates with the largest index value among the motion information candidates included in the motion information table. For the motion information candidates other than the above 3 motion information candidates, the redundancy check can be omitted. When the redundancy check is omitted, the motion information candidate can be added to the merge candidate list regardless of whether there is the same motion information as the merge candidate.

[0268] On the contrary, the redundancy check can be set to be performed only for the motion information candidates with an index exceeding the threshold value for the number and difference of the motion information candidates included in the motion information table.

[0269] The number of motion information candidates for which the redundancy check is performed can be redefined in the encoder and the decoder. In an example, the threshold value can be an integer such as 0, 1, or 2.

[0270] Optionally, the threshold value can be determined based on at least one of the number of merge candidates included in the merge candidate list or the number of motion information candidates included in the motion information table.

[0271] When the same merge candidate as a first motion information candidate is found, the redundancy check for the same merge candidate as the first motion information candidate can be omitted in the redundancy check for a second motion information candidate.

[0272] FIG. 22is a diagram showing an example in which a redundant check for a specific merge candidate is omitted.

[0273] When the motion information candidate HmvpCand[i] of index i is added to the merge candidate list, a redundant check between the motion information candidate and the pre-stored merge candidate in the merge candidate list is performed. In this regard, when the same merge candidate mergeCandList[j] as the motion information candidate HmvpCand[i] is found, a redundant check between the motion information candidate HmvpCand[i-1] of index i-1 and the merge candidate can be performed without adding the motion information candidate HmvpCand[i] to the merge candidate list. In this regard, the redundant check between the motion information candidate HmvpCand[i-1] and the merge candidate mergeCandList[j] can be omitted.

[0274] In an example, in the example shown in FIG. 22 In an example, in the example shown in

[0275] When the number of merge candidates included in the merge candidate list of the current block is less than a threshold value, at least one of a pair-wise merge candidate or a zero merge candidate can be additionally included in addition to the motion information candidate. The pair-wise merge candidate means a merge candidate having a value obtained by averaging motion vectors of more than 2 merge candidates as a motion vector, and the zero merge candidate means a merge candidate having a motion vector of 0.

[0276] For the merge candidate list of the current block, the merge candidates can be added in the following order.

[0277] Spatial merge candidate - temporal merge candidate - motion information candidate - (affine motion information candidate) - pair-wise merge candidate - zero merge candidate

[0278] The spatial merge candidate means a merge candidate derived from at least one of a neighboring block or a non-neighboring block, and the temporal merge candidate means a merge candidate derived from a previous reference picture. The affine motion information candidate means a motion information candidate derived from a block encoded / decoded by an affine motion model.

[0279] Motion information table can be used in the motion vector prediction mode. In an example, when the number of motion vector prediction candidates included in the motion vector prediction candidate list of the current block is less than a threshold, a motion information candidate included in the motion information table can be set as a motion vector prediction candidate for the current block. Specifically, the motion vector of the motion information candidate can be set as the motion vector prediction candidate.

[0280] If 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 a motion vector predictor of the current block. Then, after the motion vector residual value of the current block is decoded, the motion vector of the current block can be obtained by adding the motion vector predictor and the motion vector residual value.

[0281] The motion vector prediction candidate list of the current block can be configured in the following order.

[0282] spatial motion vector prediction candidate - temporal motion vector prediction candidate - motion information candidate - (affine motion information candidate) - zero motion vector prediction candidate

[0283] The spatial motion vector prediction candidate means a motion vector prediction candidate derived from at least one of a neighboring block or a non-neighboring block, and the temporal motion vector prediction candidate means a motion vector prediction candidate derived from a previous reference picture. The affine motion information candidate means a motion information candidate derived from a block encoded / decoded by an affine motion model. The zero motion vector prediction candidate means a candidate in which the value of the motion vector is 0.

[0284] A merge processing region larger than the coded block can be defined. The coded blocks included in the merge processing region can be processed in parallel, rather than being sequentially encoded / decoded. In this regard, being sequentially encoded / decoded means that the order of encoding / decoding is not defined. Accordingly, the encoding / decoding process of the blocks included in the merge processing region can be processed independently. Alternatively, the blocks included in the merge processing region can share a merge candidate. In this regard, the merge candidate can be derived based on the merge processing region.

[0285] According to the above-described feature, the merge processing region can be referred to as a parallel processing region, a shared merge region (SMR), or a merge estimation region (MER).

[0286] A merge candidate of the current block can be derived based on the coded blocks. However, when the current block is included in a merge processing region larger than the current block, a candidate block included in the same merge processing region as the current block can be set as unavailable to be used as a merge candidate.

[0287] FIG. 23 is a diagram illustrating an example in which a candidate block included in the same merge processing region as the current block is set as unavailable to be used as a merge candidate.

[0288] In FIG. 23 In the example shown in (a), in the decoding / decoding of CU5, blocks including the base samples neighboring CU5 can be set as candidate blocks. In this regard, candidate blocks x3 and x4 included in the same merge processing region as CU5 can be set as unavailable as merge candidates for CU5. However, candidate blocks x0, x1 and x2 not included in the same merge processing region as CU5 can be set as available as merge candidates.

[0289] In FIG. 23 In the example shown in (b), in the decoding / decoding of CU8, blocks including the base samples neighboring CU8 can be set as candidate blocks. In this regard, candidate blocks x6, x7 and x8 included in the same merge processing region as CU8 can be set as unavailable as merge candidates. However, candidate blocks x5 and x9 not included in the same merge processing region as CU8 can be set as available as merge candidates.

[0290] Optionally, when the current block is included in the merge processing region, neighboring blocks neighboring the current block and the merge processing region can be set as candidate blocks.

[0291] FIG. 24 is a diagram showing an example of deriving merge candidates for a current block when the current block is included in a merge processing region.

[0292] As shown in the example in FIG. 24 (a), neighboring blocks neighboring the current block can be set as candidate blocks for deriving merge candidates for the current block. In this regard, candidate blocks included in the same merge processing region as the current block can be set as unavailable as merge candidates. In an example, in deriving merge candidates for the coding block CU3, the above neighboring block y3 and the upper-right neighboring block y4 included in the same merge processing region as the coding block CU3 can be set as unavailable as merge candidates for the coding block CU3.

[0293] By scanning the neighboring blocks neighboring the current block in a predefined order, the merge candidates can be derived. In an example, the predefined order can be the order of y1, y3, y4, y0 and y2.

[0294] When the number of merge candidates derivable from the neighboring blocks neighboring the current block is less than a value of the maximum number of merge candidates minus an offset or the maximum number, the merge candidates can be derived as FIG. 24The example shown in (b) derives the merge candidate for the current block by using neighboring blocks adjacent to the merge processing region. In the example, the neighboring blocks adjacent to the merge processing region including the coding block CU3 can be set as the candidate blocks for the coding block CU3. In this regard, the neighboring blocks adjacent to the merge processing region can include at least one of a left neighboring block xl, an above neighboring block x3, a lower-left neighboring block xo, an upper-right neighboring block x4, or an upper-left neighboring block x2.

[0295] The merge candidate can be derived by scanning the neighboring blocks adjacent to the merge processing region in a predefined order. In the example, the predefined order can be an order of xl, x3, x4, xo, and x2.

[0296] In summary, the merge candidate for the coding block CU3 included in the merge processing region can be derived by scanning the candidate blocks in the following scanning order.

[0297] (y1, y3, y4, y0, y2, xl, x3, x4, xo, x2)

[0298] However, the scanning order of the candidate blocks shown above is merely an example of the present disclosure, and the candidate blocks can be scanned in an order different from the example above. Alternatively, the scanning order can be adaptively determined based on at least one of a size or a shape of the current block or the merge processing region.

[0299] The merge processing region can be square or non-square. Information for determining the merge processing region can be signaled in a bitstream. The information can include at least one of information representing a shape of the merge processing region or information representing a size of the merge processing region. When the merge processing region is non-square, at least one of information representing a size of the merge processing region, information representing a width or a height of the merge processing region, or information representing an aspect ratio of the merge processing region can be signaled in the bitstream.

[0300] The size of the merge processing region can be determined based on at least one of information signaled in a bitstream, a picture resolution, a size of a slice, or a size of a parallel block.

[0301] If motion-compensated prediction is performed for a block included in the merge processing region, a motion information candidate derived based on motion information of the block for which the motion-compensated prediction is performed can be added to a motion information table.

[0302] However, if a motion information candidate derived from a block included in the merge processing region is added to the motion information table, a case in which the motion information candidate derived from the block is used in encoding / decoding of other blocks which actually encode / decode slower than the block in the merge processing region can occur. In other words, although dependency between blocks should be excluded in encoding / decoding of blocks included in the merge processing region, a case in which motion prediction compensation is performed by using motion information of other blocks included in the merge processing region can occur. To solve such a problem, although encoding / decoding of blocks included in the merge processing region is completed, motion information of the blocks for which encoding / decoding is completed can not be added to the motion information table.

[0303] Alternatively, the motion information table can be updated by using only blocks at predefined positions in the merge processing region. The predefined positions can include at least one of a block at an upper left position, a block at an upper right position, a block at a lower left position, a block at a lower right position, a block at a center position, a block adjacent to a right boundary, or a block adjacent to a lower boundary in the merge processing region. In an example, motion information of only a block adjacent to a lower right corner in the merge processing region can be updated in the motion information table, and motion information of other blocks can not be updated in the motion information table.

[0304] Alternatively, motion information candidates derived from blocks included in the merge processing region can be added to the motion information table after all the blocks included in the merge processing region are decoded. In other words, although blocks included in the merge processing region are encoded / decoded, the motion information table can not be updated.

[0305] In an example, if motion compensation prediction is performed for a block included in the merge processing region, motion information candidates derived from the block can be added to the motion information table in a predefined order. In this regard, the predefined order can be determined in a scan order of encoded blocks in the merge processing region or the coding tree unit. The scan order can be at least one of a raster scan, a horizontal scan, a vertical scan, or a zigzag scan. Alternatively, the predefined order can be determined based on motion information of each block or a number of blocks having the same motion information.

[0306] Alternatively, motion information candidates including uni-directional motion information can be added to the motion information table before motion information candidates including bi-directional motion information. Conversely, motion information candidates including bi-directional motion information can be added to the motion information table before motion information candidates including uni-directional motion information.

[0307] Alternatively, motion information candidates can be added to the motion information table in an order of high or low frequency of use in the merge processing region or the coding tree unit.

[0308] When the current block is included in the merge processing region and the number of merge candidates included in the merge candidate list of the current block is less than the maximum number, the motion information candidate included in the motion information table can be added to the merge candidate list. In this regard, the motion information candidate derived from the block included in the same merge processing region as the current block can be set not to be added to the merge candidate list of the current block.

[0309] Alternatively, when the current block is included in the merge processing region, it can be set not to use the motion information candidate included in the motion information table. In other words, although the number of merge candidates included in the merge candidate list of the current block is less than the maximum number, the motion information candidate included in the motion information table can not be added to the merge candidate list.

[0310] In another example, the motion information table with respect to the merge processing region or the coding tree unit can be configured. This motion information table functions to temporarily store the motion information of the block included in the merge processing region. In order to distinguish the general motion information table from the motion information table with respect to the merge processing region or the coding tree unit, the motion information table with respect to the merge processing region or the coding tree unit is referred to as a temporary motion information table. Also, the motion information candidate stored in the temporary motion information table is referred to as a temporary motion information candidate.

[0311] FIG. 25 FIG. 1 is a diagram illustrating a temporary motion information table.

[0312] The temporary motion information table with respect to the coding tree unit or the merge processing region can be configured. When performing the motion compensation prediction on the current block included in the coding tree unit or the merge processing region, the motion information of the block can not be added to the motion information table HmvpCandList. Instead, the temporary motion information candidate derived from the block can be added to the temporary motion information table HmvpMERCandList. In other words, the temporary motion information candidate added to the temporary motion information table can not be added to the motion information table. Accordingly, the motion information table can not include the motion information candidate derived based on the motion information of the block included in the coding tree unit or the merge processing region including the current block.

[0313] Optionally, only motion information of some of the blocks included in the merge processing region can be added to the temporary motion information table. In an example, only the blocks at predefined positions in the merge processing region can be used to update the motion information table. The predefined positions can include at least one of a block at a top-left position, a block at a top-right position, a block at a bottom-left position, a block at a bottom-right position, a block at a center position, a block adjacent to a right boundary, or a block adjacent to a bottom boundary in the merge processing region. In an example, only motion information of a block adjacent to a bottom-right corner in the merge processing region can be added to the temporary motion information table, and motion information of other blocks can not be added to the temporary motion information table.

[0314] A maximum number of temporary motion information candidates that can be included in the temporary motion information table can be set to be the same as a maximum number of motion information candidates. Optionally, the maximum number of temporary motion information candidates that can be included in the temporary motion information table can be determined according to a size of the coding tree unit or the merge processing region. Optionally, the maximum number of temporary motion information candidates that can be included in the temporary motion information table can be set to be less than the maximum number of motion information candidates that can be included in the motion information table.

[0315] A current block included in a coding tree unit or a merge processing region can be set not to use a temporary motion information table for a corresponding coding tree unit or merge processing region. In other words, when a number of merge candidates included in a merge candidate list of the current block is less than a threshold value, motion information candidates included in the motion information table can be added to the merge candidate list, and temporary motion information candidates included in the temporary motion information table can not be added to the merge candidate list. Thus, motion information of other blocks included in the same coding tree unit or the same merge processing region as the current block can not be used for motion-compensated prediction of the current block.

[0316] If encoding / decoding of all blocks included in a coding tree unit or a merge processing region is completed, the motion information table and the temporary motion information table can be made consistent.

[0317] FIG. 26 is a diagram illustrating an example of making the motion information table and the temporary motion information table consistent.

[0318] If encoding / decoding of all blocks included in a coding tree unit or a merge processing region is completed, the motion information table and the temporary motion information table can be made consistent. FIG. 26

[0319] In this regard, the temporary motion information candidates included in the temporary motion information table can be added to the motion information table in an order in which they are inserted in the temporary motion information table (in other words, in an ascending order or a descending order of index values). ​

[0320] In another example, the temporary motion information candidates included in the temporary motion information table can be added to the motion information table in a predefined order. In this regard, the predefined order can be determined according to a scan order of the coding blocks in the merge processing region or the coding tree unit. The scan order can be at least one of a raster scan, a horizontal scan, a vertical scan, or a zigzag scan. 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.

[0321] Alternatively, the temporary motion information candidates including uni-directional motion information can be added to the motion information table before the temporary motion information candidates including bi-directional motion information. Conversely, the temporary motion information candidates including bi-directional motion information can be added to the motion information table before the temporary motion information candidates including uni-directional motion information.

[0322] Alternatively, the temporary motion information candidates can be added to the motion information table in an order of high usage frequency or low usage frequency in the merge processing region or the coding tree unit.

[0323] In case that the temporary motion information candidates included in the temporary motion information table are added to the motion information table, a redundancy check for the temporary motion information candidates can be performed. In an example, when a motion information candidate identical to a temporary motion information candidate included in the temporary motion information table is pre-stored in the motion information table, the temporary motion information candidate can not be added to the motion information table. In this regard, the redundancy check can be performed for a part of the motion information candidates included in the motion information table. In an example, the redundancy check can be performed for the motion information candidates whose index exceeds or is lower than a threshold value. In an example, when a temporary motion information candidate is equal to a motion information candidate whose index is higher than a predefined value, the temporary motion information candidate can not be added to the motion information table.

[0324] This can limit the motion information candidates derived from the blocks included in the same coding tree unit or the same merge processing region as the current block to be used as the merge candidate of the current block. To this end, the address information of the block can be additionally stored for the motion information candidate. The address information of the block can include at least one of a position of the block, an address of the block, an index of the block, a position of the merge processing region including the block, an address of the merge processing region including the block, an index of the merge processing region including the block, a position of the coding tree region including the block, an address of the coding tree region including the block, or an index of the coding tree region including the block.

[0325] The coding block can be partitioned into a plurality of prediction units, and the prediction can be performed for each of the partitioned prediction units. In this case, the prediction unit indicates a basic unit for performing the prediction.

[0326] A coded block can be partitioned using at least one of vertical lines, horizontal lines, diagonal lines, or diagonal lines. The prediction units partitioned by the partition lines can have shapes such as triangles, quadrilaterals, trapezoids, or pentagons. In the example, a coded block can be partitioned into two triangular prediction units, two trapezoidal prediction units, two quadrilateral prediction units, or one triangular prediction unit and one pentagonal prediction unit.

[0327] Information for determining at least one of the number, angle, or position of lines that partition a coded block can be transmitted as a bitstream signal. In the example, information representing a partition type candidate among partition type candidates for the coded block can be transmitted as a bitstream signal, or information specifying one of multiple line candidates for partitioning the coded block can be transmitted as a bitstream signal. In the example, index information indicating one of the multiple line candidates can be transmitted as a bitstream signal.

[0328] For each of the multiple line candidates, at least one of the angles or positions may be different. The number of line candidates available for the current block can be determined based on the size or shape of the current block, the number of available merge candidates, or whether neighboring blocks at a particular position are available as merge candidates.

[0329] Optionally, information for determining the number or type of line candidates can be transmitted as a bitstream signal. In an example, a 1-bit flag can be used to determine whether a line with an angle greater than the diagonal and / or an angle less than the diagonal is suitable as a line candidate. This information can be transmitted as a signal at the sequence level, the screen level, or the sequence level.

[0330] Optionally, at least one of the following can be used to adaptively determine the number, angle, or position of lines that partition the coding block: the intra-frame prediction mode or inter-frame prediction mode of the coding block, the location of available merge candidates, or the partition type of neighboring blocks.

[0331] When a coded block is partitioned into multiple prediction units, intra-frame prediction or inter-frame prediction can be performed for each prediction unit in the partition.

[0332] FIG. 27 This is a diagram illustrating an example of dividing a coded block into multiple prediction units using diagonal lines.

[0333] As in FIG. 27 In the examples shown in (a) and (b), the coded block can be partitioned into two triangular prediction units by using diagonals.

[0334] FIG. 27(a) and (b) show that a coding block is partitioned into two prediction units by using a diagonal line connecting two vertices of the coding block. However, a coding block can be partitioned into two prediction units by using a slanted line whose at least one end does not pass through a vertex of the coding block.

[0335] FIG. 28 is a diagram showing an example in which a coding block is partitioned into two prediction units.

[0336] As in the example shown in FIG. 28 (a) and (b), a coding block can be partitioned into two prediction units by using a slanted line whose both ends adjoin an upper boundary and a lower boundary of the coding block, respectively.

[0337] Alternatively, as in the example shown in FIG. 28 (c) and (d), a coding block can be partitioned into two prediction units by using a slanted line whose both ends adjoin a left boundary and a right boundary of the coding block, respectively.

[0338] Alternatively, a coding block can be partitioned into two prediction units having different sizes. In an example, a coding block can be partitioned into two prediction units having different sizes by setting a slanted line partitioning the coding block to meet two boundaries forming one vertex.

[0339] FIG. 29 shows an example in which a coding block is partitioned into prediction blocks having different sizes.

[0340] As in the example shown in FIG. 29 (a) and (b), a coding block can be partitioned into two prediction units having different sizes by setting a diagonal line connecting the upper left and lower right of the coding block to pass through a left boundary, a right boundary, an upper boundary, or a lower boundary rather than passing through a left upper corner or a right lower corner of the coding block.

[0341] Alternatively, as in the example shown in FIG. 29 (c) and (d), a coding block can be partitioned into two prediction units having different sizes by setting a diagonal line connecting the upper right and lower left of the coding block to pass through a left boundary, a right boundary, an upper boundary, or a lower boundary rather than passing through a left upper corner or a right lower corner of the coding block.

[0342] Each of the prediction units generated by partitioning a coding block is referred to as an "Nth prediction unit". In an example, in the example shown in FIG. 27 to FIG. 29 PU1 can be defined as a first prediction unit and PU2 can be defined as a second prediction unit. The first prediction unit can denote a prediction unit including a sample located at a lower left position or a sample located at an upper left position in a coding block, and the second prediction unit can denote a prediction unit including a sample located at an upper right position or a sample located at a lower right position in the coding block.

[0343] On the contrary, a prediction unit including a sample located at an upper right position or a sample located at a lower right position in the coding block can be defined as a first prediction unit, and a prediction unit including a sample located at a lower left position or a sample located at an upper left position in the coding block can be defined as a second prediction unit.

[0344] When the coding block is partitioned by using a horizontal line, a vertical line, a diagonal line, or an oblique line, this can be referred to as prediction unit partitioning. The prediction units generated by applying the prediction unit partitioning can be referred to as triangular prediction units, quadrilateral prediction units, or pentagonal prediction units according to their shapes.

[0345] In the following embodiments, it will be assumed that the coding block is partitioned by using a diagonal line. Specifically, when the coding block is partitioned into two prediction units by using a diagonal line, this is referred to as diagonal partitioning or triangular partitioning. However, even when the coding block is partitioned by using an oblique line having a different angle from a vertical line, a horizontal line, or a diagonal line, the prediction units can be encoded / decoded according to the following embodiments. In other words, matters related to the encoding / decoding of the triangular prediction units described below can also be applied to the encoding / decoding of the quadrilateral prediction units or the pentagonal prediction units.

[0346] Whether the prediction unit partitioning is to be applied to the coding block can be determined based on at least one of a slice type, a maximum number of merge candidates that can be included in a merge candidate list, a size of the coding block, a shape of the coding block, a prediction encoding mode of the coding block, or a partitioning aspect of a parent node.

[0347] In an example, whether the prediction unit partitioning is to be applied to the coding block can be determined based on whether the current slice is of a B type. The prediction unit partitioning can be allowed only when the current slice is of the B type.

[0348] Alternatively, whether the prediction unit partitioning is to be applied to the coding block can be determined based on whether a maximum number of merge candidates included in a merge candidate list is equal to or greater than 2. The prediction unit partitioning can be allowed only when the maximum number of merge candidates included in the merge candidate list is equal to or greater than 2.

[0349] Alternatively, when at least one of a width or a height is greater than 64, a drawback can occur during implementation of hardware that redundantly accesses a data processing unit of a 64x64 size. Accordingly, when at least one of a width or a height of the coding block is greater than a threshold value, the coding block can not be partitioned into a plurality of prediction units. In an example, when at least one of a width or a height of the coding block is greater than 64 (for example, when at least one of the width or the height is 128), the prediction unit partitioning can not be used.

[0350] Optionally, the prediction unit partitioning can not be allowed for a coding block having a number of samples greater than a threshold by considering a maximum number of samples that can be processed simultaneously by the implemented hardware. In an example, the prediction unit partitioning can not be allowed for a coding tree block having a number of samples greater than 4096.

[0351] Optionally, the prediction unit partitioning can not be allowed for a coding block having a number of samples less than a threshold. In an example, the prediction unit partitioning can be set to not be applied to a coding block when the number of samples included in the coding block is less than 64.

[0352] Optionally, whether the prediction unit partitioning is to be applied to a coding block can be determined based on whether a width-to-height ratio of the coding block is less than a first threshold or whether the width-to-height ratio of the coding block is greater than a second threshold. In this case, the width-to-height ratio whRatio of the coding block can be determined as a ratio of a width CbW and a height CbH of the coding block as shown in Equation 2 below.

[0353] [Equation 2]

[0354] whRatio = CbW / CbH

[0355] The second threshold can be an inverse of the first threshold. In an example, when the first threshold is k, the second threshold can be 1 / k.

[0356] The prediction unit partitioning can be applied to a coding block only when the width-to-height ratio of the coding block is within a range between the first threshold and the second threshold.

[0357] Optionally, the prediction unit partitioning can be used only when the width-to-height ratio of the coding block is less than the first threshold or greater than the second threshold. In an example, when the first threshold is 16, the prediction unit partitioning can not be allowed for a coding block having a size of 64x4 or 4x64.

[0358] Optionally, whether the prediction unit partitioning is allowed can be determined based on a partition type of a parent node. In an example, when the coding block, the parent node is partitioned based on a quad-tree partitioning, the prediction unit partitioning can be applied to the coding block, the leaf node. On the other hand, when the coding block, the parent node is partitioned based on a binary-tree or ternary-tree partitioning, the prediction unit partitioning can be set to not be allowed for the coding block, the leaf node.

[0359] Optionally, whether the prediction unit partitioning is allowed can be determined based on a prediction encoding mode of the coding block. In an example, the prediction unit partitioning can be allowed only when the coding block is encoded by intra prediction, when the coding block is encoded by inter prediction, or when the coding block is encoded by a predefined inter prediction mode. In this case, the predefined inter prediction mode can include at least one of a merge mode, a motion vector prediction mode, an affine merge mode, or an affine motion vector prediction mode.

[0360] Optionally, based on the size of the parallel processing region, it can be determined whether to allow prediction unit partitioning. In an example, when the size of the coding block is larger than the size of the parallel processing region, prediction unit partitioning can not be used.

[0361] By considering two or more of the above-listed conditions, it can be determined whether prediction unit partitioning is to be applied to the coding block.

[0362] In another example, information indicating whether prediction unit partitioning is to be applied to the coding block can be signaled in a bitstream. The information can be signaled at a sequence level, a picture level, a slice level, or a block level. For example, a flag triangle_partition_flag indicating whether prediction unit partitioning is applied to the coding block can be signaled at a coding block level.

[0363] When it is determined that prediction unit partitioning is to be applied to the coding block, information indicating the number of lines or the position of the lines partitioning the coding block can be signaled in a bitstream.

[0364] In an example, when the coding block is partitioned by a diagonal line, information indicating the direction of the diagonal line partitioning the coding block can be signaled in a bitstream. In an example, a flag triangle_partition_type_flag indicating the direction of the diagonal line can be signaled in a bitstream. The flag indicates whether the coding block is partitioned by a diagonal line connecting the top-left and bottom-right, or whether the coding block is partitioned by a diagonal line connecting the top-right and bottom-left. When the coding block is partitioned by a diagonal line connecting the top-left and bottom-right, this can be referred to as a left-side triangle partition type, and when the coding block is partitioned by a diagonal line connecting the top-right and bottom-left, this can be referred to as a right-side triangle partition type. In an example, when the value of the flag is 0, this can indicate that the partition type of the coding block is the left-side triangle partition type, and when the value of the flag is 1, this can indicate that the partition type of the coding block is the right-side triangle partition type.

[0365] Furthermore, information indicating whether the sizes of the prediction units are the same or information indicating the position of the diagonal line partitioning the coding block can be signaled in the bitstream. In an example, when the information indicating the sizes of the prediction units indicates that the sizes of the prediction units are the same, the encoding of the information indicating the position of the diagonal line can be omitted and the coding block can be partitioned into two prediction units by using a diagonal line passing through the two top corners of the coding block. On the other hand, when the information indicating the sizes of the prediction units indicates that the sizes of the prediction units are not the same, the position of the diagonal line partitioning the coding block can be determined based on the information indicating the position of the diagonal line. In an example, when the left triangle partition type is applied to the coding block, the position information can indicate whether the diagonal line meets the left boundary and the lower boundary of the coding block or whether the diagonal line meets the upper boundary and the right boundary. Alternatively, when the right triangle partition type is applied to the coding block, the position information can indicate whether the diagonal line meets the right boundary and the lower boundary of the coding block or whether the diagonal line meets the upper boundary and the left boundary.

[0366] The information indicating the partition type of the coding block can be signaled at the coding block level. Thus, the partition type can be determined per coding block to which the prediction unit partition is applied.

[0367] In another example, the information indicating the partition type for a sequence, a picture, a slice, a parallel block or a coding tree unit can be signaled. In this case, the partition types of the coding blocks in the sequence, the picture, the slice, the parallel block or the coding tree unit to which the diagonal line partition is applied can be set to be the same.

[0368] Alternatively, the information for determining the partition type of the first coding unit to which the prediction unit partition is applied in the coding tree unit can be encoded and signaled, and the second or later coding unit to which the prediction unit partition is applied can be set to use the same partition type as the first coding unit.

[0369] In another example, the partition type of the coding block can be determined based on the partition types of the neighboring blocks. In this case, the neighboring blocks can include at least one of the neighboring block adjacent to the top-left corner of the coding block, the neighboring block adjacent to the top-right corner, the neighboring block adjacent to the bottom-left corner, the neighboring block located above or the neighboring block located to the left. In an example, the partition type of the current block can be set to be the same as the partition types of the neighboring blocks. Alternatively, the partition type of the current block can be determined based on whether the left triangle partition type is applied to the top-left neighboring block or whether the right triangle partition type is applied to the top-right neighboring block or the bottom-left neighboring block.

[0370] To perform motion prediction compensation for the first and second prediction units, motion information of each of the first and second prediction units can be derived. In this case, the motion information of the first and second prediction units can be derived from merge candidates included in a merge candidate list. To distinguish between a general merge candidate list and a merge candidate list used to derive motion information of a prediction unit, the merge candidate list used to derive motion information of a prediction unit is referred to as a partition mode merge candidate list or a triangle merge candidate list. Also, a merge candidate included in the partition mode merge candidate list is referred to as a partition mode merge candidate or a triangle merge candidate. However, an operation of applying the above-described method of deriving a merge candidate and the above-described method of constructing a merge candidate list to derive a partition mode merge candidate and construct a partition mode merge candidate list is also included in the scope of the present disclosure.

[0371] Information for determining a maximum number of partition mode merge candidates that can be included in the partition mode merge candidate list can be signaled in a bitstream. The information can represent a difference between a maximum number of merge candidates that can be included in a merge candidate list and a maximum number of partition mode merge candidates that can be included in the partition mode merge candidate list.

[0372] A partition mode merge candidate can be derived from spatial and temporal neighboring blocks of a coding block.

[0373] FIG. 30 is a diagram illustrating neighboring blocks used to derive a partition mode merge candidate.

[0374] A partition mode merge candidate can be derived by using at least one of a neighboring block located above a coding block, a neighboring block located to the left of the coding block, or a collocated block included in a different picture from the coding block. The above neighboring block can include at least one of a block including a sample (xCb+CbW-1, yCb-1) located above the coding block, a block including a sample (xCb+CbW, yCb-1) located above the coding block, or a block including a sample (xCb-1, yCb-1) located above the coding block. The left neighboring block can include at least one of a block including a sample (xCb-1, yCb+CbH-1) located to the left of the coding block or a block including a sample (xCb-1, yCb+CbH) located to the left of the coding block. The collocated block can be determined as one of a block including a sample (xCb+CbW, yCb+CbH) adjacent to a top right corner of the coding block in a collocated picture or a block including a sample (xCb / 2, yCb / 2) located at a center of the coding block.

[0375] The neighboring blocks can be searched in a predefined order and the partition mode merge candidate list can be configured with partition mode merge candidates according to the predefined order. In an example, the partition mode merge candidates can be searched in an order of B1, Al, B0, A0, C0, B2, and C1 to configure the partition mode merge candidate list.

[0376] The motion information of the prediction units can be derived based on the partition mode merge candidate list. In other words, the prediction units can share a single partition mode merge candidate list.

[0377] To derive the motion information of the prediction units, information for specifying at least one of the partition mode merge candidates included in the partition mode merge candidate list can be signaled in a bitstream. In an example, index information merge_triangle_idx for specifying at least one of the partition mode merge candidates can be signaled in a bitstream.

[0378] The index information can specify a combination of the merge candidate of the first prediction unit and the merge candidate of the second prediction unit. In an example, Table 3 below is an example representing the combination of the merge candidates according to the index information merge_triangle_idx.

[0379] [Table 3]

[0380] merge_triangle_idx 0 1 2 3 4 5 6 7 8 first prediction unit 1 0 0 0 2 0 0 1 3 second prediction unit 0 1 2 1 0 3 4 0 0 merge_triangle_idx 9 10 11 12 13 14 15 16 17 first prediction unit 4 0 1 1 0 0 1 1 1 second prediction unit 0 2 2 2 4 3 3 4 4 merge_triangle_idx 18 19 20 21 22 23 24 25 26 first prediction unit 1 2 2 2 4 3 3 3 4 second prediction unit 3 1 0 1 3 0 2 4 0 merge_triangle_idx 27 28 29 30 31 32 33 34 35 first prediction unit 3 2 4 4 2 4 3 4 3 second prediction unit 1 3 1 1 3 2 2 3 1 merge_triangle_idx 36 37 38 39 first prediction unit 2 2 4 3 second prediction unit 4 4 2 4

[0381] When the value of the index information merge_triangle_idx is 1, it indicates that the motion information of the first prediction unit is derived from the merge candidate with index 1 and the motion information of the second prediction unit is derived from the merge candidate with index 0. The partition mode merge candidate used to derive the motion information of the first prediction unit and the partition mode merge candidate used to derive the motion information of the second prediction unit can be determined by the index information merge_triangle_idx. The partition type of the coding block to which the diagonal partition is applied can also be determined based on the index information. In other words, the index information can specify a combination of the merge candidate of the first prediction unit, the merge candidate of the second prediction unit, and the partition direction of the coding block. When the partition type of the coding block is determined by the index information, the information triangle_partition_type_flag representing the direction of the diagonal line partitioning the coding block can not be coded. Table 4 represents the partition type of the coding block for the index information merge_triangle_idx.

[0382] [Table 4]

[0383] merge_triangle_idx 0 1 2 3 4 5 6 7 8 TriangleDir 0 1 1 0 0 1 1 1 0 merge_triangle_idx 9 10 11 12 13 14 15 16 17 TriangleDir 0 0 0 1 0 0 0 0 1 merge_triangle_idx 18 19 20 21 22 23 24 25 26 TriangleDir 1 1 1 0 0 1 1 1 1 merge_triangle_idx 27 28 29 30 31 32 33 34 35 TriangleDir 1 1 1 0 0 1 0 1 0 merge_triangle_idx 36 37 38 39 TriangleDir 0 1 0 0

[0384] When the variable TriangleDir is 0, it indicates that the left triangle partition type is applied to the coding block, and when the variable TriangleDir is 1, it indicates that the right triangle partition type is applied to the coding block. By combining Table 3 and Table 4, the index information merge_triangle_idx can be set to specify the combination of the merge candidate of the first prediction unit, the merge candidate of the second prediction unit, and the partition direction of the coding block. In another example, the index information can be signaled for only one of the first prediction unit and the second prediction unit, and the index of the merge candidate for the other one of the first prediction unit and the second prediction unit can be determined based on the index information. In an example, the merge candidate of the first prediction unit can be determined based on the index information merge_triangle_idx representing the index of one of the partition mode merge candidates. Also, the merge candidate of the second prediction unit can be specified based on merge_triangle_idx. In an example, the merge candidate of the second prediction unit can be derived by adding or subtracting an offset from the index information merge_triangle_idx. The offset can be an integer such as 1 or 2. In an example, the merge candidate of the second prediction unit can be determined as the partition mode merge candidate having a value obtained by adding 1 to merge_triangle_idx as the index. When merge_triangle_idx indicates the partition mode merge candidate having the largest index value among the partition mode merge candidates, the motion information of the second prediction unit can be derived from the partition mode merge candidate having an index of 0 or the partition mode merge candidate having a value subtracted by 1 from merge_triangle_idx as the index.

[0385] Alternatively, the motion information of the second prediction unit can be derived from the partition mode merge candidate having the same reference picture as the partition mode merge candidate of the first prediction unit specified by the index information. In this case, the partition mode merge candidate having the same reference picture as the partition mode merge candidate of the first prediction unit can indicate the partition mode merge candidate having at least one of the L0 reference picture or the L1 reference picture same as the partition mode merge candidate of the first prediction unit. When there are multiple partition mode merge candidates having the same reference picture as the partition mode merge candidate of the first prediction unit, any one of them can be selected based on at least one of whether the merge candidate includes bi-directional motion information or a difference value between the index of the merge candidate and the index information.

[0386] In another example, index information can be signaled for each of the first and second prediction units. In an example, first index information 1st_merge_idx for determining a partition mode merge candidate of the first prediction unit and second index information 2nd_merge_idx for determining a partition mode merge candidate of the second prediction unit can be signaled in a bitstream. Motion information of the first prediction unit can be derived from the partition mode merge candidate determined based on the first index information 1st_merge_idx, and motion information of the second prediction unit can be derived from the partition mode merge candidate determined based on the second index information 2nd_merge_idx.

[0387] The first index information 1st_merge_idx can represent an index of one of the partition mode merge candidates included in the partition mode merge candidate list. The partition mode merge candidate of the first prediction unit can be determined as the partition mode merge candidate indicated by the first index information 1st_merge_idx.

[0388] The partition mode merge candidate indicated by the first index information 1st_merge_idx can be set to be unavailable as the partition mode merge candidate of the second prediction unit. Accordingly, the second index information 2nd_merge_idx of the second prediction unit can represent an index of any one of the remaining partition mode merge candidates except for the partition mode merge candidate indicated by the first index information. When a value of the second index information 2nd_merge_idx is less than a value of the first index information 1st_merge_idx, the partition mode merge candidate of the second prediction unit can be determined as the partition mode merge candidate having the index information represented by the second index information 2nd_merge_idx. On the other hand, when the value of the second index information 2nd_merge_idx is equal to or greater than the value of the first index information 1st_merge_idx, the partition mode merge candidate of the second prediction unit can be determined as the partition mode merge candidate having a value obtained by adding 1 to the value of the second index information 2nd_merge_idx as an index.

[0389] Optionally, the signaling of the second index information can be determined according to the number of partition mode merge candidates included in the partition mode merge candidate list. In an example, when the maximum number of partition mode merge candidates that can be included in the partition mode merge candidate list does not exceed 2, the signaling of the second index information can be omitted. When the signaling of the second index information is omitted, the second partition mode merge candidate can be derived by adding or subtracting an offset from the first index information. In an example, when the maximum number of partition mode merge candidates that can be included in the partition mode merge candidate list is 2 and the first index information indicates index 0, the second partition mode merge candidate can be derived by adding 1 to the first index information. Optionally, when the maximum number of partition mode merge candidates that can be included in the partition mode merge candidate list is 2 and the first index information indicates 1, the second partition mode merge candidate can be derived by subtracting 1 from the first index information.

[0390] Optionally, when the signaling of the second index information is omitted, the second index information can be inferred as a default value. In this case, the default value can be 0. The second partition mode merge candidate can be derived by comparing the first index information with the second index information. In an example, when the second index information is smaller than the first index information, the merge candidate with index 0 can be set as the second partition mode merge candidate, and when the second index information is the same as or larger than the first index information, the merge candidate with index 1 can be set as the second partition mode merge candidate.

[0391] When the partition mode merge candidate has uni-directional motion information, the uni-directional motion information of the partition mode merge candidate can be set as the motion information of the prediction unit. On the other hand, when the partition mode merge candidate has bi-directional motion information, only one of the L0 motion information or the L1 motion information can be set as the motion information of the prediction unit. Which one of the L0 motion information or the L1 motion information to be adopted can be determined based on the index of the partition mode merge candidate or the motion information of another prediction unit.

[0392] In an example, when the index of the partition mode merge candidate is even, the L0 motion information of the prediction unit can be set to 0 and the L1 motion information of the partition mode merge candidate can be set to the L1 motion information of the prediction unit. On the other hand, when the index of the partition mode merge candidate is odd, the L1 motion information of the prediction unit can be set to 0 and the L0 motion information of the partition mode merge candidate can be set to 0. Conversely, when the index of the partition mode merge candidate is even, the L0 motion information of the partition mode merge candidate can be set to the L0 motion information of the prediction unit and when the index of the partition mode merge candidate is odd, the L1 motion information of the partition mode merge candidate can be set to the L1 motion information of the prediction unit. Alternatively, for a first prediction unit, when the partition mode merge candidate for the first prediction unit is even, the L0 motion information of the partition mode merge candidate can be set to the L0 motion information of the first prediction unit, but for a second prediction unit, when the partition mode merge candidate for the second prediction unit is odd, the L1 motion information of the partition mode merge candidate can be set to the L1 motion information of the second prediction unit.

[0393] Alternatively, when the first prediction unit has L0 motion information, the L0 motion information of the second prediction unit can be set to 0 and the L1 motion information of the partition mode merge candidate can be set to the L1 information of the second prediction unit. On the other hand, when the first prediction unit has L1 motion information, the L1 motion information of the second prediction unit can be set to 0 and the L0 motion information of the partition mode merge candidate can be set to the L0 motion information of the second prediction unit.

[0394] The partition mode merge candidate list used to derive the motion information of the first prediction unit can be set to be different from the partition mode merge candidate list used to derive the motion information of the second prediction unit.

[0395] In an example, when the partition mode merge candidate in the partition mode merge candidate list used to derive the motion information of the first prediction unit is specified based on the index information for the first prediction unit, the motion information of the second prediction unit can be derived by using the partition mode merge list including the remaining partition mode merge candidates other than the partition mode merge candidate indicated by the index information. Specifically, the motion information of the second prediction unit can be derived from one of the remaining partition mode merge candidates.

[0396] Accordingly, the maximum number of partition mode merge candidates included in the partition mode merge candidate list of the first prediction unit can be different from the maximum number of partition mode merge candidates included in the partition mode merge candidate list of the second prediction unit. In an example, when the partition mode merge candidate list of the first prediction unit includes M merge candidates, the partition mode merge candidate list of the second prediction unit can include M-1 merge candidates in addition to the partition mode merge candidate indicated by the index information of the first prediction unit.

[0397] In another example, in addition to considering the shape or position of the prediction unit, the availability of neighboring blocks can be determined by deriving the merge candidates for each prediction unit based on neighboring blocks adjacent to the coding block.

[0398] FIG. 31 is a diagram for explaining an example of determining the availability of neighboring blocks per prediction unit.

[0399] A neighboring block that is not adjacent to the first prediction unit can be set as unavailable for the first prediction unit, and a neighboring block that is not adjacent to the second prediction unit can be set as unavailable for the second prediction unit.

[0400] In an example, as in the example shown in FIG. 31 (a), when the left triangle partition type is applied to the coding block, it can be determined that blocks Al, A0, and A2 adjacent to the first prediction unit among the neighboring blocks adjacent to the coding block are available for the first prediction unit, but it can be determined that blocks B0 and Bl are unavailable for the first prediction unit. Accordingly, the partition mode merge candidate list for the first prediction unit can include partition mode merge candidates derived from blocks Al, A0, and A2, but it can not include partition mode merge candidates derived from blocks B0 and Bl.

[0401] As in the example shown in FIG. 31 (b), when the left triangle partition type is applied to the coding block, it can be determined that blocks B0 and Bl adjacent to the second prediction unit are available for the second prediction unit, but it can be determined that blocks Al, A0, and A2 are unavailable for the second prediction unit. Accordingly, the partition mode merge candidate list for the second prediction unit can include partition mode merge candidates derived from blocks B0 and Bl, but it can not include partition mode merge candidates derived from blocks Al, A0, and A2.

[0402] Accordingly, the number of partition mode merge candidates available for a prediction unit or the range of partition mode merge candidates can be determined based on at least one of the position of the prediction unit or the partition type of the coding block.

[0403] In another example, the merge mode can be applied only to one of the first prediction unit and the second prediction unit. Also, the motion information of the other one of the first prediction unit and the second prediction unit can be set to be the same as the motion information of the prediction unit to which the merge mode is applied, or can be derived by modifying the motion information of the prediction unit to which the merge mode is applied.

[0404] In an example, the motion vector and the reference picture index of the first prediction unit can be derived based on the partition mode merge candidate, and the motion vector of the second prediction unit can be derived by modifying the motion vector of the first prediction unit. In an example, the motion vector of the second prediction unit can be derived by adding or subtracting the modification motion vector {Rx, Ry} from or to the motion vector {mvD1LXx, mvD1LXy} of the first prediction unit. The reference picture index of the second prediction unit can be set to be the same as the reference picture index of the first prediction unit.

[0405] Information for determining a modification motion vector representing a difference between the motion vector of the first prediction unit and the motion vector of the second prediction unit can be signaled in a bitstream. The information can include at least one of information representing a magnitude of the modification motion vector or information representing a sign of the modification motion vector.

[0406] Optionally, the sign of the modification motion vector can be derived based on at least one of a position or an index of the prediction unit or a partition type applied to the coding block.

[0407] In another example, the motion vector and the reference picture index of one of the first prediction unit and the second prediction unit can be signaled. The motion vector of the other one of the first prediction unit and the second prediction unit can be derived by modifying the signaled motion vector.

[0408] In an example, based on information signaled in a bitstream, the motion vector and the reference picture index of the first prediction unit can be determined. Also, the motion vector of the second prediction unit can be derived by modifying the motion vector of the first prediction unit. In an example, the motion vector of the second prediction unit can be derived by adding or subtracting the modification motion vector {Rx, Ry} from or to the motion vector {mvD1LXx, mvD1LXy} of the first prediction unit. The reference picture index of the second prediction unit can be set to be the same as the reference picture index of the first prediction unit.

[0409] In another example, the merge mode can be applied to only one of the first prediction unit and the second prediction unit. Also, the motion information of the other one of the first prediction unit and the second prediction unit can be derived based on the motion information of the prediction unit to which the merge mode is applied. In an example, a symmetric motion vector of a motion vector of the first prediction unit can be set as a motion vector of the second prediction unit. In this case, the symmetric motion vector can represent a motion vector having the same magnitude as the motion vector of the first prediction unit but having at least one opposite sign of an x-axis component or a y-axis component, or a motion vector having the same magnitude as a scaled vector obtained by scaling the motion vector of the first prediction unit but having at least one opposite sign of an x-axis component or a y-axis component. In an example, when the motion vector of the first prediction unit is (MVx, MVy), the motion vector of the second prediction unit can be set as (MVx, -MVy), (-MVx, MVy), or (-MVx, -MVy) which are symmetric motion vectors of the motion vector.

[0410] A reference picture index of the prediction unit to which the merge mode is not applied among the first prediction unit and the second prediction unit can be set as the same as a reference picture index of the prediction unit to which the merge mode is applied. Alternatively, the reference picture index of the prediction unit to which the merge mode is not applied can be set as a pre-defined value. In this case, the pre-defined value can be a minimum index or a maximum index in a reference picture list. Alternatively, information specifying the reference picture index of the prediction unit to which the merge mode is not applied can be signaled in a bitstream. Alternatively, the reference picture of the prediction unit to which the merge mode is not applied can be selected from a different reference picture list from a reference picture list to which the reference picture of the prediction unit to which the merge mode is applied belongs. In an example, when the reference picture of the prediction unit to which the merge mode is applied is selected from an L0 reference picture list, the reference picture of the prediction unit to which the merge mode is not applied can be selected from an L1 reference picture list. In this case, the reference picture of the prediction unit to which the merge mode is not applied can be derived based on a picture order count (POC) difference between the reference picture of the prediction unit to which the merge mode is applied and a current picture. In an example, when the reference picture of the prediction unit to which the merge mode is applied is selected from an L0 reference picture list, a reference picture having the same or similar difference value from a current picture in an L1 reference picture list and a difference value between the reference picture of the prediction unit to which the merge mode is applied and the current picture can be selected as the reference picture of the prediction unit to which the merge mode is not applied.

[0411] When the picture order count difference between the reference picture of the first prediction unit and the current picture is different from the picture order count difference between the reference picture of the second prediction unit and the current picture, the symmetrical motion vector of the scaled motion vector of the prediction unit to which the merge mode is applied can be set to the motion vector of the prediction unit to which the merge mode is not applied. In this case, scaling can be performed based on the picture order count difference between each reference picture and the current picture.

[0412] In another example, after deriving the motion vector of each of the first prediction unit and the second prediction unit, a correction vector can be added to or subtracted from the derived motion vector. In an example, the motion vector of the first prediction unit can be derived by adding or subtracting a first correction vector to or from the first motion vector derived based on the first merge candidate, and the motion vector of the second prediction unit can be derived by adding or subtracting a second correction vector to or from the second motion vector derived based on the second merge candidate. Information for determining at least one of the first correction vector or the second correction vector can be signaled in a bitstream. The information can include at least one of information for determining a size of the correction vector or information for determining a sign of the correction vector.

[0413] The second correction vector can be a symmetrical motion vector of the first correction vector. In this case, information for determining the correction vector can be signaled only for one of the first correction vector and the second correction vector. In an example, when the first correction vector is determined as (MVDx, MVDy) through the information signaled in the bitstream, (-MVDx, MVDy), (MVDx, -MVDy), or (-MVDx, -MVDy) that is a symmetrical motion vector of the first correction vector can be set as the second correction vector. A symmetrical motion vector of a scaled motion vector obtained by scaling the first correction vector can be set as the second correction vector according to the picture order count of the reference picture of each prediction unit.

[0414] In another example, information of one of the first and second prediction units can be derived based on the merge candidate, and motion information of the other can be determined based on information signaled in the bitstream. In an example, a merge index can be signaled for the first prediction unit, and at least one of information for determining a motion vector and information for determining a reference picture can be signaled for the second prediction unit. The motion information of the first prediction unit can be set to be the same as the motion information of the merge candidate specified by the merge index. The motion information of the second prediction unit can be specified by at least one of the information for determining a motion vector and the information for determining a reference picture signaled in the bitstream.

[0415] Motion prediction and compensation prediction for each coding block can be performed based on the motion information of the first prediction unit and the motion information of the second prediction unit. In this case, quality degradation can be generated on a boundary of the first prediction unit and the second prediction unit. In an example, quality continuity can be deteriorated around an edge on the boundary of the first prediction unit and the second prediction unit. To reduce the quality degradation on the boundary, a prediction sample can be derived through a smoothing filter or weighted prediction.

[0416] A prediction sample in a coding block to which a diagonal partition is applied can be derived based on a weighted sum operation of a first prediction sample obtained according to the motion information of the first prediction unit and a second prediction sample obtained according to the motion information of the second prediction unit. Alternatively, a prediction sample of the first prediction unit can be derived from a first prediction block determined based on the motion information of the first prediction unit, and a prediction sample of the second prediction unit can be derived from a second prediction block determined based on the motion information of the second prediction unit, but a prediction sample on a boundary region of the first prediction unit and the second prediction unit can be derived based on a weighted sum operation of a first prediction sample included in the first prediction block and a second prediction sample included in the second prediction block. In an example, Equation 3 below represents an example of deriving the prediction samples of the first prediction unit and the second prediction unit.

[0417]

Equation 3

[0418] P(x, y) = w1 * P1(x, y) + (1 - w1) * P2(x, y)

[0419] In Equation 3, P1 denotes a first prediction sample, and P2 denotes a second prediction sample. w1 denotes a weight applied to the first prediction sample, and (1 - w1) denotes a weight applied to the second prediction sample. As in the example shown in Equation 3, the weight applied to the second prediction sample can be derived by subtracting the weight applied to the first prediction sample from a constant value.

[0420] When the left triangle partition type is applied to the coding block, the boundary region can include prediction samples having the same x-axis coordinate and y-axis coordinate. On the other hand, when the right triangle partition type is applied to the coding block, the boundary region can include prediction samples having a sum of the x-axis coordinate and the y-axis coordinate equal to or greater than a first threshold value and equal to or smaller than a second threshold value.

[0421] The size of the boundary region can be determined based on at least one of a size of the coding block, a shape of the coding block, motion information of the prediction unit, a motion vector difference value of the prediction unit, a picture order count of a reference picture, or a difference value between the first prediction sample and the second prediction sample on a diagonal boundary.

[0422] FIG. 32 and FIG. 33 is a diagram illustrating an example of deriving a prediction sample based on a weighted sum operation of a first prediction sample and a second prediction sample. FIG. 32 illustrates a case where the left triangle partition type is applied to the coding block, and FIG. 33 illustrates a case where the right triangle partition type is applied to the coding block. Further, FIG. 32 (a) and FIG. 33 (a) is a diagram representing a prediction aspect for a luma component, and FIG. 32 (b) and FIG. 33 (b) is a diagram representing a prediction aspect for a chroma component.

[0423] In the illustrated diagrams, the numbers marked on the prediction samples around the boundary of the first prediction unit and the second prediction unit represent a weight applied to the first prediction sample. In an example, when the number marked on the prediction sample is N, the prediction sample can be derived by applying a weight N / 8 to the first prediction sample and a weight (1-(N / 8)) to the second prediction sample.

[0424] In the non-boundary region, the first prediction sample or the second prediction sample can be determined as the prediction sample. Looking at FIG. 32 in the example, the first prediction sample derived based on the motion information of the first prediction unit can be determined as the prediction sample in the region belonging to the first prediction unit. On the other hand, the second prediction sample derived based on the motion information of the second prediction unit can be determined as the prediction sample in the region belonging to the second prediction unit.

[0425] Looking at FIG. 32 in the example, the first prediction sample derived based on the motion information of the first prediction unit can be determined as the prediction sample in the region having a sum of the x-axis coordinate and the y-axis coordinate smaller than a first threshold value. On the other hand, the second prediction sample derived based on the motion information of the second prediction unit can be determined as the prediction sample in the region having a sum of the x-axis coordinate and the y-axis coordinate greater than a second threshold value.

[0426] The threshold for determining the non-boundary region can be determined based on at least one of a size of the coding block, a shape of the coding block, or a color component. In an example, when the threshold for the luma component is set to N, the threshold for the chroma component can be set to N / 2.

[0427] The prediction samples included in the boundary region can be derived based on a weighted sum operation of the first prediction sample and the second prediction sample. In this case, the weight applied to the first prediction sample and the second prediction sample can be determined based on at least one of a position of the prediction sample, a size of the coding block, a shape of the coding block, or a color component.

[0428] In an example, as FIG. 33 In the example shown in (a), the prediction sample having the same x-axis coordinate and y-axis coordinate can be derived by applying the same weight to the first prediction sample and the second prediction sample. The prediction sample having an absolute value of 1 of a difference between the x-axis coordinate and the y-axis coordinate can be derived by setting a weight ratio applied to the first prediction sample and the second prediction sample to (3:1) or (1:3). Further, the prediction sample having an absolute value of 2 of a difference between the x-axis coordinate and the y-axis coordinate can be derived by setting a weight ratio applied to the first prediction sample and the second prediction sample to (7:1) or (1:7).

[0429] Alternatively, as FIG. 33 In the example shown in (b), the prediction sample having the same x-axis coordinate and y-axis coordinate can be derived by applying the same weight to the first prediction sample and the second prediction sample, and the prediction sample having an absolute value of 1 of a difference between the x-axis coordinate and the y-axis coordinate can be derived by setting a weight ratio applied to the first prediction sample and the second prediction sample to (7:1) or (1:7).

[0430] In an example, as FIG. 34 In the example shown in (a), the prediction sample having a sum of the x-axis coordinate and the y-axis coordinate which is less than 1 of a width or a height of the coding block can be derived by applying the same weight to the first prediction sample and the second prediction sample. The prediction sample having a sum of the x-axis coordinate and the y-axis coordinate which is the same as or less than 2 of the width or the height of the coding block can be derived by setting a weight ratio applied to the first prediction sample and the second prediction sample to (3:1) or (1:3). The prediction sample having a sum of the x-axis coordinate and the y-axis coordinate which is greater than 1 or less than 3 of the width or the height of the coding block can be derived by setting a weight ratio applied to the first prediction sample and the second prediction sample to (7:1) or (1:7).

[0431] Alternatively, as FIG. 34In the example shown in (b), a prediction sample whose sum of x-axis coordinate and y-axis coordinate is smaller than the width or height of the coding block by 1 can be derived by applying the same weight to the first prediction sample and the second prediction sample. A prediction sample whose sum of x-axis coordinate and y-axis coordinate is the same as or smaller than the width or height of the coding block by 2 can be derived by setting the weight ratio applied to the first prediction sample and the second prediction sample to (7:1) or (1:7).

[0432] In another example, the weight can be determined by considering the position of the prediction sample or the shape of the coding block. Equations 4 to 6 represent examples of deriving the weight when the left triangle partition type is applied to the coding block. Equation 4 represents an example of deriving the weight applied to the first prediction sample when the coding block is square.

[0433] [Equation 4]

[0434] w1 = (x - y + 4) / 8

[0435] In Equation 4, x and y represent the position of the prediction sample. When the coding block is not square, the weight applied to the first prediction sample can be derived as in Equation 5 or Equation 6 below. Equation 5 represents the case where the width of the coding block is greater than the height, and Equation 6 represents the case where the width of the coding block is smaller than the height.

[0436] [Equation 5]

[0437] w1 = ((x / whRatio) - y + 4) / 8

[0438] [Equation 6]

[0439] w1 = (x - (y * whRatio) + 4) / 8

[0440] When the right triangle partition type is applied to the coding block, the weight applied to the first prediction sample can be determined as in Equations 7 to 9. Equation 7 represents an example of deriving the weight applied to the first prediction sample when the coding block is square.

[0441] [Equation 7]

[0442] w1 = ((CbW - 1 - x) - y) + 4) / 8

[0443] In Equation 7, CbW represents the width of the coding block. When the coding block is not square, the weight applied to the first prediction sample can be derived as in Equation 8 or Equation 9 below. Equation 8 represents the case where the width of the coding block is greater than the height, and Equation 9 represents the case where the width of the coding block is smaller than the height.

[0444] [Equation 8]

[0445] w1 = (CbH - 1 - (x / whRatio) - y) + 4) / 8

[0446]

Equation 9

[0447] w1 = (CbW - 1 - x - (y*whRatio) + 4) / 8

[0448] In Equation 8, CbH denotes a height of the coding block.

[0449] As in the illustrated example, the prediction samples included in the first prediction unit among the prediction samples in the boundary region can be derived by assigning a greater weight to the first prediction samples than to the second prediction samples, and the prediction samples included in the second prediction unit among the prediction samples in the boundary region can be derived by assigning a greater weight to the second prediction samples than to the first prediction samples.

[0450] When the diagonal partition is applied to the coding block, a combined prediction mode of combining the intra prediction mode and the merge mode can be set not to be applied to the coding block.

[0451] When the encoding / decoding of the coding block is completed, the motion information of the coding block for which the encoding / decoding is completed can be stored for the encoding / decoding of a subsequent coding block. The motion information can be stored in units of sub-blocks having a preset size. In an example, the sub-blocks having the preset size can have a 4x4 size. Alternatively, according to the size or shape of the coding block, the size or shape of the sub-blocks can be differently determined.

[0452] When the sub-block belongs to the first prediction unit, the motion information of the first prediction unit can be stored as the motion information of the sub-block. On the other hand, when the sub-block belongs to the second prediction unit, the motion information of the second prediction unit can be stored as the motion information of the sub-block.

[0453] When the sub-block is on a boundary of the first prediction unit and the second prediction unit, any one of the motion information of the first prediction unit and the motion information of the second prediction unit can be set as the motion information of the sub-block. In an example, the motion information of the first prediction unit can be set as the motion information of the sub-block, or the motion information of the second prediction unit can be set as the motion information of the sub-block.

[0454] In another example, when a sub-block is on a boundary of the first prediction unit and the second prediction unit, any one of the L0 motion information and the L1 motion information of the sub-block can be derived from the first prediction unit, and the other one of the L0 motion information and the L1 motion information of the sub-block can be derived from the second prediction unit. In an example, the L0 motion information of the first prediction unit can be set as the L0 motion information of the sub-block, and the L1 motion information of the second prediction unit can be set as the L1 motion information of the sub-block. However, when the first prediction unit and the second prediction unit have only L0 motion information or only L1 motion information, the motion information of the sub-block can be determined by selecting any one of the first prediction unit or the second prediction unit. Alternatively, an average of the motion vectors of the first prediction unit and the second prediction unit can be set as the motion vector of the sub-block.

[0455] The motion information of the coded block for which the encoding / decoding is completed can be updated in the motion information table. In this case, the motion information of the coded block to which the prediction unit partitioning is applied can be set not to be added to the motion information table.

[0456] Alternatively, only the motion information of any one of the plurality of prediction units generated by partitioning the coded block can be added to the motion information table. In an example, although the motion information of the first prediction unit can be added to the motion information table, the motion information of the second prediction unit can not be added to the motion information table. In this case, the prediction unit to be added to the motion information table can be selected based on at least one of a size of the coded block, a shape of the coded block, a size of the prediction unit, a shape of the prediction unit, or whether bi-prediction is performed for the prediction unit.

[0457] Alternatively, the motion information of each of the plurality of prediction units generated by partitioning the coded block can be added to the motion information table. In this case, an addition order for the motion information table can be predefined in the encoding apparatus and the decoding apparatus. In an example, the motion information of a prediction unit including an upper left sample or a lower left corner sample can be added to the motion information table before the motion information of another prediction unit. Alternatively, the addition order for the motion information table can be determined based on at least one of a merge index or a reference picture index of each prediction unit or a size of a motion vector.

[0458] Alternatively, motion information combining the motion information of the first prediction unit and the motion information of the second prediction unit can be added to the motion information table. Any one of the L0 motion information and the L1 motion information of the combined motion information can be derived from the first prediction unit, and the other one of the L0 motion information and the L1 motion information can be derived from the second prediction unit.

[0459] Optionally, the motion information to be added to the motion information table can be determined based on whether the reference picture of the first prediction unit is the same as the reference picture of the second prediction unit. In an example, when the reference picture of the first prediction unit is different from the reference picture of the second prediction unit, the motion information of either the first prediction unit or the second prediction unit or the motion information combining the first prediction unit and the second prediction unit can be added to the motion information table. On the other hand, when the reference picture of the first prediction unit is the same as the reference picture of the second prediction unit, the average of the motion vector of the first prediction unit and the motion vector of the second prediction unit can be added to the motion information table.

[0460] Optionally, the motion vector to be added to the motion information table can be determined based on the size of the coding block, the shape of the coding block, or the partition shape of the coding block. In an example, when the right triangle partition is applied to the coding block, the motion information of the first prediction unit can be added to the motion information table. On the other hand, when the left triangle partition is applied to the coding block, the motion information of the second prediction unit can be added to the motion information table or the motion information combining the motion information of the first prediction unit and the motion information of the second prediction unit can be added to the motion information table.

[0461] The motion information table for storing the motion information of the coding block to which the prediction unit partition is applied can be defined separately. In an example, the motion information of the coding block to which the prediction unit partition is applied can be stored in a partition mode motion information table. The partition mode motion information table can be referred to as a triangle motion information table. In other words, the motion information of the coding block to which the prediction unit partition is not applied can be stored in a general motion information table and the motion information of the coding block to which the prediction unit partition is applied can be stored in the partition mode motion information table. The embodiment of adding the motion information of the coding block to which the prediction unit partition is applied to the motion information table can be applied to update the partition mode motion information table. In an example, the motion information of the first prediction unit, the motion information of the second prediction unit, the motion information combining the motion information of the first prediction unit and the motion information of the second prediction unit, and the motion information averaging the motion vector of the first prediction unit and the motion vector of the second prediction unit can be added to the partition mode motion information table.

[0462] When the prediction mode partition is not applied to the coding block, the merge candidate can be derived by using the general motion information table. On the other hand, when the prediction mode partition is applied to the coding block, the merge candidate can be derived by using the prediction mode motion information table.

[0463] When a merge candidate of the current block is selected, a motion vector of the selected merge candidate can be set as an initial motion vector, and motion-compensated prediction for the current block can be performed by using a motion vector derived by adding or subtracting an offset vector to or from the initial motion vector. A method of deriving a new motion vector by adding or subtracting an offset vector to or from a motion vector of a merge candidate can be defined as a merge offset vector coding method.

[0464] Information indicating whether the merge offset vector coding method is to be used can be signaled in a bitstream. The information can be a 1-bit flag, merge_offset_vector_flag. In an example, when a value of the merge_offset_vector_flag is 1, this indicates that the merge offset vector coding method is applied to the current block. When the merge offset vector coding method is applied to the current block, a motion vector of the current block can be derived by adding or subtracting an offset vector to or from a motion vector of a merge candidate. When the value of the merge_offset_vector_flag is 0, this indicates that the merge offset vector coding method is not applied to the current block. When the merge offset coding method is not applied, a motion vector of the merge candidate can be set as a motion vector of the current block.

[0465] The flag can be signaled only when a value of a skip flag indicating whether a skip mode is applied is true or when a value of a merge flag indicating whether a merge mode is applied is true. In an example, when the value of the skip_flag indicating that the skip mode is applied to the current block is 1 or when the value of the merge_flag indicating that the merge mode is applied to the current block is 1, the merge_offset_vector_flag can be coded and signaled.

[0466] When it is determined that the merge offset coding method is applied to the current block, at least one of information specifying any one of merge candidates included in a merge candidate list, information indicating a size of an offset vector, or information indicating a direction of the offset vector can be additionally signaled.

[0467] Information for determining a maximum number of merge candidates that can be included in the merge candidate list can be signaled in a bitstream. In an example, the maximum number of merge candidates that can be included in the merge candidate list can be set as a natural number equal to or smaller than 6.

[0468] When it is determined that the merge offset vector coding method is applied to the current block, only a preset maximum number of merge candidates can be set as the initial motion vector of the current block. In other words, depending on whether the merge offset vector coding method is applied, the number of merge candidates available for the current block can be adaptively determined. In an example, when the value of the merge_offset_vector_flag is set to 0, the maximum number of merge candidates available for the current block can be set to M, but when the value of the merge_offset_vector_flag is set to 1, the maximum number of merge candidates available for the current block can be set to N. In this case, M denotes the maximum number of merge candidates that can be included in the merge candidate list, and N denotes a natural number equal to or smaller than M.

[0469] In an example, when M is 6 and N is 2, two merge candidates having the smallest index among the merge candidates included in the merge candidate list can be set as available for the current block. Accordingly, the motion vector of the merge candidate having an index value of 0 or the motion vector of the merge candidate having an index value of 1 can be set as the initial motion vector of the current block. When M and N are the same (for example, when M and N are 2), all of the merge candidates included in the merge candidate list can be set as available for the current block.

[0470] Alternatively, whether a neighboring block is available as a merge candidate can be determined based on whether the merge offset vector coding method is applied to the current block. In an example, when the value of the merge_offset_vector_flag is 1, at least one of a neighboring block adjacent to the upper right corner of the current block, a neighboring block adjacent to the lower left corner, or a neighboring block adjacent to the lower left corner of the current block can be set as unavailable as a merge candidate. Accordingly, when the merge offset vector coding method is applied to the current block, the motion vector of at least one of the neighboring block adjacent to the upper right corner of the current block, the neighboring block adjacent to the lower left corner, or the neighboring block adjacent to the lower left corner of the current block can not be set as the initial motion vector. Alternatively, when the value of the merge_offset_vector_flag is 1, a temporal neighboring block of the current block can be set as unavailable as a merge candidate.

[0471] When the merge offset vector coding method is applied to the current block, at least one of a pair-wise merge candidate or a zero merge candidate can be set not to be used. Accordingly, when the value of the merge_offset_vector_flag is 1, although the number of merge candidates included in the merge candidate list is smaller than the maximum number, at least one of the pair-wise merge candidate or the zero merge candidate can not be added to the merge candidate list.

[0472] The motion vector of the merge candidate can be set as the initial motion vector of the current block. In this case, when the number of the merge candidates available for the current block is plural, information designating any one of the plural merge candidates can be signaled in a bitstream. In an example, when the maximum number of the merge candidates includable in the merge candidate list is not greater than 1, the operation of signaling the information indicating one of the plural merge candidates merge_idx can be omitted. In other words, in the merge offset coding method, when one merge candidate is included in the merge candidate list, the encoding of the information indicating the merge candidate merge_idx can be omitted, and the initial motion vector can be determined based on the merge candidate included in the merge candidate list. The motion vector of the merge candidate can be set as the initial motion vector of the current block.

[0473] On the other hand, when the number of the merge candidates available for the current block is one, the signaling of the information indicating the merge candidate can be omitted. In an example, when the maximum number of the merge candidates includable in the merge candidate list is not greater than 1, the operation of signaling the information indicating the merge candidate merge_idx can be omitted. In other words, in the merge offset coding method, when one merge candidate is included in the merge candidate list, the encoding of the information indicating the merge candidate merge_idx can be omitted, and the initial motion vector can be determined based on the merge candidate included in the merge candidate list. The motion vector of the merge candidate can be set as the initial motion vector of the current block.

[0474] In another example, after determining the merge candidates of the current block, it can be determined whether the merge offset vector coding method is to be applied to the current block. In an example, when the maximum number of the merge candidates includable in the merge candidates is greater than 1, the information indicating one of the plural merge candidates merge_idx can be signaled. After selecting the merge candidate based on the merge_idx, the merge_offset_vector_flag indicating whether the merge offset vector coding method is applied to the current block can be decoded. Table 3 is a diagram representing a syntax table according to the above-described embodiment.

[0475]

Table 5

[0476]

[0477]

[0478] In another example, after determining the merge candidates of the current block, it can be determined whether the merge offset vector coding method will be applied to the current block only when the index of the determined merge candidate is smaller than the maximum number of the merge candidates available under the merge offset vector coding method. In an example, the merge_offset_vector_flag indicating whether the merge offset vector coding method will be applied to the current block can be coded and signaled only when the value of the index information merge_idx is smaller than N. When the value of the index information merge_idx is equal to or larger than N, the coding of the merge_offset_vector_flag can be omitted. When the coding of the merge_offset_vector_flag is omitted, the merge offset vector coding method can be set to not be applied to the current block. Alternatively, after determining the merge candidates of the current block, it can be determined whether the merge offset vector coding method will be applied to the current block by considering whether the determined merge candidate has bi-directional motion information or uni-directional motion information. In an example, the merge_offset_vector_flag indicating whether the merge offset vector coding method will be applied to the current block can be coded and signaled only when the value of the index information merge_idx is smaller than N and the merge candidate selected by the index information has bi-directional motion information. Alternatively, the merge_offset_vector_flag indicating whether the merge offset vector coding method will be applied to the current block can be coded and signaled only when the value of the index information merge_idx is smaller than N and the merge candidate selected by the index information has uni-directional motion information.

[0479] Alternatively, it can be determined whether the merge offset vector coding method will be applied based on at least one of the size or shape of the current block or whether the current block is adjacent to the boundary of the coding tree unit. When at least one of the size or shape of the current block or whether the current block is adjacent to the boundary of the coding tree unit does not satisfy a pre-set condition, the coding of the merge_offset_vector_flag indicating whether the merge offset vector coding method will be applied to the current block can be omitted.

[0480] When a merge candidate is selected, the motion vector of the merge candidate can be set as the initial motion vector of the current block. Also, the offset vector can be determined by decoding information indicating the size of the offset vector and information indicating the direction of the offset vector. The offset vector can have a horizontal direction component or a vertical direction component.

[0481] The information representing the size of the offset vector can be index information representing one of the vector size candidates. In an example, index information distance_idx representing one of the vector size candidates can be signaled in a bitstream. Table 4 represents binarization of the index information distance_idx and a value of a variable DistFromMergeMV used to determine the size of the offset vector from the distance_idx.

[0482] [Table 6]

[0483]

[0484]

[0485] The size of the offset vector can be derived by dividing the variable DistFromMergeMV by a preset value. Equation 10 represents an example of determining the size of the offset vector.

[0486] [Equation 10]

[0487] abs(offsetMV) = DistFromMergeMV « 2

[0488] According to Equation 10, a value obtained by dividing the variable DistFromMergeMV by 4 or a value obtained by left bit-shifting the variable DistFromMergeMV by 2 can be set as the size of the offset vector.

[0489] More vector size candidates than the example shown in Table 6 or fewer vector size candidates can be used, or a range of the motion vector offset size candidates can be set to be different from the example shown in Table 6. In an example, the size of the horizontal direction component or the vertical direction component of the offset vector can be set to be not greater than the sample distance 2. Table 7 represents binarization of the index information distance_idx and a value of a variable DistFromMergeMV used to determine the size of the offset vector from the distance_idx.

[0490] [Table 7]

[0491]

[0492] Alternatively, based on the motion vector precision, the range of the motion vector offset size candidate can be set differently. In an example, when the motion vector precision for the current block is fractional pixel, the value of the variable DistFromMergeMV corresponding to the value of the index information distance_idx can be set to 1, 2, 4, 8, 16, etc. In this case, the fractional pixel includes at least one of 1 / 16 pixel, one-eighth pixel, one-quarter pixel, or one-half pixel. On the other hand, when the motion vector precision for the current block is integer pixel, the value of the variable DistFromMergeMV corresponding to the value of the index information distance_idx can be set to 4, 8, 16, 32, 64, etc. In other words, according to the motion vector precision for the current block, the table referred to determine the variable DistFromMergeMV can be set differently. In an example, when the motion vector precision of the current block or the merge candidate is one-quarter pixel, the variable DistFromMergeMV indicated by distance_idx can be derived by using Table 6. On the other hand, when the motion vector precision of the current block or the merge candidate is integer pixel, the value obtained by multiplying the value of the variable DistFromMergeMV indicated by distance_idx in Table 6 by N times (e.g., 4 times) can be derived as the value of DistFromMergeMV.

[0493] The information for determining the motion vector precision can be signaled in a bitstream. In an example, the information can be signaled at a sequence level, a picture level, a slice level, or a block level. Accordingly, the range of the vector size candidate can be set differently by the information related to the motion vector precision signaled in a bitstream. Alternatively, based on the merge candidate of the current block, the motion vector precision can be determined. In an example, the motion vector precision of the current block can be set to be the same as the motion vector precision of the merge candidate.

[0494] Alternatively, the information for determining the search range of the offset vector can be signaled in a bitstream. Based on the search range, at least one of the number of the vector size candidate, the minimum value, or the maximum number of the vector size candidate can be determined. In an example, a flag merge_offset_vector_flag for determining the search range of the offset vector can be signaled in a bitstream. The information can be signaled in a sequence header, a picture header, or a slice header.

[0495] In an example, when the value of merge_offset_extend_range_flag is 0, the size of the offset vector can be set to not more than 2. Thus, the maximum value of DiffFromMergeMV can be set to 8. On the other hand, when the value of merge_offset_extend_range_flag is 1, the size of the offset vector can be set to not more than the sample distance 32. Thus, the maximum value of DiffFromMergeMV can be set to 128.

[0496] The size of the offset vector can be determined by using a flag indicating whether the size of the offset vector is greater than a threshold value. In an example, a flag distance_flag indicating whether the size of the offset vector is greater than a threshold value can be signaled in the bitstream. The threshold value can be 1, 2, 4, 8, or 16. In an example, when distance_flag is 1, it indicates that the size of the offset vector is greater than 4. On the other hand, when distance_flag is 0, it indicates that the size of the offset vector is equal to or less than 4.

[0497] When the size of the offset vector is greater than the threshold value, the difference between the size of the offset vector and the threshold value can be derived by using index information distance_idx. Alternatively, when the size of the offset vector is equal to or less than the threshold value, the size of the offset vector can be determined by using index information distance_idx. Table 8 is a syntax table indicating the coding aspects of distance_flag and distance_idx.

[0498] [Table 8]

[0499]

[0500]

[0501] Equation 11 indicates an example of deriving a variable DistFromMergeMV for determining the size of the offset vector by using distance_flag and distance_idx.

[0502] [Equation 11]

[0503] DistFromMergeMV = N * distance_flag + (1 « distance_idx)

[0504] In Equation 11, the value of distance_flag can be set to 1 or 0. The value of distance_idx can be set to 1, 2, 4, 8, 16, 32, 64, 128, etc. N denotes a coefficient determined by a threshold value. In an example, when the threshold value is 4, N can be set to 16.

[0505] The information indicating the direction of the offset vector can be index information indicating one of the vector direction candidates. In an example, the index information indicating one of the vector direction candidates, direction_idx, can be signaled in a bitstream. Table 9 indicates the index information direction_idx and binarization of the direction of the offset vector according to direction_idx.

[0506]

Table 9

[0507]

[0508] In Table 9, sign[0] indicates the horizontal direction and sign[1] indicates the vertical direction. +1 indicates that the value of the x component or the y component of the offset vector is positive, and -1 indicates that the value of the x component or the y component of the offset vector is negative. Equation 12 indicates an example of determining the offset vector based on the size and the direction of the offset vector.

[0509]

Equation 12

[0510] offsetMV[0] = abs(offsetMV) * sign[0]

[0511] offsetMV[1] = abs(offsetMV) * sign[1]

[0512] In Equation 12, offsetMV[0] indicates the vertical direction component of the offset vector, and offsetMV[1] indicates the horizontal direction component of the offset vector.

[0513] FIG. 35 is a diagram showing the offset vector according to the value of distance_idx showing the size of the offset vector and direction_idx showing the direction of the offset vector.

[0514] As FIG. 35In the example shown in FIG. 13, the size and direction of the offset vector can be determined according to the values of distance_idx and direction_idx. The maximum size of the offset vector can be set not to exceed a threshold. In this case, the threshold can have a predefined value in the encoding apparatus and the decoding apparatus. In an example, the threshold can be a sample distance of 32. Alternatively, the threshold can be determined according to the size of the initial motion vector. In an example, the threshold for the horizontal direction can be set based on the size of the horizontal component of the initial motion vector, and the threshold for the vertical direction can be set based on the size of the vertical component of the initial motion vector.

[0515] When the merge candidate has bi-directional motion information, the L0 motion vector of the merge candidate can be set to the L0 initial motion vector of the current block, and the L1 motion vector of the merge candidate can be set to the L1 initial motion vector of the current block. In this case, the L0 offset vector and the L1 offset vector can be determined by considering a picture order count difference between the L0 reference picture of the merge candidate and the current picture (hereinafter, referred to as L0 difference) and a picture order count difference between the L1 reference picture of the merge candidate and the current picture (hereinafter, referred to as L1 difference).

[0516] First, when the sign of the L0 difference is the same as the sign of the L1 difference, the L0 offset vector and the L1 offset vector can be set to be the same. On the other hand, when the sign of the L0 difference is different from the sign of the L1 difference, the L1 offset vector can be set in a direction opposite to the L0 offset vector.

[0517] The size of the L0 offset vector can be set to be the same as the size of the L1 offset vector. Alternatively, the size of the L1 offset vector can be determined by scaling the L0 offset vector based on the L0 difference and the L1 difference.

[0518] In an example, Equation 13 represents the L0 offset vector and the L1 offset vector when the sign of the L0 difference and the sign of the L1 difference are the same.

[0519] [Equation 13]

[0520] offsetMVL0[0] = abs(offsetMV) * sign[0]

[0521] offsetMVL0[1] = abs(offsetMV) * sign[1]

[0522] offsetMVL1[0] = abs(offsetMV) * sign[0]

[0523] offsetMVL1[1] = abs(offsetMV) * sign[1]

[0524] In Equation 13, offsetMVL0[0] represents a horizontal direction component of the L0 offset vector, and offsetMVL0[l] represents a vertical direction component of the L0 offset vector. offsetMVLl[0] represents a horizontal direction component of the Ll offset vector, and offsetMVLl[l] represents a vertical direction component of the Ll offset vector.

[0525] Equation 14 represents the L0 offset vector and the Ll offset vector when the sign of the L0 difference value and the sign of the Ll difference value are different.

[0526] [Equation 14]

[0527] offsetMVL0[0] = abs(offsetMV) * sign[0]

[0528] offsetMVL0[l] = abs(offsetMV) * sign[l]

[0529] offsetMVLl[0] = -1 * abs(offsetMV) * sign[0]

[0530] offsetMVLl[l] = -1 * abs(offsetMV) * sign[l]

[0531] Four or more vector direction candidates can be defined. Table 10 and Table 11 represent an example in which 8 vector direction candidates are defined.

[0532] [Table 10]

[0533]

[0534]

[0535] [Table 11]

[0536]

[0537] In Table 10 and Table 11, when the absolute values of sign[0] and sign[l] are greater than 0, this indicates that the offset vector has a diagonal direction. While the sizes of the x-axis and y-axis components of the offset vector in the diagonal direction can be set to abs(offsetMV) when Table 9 is used, the sizes of the x-axis and y-axis components of the offset vector in the diagonal direction can be set to abs(offsetMV / 2) when Table 10 is used.

[0538] FIG. 35is a diagram showing an offset vector according to values of distance_idx showing a size of the offset vector and direction_idx showing a direction of the offset vector.

[0539] ​ (a) is an example of the case where Table 9 is applied, and ​ (b) is an example of the case where Table 10 is applied.

[0540] Information for determining at least one of a number or a size of vector direction candidates can be signaled in a bitstream. In an example, a flag merge_offset_direction_range_flag for determining vector direction candidates can be signaled in a bitstream. The flag can be signaled at a sequence level, a picture level, or a slice level. In an example, when a value of the flag is 0, four vector direction candidates shown in Table 9 can be used. On the other hand, when the value of the flag is 1, eight vector direction candidates shown in Table 10 or Table 11 can be used.

[0541] Optionally, based on a size of the offset vector, at least one of a number or a size of vector direction candidates can be determined. In an example, when a value of a variable DistFromMergeMV for determining the size of the offset vector is equal to or less than a threshold value, eight vector direction candidates shown in Table 10 or Table 11 can be used. On the other hand, when the value of the variable DistFromMergeMV is greater than the threshold value, four vector direction candidates shown in Table 9 can be used.

[0542] Optionally, based on an x component value MVx of the initial motion vector and a y component value MVy of the initial motion vector, at least one of a number or a size of vector direction candidates can be determined. In an example, when a difference or an absolute value of the difference between MVx and MVy is equal to or less than a threshold value, eight vector direction candidates shown in Table 10 or Table 11 can be used. On the other hand, when the difference or the absolute value of the difference between MVx and MVy is greater than the threshold value, four vector direction candidates shown in Table 9 can be used.

[0543] A motion vector of the current block can be derived by adding the offset vector to the initial motion vector. Equation 15 represents an example of determining the motion vector of the current block.

[0544] [Equation 15]

[0545] mvL0[0] = mergeMVL0[0] + offsetMVL0[0]

[0546] mvL0[1] = mergeMVL0[1] + offsetMVL0[1]

[0547] mvL1[0] = mergeMVL1[0] + offsetMVL1[0]

[0548] mvL1[1] = mergeMVL1[1] + offsetMVL1[1]

[0549] In Equation 15, mvL0 denotes an L0 motion vector of the current block, and mvL1 denotes an L1 motion vector of the current block. mergeMVL0 denotes an L0 initial motion vector of the current block (i.e., an L0 motion vector of a merge candidate), and mergeMVL1 denotes an L1 initial motion vector of the current block. [0] denotes a horizontal direction component of a motion vector, and [1] denotes a vertical direction component of a motion vector.

[0550] An affine seed vector or a motion vector of a sub-block (sub-block motion vector or affine sub-block vector) derived based on an affine merge mode or an affine motion vector prediction mode can be updated based on an offset vector. Specifically, the updated affine seed vector or the updated sub-block motion vector can be derived by adding or subtracting the offset from the affine seed vector or the motion vector of the sub-block. When the affine seed vector or the motion vector of the sub-block is modified in the affine motion model, this can be referred to as an affine merge offset coding method.

[0551] When the affine motion model is applied to the coding block and a value of a flag merge_offset_vector_flag indicating whether the merge offset coding method is used is 1, the affine merge offset coding method can be applied to the coding block.

[0552] When it is determined that the affine merge offset coding method is applied, a merge index (merge_idx) for determining an initial motion vector of the current block, index information distance_idx for determining a size of the offset vector, and index information direction_idx for determining a direction of the offset vector can be signaled. The index information distance_idx for determining the size indicates one size candidate among a plurality of size candidates, and the index information direction_idx for determining the direction indicates one direction candidate among a plurality of direction candidates. Based on the index information distance_idx for determining the size and the index information direction_idx for determining the direction, the offset vector (offsetAffine[0], offsetAffine[1]) can be determined.

[0553] The updated affine seed vectors can be derived by adding or subtracting the offset vectors from the affine seed vectors. In this case, the sign of the offset vector applied to each affine seed vector can be determined according to the temporal direction of the reference pictures. In an example, when bi-prediction is applied to the coding block and the temporal direction of the L0 reference picture is the same as the temporal direction of the Ll reference picture, the offset vector can be added to each affine seed vector as in Equation 16 below. In this case, the temporal direction can be determined based on the picture order count (POC) difference between the current picture and the reference pictures. In an example, when both the picture order count (POC) difference between the current picture and the L0 reference picture and the picture order count (POC) difference between the current picture and the Ll reference picture are negative, or when both the picture order count (POC) difference between the current picture and the L0 reference picture and the picture order count (POC) difference between the current picture and the Ll reference picture are positive, the temporal direction of the L0 reference picture can be determined to be the same as the temporal direction of the Ll reference picture.

[0554] [Equation 16]

[0555] CpMV[0].mvL0[0] = CpMV[0].mvL0[0] + offsetAffine[0]

[0556] CpMV[0].mvL0[1] = CpMV[0].mvL0[1] + offsetAffine[1]

[0557] CpMV[1].mvL0[0] = CpMV[1].mvL0[0] + offsetAffine[0]

[0558] CpMV[1].mvL0[1] = CpMV[1].mvL0[1] + offsetAffine[1]

[0559] CpMV[2].mvL0[0] = CpMV[2].mvL0[0] + offsetAffine[0]

[0560] CpMV[2].mvL0[1] = CpMV[2].mvL0[1] + offsetAffine[1]

[0561] On the other hand, when the temporal direction of the L0 reference picture is different from the temporal direction of the L1 reference picture, as in Equation 17 below, the updated affine seed vectors can be derived by adding or subtracting the offset vectors to / from each affine seed vector. In an example, when the picture order count (POC) difference between the current picture and the L0 reference picture is negative and the picture order count (POC) difference between the current picture and the L1 reference picture is positive, or when the picture order count (POC) difference between the current picture and the L0 reference picture is positive and the picture order count (POC) difference between the current picture and the L1 reference picture is negative, it can be determined that the temporal direction of the L0 reference picture is different from the temporal direction of the L1 reference picture.

[0562] [Equation 17]

[0563] CpMV[0].mvL0[0] = CpMV[0].mvL0[0] + offsetAffine[0]

[0564] CpMV[0].mvL0[1] = CpMV[0].mvL0[1] - offsetAffine[1]

[0565] CpMV[1].mvL0[0] = CpMV[1].mvL0[0] + offsetAffine[0]

[0566] CpMV[1].mvL0[1] = CpMV[1].mvL0[1] - offsetAffine[1]

[0567] CpMV[2].mvL0[0] = CpMV[2].mvL0[0] + offsetAffine[0]

[0568] CpMV[2].mvL0[1] = CpMV[2].mvL0[1] - offsetAffine[1]

[0569] Equation 16 and Equation 17 show that the same offset vector is applied to all affine seed vectors, but the disclosure is not limited thereto. The offset vector for each affine seed vector can also be determined individually.

[0570] Optionally, the offset vector can be set per sub-block. The motion vector of a sub-block can be updated by using the offset vector of the corresponding sub-block.

[0571] The range of offset vector size candidates can be determined differently according to the motion vector precision of the current block or neighboring blocks. In other words, at least one of the number, the minimum value, or the maximum value of offset vector size candidates can be different according to the motion vector precision of the current block or neighboring blocks. In an example, when an affine motion model is applied to the current block and the motion vector precision of the current block is 1 / 4-pel, the value of the variable DistFromMergeMV can be determined to be one of 1, 2, 4, 8, 16, 32, 64, and 128 by distance_idx. On the other hand, when the motion vector precision of the current block is integer-pel, the value of the variable DistFromMergeMV can be determined to be one of 4, 8, 16, 32, 64, 128, 256, and 512 by distance_idx.

[0572] In another example, information for specifying one of a plurality of offset vector size candidate sets can be signaled in a bitstream. At least one of the number or the type of offset vector size candidates included in each offset vector size candidate set can be different. In an example, when a first offset vector size candidate set is selected, the variable DistFromMergeMV can be determined to be one of {1, 2, 4, 8, 16, 32, 64, 128}, and when a second offset vector size candidate set is selected, the variable DistFromMergeMV can be determined to be one of {4, 8, 16, 32, 64, 128, 256, 512}.

[0573] Index information DistMV_idx specifying one of a plurality of offset vector size candidate sets can be signaled in a bitstream. In an example, when DistMV_idx is 0, this indicates that a first offset vector size candidate set is selected, and when DistMV_idx is 1, this indicates that a second offset vector size candidate set is selected.

[0574] The offset vector can be set per sub-block or per sample. In other words, an offset vector (or difference vector) or an offset vector array (or difference vector array) for a sub-block or a sample can be defined as offset data.

[0575] For example, when a sub-block motion vector is derived based on an affine seed vector, motion compensation for the sub-block can be performed by using the derived sub-block motion vector. In this case, the offset vector per sub-block or per sample can be additionally used to perform motion compensation.

[0576] The offset vector of a sub-block can be derived by using an offset vector candidate. The sub-block motion vector can be updated based on the offset vector, and motion compensation for the sub-block can be performed based on the updated sub-block motion vector.

[0577] The offset vector can be derived per prediction sample in the sub-block. Specifically, the offset vector for each prediction sample can be derived based on the position of the prediction sample in the sub-block. In this case, the position of the prediction sample can be determined based on the top-left sample of the sub-block.

[0578] The x-component of the offset vector for the prediction sample can be derived based on a value obtained by multiplying the difference between the x-component of the second affine seed vector and the x-component of the first affine seed vector by the x-axis coordinate of the prediction sample and a value obtained by multiplying the difference between the y-component of the second affine seed vector and the y-component of the first affine seed vector by the y-axis coordinate of the prediction sample. Further, the y-component of the offset vector for the prediction sample can be derived based on a value obtained by multiplying the difference between the x-component of the third affine seed vector and the x-component of the first affine seed vector by the x-axis coordinate of the prediction sample and a value obtained by multiplying the difference between the y-component of the third affine seed vector and the y-component of the second affine seed vector by the y-axis coordinate of the prediction sample.

[0579] When the 4-parameter motion model is applied to the current block, the y-component of the offset vector can be derived based on a value obtained by multiplying the difference between the x-component of the first affine seed vector and the x-component of the second affine seed vector by the x-axis coordinate of the prediction sample and a value obtained by multiplying the difference between the y-component of the second affine seed vector and the y-component of the first affine seed vector by the y-axis coordinate of the prediction sample.

[0580] As described above, the offset vectors of the prediction samples in the sub-blocks can have different values, respectively. However, the offset vector array for the prediction samples can be commonly applied to all the sub-blocks. In other words, the offset vector array applied to the first sub-block can be the same as the offset vector array applied to the second sub-block.

[0581] Alternatively, the offset vector array per sample can be derived by further considering the positions of the sub-blocks. In this case, different offset vector arrays can be applied between the sub-blocks.

[0582] After performing the motion compensation for the sub-blocks based on the sub-block motion vectors, each prediction sample can be updated based on the offset vector. The prediction sample update can be performed based on the offset vector of the prediction sample and the gradient for the prediction sample.

[0583] The gradient for the prediction sample can be derived based on the difference of the prediction samples. The gradient for the first prediction sample can be derived based on the difference between the prediction samples belonging to the same line as the first prediction sample or the difference between the prediction samples belonging to the line adjacent to the first prediction sample.

[0584] In an example, a gradient for a first prediction sample can be derived by a difference between the first prediction sample and another prediction sample belonging to a same line as the first prediction sample. Specifically, a horizontal direction gradient for the first prediction sample can be derived by a difference between the first prediction sample and a second prediction sample belonging to a same row as the first prediction sample, and a vertical direction gradient for the first prediction sample can be derived by a difference between the first prediction sample and a third prediction sample belonging to a same column as the first prediction sample. In this case, the second prediction sample and the third prediction sample can be adjacent to the first prediction sample. In an example, the second prediction sample can be located at a left side or a right side of the first prediction sample, and the third prediction sample can be located at an upper side or a lower side of the first prediction sample. Alternatively, the second prediction sample and the third prediction sample can be spaced apart from the first prediction sample by a predetermined distance in an x-axis and / or y-axis direction. In this case, the predetermined distance can be a natural number such as 1, 2, or 3.

[0585] Alternatively, a difference of prediction samples belonging to a line adjacent to the first prediction sample can be set as the gradient for the first prediction sample. In an example, a horizontal direction gradient for the first prediction sample can be derived by a difference of prediction samples belonging to a row adjacent to the first prediction sample. In this case, the row adjacent to the first prediction sample can represent an upper row or a lower row of the first prediction sample. At least one of the prediction samples used to derive the horizontal direction gradient for the first prediction sample can be adjacent to the first prediction sample, and other prediction samples can be non-adjacent to the first prediction sample. In an example, a horizontal direction gradient for the first prediction sample can be derived based on a difference between a second prediction sample located at an upper side or a lower side of the first prediction sample and a third prediction sample spaced apart from the second prediction sample by a predetermined distance in an x-axis direction. A vertical direction gradient for the first prediction sample can be derived by a difference of prediction samples belonging to a column adjacent to the first prediction sample. In this case, the column adjacent to the first prediction sample can represent a left column or a right column of the first prediction sample. At least one of the prediction samples used to derive the vertical direction gradient for the first prediction sample can be adjacent to the first prediction sample, and other prediction samples can be non-adjacent to the first prediction sample. In an example, a vertical direction gradient for the first prediction sample can be derived based on a difference between a fourth prediction sample located at a left side or a right side of the first prediction sample and a fifth prediction sample spaced apart from the fourth prediction sample by a predetermined distance in a y-axis direction. In this case, the predetermined distance can be a natural number such as 1, 2, or 3.

[0586] Equation 18 represents an example of deriving a horizontal direction gradient gradientH and a vertical direction gradient gradientV for a first prediction sample.

[0587]

Equation 18

[0588] gradientH[x][y] = ( predSample[x+2][y+1] - predSample[x][y+1] ) » shift1

[0589] gradientV[x][y] = ( predSample[x+1][y+2] - predSample[x+1][y] ) » shift1

[0590] In Equation 18, predSample denotes a prediction sample, and [x][y] denotes x-axis and y-axis coordinates. shift1 denotes a shift parameter. The shift parameter can have a predefined value in an encoding device and a decoding device. Alternatively, the shift parameter can be adaptively determined based on at least one of a size, a shape, an aspect ratio, or an affine motion model of a current block.

[0591] When deriving a gradient for a prediction sample, an offset prediction value for the prediction sample can be derived by using the gradient and an offset vector. The offset prediction value can be derived based on a multiplication operation of the gradient and the offset vector. In an example, Equation 19 denotes an example of deriving an offset prediction value OffsetPred.

[0592]

Equation 19

[0593] OffsetPred[x][y] = gradientH[x][y] * offsetMV[x][y][0] + gradientV * offsetMV[x][y][1]

[0594] When deriving the offset prediction value, a prediction sample can be updated by adding the offset prediction value to the prediction sample. Equation 20 denotes an example of updating a prediction sample.

[0595]

Equation 20

[0596] predSample[x][y] = predSample[x][y] + OffsetPred[x][y]

[0597] In another example, a prediction sample can be updated by adding an offset vector to a surrounding prediction sample. In this case, the surrounding prediction sample can include at least one of a sample located to the right of the prediction sample, a sample located below the prediction sample, or a sample located to the right below the prediction sample. In an example, Equation 21 denotes an example of updating a prediction sample by using a surrounding prediction sample.

[0598]

Equation 21

[0599] prgdSample[x][y] = prgdSample[x+1][y+1] + OffssetPred[x][y]

[0600] The information indicating whether the offset vector is to be used for performing motion compensation for the current block can be signaled in a bitstream. The information can be a 1-bit flag.

[0601] Optionally, whether to use the offset vector can be determined based on a size of the current block, a shape of the current block, or whether the affine seed vectors are the same. In an example, if a 4-parameter affine motion model is applied to the current block, the offset vector can be used for motion compensation when the first affine seed vector and the second affine seed vector are the same. Optionally, if a 6-parameter affine motion model is applied to the current block, the offset vector can be used for motion compensation when the first affine seed vector, the second affine seed vector, and the third affine seed vector are the same or when two of the first affine seed vector, the second affine seed vector, and the third affine seed vector are the same.

[0602] One prediction mode can be applied to the current block multiple times, and multiple prediction modes can be applied redundantly. Therefore, the prediction methods using the same or different prediction modes can be referred to as a combined prediction mode (or a multi-hypothesis prediction mode).

[0603] The combined prediction mode can include at least one of a mode combining the merge mode and the merge mode, a mode combining the inter prediction and the intra prediction, a mode combining the merge mode and the motion vector prediction mode, a mode combining the motion vector prediction mode and the motion vector prediction mode, or a mode combining the merge mode and the intra prediction.

[0604] In the combined prediction mode, a first prediction block can be generated based on a first prediction mode, and a second prediction block can be generated based on a second prediction mode. Thereafter, a third prediction block can be generated based on a weighted sum operation of the first prediction block and the second prediction block. The third prediction block can be set as a final prediction block of the current block.

[0605] In the above-described embodiments, various inter prediction methods using motion information derived from a merge candidate in a merge mode are described. Specifically, the present specification introduces inter prediction methods based on the following merge modes.

[0606] i) Conventional merge mode: a method of performing motion compensation based on a motion vector derived from a merge candidate

[0607] ii) Merge offset coding mode: a method of modifying a motion vector derived from a merge candidate based on an offset vector and performing motion compensation based on the modified motion vector

[0608] iii) Subblock-based motion compensation mode: a method of deriving subblock motion vectors based on merge candidates and performing motion compensation based on subblocks

[0609] iv) Prediction unit partition-based coding mode: a method of partitioning a current block into multiple prediction units and deriving motion information of each prediction unit from different merge candidates

[0610] v) Combined prediction mode: a method of combining intra prediction and inter prediction (e.g., merge mode)

[0611] Information indicating that the inter prediction method based on the merge mode is allowed can be signaled in a bitstream. In an example, a merge flag merge_flag indicates that at least one motion information of a current block is derived from a merge candidate. In an example, when a value of the syntax merge_flag is 1, it indicates that one of the above inter prediction methods based on the merge mode is applied to the current block. In other words, when the value of the syntax merge_flag is 1, any one of the regular merge mode, the merge offset coding mode, the subblock-based motion compensation mode, the prediction unit partition-based coding mode, or the combined prediction mode can be applied to the current block. On the other hand, when the value of the syntax merge_flag is 0, it indicates that the above inter prediction methods based on the merge mode are not applied to the current block.

[0612] Although the value of the syntax merge_flag is 1, additional information is needed to determine the inter prediction method applied to the current block because there are various inter prediction methods based on the merge mode. In an example, at least one of a syntax merge_subblock_flag for determining whether the subblock-based motion compensation mode is applied, a syntax merge_offset_vector_flag or mmvd_flag for determining whether the merge offset coding mode is applied, a triangle_partition_flag or merge_triangle_flag indicating whether the prediction unit partition-based coding mode is applied, or a ciip_flag indicating whether the combined prediction mode is applied can be additionally signaled. Alternatively, whether the inter prediction method based on a specific merge mode is applied to the current block can be determined based on at least one of a size or a shape of the current block or a number of merge candidates included in a merge candidate list instead of the flag.

[0613] In this case, when no other prediction method except for the regular merge mode is applied, the regular merge mode can be applied to the current block. However, in this case, there is a problem that a large number of syntax elements should be parsed to determine whether the regular merge mode is applied to the current block. For example, there is a problem that when determining whether the regular merge mode is applied after parsing mmvd_flag indicating whether the merge offset coding mode is applied, merge_subblock_flag indicating whether the subblock motion compensation is applied, merge_triangle_flag indicating whether the coding mode based on the prediction unit partition is applied, and / or ciip_flag indicating whether the combined prediction mode is applied, although the regular merge mode is more frequently used than other modes, a large number of syntax elements should be parsed. In other words, the determination of whether the regular merge mode is applied to the current block has a multi-step parsing dependency. In addition, there is a problem that index information merge_idx for specifying a merge candidate in the regular merge mode also has a high parsing dependency.

[0614] To solve the above problem, information indicating whether the regular merge mode is used can be separately coded. Specifically, a flag regular_merge_flag indicating whether the regular merge mode is applied can be coded and signaled.

[0615] Table 12 represents a syntax table including the regular_merge_flag.

[0616]

Table 12

[0617]

[0618]

[0619] The syntax regular_merge_flag can be coded only when it is determined that the inter prediction mode based on the merge mode is applied to the current block. In other words, the syntax regular_merge_flag can be signaled in a bitstream only when the syntax merge_flag is 1.

[0620] When the syntax regular_merge_flag is 1, it indicates that the regular merge mode is applied to the current block. When it is determined that the regular merge mode is applied to the current block, a merge index merge_idx for specifying one of the merge candidates can be signaled in a bitstream.

[0621] When the syntax regular_merge_flag is 0, this indicates that regular merge mode is not applied to the current block. When the syntax regular_merge_flag is 0, at least one of mmvd_flag that indicates whether merge offset coding mode is applied, merge_subblock_flag that indicates whether subblock motion compensation mode is applied, ciip_flag that indicates whether combined prediction mode is applied, or merge_triangle_flag that indicates whether prediction unit partition based coding mode is applied can be signaled in the bitstream.

[0622] Optionally, the operation of signaling the flag merge_triangle_flag can be omitted, and whether prediction unit partition based coding mode is applied can be determined based on the ciip_flag. In an example, when the ciip_flag is true, this indicates that combined prediction mode is applied to the current block, and prediction unit partition based coding mode is not applied. When the ciip_flag is false, this indicates that combined prediction mode is not applied to the current block, and prediction unit partition based coding mode can be applied.

[0623] Optionally, at least one of mmvd_flag that indicates whether merge offset coding mode is applied, merge_subblock_flag that indicates whether subblock motion compensation mode is applied, ciip_flag that indicates whether combined prediction mode is applied, or merge_triangle_flag that indicates whether prediction unit partition based coding mode is applied can be signaled before regular_merge_flag that indicates whether regular merge mode is applied. In an example, when the value of the flag merge_subblock_flag that indicates whether subblock motion compensation mode is applied is 0, regular_merge_flag that indicates whether regular merge is applied can be signaled.

[0624] As an alternative to the flag that indicates whether regular merge mode is applied, a flag that indicates whether at least one of regular merge mode or merge offset coding mode is applied can be coded and signaled. In an example, regular_mmvd_merge_flag that indicates whether at least one of regular merge mode or merge offset coding mode is applied can be signaled in the bitstream.

[0625] Table 13 indicates a syntax table including regular_mmvd_merge_flag.

[0626]

Table 13

[0627]

[0628]

[0629] regular mmvd merge flag can be signaled in the bitstream only when the syntax merge_flag is 1.

[0630] When the value of the syntax regular mmvd merge flag is 1, it indicates that either the regular merge mode or the merge offset coding mode is applied to the current block. When the syntax regular mmvd merge flag is 1, the syntax mmvd_flag indicating whether the merge offset coding mode is applied to the current block can be additionally signaled. When the value of the syntax mmvd_flag is 1, it indicates that the merge offset coding mode is applied to the current block, and when the value of the syntax mmvd_flag is 0, it indicates that the regular merge mode is applied to the current block.

[0631] When the value of the syntax regular mmvd merge flag is 0, it indicates that neither the regular merge mode nor the merge offset coding mode is applied to the current block. When the value of the syntax regular mmvd merge flag is 0, at least one of the merge_subblock_flag indicating whether the subblock motion compensation mode is applied, the ciip_flag indicating whether the combined prediction mode is applied, or the merge_triangle_flag indicating whether the coding mode based on the prediction unit partition is applied can be signaled in the bitstream.

[0632] Optionally, the operation of signaling the flag merge_triangle_flag can be omitted, and whether the coding mode based on the prediction unit partition is applied can be determined based on the ciip_flag. In an example, when the ciip_flag is true, it indicates that the combined prediction mode is applied to the current block, and the coding mode based on the prediction unit partition is not applied. When the ciip_flag is false, it indicates that the combined prediction mode is not applied to the current block, and the coding mode based on the prediction unit partition can be applied.

[0633] Optionally, at least one of merge_subblock_flag indicating whether subblock motion compensation mode is applied, ciip_flag indicating whether combined inter / intra prediction mode is applied, or merge_triangle_flag indicating whether prediction unit partition based coding mode is applied can be signaled before regular_mmvd_merge_flag indicating whether regular merge mode or merge offset coding mode is applied. In an example, when the value of the flag merge_subblock_flag indicating whether subblock motion compensation mode is applied is 0, the flag regular_mmvd_merge_flag indicating whether regular merge mode or merge offset coding mode is applied can be signaled.

[0634] When the value of the flag regular_mmvd_merge_flag is 1, a merge index merge_idx for specifying one of the merge candidates can be coded and signaled, and the availability of the merge offset coding mode can be determined based on the value of merge_idx. In an example, when the value of the syntax merge_idx is less than a threshold, the regular merge mode or the merge offset coding mode can be applied to the current block. On the other hand, when the value of the syntax merge_idx is equal to or greater than the threshold, the regular merge mode is applied to the current block and the merge offset coding mode is not applied.

[0635] In an example, the syntax mmvd_flag indicating whether the merge offset coding mode is applied can be coded and signaled only when the value of merge_idx is less than 2. On the other hand, when the value of merge_idx is equal to or greater than 2, the coding of the syntax mmvd_flag indicating whether the merge offset coding mode is applied can be omitted and the regular merge mode can be applied to the current block. In other words, the merge offset coding mode can be applied only when the value of merge_idx is less than 2.

[0636] When the syntax mmvd_flag is 1, it indicates that the merge offset coding mode is applied. When the merge offset coding mode is applied, the motion vector of the merge candidate indicated by the merge index merge_idx can be set as the initial motion vector. In other words, one of the merge candidates for deriving the initial motion vector can be specified based on merge_idx parsed before mmvd_flag.

[0637] Optionally, distance_idx and direction_idx for determining the offset vector can be signaled in the bitstream when mmvd_flag is 1.

[0638] In another example, the syntax table can be configured such that the merge index merge_idx is parsed before a flag (e.g., regular_merge_flag or regular_mmvd_merge_flag) that indicates whether a regular merge mode is applied.

[0639] Table 14 represents an example in which the merge index is parsed before a flag that indicates whether a regular merge mode is applied.

[0640]

Table 14

[0641]

[0642]

[0643] When it is determined that the merge mode based motion prediction is performed for the current block, a merge index that specifies one of the merge candidates can be signaled. In other words, when the value of the syntax merge_flag is 1, the merge_idx that specifies the merge candidate can be signaled.

[0644] After the merge index merge_idx is parsed, a flag that indicates whether a regular merge mode is applied can be parsed. In an example, Table 14 shows that the flag regular_merge_flag that indicates whether a regular merge mode is applied is parsed after the merge_idx is parsed. Unlike the example in Table 14, the flag mmvd_flag that indicates whether a regular merge mode or a merge offset coding mode is applied can be set to be signaled after the merge index merge_idx is signaled.

[0645] When the regular merge mode is applied, the merge candidate specified by the merge index merge_idx can be used to derive the motion information of the current block.

[0646] When the merge offset coding mode is applied, the merge candidate specified by the merge index merge_idx can be used to derive the initial motion vector of the current block. The flag mmvd_flag that indicates whether the merge offset coding mode is applied can be signaled in the bitstream only when the merge index is less than a threshold.

[0647] When it is determined that the regular merge mode is not applied (e.g., when regular_merge_flag or regular_mmvd_merge_flag is 0), a flag merge_subblock_flag indicating whether the subblock motion compensation mode is applied or not can be signaled. When the subblock motion compensation mode is applied, the merge candidate specified by the merge index merge_idx can be used to derive the motion vector of the subblock.

[0648] When it is determined that the regular merge mode is not applied to the current block (e.g., when regular_merge_flag or regular_mmvd_merge_flag is 0), the coding mode based on the prediction unit partitioning can be applied to the current block. When the coding mode based on the prediction unit partitioning is applied, the merge candidate specified by the merge index merge_idx can be set as the merge candidate of one of the first partition and the second partition. When the coding mode based on the prediction unit partitioning is applied, the merge index for specifying the merge candidate of the other one of the first partition or the second partition can be additionally signaled.

[0649] The regular_merge_flag or the regular_mmvd_merge_flag indicating whether the regular merge mode is applied or not can be signaled only when the size of the current block is smaller than a threshold. In an example, the flag indicating whether the regular merge mode is applied or not can be signaled when the size of the current block is smaller than 128x128. When the flag indicating whether the regular merge mode is applied or not is not signaled, it indicates that the regular merge mode is not applied to the current block. In this case, the coding mode based on the prediction unit partitioning can be applied to the current block.

[0650] Intra prediction is a method for performing prediction on a current block by using reconstructed samples that have been coded / decoded and are around the current block. In this regard, the reconstructed samples before applying the in-loop filter can be used for the intra prediction of the current block.

[0651] The intra prediction method includes the matrix-based intra prediction and the intra prediction according to the direction of the neighboring reconstructed samples. Information indicating the intra prediction method of the current block can be signaled in a bitstream. The information can be a 1-bit flag. Alternatively, the intra prediction of the current block can be determined based on at least one of the position of the current block, the size of the current block, the shape of the current block, or the intra prediction method of the neighboring block. In an example, when the current block is presented as crossing a picture boundary, it can be set such that the matrix-based intra prediction method is not applied to the current block.

[0652] A matrix-based intra prediction method is a method of obtaining a prediction block of a current block based on a matrix product of a matrix stored in an encoder and a decoder and reconstructed samples around the current block. Information for specifying any one of a plurality of pre-stored matrices can be signaled in a bitstream. A decoder can determine a matrix for performing intra prediction on a current block based on the information and a size of the current block.

[0653] General intra prediction is a method of obtaining a prediction block of a current block based on a non-directional intra prediction mode or a directional intra prediction mode.

[0654] A residual image can be derived by subtracting a prediction image from an original image. In this regard, when the residual image is converted into a frequency domain, a subjective image quality of the image does not significantly decrease even if a high frequency component is removed from a frequency component. Accordingly, when a value of the high frequency component is transformed into a small value, or when the value of the high frequency component is set to 0, compression efficiency can be improved without causing a large visual distortion. Reflecting the above-described characteristics, a transform can be performed on a current block in order to decompose a residual image into two-dimensional frequency components. The transform can be performed by using a transform method such as DCT (Discrete Cosine Transform), DST (Discrete Sine Transform), or the like.

[0655] A transform method can be determined based on a block. The transform method can be determined based on at least one of a prediction encoding mode for a current block, a size of the current block, or the size of the current block. In an example, when the current block is encoded by an intra prediction mode and the size of the current block is smaller than NxN, a transform method using DST can be performed. On the other hand, when the above-described conditions are not satisfied, a transform method using DCT can be performed.

[0656] For a partial block of a residual image, a two-dimensional image transform can not be performed. The non-performance of the two-dimensional image transform can be referred to as a transform skip. When the transform skip is applied, quantization can be applied to residual values for which the transform is not performed.

[0657] After a transform is performed on a current block by using DCT or DST, a transform can be performed on the transformed current block again. In this regard, the transform based on DCT or DST can be defined as a first transform, and the transform performed on a block to which the first transform is applied again can be defined as a second transform.

[0658] The first transform can be performed by using any one of a plurality of transform kernel candidates. In an example, the first transform can be performed by using any one of DCT2, DCT8, or DCT7.

[0659] Different transform kernels can be used for a horizontal direction and a vertical direction. Information indicating a combination of a transform kernel of the horizontal direction and a transform kernel of the vertical direction can be signaled in a bitstream.

[0660] The processing unit of the first transform can be different from the second transform. In an example, the first transform can be performed on a block of 8x8, and the second transform can be performed on a sub-block of 4x4 size within the transformed 8x8 block. In this regard, the transform coefficients for the remaining area for which the second transform is not performed can be set to 0.

[0661] Alternatively, the first transform can be performed on a block of 4x4, and the second transform can be performed on an area of 8x8 size including the transformed 4x4 block.

[0662] The information indicating whether the second transform is performed can be signaled in a bitstream.

[0663] Alternatively, whether the second transform is performed can be determined based on whether the horizontal direction transform kernel and the vertical direction transform kernel are the same as each other. In one example, the second transform can be performed only when the horizontal direction transform kernel and the vertical direction transform kernel are the same as each other. Alternatively, the second transform can be performed only when the horizontal direction transform kernel and the vertical direction transform kernel are not the same as each other.

[0664] Alternatively, the second transform can be allowed only when a predefined transform kernel is used for the horizontal direction transform and the vertical direction transform. In one example, the second transform can be allowed when a DCT2 transform kernel is used for the transform in the horizontal direction and the transform in the vertical direction.

[0665] Alternatively, whether the second transform is performed can be determined based on the number of non-zero transform coefficients of the current block. In one example, when the number of non-zero transform coefficients of the current block is less than or equal to a threshold value, the prediction method can be configured not to use the second transform. When the number of non-zero transform coefficients of the current block is greater than the threshold value, the prediction method can be configured to use the second transform. The prediction method can be configured to use the second transform as long as the current block is encoded using intra prediction.

[0666] The decoder can perform an inverse transform with respect to the second transform (second inverse transform), and can perform an inverse transform with respect to the first transform that is a result of the second inverse transform (first inverse transform). As a result of performing the second inverse transform and the first inverse transform, a residual signal for the current block can be obtained.

[0667] When the transform and the quantization are performed by the encoder, the decoder can obtain a residual block via dequantization and inverse transform. The decoder can add the prediction block and the residual block to each other to obtain a reconstructed block for the current block.

[0668] When the reconstructed block of the current block is obtained, a loss of information that occurs in the quantization and encoding process can be reduced via in-loop filtering. The in-loop filter can include at least one of a deblocking filter, a sample adaptive offset filter (SAO), or an adaptive loop filter (ALF).

[0669] Embodiments as described with respect to a decoding process or an encoding process can be applied to an operation of an encoding process or a decoding process, respectively, can be included in the scope of the present disclosure. Embodiments in which operations occur in a predetermined order can be modified to embodiments in which operations occur in an order different from the predetermined order, within the scope of the present disclosure.

[0670] Although the above-described embodiments are described based on a series of operations or flowcharts, the embodiments do not limit the time sequential order of the operations of the methods to this. In another example, the operations can be performed simultaneously or in a different order from this, as needed. Also, in the above-described embodiments, each of the components (e.g., units, modules, etc.) constituting a block diagram can be implemented in the form of hardware devices or software. A plurality of components can be combined with each other into a single component that can be implemented using a single hardware device or software. The above-described embodiments can be implemented using program instructions that can be executed via various computer components. The instructions can be recorded in computer-readable storage media. The computer-readable storage media can include program instructions, data files, data structures, etc., individually or in combination, therein. Examples of the computer-readable storage media include magnetic media such as hard disks, floppy disks and magnetic tapes, optical media such as CD-ROMs and DVDs, magneto-optical media such as floptical disks, and hardware devices specially configured to store and perform program instructions such as ROMs, RAMs, flash memories, etc. The hardware device can be configured to operate as one or more software modules in order to perform processes according to the present disclosure, and vice versa.

[0671] Industrial applicability

[0672] The present disclosure can be applied to an electronic device that encodes / decodes a video.

Claims

1. A method of decoding a video, the method comprising: obtaining one or more spatial merge candidates for a current block; obtaining a temporal merge candidate for the current block; generating a merge candidate list for the current block by adding the spatial merge candidates and the temporal merge candidate to the merge candidate list for the current block; obtaining motion information for the current block from one of the merge candidates included in the merge candidate list; obtaining prediction samples for the current block based on the motion information for the current block; and based on a position of the current block, determining whether to update a motion information table with the motion information for the current block, wherein when the current block is included in a predetermined region, the motion information table is updated with the motion information for the current block only when the current block is located at a lower right of the predetermined region, and wherein when a number of spatial merge candidates and temporal merge candidates included in the merge candidate list is less than a threshold, motion information candidates included in the motion information table are added to the merge candidate list as merge candidates. signaling information for determining a size of the predetermined region via a bitstream.

2. The method of claim 1, wherein, when the current block is included in the predetermined region, the motion information table is not updated with motion information of a previous block included in a same region as the current block.

3. The method of claim 1, wherein, the method further comprises performing a redundancy check on the motion information candidates included in the motion information table, and 4. The method of claim 1, wherein, wherein the redundancy check on the motion information candidates is performed with merge candidates derived from an above neighboring block or a left neighboring block.

5. A system comprising: one or more processors; and one or more non-transitory computer-readable media storing instructions that, when executed by the one or more processors, cause the one or more processors to perform operations comprising: obtaining one or more spatial merge candidates for a current block; obtaining a temporal merge candidate for the current block; generating a merge candidate list for the current block by adding the spatial merge candidates and the temporal merge candidate to the merge candidate list for the current block; obtaining motion information for the current block from one of the merge candidates included in the merge candidate list; obtaining prediction samples for the current block based on the motion information for the current block; and based on a position of the current block, determining whether to update a motion information table with the motion information for the current block, wherein when the current block is included in a predetermined region, the motion information table is updated with the motion information for the current block only when the current block is located at a lower right of the predetermined region, and wherein when a number of spatial merge candidates and temporal merge candidates included in the merge candidate list is less than a threshold, motion information candidates included in the motion information table are added to the merge candidate list as merge candidates. signaling information for determining a size of the predetermined region via a bitstream. ​ 6. The system of claim 5, wherein, ​ 7. The system of claim 5, wherein, when the current block is included in the predetermined region, the motion information table is not updated with motion information of a previous block included in a same region as the current block.

8. The system of claim 5, wherein, The operations further include performing a redundancy check on the motion information candidates included in the motion information table, and wherein the redundancy check on the motion information candidates is performed with a merge candidate derived from an above neighboring block or a left neighboring block.

9. A method of encoding a video, the method comprising: obtaining one or more spatial merge candidates for a current block; obtaining a temporal merge candidate for the current block; generating a merge candidate list for the current block by adding the spatial merge candidates and the temporal merge candidate to the merge candidate list for the current block; obtaining motion information for the current block from one of the merge candidates included in the merge candidate list; obtaining prediction samples for the current block based on the motion information for the current block; based on a position of the current block, determining whether to update a motion information table with the motion information for the current block, wherein when the current block is included in a predetermined region, the motion information table is updated with the motion information for the current block only when the current block is located at a lower right of the predetermined region; and generating a bitstream representing the video based on the prediction samples, wherein when a number of spatial merge candidates and temporal merge candidates included in the merge candidate list is less than a threshold, motion information candidates included in the motion information table are added to the merge candidate list as merge candidates.

10. The method of claim 9, wherein, information for determining a size of the predetermined region is encoded into the bitstream.

11. The method of claim 9, wherein, when the current block is included in the predetermined region, the motion information table is not updated with motion information of a previous block included in a same region as the current block.

12. The method of claim 9, wherein, The method further includes performing a redundancy check on the motion information candidates included in the motion information table, and wherein the redundancy check on the motion information candidates is performed with a merge candidate derived from an above neighboring block or a left neighboring block.

13. A system comprising: one or more processors; and one or more non-transitory computer-readable media storing instructions that, when executed by the one or more processors, cause the one or more processors to perform operations comprising: obtaining one or more spatial merge candidates for a current block; obtaining a temporal merge candidate for the current block; generating a merge candidate list for the current block by adding the spatial merge candidates and the temporal merge candidate to the merge candidate list for the current block; obtaining motion information for the current block from one of the merge candidates included in the merge candidate list; obtaining prediction samples for the current block based on the motion information for the current block; based on a position of the current block, determining whether to update a motion information table with the motion information for the current block, wherein the motion information table is updated with the motion information of the current block only when the current block is located at the bottom right of the predetermined region when the current block is included in the predetermined region; and generating a bitstream representing the video based on the prediction samples, wherein the motion information candidate included in the motion information table is added to the merge candidate list as a merge candidate when a number of spatial merge candidates and temporal merge candidates included in the merge candidate list is less than a threshold.

14. The system of claim 13, wherein, information for determining a size of the predetermined region is encoded into the bitstream.

15. The system of claim 13, wherein, The motion information table is not updated with motion information of a previous block included in a same region as the current block when the current block is included in the predetermined region.

16. The system of claim 13, wherein, The operations further include performing a redundancy check on the motion information candidate included in the motion information table, and wherein the redundancy check on the motion information candidate is performed with a merge candidate derived from an above neighboring block or a left neighboring block.

17. A non-transitory computer readable medium for storing data associated with a video signal, comprising: a data stream stored in the non-transitory computer readable medium, the data stream being encoded by an encoding method, the encoding method comprising: obtaining one or more spatial merge candidates for a current block; obtaining temporal merge candidates for the current block; generating a merge candidate list for the current block by adding the spatial merge candidates and the temporal merge candidates to the merge candidate list for the current block; obtaining motion information for the current block from one of the merge candidates included in the merge candidate list; obtaining prediction samples for the current block based on the motion information for the current block; determining whether to update a motion information table with the motion information of the current block based on a location of the current block, wherein the motion information table is updated with the motion information of the current block only when the current block is located at the bottom right of the predetermined region when the current block is included in the predetermined region; and wherein the motion information candidate included in the motion information table is added to the merge candidate list as a merge candidate when a number of spatial merge candidates and temporal merge candidates included in the merge candidate list is less than a threshold.

Citation Information

Patent Citations

  • Image decoding method in merge mode

    CN108282661A

  • Image encoding / decoding method and recording medium for same

    CN109196864A