Method for encoding / decoding image signal and apparatus therefor

By employing an affine model-based inter-frame prediction method in video signal encoding/decoding, and deriving sub-block motion vectors using affine seed vectors and offset vectors, the low inter-frame prediction efficiency of HEVC in high-definition video services is solved, achieving more efficient video encoding/decoding performance.

CN118590660APending Publication Date: 2024-09-03APPLE INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410660926.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2018-12-26
Filing Date
2019-12-26
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

Existing video coding standards such as HEVC exhibit performance limitations in high-definition video services, making it difficult to effectively improve inter-frame prediction efficiency.

Method used

The inter-frame prediction method using an affine model improves the efficiency of video signal encoding/decoding by deriving affine seed vectors and offset vectors. This includes generating an affine merging candidate list, specifying affine merging candidates, deriving sub-block motion vectors and offset data, and updating prediction samples using an affine model.

Benefits of technology

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

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118590660A
    Figure CN118590660A
Patent Text Reader

Abstract

The present disclosure relates to a method for encoding / decoding an image signal and an apparatus therefor. A video decoding method according to the present disclosure comprises the steps of: generating an affine merge candidate list for a current block; specifying one affine merge candidate from among a plurality of affine merge candidates included in the affine merge candidate list; deriving an affine seed vector of the specified merge candidate; deriving a sub-block motion vector for a sub-block in the current block by using the affine seed vector, where the sub-block is smaller than the current block in size; deriving offset data for the sub-block; and generating a sub-prediction block for the sub-block based on the affine vector and the offset data.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the invention patent application with the application date of December 26, 2019, named “Method and device for encoding / decoding image signals” and application number 201980038103.8. Technical Field

[0002] The present disclosure relates to a video signal encoding / decoding method and a device thereof. Background Art

[0003] As display panels become larger, higher quality video services are required. The biggest problem with high-definition video services is the greatly increased amount of data. In order to solve the above problems, research on improving video compression rates is being actively conducted. As a representative example, the Joint Task Force on Video Coding (JCT-VC) was established in 2009 by the Moving Picture Experts Group (MPEG) and the Video Coding Experts Group (VCEG) under the International Telecommunication Union Telecommunication Standardization Division (ITU-T). JCT-VC proposed a video compression standard: High Efficiency Video Coding (HEVC), which has a compression performance approximately twice that of H.264 / AVC, and was approved as a standard on January 25, 2013. However, with the rapid development of high-definition video services, the performance of HEVC has gradually shown its limitations. Summary of the invention

[0004] Technical issues

[0005] An object of the present disclosure is to provide an inter-frame prediction method using an affine model when encoding / decoding a video signal and a device for performing the method.

[0006] An object of the present disclosure is to provide a method and apparatus for deriving an affine seed vector by using a translational motion vector of a sub-block when encoding / decoding a video signal.

[0007] An object of the present disclosure is to provide a method and apparatus for updating prediction samples derived under an affine model by using an offset vector when encoding / decoding a video signal.

[0008] Technical objectives that can be obtained from the present disclosure are not limited to the above-mentioned technical objectives, and other unmentioned technical objectives can be clearly understood by a person of ordinary skill in the technical field to which the present disclosure belongs from the following description.

[0009] Technical Solution

[0010] The video signal decoding / encoding method according to the present disclosure may include: generating an affine merge candidate list for a current block;

[0011] Specifying one affine merge candidate among a plurality of affine merge candidates included in an affine merge candidate list; deriving an affine seed vector of the specified merge candidate; deriving a sub-block motion vector for a sub-block in a current block by using the affine seed vector; deriving offset data for the sub-block; and generating a sub-prediction block for the sub-block based on the affine vector and the offset data. In this regard, the sub-block may be a smaller area than the current block.

[0012] The video signal decoding / encoding method according to the present disclosure may further include decoding a flag for determining whether to use the offset data from a bitstream. In this regard, whether to use the offset data in the process of generating the sub-prediction block may be determined based on the value of the flag.

[0013] In the video signal decoding / encoding method according to the present disclosure, whether to use the offset data in generating the sub-prediction block may be determined based on whether the affine seed vectors are identical to each other.

[0014] In the video signal decoding / encoding method according to the present disclosure, a third prediction sample in the sub-prediction block can be obtained based on the first prediction sample and the second prediction sample, wherein the first prediction sample is derived based on the affine vector, and the second prediction sample is derived based on the offset data.

[0015] In the video signal decoding / encoding method according to the present disclosure, the second prediction sample may be derived based on the horizontal direction gradient and the vertical direction gradient of the first prediction sample.

[0016] In the video signal decoding / encoding method according to the present disclosure, the offset data is an array of offset vectors for each prediction sample in the sub-block.

[0017] It should be understood that the foregoing summarized features are exemplary aspects of the following detailed description of the present disclosure and do not limit the scope of the present disclosure.

[0018] Technical Effects

[0019] According to the present disclosure, an inter prediction method using an affine model may be provided to improve inter prediction efficiency.

[0020] According to the present disclosure, a method of inducing an affine seed vector by using a translation motion vector of a subblock may be provided to improve inter prediction efficiency.

[0021] According to the present disclosure, a method for improving inter-frame prediction efficiency by updating prediction samples derived under an affine model using an offset vector may be provided.

[0022] Effects obtainable from the present disclosure may not be limited to the above-mentioned effects, and other unmentioned effects may be clearly understood from the following description by a person of ordinary skill in the technical field to which the present disclosure belongs. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 is a diagram illustrating a block diagram of a video encoding device (encoder) according to an embodiment of the present disclosure.

[0024] Figure 2 is a diagram showing a block diagram of a video decoding device (decoder) according to an embodiment of the present disclosure.

[0025] Figure 3 is a diagram illustrating a basic coding tree unit according to an embodiment of the present disclosure.

[0026] Figure 4 is a diagram illustrating various partition types of a coding block.

[0027] Figure 5 is a diagram illustrating an example of one aspect of partitioning a CTU.

[0028] Figure 6 is a flowchart of an inter-frame prediction method according to an embodiment of the present disclosure.

[0029] Figure 7 is a diagram illustrating non-straight line motion of an object.

[0030] Figure 8 is a flowchart of an inter-frame prediction method based on affine motion according to an embodiment of the present disclosure.

[0031] Fig. 9 is a diagram showing the affine seed vector of each affine motion model.

[0032] Fig.10 is a diagram showing affine vectors of sub-blocks in a 4-parameter motion model.

[0033] Fig.11 is a diagram showing neighboring blocks that may be used to derive merge candidates.

[0034] Fig.12 A diagram showing an example of deriving an affine seed vector of a current block based on affine seed vectors of affine neighboring blocks.

[0035] Fig.13 is a diagram showing an example of setting a motion vector of a subblock to an affine seed vector of an affine neighboring block.

[0036] Figures 14 to 16 is a diagram showing the positions of affine basic sample points.

[0037] Fig.17 is a diagram illustrating an example of a method of applying an affine merging vector that derives a transformation.

[0038] Fig.18 is a diagram illustrating an example of deriving an affine seed vector of an affine merging candidate based on a motion vector of a subblock included in a neighboring block.

[0039] Fig.19 is a diagram illustrating an example of deriving an affine seed vector of an affine merge candidate based on a motion vector of a subblock located on the left side of a current block.

[0040] Fig. 20 is a diagram illustrating an example of deriving an affine seed vector of an affine merging candidate based on motion information of a non-neighboring block or a neighboring block located on the left side of a current block.

[0041] Fig.21 is a diagram showing the positions of blocks used to derive affine seed vectors for affine merge candidates.

[0042] Fig. 22 is a diagram for explaining an example of deriving a combined affine merging candidate by combining motion vectors of a plurality of neighboring blocks.

[0043] Fig.23 is a diagram illustrating unavailable neighboring blocks.

[0044] Fig.24 is a diagram showing an example in which a current block is partitioned into 2 sub-blocks.

[0045] Fig.25 is a diagram showing an example of deriving an offset vector for each sub-block.

[0046] Fig.26 is a flow chart of a process for deriving motion information for a current block in merge mode.

[0047] Fig. 27 is a diagram illustrating candidate blocks for deriving merge candidates.

[0048] Fig.28 is a diagram for explaining the updating aspect of the motion information table.

[0049] Fig.29 is a diagram illustrating an updating aspect of a motion information table.

[0050] Fig.30 is a diagram illustrating an example of updating an index of a pre-stored motion information candidate.

[0051] Fig.31 is a diagram showing the positions of representative sub-blocks.

[0052] Fig.32An example of generating a motion information table for each inter prediction mode is shown.

[0053] Fig.33 is a diagram illustrating an example of adding motion information candidates included in a long-term motion information table to a merge candidate list.

[0054] Fig.34 is a diagram illustrating an example of performing a redundancy check on only a part of merge candidates.

[0055] Fig.35 is a diagram illustrating an example of omitting a redundant check with a specific merge candidate. DETAILED DESCRIPTION

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

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

[0058] Hereinafter, the encoding / decoding target block is referred to as a “current block.” In an example, the current block may refer to a coding block, a transform block, or a prediction block according to a current encoding / decoding process.

[0059] In addition, the term "unit" used in this specification means a basic unit for performing a specific encoding / decoding process, and "block" can be understood to mean a sample array having a predetermined size. Unless otherwise specified, "block" and "unit" can be used interchangeably. In the example, the coding block and the coding unit can be understood to have the same meaning as each other in the examples described later.

[0060] Figure 1 is a diagram showing a block diagram of an image encoding device (encoder) according to an embodiment of the present disclosure.

[0061] Reference Figure 1 The image encoding device may include a picture partition unit 110, a prediction unit 120 and a prediction unit 125, a transform unit 130, a quantization unit 135, a rearrangement unit 160, an entropy encoding unit 165, an inverse quantization unit 140, an inverse transform unit 145, a filter unit 150 and a memory 155.

[0062] Figure 1The components described in the figure are shown independently in order to illustrate different characteristic functions in the image encoding device, and the figure does not mean that each component is composed of separate hardware or a software unit. That is, each component is listed only for the convenience of explanation, at least two of the components may constitute a component, or a component may be partitioned into multiple components that can perform their functions. Even embodiments that integrate various components and embodiments that divide components are included in the scope of the present disclosure unless they depart from the spirit of the present disclosure.

[0063] In addition, some components are not essential components for performing the essential functions of the present disclosure, but are optional components only for improving performance. The present disclosure may be implemented using essential components for implementing the spirit of the present disclosure other than components only for improving performance, and a structure including only essential components other than optional components only for improving performance is also included in the scope of the present disclosure.

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

[0065] For example, a single picture may be partitioned into a plurality of coding units. In order to partition a picture into coding units, a recursive tree structure such as a quadtree structure may be used, and a coding unit derived from a root such as a single image or a maximum coding unit may be partitioned into other coding units and may have as many child nodes as the partitioned coding units. Coding units that are no longer partitioned according to certain restrictions become leaf nodes. That is, when it is assumed that only square partitions are available for a single coding unit, a single coding unit may be partitioned into up to four other coding units.

[0066] Hereinafter, in an embodiment of the present disclosure, a coding unit may be used as a unit for encoding, or may be used as a unit for decoding.

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

[0068] When a prediction unit is generated based on a coding block on which intra prediction is being performed, when the coding unit is not a minimum coding unit, intra prediction may be performed without performing partitioning into a plurality of N×N prediction units.

[0069] The prediction unit 120 and the prediction unit 125 may include an inter-frame prediction unit 120 that performs inter-frame prediction and an intra-frame prediction unit 125 that performs intra-frame prediction. It may be determined whether inter-frame prediction or intra-frame prediction is performed on the prediction unit, and detailed information (e.g., intra-frame prediction mode, motion vector, reference picture, etc.) according to each prediction method may be determined. In this regard, the processing unit on which the prediction is performed may be different from the prediction unit on which the prediction method and its details are determined. For example, the prediction method, prediction mode, etc. may be determined based on the prediction unit, but the prediction may be performed based on the transform unit. The residual value (residual block) between the generated prediction block and the original block may be input to the transform unit 130. In addition, the prediction mode information, motion vector information, etc. used for prediction may be encoded by the entropy encoding unit 165 using the residual value and may be sent to the decoder. When a specific encoding mode is used, the original block is encoded as it is without generating a prediction block through the prediction unit 120 or the prediction unit 125 and is sent to the decoding unit.

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

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

[0072] The motion prediction unit may perform motion prediction based on the reference picture interpolated by the reference picture interpolation unit. Various methods such as a full search based matching algorithm (FBMA), a three-step search (TSS) algorithm, a new three-step search (NTS) algorithm, etc. may be used as a method for calculating a motion vector. The motion vector may have a motion vector value in units of 1 / 2 pixel or 1 / 4 pixel based on the interpolated pixel. The motion prediction unit may predict the current prediction unit by changing 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. may be used as a motion prediction method.

[0073] The intra prediction unit 125 may generate a prediction unit based on information of reference pixels around the current block as pixel information in the current picture. When the neighboring block of the current prediction unit is a block on which inter prediction is performed, and thus the reference pixel is a pixel on which inter prediction is performed, the reference pixel included in the block on which inter prediction is performed may be replaced with information about the reference pixel of the neighboring block on which intra prediction is performed. In other words, when the reference pixel is unavailable, at least one reference pixel among the available reference pixels may be used to replace the unavailable reference pixel information.

[0074] The prediction mode under the intra prediction may include a directional prediction mode that uses reference pixel information according to a prediction direction when performing prediction, and a non-directional mode that does not use directional information when performing prediction. The mode for predicting luma information may be different from the mode for predicting chroma information. In order to predict chroma information, information about the intra prediction mode for predicting luma information or information about the predicted luma signal may be used.

[0075] When performing intra prediction, when the size of the prediction unit is the same as the size of the transformation unit, intra prediction can be performed on the prediction unit based on pixels located on the left, upper left, and top of the prediction unit. However, when performing intra prediction, when the size of the prediction unit is different from the size of the transformation unit, intra prediction can be performed by using reference pixels based on the transformation unit. In addition, intra prediction using N×N partitions can be used only for the minimum coding unit.

[0076] In the intra prediction method, a prediction block may be generated after an adaptive intra smoothing (AIS) filter is applied to reference pixels according to a prediction mode. The type of the AIS filter applied to the reference pixels may vary. In order to perform the intra prediction method, an intra prediction mode for a current prediction unit may 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 unit, information indicating that the current prediction unit has the same prediction mode as the neighboring prediction unit may be sent by using predetermined flag information. When the prediction mode for the current prediction unit is different from the prediction mode of the neighboring prediction unit, entropy coding may be performed to encode information about the prediction mode for the current block.

[0077] In addition, a residual block including information on a residual value which is a difference value between a prediction unit predicted by the prediction unit 120 or the prediction unit 125 and an original block of the prediction unit may be generated. The generated residual block may be input to the transform unit 130.

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

[0079] The quantization unit 135 may perform quantization on the value transformed into the frequency domain by the transformation unit 130. The quantization coefficient may vary according to the importance or block of the image. The value calculated in the quantization unit 135 may be provided to the inverse quantization unit 140 and the rearrangement unit 160.

[0080] The rearrangement unit 160 may perform rearrangement on the transform coefficients with respect to the quantized residual values.

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

[0082] The entropy encoding unit 165 may perform entropy encoding based on the value calculated by the rearrangement unit 160. The entropy encoding may use various encoding methods, for example, exponential Golomb coding, context adaptive variable length coding (CAVLC), or context adaptive binary arithmetic coding (CABAC).

[0083] The entropy coding unit 165 may encode various types of information obtained from the rearrangement unit 160 and the prediction units 120 and 125 (such as information about residual value coefficients and information about block types of coding units, information about prediction modes, information about partition units, information about prediction units and information about transform units, information about motion vectors, information about reference frames, information about block interpolation, filtering information, and the like).

[0084] The entropy encoding unit 165 may entropy encode coefficients of the coding unit input from the rearrangement unit 160 .

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

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

[0087] The deblocking filter can remove block distortion caused by the boundary between blocks in the reconstructed picture. In order to determine whether to perform the deblocking operation, it can be determined whether to apply the deblocking filter to the current block based on the pixels included in the rows or 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 the required deblocking filter strength. In addition, when applying the deblocking filter, when performing horizontal direction filtering and vertical direction filtering, the horizontal direction filtering and the vertical direction filtering can be configured to be processed in parallel.

[0088] The offset correction unit can correct the original image with an offset in pixels relative to the image on which deblocking is performed. In order to perform offset correction on a specific picture, a method of applying an offset to an area determined after partitioning the pixels of the image into a predetermined number of areas, or a method of applying an offset according to edge information of each pixel can be used.

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

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

[0091] Figure 2 is a diagram showing a block diagram of an image decoding device (decoder) according to an embodiment of the present disclosure.

[0092] Reference Figure 2 , the image decoding apparatus may include an entropy decoding unit 210, a rearrangement unit 215, an inverse quantization unit 220, an inverse transform unit 225, a prediction unit 230 and a prediction unit 235, a filter unit 240, and a memory 245.

[0093] When an image bitstream is input from an encoder, the input bitstream may be decoded according to an inverse process of the image encoding apparatus.

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

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

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

[0097] The inverse quantization unit 220 may perform inverse quantization based on the quantization parameter received from the encoder and the coefficient value of the rearranged block.

[0098] The inverse transform unit 225 may perform an inverse transform (i.e., inverse DCT or inverse DST) for the transform (i.e., DCT or DST) performed on the quantization result by the transform unit in the image encoder. In this regard, the DCT transform core may include at least one of DCT2 or DCT8, and the DST transform core may include DST7. Optionally, when the transform is skipped in the image encoder, the inverse transform is not performed in the inverse transform unit 225. The inverse transform may be performed based on the transform unit determined by the image encoder. The inverse transform unit 225 of the image decoder may selectively perform a transform method (e.g., DCT or DST) according to a plurality of pieces of information (such as a prediction method, a size of a current block, a prediction direction, etc.).

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

[0100] As described above, like the operation of the image encoder, in the process of performing intra-frame prediction, when the size of the prediction unit is the same as the size of the transformation unit, intra-frame prediction can be performed on the prediction unit based on the pixels located on the left, upper left, and top of the prediction unit. However, in the process of performing intra-frame prediction, when the size of the prediction unit is different from the size of the transformation unit, intra-frame prediction can be performed by using reference pixels based on the transformation unit. In addition, intra-frame prediction using N×N partitions can be used only for the minimum coding unit.

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

[0102] In order to perform inter prediction, which method of the skip mode, the merge mode, the AMVP mode, or the intra block copy mode is used as a motion prediction method for a prediction unit included in the coding unit may be determined based on the coding unit.

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

[0104] When the prediction mode of the prediction unit is a prediction mode for performing intra prediction based on a pixel value obtained by interpolating reference pixels, the reference pixel interpolation unit may interpolate the reference pixels so as to generate reference pixels having integer units or smaller units. When the prediction mode for the current prediction unit is a prediction mode for generating a prediction block without interpolating reference pixels, the reference pixels may not be interpolated. When the prediction mode for the current block is a DC mode, the DC filter may generate a prediction block by filtering.

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

[0106] Information about whether a deblocking filter has been applied to a corresponding block or picture and information about whether a strong filter or a weak filter is applied when the deblocking filter is applied may be received from the image encoder. A deblocking filter of an image decoder may receive information about the deblocking filter from the image encoder, and the image decoder may perform deblocking filtering on the corresponding block.

[0107] The offset correction unit may perform offset correction on the reconstructed image based on the type of offset correction applied to the image when encoding is performed, information about the offset value, and the like.

[0108] ALF may be applied to the coding unit based on information on whether ALF is applied, information on an ALF coefficient, etc. received from the encoder. The above ALF information may be provided by being included in a specific parameter set.

[0109] In the memory 245 , the reconstructed picture or the reconstructed block may be stored in order to be used as a reference picture or a reference block, and the reconstructed picture may be provided to the output unit.

[0110] Figure 3 is a diagram illustrating a basic coding tree unit according to an embodiment of the present disclosure.

[0111] The largest coding block may be defined as a coding tree block. A single picture may be partitioned into a plurality of coding tree units (CTUs). A CTU may be a coding unit of the largest size and may be referred to as a largest coding unit (LCU). Figure 3 is a diagram showing an example in which a single picture is partitioned into a plurality of CTUs.

[0112] The size of a CTU may be defined at a picture level or a sequence level. Similarly, information indicating the size of a CTU may be signaled via a picture parameter set or a sequence parameter set.

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

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

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

[0116] The current picture reference is to set the current picture as the reference picture and obtain the prediction block of the current block from the area in the current picture that has been encoded / decoded. In this regard, the current picture represents the picture including the current block. Information indicating whether the current picture reference is applied to the current block can be transmitted by signal in the bitstream. In an example, the information can be a 1-bit flag. When the flag is true (TRUE), the prediction coding mode for the current block can be determined as the current picture reference, and when the flag is false (FALSE), the prediction coding mode for the current block can be determined as inter-frame prediction.

[0117] Alternatively, the prediction coding mode for the current block may be determined based on the reference picture index. In an example, when the reference picture index indicates the current picture, the prediction coding mode for the current block may be determined as the current picture reference. When the reference picture index indicates a picture other than the current picture, the prediction coding mode for the current block may be determined as the inter-frame prediction. In other words, the current picture reference is a prediction method using information about an area that has been encoded / decoded within the current picture, and the inter-frame prediction is a prediction method using information about another picture that has been encoded / decoded.

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

[0119] Figure 4 is a diagram illustrating various partition types of a coding block.

[0120] The coding block may be partitioned into a plurality of coding blocks based on quadtree partitioning, binary tree partitioning, or ternary tree partitioning. The partitioned coding block may be partitioned into a plurality of coding blocks based on quadtree partitioning, binary tree partitioning, or ternary tree partitioning.

[0121] Quadtree partitioning represents a method of partitioning the current block into four blocks. As a result of quadtree partitioning, the current block can be partitioned into four square partitions (refer to Figure 4 of "SPLIT_QT").

[0122] Binary tree partitioning refers to a method of partitioning a current block into two blocks. An operation of partitioning a current block into two blocks in a vertical direction (that is, using a vertical line passing through the current block) may be referred to as vertical binary tree partitioning, and an operation of partitioning a current block into two blocks in a horizontal direction (that is, using a horizontal line passing through the current block) may be referred to as horizontal binary tree partitioning. As a result of the binary tree partitioning, the current block may be partitioned into two non-square partitions. Figure 4 "SPLIT_BT_VER" is a diagram showing the result of binary tree partitioning in the vertical direction. Figure 4 “SPLIT_BT_HOR” is a diagram showing the result of binary tree partitioning in the horizontal direction.

[0123] Ternary tree partitioning means a method of partitioning a current block into three blocks. The operation of partitioning a current block into three blocks along a vertical direction (that is, using two vertical lines passing through the current block) may be referred to as vertical ternary tree partitioning, and the operation of partitioning a current block into three blocks along a horizontal direction (that is, using two horizontal lines passing through the current block) may be referred to as horizontal ternary tree partitioning. As a result of the ternary tree partitioning, the current block may be partitioned into three non-square partitions. In this regard, the width / height of the partition located at the center of the current block may be twice the width / height of the other partitions. Figure 4"SPLIT_TT_VER" is a diagram showing the result of ternary tree partitioning in the vertical direction. Figure 4 “SPLIT_TT_HOR” is a diagram showing the result of ternary tree partitioning in the horizontal direction.

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

[0125] Optionally, the maximum partition depth may be determined independently for each partitioning method. In an example, the maximum partition depth allowed for quadtree partitioning may be different from the maximum partition depth allowed for binary tree partitioning and / or ternary tree partitioning.

[0126] The encoder may signal information indicating at least one of a partition type and a partition depth of the current block in a bitstream. The decoder may determine a partition type and a partition depth of the CTU based on the information obtained by parsing the bitstream.

[0127] Figure 5 is a diagram illustrating an example of one aspect of partitioning a CTU.

[0128] An operation of partitioning a coding block by using quadtree partitioning, binary tree partitioning, and / or ternary tree partitioning may be referred to as multitree partitioning.

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

[0130] In contrast, for a coding block whose partition depth is k+1, the coding block whose partition depth is k may be referred to as a parent coding block.

[0131] The partition type of the current coding block may be determined based on at least one of the partition type of the parent coding block and the partition type of the adjacent coding block. In this regard, the adjacent coding block may be a block adjacent to the current coding block, and may include at least one of a top adjacent block, a left adjacent block, or an adjacent block adjacent to the upper left corner of the current coding block. In this regard, the partition type may include whether quadtree partitioning is applied, whether binary tree partitioning is applied, the direction of binary tree partitioning, whether ternary tree partitioning is applied, or the direction of ternary tree partitioning.

[0132] In order to determine the partition type of the coding block, information indicating whether the coding block is partitioned may be signaled in the bitstream. This information may be a 1-bit flag "split_cu_flag", and when the flag is true, it may indicate that the coding block is partitioned by a multi-tree partitioning method.

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

[0134] In the example, Figure 5 In the example shown in , the CTU is partitioned by quadtree partitioning, and thus four coding blocks with a partition depth of 1 are generated. In addition, it is shown that quadtree partitioning is applied again to the first coding block and the fourth coding block among the four coding blocks generated by quadtree partitioning. As a result, four coding blocks with a partition depth of 2 can be generated.

[0135] In addition, by applying quadtree partitioning again to the coding block with a partition depth of 2, a coding block with a partition depth of 3 may be generated.

[0136] When quadtree partitioning is not applied to a coding block, it may be determined whether to perform binary tree partitioning or ternary tree partitioning on the coding block according to at least one of the size of the coding block, whether the coding block is located at a picture boundary, the maximum partition depth, or the partition type of the neighboring block. When it is determined that binary tree partitioning or ternary tree partitioning is performed on the coding block, information indicating the partition direction may be transmitted by signal in the bitstream. The information may be a 1-bit flag mtt_split_cu_vertical_flag. Based on the flag, it may be determined whether the partition direction is vertical or horizontal. In addition, information indicating which of binary tree partitioning or ternary tree partitioning is applied to the coding block may be transmitted by signal in the bitstream. The information may be a 1-bit flag mtt_split_cu_binary_flag. Based on the flag, it may be determined whether binary tree partitioning is applied to the coding block or ternary tree partitioning is applied to the coding block.

[0137] In the example, Figure 5 In the example shown in , vertical binary tree partitioning is applied to a coding block with a partition depth of 1, vertical ternary tree partitioning is applied to a left coding block among the coding blocks generated by the vertical binary tree partitioning, and vertical binary tree partitioning is applied to a right coding block.

[0138] Inter prediction is a prediction coding mode that predicts a current block by using information about a previous picture. In an example, a block in a previous picture that is located at the same position as the current block (hereinafter referred to as a co-located block) may be set as a prediction block of the current block. Hereinafter, a prediction block generated based on the co-located block of the current block may be referred to as a co-located prediction block.

[0139] In contrast, when an object existing 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 the motion direction and size of the object are determined by comparing the previous picture with the current picture, a prediction block (or a prediction image) 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 may be referred to as a motion prediction block.

[0140] The residual block may be generated by subtracting the prediction block from the current block. In this regard, in the case where the object moves, the energy of the residual block may be reduced by using the motion prediction block instead of using the co-located prediction block, and thus the compression performance of the residual block may be improved.

[0141] As above, the operation of generating a prediction block by using motion information may be referred to as motion estimation prediction. In most inter predictions, a prediction block may be generated based on motion compensation prediction.

[0142] The motion information may include at least one of a motion vector, a reference picture index, a prediction direction, and a bidirectional weighting factor index. The motion vector represents the motion direction and magnitude of an object. The reference picture index specifies a reference picture of a current block among reference pictures included in a reference picture list. The prediction direction indicates any one of unidirectional L0 prediction, unidirectional L1 prediction, or bidirectional prediction (L0 prediction and L1 prediction). At least one of L0 direction motion information and L1 direction motion information may be used according to the prediction direction of the current block. The bidirectional weighting factor index specifies a weighting factor applied to an L0 prediction block and a weighting factor applied to an L1 prediction block.

[0143] Figure 6 is a flowchart of an inter-frame prediction method according to an embodiment of the present disclosure.

[0144] Reference Figure 6 The inter-frame prediction method includes: determining an inter-frame prediction mode for a current block S601, obtaining motion information of the current block according to the determined inter-frame prediction mode S602, and performing motion compensation prediction for the current block based on the obtained motion information S603.

[0145] In this regard, the inter prediction mode may represent various methods for determining motion information of the current block, and may 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 may include a merge mode and a motion vector prediction mode, and the inter prediction mode using affine motion information may include an affine merge mode and an affine motion vector prediction mode. The motion information about the current block may be determined based on a neighboring block adjacent to the current block or information obtained by parsing a bitstream.

[0146] Hereinafter, an inter prediction method using affine motion information is described in detail.

[0147] Figure 7 is a diagram illustrating the rectilinear motion of an object.

[0148] In a video, non-linear motion of an object may occur. In the example, Figure 7 In the example shown in , non-linear motion of the object may occur, such as camera zooming in, zooming out, rotating, or affine transformation. For non-linear motion of the object, the translation motion vector may not be able to effectively express the motion of the object. Therefore, for areas where non-linear motion of the object occurs, the encoding efficiency can be improved by using affine motion instead of translation motion.

[0149] Figure 8 is a flowchart of an inter-frame prediction method based on affine motion according to an embodiment of the present disclosure.

[0150] Whether the affine motion based inter prediction method is applied to the current block may be determined based on information parsed from the bitstream. Specifically, based on at least one of a flag indicating whether the affine merge mode is applied to the current block or a flag indicating whether the affine motion vector prediction mode is applied to the current block, it is determined whether the affine motion based inter prediction method is applied to the current block.

[0151] When the inter prediction method based on affine motion is applied to the current block, an affine motion model of the current block may be determined S801. The affine motion model may be determined as at least one of a 6-parameter affine motion model or a 4-parameter affine motion model. The 6-parameter affine motion model expresses affine motion by using 6 parameters, and the 4-parameter affine motion model expresses affine motion by using 4 parameters.

[0152] Equation 1 expresses the affine motion by using 6 parameters. The affine motion represents a translation motion with respect to a predetermined area determined by an affine seed vector.

[0153] [Equation 1]

[0154] v x =ax-by+e

[0155] v y =cx+dy+f

[0156] In the case of expressing affine motion by using 6 parameters, complex motion can be expressed, but since more bits are required to encode each parameter, encoding efficiency may be reduced. Therefore, affine motion can be expressed by using 4 parameters. Equation 2 represents affine motion by using 4 parameters.

[0157] [Equation 2]

[0158] v x =ax-by+e

[0159] v y =bx+ay+f

[0160] Information for determining an affine motion model for a current block may be encoded and signaled in a bitstream. In an example, the information may be a 1-bit flag 'affine_type_flag'. If the value of the flag is 0, it may indicate that a 4-parameter affine motion model is applied, and if the value of the flag is 1, it may indicate that a 6-parameter affine motion model is applied. The flag may be encoded in units of a slice, a tile, or a block (e.g., a coding block or a coding tree unit). When the flag is signaled at a slice level, the affine motion model determined at the slice level may be applied to all blocks belonging to the slice.

[0161] Optionally, based on the affine inter prediction mode of the current block, the affine motion model of the current block may be determined. In an example, when the affine merge mode is applied, the affine motion model of the current block may be determined as a 4-parameter motion model. On the other hand, when the affine motion vector prediction mode is applied, information for determining the affine motion model of the current block may be encoded and signaled in the bitstream. In an example, when the affine motion vector prediction mode is applied to the current block, the affine motion model of the current block may be determined based on a 1-bit flag "affine_type_flag".

[0162] Next, an affine seed vector of the current block may be derived S802. When a 4-parameter affine motion model is selected, a motion vector at two control points of the current block may be derived. On the other hand, when a 6-parameter affine motion model is selected, a motion vector at three control points of the current block may be derived. The motion vector at the control point may be referred to as an affine seed vector. The control point may include at least one of the upper left corner, the upper right corner, or the lower left corner of the current block.

[0163] Fig. 9 is a diagram showing the affine seed vector used for each affine motion model.

[0164] In a 4-parameter affine motion model, an affine seed vector may be derived for two of the top left corner, top right corner, or bottom left corner. In an example, as in Fig. 9In the example shown in (a), when the 4-parameter affine motion model is selected, the affine vector can be derived by using the affine seed vector sv0 of the upper left corner of the current block (e.g., the upper left sample point (x0, y0)) and the affine seed vector sv1 of the upper right corner of the current block (e.g., the upper right sample point (x1, y1)). The affine seed vector of the lower left corner can be used to replace the affine seed vector of the upper left corner, or the affine seed vector of the lower left corner can be used to replace the affine seed vector of the upper right corner.

[0165] In the 6-parameter affine motion model, affine seed vectors for the upper left corner, upper right corner, and lower left corner can be derived. In the example, as in Fig. 9 In the example shown in (b), when the 6-parameter affine motion model is selected, the affine vector can be derived by using the affine seed vector sv0 of the upper left corner of the current block (e.g., the upper left sample point (x0, y0)), the affine seed vector sv1 of the upper right corner of the current block (e.g., the upper right sample point (x1, y1)), and the affine seed vector sv2 of the lower left corner of the current block (e.g., the lower left sample point (x2, y2)).

[0166] In the embodiment described later, under the 4-parameter affine motion model, the affine seed vectors at the upper left control point and the upper right control point are respectively referred to as the first affine seed vector and the second affine seed vector. In the embodiment using the first affine seed vector and the second affine seed vector described later, at least one of the first affine seed vector and the second affine seed vector may be replaced by the affine seed vector at the lower left control point (the third affine seed vector) or the affine seed vector at the lower right control point (the fourth affine seed vector).

[0167] In addition, under the 6-parameter affine motion model, the affine seed vectors at the upper left control point, the upper right control point, and the lower left control point are respectively referred to as the first affine seed vector, the second affine seed vector, and the third affine seed vector. In the embodiment using the first affine seed vector, the second affine seed vector, and the third affine seed vector described later, at least one of the first affine seed vector, the second affine seed vector, and the third affine seed vector may be replaced by the affine seed vector (fourth affine seed vector) at the lower right control point.

[0168] An affine vector may be derived for each sub-block by using an affine seed vector S803. In this regard, the affine vector represents a translation motion vector derived based on the affine seed vector. The affine vector of the sub-block may be referred to as an affine sub-block motion vector or a sub-block motion vector.

[0169] Fig.10 is a diagram showing affine vectors of sub-blocks under a 4-parameter motion model.

[0170] The affine vector of the sub-block may be derived based on the position of the control point, the position of the sub-block, and the affine seed vector. In an example, Equation 3 represents an example of deriving an affine sub-block motion vector.

[0171] [Equation 3]

[0172]

[0173] In Equation 3, (x, y) represents the position of the sub-block. In this regard, the position of the sub-block represents the position of the basic sample point included in the sub-block. The basic sample point may be a sample point located at the upper left corner of the sub-block or a sample point at the center position of at least one of the x-axis or y-axis coordinates. (x0, y0) represents the position of the first control point, and (sv0x, sv0y) represents the first affine seed vector. In addition, (x1, y1) represents the position of the second control point, and (sv1x, sv1y) represents the second affine seed vector.

[0174] When the first control point and the second control point correspond to the upper left corner and the upper right corner of the current block, respectively, x1-x0 may be set to the same value as the width of the current block.

[0175] Afterwards, motion compensation prediction of each sub-block may be performed by using the affine vector of each sub-block S804. As a result of performing the motion compensation prediction, a prediction block of each sub-block may be generated. The prediction block of the sub-block may be set as the prediction block of the current block.

[0176] The affine seed vector of the current block may be derived based on the affine seed vector of the neighboring block adjacent to the current block. When the inter prediction mode of the current block is the affine merge mode, the affine seed vector of the merge candidate included in the merge candidate list may be determined as the affine seed vector of the current block. In addition, when the inter prediction mode of the current block is the affine merge mode, motion information including at least one of the reference picture index, the specific direction prediction flag, or the bidirectional weight of the current block may be set to be the same as the merge candidate.

[0177] The merge candidate may be derived based on the neighboring blocks of the current block. The neighboring blocks may include at least one of a spatial neighboring block spatially adjacent to the current block and a temporal neighboring block included in a picture different from the current picture.

[0178] Fig.11 is a diagram showing neighboring blocks that may be used to derive merge candidates.

[0179] The neighboring blocks of the current block may include at least one of a neighboring block (A) adjacent to the left side of the current block, a neighboring block (B) adjacent to the top of the current block, a neighboring block (C) adjacent to the upper right corner of the current block, a neighboring block (D) adjacent to the lower left corner of the current block, or a neighboring block (E) adjacent to the upper left corner of the current block. When the coordinates of the upper left sample point of the current block are (x0, y0), the left neighboring block A includes a sample point at a position (x0-1, y0+H-1), and the top neighboring block B includes a sample point at a position (x0+W-1, y0-1). In this regard, W and H represent the width and height of the current block, respectively. The upper right neighboring block C includes a sample point at a position (x0+W, y0-1), and the upper left neighboring block E includes a sample point at a position (x0-1, y0-1).

[0180] When a neighboring block is encoded by an affine inter prediction mode, an affine seed vector of a merge candidate may be derived based on an affine seed vector of the corresponding neighboring block. Hereinafter, a neighboring block encoded by an affine inter prediction mode is referred to as an affine neighboring block. In addition, in an affine merge mode, a merge candidate used to derive an affine seed vector of a current block is referred to as an affine merge candidate.

[0181] By searching the neighboring blocks in a predetermined scanning order, an affine merge candidate of the current block may be generated. The scanning order may be predefined in the encoder and the decoder. In an example, the neighboring blocks may be searched in the order of A, B, C, D, and E, and the affine merge candidate may be derived sequentially from the searched affine neighboring blocks. Alternatively, the scanning order may be adaptively determined based on at least one of the size or shape or the affine motion model of the current block. In other words, the scanning order of blocks of at least one different size, shape, or affine motion model may be different from each other.

[0182] Alternatively, by sequentially searching for blocks located at the top of the current block, an affine merge candidate may be derived from the first found affine neighboring block, and by sequentially searching for blocks located at the left side of the current block, an affine merge candidate may be derived from the first found affine neighboring block. In this regard, the neighboring block located at the top of the current block may include at least one of the neighboring block E, the neighboring block B, or the neighboring block C, and the block located at the left side of the current block may include at least one of the block A or the block D. In this regard, the neighboring block E may also be classified as a block located at the left side of the current block.

[0183] Although not shown in the drawings, an affine merge candidate may be derived from a temporal neighboring block of the current block. In this regard, the temporal neighboring block may include a block at the same position as the current block or adjacent to the current block in a co-located picture. Specifically, if the temporal neighboring block of the current block is encoded by an affine inter prediction mode, the affine merge candidate may be derived based on an affine seed vector of the temporal affine merge candidate.

[0184] A merge candidate list including affine merge candidates may be generated, and an affine seed vector of one of the merge candidates included in the merge candidate list may be determined as an affine seed vector of the current block. To this end, index information identifying any one of the affine merge candidates may be encoded and transmitted in a bitstream.

[0185] In another example, neighboring blocks are searched in a scan order, and the affine seed vector of the current block may be derived from the affine seed vector of the affine neighboring block that is found first.

[0186] As above, in the affine merge mode, the affine seed vector of the current block may be derived by using the affine seed vectors of the neighboring blocks.

[0187] When the inter prediction mode of the current block is the affine motion vector prediction mode, the affine seed vector of the affine motion vector prediction candidate included in the motion vector prediction candidate list may be determined as the affine seed vector prediction value of the current block. The affine seed vector of the current block may be derived by adding the affine seed vector difference value to the affine seed vector prediction value.

[0188] Affine motion vector prediction candidates may be derived based on neighboring blocks of the current block. Specifically, neighboring blocks located at the top of the current block may be searched in a predetermined scanning order, and a first affine motion vector prediction candidate may be derived from the first found affine neighboring block. In addition, neighboring blocks located on the left side of the current block may be searched in a predetermined scanning order, and a second affine motion vector prediction candidate may be derived from the first found affine neighboring block.

[0189] Information for determining the affine seed vector difference may be encoded and transmitted in a bitstream. The information may include size information indicating the size of the affine seed vector difference and sign information indicating the sign of the affine seed vector difference. The affine seed vector difference of each control point may be set to the same value. Alternatively, the affine seed vector difference may be set differently for each control point.

[0190] As described above, the affine seed vector of the affine merging candidate or the affine motion vector prediction candidate may be derived from the affine seed vector of the affine neighboring block, and the affine seed vector of the current block may be derived by using the derived affine merging candidate or the affine motion vector prediction candidate. Alternatively, after searching the affine neighboring blocks in a predetermined scanning order, the affine seed vector of the current block may be derived from the affine seed vector of the affine neighboring block that is found first.

[0191] Hereinafter, a method for deriving an affine seed vector of an affine merge candidate or an affine motion vector prediction candidate of a current block from an affine seed vector of an affine neighboring block will be described in detail. In the embodiments described later, it can be understood that the affine seed vector of the current block is derived to correspond to the affine seed vector of the affine merge candidate or the affine seed vector of the affine motion vector prediction candidate.

[0192] Fig.12 is a diagram showing an example of deriving an affine seed vector of a current block based on affine seed vectors of affine neighboring blocks.

[0193] If a first affine seed vector nv0 for an upper left control point and a second affine seed vector nv1 for an upper right control point are stored for the affine neighboring block, a third affine seed vector nv2 for a lower left control point of the affine neighboring block may be derived based on the first affine seed vector and the second affine seed vector. Equation 4 represents an example of deriving the third affine seed vector.

[0194] [Equation 4]

[0195]

[0196] In Equation 4, (nv0x, nv0y) represents the first affine seed vector nv0, (nv1x, nv1y) represents the second affine seed vector nv1, and (nv2x, nv2y) represents the third affine seed vector nv2. In addition, (xn0, xn0) represents the position of the first control point, (xn1, xn1) represents the position of the second control point, and (xn2, xn2) represents the position of the third control point.

[0197] Afterwards, by using the first affine seed vector, the second affine seed vector and the third affine seed vector, the affine seed vector of the current block may be derived. Equation 5 represents an example of deriving the first affine seed vector sv0 of the current block, and Equation 6 represents an example of deriving the second affine seed vector sv1 of the current block.

[0198] [Equation 5]

[0199]

[0200] [Equation 6]

[0201]

[0202] In Equation 5 and Equation 6, (v0x, v0y) represents the first affine seed vector sv0 of the current block, and (v1x, v1y) represents the second affine seed vector sv1 of the current block. In addition, (x0, y0) represents the position of the first control point, and (x1, y1) represents the position of the second control point. In the example, the first control point represents the upper left corner of the current block, and the second control point represents the upper right corner of the current block.

[0203] The above example describes that the affine seed vector of the current block is derived by using 3 affine seed vectors of the affine neighboring blocks. In another example, the affine seed vector of the current block may be derived by using only 2 of the affine seed vectors of the affine neighboring blocks.

[0204] Alternatively, the affine seed vector of the current block may be derived by using the fourth affine seed vector at the lower right corner of the affine neighboring block instead of the first affine seed vector at the upper left corner, the second affine seed vector at the upper right corner, or the third affine seed vector at the lower left corner.

[0205] Specifically, when the top boundary of the current block is adjacent to the top boundary of the coding tree unit, and the affine seed vector of the top control point (e.g., the upper left corner or the upper right corner) of the affine neighboring block (hereinafter referred to as the top affine neighboring block) adjacent to the top of the current block is used, the affine seed vector should be stored in the memory in advance, which may cause the problem of increasing the number of line buffers. Therefore, when the top boundary of the current block is adjacent to the top boundary of the coding tree unit, the affine seed vector using the bottom control point (e.g., the lower left corner or the lower right corner) may be set for the top affine neighboring block instead of the affine seed vector using the top control point. In the example, the affine seed vector of the current block may be derived by using the third affine seed vector of the lower left corner and the fourth affine seed vector of the lower right corner in the top affine neighboring block. In this regard, the affine seed vector of the bottom corner may be derived by copying the affine seed vector of the top corner, or the affine seed vector of the bottom corner may be derived from the affine seed vector of the top corner. In an example, the first affine seed vector, the second affine seed vector, or the third affine seed vector may be used by converting / replacing the first affine seed vector, the second affine seed vector, or the third affine seed vector with the fourth affine seed vector in the lower right corner.

[0206] Equation 7 and Equation 8 represent examples of deriving the first affine seed vector and the second affine seed vector by using the third affine seed vector of the lower left control point and the fourth affine seed vector of the lower right control point in the affine neighboring block.

[0207] [Equation 7]

[0208]

[0209] [Equation 8]

[0210]

[0211] In Equations 7 and 8, (xn2, yn2) represents the coordinates of the lower left control point of the affine neighboring block, and (xn3, yn3) represents the coordinates of the lower right control point of the affine neighboring block. (x0, y0) represents the coordinates of the upper left control point of the current block, and (x1, y1) represents the coordinates of the upper right control point of the current block. (nv2x, nv2y) represents the affine seed vector of the lower left control point of the affine neighboring block (i.e., the third affine seed vector), and (nv3x, nv3y) represents the affine seed vector of the lower right control point of the affine neighboring block (i.e., the fourth affine seed vector). (v0x, v0y) represents the affine seed vector of the upper left control point of the current block (i.e., the first affine seed vector), and (v1x, v1y) represents the affine seed vector of the upper right control point of the current block (i.e., the second affine seed vector).

[0212] The division operation included in Equation 7 and Equation 8 may be changed into a shift operation. The shift operation may be performed based on a value derived from a width between the lower left control point and the lower right control point, ie, (xn3-xn2).

[0213] As in the above example, the affine seed vector of the current block can be derived from the affine seed vector of the affine neighboring block of the encoding / decoding. To this end, the affine seed vector of the affine neighboring block of the encoding / decoding should be stored in the memory. However, there is the following problem: since the affine seed vector of the affine neighboring block is also stored in the memory in addition to the translation motion vector (i.e., affine vector) of the sub-block included in the affine neighboring block being stored in the memory, the memory usage increases. To solve the above problem, the affine seed vector of the current block can be derived by using the motion vector of the sub-block adjacent to the control point of the affine neighboring block instead of the affine seed vector of the affine neighboring block. In other words, the affine seed vector of the current block can be derived by treating the motion vector of the sub-block adjacent to the control point of the affine neighboring block as the affine seed vector of the affine neighboring block. In this regard, the sub-block can be a block with a size / shape predefined in the encoder and the decoder, and can be a block with a basic size / shape in which the motion vector is stored. In the example, the sub-block is a square block of 4×4 size. Alternatively, the motion vector for a particular sample location may be set to an affine seed vector of an affine neighboring block.

[0214] Fig.13 is a diagram showing an example of setting a motion vector of a subblock to an affine seed vector of an affine neighboring block.

[0215] The motion vector of the sub-block adjacent to the control point can be set to the affine seed vector at the corresponding control point. Fig.13 In the example shown in , the motion vector (nv4x, nv4y) of the sub-block adjacent to the lower left corner of the affine neighboring block (lower left sub-block) may be set to the affine seed vector (nv2x, nv2y) for the lower left control point, and the motion vector (nv5x, nv5y) of the sub-block adjacent to the lower right corner (lower right sub-block) may be set to the affine seed vector (nv3x, nv3y) for the lower right control point. In this regard, the lower left sub-block may refer to a sub-block including samples adjacent to the lower left control point (xn2, yn2) in the affine neighboring block (e.g., samples at the position of (xn2, yn2-1)), and the lower right sub-block may refer to a sub-block including samples adjacent to the lower right control point (xn3, yn3) in the affine neighboring block (e.g., samples at the position of (xn3-1, yn3-1)). When the affine seed vector of the current block is derived based on Equations 7 and 8, the third affine seed vector of the affine neighboring block may be replaced by the motion vector of the lower left subblock, and the fourth affine seed vector may be replaced by the motion vector of the lower right subblock.

[0216] Hereinafter, in an embodiment described later, a sub-block used to replace an affine seed vector of an affine neighboring block is referred to as an affine sub-block.

[0217] According to an embodiment of the present disclosure, an affine sub-block may be determined based on a sample point at a specific position. In an example, a sub-block including a sample point at a specific position may be set as an affine sub-block. Hereinafter, the sample point at the specific position is referred to as an affine basic sample point. In addition, an affine basic sample point used to determine an affine sub-block at a lower left control point is referred to as a lower left basic sample point, and an affine basic sample point used to determine an affine sub-block at a lower right control point is referred to as a lower right basic sample point.

[0218] A lower left basic sample and a lower right basic sample may be selected from samples included in the affine neighboring block. In an example, at least one of an upper left sample, a lower left sample, an upper right sample, or a lower right sample of a lower left sub-block may be set as a lower left basic sample, and at least one of an upper left sample, a lower left sample, an upper right sample, or a lower right sample of a lower right sub-block may be set as a lower right basic sample. Therefore, motion vectors of a lower left sub-block including a lower left basic sample and a lower right sub-block including a lower right basic sample may be set as affine seed vectors for a lower left control point and for a lower right control point, respectively.

[0219] In another example, at least one of the lower left basic sample point or the lower right basic sample point may be set to a sample point located outside the affine neighboring block. Figures 14 to 16 Describe in detail.

[0220] Figures 14 to 16 is a diagram showing the positions of affine basic sample points.

[0221] As in Fig.14 In the example shown in (a), for the lower left control point, the upper left sample point of the lower left sub-block can be set to the affine basic sample point (xn4, yn4). Therefore, the lower left sub-block including the affine basic sample point (xn4, yn4) can be set as the affine sub-block of the lower left control point.

[0222] For the lower right control point, the sample point located to the right of the upper right sample point of the lower right sub-block may be set as the affine basic sample point (xn5, yn5). Therefore, the sub-block adjacent to the right side of the lower right sub-block and including the affine basic sample point (xn5, yn5) may be set as the affine sub-block of the lower right control point.

[0223] Optionally, as in Fig.14 In the example shown in (b), for the lower left control point, the sample point located to the left of the upper left sample point of the lower left sub-block can be set as the affine basic sample point (xn4, yn4). Therefore, the sub-block adjacent to the left side of the lower left sub-block and including the affine basic sample point (xn4, yn4) can be set as the affine sub-block of the lower left control point.

[0224] For the lower right control point, the upper right sample point of the lower right sub-block may be set as the affine basic sample point (xn5, yn5). Therefore, the lower right sub-block including the affine basic sample point (xn5, yn5) may be set as the affine sub-block of the lower right control point.

[0225] Optionally, as in Fig.15 In the example shown in (a), for the lower left control point, the lower left sample point of the lower left sub-block can be set to the affine basic sample point (xn4, yn4). Therefore, the lower left sub-block including the affine basic sample point (xn4, yn4) can be set as the affine sub-block of the lower left control point.

[0226] For the lower right control point, the sample point located to the right of the lower right sample point of the lower right sub-block may be set as the affine basic sample point (xn5, yn5). Therefore, the sub-block adjacent to the right side of the lower right sub-block and including the affine basic sample point (xn5, yn5) may be set as the affine sub-block of the lower right control point.

[0227] Optionally, as in Fig.15 In the example shown in (b), for the lower left control point, the sample point located to the left of the lower left sample point of the lower left sub-block can be set as the affine basic sample point (xn4, yn4). Therefore, the sub-block adjacent to the left side of the lower left sub-block and including the affine basic sample point (xn4, yn4) can be set as the affine sub-block of the lower left control point.

[0228] For the lower right control point, the lower right sample point of the lower right sub-block may be set as the affine basic sample point (xn5, yn5). Therefore, the lower right sub-block including the affine basic sample point (xn5, yn5) may be set as the affine sub-block of the lower right control point.

[0229] Optionally, as in Fig.16 In the example shown in (a), for the lower left control point, a sample point between the upper left sample point and the lower left sample point of the lower left sub-block (e.g., the left middle sample point) may be set as an affine basic sample point (xn4, yn4). Therefore, the lower left sub-block including the affine basic sample point (xn4, yn4) may be set as an affine sub-block of the lower left control point.

[0230] For the lower right control point, the sample point on the right side of the sample point between the upper right sample point and the lower right sample point of the lower right sub-block (e.g., the middle sample point on the right side) may be set as the affine basic sample point (xn5, yn5). Therefore, the sub-block adjacent to the right side of the lower right sub-block and including the affine basic sample point (xn5, yn5) may be set as the affine sub-block of the lower right control point.

[0231] Optionally, as in Fig.16 In the example shown in (b), for the lower left control point, the sample point on the left side of the sample point between the upper left sample point and the lower left sample point of the lower left sub-block can be set as the affine basic sample point (xn4, yn4). Therefore, the sub-block adjacent to the left side of the lower left sub-block and including the affine basic sample point (xn4, yn4) can be set as the affine sub-block of the lower left control point.

[0232] For the lower right control point, the sample point between the upper right sample point and the lower right sample point of the lower right sub-block can be set as the affine basic sample point (xn5, yn5). Therefore, the lower right sub-block including the affine basic sample point (xn5, yn5) can be set as the affine sub-block of the lower right control point.

[0233] In the case of deriving the affine seed vector of the current block based on Equations 7 and 8, the third affine seed vector of the affine neighboring block may be replaced by the motion vector of the affine sub-block of the lower left control point, and the fourth affine seed vector may be replaced by the motion vector of the affine sub-block of the lower right control point. In addition, the position of the lower left control point may be replaced by the position of the lower left basic sample point, and the position of the lower right control point may be replaced by the position of the lower right basic sample point.

[0234] and Figures 14 to 16Unlike the description in , a subblock including a sample point adjacent to an affine basic sample point may be set as an affine subblock. Specifically, a sample point located outside the affine adjacent subblock may be set as an affine basic sample point, but a subblock included in the affine adjacent block may be set as an affine subblock. Fig.14 In the example shown in (a) of FIG. 1 , the sample point located to the right of the upper right sample point of the lower right sub-block may be set as the affine basic sample point (xn5,yn5), but the lower right sub-block may be set as the affine sub-block at the lower right corner. Fig.14 In the example shown in (b), the sample point located to the left of the upper left sample point of the lower left sub-block can be set to the affine basic sample point (xn4,yn4), but the lower left sub-block can be set to the affine sub-block at the lower left corner.

[0235] The described embodiments can also be applied to Fig.15 and Fig.16 In other words, in Fig.15 (a) or Fig.16 In the example shown in (a), the sample point located at the lower right sample point or the right side of the middle sample point of the lower right sub-block can be set as the affine basic sample point (xn5,yn5), but the lower right sub-block can be set as the affine sub-block at the lower right corner. Fig.15 (b) or Fig.16 In the example shown in (b), the sample point located at the lower left sample point or the left side of the left middle sample point of the lower left sub-block can be set as the affine basic sample point (xn4,yn4), but the lower left sub-block can be set as the affine sub-block at the lower left corner.

[0236] As in the above example, the affine seed vector of the affine neighboring block can be derived by using the motion vector of the affine sub-block. To this end, for the encoded / decoded block, the motion vector can be stored in units of sub-blocks.

[0237] In another example, after storing affine seed vectors of a minimum number of affine neighboring blocks instead of storing motion vectors in units of sub-blocks, the motion vector of the affine sub-block may be derived by using the stored affine seed vectors.

[0238] Equation 9 and Equation 10 represent examples of deriving a motion vector of an affine sub-block by using an affine seed vector of an affine neighboring block.

[0239] [Equation 9]

[0240]

[0241] [Equation 10]

[0242]

[0243] In Equations 9 and 10, (nv4x, nv4y) represents the motion vector of the affine sub-block of the lower left control point, and (nv5x, nv5y) represents the motion vector of the affine sub-block of the lower right control point. Since the motion vector of the affine sub-block is set equal to the affine seed vector of the control point, (nv4x, nv4y) may be replaced by the affine seed vector (nv2x, nv2y) of the lower left control point, or (nv5x, nv5y) may be replaced by the affine seed vector (nv3x, nv3y) of the lower right control point.

[0244] (xn4,yn4) represents the position of the affine basic sample point of the lower left sub-block. Alternatively, the center position of the lower left sub-block or the position of the lower left control point may be used as an alternative. (xn5,yn5) represents the position of the affine basic sample point of the lower right sub-block. Alternatively, the center position of the lower right sub-block or the position of the lower right control point may be used as an alternative.

[0245] When the current block is not adjacent to the boundary of the coding tree unit, Equations 9 and 10 may be applied. When the current block is adjacent to the top boundary of the coding tree unit, the translation motion vector of the affine sub-block determined based on the lower left basic sample point may be set to the third affine seed vector, and the translation motion vector of the affine sub-block determined based on the lower right basic sample point may be set to the fourth affine seed vector, instead of using Equations 9 and 10.

[0246] In Equation 7 and Equation 8, (xn3-xn2) represents the width between the lower left control point and the lower right control point. As described above, xn3 may be replaced by the position of the lower right basic sample point xn5, and xn2 may be replaced by the position of the lower left basic sample point xn4. Hereinafter, the value of (xn3-xn2) or the value obtained by replacing the position shown in the equation with the position of the affine basic sample point (e.g., (xn5-xn4)) is defined as a variable Wseed, and the variable is referred to as a sub-seed vector width.

[0247] Depending on the position of the affine basic sample point, a situation where the sub-seed vector width is not a power series of 2 (e.g., 2n) may occur. In an example, when the lower left sample point of the lower left sub-block is set to the lower left basic sample point and the lower right sample point of the lower right sub-block is set to the lower right basic sample point, the sub-seed vector width is not a multiple of 2. Like this, when the sub-seed vector width is not a power series of 2, the sub-seed vector width may be converted to a power series of 2. The conversion may be performed based on adding / subtracting an offset from the sub-seed vector width or using the position of a sample point adjacent to the affine basic sample point instead of the position of the affine basic sample point. In an example, the converted sub-seed vector width may be derived by adding 1 to the width between the lower left basic sample point and the lower right basic sample point. Alternatively, the width between the adjacent sample point adjacent to the right side of the lower right basic sample point and the lower left reference sample point may be set to the converted sub-seed vector width. Thereafter, by applying the converted sub-seed vector width to Equations 7 and 8, the affine seed vector of the current block may be derived.

[0248] The division operation included in Equation 7 and Equation 8 may be changed into a shift operation. The shift operation may be performed based on a value derived from the converted sub-seed vector width (ie, a value represented by a power series of 2).

[0249] When the affine basic sample points for determining the affine sub-block are not included in the affine neighboring block, the affine seed vector of the affine neighboring block may be derived based on the sample points adjacent to the affine basic sample points among the sample points included in the affine neighboring block. Specifically, in the affine neighboring block, the translation motion vector of the sub-block including the sample points adjacent to the affine basic sample points (hereinafter, referred to as the adjacent basic sample points) may be set as the affine seed vector of the affine neighboring block. In this way, the method of deriving the affine seed vector by using the adjacent basic sample points may be defined as a method of deriving the transformed affine merged vector.

[0250] Fig.17 is a diagram illustrating an example of a method of applying an affine merging vector that derives a transformation.

[0251] When the lower right basic sample point (xn5, yn5) of the affine neighboring block E is not included in the affine neighboring block, the affine seed vector may be derived based on a sample point (xn5-1, yn5) adjacent to the left side of the lower right basic sample point among the samples included in the affine neighboring block. Specifically, the translation motion vector of the subblock including the adjacent basic sample point (xn5-1, yn5) may be set as the affine seed vector of the lower right control point.

[0252] exist Fig.17The example shown in shows that the sample point adjacent to the right side of the upper right sample point of the lower right sub-block is the lower right basic sample point. When the sample point adjacent to the right side of the lower right sample point of the lower right sub-block or the right side of the right middle sample point of the lower right sub-block is set as the lower right basic sample point, the affine seed vector can be derived based on the sample point adjacent to the left side of the adjacent basic sample point.

[0253] In addition, when the lower left basic sample point is not included in the affine neighboring block, the affine seed vector may be derived based on the sample points adjacent to the right side of the lower left basic sample point according to the described embodiment.

[0254] By setting the positions of the affine basis sample points to be different from the sub-blocks used to derive the affine seed vectors, the sub-seed vector widths can be set to a power of 2.

[0255] Alternatively, an affine seed vector may be derived by using the motion vectors of the lower left and lower right sub-blocks, but based on the width of the neighboring blocks.

[0256] Fig.18 is a diagram illustrating an example of deriving an affine seed vector of an affine merging candidate based on a motion vector of a subblock included in a neighboring block.

[0257] When the top boundary of the current block is adjacent to the boundary of the coding tree unit, an affine seed vector of the affine merging candidate may be derived based on the motion vectors of the lower left subblock and the lower right subblock in the top neighboring block located at the top of the current block. When it is assumed that the position of the upper left sample of the top neighboring block is (xNb, yNb) and the width and height of the top neighboring block are NbW and NbH, respectively, the lower left subblock may include a sample at a position (xNb, yNb+yNbH-1) and the lower right subblock may include a sample at a position (xNb+NbW-1, yNb+NbH-1).

[0258] The affine seed vector of the affine merge candidate may be derived based on the width of the neighboring block and the coordinate difference between the neighboring block and the current block. In an example, the affine seed vector of the affine merge candidate may be derived based on the following Equations 11 to 13.

[0259] [Equation 11]

[0260] v 0x =V LBx <<7+((V RBx -V LBx )<<(7-log2(NbW))*(xCb-xNb)

[0261] v 0y =V LBy <<7+((V RBy -V LBy)<<(7-log2(NbW))*(xCb-xNb)

[0262] [Equation 12]

[0263] v 1x =V LBx <<7+((V RBx -V LBx )<<(7-log2(NbW))*(xCb+xCbW-xNb)

[0264] v 1y =V LBy <<7+((V RBy -V LBy )<<(7-log2(NbW))*(xCb+xCbW-xNb)

[0265] [Equation 13]

[0266] v 2x =V LBx <<7+((V RBx -V LBx )<<(7-log2(NbW))*(xCb+xCbW-xNb)+((V LBy -V RBy )<<(7-log2(NbW))*xCbH

[0267] v 2y =V LBy <<7+((V RBy -V LBy )<<(7-log2(NbW))*(xCb+xCbW-xNb)+((V LBx -V RBx )<<(7-log2(NbW))*xCbH

[0268] In the above equations 11 to 13, (v 0x , v 0y ) represents the first affine seed vector, (v 1x , v 1y ) represents the second affine seed vector, and (v 2x , v 2y ) represents the third affine seed vector. V LBx represents the horizontal component motion vector of the lower left sub-block, and V LBx V represents the vertical component motion vector of the lower left sub-block. RBx represents the horizontal component motion vector of the lower right sub-block, and V RByrepresents the vertical component motion vector of the lower right subblock. NbW represents the width of the neighboring block, and xCbW and xCbH represent the width and height of the current block, respectively. xCb represents the x coordinate of the upper left sample point of the current block, and xNb represents the x coordinate of the upper left sample point of the neighboring block.

[0269] The affine merge candidate may be generated by combining the affine seed vector derived from the first neighboring block with the motion vector of the second neighboring block. Fig.18 In the example shown in , the third affine seed vector of the affine merge candidate may be derived based on the motion vector of the sub-block located to the left of the current block, instead of deriving the third affine seed vector of the affine merge candidate based on the motion vectors of the lower left sub-block and the lower right sub-block.

[0270] Fig.19 is a diagram illustrating an example of deriving an affine seed vector of an affine merge candidate based on a motion vector of a subblock located on the left side of a current block.

[0271] The affine seed vector of the affine merge candidate may be derived based on the motion vectors of the lower left sub-block and the lower right sub-block included in the top neighboring block located at the top of the current block. Specifically, the first affine seed vector and the second affine seed vector of the affine merge candidate may be derived based on the motion vectors of the lower left sub-block and the lower right sub-block. In the example, based on Equations 11 and 12, the first affine seed vector and the second affine seed vector of the affine merge candidate may be derived.

[0272] The third affine seed vector of the affine merge candidate may be derived based on the motion vector of the neighboring block located on the left side of the current block. In an example, the motion vector of the neighboring block adjacent to the left side of the current block or the motion vector of the neighboring block adjacent to the lower left corner of the current block may be set as the third affine seed vector. The neighboring block adjacent to the left side of the current block may include a sample at a position (xCb-1, yCb+CbH-1), and the neighboring block adjacent to the lower left of the current block may include a sample at a position (xCb-1, yCb+CbH). Equations 14 and 15 represent examples of setting the motion vector of the neighboring block located on the left side of the current block as the third affine seed vector.

[0273] [Equation 14]

[0274] v 2x =V Leftx

[0275] v 2y =V Lefty

[0276] [Equation 15]

[0277] v 2x =V LBx

[0278] v 2y =V LBy

[0279] In Equation 14, V Leftx represents the horizontal motion vector of the neighboring block adjacent to the left side of the current block, and V Lefty represents the vertical motion vector of the neighboring block adjacent to the left side of the current block. In Equation 15, V LBx represents the horizontal motion vector of the neighboring block adjacent to the lower left corner of the current block, and V LBy Indicates the vertical motion vector of the neighboring block adjacent to the lower left corner of the current block.

[0280] Only when the motion vector of the neighboring block adjacent to the left side of the current block cannot be used, the third affine seed vector may be derived by using the motion vector of the neighboring block adjacent to the lower left corner of the current block.

[0281] Depending on whether the motion vector of the neighboring block located on the left side of the current block is used, the method of deriving the third affine seed vector of the affine merge candidate can be set differently. In the example, when the motion vector of the neighboring block located on the left side of the current block (for example, the sub-block adjacent to the left side of the current block or the sub-block adjacent to the lower left corner of the current block) can be used, the third affine seed vector can be derived by using Equation 14 or Equation 15. On the other hand, when the motion vector of the neighboring block located on the left side of the current block cannot be used, the third affine seed vector can be derived by using Equation 13.

[0282] The third affine seed vector may also be derived based on the motion vector of the non-neighboring block whose basic sample is not adjacent to the current block. In order to derive the third affine seed vector, it may be determined whether to use the motion vector of the neighboring block whose basic sample is adjacent to the current block or the motion vector of the non-neighboring block whose basic sample is not adjacent to the current block based on the position of the top neighboring block used to derive the affine merge candidate.

[0283] Fig. 20 is a diagram illustrating an example of deriving an affine seed vector of an affine merging candidate based on motion information of a non-neighboring block or a neighboring block located on the left side of a current block.

[0284] By comparing the position of the upper left sample point of the top neighboring block used to derive the affine merge candidate with the position of the upper left sample point of the current block, the position of the block used to derive the third affine seed vector can be determined. Fig. 20In the example shown in (a) of FIG. 1 , when the x coordinate (xNb) of the upper left sample of the top neighboring block is less than the x coordinate (xCb) of the upper left sample of the current block, the third affine seed vector may be derived based on the motion vector of the non-neighboring block not adjacent to the left side of the current block. Specifically, the third affine seed vector may be derived based on the motion vector of the left non-neighboring block including the sample (xNb, yCb+CbH-1) having the same x coordinate as the upper left sample of the top neighboring block or the lower left non-neighboring block including the sample at the position (xNb, yCb+CbH). Equations 16 and 17 are equations showing examples of deriving the third affine seed vector based on the motion vector of the non-neighboring block.

[0285] [Equation 16]

[0286] v 2x =V Leftt2x

[0287] v 2y =V Leftt2y

[0288] [Equation 17]

[0289] v 2x =V LB2x

[0290] v 2y =V LB2y

[0291] In Equation 16, V Left2x represents the horizontal motion vector of the left non-neighboring block, and V Left2y represents the vertical motion vector of the non-neighboring block on the left. In Equation 17, V Left2y represents the horizontal motion vector of the lower left non-neighboring block, and V LB2y Indicates the vertical motion vector of the lower left non-neighboring block.

[0292] Only when the motion vector of the left non-neighboring block cannot be used, the third affine seed vector may be derived by using the motion vector of the lower left non-neighboring block.

[0293] As in Fig. 20In the example shown in (b) of FIG. 1 , when the x coordinate (xNb) of the upper left sample of the top neighboring block is equal to or greater than the x coordinate (xCb) of the upper left sample of the current block, the third affine seed vector may be derived based on the motion vector of the neighboring block adjacent to the left or lower left corner of the current block. Specifically, the third affine seed vector may be derived based on the motion vector of the left neighboring block including the sample (xCb-1, yCb+CbH-1) adjacent to the left side of the current block or the lower left neighboring block including the sample at the position (xCb-1, yCb+CbH) adjacent to the lower left corner of the current block.

[0294] Available with Figures 18 to 20 The positions of the basic samples of the left neighboring blocks or the left non-neighboring blocks are set differently from the positions of the basic samples of the left neighboring blocks or the left non-neighboring blocks shown in . In an example, a block including a sample (xCb-1, yCb+subH-1) adjacent to the current block may be set as the left neighboring block, and a block including a sample (xNb-1, yCb+subH-1) not adjacent to the current block may be set as the left non-neighboring block. In this regard, subH represents the minimum height of a block storing motion information, and it may be a natural number such as 2, 4, or 8.

[0295] Fig.21 is a diagram showing the positions of blocks used to derive affine seed vectors for affine merge candidates.

[0296] In the example, as in Fig.21 In the example shown in (a) of FIG. 18 , when the x coordinate (xNb) of the upper left sample of the top neighboring block is less than the x coordinate (xCb) of the upper left sample of the current block, the third affine seed vector may be derived based on the motion vector of the non-neighboring block not adjacent to the left side of the current block. Specifically, the third affine seed vector may be derived based on the motion vector of the left non-neighboring block including the sample (xNb, yCb+subH-1), wherein the sample (xNb, yCb+subH-1) has the same x coordinate as the upper left sample of the top neighboring block and is a predetermined distance (e.g., subH) from the lower left sample of the top neighboring block. Equation 18 is an equation showing an example of deriving the third affine seed vector based on the motion vector of the non-neighboring block.

[0297] [Equation 18]

[0298] v 2x =V LeftT2x

[0299] v 2y =V LeftT2y

[0300] In Equation 18, V LeftT2xV represents the horizontal motion vector of the left non-neighboring block including the sample point which is a predetermined distance away from the lower left sample point of the top neighboring block. LeftT2y Indicates the vertical motion vector of the left non-neighboring block including a sample that is a predetermined distance away from the lower left sample of the top neighboring block.

[0301] Optionally, as in Fig.21 In the example shown in (b), when the x coordinate (xNb) of the upper left sample of the top neighboring block is equal to or greater than the x coordinate (xCb) of the upper left sample of the current block, the third affine seed vector may be derived based on the motion vector of the left neighboring block adjacent to the left side of the current block and including a sample (xCb-1, yCb+subH-1) vertically spaced a predetermined distance (e.g., subH-1) from the upper left sample of the current block. Equation 19 is an equation showing an example of deriving the third affine seed vector based on the motion vector of the neighboring block.

[0302] [Equation 19]

[0303] v 2x =V LeftTx

[0304] v 2y =V LeftTy

[0305] In Equation 19, V LeftTx V represents the horizontal motion vector of the left neighboring block including the sample point adjacent to the left side of the current block and vertically separated by a predetermined distance from the upper left sample point of the current block. LeftTy y represents a vertical motion vector of a left neighboring block including a sample adjacent to the left side of the current block and vertically spaced a predetermined distance from an upper left sample of the current block.

[0306] Optionally, the basic sample point can be set at Figures 18 to 21 In an example, a sample (xCb-1, yCb) adjacent to the left side of the current block and having the same y coordinate as the upper left sample of the current block or a sample (xNb, yCb) not adjacent to the left side of the current block and having the same y coordinate as the upper left sample of the current block may be set as a basic sample.

[0307] As in the described example, the first affine seed vector and the second affine seed vector of the affine merge candidate may be derived from the neighboring block located at the top of the current block, and the third affine seed vector of the affine merge candidate may be derived from the neighboring block located at the left side of the current block. The first affine seed vector and the third affine seed vector of the affine merge candidate may also be derived from the neighboring block located at the left side of the current block, and the second affine seed vector of the affine merge candidate may be derived from the neighboring block located at the top of the current block.

[0308] In the examples shown in Equations 11 to 13, the motion vector V of the lower left sub-block included in the top neighboring block may be LB The motion vector V of the lower right sub-block RB The affine seed vector of the affine merge candidate is derived by using the difference between . In this regard, the affine seed vector of the affine merge candidate can be derived by using the motion vector of another block instead of the motion vector of the lower left sub-block or the lower right sub-block. In the example, when the motion vector V of the lower left sub-block in the top neighboring block is LB The motion vector V of the lower right sub-block RB When the values ​​of V are the same, V may be replaced by the motion vector of the block including the sample located on the right or bottom of the lower right sub-block. RB In an example, the motion vector V of the lower right sub-block may be replaced by using the motion vector of the block including the sample at the position (xNb+NbW, yNb+NbH-1). RB To derive the motion vectors of the affine merge candidates.

[0309] Optionally, when the motion vector V of the lower left sub-block in the top neighboring block LB and the motion vector V of the lower right sub-block RB The values ​​of V may be replaced by the motion vector of the block including the sample located at the left or bottom of the lower left sub-block. LB In an example, the motion vector V of the lower left sub-block may be replaced by using the motion vector of the block including the sample at the position (xNb, yNb+NbH-1+offset) LB To derive the motion vector of the affine merge candidate. The offset can be an integer equal to or greater than 1.

[0310] Alternatively, V may be replaced by the motion vector of the block including the sample located at the left or bottom of the lower left sub-block. RB , or V may be replaced by the motion vector of the block including the sample located at the right or bottom of the lower right sub-block. LB .

[0311] An affine merge candidate may also be derived by combining motion vectors of a plurality of neighboring blocks adjacent to the current block. An affine merge candidate generated by combining the motion vectors of the plurality of neighboring blocks may be referred to as a combined affine merge candidate. When deriving the combined affine merge candidate, an affine seed vector at the control point may be derived from one of the neighboring blocks adjacent to the control point.

[0312] Fig. 22 is a diagram for explaining an example of deriving a combined affine merging candidate by combining motion vectors of a plurality of neighboring blocks.

[0313] The plurality of neighboring blocks may include a top neighboring block located at the top of the current block and a left neighboring block located at the left of the current block. The top neighboring block may include at least one of the following: a block B0 including a sample at a position (xCb+CbW, yCb-1), a block B1 including a sample at a position (xCb+CbW-1, yCb-1), a block B2 including a sample at a position (xCb-1, yCb-1), or a block B3 including a sample at a position (xCb, yCb-1). In this regard, (xCb, yCb) represents the position of the upper left sample of the current block, and CbW represents the width of the current block. The left neighboring block may include at least one of the following: a block A0 including a sample at a position (xCb-1, yCb+CbH), a block A1 including a sample at a position (xCb-1, yCb+CbH-1), or a block A2 including a sample at a position (xCb-1, yCb). In this regard, CbH represents the height of the current block.

[0314] In addition, the plurality of neighboring blocks may further include a temporal neighboring block of the current block.

[0315] The combined affine merge candidate may be derived by combining motion information of two or more neighboring blocks among the plurality of neighboring blocks. The combined affine merge candidate may be derived by combining motion information of 2 or 3 neighboring blocks. Specifically, the combined affine merge candidate may be derived by combining at least two of the motion information of the neighboring blocks adjacent to the first control point, the motion information of the neighboring blocks adjacent to the second control point, or the motion information of the neighboring blocks adjacent to the third control point.

[0316] In an example, a combined affine merge candidate can be derived by combining motion vectors of at least two of the neighboring blocks A2, B2, or B3 adjacent to the upper left control point CP0, the neighboring blocks B1 or B0 adjacent to the upper right control point CP1, or the temporal neighboring block T of the lower left control point CP2.

[0317] In this regard, when the neighboring blocks adjacent to the control point are scanned in a predetermined scanning order, the motion vector of the available neighboring block that is found first may be set as the affine seed vector at the control point. In the example, the first affine seed vector of the combined affine merge candidate for CP0 may be set to the motion vector of the available neighboring block that is first found when the neighboring blocks are searched in the order of B2, B3, and A2. The second affine seed vector of the combined affine merge candidate of CP1 may be set to the motion vector of the available neighboring block that is first found when the neighboring blocks are searched in the order of B1 and B0. The third affine seed vector of the combined affine merge candidate of CP2 may be set to the motion vector of the available neighboring block that is first found when the neighboring blocks are searched in the order of A1 and A0.

[0318] In the process of deriving the combined affine merge candidate, a neighboring block encoded by the affine inter prediction mode or a neighboring block used to derive the affine merge candidate may be set to be unavailable.

[0319] Fig.23 is a diagram showing unavailable neighboring blocks.

[0320] When deriving an affine merging candidate from a neighboring block B1 located on top of the current block, the neighboring block B1 may be determined to be unavailable for deriving a combined affine merging candidate. Therefore, the motion vector of the neighboring block B1 may not be used to derive an affine seed vector of the combined affine merging candidate of CP1.

[0321] In another example, when the neighboring block is encoded by the affine inter prediction mode, the combined affine merge candidate may be derived based on the affine vector of the sub-block including the basic sample. In the example, when the neighboring block including the sample at the position of B1 is encoded by the affine inter prediction mode, the combined merge candidate may be derived by using the affine vector of the sub-block including the sample at the position of B1 in the neighboring block.

[0322] Optionally, the scanning order may be determined considering whether the neighboring block is encoded by the affine inter prediction mode or whether the neighboring block is derived by the affine merge candidate. In the example, the scanning order of the neighboring blocks encoded by the affine inter prediction mode or used to derive the affine merge candidate may be set last. In the example, when the neighboring block at the position B1 is encoded by the affine inter prediction mode, the second affine seed vector of the combined affine merge candidate of CP2 may be derived by searching the neighboring blocks in the order of B0 and B1.

[0323] When the reference picture index differs between neighboring blocks, the motion vector may be scaled based on the reference picture with the smallest index or the largest index. The scaling may be performed based on the difference in POC (Picture Order Count) between the reference picture and the current picture.

[0324] Alternatively, a combined affine merge candidate may be generated by combining only neighboring blocks with the same reference picture index among the neighboring blocks. In an example, when at least one of the neighboring blocks has a reference picture index different from that of other neighboring blocks, this combination may be set to be unusable as a combined affine merge candidate. In addition, the availability of the combination may be determined regardless of whether the motion information or motion vectors of the neighboring blocks are the same. In an example, even when the motion vectors of the neighboring blocks (e.g., the CP0 affine seed vector and the CP1 affine seed vector) are the same, a combined affine merge candidate may be derived by combining neighboring blocks with the same reference picture index. Alternatively, the scanning order of the neighboring blocks may be determined in consideration of the reference picture indexes of the neighboring blocks. Alternatively, a combination may be constructed by using only neighboring blocks with the same prediction direction among the neighboring blocks.

[0325] According to a preset combination order, a merge candidate may be generated. In an example, the combination order may be set as follows.

[0326] 1. {CP0 affine seed vector, CP1 affine seed vector, CP2 affine seed vector}

[0327] 2. {CP0 affine seed vector, CP1 affine seed vector, CP3 affine seed vector}

[0328] 3. {CP0 affine seed vector, CP2 affine seed vector, CP3 affine seed vector}

[0329] 4. {CP1 affine seed vector, CP2 affine seed vector, CP3 affine seed vector}

[0330] 5. {CP0 affine seed vector, CP1 affine seed vector}

[0331] 6. {CP0 affine seed vector, CP2 affine seed vector}

[0332] There are 6 combination examples, but fewer or more combination examples may also be used.

[0333] A combined affine merge candidate generated by combining 3 affine seed vectors may be referred to as a 6-parameter combined affine merge candidate, and a combined affine merge candidate generated by combining 2 affine seed vectors may be referred to as a 4-parameter combined affine merge candidate.

[0334] The combination order may be predefined in the encoder and the decoder. Optionally, the combination order may be determined based on at least one of the size, shape, partition shape or affine motion model of the current block, the position of the current block in the coding tree unit, or the POC of the reference picture. In the example, when a 4-parameter affine motion model is applied to the current block, a combination example of a 4-parameter combination affine merge candidate may be set to have a higher priority than a combination example of a 6-parameter combination affine merge candidate.

[0335] Combined affine merge candidates are generated in a combination order, but only combined affine merge candidates generated by combining neighboring blocks having the same reference picture may be set to be available. Optionally, when at least one of the neighboring blocks has different reference pictures, the combined affine merge candidate may be derived by scaling the motion vector based on the reference picture having the largest index or the smallest index. The scaling may be performed based on the POC difference between the current picture and the reference picture. Optionally, when two neighboring blocks have the same reference picture and the other neighboring blocks have different reference pictures, the combined affine merge candidate may be derived by scaling the motion vectors of the other neighboring blocks based on the reference picture commonly applied to the two neighboring blocks.

[0336] The number of combined affine merge candidates added to the affine merge candidate list may be determined based on at least one of the number of affine merge candidates previously included in the affine merge candidate list or the maximum number of affine merge candidates. Alternatively, depending on the affine motion model of the current block, only a 6-parameter combined affine merge candidate may be added to the affine merge candidate list, or only a 4-parameter combined affine merge candidate may be added to the affine merge candidate list.

[0337] In the example, when the number of combined affine merge candidates to be added to the affine merge candidate list is 1 and a 6-parameter motion model is applied to the current block, a 6-parameter combined affine merge candidate generated in a preset combination order may be added to the affine merge candidate list. Specifically, when the CP0 affine seed vector, the CP1 affine seed vector, and the CP2 affine seed vector are all available, a combined affine merge candidate consisting of {CP0 affine seed vector, CP1 affine seed vector, CP2 affine seed vector} may be added to the affine merge candidate list. Alternatively, when the CP2 affine seed vector is not available and the CP3 affine seed vector is available, a combined affine merge candidate consisting of {CP0 affine seed vector, CP1 affine seed vector, CP3 affine seed vector} may be added to the affine merge candidate list.

[0338] Optionally, when the number of combined affine merge candidates to be added to the affine merge candidate list is 1 and a 4-parameter motion model is applied to the current block, a 4-parameter combined affine merge candidate generated in a preset combination order may be added to the affine merge candidate list.

[0339] In another example, the number of combined affine merge candidates added to the affine merge candidate list may be set differently according to the affine motion model of the current block. In the example, when a 6-parameter motion model is applied to the current block, 1 combined affine merge candidate may be added to the affine merge candidate list. On the other hand, when a 4-parameter motion model is applied to the current block, 2 combined affine merge candidates may be added to the affine merge candidate list.

[0340] Based on the number of available affine merge candidates, a combined affine merge candidate for being added to the affine merge candidate list can be determined. In the example, when the number of available affine merge candidates is equal to or greater than 2, only a 4-parameter combined affine merge candidate can be added to the affine merge candidate list. On the other hand, when the number of available affine merge candidates is equal to or less than 1, only a 6-parameter combined affine merge candidate can be added to the affine merge candidate list. Optionally, when the number of available affine merge candidates is equal to or less than 1, N 6-parameter combined affine merge candidates and M 4-parameter combined affine merge candidates can be added to the affine merge candidate list. In this regard, N and M are natural numbers, and M can be derived based on the number obtained by subtracting N from the maximum number of affine merge candidates. Optionally, when the number of available affine merge candidates is equal to or less than 1, only a 4-parameter combined affine merge candidate can be added to the affine merge candidate list.

[0341] Optionally, based on the availability of the affine seed vectors, the combination order may be determined. In an example, considering the availability of the affine seed vectors, the combined affine merge candidates may be added to the merge candidate list in the following order.

[0342] 1. When CP0 affine seed vector, CP1 affine seed vector and CP2 affine seed vector are available

[0343] {CP0 affine seed vector, CP1 affine seed vector, CP2 affine seed vector}

[0344] 2. When CP0 affine seed vector, CP1 affine seed vector and CP3 affine seed vector are available

[0345] {CP0 affine seed vector, CP1 affine seed vector, CP3 affine seed vector}

[0346] 3. When CP0 affine seed vector, CP2 affine seed vector and CP3 affine seed vector are available

[0347] {CP0 affine seed vector, CP2 affine seed vector, CP3 affine seed vector}

[0348] 4. When CP1 affine seed vector, CP2 affine seed vector and CP3 affine seed vector are available

[0349] {CP1 affine seed vector, CP2 affine seed vector, CP3 affine seed vector}

[0350] 5. When CP0 affine seed vector and CP1 affine seed vector are available

[0351] {CP0 affine seed vector, CP1 affine seed vector}

[0352] 6. When CP0 affine seed vector and CP2 affine seed vector are available

[0353] {CP0 affine seed vector, CP2 affine seed vector}

[0354] When the number of combined affine merge candidates that can be added to the affine merge candidate list is 1, the combined affine merge candidate under the condition that is first satisfied among the conditions in 1 to 6 above may be added to the affine merge candidate list. When there is no case where any of the conditions 1 to 6 is satisfied, the combined affine merge candidate may not be added to the affine merge candidate list.

[0355] In another example, according to the number of available affine merge candidates, a maximum number of combined affine merge candidates that can be added to the affine merge candidate list may be determined.

[0356] When the number of affine merge candidates included in the affine merge candidate list is less than the maximum number, a zero affine merge candidate having a motion vector of 0 may be added to the merge candidate list. The zero affine merge candidate refers to a merge candidate having an affine seed vector value of 0. Therefore, the affine merge candidate may be derived in the following order in the affine merge mode.

[0357] 1. Affine merge candidates derived from affine neighboring blocks

[0358] 2. Combined affine merge candidates

[0359] 3. Zero Affine Merge Candidates

[0360] Based on the affine seed vector of the current block, a sub-block motion vector of each sub-block can be derived. Using the sub-block motion vector of each sub-block, motion compensation for each sub-block can be performed. In the process of performing motion compensation, offset data can be used in addition.

[0361] Information indicating whether the offset data will be used to perform motion compensation on the current block may be signaled in the bitstream. This information may be a 1-bit flag.

[0362] Optionally, whether to use the offset data may be determined based on the size of the current block, the shape of the current block, or whether the affine seed vectors are the same. In the example, when a 4-parameter affine motion model is applied to the current block, when the first affine seed vector is the same as the second affine seed vector, the offset data may be set to not be used. Optionally, when a 6-parameter affine motion model is applied to the current block, when the first affine seed vector, the second affine seed vector, and the third affine seed vector are all 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, the offset data may be set to not be used.

[0363] The offset data may represent an offset vector (or difference vector) or an offset vector array (or difference vector array) for the affine seed vector.

[0364] The affine seed vector of the current block may be updated by adding the offset vector to the affine seed vector or subtracting the offset vector from the affine seed vector, or the sub-block motion vector may be updated by adding the offset vector to the sub-block motion vector or subtracting the offset vector from the sub-block motion vector.

[0365] In an example, Equation 20 and Equation 21 below show examples of updating an affine seed vector.

[0366] [Equation 20]

[0367] CPMV[0].mvL0[0]=CPMV[0].mvL0[0]+f[0]

[0368] CPMV[0].mvL0[1]=CPMV[0].mvL0[1]+f[1]

[0369] CPMV[1].mvL0[0]=CPMV[1].mvL0[0]+f[0]

[0370] CPMV[1].mvL0[1]=CPMV[1].mvL0[1]+f[1]

[0371] CPMV[2].mvL0[0]=CPMV[2].mvL0[0]+f[0]

[0372] CPMV[2].mvL0[1]=CPMV[2].mvL0[1]+f[1]

[0373] [Equation 21]

[0374] CPMV[0].mvL0[0]=CPMV[0].mvL0[0]+f[0]

[0375] CPMV[0].mvL0[1]=CPMV[0].mvL0[1]-f[1]

[0376] CPMV[1].mvL0[0]=CPMV[1].mvL0[0]+f[0]

[0377] CPMV[1].mvL0[1]=CPMV[1].mvL0[1]-f[1]

[0378] CPMV[2].mvL0[0]=CPMV[2].mvL0[0]+f[0]

[0379] CPMV[2].mvL0[1]=CPMV[2].mvL0[1]-f[1]

[0380] CPMV[0], CPMV[1] and CPMV[2] represent the first affine seed vector, the second affine seed vector and the third affine seed vector, respectively. mvL0[0] and mvL0[1] represent the horizontal component of the L0 direction affine seed vector and the vertical component of the L0 direction affine seed vector, respectively. f(0) and f(1) represent the horizontal component of the offset vector and the vertical component of the offset vector, respectively.

[0381] Equation 20 and Equation 21 only represent the update aspect of the L0 direction affine seed vector, but the L1 direction affine seed vector can also be updated by the offset vector.

[0382] The affine seed vector may be updated by adding the offset vector to the affine seed vector, as in the example shown in Equation 20. Alternatively, the affine seed vector may be updated by adding the offset vector to the affine seed vector or subtracting the offset vector from the affine seed vector, as in the example shown in Equation 21.

[0383] Whether to add the offset vector to the affine seed vector or to subtract the offset vector from the affine seed vector may be determined based on at least one of the temporal direction of the L0 reference picture or the temporal direction of the L1 reference picture. In this regard, the temporal direction may be determined based on whether the POC difference between the current picture and the reference picture is positive or negative. For example, when the value obtained by subtracting the POC of the reference picture from the POC of the current picture is positive, it indicates that the temporal direction is forward, and when the value obtained by subtracting the POC of the reference picture from the POC of the current picture is negative, it indicates that the temporal direction is backward.

[0384] In an example, when the temporal direction of the L0 reference picture is the same as the temporal direction of the L1 reference picture, the affine seed vector may be updated based on Equation 20. On the other hand, when the temporal direction of the L0 reference picture is different from the temporal direction of the L1 reference picture (e.g., when the temporal direction of the L0 reference picture is forward and the temporal direction of the L1 reference picture is backward, or when the temporal direction of the L0 reference picture is backward and the temporal direction of the L1 reference picture is forward), the affine seed vector may be updated based on Equation 21.

[0385] A different offset vector may be applied for each control point. In the example, Equation 22 and Equation 23 represent an example of updating the affine seed vector by using different offset vectors.

[0386] [Equation 22]

[0387] CPMV[0].mvL0[0]=CPMV[0].mvL0[0]+f0[0]

[0388] CPMV[0].mvL0[1]=CPMV[0].mvL0[1]+f0[1]

[0389] CPMV[1].mvL0[0]=CPMV[1].mvL0[0]+f1[0]

[0390] CPMV[1].mvL0[1]=CPMV[1].mvL0[1]+f1[1]

[0391] CPMV[2].mvL0[0]=CPMV[2].mvL0[0]+f2[0]

[0392] CPMV[2].mvL0[1]=CPMV[2].mvL0[1]+f2[1]

[0393] [Equation 23]

[0394] CPMV[0].mvL0[0]=CPMV[0].mvL0[0]+f0[0]

[0395] CPMV[0].mvL0[1]=CPMV[0].mvL0[1]-f0[1]

[0396] CPMV[1].mvL0[0]=CPMV[1].mvL0[0]+f1[0]

[0397] CPMV[V].mvL0[1]=CPMV[1].mvL0[1]-f1[1]

[0398] CPMV[2].mvL0[0]=CPMV[2].mvL0[0]+f2[0]

[0399] CPMV[2].mvL0[1]=CPMV[2].mvL0[1]-f2[1]

[0400] As in the examples shown in Equations 22 and 23, the first affine seed vector CPMV[0] may be updated by the first offset vector f0, the second affine seed vector CPMV[1] may be updated by the second offset vector f1, and the third affine seed vector CPMV[2] may be updated by the third offset vector f2.

[0401] Equation 22 and Equation 23 only represent the update aspect of the L0 direction affine seed vector, but the L1 direction affine seed vector can also be updated by the offset vector.

[0402] As in the example shown in Equation 22, the affine seed vector may be updated by adding the offset vector to the affine seed vector. Alternatively, as in the example shown in Equation 23, the affine seed vector may be updated by adding the offset vector to the affine seed vector or subtracting the offset vector from the affine seed vector.

[0403] Whether to add the offset vector to the affine seed vector or to subtract the offset vector from the affine seed vector may be determined based on at least one of the temporal direction of the L0 reference picture or the temporal direction of the L1 reference picture. In an example, when the temporal direction of the L0 reference picture is the same as the temporal direction of the L1 reference picture, the affine seed vector may be updated based on Equation 22. On the other hand, when the temporal direction of the L0 reference picture is different from the temporal direction of the L1 reference picture (for example, when the temporal direction of the L0 reference picture is forward and the temporal direction of the L1 reference picture is backward, or when the temporal direction of the L0 reference picture is backward and the temporal direction of the L1 reference picture is forward), the affine seed vector may be updated based on Equation 23.

[0404] In another example, the first offset vector may be commonly applied to two of the three affine seed vectors, and the second offset vector may be applied to the other of the three affine seed vectors. For example, the first affine seed vector CPMV[0] and the second affine seed vector CPMV[1] may be updated with the first offset vector f0, and the third affine seed vector CPMV[2] may be updated with the second offset vector f1. Alternatively, the first affine seed vector CPMV[0] and the third affine seed vector CPMV[2] may be updated with the first offset vector f0, and the second affine seed vector CPMV[1] may be updated with the second offset vector f1.

[0405] In another example, the current block may be partitioned into a plurality of sub-blocks, and an offset vector may be set for each sub-block. Also, the affine seed vector of the control point may be updated by using the offset vector assigned to the sub-block adjacent to the control point.

[0406] Fig.24 is a diagram showing an example in which a current block is partitioned into 2 sub-blocks.

[0407] The current block may be partitioned into 2 sub-blocks, and an offset vector may be set for each sub-block. And then, the affine seed vector of the control point adjacent to the sub-block may be updated by using the offset vector assigned to the sub-block.

[0408] In the example, as in Fig.24In the example shown in (a), when the current block is partitioned into 2 sub-blocks by vertical lines, the first affine seed vector CPMV[0] of the first control point and the third affine seed vector CPMV[2] of the third control point adjacent to the left sub-block may be updated based on the offset vector f0 assigned to the left sub-block in the current block. On the other hand, the second affine seed vector CPMV[1] of the second control point adjacent to the right sub-block may be updated based on the offset vector f1 assigned to the right sub-block in the current block.

[0409] Optionally, as in Fig.24 In the example shown in (b), when the current block is partitioned into two sub-blocks by a horizontal line, the first affine seed vector CPMV[0] of the first control point adjacent to the top sub-block and the second affine seed vector CPMV[1] of the second control point may be updated based on the offset vector f0 assigned to the top sub-block in the current block. On the other hand, the third affine seed vector CPMV[2] of the third control point adjacent to the bottom sub-block may be updated based on the offset vector f1 assigned to the bottom sub-block in the current block.

[0410] In the process of deriving an affine merge candidate, the above method of updating an affine seed vector may be applied. In the example, after deriving an affine merge candidate from a neighboring block adjacent to the current block, the affine seed vector of the derived affine merge candidate may be updated by using an offset vector. Thereafter, the derived affine merge candidate may be replaced with the updated affine merge candidate, or the updated affine merge candidate may be added to the merge candidate list as a new affine merge candidate. When the updated affine merge candidate is used as a new affine merge candidate, the affine merge candidate may be derived in the following order.

[0411] 1. Affine merge candidates derived from affine neighboring blocks

[0412] 2. Combined affine merge candidates

[0413] 3. Affine merge candidates updated based on offset vector

[0414] 4. Zero Affine Merge Candidates

[0415] Information for determining an offset vector may be signaled in a bitstream. In an example, index information indicating any one of a plurality of offset vector candidates may be signaled in a bitstream.

[0416] The number of offset vector candidates may be 4, 8, or 16. In an example, 4 offset vector sets may be defined as follows.

[0417] {(4,0),(0,4),(-4,0),(0,-4)}

[0418] The 8 offset vector sets can be defined as follows.

[0419] {(4,0),(0,4),(-4,0),(0,-4),(8,0),(0,8),(-8,0),(0,-8)}

[0420] The 16 offset vector sets can be defined as follows.

[0421] {(4,0),(0,4),(-4,0),(0,-4),(-4,-4),(4,-4),(4,4),(-4,4),(8,0),(0,8),(-8,0),(0,-8),(-8,-8),(8,-8),(8,8),(-8,8)}

[0422] The above offset vector set lists the offset vector candidates included in the offset vector set. In this regard, in (x, y), x represents the horizontal direction component (i.e., the x-axis component) of the offset vector candidate, and y represents the vertical direction component (i.e., the y-axis component) of the offset vector candidate.

[0423] The number of offset vector candidates may be determined based on at least one of an affine motion model of the current block or the number of sub-blocks included in the current block. Optionally, information for determining the number of offset vector candidates may be signaled in a bitstream. For example, the information may specify any one of a plurality of offset vector sets.

[0424] The same offset vector may be applied to the control point. In an example, if index information specifying any one of the offset vector candidates included in the offset vector set is transmitted with a signal, all affine seed vectors may be updated based on the offset vector candidate specified by the index information.

[0425] Optionally, an offset vector may be determined for each control point. In this regard, the offset vector for each control point may be derived from a single offset vector set. In an example, if any one of a plurality of offset vector sets is specified, the offset vector for each control point may be derived from the offset vector candidates included in the specified offset vector set. To this end, index information for specifying the offset vector candidate may be signaled for each control point.

[0426] In this regard, the offset vector of each control point may not be derived from the same offset vector candidate. In the example, if the first offset vector is derived from the first offset vector candidate, the second offset vector may be derived from any one of the remaining offset vector candidates except the first offset vector candidate.

[0427] Optionally, each control point may be set to use a different offset vector set. In the example, although the offset vector is derived by using the first offset vector set {(4, 0), (0, 4), (-4, 0), (0, -4)} for the first control point, the offset vector may be derived by using the second offset vector set {(4, 4), (-4, 4), (-4, -4), (4, -4)} for the second control point.

[0428] In another example, a new offset vector may be derived by using a previously derived offset vector. In the example, if a first offset vector of a first affine seed vector and a second offset vector of a second affine seed vector are determined, a third offset vector of a third affine seed vector may be derived based on the first offset vector and the second offset vector. The following equation 24 shows an example of deriving a third offset vector based on the first offset vector and the second offset vector.

[0429] [Equation 24]

[0430] f2[0]=(f0[0]+f1[0]+1)>>1

[0431] f2[1]=(f0[1]+f1[1]+1)>>1

[0432] As in the example shown in the above Equation 24, the average value of the first offset vector and the second offset vector may be set as the third offset vector.

[0433] Alternatively, the third offset vector may be derived based on a weighted sum operation of the first offset vector and the second offset vector. In this regard, the weights applied to the first offset vector and the second offset vector may be determined based on the size or shape of the current block. The following equation 25 shows an example of deriving the third offset vector based on a weighted sum operation of the first offset vector and the second offset vector.

[0434] [Equation 25]

[0435] f2[0]=((16-whRatio)*f0[0]+whRatio*f1[0]+1)>>4

[0436] f2[1]=((16-whRatio)*f0[1]+whRatio*f1[1]+1)>>4

[0437] In Equation 25, whRatio represents the ratio of the width to the height of the current block. whRatio may be derived as in Equation 26 below.

[0438] [Equation 26]

[0439] whRatio=Abs(Log2(nCbW / nCbH))

[0440] In Equation 26, nCbW represents the width of the coding block, and nCbH represents the height of the coding block.

[0441] As in the example shown in Equation 25, the weights applied to the first offset vector f0 and the second offset vector may be determined by using a ratio of the width to the height of the current block.

[0442] The offset vector may be set for each sub-block or sample. In other words, an offset vector (or difference vector) or an offset vector array (or difference vector array) of a sub-block or sample may be defined as offset data.

[0443] For example, if the sub-block motion vector is derived based on the affine seed vector, motion compensation for the sub-block can be performed by using the derived sub-block motion vector. In this regard, an offset vector for each sub-block or sample can be additionally used when performing motion compensation.

[0444] An offset vector may be derived for each sub-block or sample.

[0445] Fig.25 A diagram showing an example of deriving an offset vector for each sub-block.

[0446] As in Fig.25 (a) and Fig.25 In the example shown in (b), when the current block is partitioned into 2 sub-blocks, an offset vector may be derived for each of the 2 sub-blocks. In the example, motion compensation for the first sub-block may be performed by using the sub-block motion vector of the first sub-block and the first offset vector f0, and motion compensation for the second sub-block may be performed by using the sub-block motion vector of the second sub-block and the second offset vector f1.

[0447] Optionally, as in Fig.25 In the example shown in (c) of FIG. 1 , when the current block is partitioned into 4 sub-blocks, an offset vector may be derived for each of the 4 sub-blocks. In the example, motion compensation for the first sub-block may be performed by using the first offset vector f0, and motion compensation for the second sub-block may be performed by using the second offset vector f1. In addition, motion compensation for the third sub-block may be performed by using the third offset vector f2, and motion compensation for the fourth sub-block may be performed by using the fourth offset vector f3.

[0448] The current block may be partitioned into more sub-blocks than shown.

[0449] The offset vector of the sub-block can be derived by using an offset vector candidate or a pre-derived offset vector. Since the method of deriving an offset vector from an offset vector candidate and the method of deriving an offset vector using a pre-derived offset vector are described in detail above, the detailed description is omitted.

[0450] Based on the offset vector, the sub-block motion vector may be updated, and based on the updated sub-block motion vector, motion compensation for the sub-block may be performed. In an example, Equation 27 and Equation 28 show an example of updating the sub-block motion vector based on the offset vector.

[0451] [Equation 27]

[0452] SubMV[0].mvL0[0]SubMV[0].mvL0[0]+f0[0]

[0453] SubMV[0].mvL0[1]SubMV[0].mvL0[1]+f0[1]

[0454] SubMV[1].mvL0[0]SubMV[1].mvL0[0]+f1[0]

[0455] SubMV[1].mvL0[1]SubMV[1].mvL0[1]+f1[1]

[0456] SubMV[2].mvL0[0]SubMV[2].mvL0[0]+f2[0]

[0457] SubMV[2].mvL0[1]SubMV[2].mvL0[1]+f2[1]

[0458] SubMV[3].mvL0[0]SubMV[3].mvL0[0]+f3[0]

[0459] SubMV[3].mvL0[1]SubMV[3].mvL0[1]+f3[1]

[0460] [Equation 28]

[0461] SubMV[0].mvL0[0]=SubMV[0].mvL0[0]+f0[0]

[0462] SubMV[0].mvL0[1]=SubMV[0].mvL0[1]-f0[1]

[0463] SubMV[1].mvL0[0]=SubMV[1].mvL0[0]+f1[0]

[0464] SubMV[1].mvL0[1]=SubMV[1].mvL0[1]-f1[1]

[0465] SubMV[2].mvL0[0]=SubMV[2].mvL0[0]+f2[0]

[0466] SubMV[2].mvL0[1]=SubMV[2].mvL0[1]-f2[1]

[0467] SubMV[3].mvL0[0]=SubMV[3].mvL0[0]+f3[0]

[0468] SubMV[3].mvL0[1]=SubMV[3].mvL0[1]-f3[1]

[0469] In Equation 27 and Equation 28, SubMV[0] represents the subblock motion vector of the first subblock, and SubMV[1] represents the subblock motion vector of the second subblock. SubMV[3] represents the subblock motion vector of the third subblock. Hereinafter, the subblock motion vector of the Nth subblock is referred to as the Nth subblock motion vector.

[0470] As in the examples shown in Equations 27 and 28, the first sub-block motion vector SubMV[0] can be updated by using the first offset vector f0, the second sub-block motion vector SubMV[1] can be updated by using the second offset vector f1, and the third sub-block motion vector SubMV[2] can be updated by using the third offset vector f2.

[0471] Equation 27 and Equation 28 only show the update aspect of the L0 direction sub-block motion vector, but the L1 direction sub-block motion vector can also be updated by the offset vector.

[0472] As in the example shown in Equation 27, the affine seed vector may be updated by adding the offset vector to the sub-block motion vector. Alternatively, as in the example shown in Equation 28, the affine seed vector may be updated by adding the offset vector to the sub-block motion vector or subtracting the offset vector from the sub-block motion vector.

[0473] Whether to add the offset vector to the affine seed vector or to subtract the offset vector from the affine seed vector may be determined based on at least one of the temporal direction of the L0 reference picture or the temporal direction of the L1 reference picture. In an example, when the temporal direction of the L0 reference picture is the same as the temporal direction of the L1 reference picture, the sub-block motion vector may be updated based on Equation 27. On the other hand, when the temporal direction of the L0 reference picture is different from the temporal direction of the L1 reference picture (e.g., when the temporal direction of the L0 reference picture is forward and the temporal direction of the L1 reference picture is backward, or when the temporal direction of the L0 reference picture is backward and the temporal direction of the L1 reference picture is forward), the sub-block motion vector may be updated based on Equation 28.

[0474] The offset vector may be derived for each prediction sample in the sub-block. Specifically, based on the position of each prediction sample in the sub-block, the offset vector of each prediction sample may be derived. In this regard, the position of the prediction sample may be determined based on the upper left sample of the sub-block.

[0475] The x component of the offset vector of the prediction sample point may 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 point 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 point. In addition, the y component of the offset vector of the prediction sample point may 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 point 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 point.

[0476] When a 4-parameter motion model is applied to the current block, the y component of the offset vector can be derived based on the 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 predicted sample point, and the 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 predicted sample point.

[0477] As described above, the offset vectors of the prediction samples in the sub-blocks may have different values ​​from each other. However, the offset vector array for the prediction samples may be commonly applied to all sub-blocks. In other words, the offset vector array applied to the first sub-block and the offset vector array applied to the second sub-block may be the same.

[0478] Alternatively, the offset vector arrays for the samples may be derived taking into account the positions of the sub-blocks. In this case, different offset vector arrays may be applied between the sub-blocks.

[0479] After performing motion compensation on the sub-block based on the sub-block motion vector, each prediction sample may be updated based on the offset vector. The prediction sample may be updated based on the offset vector of the prediction sample and the gradient of the prediction sample.

[0480] The gradient of the prediction sample may be derived based on the difference of the prediction sample. The gradient of the first prediction sample may be derived based on the difference between the prediction samples belonging to the same row as the first prediction sample or the difference between the prediction samples belonging to the row adjacent to the first prediction sample.

[0481] In an example, the gradient of the first prediction sample point may be derived by the difference between the first prediction sample point and another prediction sample point belonging to the same row as the first prediction sample point. Specifically, the horizontal direction gradient of the first prediction sample point may be derived by the difference between the first prediction sample point and the second prediction sample point belonging to the same row as the first prediction sample point, and the vertical direction gradient of the first prediction sample point may be derived by the difference between the first prediction sample point and the third prediction sample point belonging to the same column as the first prediction sample point. In this regard, the second prediction sample point and the third prediction sample point may be adjacent to the first prediction sample point. In an example, the second prediction sample point may be located on the left or right side of the first prediction sample point, and the third prediction sample point may be located at the top or bottom of the first prediction sample point. Optionally, the second prediction sample point and the third prediction sample point may be a predetermined distance from the first prediction sample point in the x-axis or y-axis direction. In this regard, the predetermined distance may be a natural number such as 1, 2, or 3.

[0482] Optionally, the difference value of the predicted sample points belonging to the row adjacent to the first predicted sample point may be set as the gradient of the first predicted sample point. In an example, the horizontal direction gradient of the first predicted sample point may be derived by the difference value of the predicted sample points belonging to the row adjacent to the first predicted sample point. In this regard, the row adjacent to the first predicted sample point may represent the top row or the bottom row of the first predicted sample point. Among the predicted samples used to derive the horizontal direction gradient of the first predicted sample point, at least one predicted sample point may be adjacent to the first predicted sample point, and the other predicted sample points may not be adjacent to the first predicted sample point. In an example, the horizontal direction gradient of the first predicted sample point may be derived based on the difference value between the second predicted sample point located at the top or bottom of the first predicted sample point and the third predicted sample point that is a predetermined distance away from the second predicted sample point in the x-axis direction. The vertical direction gradient of the first predicted sample point may be derived by the difference value of the predicted sample points belonging to the column adjacent to the first predicted sample point. In this regard, the column adjacent to the first predicted sample point may represent the left column or the right column of the first predicted sample point. Among the prediction samples used to derive the vertical gradient of the first prediction sample, at least one prediction sample may be adjacent to the first prediction sample, and the other prediction samples may not be adjacent to the first prediction sample. In an example, the vertical gradient of the first prediction sample may be derived based on a difference between a fourth prediction sample located on the left or right side of the first prediction sample and a fifth prediction sample that is a predetermined distance away from the fourth prediction sample in the y-axis direction. In this regard, the predetermined distance may be a natural number such as 1, 2, or 3.

[0483] Equation 29 shows an example of deriving the horizontal gradient gradientH and the vertical gradient gradientV of the first prediction sample.

[0484] [Equation 29]

[0485] gradientH[x][y]=(predSample[x+2][y+1]-predSample[x][y+1])>>shift1

[0486] gradientV[x][y]=(predSample[x+1][y+2]-predSample[x+1][y])>>shift1

[0487] In Equation 29, predSample represents a prediction sample, and [x][y] represents an x-axis coordinate and a y-axis coordinate. shift1 represents a shift parameter. The shift parameter may have a predefined value in an encoder and a decoder. Optionally, the shift parameter may be adaptively determined based on at least one of a size, a shape, an aspect ratio, or an affine motion model of the current block.

[0488] If the gradient of the prediction sample is derived, then the offset prediction value of the prediction sample can be derived by using the gradient and the offset vector. The offset prediction value can be derived based on the multiplication operation of the gradient and the offset vector. In an example, Equation 30 represents an example of deriving the offset prediction value OffsetPred.

[0489] [Equation 30]

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

[0491] If the offset prediction value is derived, the prediction sample can be updated by adding the offset prediction value to the prediction sample. Equation 31 represents an example of updating the prediction sample.

[0492] [Equation 31]

[0493] predSample[x][y]=predSample[x+1][y+1]+OffsetPred[x][y]

[0494] In another example, the prediction sample may be updated by adding the offset vector to the surrounding prediction samples. In this regard, the surrounding prediction samples may include at least one of a sample located to the right of the prediction sample, a sample located at the bottom of the prediction sample, or a sample located to the right below the prediction sample. In an example, Equation 32 represents an example of updating the prediction sample by using the surrounding prediction samples.

[0495] [Equation 32]

[0496] predSample[x][y]=predSample[x+1][y+1]+OffsetPred[x][y]

[0497] Information indicating whether the offset vector will be used to perform motion compensation on the current block may be signaled in the bitstream. This information may be a 1-bit flag.

[0498] Alternatively, whether to use the offset vector may be determined based on the size of the current block, the shape of the current block, or whether the affine seed vectors are the same. In the example, when a 4-parameter affine motion model is applied to the current block, if the first affine seed vector and the second affine seed vector are identical to each other, motion compensation may be performed by using the offset vector. Alternatively, when a 6-parameter affine motion model is applied to the current block, if the first affine seed vector, the second affine seed vector, and the third affine seed vector are all identical, or if two of the first affine seed vector, the second affine seed vector, and the third affine seed vector are identical, motion compensation may be performed by using the offset vector.

[0499] Next, an inter prediction method using translational motion information is described in detail.

[0500] The motion information of the current block may be derived from the motion information of another block. In this regard, the other block may be a block that is encoded / decoded by inter-frame prediction before the current block. An operation of setting the motion information of the current block to be the same as the motion information of the other block may be defined as a merge mode. In addition, an operation of setting the motion vector of the other block to a predicted value of the motion vector of the current block may be defined as a motion vector prediction mode.

[0501] Fig.26 is a flow chart of a process for deriving motion information for a current block in merge mode.

[0502] A merge candidate of the current block may be derived S2601. The merge candidate of the current block may be derived from a block encoded / decoded by inter prediction before the current block.

[0503] Fig. 27 is a diagram illustrating candidate blocks for deriving merge candidates.

[0504] The candidate block may include at least one of a neighboring block or a non-neighboring block, wherein the neighboring block includes samples adjacent to the current block and the non-neighboring block includes samples not adjacent to the current block. Hereinafter, samples used to determine the candidate block are defined as basic samples. In addition, basic samples adjacent to the current block are referred to as neighboring basic samples, and basic samples not adjacent to the current block are referred to as non-neighboring basic samples.

[0505] The neighboring basic sample points may be included in the neighboring columns of the leftmost column of the current block or the neighboring rows of the uppermost row of the current block. In an example, when the coordinates of the upper left sample point of the current block are (0,0), at least one of the blocks including the basic sample points at positions (-1,H-1), (W-1,-1), (W,-1), (-1,H) or (-1,1) may be used as a candidate block. Referring to the diagram, neighboring blocks of indexes 0 to 4 may be used as candidate blocks.

[0506] The non-neighboring basic sample points represent samples whose x-axis distance or y-axis distance to the basic sample points adjacent to the current block is a predefined value. In an example, at least one of a block including a basic sample point whose x-axis distance to the left basic sample point is a predefined value, a block including a non-neighboring sample point whose y-axis distance to the top basic sample point is a predefined value, or a block including a non-neighboring sample point whose x-axis distance and y-axis distance to the top left basic sample point are predefined values ​​may be used as a candidate block. The predefined value may be a natural number such as 4, 8, 12, 16, etc. Referring to the accompanying drawings, at least one of the blocks indexed from 5 to 26 may be used as a candidate block.

[0507] Optionally, a candidate block that does not belong to the same coding tree unit as the current block may be set to be unavailable as a merge candidate. In an example, when a base sample is outside the upper boundary of the coding tree unit to which the current block belongs, the candidate block including the base sample may be set to be unavailable as a merge candidate.

[0508] The merge candidate may be derived from a temporally neighboring block included in a picture different from the current block. In an example, the merge candidate may be derived from a co-located block included in a co-located picture. Any one of the reference pictures included in the reference picture list may be set as the co-located picture. Index information identifying the co-located picture in the reference picture may be signaled in the bitstream. Optionally, a reference picture having a predefined index in the reference picture may be determined as the co-located picture.

[0509] The motion information of the merge candidate may be set to be 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 bidirectional weight index of the candidate block may be set as the motion information of the merge candidate.

[0510] A merge candidate list including merge candidates may be generated S2602.

[0511] The indexes of the merge candidates in the merge candidate list may be assigned according to a predetermined order. In an example, the indexes may be assigned in the order of a merge candidate derived from a left neighboring block, a merge candidate derived from a top neighboring block, a merge candidate derived from an upper right neighboring block, a merge candidate derived from a lower left neighboring block, a merge candidate derived from an upper left neighboring block, and a merge candidate derived from a temporal neighboring block.

[0512] When multiple merge candidates are included in the merge candidate list, at least one of the multiple merge candidates may be selected S2603. Specifically, information for specifying any one of the multiple merge candidates may be transmitted by signal in the bitstream. In an example, information merge_idx indicating an index of any one of the merge candidates included in the merge candidate list may be transmitted by signal in the bitstream.

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

[0514] The motion information table includes motion information candidates derived from blocks encoded / decoded based on inter-frame prediction in the current picture. In an example, the motion information of the motion information candidates included in the motion information table may be set to be the same as the motion information of the blocks encoded / decoded based on inter-frame prediction. In this regard, the motion information may include at least one of a motion vector, a reference picture index, a prediction direction, or a bidirectional weight index.

[0515] The motion information candidates included in the motion information table may also be referred to as inter-region merge candidates or prediction region merge candidates.

[0516] 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 more (e.g., 16).

[0517] Optionally, information indicating a maximum number of motion information candidates that can be included in a motion information table may be signaled in a bitstream. The information may be signaled at a sequence, picture, or slice level. The information may indicate the maximum number of motion information candidates that can be included in the motion information table. Optionally, the information may indicate 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.

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

[0519] The motion information table may be initialized in units of pictures, slices, tiles, blocks, coding tree units, or coding tree unit lines (rows or columns). In an example, when a slice is initialized, the motion information table is also initialized, and thus the motion information table may not include any motion information candidates.

[0520] Optionally, information indicating whether the motion information table is to be initialized may be signaled in the bitstream. The information may be signaled at a slice, tile, block or block level. Before the information indicates initialization of the motion information table, a pre-configured motion information table may be used.

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

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

[0523] The blocks are encoded / decoded in the order of encoding / decoding, and the blocks encoded / decoded based on the inter prediction may be sequentially set as motion information candidates in the order of encoding / decoding.

[0524] Fig.28 2 is a diagram for explaining an aspect of updating a motion information table.

[0525] When inter prediction is performed on the current block S2801, a motion information candidate may be derived based on the current block S2802. The motion information of the motion information candidate may be set to be the same as the motion information of the current block.

[0526] When the motion information table is empty S2803, the motion information candidate derived based on the current block may be added to the motion information table S2804.

[0527] When the motion information table already includes motion information candidates S2803, a redundancy check S2805 on the motion information of the current block (or the motion information candidates derived based on the current block) may be performed. The redundancy check is used to determine whether the motion information of the pre-stored motion information candidates in the motion information table is the same as the motion information of the current block. The redundancy check may be performed on all pre-stored motion information candidates in the motion information table. Optionally, the redundancy check may be performed on motion information candidates having an index exceeding or below a threshold among the pre-stored motion information candidates in the motion information table. Optionally, the redundancy check may be performed on a predefined number of motion information candidates. In an example, two motion information candidates having the smallest index or having the largest index may be determined as targets of the redundancy check.

[0528] When the motion information candidate having the same motion information as the current block is not included, the motion information candidate derived based on the current block may be added to the motion information table S2808. Whether the motion information candidates are the same may be determined based on whether the motion information (e.g., motion vector / reference picture index, etc.) of the motion information candidates are the same.

[0529] In this regard, when the maximum number of motion information candidates are already stored in the motion information table S2806, the oldest motion information candidate may be deleted S2807, and the motion information candidate derived based on the current block may be added to the motion information table S2808. In this regard, the oldest motion information candidate may be a motion information candidate having a maximum or minimum index.

[0530] The motion information candidate may be identified by a corresponding index. When a motion information candidate derived from the current block is added to the motion information table, a minimum index (e.g., 0) may be assigned to the motion information candidate, and the index of the pre-stored motion information candidate may be increased by 1. In this regard, when the maximum number of motion information candidates is already stored in the motion information table, the motion information candidate with the largest index is removed.

[0531] Optionally, when adding a motion information candidate derived from the current block to the motion information table, the maximum index may 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 may be assigned to the motion information candidate. Optionally, 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 may be assigned to the motion information candidate. Optionally, the motion information candidate having the smallest index is removed, and the indexes of the remaining pre-stored motion information candidates are decreased by 1.

[0532] Fig.29 is a diagram showing aspects of updating a motion information table.

[0533] It is assumed that when a motion information candidate derived from the current block is added to the motion information table, a maximum index is assigned to the motion information candidate. In addition, it is assumed that a maximum number of motion information candidates have been stored in the motion information table.

[0534] 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 may be deleted, and the indexes of the remaining motion information candidates may be reduced by 1. In addition, the index of the motion information candidate HmvpCand[n+1] derived from the current block may be set to a maximum value (e.g., Fig.29 n) shown in .

[0535] When the same motion information candidate as the motion information candidate derived based on the current block is pre-stored S2805, the motion information candidate derived based on the current block may not be added to the motion information table S2809.

[0536] Optionally, while adding the motion information candidate derived based on the current block to the motion information table, the pre-stored motion information candidate identical to the motion information candidate may be removed. In this case, the same effect as when the index of the pre-stored motion information candidate is newly updated is produced.

[0537] Fig.30 is a diagram illustrating an example of updating an index of a pre-stored motion information candidate.

[0538] When the index of the pre-stored motion information candidate that is the same as the motion information candidate mvCand derived from the current block is hIdx, the pre-stored motion information candidate may be removed, and the index of the motion information candidate with an index greater than hIdx may be decreased by 1. In an example, Fig.30 The example shown in shows that HmvpCand[2] identical to mvCand is deleted in the motion information table HvmpCandList, and the indexes from HmvpCand[3] to HmvpCand[n] are decreased by 1.

[0539] And, the motion information candidate mvCand derived based on the current block may be added to the end of the motion information table.

[0540] Alternatively, an index assigned to the same pre-stored motion information candidate as the motion information candidate derived based on the current block may be updated. For example, the index of the pre-stored motion information candidate may be changed to a minimum value or a maximum value.

[0541] The motion information of the blocks included in the predetermined area may be set not to be added to the motion information table. In an example, the motion information candidates derived based on the motion information of the blocks included in the merge processing area may not be added to the motion information table. Since the encoding / decoding order for the blocks included in the merge processing area is not defined, it is not appropriate to use the motion information of any one of the blocks included in the merge processing area for inter-frame prediction of another block therein. Therefore, the motion information candidates derived based on the blocks included in the merge processing area may not be added to the motion information table.

[0542] Optionally, the motion information of a block smaller than a preset size may be set not to be added to the motion information table. In an example, the motion information candidate derived based on the motion information of a coding block with a width or height less than 4 or 8 or the motion information of a coding block of 4×4 size may not be added to the motion information table.

[0543] When motion compensated prediction is performed on a per-subblock basis, a motion information candidate may be derived based on motion information of a representative subblock among a plurality of subblocks included in the current block. In an example, when a subblock merge candidate is used for the current block, a motion information candidate may be derived based on motion information of a representative subblock among the subblocks.

[0544] The motion vector of the sub-block may be derived in the following order. First, any one of the merge candidates included in the merge candidate list of the current block may be selected, and an initial shift vector (shVector) may be derived based on the motion vector of the selected merge candidate. And, a shifted sub-block whose base sample is located at a position (xColSb, yColSb) may be derived by adding the initial shift vector to the position (xSb, ySb) of the base sample (e.g., the upper left sample or the center sample) of each sub-block in the coding block. The following equation 1 shows a formula for deriving a shifted sub-block.

[0545] [Equation 33]

[0546] (xColsb, ycolsb) = (xSb+shVector[o]>>4, ysb+shVector[1]>>4)

[0547] Then, a motion vector of a co-located block corresponding to a center position of a sub-block including (xColSb, yColSb) may be set as a motion vector of a sub-block including (xSb, ySb).

[0548] The representative sub-block may mean a sub-block including an upper left sample or a center sample of the current block.

[0549] Fig.31 is a diagram showing the positions of representative sub-blocks.

[0550] Fig.31 (a) shows an example of setting a sub-block located at the upper left of the current block as a representative sub-block, and Fig.31 (b) shows an example of setting a subblock located at the center of the current block as a representative subblock. When motion compensation prediction is performed based on subblocks, motion information candidates of the current block may be derived based on a motion vector of a subblock including an upper left sample of the current block or a central sample of the current block.

[0551] Based on the inter prediction mode of the current block, it may be determined whether the current block will be used as a motion information candidate. In an example, a block encoded / decoded based on an affine motion model may be set to be unusable as a motion information candidate. Therefore, 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 may not be updated based on the current block.

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

[0553] Alternatively, the motion information candidate may be derived based on an average value of affine seed vectors of blocks encoded / decoded based on an affine motion model. In an example, at least an average value of a first affine seed vector, a second affine seed vector, or a third affine seed vector of the current block may be set as a motion vector of the motion information candidate.

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

[0555] Fig.32 An example of generating a motion information table for each inter prediction mode is shown.

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

[0557] The affine seed vector of the above block may be stored in a motion information candidate derived from a block encoded / decoded based on an affine motion model. Therefore, the motion information candidate may be used as a merge candidate for deriving an affine seed vector of the current block.

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

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

[0560] Alternatively, one motion information candidate may be added to both the second motion information table and the first motion information table.

[0561] In this regard, the update of the fully populated second motion information table may no longer be performed. Alternatively, the second motion information table may be updated when the decoded area in the slice exceeds a predetermined ratio. Alternatively, the second motion information table may be updated every N coding tree unit lines.

[0562] On the other hand, whenever an encoding / decoding block is generated by inter prediction, the first motion information table may be updated. However, the motion information candidate added to the second motion information table may be set not to be used for updating the first motion information table.

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

[0564] Alternatively, the motion information table may be selected based on the size of the current block, the shape of the current block, the inter prediction mode of the current block, whether bidirectional prediction is applied to the current block, whether the motion vector is refined, or whether triangle partitioning is applied to the current block.

[0565] Alternatively, when the number of merge candidates included in the merge candidate list is less than the maximum number even if the motion information candidate included in the first motion information table is added, the motion information candidate included in the second motion information table may be added to the merge candidate list.

[0566] Fig.33 is a diagram illustrating an example of adding motion information candidates included in a long-term motion information table to a merge candidate list.

[0567] In the case where 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 may 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 if 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 may be added to the merge candidate list.

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

[0569]

Table 1

[0570]

[0571] The motion information candidate may be set to include additional information in addition to the motion information. In an example, at least one of the size, shape, or partition information of the block may be additionally stored in the motion information candidate. When configuring the merge candidate list of the current block, only the motion information candidates whose size, shape, or partition information is the same as or similar to that of the current block among the motion information candidates may be used, or the motion information candidates whose size, shape, or partition information is the same as or similar to that of the current block may be pre-added to the merge candidate list.

[0572] Alternatively, a motion information table may be generated according to each block size, shape, or partition information. The merge candidate list of the current block may be configured by using a motion information table matching the shape, size, or partition information of the current block among a plurality of motion information tables.

[0573] 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 may be added to the merge candidate list as a merge candidate. The additional processing is performed in an order reflecting the order of the indexes of the motion information candidates arranged in ascending or descending order. In an example, the motion information candidate with the largest index may be first added to the merge candidate list of the current block.

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

[0575] In an example, Table 2 shows a process of adding motion information candidates to the merge candidate list.

[0576]

Table 2

[0577]

[0578] The redundancy check may be performed only on a portion of the motion information candidates included in the motion information table. In an example, the redundancy check may be performed only on motion information candidates having an index exceeding or below a threshold. Alternatively, the redundancy check may be performed only on N motion information candidates having a maximum index or a minimum index.

[0579] Optionally, the redundancy check may be performed only on a portion of the pre-stored merge candidates in the merge candidate list. In an example, the redundancy check may be performed only on merge candidates whose index exceeds or is below a threshold or merge candidates derived from a block at a specific position. In this regard, the specific position may include at least one of a left neighboring block, a top neighboring block, an upper right neighboring block, or a lower left neighboring block of the current block.

[0580] Fig.34 is a diagram illustrating an example of performing a redundancy check on only a part of merge candidates.

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

[0582] Unlike the example shown, when adding motion information candidate HmvpCand[j] to the merge candidate list, a redundancy check with two merge candidates with the smallest index may be performed for the motion information candidate. For example, it may be checked whether mergeCandList[0] and mergeCandList[1] are the same as HmvpCand[j].

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

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

[0585] A redundancy check with a merge candidate may be performed only on a portion of the motion information candidates. In an example, a redundancy check may be performed only on N motion information candidates with large or small indexes among the motion information candidates included in the motion information table. In an example, a redundancy check may be performed only on motion information candidates with indexes whose number and difference of motion information candidates included in the motion information table are lower than a threshold. When the threshold is 2, a redundancy check may be performed only on 3 motion information candidates with the largest index value among the motion information candidates included in the motion information table. For motion information candidates other than the above 3 motion information candidates, a redundancy check may be omitted. When the redundancy check is omitted, the motion information candidate may be added to the merge candidate list regardless of whether there is the same motion information as the merge candidate.

[0586] On the contrary, the redundancy check is set to be performed only on motion information candidates having indices whose sum of the number of motion information candidates included in the motion information table exceeds a threshold value.

[0587] The number of motion information candidates for performing redundancy check may be redefined in the encoder and the decoder. In an example, the threshold may be an integer such as 0, 1, or 2.

[0588] Alternatively, the threshold may 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.

[0589] When the same merge candidate as the first motion information candidate is found, redundant checking of the same merge candidate as the first motion information candidate may be omitted in redundant checking of the second motion information candidate.

[0590] Fig.35 is a diagram illustrating an example of omitting a redundant check with a specific merge candidate.

[0591] When a motion information candidate HmvpCand[i] with an index of i is added to a merge candidate list, a redundancy check is performed between the motion information candidate and the pre-stored merge candidates in the merge candidate list. In this regard, when it is found that the merge candidate mergeCandlist[j] is the same as the motion information candidate HmvpCand[i], a redundancy check between the motion information candidate HmvpCand[i-1] (where its index is i-1) and the merge candidate may be performed without adding the motion information candidate HmvpCand[i] to the merge candidate list. In this regard, the redundancy check between the motion information candidate HmvpCand[i-1] and the merge candidate mergeCandList[j] may be omitted.

[0592] In the example, Fig.35 In the example shown, it has been determined that HmvpCand[1] is the same as mergeCandList[2]. Therefore, a redundancy check for HmvpCand[i-1] may be performed without adding HmvpCand[i] to the merge candidate list. In this regard, a redundancy check between HmvpCand[i-1] and mergeCandList[2] may be omitted.

[0593] When the number of merge candidates included in the merge candidate list of the current block is less than a threshold value, in addition to the motion information candidate, at least one of a paired merge candidate or a zero merge candidate may be further included. The paired merge candidate indicates 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 indicates a merge candidate having a motion vector of 0.

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

[0595] Spatial merging candidate - Temporal merging candidate - Motion information candidate - (affine motion information candidate) - Paired merging candidate - Zero merging candidate

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

[0597] The motion information table may 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 value, the motion information candidate included in the motion information table may be set as the motion vector prediction candidate of the current block. Specifically, the motion vector of the motion information candidate may be set as the motion vector prediction candidate.

[0598] 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 may be set as a motion vector predictor of the current block. Then, after decoding the motion vector residual value of the current block, the motion vector of the current block may be obtained by adding the motion vector predictor and the motion vector residual value.

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

[0600] Spatial motion vector prediction candidate - Temporal motion vector prediction candidate - Motion information candidate - (affine motion information candidate) - Zero motion vector prediction candidate

[0601] The spatial motion vector prediction candidate represents 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 represents a motion vector prediction candidate derived from a previous reference picture. The affine motion information candidate represents a motion information candidate derived from a block encoded / decoded by an affine motion model. The zero motion vector prediction candidate represents a candidate whose motion vector value is 0.

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

[0603] The intra prediction method includes matrix-based intra prediction and intra prediction based on the direction of adjacent reconstruction samples. Information indicating the intra prediction method of the current block can be transmitted by signal in the bit stream. The information can be a 1-bit flag. Optionally, 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 adjacent block. In the example, when the current block crosses the picture boundary, it can be set so that the matrix-based intra prediction method is not applied to the current block.

[0604] The matrix-based intra prediction method is a method for obtaining a prediction block of a current block based on the matrix product of the matrices stored in the encoder and decoder and the reconstructed samples around the current block. Information for specifying any one of a plurality of pre-stored matrices may be transmitted by signal in the bitstream. The decoder may determine the matrix for performing intra prediction on the current block based on the above information and the size of the current block.

[0605] Generally, 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.

[0606] The residual image can be derived by subtracting the predicted image from the original image. In this regard, when the residual image is converted to the frequency domain, the subjective image quality of the image will not be significantly reduced even if the high-frequency components are removed from the frequency components. Therefore, when the value of the high-frequency component is transformed to a small value, or when the value of the high-frequency component is set to 0, the compression efficiency can be improved without causing large visual distortion. Reflecting the above characteristics, a transformation can be performed on the current block so as to decompose the residual image into two-dimensional frequency components. The transformation can be performed by using a transformation method such as DCT (discrete cosine transform), DST (discrete sine transform), etc.

[0607] The transformation method may be determined based on the block. The transformation method may be determined based on at least one of the prediction coding mode for 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 less than N×N, the transformation may be performed by using a DST transformation method. On the other hand, when the above conditions are not met, the transformation may be performed by using a DCT transformation method.

[0608] For some blocks of the residual image, two-dimensional image transformation may not be performed. The operation of not performing two-dimensional image transformation may be referred to as transformation skipping. When transformation skipping is applied, quantization may be applied to the residual value on which the transformation is not performed.

[0609] After the current block is transformed by using DCT or DST, the transformed current block may be transformed again. In this regard, the transformation based on DCT or DST may be defined as a first transformation, and the operation of performing the transformation again on the block to which the first transformation is applied may be defined as a second transformation.

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

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

[0612] The processing unit of the first transform may be different from the second transform. In an example, the first transform may be performed on an 8×8 block, and the second transform may be performed on a 4×4 sized sub-block within the transformed 8×8 block. In this regard, the transform coefficients of the remaining areas where the second transform is not performed may be set to 0.

[0613] Alternatively, the first transform may be performed on a 4×4 block, and the second transform may be performed on a region having a size of 8×8 including the transformed 4×4 block.

[0614] Information indicating whether the second transform is performed may be signaled in the bitstream.

[0615] Alternatively, whether to perform the second transform may be determined based on whether the horizontal transform kernel and the vertical transform kernel are identical to each other. In an example, the second transform may be performed only when the horizontal transform kernel and the vertical transform kernel are identical to each other. Alternatively, the second transform may be performed only when the horizontal transform kernel and the vertical transform kernel are different from each other.

[0616] Optionally, the second transform may be allowed only when a predefined transform kernel is used for the horizontal direction transform and the vertical direction transform.In an example, the second transform may be allowed when a DCT2 transform kernel is used for the transform in the horizontal direction and the transform in the vertical direction.

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

[0618] The decoder may perform an inverse transform on the second transform (second inverse transform), and may perform an inverse transform on the first transform generated from 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 may be obtained.

[0619] When the encoder performs transformation and quantization, the decoder may obtain a residual block through inverse quantization and inverse transformation. The decoder may add the prediction block and the residual block to each other to obtain a reconstructed block for the current block.

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

[0621] The operation of applying the above-described embodiments of the decoding process or the encoding process to the encoding process or the decoding process, respectively, may be included in the scope of the present disclosure. Within the scope of the present disclosure, the embodiments in which the operations occur in a predetermined order may be modified to embodiments in which the operations occur in an order different from the predetermined order.

[0622] Although the above embodiments are described based on a series of operations or flow charts, the embodiments are not limited to the time sequence of the operations of the method. In another example, these operations may be performed simultaneously, or may be performed in different orders, as required. In addition, in the above embodiments, each of the components (e.g., units, modules, etc.) constituting the block diagram may be implemented in the form of a hardware device or software. Multiple components may be combined with each other into a single component that may be implemented using a single hardware device or software. The above embodiments may be implemented using program instructions that may be run via various computer components. The instructions may be recorded in a computer-readable storage medium. The computer-readable storage medium may include program instructions, data files, data structures, etc. that are separate or combined with each other. Examples of computer-readable storage media include magnetic media (such as hard disks, floppy disks, and tapes), optical storage media (such as CD-ROMs, DVDs), and magneto-optical media (such as floppy disks), and hardware devices (such as ROMs, RAMs, flash memories, etc.) that are specifically configured to store and run program instructions. The hardware device may be configured to operate as one or more software modules to perform processing according to the present disclosure, or vice versa.

[0623] [Industrial Availability]

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

Claims

1. A method for decoding a video, the method include: generating an affine merge candidate list for the current block; specifying an affine merging candidate from among a plurality of affine merging candidates included in the affine merging candidate list; Deriving an affine seed vector of the specified merge candidate; deriving a sub-block motion vector for a sub-block in the current block by using the affine seed vector, wherein the sub-block is a region smaller than the current block; deriving offset data for the sub-block; and A sub-prediction block for the sub-block is generated based on the affine vector and the offset data.

2. The method according to claim 1, in, The method comprises decoding a flag for determining whether to use the offset data from a bit stream, and Wherein, whether the offset data will be used in the process of generating the sub-prediction block is determined based on the value of the flag.

3. The method according to claim 1, in, Whether to use the offset data in generating the sub-prediction block is determined based on whether the affine seed vectors are identical to each other.

4. The method according to claim 1, in, A third prediction sample in the sub-prediction block is obtained based on the first prediction sample and the second prediction sample, wherein the first prediction sample is derived based on the affine vector, and the second prediction sample is derived based on the offset data.

5. The method according to claim 4, in, The second prediction sample point is derived based on the horizontal gradient and the vertical gradient of the first prediction sample point.

6. The method according to claim 1, in, The offset data is an array of offset vectors for each prediction sample in the sub-block.

7. A method for encoding a video, the method comprising: include: generating an affine merge candidate list for the current block; specifying an affine merging candidate from among a plurality of affine merging candidates included in the affine merging candidate list; Deriving an affine seed vector of the specified merge candidate; deriving a sub-block motion vector for a sub-block in the current block by using the affine seed vector, wherein the sub-block is a region smaller than the current block; deriving offset data for the sub-block; and A sub-prediction block for the sub-block is generated based on the affine vector and the offset data.

8. The method according to claim 7, in, The method includes encoding a flag for determining whether to use the offset data.

9. The method according to claim 7, in, Whether to use the offset data in generating the sub-prediction block is determined based on whether the affine seed vectors are identical to each other.

10. The method according to claim 7, in, A third prediction sample in the sub-prediction block is obtained based on the first prediction sample and the second prediction sample, wherein the first prediction sample is derived based on the affine vector, and the second prediction sample is derived based on the offset data.