Image encoding / decoding method and storage medium

Through motion vector correction technology, the efficiency of image encoding and decoding is improved, the problem of high-resolution image data transmission and storage costs is solved, and efficient image compression and decoding is achieved.

CN119324982APending Publication Date: 2025-01-17INTELLECTUAL DISCOVERY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411394729.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2019-03-08
Filing Date
2019-03-28
Publication Date
2025-01-17

AI Technical Summary

Technical Problem

The cost of transmission and storage of high-resolution and high-quality image data has increased, and existing image encoding technologies are difficult to effectively compress and decode, resulting in high computational complexity.

Method used

Motion vector correction technology is used to deduce the initial motion vector and the modified motion vector to generate prediction blocks, reducing the computational complexity of inter-prediction and improving image compression efficiency.

Benefits of technology

The efficiency of image encoding and decoding is improved, the computational complexity is reduced, and transmission and storage costs are reduced by optimizing the storage method of bitstreams.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119324982A_ABST
    Figure CN119324982A_ABST
Patent Text Reader

Abstract

The invention provides an image encoding / decoding method and a storage medium. The image decoding method includes: determining a prediction mode of a current block; when the prediction mode of the current block is a merge mode, deriving an initial motion vector of the current block based on a merge candidate list of the current block; deriving a corrected motion vector of the current block; deriving a final motion vector of the current block based on the initial motion vector and the corrected motion vector; obtaining a prediction block of the current block based on the final motion vector; and reconstructing the current block by adding the prediction block and the residual block, in which deriving the modified motion vector of the current block includes: determining a size of the modified motion vector based on modified motion vector size index information decoded from the bitstream; and determining a direction of the corrected motion vector based on the corrected motion vector direction index information, where the corrected motion vector size index specifies an index of one of the size candidates predefined in the decoding device.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the Chinese patent application with an application date of March 28, 2019, an international application number of PCT / KR2019 / 003642, an invention name of “Image encoding / decoding method and device and recording medium for storing bit stream”, and an application number of 201980024117.4 after entering the Chinese national phase. Technical Field

[0002] The present invention relates to an image encoding / decoding method, an image encoding / decoding device, and a recording medium storing a bit stream. In particular, the present invention relates to an image encoding / decoding method and device using a motion vector correction technology. Background Art

[0003] Recently, the demand for high-resolution and high-quality images such as high-definition (HD) images and ultra-high-definition (UHD) images has increased in various application fields. However, compared with traditional image data, higher resolution and quality image data has an increasing amount of data. Therefore, when image data is transmitted by using a medium such as a traditional wired and wireless broadband network, or when image data is stored by using a traditional storage medium, the cost of transmission and storage increases. In order to solve these problems occurring as the resolution and quality of image data increase, efficient image encoding / decoding technology is required for higher resolution and higher quality images.

[0004] The image compression technology includes various technologies, including: an inter-frame prediction technology for predicting a pixel value included in a current picture from a previous picture or a subsequent picture of the current picture; an intra-frame prediction technology for predicting a pixel value included in the current picture by using pixel information in the current picture; a transform and quantization technology for compressing the energy of a residual signal; an entropy coding technology for assigning a short code to a value with a high frequency of occurrence and a long code to a value with a low frequency of occurrence; etc. Image data can be effectively compressed by using such an image compression technology, and the image data can be transmitted or stored. Summary of the invention

[0005] Technical issues

[0006] An object of the present invention is to provide an image encoding / decoding method and apparatus capable of improving compression efficiency, and a recording medium storing a bit stream generated by the image encoding method or apparatus.

[0007] Another object of the present invention is to provide a motion vector correction method and apparatus for improving compression efficiency of inter-frame prediction, and a recording medium storing a bit stream generated by the method or apparatus.

[0008] Another object of the present invention is to provide an inter-frame prediction method and device capable of reducing computational complexity, and a recording medium storing a bit stream generated by the method or device.

[0009] Technical Solution

[0010] The method of decoding an image of the present invention may include: deriving an initial motion vector of a current block; deriving a revised motion vector by using the initial motion vector; and generating a prediction block of the current block by using the revised motion vector.

[0011] In the method for decoding an image of the present invention, the initial motion vector includes an initial L0 motion vector and an initial L1 motion vector, the corrected motion vector includes a corrected L0 motion vector and a corrected L1 motion vector, and the corrected motion vector is derived by using a merge mode-based motion vector correction method or a prediction block-based motion vector correction method.

[0012] In the method for decoding an image of the present invention, when the corrected motion vector is derived by the motion vector correction method based on the merge mode, the image decoding method further includes: entropy decoding information indicating an initial motion vector to be used in the motion vector correction method based on the merge mode.

[0013] The method for decoding an image of the present invention further includes: performing entropy decoding on the size information and direction information of the modified motion vector.

[0014] The method for decoding an image of the present invention further includes: performing entropy decoding on the size unit information of the modified motion vector, wherein the size unit of the modified motion vector refers to an integer pixel or a sub-pixel.

[0015] In the method of decoding an image of the present invention, a modified L0 motion vector is derived by adding a difference between the L0 initial motion vector and the L0 motion vector that has moved within a predetermined search area to the L0 initial motion vector.

[0016] In the method of decoding an image of the present invention, a modified L1 motion vector is derived by adding a difference between an L1 initial motion vector and an L1 motion vector moving within a predetermined search area to the L1 initial motion vector.

[0017] In the method for decoding an image of the present invention, when the POC difference between the L0 reference picture of the current block and the decoding target picture including the current block and the POC difference between the L1 reference picture and the decoding target picture including the current block are both negative values, a corrected L0 motion vector is derived by adding the difference between the L1 initial motion vector and the L1 motion vector that has moved within a predetermined search area to the L0 initial motion vector.

[0018] In the method for decoding an image of the present invention, when only one of the POC difference between the L0 reference picture of the current block and the decoding target picture including the current block and the POC difference between the L1 reference picture and the decoding target picture including the current block has a negative value, a corrected L0 motion vector is derived by mirroring the difference between the L1 initial motion vector and the L1 motion vector that has moved within a predetermined search area and adding the mirrored difference to the L0 initial motion vector.

[0019] In the method for decoding an image of the present invention, when a POC difference between an L0 reference picture of a current block and a decoding target picture including the current block and a POC difference between an L1 reference picture and a decoding target picture including the current block are different from each other, a corrected L0 motion vector is derived by scaling the difference between an L1 initial motion vector and an L1 motion vector that has moved within a predetermined search area and adding the scaled difference to the initial L0 motion vector.

[0020] In the method for decoding an image of the present invention, when a POC difference between an L0 reference picture of a current block and a decoding target picture including the current block and a POC difference between an L1 reference picture and a decoding target picture including the current block are different from each other, a corrected L1 motion vector is derived by scaling the difference between an L0 initial motion vector and an L0 motion vector that has moved within a predetermined search area and adding the scaled difference to the initial L1 motion vector.

[0021] In the method for decoding an image of the present invention, when the corrected motion vector is derived by the motion vector correction method based on the prediction block, the image decoding method further comprises: entropy decoding information indicating whether the motion vector correction method based on the prediction block is available.

[0022] In the method for decoding an image of the present invention, the motion vector correction method based on the prediction block is performed only when the current block has a bi-prediction merge mode.

[0023] In the method of decoding an image of the present invention, a motion vector correction method based on a prediction block is performed only when a POC difference between an L0 reference picture of a current block and a decoding target picture including the current block is equal to a POC difference between an L1 reference picture of the current block and a decoding target picture including the current block.

[0024] In the method of decoding an image of the present invention, the motion vector correction method based on the prediction block is performed only when the vertical size of the current block is 8 or more and the area of ​​the current block is 64 or more.

[0025] In the method for decoding an image of the present invention, the prediction block is located within a predetermined search area that falls within a predetermined distance from a pixel position indicated by the initial motion vector, and the predetermined search area is set on a per integer pixel basis and is within a range from -2 pixel positions to 2 pixel positions in both horizontal and vertical directions for the pixel position indicated by the initial motion vector.

[0026] In the method of decoding an image of the present invention, when the vertical size or the horizontal size of the current block is greater than 16, the current block is divided into 16×16 subblocks, and a motion vector correction method based on a prediction block is performed by using a prediction block based on each subblock.

[0027] In the method of decoding an image of the present invention, the corrected L0 motion vector is derived from a distortion value between a prediction block generated by using a motion vector that has moved within a predetermined search area centered on a pixel position present in an L0 reference picture and indicated by the L0 initial motion vector and a prediction block generated by using a motion vector that has moved within a predetermined search area centered on a pixel position present in an L1 reference picture and indicated by the L1 initial motion vector.

[0028] In the method of decoding an image of the present invention, the distortion value is calculated by one or more operations selected from the sum of absolute differences (SAD), the sum of absolute transform differences (SATD), the sum of squared errors (SSE) and the mean square error (MSE).

[0029] In the method of encoding an image of the present invention, it may include: deriving an initial motion vector of a current block; deriving a modified motion vector by using the initial motion vector; and entropy encoding motion compensation information of the current block using the modified motion vector.

[0030] In the non-temporary storage medium of the present invention, a bit stream generated by an image encoding method is included, wherein the image encoding method includes: deriving an initial motion vector of a current block; deriving a modified motion vector by using the initial motion vector; and entropy encoding motion compensation information of the current block using the modified motion vector.

[0031] The image decoding method according to the present invention includes: determining a prediction mode of a current block; when the prediction mode of the current block is a merge mode, deriving an initial motion vector of the current block based on a merge candidate list of the current block; deriving a revised motion vector of the current block; deriving a final motion vector of the current block based on the initial motion vector and the revised motion vector; obtaining a prediction block of the current block based on the final motion vector; and reconstructing the current block by adding the prediction block to a residual block, wherein deriving the revised motion vector of the current block includes: determining a size of the revised motion vector based on revised motion vector size index information decoded from a bitstream; and determining a direction of the revised motion vector based on revised motion vector direction index information, wherein the revised motion vector size index specifies an index of one of size candidates predefined in a decoding device, and wherein the size of the revised motion vector is determined by shifting the size candidate specified by the revised motion vector size index.

[0032] The image encoding method according to the present invention includes: when the prediction mode of the current block is the merge mode, deriving the initial motion vector of the current block based on the merge candidate list of the current block; deriving the revised motion vector of the current block; deriving the final motion vector of the current block based on the initial motion vector and the revised motion vector; obtaining the prediction block of the current block based on the final motion vector; and obtaining the residual block of the current block by subtracting the prediction block from the original block, wherein the method also includes: encoding revised motion vector size index information of the revised motion vector; and encoding revised motion vector direction information of the revised motion vector, wherein the revised motion vector size index information specifies the index of a size candidate among the size candidates predefined in the encoding device, and wherein the size of the revised motion vector is the same as the value obtained by shifting the size candidate specified by the revised motion vector size index.

[0033] According to the present invention, a non-volatile storage medium containing a bit stream generated by an image encoding method is also provided, the method comprising: when the prediction mode of the current block is a merge mode, deriving an initial motion vector of the current block based on a merge candidate list of the current block; deriving a revised motion vector of the current block; deriving a final motion vector of the current block based on the initial motion vector and the revised motion vector; and obtaining a prediction block of the current block based on the final motion vector, wherein the method further comprises: encoding revised motion vector size index information of the revised motion vector; and encoding revised motion vector direction information of the revised motion vector, wherein the revised motion vector size index information specifies an index of a size candidate among size candidates predefined in the encoding device, and wherein the size of the revised motion vector is the same as a value obtained by shifting the size candidate specified by the revised motion vector size index.

[0034] Beneficial Effects

[0035] According to the present invention, an image encoding / decoding method and apparatus capable of improving the efficiency of image compression, and a recording medium storing a bit stream generated by the image encoding / decoding method or apparatus can be provided.

[0036] According to the present invention, a motion vector correction method and apparatus for improving compression efficiency through inter-frame prediction and a recording medium storing a bit stream generated by the method or apparatus can be provided.

[0037] According to the present invention, an inter-frame prediction method and apparatus capable of reducing computational complexity and a recording medium storing a bit stream generated by the method or apparatus can be provided. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 is a block diagram showing a configuration of an encoding device according to an embodiment to which the present invention is applied.

[0039] Figure 2 is a block diagram showing a configuration of a decoding device according to an embodiment to which the present invention is applied.

[0040] Figure 3 is a diagram schematically showing a partition structure of an image when the image is encoded and decoded.

[0041] Figure 4 is a diagram illustrating an inter-frame prediction process.

[0042] Figure 5 is a flowchart illustrating an image encoding method according to an embodiment of the present invention;

[0043] Figure 6 is a flowchart illustrating an image decoding method according to an embodiment of the present invention;

[0044] Figure 7 is a diagram illustrating an exemplary method of deriving a spatial merging candidate and a temporal merging candidate for a current block;

[0045] Figure 8 is a flow chart showing a motion vector correction method according to an embodiment of the present invention;

[0046] Fig. 9 is a diagram showing spatial neighboring blocks and temporal neighboring blocks used to construct an additional merge candidate list;

[0047] Fig.10 is a diagram showing a motion vector correction method using a motion estimation area;

[0048] Fig.11 and Fig.12 is a diagram showing a method of constructing an initial motion vector list;

[0049] Fig.13 is a diagram showing a method of deriving an initial motion vector using merge index information;

[0050] Fig.14 is a diagram showing a method of mirroring a motion vector;

[0051] Fig.15 is a diagram showing a method of scaling a motion vector;

[0052] Fig.16 is a diagram showing a method of deriving an additional motion vector when a bidirectionally predictable block has a motion vector belonging to only one of lists L0 and L1;

[0053] Fig.17 is a diagram showing a method of selecting a merge candidate having bidirectional motion information as an initial motion vector in a bidirectionally predictable block;

[0054] Figures 18 to 23 is a diagram showing a template to be used in some embodiments of the present invention;

[0055] Fig.24 is a diagram showing a template construction process taking into account a motion estimation area;

[0056] Fig.25 is a diagram showing a template composed of reconstructed pixel values ​​that are not filtered by the in-loop filter;

[0057] Fig.26 is a diagram showing a template composed of predicted pixel values ​​in neighboring blocks and reconstructed transform coefficient DC component values;

[0058] Fig. 27 is a diagram showing an example of template size;

[0059] Figure 28 to Figure 31 is a diagram illustrating a template construction method based on interpolation according to various embodiments of the present invention;

[0060] Fig.32 is a diagram showing a method of correcting an initial motion vector using a template;

[0061] Fig.33 is a diagram showing a distortion cost calculation method based on a distortion cost;

[0062] Fig.34 is a diagram showing the range of a search area for searching a corrected motion vector;

[0063] Fig.35 is a diagram showing a method of searching for a motion vector by changing a unit size of a motion vector offset;

[0064] Figure 36 to Figure 38 is a diagram showing a method of correcting an initial motion vector;

[0065] Fig.39 and Fig.40 is a diagram showing sub-blocks into which a current block may be divided;

[0066] Fig.41 is a diagram illustrating a method of setting an initial motion vector for correction of a motion vector on a per-subblock basis; and

[0067] Fig.42 is a flowchart illustrating an image decoding method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0068] The present invention may be modified in various ways, and there are various embodiments of the present invention, wherein examples of the various embodiments will now be provided and described in detail with reference to the accompanying drawings. However, although the exemplary embodiments may be interpreted as including all modifications, equivalents or substitutions within the technical concept and technical scope of the present invention, the present invention is not limited thereto. Similar figure numerals refer to the same or similar functions in various aspects. In the accompanying drawings, the shapes and sizes of the elements may be exaggerated for clarity. In the following detailed description of the present invention, reference is made to the accompanying drawings showing specific embodiments in which the present invention can be practiced by way of illustration. These embodiments are described in sufficient detail to enable those skilled in the art to implement the present disclosure. It should be understood that the various embodiments of the present disclosure, although different, do not necessarily exclude each other. For example, without departing from the spirit and scope of the present disclosure, the specific features, structures and characteristics described herein in conjunction with one embodiment may be implemented in other embodiments. In addition, it should be understood that the position or arrangement of each element within each disclosed embodiment may be modified without departing from the spirit and scope of the present disclosure. Therefore, the following detailed description should not be considered as limiting, and the scope of the present disclosure is limited only by the full range of the appended claims and the equivalents claimed by the claims, which are properly interpreted.

[0069] The terms "first", "second", etc. used in the specification may be used to describe various components, but the components should not be interpreted as limited to the terms. The terms are only used to distinguish one component from other components. For example, without departing from the scope of the present invention, the "first" component may be referred to as the "second" component, and the "second" component may also be similarly referred to as the "first" component. The term "and / or" includes a combination of multiple items or any one of the multiple terms.

[0070] It will be understood that when an element is simply referred to as being “connected to” or “coupled to” another element in this specification rather than being “directly connected to” or “directly coupled to” another element, it may be “directly connected to” or “directly coupled to” another element, or connected to or coupled to another element with other elements interposed therebetween. Conversely, it will be understood that when an element is referred to as being “directly coupled to” or “directly connected to” another element, there are no intervening elements.

[0071] In addition, the components shown in the embodiments of the present invention are shown independently to represent the characteristic functions that are different from each other. Therefore, this does not mean that each component is constituted with separated hardware or software as a constituent unit. In other words, for convenience, each component includes each of the listed components. Therefore, at least two components in each component can be combined to form a component, or a component can be divided into multiple components to perform each function. Without departing from the essence of the present invention, the embodiments in which each component is combined and the embodiments in which a component is divided are also included in the scope of the present invention.

[0072] The terms used in this specification are only used to describe specific embodiments and are not intended to limit the present invention. Expressions used in the singular form cover expressions in the plural form unless it has a significantly different meaning in the context. In this specification, it is to be understood that terms such as "including", "having" and the like are intended to indicate the existence of features, numbers, steps, actions, elements, parts or combinations thereof disclosed in the specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, actions, elements, parts or combinations thereof may exist or may be added. In other words, when a particular element is referred to as "included", elements other than the corresponding element are not excluded, but additional elements may be included in embodiments of the present invention or in the scope of the present invention.

[0073] In addition, some components may not be indispensable components for performing the necessary functions of the present invention, but selective components that only improve the performance thereof. The present invention may be realized by only including the indispensable constituent parts for realizing the essence of the present invention except the components for improving the performance. A structure including only the indispensable components except the selective components for only improving the performance is also included in the scope of the present invention.

[0074] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings. When describing the exemplary embodiments of the present invention, well-known functions or structures may unnecessarily obscure the understanding of the present invention, so well-known functions or structures will not be described in detail. The same constituent elements in the accompanying drawings are represented by the same reference numerals, and repeated descriptions of the same elements will be omitted.

[0075] Hereinafter, an image may refer to a picture constituting a video, or may refer to a video itself. For example, "encoding or decoding of an image, or both encoding and decoding" may refer to "encoding or decoding of a moving picture, or both encoding and decoding", and may refer to "encoding or decoding of one image among a plurality of images of a moving picture, or both encoding and decoding".

[0076] Hereinafter, the terms "motion picture" and "video" may be used as the same meaning and replaced with each other.

[0077] Hereinafter, a target image may be an encoding target image as a target of encoding and / or a decoding target image as a target of decoding. In addition, the target image may be an input image input to an encoding device and an input image input to a decoding device. Here, the target image may have the same meaning as the current image.

[0078] Hereinafter, the terms "image", "picture", "frame" and "screen" may be used as the same meaning and replaced with each other.

[0079] Hereinafter, the target block may be an encoding target block as a target of encoding and / or a decoding target block as a target of decoding. In addition, the target block may be a current block as a target of current encoding and / or decoding. For example, the terms "target block" and "current block" may be used as the same meaning and may be replaced with each other.

[0080] Hereinafter, the terms "block" and "unit" may be used as the same meaning and replaced with each other. Alternatively, a "block" may refer to a specific unit.

[0081] In the following, the terms "region" and "segment" may be used interchangeably.

[0082] Hereinafter, a specific signal may be a signal representing a specific block. For example, an original signal may be a signal representing a target block. A prediction signal may be a signal representing a prediction block. A residual signal may be a signal representing a residual block.

[0083] In an embodiment, each of the specific information, data, flags, indexes, elements, attributes, etc. may have a value. The value of the information, data, flags, indexes, elements, and attributes equal to "0" may represent a logical false or a first predefined value. In other words, the value "0", false, logical false, and the first predefined value may be replaced with each other. The value of the information, data, flags, indexes, elements, and attributes equal to "1" may represent a logical true or a second predefined value. In other words, the value "1", true, logical true, and the second predefined value may be replaced with each other.

[0084] When the variable i or j is used to represent a column, a row, or an index, the value of i may be an integer equal to or greater than 0 or equal to or greater than 1. That is, the column, row, index, etc. may be counted from 0 or may be counted from 1.

[0085] Description of terms

[0086] Encoder: This refers to the device that performs encoding. In other words, it refers to the encoding device.

[0087] Decoder: refers to a device that performs decoding. In other words, it refers to a decoding device.

[0088] Block: is an M×N array of samples. Here, M and N may represent positive integers, and a block may represent an array of samples in a two-dimensional form. A block may refer to a unit. A current block may represent an encoding target block that becomes a target at the time of encoding, or a decoding target block that becomes a target at the time of decoding. In addition, the current block may be at least one of a coding block, a prediction block, a residual block, and a transform block.

[0089] Sample: It is the basic unit of a block. Samples can be expressed from 0 to 2 according to the bit depth (Bd). Bd In the present invention, a sample point may be used as the meaning of a pixel. That is, a sample point, a pel, and a pixel may have the same meaning as each other.

[0090] Unit: may refer to a coding unit and a decoding unit. When encoding and decoding an image, a unit may be a region generated by partitioning a single image. In addition, when a single image is partitioned into sub-division units during encoding or decoding, a unit may represent a sub-division unit. That is, an image may be partitioned into a plurality of units. When encoding and decoding an image, a predetermined process for each unit may be performed. A single unit may be partitioned into sub-units having a size smaller than that of the unit. According to the function, a unit may represent a block, a macroblock, a coding tree unit, a coding tree block, a coding unit, a coding block, a prediction unit, a prediction block, a residual unit, a residual block, a transform unit, a transform block, and the like. In addition, in order to distinguish a unit from a block, a unit may include a luminance component block, a chrominance component block associated with the luminance component block, and a syntax element for each color component block. A unit may have various sizes and forms, and in particular, the form of a unit may be a two-dimensional geometric figure such as a square shape, a rectangular shape, a trapezoidal shape, a triangular shape, a pentagonal shape, and the like. Also, the unit information may include at least one of a unit type indicating a coding unit, a prediction unit, a transformation unit, etc., and a unit size, a unit depth, an order of encoding and decoding of the unit, and the like.

[0091] Coding tree unit: A single coding tree block configured with a luminance component Y and two coding tree blocks associated with chrominance components Cb and Cr. In addition, the coding tree unit may represent a syntax element including a block and each block. Each coding tree unit may be partitioned by using at least one of a quadtree partitioning method, a binary tree partitioning method, a ternary tree partitioning method, etc. to configure a lower-level unit such as a coding unit, a prediction unit, a transform unit, etc. The coding tree unit may be used as a term for specifying a sample block that becomes a processing unit when encoding / decoding an image as an input image. Here, the quadtree may represent a quadtree.

[0092] When the size of the coding block falls within the first predetermined range, only quadtree partitioning is allowed for the coding block. Here, the first predetermined range may be defined by at least one of the maximum size and the minimum size of the coding block that can be partitioned only by quadtree partitioning. Information indicating the maximum / minimum size of the coding block that allows quadtree partitioning may be signaled as data included in the bitstream, and the information may be signaled in units of at least one of a sequence, a picture parameter, a parallel block group, and a slice (fragment). Optionally, the maximum / minimum size of the coding block may be a fixed size preset in the encoder / decoder. For example, when the size of the coding block is in the range from 64×64 to 256×256, the coding block may be partitioned only by quadtree partitioning. Optionally, when the size of the coding block is greater than the maximum size of the transform block (TB), the coding block may be partitioned only by quadtree partitioning. In this case, the block to be partitioned into four quadrants may be a coding block or a transform block. In this case, the information indicating the quadtree partition of the coding block (e.g., split_flag) may be a flag indicating whether the coding unit is partitioned by quadtree partitioning. When the size of the coding block falls within the second predetermined range, the coding block may be partitioned only by binary tree partitioning or ternary tree partitioning. In this case, the above description of quadtree partitioning may also be applied to binary tree partitioning or ternary tree partitioning.

[0093] Coding tree block: may be used as a term for designating any one of a Y coding tree block, a Cb coding tree block, and a Cr coding tree block.

[0094] Neighboring block: may refer to a block adjacent to the current block. The block adjacent to the current block may refer to a block that touches the boundary of the current block or a block that is within a predetermined distance from the current block. The neighboring block may refer to a block adjacent to a vertex of the current block. Here, the block adjacent to a vertex of the current block may refer to a block that is vertically adjacent to a neighboring block that is horizontally adjacent to the current block or a block that is horizontally adjacent to a neighboring block that is vertically adjacent to the current block.

[0095] Reconstructed neighboring block: may refer to a neighboring block that is adjacent to the current block and has been encoded or decoded in space / time. Here, the reconstructed neighboring block may refer to a reconstructed neighboring unit. The reconstructed spatial neighboring block may be a block within the current picture that has been reconstructed by encoding or decoding or both encoding and decoding. The reconstructed temporal neighboring block is a block at a position corresponding to the current block of the current picture within the reference image or a neighboring block of the block.

[0096] Unit depth: can represent the degree of partitioning of a unit. In a tree structure, the highest node (root node) can correspond to the first unit that is not partitioned. In addition, the highest node can have a minimum depth value. In this case, the highest node can have a depth of level 0. A node with a depth of level 1 can represent a unit generated by partitioning the first unit once. A node with a depth of level 2 can represent a unit generated by partitioning the first unit twice. A node with a depth of level n can represent a unit generated by partitioning the first unit n times. A leaf node can be the lowest node and a node that cannot be further partitioned. The depth of a leaf node can be the maximum level. For example, the predefined value of the maximum level can be 3. The depth of the root node can be the lowest, and the depth of the leaf node can be the deepest. In addition, when a unit is expressed as a tree structure, the level at which the unit is located can represent the unit depth.

[0097] Bitstream: can represent a stream of bits including coded image information.

[0098] Parameter set: corresponds to header information in the configuration within the bitstream. At least one of a video parameter set, a sequence parameter set, a picture parameter set, and an adaptation parameter set may be included in the parameter set. In addition, the parameter set may include a parallel block group, a slice header, and parallel block header information. In addition, a parallel block group may represent a group including a plurality of parallel blocks, and may have the same meaning as a slice.

[0099] Parsing: may mean determining the value of a syntax element by performing entropy decoding, or may mean the entropy decoding itself.

[0100] Symbol: At least one of a syntax element, a coding parameter, and a transform coefficient value that can represent a coding / decoding target unit. In addition, the symbol can represent an entropy coding target or an entropy decoding result.

[0101] Prediction mode: may be information indicating a mode of encoding / decoding using intra-frame prediction or a mode of encoding / decoding using inter-frame prediction.

[0102] Prediction unit: may represent a basic unit when performing prediction (such as inter prediction, intra prediction, inter compensation, intra compensation, and motion compensation). A single prediction unit may be partitioned into multiple partitions of smaller size, or may be partitioned into multiple prediction units of lower levels. Multiple partitions may be basic units when performing prediction or compensation. Partitions generated by splitting a prediction unit may also be prediction units.

[0103] Prediction unit partition: may represent a form obtained by partitioning a prediction unit.

[0104] Reference picture list: may refer to a list including one or more reference pictures used for inter-picture prediction or motion compensation. LC (List Combination), L0 (List 0), L1 (List 1), L2 (List 2), L3 (List 3), etc. are various types of reference picture lists. One or more reference picture lists may be used for inter-picture prediction.

[0105] Inter-picture prediction indicator: may indicate the inter-picture prediction direction (unidirectional prediction, bidirectional prediction, etc.) of the current block. Optionally, the inter-picture prediction indicator may indicate the number of reference pictures used to generate the prediction block of the current block. Also optionally, the inter-picture prediction indicator may indicate the number of prediction blocks used to perform inter-picture prediction or motion compensation for the current block.

[0106] Prediction list utilization flag: may indicate whether at least one reference image included in a specific reference picture list is used to generate a prediction block. The prediction list utilization flag may be used to derive an inter-prediction indicator, and conversely, the prediction list utilization flag may be used to derive an inter-prediction indicator. For example, when the prediction list utilization flag indicates a first value of "0", this indicates that a reference picture included in the corresponding reference picture list is not used to generate a prediction block. When the prediction list utilization flag indicates a second value of "1", this indicates that a reference picture included in the corresponding reference picture list is used to generate a prediction block.

[0107] Reference picture index: may represent an index indicating a specific reference picture in a reference picture list.

[0108] Reference picture: may refer to a picture referenced by a specific block for inter-picture prediction or motion compensation. Alternatively, the reference picture may be a picture including a reference block referenced by the current block for inter-frame prediction or motion compensation. Hereinafter, the terms "reference picture" and "reference image" may be used as the same meaning and may be used interchangeably.

[0109] Motion vector: is a two-dimensional vector used for inter-picture prediction or motion compensation, and may represent the offset between a reference picture and an encoding / decoding target picture. For example, (mvX, mvY) may represent a motion vector, mvX may represent a horizontal component, and mvY may represent a vertical component.

[0110] Search range: may be a 2-dimensional area in which a motion vector is searched during inter prediction. For example, the size of the search range may be M×N. M and N may be positive integers, respectively.

[0111] Motion vector candidate: may indicate a block that becomes a prediction candidate when predicting a motion vector, or a motion vector of the block. The motion vector candidates may be listed in the motion vector candidate list.

[0112] Motion vector candidate list: may represent a list configured using one or more motion vector candidates.

[0113] Motion vector candidate index: represents an indicator indicating a motion vector candidate in a motion vector candidate list. The motion vector candidate index is also called an index of a motion vector predictor.

[0114] Motion information: may refer to information including at least any one of reference picture list information, reference picture, motion vector candidate, motion vector candidate index, merge candidate and merge index, as well as motion vector, reference picture index, and inter-picture prediction indicator.

[0115] Merge candidate list: may represent a list consisting of merge candidates.

[0116] Merge candidate: may refer to a spatial merge candidate, a temporal merge candidate, a combined merge candidate, a combined bi-predictive merge candidate, a zero merge candidate, etc. The merge candidate may have an inter-picture prediction indicator, a reference picture index for each list, and motion information such as a motion vector.

[0117] Merge index: may represent an indicator indicating a merge candidate in a merge candidate list. The merge index may indicate a block used to derive a merge candidate in a reconstructed block that is spatially and / or temporally adjacent to the current block. The merge index may indicate at least one item of motion information that the merge candidate has.

[0118] Transform unit: may represent a basic unit when performing encoding / decoding (such as transformation, inverse transformation, quantization, inverse quantization, and transformation coefficient encoding / decoding of a residual signal). A single transform unit may be partitioned into a plurality of lower-level transform units having a smaller size. Here, the transform / inverse transform may include at least one of a primary transform / primary inverse transform and a secondary transform / secondary inverse transform.

[0119] Scaling: may refer to the process of multiplying the level of quantization by a factor. Transform coefficients may be generated by scaling the level of quantization. Scaling may also be referred to as inverse quantization.

[0120] Quantization parameter: may represent a value used when a transform coefficient is used to generate a quantized level during quantization. The quantization parameter may also represent a value used when a transform coefficient is generated by scaling the quantized level during inverse quantization. The quantization parameter may be a value mapped on a quantization step size.

[0121] Delta quantization parameter: may represent the difference between the predicted quantization parameter and the quantization parameter of the encoding / decoding target unit.

[0122] Scan: may refer to a method of ordering coefficients within a cell, block, or matrix. For example, changing a two-dimensional matrix of coefficients to a one-dimensional matrix may be referred to as scanning, and changing a one-dimensional matrix of coefficients to a two-dimensional matrix may be referred to as scanning or inverse scanning.

[0123] Transform coefficient: may refer to a coefficient value generated after performing a transform in an encoder. Transform coefficient may refer to a coefficient value generated after performing at least one of entropy decoding and inverse quantization in a decoder. A quantization level obtained by quantizing a transform coefficient or a residual signal or a quantized transform coefficient level may also fall within the meaning of a transform coefficient.

[0124] Quantization level: may represent a value generated by quantizing a transform coefficient or a residual signal in an encoder. Alternatively, the quantization level may represent a value that is a dequantization target subjected to dequantization in a decoder. Similarly, the quantized transform coefficient level as a result of transformation and quantization may also fall within the meaning of the quantization level.

[0125] Non-zero transform coefficient: may refer to a transform coefficient having a value other than zero or a transform coefficient level or quantization level having a value other than zero.

[0126] Quantization matrix: may refer to a matrix used in a quantization process or an inverse quantization process performed to improve subjective or objective image quality. A quantization matrix may also be referred to as a scaling list.

[0127] Quantization matrix coefficients: can represent each element in the quantization matrix. Quantization matrix coefficients can also be called matrix coefficients.

[0128] Default matrix: may represent a predetermined quantization matrix predefined in an encoder or a decoder.

[0129] Non-default matrix: may represent a quantization matrix that is not predefined in the encoder or decoder but is signaled by the user.

[0130] Statistical value: The statistical value for at least one of a variable, a coding parameter, a constant value, etc. having a calculable specific value can be one or more of the average value, weighted average value, weighted sum value, minimum value, maximum value, most frequent value, median value, and interpolation value of the corresponding specific value.

[0131] Figure 1 is a block diagram showing a configuration of an encoding device according to an embodiment to which the present invention is applied.

[0132] The encoding device 100 may be an encoder, a video encoding device, or an image encoding device. A video may include at least one image. The encoding device 100 may sequentially encode at least one image.

[0133] Reference Figure 1, the encoding device 100 may include a motion prediction unit 111, a motion compensation unit 112, an intra-frame prediction unit 120, a switch 115, a subtractor 125, a transform unit 130, a quantization unit 140, an entropy encoding unit 150, an inverse quantization unit 160, an inverse transform unit 170, an adder 175, a filter unit 180 and a reference picture buffer 190.

[0134] The encoding device 100 may perform encoding of an input image by using an intra mode or an inter mode or both an intra mode and an inter mode. In addition, the encoding device 100 may generate a bit stream including encoded information by encoding the input image, and output the generated bit stream. The generated bit stream may be stored in a computer-readable recording medium, or may be streamed through a wired / wireless transmission medium. When the intra mode is used as a prediction mode, the switch 115 may be switched to the intra mode. Alternatively, when the inter mode is used as a prediction mode, the switch 115 may be switched to the inter mode. Here, the intra mode may represent an intra prediction mode, and the inter mode may represent an inter prediction mode. The encoding device 100 may generate a prediction block for an input block of the input image. In addition, the encoding device 100 may encode a residual block using a residual of the input block and the prediction block after the prediction block is generated. The input image may be referred to as a current image as a current encoding target. The input block may be referred to as a current block as a current encoding target, or may be referred to as an encoding target block.

[0135] When the prediction mode is the intra mode, the intra prediction unit 120 may use samples of a block that has been encoded / decoded and is adjacent to the current block as reference samples. The intra prediction unit 120 may generate prediction samples of the input block by performing spatial prediction for the current block using the reference samples or by performing spatial prediction. Here, intra prediction may refer to prediction within a frame.

[0136] When the prediction mode is the inter mode, the motion prediction unit 111 may retrieve the area that best matches the input block from the reference image when performing motion prediction, and derive the motion vector by using the retrieved area. In this case, the search area may be used as the area. The reference image may be stored in the reference picture buffer 190. Here, when encoding / decoding for the reference image is performed, the reference image may be stored in the reference picture buffer 190.

[0137] The motion compensation unit 112 may generate a prediction block by performing motion compensation on the current block using a motion vector. Here, inter prediction may refer to prediction or motion compensation between frames.

[0138] When the value of the motion vector is not an integer, the motion prediction unit 111 and the motion compensation unit 112 may generate a prediction block by applying an interpolation filter to a partial area of ​​a reference picture. In order to perform inter-frame prediction or motion compensation on a coding unit, it may be determined which mode of a skip mode, a merge mode, an advanced motion vector prediction (AMVP) mode, and a current picture reference mode is used for motion prediction and motion compensation of a prediction unit included in the corresponding coding unit. Then, inter-frame prediction or motion compensation may be performed differently according to the determined mode.

[0139] The subtractor 125 may generate a residual block by using the residual of the input block and the prediction block. The residual block may be referred to as a residual signal. The residual signal may represent the difference between the original signal and the prediction signal. In addition, the residual signal may be a signal generated by transforming or quantizing the difference between the original signal and the prediction signal, or by transforming and quantizing. The residual block may be a residual signal of a block unit.

[0140] The transform unit 130 may generate a transform coefficient by performing a transform of the residual block and output the generated transform coefficient. Here, the transform coefficient may be a coefficient value generated by performing a transform of the residual block. When the transform skip mode is applied, the transform unit 130 may skip the transform of the residual block.

[0141] The quantized level may be generated by applying quantization to a transform coefficient or a residual signal. Hereinafter, the quantized level may also be referred to as a transform coefficient in an embodiment.

[0142] The quantization unit 140 may generate a quantization level by quantizing the transform coefficient or the residual signal according to the parameter and output the generated quantization level. Here, the quantization unit 140 may quantize the transform coefficient by using a quantization matrix.

[0143] The entropy encoding unit 150 may generate a bitstream by performing entropy encoding on the value calculated by the quantization unit 140 or the encoding parameter value calculated when encoding is performed according to the probability distribution, and output the generated bitstream. The entropy encoding unit 150 may perform entropy encoding on sample information of the image and information for decoding the image. For example, the information for decoding the image may include a syntax element.

[0144] When entropy coding is applied, symbols are represented so that a smaller number of bits are allocated to symbols with a high chance of generation and a larger number of bits are allocated to symbols with a low chance of generation, and therefore, the size of the bitstream for the symbol to be encoded can be reduced. The entropy coding unit 150 can use a coding method for entropy coding, such as exponential Golomb, context adaptive variable length coding (CAVLC), context adaptive binary arithmetic coding (CABAC), etc. For example, the entropy coding unit 150 can perform entropy coding by using a variable length coding / code (VLC) table. In addition, the entropy coding unit 150 can derive a binarization method of the target symbol and a probability model of the target symbol / binary bit, and perform arithmetic coding by using the derived binarization method and context model.

[0145] In order to encode a transform coefficient level (quantized level), the entropy encoding unit 150 may change a coefficient in a two-dimensional block form into a one-dimensional vector form by using a transform coefficient scanning method.

[0146] The coding parameters may include information such as syntax elements that are encoded in the encoder and sent to the decoder by signaling (flags, indexes, etc.), as well as information derived when performing encoding or decoding. The coding parameters may represent information required when encoding or decoding an image. For example, at least one value or combination of the following items may be included in the coding parameters: unit / block size, unit / block depth, unit / block partition information, unit / block shape, unit / block partition structure, whether to perform quadtree partitioning, whether to perform binary tree partitioning, binary tree partition direction (horizontal or vertical), binary tree partition form (symmetric partitioning or asymmetric partitioning), whether to perform ternary tree partitioning, ternary tree partition direction (horizontal or vertical direction), ternary tree partition form (symmetric partitioning or asymmetric partitioning), whether to perform multi-type tree partitioning, multi-type tree partition direction (horizontal or vertical direction), vertical direction), multi-type tree-based partitioning (symmetric partitioning or asymmetric partitioning), multi-type tree-based partitioning trees, prediction mode (intra-frame prediction or inter-frame prediction), luminance intra-frame prediction mode / direction, chrominance intra-frame prediction mode / direction, intra-frame partition information, inter-frame partition information, coding block partition flag, prediction block partition flag, transform block partition flag, reference sample filtering method, reference sample filter taps, reference sample filter coefficients, prediction block filtering method, prediction block filter taps, prediction block filter coefficients, prediction block boundary filtering method, prediction block boundary filter taps, prediction block boundary filter coefficients, intra-frame prediction mode, inter-frame prediction mode, motion information, motion vector amount, motion vector difference, reference picture index, inter-frame prediction angle, inter-frame prediction indicator, prediction list utilization flag, reference picture list, reference picture, motion vector predictor index, motion vector predictor candidate, motion vector candidate list, whether to use merge mode, merge index, merge candidate, merge candidate list, whether to use skip mode, interpolation filter type, interpolation filter tap, interpolation filter coefficient, motion vector size, motion vector representation accuracy, transform type, transform size, whether to use the primary (first) transform information, whether to use the secondary transform information, primary transform index, secondary transform index, whether there is a residual signal information, coding block pattern, Coding block flag (CBF), quantization parameter, quantization parameter residual, quantization matrix, whether to apply intra-frame loop filter, intra-frame loop filter coefficient, intra-frame loop filter tap, intra-frame loop filter shape / form, whether to apply deblocking filter, deblocking filter coefficient, deblocking filter tap, deblocking filter strength, deblocking filter shape / form, whether to apply adaptive sample offset, adaptive sample offset value, adaptive sample offset category, adaptive sample offset type, whether to apply adaptive loop filter, adaptive loop filter coefficient, adaptive loop filter tap, adaptive loop filter shape / form, binarization / inverse binarization method, context model determination method,Context model update method, whether to execute normal mode, whether to execute bypass mode, context binary bit, bypass binary bit, valid coefficient flag, last valid coefficient flag, encoding flag for unit of coefficient group, position of last valid coefficient, flag for whether coefficient value is greater than 1, flag for whether coefficient value is greater than 2, flag for whether coefficient value is greater than 3, information about remaining coefficient values, sign information, reconstructed luminance samples, reconstructed chrominance samples, residual luminance samples, residual chrominance samples, luminance transform coefficient, chrominance transform coefficient, quantized luminance level, quantized chrominance level, transform coefficient level scanning method, size of motion vector search area at decoder side, at decoder side shape of the motion vector search area, the number of motion vector searches at the decoder side, information about the CTU size, information about the minimum block size, information about the maximum block size, information about the maximum block depth, information about the minimum block depth, image display / output order, slice identification information, slice type, slice partition information, tile group identification information, tile group type, tile group partition information, tile identification information, tile type, tile partition information, picture type, bit depth of input samples, bit depth of reconstructed samples, bit depth of residual samples, bit depth of transform coefficients, bit depth of quantization levels, and information about a luminance signal or information about a chrominance signal.

[0147] Here, signaling a flag or an index may mean that the corresponding flag or index is entropy encoded by an encoder and included in a bitstream, and may mean that the corresponding flag or index is entropy decoded from the bitstream by a decoder.

[0148] When the encoding apparatus 100 performs encoding by inter-frame prediction, the encoded current image may be used as a reference image for another image that is subsequently processed. Therefore, the encoding apparatus 100 may reconstruct or decode the encoded current image, or store the reconstructed or decoded image as a reference image in the reference picture buffer 190.

[0149] The quantized level may be dequantized in the dequantization unit 160 or may be inversely transformed in the inverse transform unit 170. The dequantized or inversely transformed coefficient or the dequantized and inversely transformed coefficient may be added to the prediction block through the adder 175. By adding the dequantized or inversely transformed coefficient or the dequantized and inversely transformed coefficient to the prediction block, a reconstructed block may be generated. Here, the dequantized or inversely transformed coefficient or the dequantized and inversely transformed coefficient may mean a coefficient on which at least one of dequantization and inverse transformation is performed, and may mean a reconstructed residual block.

[0150] The reconstructed block may pass through the filter unit 180. The filter unit 180 may apply at least one of a deblocking filter, a sample adaptive offset (SAO), and an adaptive loop filter (ALF) to the reconstructed sample, the reconstructed block, or the reconstructed image. The filter unit 180 may be referred to as an in-loop filter.

[0151] The deblocking filter may remove block distortion generated in the boundary between blocks. In order to determine whether to apply the deblocking filter, it may be determined whether to apply the deblocking filter to the current block based on samples included in a number of rows or columns included in the block. When the deblocking filter is applied to the block, another filter may be applied according to the required deblocking filter strength.

[0152] In order to compensate for the coding error, an appropriate offset value may be added to the sample value by using sample adaptive offset. Sample adaptive offset may correct the offset of the deblocked image and the original image in sample units. A method of partitioning the samples of the image into a predetermined number of regions, determining the regions to which the offset is applied, and applying the offset to the determined regions, or a method of applying the offset in consideration of edge information about each sample may be used.

[0153] The adaptive loop filter may perform filtering based on a comparison result of a filtered reconstructed image with an original image. Samples included in an image may be partitioned into predetermined groups, a filter to be applied to each group may be determined, and differential filtering may be performed for each group. Information on whether ALF is applied may be signaled per coding unit (CU), and the form and coefficient of ALF to be applied to each block may vary.

[0154] The reconstructed block or the reconstructed image that has passed through the filter unit 180 may be stored in the reference picture buffer 190. The reconstructed block processed by the filter unit 180 may be a part of the reference image. That is, the reference image is a reconstructed image composed of the reconstructed blocks processed by the filter unit 180. The stored reference image may be used later in inter-frame prediction or motion compensation.

[0155] Figure 2 is a block diagram showing the configuration of a decoding device according to an embodiment and to which the present invention is applied.

[0156] The decoding device 200 may be a decoder, a video decoding device, or an image decoding device.

[0157] Reference Figure 2 , the decoding device 200 may include an entropy decoding unit 210, an inverse quantization unit 220, an inverse transform unit 230, an intra-frame prediction unit 240, a motion compensation unit 250, an adder 225, a filter unit 260 and a reference picture buffer 270.

[0158] The decoding device 200 may receive a bit stream output from the encoding device 100. The decoding device 200 may receive a bit stream stored in a computer-readable recording medium, or may receive a bit stream streamed through a wired / wireless transmission medium. The decoding device 200 may decode the bit stream by using an intra-frame mode or an inter-frame mode. In addition, the decoding device 200 may generate a reconstructed image or a decoded image generated by decoding, and output the reconstructed image or the decoded image.

[0159] When the prediction mode used in decoding is intra mode, the switch may be switched to intra mode. Alternatively, when the prediction mode used in decoding is inter mode, the switch may be switched to inter mode.

[0160] The decoding device 200 can obtain a reconstructed residual block by decoding the input bit stream and generate a prediction block. When the reconstructed residual block and the prediction block are obtained, the decoding device 200 can generate a reconstructed block that becomes a decoding target by adding the reconstructed residual block to the prediction block. The decoding target block may be referred to as a current block.

[0161] The entropy decoding unit 210 may generate symbols by entropy decoding the bit stream according to the probability distribution. The generated symbols may include symbols in the form of quantized levels. Here, the entropy decoding method may be an inverse process of the above entropy encoding method.

[0162] In order to decode the transform coefficient levels (quantized levels), the entropy decoding unit 210 may change the coefficients in the form of a one-way vector into a two-dimensional block form by using a transform coefficient scanning method.

[0163] The quantized level may be inversely quantized in the inverse quantization unit 220, or may be inversely transformed in the inverse transform unit 230. The quantized level may be a result of inverse quantization or inverse transformation or both inverse quantization and inverse transformation, and may be generated as a reconstructed residual block. Here, the inverse quantization unit 220 may apply a quantization matrix to the quantized level.

[0164] When the intra mode is used, the intra prediction unit 240 may generate a predicted block by performing spatial prediction using sample values ​​of a block adjacent to the decoding target block and already decoded, with respect to the current block.

[0165] When the inter mode is used, the motion compensation unit 250 may generate a prediction block by performing motion compensation using a reference image and a motion vector stored in the reference picture buffer 270 on the current block.

[0166] The adder 225 can generate a reconstructed block by adding the reconstructed residual block to the prediction block. The filter unit 260 can apply at least one of a deblocking filter, a sample adaptive offset, and an adaptive loop filter to the reconstructed block or the reconstructed image. The filter unit 260 can output the reconstructed image. The reconstructed block or the reconstructed image can be stored in the reference picture buffer 270 and used when performing inter-frame prediction. The reconstructed block processed by the filter unit 260 can be a part of the reference image. That is, the reference image is a reconstructed image composed of the reconstructed blocks processed by the filter unit 260. The stored reference image can be used later in inter-frame prediction or motion compensation.

[0167] Figure 3 is a diagram schematically showing a partition structure of an image when the image is encoded and decoded. Figure 3 An example of partitioning a single cell into a plurality of lower-level cells is schematically shown.

[0168] In order to efficiently partition an image, a coding unit (CU) may be used when encoding and decoding. A coding unit may be used as a basic unit when encoding / decoding an image. In addition, a coding unit may be used as a unit for distinguishing an intra prediction mode from an inter prediction mode when encoding / decoding an image. A coding unit may be a basic unit for prediction, transformation, quantization, inverse transformation, inverse quantization, or encoding / decoding processing of a transform coefficient.

[0169] Reference Figure 3 , the image 300 is partitioned sequentially by the largest coding unit (LCU), and the LCU unit is determined as a partition structure. Here, the LCU may be used in the same meaning as the coding tree unit (CTU). Unit partitioning may mean partitioning a block associated with the unit. In the block partition information, information about the unit depth may be included. The depth information may indicate the number or degree of partitioning of the unit or both the number and degree. A single unit may be partitioned into a plurality of lower-level units hierarchically associated with the depth information based on a tree structure. In other words, the unit and the lower-level units generated by partitioning the unit may correspond to a node and a child node of the node, respectively. Each of the partitioned lower-level units may have depth information. The depth information may be information indicating the size of a CU and may be stored in each CU. The unit depth indicates the number and / or degree associated with partitioning the unit. Therefore, the partition information of the lower-level unit may include information about the size of the lower-level unit.

[0170] The partition structure may indicate the distribution of coding units (CUs) within the CTU 310. Such distribution may be determined according to whether a single CU is partitioned into a plurality of (positive integers equal to or greater than 2, including 2, 4, 8, 16, etc.) CUs. The horizontal size and vertical size of the CU generated by partitioning may be half of the horizontal size and vertical size of the CU before partitioning, respectively, or may have a size smaller than the horizontal size and vertical size before partitioning, respectively, according to the number of partitioning times. The CU may be recursively partitioned into a plurality of CUs. By recursive partitioning, at least one of the height and width of the CU after partitioning may be reduced compared to at least one of the height and width of the CU before partitioning. The partitioning of the CU may be recursively performed until a predefined depth or a predefined size. For example, the depth of the CTU may be 0, and the depth of the smallest coding unit (SCU) may be a predefined maximum depth. Here, as described above, the CTU may be a coding unit having a maximum coding unit size, and the SCU may be a coding unit having a minimum coding unit size. Starting partitioning from the CTU 310, as the horizontal size or vertical size or both the horizontal size and the vertical size of the CU decrease through partitioning, the CU depth increases by 1. For example, for each depth, a non-partitioned CU may have a size of 2N×2N. Also, in the case of a partitioned CU, a CU of size 2N×2N may be partitioned into four CUs of size N×N. The size of N may be reduced to half as the depth increases by 1.

[0171] In addition, information on whether a CU is partitioned may be indicated by using partition information of the CU. The partition information may be 1-bit information. All CUs except the SCU may include partition information. For example, when the value of the partition information is a first value, the CU may not be partitioned, and when the value of the partition information is a second value, the CU may be partitioned.

[0172] Reference Figure 3 , a CTU with a depth of 0 may be a 64×64 block. 0 may be the minimum depth. An SCU with a depth of 3 may be an 8×8 block. 3 may be the maximum depth. A CU with a block of 32×32 and a block of 16×16 may be represented as depth 1 and depth 2, respectively.

[0173] For example, when a single coding unit is partitioned into four coding units, the horizontal size and vertical size of the four partitioned coding units may be half the horizontal size and vertical size of the CU before partitioning. In one embodiment, when a coding unit of size 32×32 is partitioned into four coding units, each of the four partitioned coding units may have a size of 16×16. When a single coding unit is partitioned into four coding units, it can be said that the coding unit can be partitioned (quadtree partitioning) into a quadtree form.

[0174] For example, when a single coding unit is partitioned into two coding units, the horizontal size or vertical size of the two coding units may be half of the horizontal size or vertical size of the coding unit before partitioning. For example, when a coding unit of size 32×32 is partitioned in the vertical direction, the two partitioned coding units may have a size of 16×32. For example, when a coding unit of size 8×32 is partitioned horizontally into two sub-coding units, each of the two sub-coding units may have a size of 8×16. When a single coding unit is partitioned into two coding units, the coding unit may be said to be partitioned in the form of a binary tree (partitioned by a binary tree).

[0175] For example, when one coding unit is partitioned into three sub-coding units, the horizontal size or the vertical size of the coding unit may be partitioned at a ratio of 1:2:1, thereby generating three sub-coding units having a ratio of the horizontal size or the vertical size of 1:2:1. For example, when a coding unit having a size of 16×32 is partitioned horizontally into three sub-coding units, the three sub-coding units may have sizes of 16×8, 16×16, and 16×8, respectively, in order from the uppermost sub-coding unit to the lowermost sub-coding unit. For example, when a coding unit having a size of 32×32 is partitioned vertically into three sub-coding units, the three sub-coding units may have sizes of 8×32, 16×32, and 8×32, respectively, in order from the left sub-coding unit to the right sub-coding unit. When one coding unit is partitioned into three sub-coding units, the coding unit may be said to be partitioned by a ternary tree partition or partitioned according to a ternary tree partition structure.

[0176] exist Figure 3 , a coding tree unit (CTU) 320 is an example of a CTU to which a quadtree partition structure, a binary tree partition structure, and a ternary tree partition structure are all applied.

[0177] As described above, in order to partition a CTU, at least one of a quadtree partition structure, a binary tree partition structure, and a ternary tree partition structure may be applied. Various tree partition structures may be sequentially applied to a CTU according to a predetermined priority order. For example, a quadtree partition structure may be preferentially applied to a CTU. Coding units that can no longer be partitioned using a quadtree partition structure may correspond to leaf nodes of a quadtree. Coding units corresponding to leaf nodes of a quadtree may be used as root nodes of a binary and / or ternary tree partition structure. That is, coding units corresponding to leaf nodes of a quadtree may be further partitioned by a binary tree partition structure or a ternary tree partition structure, or may not be further partitioned. Therefore, by preventing coding blocks generated by binary tree partitioning or ternary tree partitioning of coding units corresponding to leaf nodes of a quadtree from undergoing further quadtree partitioning, block partitioning and / or signaling of partition information may be efficiently performed.

[0178] The four partition information may be used to signal the fact that the coding unit corresponding to the node of the quadtree is partitioned. The four partition information having a first value (e.g., '1') may indicate that the current coding unit is partitioned in a quadtree partition structure. The four partition information having a second value (e.g., '0') may indicate that the current coding unit is not partitioned in a quadtree partition structure. The four partition information may be a flag having a predetermined length (e.g., one bit).

[0179] There may be no priority between the binary tree partition and the ternary tree partition. That is, the coding unit corresponding to the leaf node of the quadtree may further undergo any partition of the binary tree partition and the ternary tree partition. In addition, the coding unit generated by the binary tree partition or the ternary tree partition may undergo further binary tree partition or further ternary tree partition, or may not be further partitioned.

[0180] A tree structure in which there is no priority between a binary tree partition and a ternary tree partition is referred to as a multi-type tree structure. A coding unit corresponding to a leaf node of a quadtree may be used as a root node of a multi-type tree. At least one of multi-type tree partition indication information, partition direction information, and partition tree information may be used to signal whether to partition a coding unit corresponding to a node of a multi-type tree. For partitions of coding units corresponding to nodes of a multi-type tree, multi-type tree partition indication information, partition direction, and partition tree information may be sequentially signaled.

[0181] The multi-type tree partition indication information having a first value (eg, '1') may indicate that the current coding unit will undergo multi-type tree partitioning. The multi-type tree partition indication information having a second value (eg, '0') may indicate that the current coding unit will not undergo multi-type tree partitioning.

[0182] When the coding unit corresponding to the node of the multi-type tree is partitioned according to the multi-type tree partition structure, the coding unit may further include partition direction information. The partition direction information may indicate in which direction the current coding unit will be partitioned for the multi-type tree partition. The partition direction information having a first value (e.g., "1") may indicate that the current coding unit will be partitioned vertically. The partition direction information having a second value (e.g., "0") may indicate that the current coding unit will be partitioned horizontally.

[0183] When the coding unit corresponding to the node of the multi-type tree is partitioned according to the multi-type tree partition structure, the current coding unit may further include partition tree information. The partition tree information may indicate a tree partition structure to be used for the partition of the node of the multi-type tree. The partition tree information having a first value (e.g., "1") may indicate that the current coding unit will be partitioned according to the binary tree partition structure. The partition tree information having a second value (e.g., "0") may indicate that the current coding unit will be partitioned according to the ternary tree partition structure.

[0184] The partition indication information, the partition tree information and the partition direction information may all be flags having a predetermined length (eg, one bit).

[0185] At least any one of the quadtree partition indication information, the multi-type tree partition indication information, the partition direction information, and the partition tree information may be entropy encoded / decoded. For entropy encoding / decoding of those types of information, information about neighboring coding units adjacent to the current coding unit may be used. For example, the partition type (partition or non-partition, partition tree, and / or partition direction) of the left neighboring coding unit and / or the upper neighboring coding unit of the current coding unit is likely to be similar to the partition type of the current coding unit. Therefore, context information for entropy encoding / decoding the information about the current coding unit may be derived from the information about the neighboring coding unit. The information about the neighboring coding unit may include at least any one of the quadtree partition information, the multi-type tree partition indication information, the partition direction information, and the partition tree information.

[0186] As another example, among binary tree partitioning and ternary tree partitioning, binary tree partitioning may be preferentially performed. That is, the current coding unit may first undergo binary tree partitioning, and then the coding unit corresponding to the leaf node of the binary tree may be set as the root node for the ternary tree partitioning. In this case, quadtree partitioning or binary tree partitioning may not be performed on the coding unit corresponding to the node of the ternary tree.

[0187] A coding unit that cannot be partitioned according to a quadtree partition structure, a binary tree partition structure, and / or a ternary tree partition structure becomes a basic unit for encoding, prediction, and / or transformation. That is, the coding unit cannot be further partitioned for prediction and / or transformation. Therefore, the partition structure information and partition information for partitioning the coding unit into prediction units and / or transformation units may not be present in the bitstream.

[0188] However, when the size of the coding unit (i.e., the basic unit for partitioning) is larger than the size of the maximum transform block, the coding unit may be recursively partitioned until the size of the coding unit is reduced to be equal to or smaller than the size of the maximum transform block. For example, when the size of the coding unit is 64×64 and when the size of the maximum transform block is 32×32, the coding unit may be partitioned into four 32×32 blocks for transformation. For example, when the size of the coding unit is 32×64 and the size of the maximum transform block is 32×32, the coding unit may be partitioned into two 32×32 blocks for transformation. In this case, the partition of the coding unit for transformation is not separately signaled and may be determined by comparison between the horizontal size or vertical size of the coding unit and the horizontal size or vertical size of the maximum transform block. For example, when the horizontal size (width) of the coding unit is larger than the horizontal size (width) of the maximum transform block, the coding unit may be vertically bisected. For example, when the vertical size (length) of the coding unit is larger than the vertical size (length) of the maximum transform block, the coding unit may be horizontally bisected.

[0189] Information on the maximum and / or minimum size of a coding unit and information on the maximum and / or minimum size of a transform block may be signaled or determined at a higher level of the coding unit. The higher level may be, for example, a sequence level, a picture level, a tile level, a tile group level, a slice level, etc. For example, the minimum size of a coding unit may be determined as 4×4. For example, the maximum size of a transform block may be determined as 64×64. For example, the minimum size of a transform block may be determined as 4×4.

[0190] Information on the minimum size of the coding unit corresponding to the leaf node of the quadtree (quadtree minimum size) and / or information on the maximum depth from the root node of the multi-type tree to the leaf node (maximum tree depth of the multi-type tree) may be sent with a signal or determined at a higher level of the coding unit. For example, the higher level may be a sequence level, a picture level, a slice level, a parallel block group level, a parallel block level, etc. Information on the minimum size of the quadtree and / or information on the maximum depth of the multi-type tree may be sent with a signal or determined for each of the intra-frame slices and the inter-frame slices.

[0191] The difference information between the size of the CTU and the maximum size of the transform block may be signaled or determined at a higher level of the coding unit. For example, the higher level may be a sequence level, a picture level, a slice level, a parallel block group level, a parallel block level, etc. The information of the maximum size of the coding unit corresponding to each node of the binary tree (hereinafter referred to as the maximum size of the binary tree) may be determined based on the size of the coding tree unit and the difference information. The maximum size of the coding unit corresponding to each node of the ternary tree (hereinafter referred to as the maximum size of the ternary tree) may vary according to the type of the slice. For example, for an intra-frame slice, the maximum size of the ternary tree may be 32×32. For example, for an inter-frame slice, the maximum size of the ternary tree may be 128×128. For example, the minimum size of the coding unit corresponding to each node of the binary tree (hereinafter referred to as the minimum size of the binary tree) and / or the minimum size of the coding unit corresponding to each node of the ternary tree (hereinafter referred to as the minimum size of the ternary tree) may be set to the minimum size of the coding block.

[0192] As another example, the maximum size of the binary tree and / or the maximum size of the ternary tree may be signaled or determined at the slice level. Alternatively, the minimum size of the binary tree and / or the minimum size of the ternary tree may be signaled or determined at the slice level.

[0193] According to the sizes and depth information of the above-mentioned various blocks, quad partition information, multi-type tree partition indication information, partition tree information and / or partition direction information may be included in the bitstream or may not be included in the bitstream.

[0194] For example, when the size of the coding unit is not greater than the minimum size of the quadtree, the coding unit does not include the quad partition information. Therefore, the quad partition information can be derived from the second value.

[0195] For example, when the size (horizontal size and vertical size) of the coding unit corresponding to the node of the multi-type tree is greater than the maximum size (horizontal size and vertical size) of the binary tree and / or the maximum size (horizontal size and vertical size) of the ternary tree, the coding unit may not be partitioned by the binary tree or the ternary tree. Therefore, the multi-type tree partition indication information may not be signaled, but may be derived from the second value.

[0196] Optionally, when the size (horizontal size and vertical size) of the coding unit corresponding to the node of the multi-type tree is the same as the maximum size (horizontal size and vertical size) of the binary tree and / or is twice as large as the maximum size (horizontal size and vertical size) of the ternary tree, the coding unit may not be further partitioned by the binary tree or the ternary tree. Therefore, the multi-type tree partition indication information may not be sent by signal, but may be derived from the second value. This is because when the coding unit is partitioned by the binary tree partition structure and / or the ternary tree partition structure, a coding unit smaller than the minimum size of the binary tree and / or the minimum size of the ternary tree is generated.

[0197] Optionally, when the depth of the coding unit corresponding to the node of the multi-type tree is equal to the maximum depth of the multi-type tree, the coding unit may not be further binary tree partitioned and / or ternary tree partitioned. Therefore, the multi-type tree partition indication information may not be sent with a signal, but may be derived from the second value.

[0198] Optionally, only when at least one of vertical binary tree partitioning, horizontal binary tree partitioning, vertical ternary tree partitioning, and horizontal ternary tree partitioning is possible for the coding unit corresponding to the node of the multi-type tree, the multi-type tree partition indication information may be sent by signal. Otherwise, the coding unit may not be partitioned by the binary tree and / or the ternary tree. Therefore, the multi-type tree partition indication information may not be sent by signal, but may be derived from the second value.

[0199] Optionally, partition direction information may be signaled only when both vertical binary tree partitioning and horizontal binary tree partitioning or both vertical ternary tree partitioning and horizontal ternary tree partitioning are possible for the coding unit corresponding to the node of the multi-type tree. Otherwise, the partition direction information may not be signaled, but may be derived from a value indicating a possible partition direction.

[0200] Optionally, partition tree information may be signaled only when both vertical binary tree partitioning and vertical ternary tree partitioning or both horizontal binary tree partitioning and horizontal ternary tree partitioning are possible for a coding unit corresponding to a node of a multi-type tree. Otherwise, the partition tree information may not be signaled but may be derived from a value indicating a possible partition tree structure.

[0201] Figure 4 is a diagram illustrating an embodiment of an inter-picture prediction process.

[0202] exist Figure 4 In , a rectangle can represent a picture. Figure 4 In FIG, the arrow indicates the prediction direction. Pictures can be classified into intra-pictures (I pictures), predicted pictures (P pictures) and bi-predicted pictures (B pictures) according to their coding types.

[0203] I pictures may be encoded by intra prediction without inter-picture prediction. P pictures may be encoded by inter-picture prediction using reference pictures existing in one direction (i.e., forward or backward) for the current block. B pictures may be encoded by inter-picture prediction using reference pictures existing in two directions (i.e., forward and backward) for the current block. When inter-picture prediction is used, the encoder may perform inter-picture prediction or motion compensation, and the decoder may perform corresponding motion compensation.

[0204] Next, embodiments of inter-picture prediction will be described in detail.

[0205] Reference pictures and motion information may be used to perform inter-picture prediction or motion compensation.

[0206] The motion information of the current block may be derived during inter-picture prediction by each of the encoding device 100 and the decoding device 200. The motion information of the current block may be derived by using the motion information of a reconstructed neighboring block, a co-located block (also referred to as a col block or a co-located block), and / or motion information of a block adjacent to the co-located block. The co-located block may represent a block within a previously reconstructed co-located picture (also referred to as a col picture or a co-located picture) that is spatially located at the same position as the current block. The co-located picture may be one of one or more reference pictures included in a reference picture list.

[0207] The method of deriving motion information of the current block may vary according to the prediction mode of the current block. For example, as a prediction mode for inter-picture prediction, there may be AMVP mode, merge mode, skip mode, current picture reference mode, etc. The merge mode may be referred to as a motion merge mode.

[0208] For example, when AMVP is used as a prediction mode, at least one of the motion vector of the reconstructed neighboring block, the motion vector of the co-located block, the motion vector of the block adjacent to the co-located block, and the (0,0) motion vector may be determined as a motion vector candidate for the current block, and a motion vector candidate list is generated by using the motion vector candidate. The motion vector candidate of the current block may be derived by using the generated motion vector candidate list. The motion information of the current block may be determined based on the derived motion vector candidate. The motion vector of the co-located block or the motion vector of the block adjacent to the co-located block may be referred to as a temporal motion vector candidate, and the motion vector of the reconstructed neighboring block may be referred to as a spatial motion vector candidate.

[0209] The encoding device 100 may calculate a motion vector difference (MVD) between a motion vector of a current block and a motion vector candidate and may perform entropy coding on the motion vector difference (MVD). In addition, the encoding device 100 may perform entropy coding on a motion vector candidate index and generate a bitstream. The motion vector candidate index may indicate an optimal motion vector candidate among motion vector candidates included in a motion vector candidate list. The decoding device may perform entropy decoding on the motion vector candidate index included in the bitstream, and may select a motion vector candidate of a decoding target block from the motion vector candidates included in the motion vector candidate list by using the entropy-decoded motion vector candidate index. In addition, the decoding device 200 may add the entropy-decoded MVD to the motion vector candidate extracted by entropy decoding, thereby deriving a motion vector of the decoding target block.

[0210] The bitstream may include a reference picture index indicating a reference picture. The reference picture index may be entropy-encoded by the encoding apparatus 100 and then signaled as a bitstream to the decoding apparatus 200. The decoding apparatus 200 may generate a prediction block of a decoding target block based on the derived motion vector and the reference picture index information.

[0211] Another example of a method of deriving motion information of a current block may be a merge mode. The merge mode may represent a method of merging motions of multiple blocks. The merge mode may represent a mode of deriving motion information of a current block from motion information of neighboring blocks. When the merge mode is applied, the motion information of reconstructed neighboring blocks and / or the motion information of the same-positioned blocks may be used to generate a merge candidate list. The motion information may include at least one of a motion vector, a reference picture index, and an inter-picture prediction indicator. The prediction indicator may indicate unidirectional prediction (L0 prediction or L1 prediction) or bidirectional prediction (L0 prediction and L1 prediction).

[0212] The merge candidate list may be a list of stored motion information. The motion information included in the merge candidate list may be at least any one of a zero merge candidate and new motion information, wherein the new motion information is a combination of motion information of a neighboring block adjacent to the current block (spatial merge candidate), motion information of a co-located block of the current block included in a reference picture (temporal merge candidate), and motion information present in the merge candidate list.

[0213] The encoding device 100 may generate a bitstream by performing entropy encoding on at least one of a merge flag and a merge index, and may signal the bitstream to the decoding device 200. The merge flag may be information indicating whether a merge mode is performed for each block, and the merge index may be information indicating which neighboring block among neighboring blocks of the current block is a merge target block. For example, the neighboring blocks of the current block may include a left neighboring block on the left side of the current block, an upper neighboring block set above the current block, and a temporal neighboring block temporally adjacent to the current block.

[0214] The skip mode may be a mode in which the motion information of the neighboring blocks is applied to the current block as it is. When the skip mode is applied, the encoding apparatus 100 may perform entropy encoding on information of the fact of which block's motion information is to be used as the motion information of the current block to generate a bitstream, and may signal the bitstream to the decoding apparatus 200. The encoding apparatus 100 may not signal a syntax element regarding at least any one of the motion vector difference information, the coded block flag, and the transform coefficient level to the decoding apparatus 200.

[0215] The current picture reference mode may indicate a prediction mode in which a previously reconstructed region within the current picture to which the current block belongs is used for prediction. Here, a vector may be used to specify the previously reconstructed region. Information indicating whether the current block will be encoded in the current picture reference mode may be encoded by using the reference picture index of the current block. A flag or index indicating whether the current block is a block encoded in the current picture reference mode may be signaled and may be derived based on the reference picture index of the current block. In the case where the current block is encoded in the current picture reference mode, the current picture may be added to the reference picture list for the current block to be located at a fixed position or a random position in the reference picture list. The fixed position may be, for example, a position indicated by a reference picture index 0 or the last position in the list. When the current picture is added to the reference picture list to be located at a random position, a reference picture index indicating the random position may be signaled.

[0216] Hereinafter, an image encoding / decoding method using motion vector correction according to an embodiment of the present invention will be described with reference to the accompanying drawings.

[0217] Figure 5 is a flowchart showing an image encoding method according to an embodiment of the present invention, and Figure 6 is a flowchart illustrating an image decoding method according to an embodiment of the present invention.

[0218] Reference Figure 5 According to an embodiment of the present invention, an image encoding method includes the following steps: deriving a merge candidate for a current block (S510); determining motion information of the current block (S520); performing motion compensation on the current block (S530); and entropy encoding information associated with the motion compensation (S540).

[0219] Reference Figure 6 According to an embodiment of the present invention, an image decoding method includes the following steps: entropy decoding motion compensation information for a current block (S610); deriving a merge candidate for the current block (S620); determining motion information of the current block using the derived merge candidate (S630); and performing motion compensation using the determined motion information (S640).

[0220] Here, the step of deriving a merge candidate (S510, S620) means a process of deriving at least one of a spatial merge candidate, a temporal merge candidate, and an additional merge candidate for the current block. In this case, the operation of deriving a spatial merge candidate means a process of deriving a spatial merge candidate and adding the derived spatial merge candidate to a merge candidate list. The operation of deriving a temporal merge candidate means a process of deriving a temporal merge candidate and adding the derived temporal merge candidate to a merge candidate list.

[0221] Figure 7 is a diagram illustrating an exemplary method of deriving spatial merging candidates and temporal merging candidates for a current block.

[0222] Reference Figure 7 (a), derive spatial merging candidates for the current block X from neighboring blocks adjacent to the current block X. The neighboring blocks adjacent to the current block include a block B1 adjacent to the upper boundary of the current block, a block A1 adjacent to the left boundary of the current block, a block B0 adjacent to the upper right corner of the current block, a block B2 adjacent to the upper left corner of the current block, and a block A0 adjacent to the lower boundary of the current block.

[0223] In order to derive a spatial merge candidate for the current block, the encoder or decoder determines whether a neighboring block adjacent to the current block can be used to derive a spatial merge candidate for the current block. When determining whether a neighboring block adjacent to the current block can be used to derive a spatial merge candidate, the neighboring blocks are scanned sequentially according to a predetermined priority. For example, the availability of spatial merge candidates is determined in the order of blocks A1, B1, B0, A0, and B2. The encoder or decoder sequentially adds the spatial merge candidates determined according to the predetermined priority order (availability determination order) to the merge candidate list.

[0224] For example, when four spatial merging candidates are derived from neighboring blocks located at positions A1, B0, A0, and B2, the derived four spatial merging candidates are sequentially added to the merging candidate list.

[0225] The encoder or the decoder derives the spatial merging candidate by referring to at least one of the encoding parameters.

[0226] Here, the motion information of the spatial merging candidate includes three or more pieces of motion information including not only L0 motion information and L1 motion information but also L2 motion information and L3 motion information. The reference picture list indicates at least one list of L0 list, L1 list, L2 list, and L3 list.

[0227] A temporal merging candidate for the current block is derived from a reconstructed block included in a co-located picture of the current picture. Here, the co-located picture refers to a picture that was previously encoded / decoded before the current picture and is different from the current picture in temporal order.

[0228] Reference Figure 7 (b) derives a temporal merge candidate for the current block from blocks in a co-located picture of the current picture, wherein the blocks include a block corresponding to a position spatially co-located with the current block, a block including a position within a block corresponding to a position spatially co-located with the current block, and a neighboring block of a block corresponding to a position spatially co-located with the current block. Here, the temporal merge candidate refers to motion information of the co-located block.

[0229] For example, a temporal merge candidate of the current block is derived from a block H adjacent to the lower right corner of the block C or a block C3 including the center position of the block C, where the block C corresponds to the same position as the current block in space. The block H and the block C3 used to derive the temporal merge candidate of the current block are called the same position blocks.

[0230] When a temporal merge candidate can be derived from block H including a position outside block C, block H is set as the same-position block of the current block. In this case, the temporal merge candidate of the current block is derived from the motion information of block H. On the other hand, when the temporal merge candidate of the current block cannot be derived from block H, block C3 including a position inside block C is set as the same-position block of the current block. In this case, the temporal merge candidate of the current block is derived from the motion information of block C3. When the temporal merge candidate of the current block cannot be derived from either block H or block C3, the temporal merge candidate of the current block is not derived, or the temporal merge candidate of the current block is derived from blocks other than block H and block C3. For example, when the temporal merge of the current block cannot be derived from either block H or block C3, both block H and block C3 are encoded in intra-frame prediction mode.

[0231] Optionally, the temporal merging candidates of the current block are derived from multiple blocks in the same-position picture. For example, multiple temporal merging candidates of the current block are derived from block H and block C3.

[0232] When the distance between the current picture including the current block and the reference picture of the current block is different from the distance between the co-located picture including the co-located block and the reference picture of the co-located block, the motion vector of the temporal merging candidate of the current block is obtained by scaling the motion vector of the co-located block. Here, the scaling is performed according to the distance between the current picture of the current block and the reference picture and / or the distance between the co-located picture of the co-located block and the reference picture.

[0233] For example, the temporal merging candidate of the current block may be obtained by scaling the motion vector of the collocated block according to a ratio of the distance between the current picture and the reference picture of the current block relative to the distance between the collocated picture and the reference picture of the collocated block.

[0234] Furthermore, at least one of a temporal merging candidate, a co-located picture, a co-located block, a prediction list utilization flag, and a reference picture index is derived according to at least one of encoding parameters of a current block, a neighboring block, or a co-located block.

[0235] The encoder or decoder generates a merge candidate list by deriving at least one spatial merge candidate and / or temporal merge candidate and sequentially adding the derived spatial merge candidates and / or temporal merge candidates to the merge candidate list in the order in which the spatial merge candidates and / or temporal merge candidates are derived.

[0236] Next, a method of deriving additional merging candidates for the current block will be described.

[0237] The additional merge candidate refers to at least one of a modified spatial merge candidate, a modified temporal merge candidate, a combined merge candidate, and a merge candidate with a predetermined motion information value. Here, the operation of deriving additional merge candidates means that the encoder or decoder derives additional merge candidates and adds them to the merge candidate list.

[0238] The modified spatial merge candidate refers to a merge candidate obtained by modifying at least one piece of motion information of the derived spatial merge candidate. The modified temporal merge candidate refers to a merge candidate obtained by modifying at least one piece of motion information of the derived temporal merge candidate.

[0239] A combined merge candidate refers to a merge candidate derived by combining motion information of one or more merge candidates, wherein the one or more merge candidates are selected from spatial merge candidates, temporal merge candidates, modified spatial merge candidates, modified temporal merge candidates, combined merge candidates and merge candidates with predetermined motion information values, all of which are included in the merge candidate list.

[0240] A combined merge candidate also represents a merge candidate derived by combining motion information of one or more merge candidates, wherein the one or more merge candidates are selected from spatial merge candidates and temporal merge candidates that are not present in the merge candidate list but are derived from available blocks, modified merge candidates generated from these spatial merge candidates, modified temporal merge candidates generated from these temporal merge candidates, combined merge candidates, and merge candidates with predetermined motion information values.

[0241] In addition, the decoder derives the combined merge candidate by using the motion information obtained by entropy decoding the bitstream. In this case, the encoder entropy encodes the motion information for deriving the combined merge candidate into the bitstream.

[0242] A combined merge candidate also refers to a combined bi-prediction merge candidate. A combined bi-prediction merge candidate is a merge candidate using bi-prediction. In other words, a combined bi-prediction merge candidate is a merge candidate having L0 motion information and L1 motion information.

[0243] For example, the merge candidate having the predetermined motion information value means a zero merge candidate whose motion vector is (0, 0). The merge candidate having the predetermined motion information value is predefined, and the predetermined motion information value is commonly set in the encoder and the decoder.

[0244] At least one of the modified spatial merge candidate, the modified temporal merge candidate, the combined merge candidate, and the merge candidate with a predetermined motion information value is derived based on one or more coding parameters selected from the coding parameters of the current block, the coding parameters of the neighboring blocks, and the coding parameters of the same-position block. Then, at least one of the modified spatial merge candidate, the modified temporal merge candidate, the combined merge candidate, and the merge candidate with a predetermined motion information value is added to the merge candidate list based on at least one of the coding parameters of the current block, the neighboring blocks, and the same-position block.

[0245] The size of the merge candidate list is determined according to the encoding parameters of the current block, the neighboring block or the same-position block. The size of the merge candidate list varies according to the encoding parameters.

[0246] When deriving a merge candidate, the corrected motion vector generated by the motion vector correction method according to the present invention may be used.

[0247] Next, the step of determining the motion information of the current block (S520, S630) will be described in detail.

[0248] The encoder selects a merge candidate to be used for motion compensation of the current block from among merge candidates included in the merge candidate list by performing motion estimation, and encodes a merge candidate index (merge_idx) indicating the selected merge candidate into a bitstream.

[0249] For example, in order to generate a prediction block of a current block, the encoder determines motion information of the current block by selecting a merge candidate from merge candidates in a merge candidate list by referring to a merge candidate index. Next, motion compensation is performed on the current block based on the determined motion information.

[0250] The decoder decodes the merge candidate index in the bitstream and specifies the merge candidate indicated by the decoded merge candidate index among the merge candidates included in the merge candidate list. The motion information of the specified merge candidate is determined as the motion information of the current block. The determined motion information is used for motion compensation of the current block. In this case, motion compensation means inter-frame prediction (i.e., inter-picture prediction).

[0251] Next, the steps of performing motion compensation (S530, S640) will be described in detail.

[0252] The encoder or decoder performs inter prediction or motion compensation using the determined motion information. Here, the current block has the same motion information as the selected merge candidate.

[0253] The current block has one or more motion vectors (up to N motion vectors) depending on the prediction direction. The encoder or decoder generates at least one prediction block and at most N prediction blocks by using the motion vectors to obtain a final prediction block of the current block.

[0254] For example, when the current block has one motion vector, the encoder or the decoder determines a prediction block generated by using the motion vector (or motion information) as a final prediction block of the current block.

[0255] On the other hand, when the current block has multiple motion vectors (or motion information), the encoder or decoder generates multiple prediction blocks by using the multiple motion vectors (or motion information), and determines the final prediction block of the current block by performing a weighted sum operation on the multiple prediction blocks. The reference picture including the corresponding prediction block indicated by the corresponding multiple motion vectors (or motion information) may be included in different reference picture lists or in the same reference picture list.

[0256] For example, the encoder or decoder generates multiple prediction blocks based on at least one of spatial motion vector candidates, temporal motion vector candidates, motion vectors with predetermined values, and combined motion vector candidates, and determines a final prediction block of the current block based on a weighted sum of the multiple prediction blocks.

[0257] Alternatively, the encoder or decoder may generate a plurality of prediction blocks based on motion vector candidates indicated by predetermined motion vector candidate indices, and determine a final prediction block of the current block based on a weighted sum of the plurality of prediction blocks. Also optionally, the encoder or decoder may generate a plurality of prediction blocks based on motion vector candidates indicated by motion vector candidate indices in a specific range, and determine a final prediction block of the current block based on a weighted sum of the plurality of prediction blocks.

[0258] To this end, the weights applied to the respective prediction blocks may have the same value 1 / N. N is the number of prediction blocks generated. For example, when two prediction blocks are generated, the weights applied to the respective prediction blocks are 1 / 2 and 1 / 2, respectively. On the other hand, when three prediction blocks are generated, the weights applied to the respective prediction blocks are 1 / 3, 1 / 3, and 1 / 3, respectively. When four prediction blocks are generated, the weight applied to each prediction block is 1 / 4.

[0259] Alternatively, the encoder or decoder may determine a final prediction block for the current block by applying different weights to respective prediction blocks.

[0260] The weight applied to the prediction block does not have to be a fixed value, but can be a variable value. The weights applied to the respective prediction blocks may be equal to each other or may be different from each other. For example, when two prediction blocks are generated, examples of the weights applied to the two prediction blocks include (1 / 2, 1 / 2), (1 / 3, 2 / 3), (1 / 4, 3 / 4), (2 / 5, 3 / 5), and (3 / 8, 5 / 8). On the other hand, each weight is a positive real number or a negative real number. For example, the weight may include a negative real number. That is, the weight may be (-1 / 2, 3 / 2), (-1 / 3, 4 / 3), or (-1 / 4, 5 / 4)

[0261] On the other hand, in order to apply variable weights to a prediction block, weight information of the current block is signaled via a bitstream. Weight information is signaled on a per-prediction block or per-reference picture basis. Multiple prediction blocks may have the same weight information.

[0262] The encoder or decoder determines whether to use the prediction motion vector (prediction motion information) based on the prediction block list utilization flag. For example, when the prediction block list utilization flag has a first value of 1 for each reference picture list, this indicates that the encoder or decoder can use the prediction motion vector of the current block to perform inter-frame prediction or motion compensation. On the other hand, when the prediction block list utilization flag has a second value of 0, the encoder or decoder does not use the prediction motion vector of the current block to perform inter-frame prediction or motion compensation of the current block. Conversely, the first value and the second value of the prediction block list utilization flag may be set to 0 and 1, respectively.

[0263] Equations 1 to 3 represent a method for determining a final prediction block of a current block for the following cases when the prediction direction for each reference picture list is a single direction: a case where the inter-frame prediction indicator of the current block is PRED_BI, a case where the inter-frame prediction indicator of the current block is PRED_TRI, and a case where the inter-frame prediction indicator of the current block is PRED_QUAD.

[0264] [Equation 1]

[0265] P_BI=(WF_L0*P_L0+OFFSET_L0+WF_L1*P_L1+OFFSET_L1+RF')>>1

[0266] [Equation 2]

[0267] P_TRI=(WF_L0*P_L0+OFFSET_L0+WF_L1*P_L1+OFFSET_L1+WF_L2*P_L2+OFFSET_L2+RF') / 3

[0268] [Equation 3]

[0269] P_QUAD=(WF_L0*P_L0+OFFSET_L0+WF_L1*P_L1+OFFSET_L1+WF_L2*P_L2+OFFSET_L2+WF_L3*P_L3+OFFSET_L3+RF')>>2

[0270] In Equations 1 to 3, P_BI, P_TRI, and P_QUAD represent the final prediction block of the current block, and LX (X=0, 1, 2, 3) represents a reference picture list. WF_LX represents a weighted value of a prediction block generated using the reference picture list LX, and OFFSET_LX represents an offset value of a prediction block generated using the reference picture list LX. P_LX represents a prediction block generated using a motion vector (or motion information) of the reference picture list LX for the current block. RF represents a rounding factor that is 0, a positive number, or a negative number. The reference picture list LX includes at least one of the following reference pictures: a long-term reference picture, a reference picture that has not passed through a deblocking filter, a reference picture that has not passed through a sample adaptive offset (SAO), a reference picture that has not passed through an adaptive loop filter (ALF), a reference picture that has passed through a deblocking filter (DF) and an adaptive offset, a reference picture that has passed through a deblocking filter and an adaptive loop filter, a reference picture that has passed through a sample adaptive offset and an adaptive loop filter, and a reference picture that has passed through a deblocking filter, a sample adaptive offset, and an adaptive loop filter. In this case, the LX reference picture list is the reference picture list L2 or the reference picture list L3.

[0271] When the predetermined picture list involves multiple prediction blocks, the final prediction block of the current block is obtained based on the weighted sum of the multiple prediction blocks. In this case, the weights applied to the prediction blocks derived from the same reference picture list have the same value or different values.

[0272] The weight WF_LX or offset OFFSET_LX for each prediction block is a coding parameter to be entropy encoded / decoded. In another example, the weight and offset are derived from the encoded / decoded neighboring blocks adjacent to the current block. Here, the neighboring blocks adjacent to the current block include a block for deriving a spatial motion vector candidate for the current block, a block for deriving a temporal motion vector candidate for the current block, or a block for deriving a spatial motion vector candidate for the current block and a block for deriving a temporal motion vector candidate for the current block.

[0273] In another example, the weight and offset of the current block are determined according to the display order of each reference picture, i.e., the picture order count (POC). In this case, as the distance between the current picture and the reference picture increases, the weight or offset is set to a smaller value. Conversely, as the distance between the current picture and the reference picture decreases, the weight or offset is set to a larger value.

[0274] For example, when the POC difference between the current picture and the L0 reference picture is 2, the weight applied to the prediction block generated by referring to the L0 reference picture is set to 1 / 3. On the other hand, when the POC difference between the current picture and the L0 reference picture is 1, the weight applied to the prediction block generated by referring to the L0 reference picture is set to 2 / 3. That is, the weight or offset is inversely proportional to the POC difference between the current picture and the reference picture. Alternatively, the weight or offset may be proportional to the POC difference between the current picture and the reference picture.

[0275] Optionally, the encoder or decoder performs entropy encoding / decoding on the weight and / or offset of the current block based on at least one coding parameter. Optionally, the encoder or decoder calculates a weighted sum of the prediction block based on at least one coding parameter.

[0276] The weighted sum of the multiple prediction blocks is applied only to a partial area within the prediction block. Here, the partial area represents the boundary of the prediction block. In order to apply the weighted sum only to the partial area as described above, the encoder or decoder performs a weighted sum operation on each sub-block within the prediction block.

[0277] For each of the subblocks existing within the block indicated by the region information, inter prediction or motion compensation is performed by using the same prediction block or the same final prediction block.

[0278] Furthermore, for each of the subblocks having a block depth deeper than the block indicated by the region information, inter prediction or motion compensation is performed by using the same prediction block or the same final prediction block.

[0279] When calculating the weighted sum of the prediction block by prediction using a motion vector, the encoder or decoder calculates the weighted sum by using at least one motion vector candidate within the motion vector candidate list and uses the weighted sum (weighted prediction block) as the final prediction block of the current block.

[0280] For example, an encoder or a decoder generates a prediction block using only spatial motion vector candidates, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block of the current block.

[0281] Alternatively, the encoder or decoder may generate a prediction block using the spatial motion vector candidate and the temporal motion vector candidate, calculate a weighted sum of the prediction blocks, and use the weighted sum (weighted prediction block) as a final prediction block of the current block.

[0282] Alternatively, the encoder or decoder generates a prediction block using only the combined motion vector candidates, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block for the current block.

[0283] Alternatively, the encoder or decoder generates a prediction block using only the motion vector candidates indicated by a specific motion vector candidate index, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block of the current block.

[0284] Alternatively, the encoder or decoder generates a prediction block using only motion vector candidates indicated by a specific range of motion vector candidate indices, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block for the current block.

[0285] When calculating the weighted sum of a prediction block by using the merge mode, the encoder or the decoder calculates the weighted sum by using at least one merge candidate existing in the merge candidate list and uses the weighted sum (weighted prediction block) as the final prediction block of the current block.

[0286] For example, the encoder or the decoder generates a prediction block using only the spatial merging candidates, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block of the current block.

[0287] Furthermore, for example, the encoder or the decoder generates a prediction block using both the spatial merging candidate and the temporal merging candidate, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block of the current block.

[0288] Furthermore, for example, the encoder or the decoder generates a prediction block using only the combined merging candidates, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block of the current block.

[0289] Furthermore, for example, the encoder or the decoder generates a prediction block using only merge candidates having a specific merge candidate index, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block of the current block.

[0290] Furthermore, for example, the encoder or decoder generates a prediction block using only merge candidates having merge candidate indices within a specific range, calculates a weighted sum of the prediction blocks, and uses the weighted sum (weighted prediction block) as a final prediction block of the current block.

[0291] The encoder or decoder uses the motion vector (motion information) of the current block to perform motion compensation. In this case, the final prediction block as a result of motion compensation is generated by using at least one prediction block. Here, the current block refers to the current coding block, the current prediction block, or both the current coding block and the current prediction block.

[0292] Next, the steps of entropy encoding / decoding the motion compensation information (S540 and S610) will be described in detail.

[0293] The encoder entropy encodes “information associated with compensation” (hereinafter referred to as motion compensation information) into a bitstream, and the decoder entropy decodes the motion compensation information included in the bitstream. The motion compensation information to be entropy encoded / decoded includes at least one of an inter-frame prediction indicator (Inter_pred_idc), reference picture indexes (ref_idx_l0, ref_idx_l1, ref_idx_l2, and ref_idx_l3), motion vector candidate indexes (mvp_l0_idx, mvp_l1_idx, mvp_l2_idx, and mvp_l3_idx), motion vector difference, skip mode utilization information (cu_skip_flag), merge mode utilization information (merge_flag), merge index information (merge_index), merge mode-based motion vector correction utilization information (fruc_flag), weights (wf_l0, wf_l1, wf_l2, and wf_l3), and offsets (offset_l0, offset_l1, offset_l2, and offset_l3).

[0294] When the current block is encoded / decoded by inter-frame prediction, the inter-frame prediction indicator indicates the inter-frame prediction direction of the current block and / or the number of prediction directions of the current block, for example, the inter-frame prediction indicator indicates unidirectional prediction or multi-directional prediction (for example, bidirectional prediction, tri-directional prediction or quad-directional prediction). The inter-frame prediction indicator also indicates the number of reference pictures to be used to generate the prediction block of the current block. One reference picture can be used for multi-directional prediction. In this case, M reference pictures are used to perform predictions in N directions (N>M). In addition, the inter-frame prediction indicator indicates the inter-frame prediction mode of the current block or the number of prediction blocks used for motion compensation of the current block.

[0295] The reference picture indicator indicates the directionality of prediction, such as unidirectional (PRED_LX), bidirectional (PRED_BI), tridirectional (PRED_TRI), quaddirectional (PRED_QUAD), or more multidirectional, ie, the number of prediction directions in the current block.

[0296] A prediction list utilizes a flag to indicate whether the associated reference picture list is used to generate the prediction block.

[0297] The reference picture index specifies a reference picture to be referenced by the current block among the reference pictures in the reference picture list. For each reference picture list, one or more reference picture indexes are entropy encoded / decoded. Motion compensation is performed by using one or more reference picture indexes for the current block.

[0298] For each corresponding reference picture list or each corresponding reference picture index, the motion vector candidate index indicates a motion vector candidate for the current block. Entropy encoding / decoding is performed on at least one motion vector candidate index for each motion vector candidate list. At least one motion vector candidate index is used to perform motion compensation for the current block.

[0299] The motion vector difference represents the difference between the original motion vector and the predicted motion vector. For each motion vector candidate list in the motion vector candidate list corresponding to the corresponding reference picture index or corresponding to the corresponding reference picture list, one or more motion vector differences are entropy encoded / decoded. One or more motion vector differences are used for motion compensation of the current block.

[0300] Regarding the skip mode utilization information (cu_skip_flag), a first value of 1 indicates that the skip mode is used, and a second value of 0 indicates that the skip mode is not used. Motion compensation of the current block is performed according to the skip mode utilization information.

[0301] Regarding the merge mode utilization information (merge_flag), a first value of 1 indicates that the merge mode is used, and a second value of 0 indicates that the merge mode is not used. Motion compensation of the current block is performed according to the merge mode utilization information.

[0302] The merge index information (merge_index) represents information indicating a merge candidate in the merge candidate list.

[0303] For example, the merge index information indicates information of the merge index.

[0304] In addition, for example, the merge index information indicates a reconstructed neighboring block from which a merge candidate has been derived, among reconstructed neighboring blocks spatially / temporally adjacent to the current block.

[0305] In addition, for example, the merge index information indicates at least one piece of motion information of the merge candidate. For example, the first value (e.g., 0) of the merge index information indicates the first merge candidate in the merge candidate list, the second value (e.g., 1) indicates the second merge candidate in the merge candidate list, and the third value (e.g., 2) indicates the third merge candidate in the merge candidate list. Similarly, the fourth value to the Nth value respectively indicate the fourth merge candidate to the Nth merge candidate in the merge candidate list. Wherein, N is a positive integer or zero.

[0306] Motion compensation of the current block is performed based on the merge mode index information.

[0307] The motion vector correction utilization information based on the merge mode (fruc_flag) is information indicating whether to perform motion vector correction based on the merge mode. The motion vector correction utilization information based on the merge mode is entropy encoded / decoded on a per coding unit or per prediction block basis.

[0308] For example, regarding the merge mode-based motion vector correction utilization information, a first value of 1 indicates that merge mode-based motion vector correction is performed, and a second value of 0 indicates that merge mode-based motion vector correction is not performed. Here, the first value and the second value may be exchanged.

[0309] Alternatively, whether to perform motion vector correction may be determined based on different inter prediction modes predefined in the encoder and the decoder (e.g., skip mode, AMVP, etc.). That is, even when merge mode-based motion vector correction utilization information (fruc_flag) is not explicitly signaled, whether to use motion vector correction may be determined according to a predetermined criterion.

[0310] On the other hand, when the merge mode utilization information (merge_flag) has the first value indicating that the merge mode is used, the motion vector correction utilization information (fruc_flag) based on the merge mode is entropy-decoded.

[0311] On the other hand, when the merge mode utilization information (merge_flag) has the second value indicating that the merge mode is not used, the motion vector correction utilization information (fruc_flag) based on the merge mode is entropy-decoded.

[0312] When two or more prediction blocks are generated by motion compensation of the current block, a final prediction block of the current block is generated by calculating a weighted sum of each prediction block. When calculating the weighted sum, weights and / or offsets are applied to each prediction block. At least one weighting factor selected from a reference picture list, a reference picture, a motion vector candidate index, a motion vector difference, a motion vector, a skip mode utilization flag, a merge mode utilization flag, and merge index information is entropy encoded / decoded. In addition, the weighting factor of each prediction block is entropy encoded / decoded according to an inter-frame prediction indicator. Here, the weighting factor includes a weight, an offset, or both a weight and an offset.

[0313] When entropy encoding / decoding the motion compensation information on a per-CTU basis, motion compensation is performed on all or part of the blocks within the CTU using the motion compensation information, depending on the value of the motion compensation information.

[0314] When the motion compensation information is entropy encoded / decoded at a CTU level or a sub-CTU level, the motion compensation information is entropy encoded / decoded according to at least one of a predetermined block size or a predetermined block depth.

[0315] Here, the information of the predetermined block size or the predetermined block depth is additionally entropy encoded / decoded. Optionally, the information of the predetermined block size or the predetermined block depth is determined according to at least one of a value preset in the encoder and the decoder, a coding parameter, and a syntax element value.

[0316] The motion compensation information is entropy encoded / decoded only in a block having a block size equal to or larger than a predetermined block size. However, the motion compensation information is not entropy encoded / decoded in a block having a block size smaller than a predetermined block size.

[0317] In this case, motion compensation is performed on subblocks within a block having a block size equal to or greater than a predetermined block size based on entropy encoded / decoded motion compensation information of a block having a block size equal to or greater than a predetermined block size. That is, subblocks within a block having a block size equal to or greater than a predetermined block size share motion compensation information including motion vector candidates, motion vector candidate lists, merge candidates, and merge candidate lists.

[0318] The motion compensation information is entropy encoded / decoded only in blocks having a block depth equal to or less than a predetermined block depth value, and is not entropy encoded / decoded in blocks having a block depth greater than the predetermined block depth value.

[0319] In this case, based on the entropy encoded / decoded motion compensation information of the block whose block depth is equal to or less than the predetermined block depth value, motion compensation is performed on the sub-blocks in the block whose block depth is equal to or less than the predetermined block depth value. That is, the sub-blocks in the block whose block depth is equal to or less than the predetermined block depth value share the motion compensation information including the motion vector candidate, the motion vector candidate list, the merge candidate, and the merge candidate list.

[0320] The motion compensation information is entropy encoded / decoded on a per-block basis, or entropy encoded / decoded at a higher level. For example, the motion compensation information is entropy encoded / decoded on a per-block basis (i.e., per-CTU, per-CU, or per-PU), or entropy encoded / decoded at a higher level (e.g., video parameter set, sequence parameter set, picture parameter set, adaptation parameter set, parallel block group header, or slice header).

[0321] The motion compensation information is entropy encoded / decoded according to a motion compensation information difference value which is a difference between the motion compensation information and predicted motion compensation information (ie, a predicted value of the motion compensation information).

[0322] Motion compensation information of a previously encoded / decoded neighboring block may be used as motion compensation information of a current block instead of entropy encoding / decoding the motion compensation information of the current block.

[0323] At least one piece of motion compensation information is derived based on at least one encoding parameter.

[0324] Furthermore, the decoder entropy decodes at least one piece of motion compensation information extracted from the bitstream according to the at least one encoding parameter. The encoder entropy encodes at least one piece of motion compensation information according to the at least one encoding parameter.

[0325] The motion compensation information includes at least one of a motion vector, a motion vector candidate, a motion vector candidate value, a motion vector difference, a motion vector prediction value, skip mode utilization information (skip_flag), merge mode utilization information (merge_flag), motion vector resolution information, overlapped block motion compensation information, local illumination compensation information, affine motion compensation information, decoder side motion vector derivation information, and bidirectional optical flow information. Here, the decoder side motion vector derivation means pattern matching motion vector derivation.

[0326] The motion vector resolution information indicates information indicating a specific resolution of a motion vector, a motion vector difference, or both a specific resolution of a motion vector and a motion vector difference. Here, the resolution indicates accuracy. In addition, a specific resolution is selected from 16-pel, 8-pel, 4-pel, integer-pel, 1 / 16-pel, 1 / 4-pel, 1 / 8-pel, 1 / 32-pel, and 1 / 64-pel.

[0327] Here, the overlapped block motion compensation information refers to information indicating whether to calculate a weighted sum of prediction blocks of the current block by using motion vectors of neighboring blocks spatially adjacent to the current block during motion compensation of the current block.

[0328] The local illumination compensation information refers to information indicating whether at least one of a weight and an offset is applied when generating a prediction block of a current block. Here, the weight, the offset, or both the weight and the offset are derived from a reference block.

[0329] The affine motion compensation information indicates whether an affine motion model is used during motion compensation of the current block. Here, the affine motion model refers to a process of dividing a block into a plurality of sub-blocks by using a plurality of parameters and generating motion vectors of the sub-blocks by using a representative motion vector.

[0330] The decoder-side motion vector derivation information indicates whether the motion vector required for motion compensation is to be derived by the decoder. Depending on the decoder-side motion vector derivation information, the motion vector information may not be entropy encoded / decoded. For example, when the decoder-side motion vector derivation information indicates that the decoder uses the motion vector, the merge mode utilization information is entropy encoded / decoded. That is, the decoder-side motion vector derivation information indicates whether the merge mode is used in the decoder.

[0331] The bidirectional optical flow information indicates whether to perform motion compensation by modifying the motion vector on a per-pixel basis or on a per-sub-block basis. According to the bidirectional optical flow information, entropy encoding / decoding is not performed on the pixel-based motion vector or the sub-block-based motion vector. Here, the motion vector modification indicates changing the block-based motion vector value to a pixel-based motion vector value or to a sub-block-based motion vector value.

[0332] The encoder or the decoder performs motion compensation on the current block by using the at least one piece of motion compensation information, and entropy encodes / decodes the at least one piece of motion compensation information.

[0333] When entropy encoding / decoding motion compensation information, a binarization method is used, such as a truncated Rice binarization method, a k-order Exp_Golomb binarization method, a restricted k-order exponential Golomb binarization method, a fixed-length binarization method, a unary binarization method, or a truncated unary binarization method.

[0334] When entropy encoding / decoding motion compensation information, a context model is determined based on at least one of the following information: motion compensation information or region information of a neighboring block; previously encoded / decoded motion compensation information or region information; block depth information of a current block and block size information of a current block.

[0335] When entropy encoding / decoding motion compensation information, at least one of motion compensation information of neighboring blocks, previously encoded / decoded motion compensation information, block depth information of the current block, and block size information of the current block is used as motion compensation information of the current block.

[0336] In the following, reference will be made to Figures 7 to 42 A specific embodiment of the motion vector correction method according to the present invention is described.

[0337] In order to derive the motion vector of the current block, at least one of a motion vector derivation method based on skip / merge mode and a derivation method based on enhanced motion vector prediction mode is used. Here, the derivation of the motion vector includes deriving the motion vector of the current block and deriving the reference picture index information of the current block.

[0338] Hereinafter, the motion vector correction method based on the merge mode will be described in detail. However, the following description is applicable to the motion vector correction method based on the merge mode as well as to the motion vector correction method based on the inter prediction mode other than the merge mode.

[0339] Figure 8 is a flow chart showing a motion vector correction method according to an embodiment of the present invention.

[0340] The motion vector correction method according to the present invention includes a step S810 of deriving an initial motion vector of a current block and a step S820 of deriving a corrected motion vector from the initial motion vector. In this case, the step S820 of deriving a corrected motion vector includes deriving a motion vector corrected in units of sub-blocks.

[0341] First, step S810 of deriving an initial motion vector of a current block will be described in detail.

[0342] An initial motion vector of the current block is derived using a merge candidate that exists in a merge candidate list and is derived from a spatially neighboring block, a temporally neighboring block, or both a spatially neighboring block and a temporally neighboring block.

[0343] Optionally, the encoder or decoder may construct an additional merge candidate list dedicated for merge mode based motion vector correction.

[0344] Fig. 9 is a diagram illustrating spatially neighboring blocks and temporally neighboring blocks used to construct an additional merge candidate list.

[0345] Reference Fig. 9 , when constructing an additional merge candidate list, a predetermined number of candidates are derived from spatial neighboring blocks A0, A1, A2, B0, A0, B2, and B3 in the order of A0, A1, A2, B0, A0, B2, and B3, and then the predetermined number of candidates are inserted into the merge candidate list in the order of A1, B1, B0, A0, B2, B3, and A2. Then, the merge candidates derived from the temporal neighboring blocks, the combined bi-directional prediction merge candidates, and the zero merge candidates are inserted into another additional merge candidate list.

[0346] The encoder or decoder entropy encodes / decodes information indicating the maximum number of candidates to be included in the additional merge candidate list to be used for motion vector correction based on merge mode at one or more levels selected from video parameter sets, sequence parameter sets, picture parameter sets, adaptation parameter sets, tile group headers, slice headers, tiles, CTUs, and blocks.

[0347] The maximum number of candidates to be included in the additional merge candidate list to be used for merge mode-based motion vector correction is set commonly in the encoder and the decoder.

[0348] When constructing a merge mode candidate list to be used for merge mode-based motion vector correction, information of spatially neighboring blocks is not included in the list when the neighboring blocks are within the same motion estimation region (MER).

[0349] A largest coding unit (LCU) is split into N non-overlapping motion estimation regions, and parallel motion prediction is performed on coding units belonging to the same motion estimation region (MER).

[0350] Fig.10 is a diagram illustrating a motion vector correction method using a motion estimation area.

[0351] like Fig.10 As shown in , since the left neighboring blocks A1 and A2 of the current block CU5 existing in the motion estimation region MER3 belong to the same motion estimation region MER3, they are not included in the list.

[0352] Here, a motion estimation region (MER) is generated by performing quadtree partitioning on a maximum coding unit (LCU) similarly in an encoder and a decoder. On the other hand, partition information for generating a motion estimation region (MER) is determined by an encoder and then entropy encoded / decoded at one or more levels selected from a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, and a slice header.

[0353] On the other hand, when a merge candidate in the merge candidate list is used, an initial motion vector of the current block may be derived by using all or part of the merge candidates in the merge candidate list.

[0354] For example, when a merge candidate in a merge candidate list has motion information derived in units of sub-blocks (hereinafter referred to as sub-block-based motion information), the encoder or decoder replaces the merge candidate with the sub-block-based motion information with the motion information derived from additional spatial neighboring blocks and / or temporal neighboring blocks during construction of the merge candidate list, or does not use the merge candidate with the sub-block-based motion information as an initial motion vector.

[0355] In other words, when merge candidates in the merge candidate list have motion information derived in sub-block units, the encoder or decoder uses those merge candidates as initial motion vectors only when the size of the current block is equal to or smaller than a sub-block size that is preset or signaled at the level of a sequence parameter set (SPS), a picture parameter set (PPS), a tile group header, a slice header, a tile, or a CTU.

[0356] In addition, for example, the encoder or decoder uses the motion vector candidate as the initial motion vector only when the merge type of the merge candidate in the merge candidate list is a general (basic) merge candidate (e.g., MRG_TYPE_DEFAULT_N) (not a sub-block based merge candidate (e.g., MRG_TYPE_SUBPU_ATMVP)).

[0357] Furthermore, for example, when the merge type of a merge candidate in the merge candidate list is current picture reference (CPR, for example, MRG_TYPE_IBC or MRG_TYPE_CRP), the encoder or the decoder does not use the motion vector of the merge candidate as an initial motion vector.

[0358] In addition, for example, only N candidates in the merge candidate list are used as initial motion vectors. Here, N is a natural number greater than 0 and not exceeding the maximum number of candidates included in the merge candidate list.

[0359] Fig.11 and Fig.12 is a diagram illustrating a method of constructing an initial motion vector list.

[0360] When Fig.11 When constructing the merge candidate list as shown in , the initial motion vector list for each direction is constructed using the merge candidates corresponding to each list direction. Here, the initial motion vector list includes a motion vector, a reference picture index, or both a motion vector and a reference picture index.

[0361] For example, the initial motion vector list only takes motion vectors from the merge candidate list, and the reference picture index uses a fixed predetermined value. Here, the fixed predetermined value is a value signaled from the encoder to the decoder, or a value shared by the encoder and the decoder.

[0362] On the other hand, when the reference picture index information of the merge candidate in the merge candidate list does not match the predetermined reference picture index information of the initial motion vector list, the encoder or decoder uses the scaled motion vector as the initial motion vector by reflecting the temporal distance (or POC difference).

[0363] When building an initial motion vector list, the encoder or decoder does not add motion information when the same motion vector and the same reference picture index already exist in the list.

[0364] Fig.13 is a diagram illustrating a method of deriving an initial motion vector using merge index information.

[0365] Motion information of a merge candidate corresponding to the merge index information among the merge candidates in the merge candidate list may be used as an initial motion vector.

[0366] like Fig.13 As shown in , when the merge index information value is 3, the encoder or decoder derives the L0 list [motion vector: (3,1), reference picture index: 0] and the L1 list [motion vector: (-3,0), reference picture index: 0] corresponding to the fourth candidate in the merge candidate list as the initial motion vectors for the corresponding list directions.

[0367] On the other hand, when the merge index information value is 4, the encoder or decoder derives only the L0 list [motion vector: (6, 2), reference picture index: 0] corresponding to the fifth candidate in the merge candidate list as the initial motion vector. Here, the merge index information refers to index information indicating a merge mode.

[0368] On the other hand, a flag indicating whether to perform motion vector correction based on merge mode is defined. For example, when the motion vector correction flag indicating whether to perform motion vector correction has a first value, the encoder or decoder corrects the initial motion vector. On the other hand, when the motion vector correction utilization flag has a second value, the encoder or decoder does not perform initial motion vector correction. The motion vector correction utilization flag may have a value that is signaled from the encoder to the decoder via a bitstream and may be entropy encoded / decoded on a per-coding block basis.

[0369] In addition, initial motion vector index information for motion vector correction based on merge mode is defined, and then the initial motion vector index information is entropy encoded / decoded based on each coding block. The motion vector index information may be a value indicating an initial motion vector to be subjected to motion vector correction, and may be a value defined separately from the merge index information.

[0370] For example, the initial motion vector index information is defined in the form of a flag value. For example, the initial motion vector index information may have a first value or a second value.

[0371] The encoder or the decoder uses the initial motion vector index information to select an initial motion vector to be used for motion vector correction based on the merge mode from among a plurality of motion vector candidates.

[0372] In addition, a modified motion vector parameter to be used for motion vector correction based on merge mode is defined and entropy encoded / decoded on a per coding block basis. Here, the modified motion vector refers to a motion vector to be added to the initial motion vector to obtain a modified motion vector.

[0373] For example, the modified motion vector parameter includes modified motion vector magnitude index information indicating the magnitude of the modified motion vector and modified motion vector direction index information indicating the direction of the modified motion vector.

[0374] For example, the size of the modified motion vector has a value in the range of 1 to 128, and the modified motion vector size index information indicates one of the size values ​​of the modified motion vector. For example, the modified motion vector size index information indicates a value satisfying 2^N (N is an integer ranging from 0 to 7) among the values ​​in the range of 1 to 128. That is, the size of the modified motion vector has a value of 1, 2, 4, 8, 16, 32, 64, or 128.

[0375] In addition, the encoder or decoder obtains the final corrected motion vector by multiplying the corrected motion vector magnitude value (indicated by the corrected motion vector magnitude index information) by a predetermined value, or by performing a left shift operation on the corrected motion vector magnitude value. In this case, the predetermined value is a value commonly defined in the encoder and the decoder. For example, the predetermined value multiplied by the corrected motion vector magnitude value may be 4, and the predetermined value used in the left shift operation may be 2.

[0376] When the preset value used in the left shift operation is 2, the size of the final modified motion vector has a value of 4, 8, 16, 32, 64, 128 or 256, which in terms of integer pixel units may be 1 / 4, 1 / 2, 1, 2, 4, 8, 16 and 32, respectively.

[0377] On the other hand, the size of the corrected motion vector is determined based on each integer pixel or each sub-pixel. To this end, the corrected motion vector unit index information or flag (tile_group_fpel_mmvd_enabled_flag) indicating the unit size of the corrected motion vector is defined and entropy encoded / decoded for each slice, tile, or tile group. In addition, for example, when the size of the corrected motion vector is determined in units of integer pixels, the size of the corrected motion vector has a value ranging from 4 to 512, and the corrected motion vector size index information is one of those corrected vector size values. For example, the corrected motion vector size index information is a value that satisfies 2^N (N is an integer ranging from 2 to 9) among the values ​​of 4 to 512.

[0378] In addition, the encoder or decoder obtains the final corrected motion vector by multiplying the corrected motion vector magnitude value (indicated by the corrected motion vector magnitude index information) by a predetermined value, or by performing a left shift operation on the corrected motion vector magnitude value. In this case, the predetermined value is a value commonly defined in the encoder and the decoder. For example, the predetermined value multiplied by the corrected motion vector magnitude value may be 4, and the predetermined value used in the left shift operation may be 2.

[0379] When the preset value used in the left shift operation is 2, the size of the final modified motion vector has a value of 16, 32, 64, 128, 256, 512 or 1024, which means 1, 2, 4, 8, 16, 32, 64 or 128 in terms of integer pixels.

[0380] The encoder or the decoder derives the modified motion vector to derive a modified motion vector based on the modified motion vector parameters.

[0381] On the other hand, when a merge candidate in the merge candidate list is used, the decoder does not entropy decode the merge index information, and sets the merge candidate motion vector corresponding to the predetermined number among the merge candidates in the merge candidate list as the initial motion vector. Here, the predetermined number is a number set in common in the encoder and the decoder.

[0382] For example, when it is assumed that a motion vector corresponding to the first candidate in the merge candidate list is used as an initial motion vector in the encoder / decoder, the encoder or decoder uses Fig.13 The first candidate in the merge candidate list corresponds to the L0 list [motion vector: (3, 1), reference picture index: 0] and the L1 list [motion vector: (-2, 0), reference picture index: 0].

[0383] On the other hand, when a merge candidate in a merge candidate list is used, when the current block is a bidirectionally predictable block and has only motion information corresponding to the L0 list or the L1 list, new motion information derived from the existing motion information may be used as additional initial motion information. Here, the existing motion information is the motion information of another merge candidate in the same list.

[0384] When additional motion information is derived based on existing motion information as described above, an additional motion vector used to replace the motion information is derived based on the temporal distance (or POC) between the reference picture indicated by the existing motion information, the current picture to which the current block belongs, or the reference picture in the reference picture list for which motion information needs to be generated.

[0385] Specifically, mirroring, scaling, or both mirroring and scaling are performed on the existing motion vector to derive an additional initial motion vector to replace the non-existent motion vector.

[0386] exist Fig.13 In the example, when the merge index information has a value of 2, only L0 motion information may exist. In this case, the L0 motion vector is derived as an L1 list motion vector, wherein the L0 motion vector is mirrored with respect to a reference picture in the L1 reference picture list whose POC difference is equal to the POC difference between the reference picture indicated by the L0 motion vector and the current picture to which the current block belongs.

[0387] In addition, except for the reference pictures in the L1 list that have the same POC as the reference picture indicated by the L0 motion vector, the picture with the minimum POC difference from the current picture is derived as the L1 reference picture, and the scaled L0 motion vector scaled according to the POC difference between the L0 reference picture and the current picture and the derived POC difference between the L1 reference picture and the current picture is derived as the L1 motion vector.

[0388] Fig.14 is a diagram illustrating a method of mirroring a motion vector.

[0389] Reference Fig.14 , an L0 motion vector obtained by mirroring the following reference picture in the L1 reference picture list is derived as the L1 motion vector: the POC difference of this reference picture is equal to the POC difference between the reference picture indicated by the L0 motion vector and the picture to which the current block belongs.

[0390] Specifically, since the POC of the reference picture indicated by the L0 motion vector is 0 and the POC of the current picture is 4, the POC difference between the two pictures is 4. Since there is a reference picture having a POC difference of 4 with the current picture among the reference pictures in the direction of the L1 list, a motion vector is generated by mirroring the L0 motion vector, and the reference picture index of the reference picture is used as the L1 motion information. Here, the L1 motion vector generated by mirroring the L0 motion vector in the direction of the L1 list is (3, 1), and the L1 reference picture index is 0.

[0391] Fig.15 is a diagram illustrating a method of scaling a motion vector.

[0392] Reference Fig.15 , except for the reference pictures in the L1 list that have the same POC as the reference picture indicated by the L0 motion vector, the picture with the minimum POC difference with the current picture is derived as the L1 reference picture. Next, the L0 motion vector scaled according to the POC difference between the L0 reference picture and the current picture and the derived POC difference between the L1 reference picture and the current picture is determined as the L1 direction motion vector.

[0393] Specifically, in addition to the reference picture POC2 indicated by the L0 motion vector, the picture POC1 having the minimum POC difference with the current picture is derived as the L1 reference picture. The L0 motion vector scaled by considering the POC difference tb between the L0 reference picture and the current picture and the POC difference td between the L1 reference picture and the current picture is derived as the L1 direction motion vector.

[0394] Hereinafter, the process of scaling the motion vector will be described in more detail.

[0395] The POC difference td represents the difference between the picture order count (POC) of the current picture and the picture order count (POC) of the L1 reference picture of the current block. The POC difference tb represents the difference between the POC of the current picture and the POC of the L0 reference picture of the current block.

[0396] The td value, the tb value, or both the td value and the tb value are adjusted so that the td value or the tb value is included in the range from -128 to 127. When the td value or the tb value is less than -128, the td value or the tb value is adjusted to -128. When the td value or the tb value is greater than 127, the td value or the tb value is adjusted to 127. When the td value or the tb value is within the range from -128 to 127, the td value or the tb value is not adjusted. That is, the td value or the tb value may be clipped so that the td value or the tb value falls within a predetermined value range.

[0397] In this case, the tx value is obtained by (16384Abs(td / 2)) / td. Here, Abs() represents an absolute value function, and the output value of this function is always the absolute value of the input value.

[0398] The scaling factor DistScaleFactor is obtained by (tb*tx+32)>>6, and the scaling factor DistScaleFactor is adjusted to fall within the range of -1024 to 1023.

[0399] The scaled motion vector is obtained by Sign(DistScaleFactor*mv)*((Abs(DistScaleFactor*mv)127)>>8). At this time, sign() is a function that outputs sign information of a specific value. For example, sign(-1) outputs "-". In addition, mv represents the unscaled motion vector value.

[0400] Fig.16 is a diagram showing a method of deriving an additional motion vector when a motion vector corresponding to only one of the L0 list and the L1 list exists in a bidirectionally predictable block.

[0401] When using a merge candidate in a merge candidate list, when there is only one merge candidate corresponding to the L0 list or the L1 list although the current block is a bidirectionally predictable block, an additional motion vector is derived to construct a merge candidate list for a direction in which no motion vector exists.

[0402] Reference Fig.16 , when the merge index information value is 2, there is only an L0 motion vector. In this case, the nth available motion vector in the L1 list is used as the initial L1 motion vector of the current block. Here, n is a value commonly set in the encoder and decoder, and is a positive integer including 1.

[0403] Fig.17 is a diagram illustrating an exemplary method of selecting a merge candidate having bidirectional motion information as an initial motion vector in a bidirectionally predictable block.

[0404] In the case of using a merge candidate in the merge candidate list, when the current block is a bidirectional predictable block, the motion vector of the merge candidate with bidirectional motion information among the merge candidates in the merge candidate list is used as the initial motion vector. Here, when there are multiple candidates with bidirectional motion information, the candidate with the smallest merge index information is used for bidirectional prediction.

[0405] Reference Fig.17 , when the current block is a bidirectional predictable block, the motion vector corresponding to the merge candidate index 3 which is the first available merge candidate motion vector having bidirectional motion information is used.

[0406] When there is no reference picture satisfying the above conditions, the motion information of the merge candidate selected by the existing merge index information is derived as the initial motion vector.

[0407] On the other hand, when a merge candidate in a merge candidate list is used, a motion vector of the merge candidate that satisfies a specific condition is used as an initial motion vector. The specific condition refers to 1) only a first POC difference value (POCref0-POCcurr) or a second POC difference value (POCref1-POCcurr) has a negative value, wherein the first POC difference value is a POC difference value (POCref0-POCcurr) between a target picture to be encoded / decoded and a first reference picture corresponding to a first prediction direction (e.g., L0 prediction direction) in a merge candidate having dual prediction information, and the second POC difference value is a POC difference value (POCref1-POCurr) between a target picture to be encoded / decoded and a second reference picture corresponding to a second prediction direction (e.g., L1 prediction direction), and / or 2) a merge candidate in the merge candidate list presents a motion vector difference greater than a predetermined threshold value (e.g., one integer pixel) with each of the other merge candidates in the merge candidate list.

[0408] Here, the predetermined threshold value varies depending on the size of the current block or the number of pixels constituting the current block. For example, when the number of pixels constituting the current block is less than 64, one integer pixel value is used. On the other hand, when the number of pixels constituting the current block ranges from 64 to 256, 2 integer pixel values ​​are used. When the number of pixels constituting the current block is 256, 4 integer pixel values ​​are used.

[0409] On the other hand, the encoder or decoder may not use a variable threshold value determined according to the size or number of pixels of the current block, but may use a predetermined threshold value preset in the encoder or decoder. Alternatively, the encoder or decoder may derive and use a threshold value according to the size of the current block or the number of pixels in the current block, wherein the size of the current block or the number of pixels in the current block is determined based on the threshold value signaled to the decoder via a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, a slice header, a tile, a CTU, a CU, or a block.

[0410] For example, when the predetermined threshold MV_THR is 4 integer pixels, an integer number of pixels is used when the number of pixels of the current block is less than 64 (MV_THR(4)>>2). When the number of pixels of the current block ranges from 64 to 256, an integer number of pixels is used (MV_THR(4)>>1). When the number of pixels in the current block is greater than 256, an integer number of pixels is used (MV_THR(4)>>0).

[0411] On the other hand, when a merge candidate in the merge candidate list is used, when the first POC difference value (POCref0-POCcurr) and the second POC difference value (POCref1-POCcurr) have negative values, the motion information of the merge candidate that satisfies the conditions described below is used as the initial motion information, wherein the first POC difference value represents the POC difference value between the encoding / decoding target picture and the first reference picture corresponding to the first prediction direction (for example, L0 prediction direction) among the merge candidates with bidirectional motion information in the merge candidate list, and the second POC difference value represents the POC difference value between the encoding / decoding target block and the second reference picture corresponding to the second prediction direction (for example, L1 prediction direction).

[0412] Condition 1) POCref0 is not equal to POCref1.

[0413] Condition 2) The vertical motion vector and horizontal motion vector of MVref0 and MVref1 are not zero

[0414] Condition 3)((MVx0×(POCref1-–POCcurr)–-MVx1×(POCref0-–POCcurr))===0)&&((MVy0×(POCref1-–POCcur r)--MVy1×(POCref0--POCcurr))==0)or((MVx0×(POCref1--POCcurr)--MVx1×(POCref0--POCcurr)) <TH)&&((MVy0×(POCref1-–POCcurr))-–MVy1×(POCref0--POCcurr))<TH)

[0415] MVx0, MVy0, MVx1, and MVy1 represent a horizontal motion vector of a first reference picture, a vertical motion vector of a first reference picture, a horizontal motion vector of a second reference picture, and a vertical motion vector of a second reference picture, respectively. TH represents a threshold value that is a predetermined threshold value set in an encoder and a decoder, or a threshold value determined by an encoder and signaled to a decoder via at least one of a predetermined video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a slice header, a CTU, a CU, or a block.

[0416] When motion compensation of the current block is performed based on the initial motion vector derived by the above method, when the initial motion vector has a motion vector for each sub-pixel, motion compensation is performed based on the motion vector rounded to the nearest integer pixel position.

[0417] For example, when the motion vector has a motion vector precision of 1 / 16-pel, it is rounded to an integer pixel position by Equation 4. The shift value (shift) varies depending on the precision. For example, when the motion vector precision is 1 / 16-pel, the shift value is 4. When the motion vector precision is 1 / 8-pel, the shift value is 3.

[0418] [Equation 4]

[0419] roundMV(x,y)=((M x +(1<<shift-1))>>shift)<<shift, ((MV y +(1<<shift-1))>>shift)<<shift

[0420] Next, the step S820 of deriving the corrected motion vector by using the derived initial motion vector will be described in detail.

[0421] The encoder / decoder uses the derived initial motion vectors to perform block-based motion vector modification.

[0422] Regarding motion vector correction, the encoder or decoder corrects the initial motion vector by using the spatial neighboring blocks and / or the temporal neighboring blocks of the current block. The reconstructed pixels in the spatial neighboring blocks and / or the temporal neighboring blocks used for motion vector correction are defined as templates. The reconstructed pixels represent the reconstructed neighboring samples after filtering by in-loop filtering, or the unfiltered reconstructed neighboring blocks that have not passed through an in-loop filter (such as a deblocking filter, sample adaptive offset (SAO) or adaptive loop filter (ALF)).

[0423] For example, the encoder or decoder constructs a template using spatially reconstructed spatially neighboring pixels of the current block, and uses the template to correct the initial motion vector.

[0424] Constructing a template using reconstructed pixels in temporally neighboring blocks means that the template is composed of reconstructed pixels or interpolated pixels in a reference picture, wherein the reference picture is indicated by motion information of an upper neighboring block of the current block and / or motion information of a left neighboring block of the current block.

[0425] Figures 18 to 21 is a diagram illustrating a template according to an embodiment of the present invention.

[0426] Regarding template construction, the encoder or decoder can use Figure 8 The template is constructed by using pixels in the reconstructed upper neighboring block and / or the reconstructed left neighboring block shown in .

[0427] Here, when there are unavailable pixels among pixels of a reconstructed upper neighboring block or a left neighboring block of a current block, the encoder or the decoder may construct a template using only pixels of an available block.

[0428] For example, Fig.19 As shown in , when the reconstructed upper neighboring block of the current block is not available because it is adjacent to a picture boundary, a slice boundary, a tile boundary, a tile group boundary, or a CTU boundary, the encoder or decoder constructs a template consisting of pixels of the reconstructed left neighboring block only. When the reconstructed left neighboring block of the current block is not available because it is adjacent to a picture boundary, a slice boundary, a tile boundary, a tile group boundary, or a CTU boundary, the encoder or decoder constructs a template consisting of pixels of the reconstructed upper neighboring block.

[0429] For example, when the reconstructed upper neighboring block of the current block is not available because it is adjacent to the CTU boundary and the pixels in the reconstructed left neighboring block are available, the encoder or decoder constructs the left template using the reconstructed left neighboring pixels. In this case, the horizontal size of the left template is N+m, and the vertical size is the same as the vertical size of the current block. Where N is the size of the template sent to the decoder or the fixed template size, and m is an integer value including zero.

[0430] When constructing a template, when a neighboring block of a current block belongs to the same motion estimation region as the current block, the encoder or the decoder determines that a block or template corresponding to the position is not available.

[0431] Fig.24 is a diagram illustrating a template construction process taking a motion estimation area into consideration.

[0432] Reference Fig.24, the encoder or decoder determines that the upper template is not available for the current block CU3 belonging to the motion estimation area 2, and the left template is not available for the current block CU5 belonging to the motion estimation area 3.

[0433] The motion estimation region is generated by partitioning a maximum coding unit (LCU) in a quadtree partition structure in the same manner in the encoder and the decoder. In another example, when the encoder signals at least one of a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, a slice header, and a tile to the decoder, the motion estimation region is generated according to partition information signaled to the decoder.

[0434] In another example, the encoder or the decoder constructs the template using only the reconstructed upper neighboring block or the left neighboring block of the current block regardless of the availability of the reconstructed upper neighboring block and the left neighboring block.

[0435] Fig.25 is a diagram showing a template constructed by using reconstructed pixel values ​​that are not filtered by the in-loop filter.

[0436] like Fig.25 As shown in , the encoder or decoder constructs an upper template using reconstructed pixel values ​​that are not filtered by an in-loop filter (such as a deblocking filter, a sample adaptive offset (SAO), and an adaptive loop filter) by performing hardware pipeline processing using only the upper neighboring blocks of the current block. When the template is constructed using only the upper neighboring blocks as described above, the horizontal size of the template is larger than the horizontal size of the current block.

[0437] In addition, when constructing a template, the encoder or decoder constructs the template by replacing unavailable pixels with available pixels. Here, available pixels include neighboring pixels adjacent to the current block, pixels derived by applying an interpolation filter to neighboring pixels, or pixels with values ​​predefined in the encoder and decoder. On the other hand, the template may consist of predicted pixel values ​​rather than reconstructed pixel values.

[0438] When a template is constructed using predicted pixel values ​​in a neighboring block adjacent to a current block, the template may be constructed by adding a reconstructed transform coefficient DC component to the predicted pixel value.

[0439] Fig.26 is a diagram showing a template composed of predicted pixel values ​​in neighboring blocks and reconstructed transform coefficient DC component values.

[0440] like Fig.26As shown in , the encoder or decoder constructs the template of the current block by summing the predicted pixel values ​​of the left neighboring blocks of the current block and the reconstructed transform coefficient DC components of the left neighboring blocks. When the encoder or decoder constructs the template using only the left neighboring blocks, the vertical size of the template is larger than the vertical size of the current block.

[0441] When constructing a template, when the motion vector is a sub-pixel motion vector, the encoder or decoder generates pixel values ​​at the corresponding position by applying an interpolation filter. Here, a bilinear filter, an 8-tap DCT-IF filter, etc. are used as interpolation filters. The encoder or decoder determines information about the interpolation filter to be used to construct the template. Optionally, the encoder or decoder determines to use a predetermined filter without sending information about the type of interpolation filter. The information of the interpolation filter type is sent via a bitstream with a signal.

[0442] On the other hand, the template has a size of M×N, where M and N are positive integers.

[0443] For example, Fig. 20 As shown in , when the size (width×length) of the current block is 64×32 and the pixel length of the template defined in the encoder and the decoder is 4 pixels, the size of the upper template is 64×4 and the size of the left template is 4×32.

[0444] The pixel length depends on the motion vector accuracy. For example, when the motion vector accuracy is 1 / 4 pixel and the block size is 16 pixels, the pixel length of the template is 4 pixels.

[0445] On the other hand, Fig.21 As shown in , when the width (horizontal size) of the current block is different from the height (vertical size) of the current block, the encoder or decoder sets the template size so that the upper template and the left template have the same size.

[0446] When constructing a template, when the size of the template is M×N, the M of the upper template has a value greater than the horizontal length of the current block, and the N of the upper template has a fixed pixel length defined by the encoder and the decoder. In addition, the N of the right template has a value greater than the vertical length of the current block, and the M of the right template has a fixed pixel length defined by the encoder and the decoder.

[0447] For example, when the size of the current block is 64×64 and the pixel length of the template defined by the encoder and the decoder is 6 pixels, the size of the upper template is 128×6 and the size of the left template is 6×128.

[0448] On the other hand, when constructing a template, the template has a size of M×N, and the size varies depending on the size or depth of the current block.

[0449] For example, when the size of the current block is 128×64 and the horizontal length or the vertical length is greater than 32, the size of the upper template is 128×6 and the size of the left template is 6×64.

[0450] Furthermore, for example, when the size of the current block is 16×16 and the length is less than 32, the size of the upper template is 16×2 and the size of the left template is 2×16.

[0451] On the other hand, when constructing a template, the size of the template varies depending on the position indicated by the motion vector in the reference picture. In addition, when constructing a template, the size of the template is determined based on the maximum search area.

[0452] Here, the maximum search area refers to an area whose horizontal size is equal to the sum of the horizontal size of the search area in the reference picture and +M and whose vertical size is equal to the sum of the vertical size of the search area in the reference picture and +N. Wherein, N and M are positive integers and are the same value. The size information N and M of the maximum search area are set equally in the encoder and the decoder. Optionally, the size information is determined by the encoder and is signaled to the decoder via a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a slice header, a CTU, a CU, or a block.

[0453] For example, the size of the template varies depending on whether the motion vectors that have been moved around the initial motion vector indicate the boundary of the upper maximum search area or the left search area.

[0454] For example, when the template size sent to the decoder or the predetermined fixed size defined by the encoder and the decoder is N, and the motion vector indicates the boundary of the upper maximum search area, the size of the upper template located outside the search area is determined as the horizontal size of the current block (W×N-1).

[0455] When the template size sent to the decoder or a predetermined fixed size defined by the encoder and decoder is N, and the motion vector indicates the boundary of the left search area, the size of the left template outside the search area is determined to be (N-1)×the vertical size H of the current block.

[0456] The template size is determined to reduce memory access bandwidth.

[0457] Fig. 27 is a diagram showing an example of template sizes.

[0458] like Fig. 27As shown in , when the template size is 4 (=N) and the motion vector indicates the boundary of the upper maximum search area and the boundary of the left search area (case A), the size of the upper template is determined to be W×3 and the size of the left template is determined to be 3×H. The sizes of the upper template and the left template in the other search area B are determined to be W×4 and 4×H.

[0459] On the other hand, when constructing a template, the interpolation method used to construct the template varies depending on the position indicated by the motion vector in the reference picture.

[0460] For example, the interpolation method used to construct the template varies depending on whether the subblock position motion vector that has moved in the direction from the initial motion vector indicates the boundary of the upper maximum search area or the left maximum search area. The reason for the interpolation method to vary is to reduce memory access bandwidth.

[0461] Figure 28 to Figure 31 is a diagram illustrating a template construction method based on interpolation according to various embodiments of the present invention.

[0462] For example, Fig.28 As shown in , when the size of the template is W×4 and the motion vector indicates the upper maximum search area, the encoder or decoder does not perform interpolation processing on the pixel values ​​in the first row of the template, but uses the pixel values ​​at the integer pixel positions closest to the sub-pixel positions downward. On the other hand, the encoder or decoder may use the pixel values ​​generated by performing bilinear interpolation on the integer pixels as the pixel values ​​located in the second row, the third row, and the fourth row.

[0463] In addition, for example, Fig.29 As shown in , when the template has a horizontal size / vertical size of 4×H and the motion vector indicates the left maximum search area, the encoder or decoder does not perform interpolation on the pixel values ​​in the first row of the template, but uses the pixel value closest to the integer pixel position on the left. On the other hand, the encoder or decoder can use the pixel values ​​generated by performing bilinear interpolation on the integer pixels in the second row, the third row, and the fourth row.

[0464] In addition, for example, Fig.30 As shown in , when the size of the template is W×4 and the motion vector indicates the boundary of the upper maximum search area, the encoder or decoder copies and uses the pixel values ​​in the Nth row generated by performing bilinear interpolation on the pixel values ​​in the first row of the template.

[0465] Furthermore, for example, when the size of the template is 4×H and the motion vector indicates a position in the left maximum search area, the encoder or decoder copies and uses pixel values ​​in the Nth row generated by performing bilinear interpolation on pixel values ​​in the first row of the template.

[0466] On the other hand, template size information required to construct the template is signaled via the bitstream.

[0467] Fig.32 is a diagram illustrating a method of correcting an initial motion vector using a template.

[0468] Reference Fig.32 , the encoder or decoder searches for a motion vector indicating a template that minimizes an error with a neighboring template of the current block in a search area in the reference picture indicated by the initial motion vector, and determines the motion vector as a modified motion vector.

[0469] In this case, a template in the reference picture is generated from a predetermined search area including the pixel position indicated by the initial motion vector.

[0470] According to the search method, the predetermined search area has a cross shape, a square shape, a diamond shape, a rhombus shape, a hexagonal shape, etc. including the pixel position indicated by the initial motion vector. On the other hand, the process of minimizing the error between the template in the reference picture and the neighboring template of the current block means the process of minimizing the difference between the template in the reference picture and the neighboring template of the current block.

[0471] When calculating the error between the template in the reference picture and the template of the current block, the error is calculated based on the distortion value, the cost value for the motion vector, or both the distortion value and the cost value for the motion vector.

[0472] For example, when both the left template and the upper template are available, the cost value is calculated according to Equation 5.

[0473] [Equation 5]

[0474] Cost value = (distortion value between left templates + distortion value between upper templates) + (initial motion vector (x, y) - corrected motion vector (x, y)) * weight

[0475] In another example, when only the upper template is available, the cost value is calculated according to Equation 6.

[0476] [Equation 6]

[0477] Cost value = distortion value between the upper templates + (initial motion vector (x, y) - corrected motion vector (x, y)) * weight

[0478] Here, weights are negative numbers less than 0 and positive numbers greater than 0.

[0479] In addition, at least one of the SAD and MR-SAD between the templates is used to calculate the distortion value. The values ​​of SAD and MR-SAD are calculated according to Equation 7.

[0480] [Equation 7]

[0481] SAD=∑ i,j |Ctp(i,j)-Ltp(i,j)|:

[0482] MR-SAD=∑ i,j |Ctp(i,j)-Ltp(i,j)-deltaDC|:

[0483] Here, Ctp(i,j) is the pixel value in the left template or the upper template of the current block, Ltp(i,j) is the pixel value in the left template or the upper template in the reference picture, and deltaDC is the value obtained by subtracting the average pixel value of the left template in the reference picture from the average pixel value of the left template of the current block, or the value obtained by subtracting the average pixel value of the upper template in the reference picture from the average pixel value of the upper template of the current block.

[0484] For example, whether to use SAD or MR-SAD is determined according to the size of the current block. For example, when the horizontal size or vertical size of the block is greater than 64 pixels, MR-SAD is used; otherwise, SAD is used.

[0485] When comparing the template sample values ​​between the current block and the reference picture, the distortion value is calculated by performing an exclusive OR (XOR) operation on the template sample values. For example, an exclusive OR operation is performed on at least one of the template samples of the current block and the template samples of the reference picture, and then the distortion value is calculated using the sum of the exclusive OR operation results of the corresponding template samples.

[0486] When comparing the template sample values ​​between the current block and the reference picture, the encoder or decoder calculates the distortion value after reducing the bit depth of each sample by a predetermined value K. In this case, K has a value of 0 to the bit depth value of the sample, and it is a positive integer or zero. For example, when the bit depth of the template samples of the current block and the bit depth of the template samples of the reference picture are 10 bits, the encoder or decoder reduces the bit depth of the template samples of the current block and the bit depth of the template samples of the reference picture by 4 bits, and calculates the distortion value using an inter-sample distortion calculation method such as SAD, SATD, SSE, or MSE.

[0487] In addition, when comparing the template sample values ​​between the current block and the reference picture, the inter-sample distortion calculation method and the rate calculation method of calculating the rate included in the motion information are used. Therefore, the position of the reconstructed sample presenting the minimum rate distortion value in the reference picture is used as the corrected motion vector.

[0488] Here, the rate is calculated by performing entropy coding on at least one of the initial motion vector value and the modified motion vector value. The rate may also be calculated by performing entropy coding on the difference between the initial motion vector value and the modified motion vector value. Entropy coding means at least one of the above binarization methods.

[0489] The distortion value is calculated by considering not only the error between the template in the reference picture and the template of the current block, but also the error between the template of the current block and the predicted block generated from the corrected motion vector position in the search area.

[0490] Fig.33 is a diagram illustrating a distortion cost calculation method based on a distortion cost.

[0491] like Fig.33 As shown in , the encoder or decoder can calculate the distortion value by considering not only the distortion value between the template of the current block and the prediction block, but also the boundary pixel distortion value between the template of the current block and the prediction block generated from the reference picture. For example, the distortion value is calculated according to Equation 8.

[0492] [Equation 8]

[0493] Distortion value = W0×(inter-template distortion value)+W1*(distortion value for the boundary between the current block template and the predicted block)

[0494] Here, weights W0 and W1 are fixed values ​​or variable values. The weights applied to each prediction block are equal to or different from each other. In order to apply variable weights, one or more weight information for the decoding target block is sent via a bitstream signal. Weight information is sent for each prediction block or for each reference picture. Multiple prediction blocks can share weight information.

[0495] The encoder or decoder searches for a new motion vector nMV in a predetermined search area, wherein the new motion vector nMV indicates a template that exhibits minimum error with the template of the current block, and the predetermined search area is centered on a pixel position indicated by a modified motion vector rMV found based on the initial motion vector.

[0496] Here, when the error between the template of the reference picture obtained by using the new motion vector (nMV) and the template of the current block is greater than the error between the template of the reference picture obtained from the previous corrected motion vector (rMV) and the template of the current block, the encoder or decoder stops the correction process.

[0497] However, when the error between the template of the reference picture obtained from the new motion vector (nMV) and the template of the current block is smaller than the error between the template of the reference picture obtained from the previous corrected motion vector (rMV) and the template of the current block, the encoder or decoder continues to perform correction by searching for the new motion vector in a search area centered on the pixel position indicated by the new motion vector nMV.

[0498] On the other hand, when the error between the template of the reference picture obtained from the new motion vector (nMV) and the template of the current block is smaller than the error between the template of the reference picture obtained from the previous corrected motion vector (rMV) and the template of the current block, the encoder or decoder iteratively searches for the new motion vector. In this case, the number of times the new motion vector is searched is limited by the motion correction execution frequency information indicating the number of times motion correction is performed.

[0499] For example, when the motion correction execution frequency information is 2, the number of times of searching for a new motion vector is limited to a total of two times. The motion correction execution frequency information is inserted into the bit stream so as to be signaled. On the other hand, the motion correction execution frequency information may be set to a predetermined number that is the same in the encoder and the decoder.

[0500] On the other hand, when the initial motion vector has motion vectors corresponding to N prediction directions (for example, an L0 motion vector and an L1 motion vector), a corrected motion vector for each prediction direction is obtained.

[0501] The predetermined search area is determined by search area information. Here, the search area information required to determine the search area is inserted into the bitstream so as to be signaled from the encoder to the decoder.

[0502] For example, the size of the predetermined search area varies depending on coding parameters such as picture type, temporal layer, and block size. For example, the search area in the picture corresponding to the highest layer has a size of 1 integer pixel, and the search area in the picture corresponding to the layer below the highest layer may have a size of 8 integer pixels.

[0503] Regarding the search area set for searching the corrected motion vector, the pixel range in the horizontal direction and the pixel range in the vertical direction may be different from each other. For example, the pixel range in the vertical direction may be smaller than the pixel range in the horizontal direction. The reason why the pixel range is set to have a difference between the horizontal direction and the vertical direction is because the memory access bandwidth can be reduced.

[0504] Fig.34 : is a diagram showing the range of the search area for searching the corrected motion vector.

[0505] like Fig.34As shown in , the size of the search area based on integer pixels in the horizontal direction is set to 8 pixels, and the size of the search area based on integer pixels in the vertical direction is set to 4 pixels. When the search area is set as described above, the difference between the horizontal component of the initial motion vector and the horizontal component of the corrected motion vector is 8 or less. The difference between the vertical component of the initial motion vector and the horizontal component of the corrected motion vector has a value of 4 or less. When the motion vector has 1 / 16 motion vector accuracy, the difference between the horizontal components is 128 or less, and the difference between the vertical components is 64 or less.

[0506] The encoder or decoder searches for the modified motion vector while changing the unit size of the motion vector offset by which the initial motion vector can move within a predetermined search area.

[0507] The encoder or decoder searches for the corrected motion vector by changing the unit size of the corrected motion vector offset used for the motion vector from an integer pixel size to a sub-pixel size.

[0508] For example, the encoder or decoder sequentially searches for the corrected motion vector starting from the integer pixel size offset unit while sequentially changing the offset size unit to (integer pixel size) / (2×n). Here, n is a positive integer, and it is a value preset in the encoder and the decoder or a value signaled from the encoder to the decoder.

[0509] Fig.35 is a diagram illustrating a method of searching for a motion vector by changing a unit size of a motion vector offset.

[0510] like Fig.35 As shown in (a), when the size of the search area in the horizontal direction / vertical direction is 1 pixel (integer pixel) and a square-shaped search method is used, the encoder or decoder compares the matching costs of 8 motion vector candidates with a 1-pixel offset in the area around the initial motion vector to find the motion vector candidate with the smallest matching cost.

[0511] In addition, the encoder or decoder compares the matching costs of 8 motion vector candidates with 1 / 2 pixel offsets in the area around the motion vector with the minimum matching cost calculated based on each 1 pixel offset to find the 1 / 2 pixel motion vector candidate with the minimum matching cost.

[0512] In this case, when the encoder or decoder searches for motion vector candidates, the motion vector is not used when the size difference between the initial motion vector and the motion vector moved with a 1 / 2 pixel offset for each component is greater than 1. In addition, after searching for the best corrected motion vector based on the 1 / 2 pixel offset, the encoder or decoder searches for motion vector candidates based on each 1 / 4 pixel offset in an area around the best corrected motion vector based on the 1 / 2 pixel offset.

[0513] The encoder or decoder searches for the corrected motion vector while changing the unit size of the motion vector offset from a larger sub-pixel to a smaller sub-pixel.

[0514] For example, the encoder or decoder sequentially searches for the corrected motion vector based on each sub-pixel, starting from the sub-pixel size offset and sequentially moving to the size of (sub-pixel size offset) / (2×m). Here, m is a positive integer, and m and the unit size of the sub-pixel offset to start the search are predetermined values ​​preset in the encoder and the decoder, or values ​​sent from the encoder to the decoder by signaling.

[0515] like Fig.35 As shown in (b), when the size of the integer pixel based search area in the horizontal / vertical direction is one pixel and the square search method is used, the encoder or decoder compares 8 motion vector candidates with a 1 / 4 pixel offset in the area around the initial motion vector to find the modified motion vector with the minimum matching cost.

[0516] Furthermore, the encoder or decoder searches for a revised motion vector candidate having a minimum matching cost by comparing matching costs of 8 motion vectors having a 1 / 4 pixel offset with respect to a previous revised motion vector to find the revised motion vector having the minimum matching cost.

[0517] Next, the encoder or decoder compares the matching costs of eight motion vector candidates with 1 / 8 pixel offsets in an area around the motion vector with the minimum matching cost based on the 1 / 4 pixel offset to find a motion vector candidate for the 1 / 8 pixel offset.

[0518] Information indicating the total number of searches in a search area and / or the number of searches in each offset size unit includes a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, a slice header, a tile, a CTU, and a block, and is entropy encoded / decoded.

[0519] Information indicating the total number of searches in the search area and / or the number of searches in each offset size unit is set to the same value in the encoder and the decoder.

[0520] When setting the size of the search area, the encoder or decoder considers the accuracy of the motion vector. For example, when the motion vector accuracy is 1 / 16 and the size of the search area based on integer pixels in the horizontal direction / vertical direction is 1 pixel, this means that the size of the search area based on sub-pixels is 16.

[0521] The motion search pattern (method) in the predetermined search area varies depending on the size of the motion vector offset. For example, the encoder or decoder uses a square search method for integer pixel offsets, a diamond shape search method for 1 / 2 pixel offsets, and a cross search method for 1 / 4 pixel offsets.

[0522] The encoder or decoder compares the matching costs of all integer pixel positions and all sub-pixel positions in a predetermined search area centered on the initial motion vector, and determines the motion vector at the position that produces the minimum matching cost as the modified motion vector.

[0523] Information on whether to search for a modified motion vector based on an integer pixel offset is signaled at at least one level selected from a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, a slice header, a tile, a CTU, and a block, and entropy encoding / decoding the information.

[0524] Whether to search for the motion vector on a per integer pixel basis in the encoder or the decoder is determined based on the information whether the motion vector is corrected on a per integer pixel basis.

[0525] Information on whether a motion vector is corrected on a per-sub-pixel basis is signaled at one or more levels selected from a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, a slice header, a tile, a CTU, and a block, and the information is entropy encoded / decoded.

[0526] The encoder or the decoder determines whether to search for a motion vector for each sub-pixel according to the corrected motion vector search information for each sub-pixel size offset.

[0527] Signaling information of at least one of a pixel range of a search area for a corrected motion vector based on integer pixel offsets and a sub-pixel range of a search area for a corrected motion vector based on sub-pixel offsets at one or more levels selected from a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, a slice header, a tile, a CTU, and a block, and entropy encoding / decoding the information. The encoder or decoder corrects the motion vector in the same manner using the integer pixel range information and the sub-pixel range information.

[0528] The maximum pixel range of the search area for the corrected motion vector based on integer pixel offset and the maximum sub-pixel range of the search area for the corrected motion vector based on sub-pixel offset are set in the same way in the encoder and the decoder.

[0529] In this case, at least one of the information of the difference from the maximum pixel range and the difference from the maximum sub-pixel range is signaled at one or more levels selected from a video parameter set, a sequence parameter set, a picture parameter set, an adaptive parameter set, a tile group header, a slice header, a tile, a CTU, and a block, and the information is entropy encoded / decoded. The encoder and the decoder use the maximum pixel range information, the information of the difference from the maximum pixel range, or both the maximum pixel range information and the information of the difference from the maximum pixel range to perform similar corrections on the motion vector. In addition, the encoder and the decoder use the maximum sub-pixel range information, the information of the difference from the maximum sub-pixel range, or both the maximum sub-pixel range information and the information of the difference from the maximum sub-pixel range to correct the motion vector.

[0530] The encoder or decoder entropy encodes / decodes the sub-pixel size information based on whether the corrected motion vector is searched based on each sub-pixel offset. In this case, the unit size of the sub-pixel offset refers to at least one of 1 / 2 pixel, 1 / 4 pixel, 1 / 8 pixel, 1 / 16 pixel, and 1 / 32 pixel. The encoder and decoder perform similar correction on the motion vector using the sub-pixel unit information.

[0531] In addition, a plurality of pieces of sub-pixel unit information are entropy encoded / decoded. When a plurality of pieces of sub-pixel size information are entropy encoded / decoded, the encoder or decoder corrects a motion vector for each sub-pixel offset corresponding to the information of the coding unit.

[0532] Figure 36 to Figure 38 is a diagram showing a method of correcting an initial motion vector.

[0533] The encoder or decoder uses a merge mode-based motion vector correction process or a prediction block-based motion vector correction method to perform correction on the initial motion vector.

[0534] Here, the encoder or decoder performs correction on the initial motion vector using the corrected motion vector parameter signaled from the encoder without using the above-mentioned template, or performs correction on the initial motion vector using a predicted block of the current block generated by using the motion vector.

[0535] When motion correction is performed using a prediction block (ie, in the case of motion vector correction based on a prediction block), motion vector correction is performed based on a difference between prediction blocks in each reference picture indicated by an initial motion vector.

[0536] The motion correction using the prediction block according to the present invention uses bilateral template matching.

[0537] In this case, a flag indicating whether prediction block-based motion vector correction can be performed is defined, and the flag is inserted into a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, a slice header, a tile, a CTU, a CU, or a block to be signaled to a decoder.

[0538] The encoder or decoder determines whether to perform motion vector correction on the current block according to the encoding parameter value of the current block.

[0539] For example, when the current block is in merge mode, motion vector correction may be performed.

[0540] Alternatively, when the current block is encoded / decoded by bidirectional prediction, motion vector correction may be performed.

[0541] Further optionally, whether to perform motion vector correction is determined based on whether a first POC difference (POC_curr-POC_ref0) is equal to a second POC difference (POC_ref1-POC_curr), wherein the first POC difference represents a POC difference between an encoding / decoding target picture and a first reference picture corresponding to a first prediction direction (e.g., L0 prediction direction), and the second POC difference represents a POC difference between an encoding / decoding target picture and a second reference picture corresponding to a second prediction direction (e.g., L1 prediction direction).

[0542] Alternatively, whether to perform motion vector correction is determined based on the size of the current block. For example, when the vertical size of the current block is 8 or more, it is determined to perform motion vector correction. For example, when the area of ​​the current block is 64 or more, it may be determined to perform motion vector correction.

[0543] For example, when the weight information of the prediction block of the current block is 1 / 2, it is determined to perform motion vector correction.

[0544] For example, whether to perform motion vector correction is determined based on a comparison result between a predetermined threshold and a difference signal between prediction blocks in each reference picture indicated by an initial motion vector. The predetermined threshold refers to a reference value for determining whether to perform motion vector correction by determining the accuracy of the difference signal. Here, the predetermined threshold is represented by at least one of a minimum value and a maximum value. For example, the predetermined threshold is a fixed value preset in an encoder and a decoder. Optionally, the predetermined threshold is a value determined by coding parameters such as the size, type, and bit depth of the current block, or is a value signaled at an SPS, PPS, slice header, parallel block, parallel block group header, CTU, or CU level.

[0545] When the SAD value between the prediction blocks in each reference picture indicated by the initial motion vector is less than the predetermined threshold, the encoder or decoder does not perform motion vector correction. For example, the predetermined threshold is the size of the current block (W×H). When calculating the SAD between prediction blocks, when an even or odd number of pixels in the vertical direction are excluded, the predetermined threshold is set to W×H>>1 of the current block, where W and H are the width (horizontal size) and height (vertical size) of the current block, respectively. For example, the predetermined threshold may be 4W×H>>1 of the current block. For example, considering the bit depth of the luminance component, the predetermined threshold is defined according to Equation 9.

[0546] [Equation 9]

[0547] shift=Max(2,14-BitDepthY_)

[0548] Threshold = (1<<(BitDepth_Y-N+shift))×width of current block (W)×height of current block (H)

[0549] Here, N is any number in the range of 8 to 13. When calculating the SAD between prediction blocks, when an even number or an odd number of pixels in the vertical direction are excluded, the vertical length of the current block is equal to H>>1.

[0550] When the size of the current block is equal to or greater than a predetermined size, the encoder or the decoder divides the current block into sub-blocks having a smaller size and performs motion vector correction while regarding the sub-blocks as the current block.

[0551] For example, when the width or height of the current block is greater than 16, the current block is divided into sub-blocks of a size of 16×16, and motion vector correction is performed on a per-sub-block basis.

[0552] When motion vector correction is performed on a per-subblock basis, the number of subblocks is determined according to at least one of the encoding parameters of the current block.

[0553] For example, the number of sub-blocks varies depending on the size of the current block. When the size of the current block is 32×32, the number of sub-blocks is 16, and when the size of the current block is 64×64, the number of sub-blocks is 4.

[0554] For example, the number of sub-blocks varies depending on the type of the current block. When the type of the current block is a non-square type of 16×32 in which the vertical size is larger than the horizontal size, the number of sub-blocks is 8. On the other hand, when the type of the current block is a square type in which the size is 32×32, the number of sub-blocks is 16.

[0555] Furthermore, when the motion information correction method is performed on a sub-block basis, the shape of the sub-block is determined to be a square regardless of the shape of the current block.

[0556] When motion information correction is performed based on a sub-block, the shape of the sub-block is determined to be the same as that of the current block.

[0557] For example, when the current block has a non-square shape in which the vertical size is larger than the horizontal size, the shape of the sub-block is determined to be a non-square shape in which the vertical size is larger than the horizontal size.

[0558] In the case where motion vector correction can be performed on a sub-block basis, sub-block-based motion vector correction execution information is determined according to information signaled via a bitstream. Here, the sub-block-based motion vector correction execution information is signaled for one or more units selected from a video, a sequence, a picture, a slice, a tile group, a tile, a coding tree unit, a coding unit, a prediction unit, a transform unit, and a block. The sub-block-based motion vector correction execution information indicates whether sub-block-based motion information correction is performed for the corresponding unit.

[0559] Furthermore, sub-block based motion information correction is performed based on the motion information of the sub-block having the determined size by using at least one of the sub-block based motion information prediction methods.

[0560] Here, the prediction block is located within a predetermined search range centered at the pixel position indicated by the initial motion vector. A prediction block may be generated from the motion vector derived in the predetermined search range, and a motion vector that minimizes the difference between the prediction blocks may be determined as a modified motion vector. For example, the search range is determined to be 4 pixels for each of the horizontal direction and the vertical direction.

[0561] Alternatively, for the pixel position indicated by the initial motion vector, the search range may be set to a range from -2 integer pixels to +2 integer pixels.

[0562] The difference between prediction blocks means a difference between a plurality of prediction blocks generated based on the L0 initial motion vector for the L0 direction or the L1 initial motion vector for the L1 direction, or a difference between prediction blocks generated based on the L0 initial motion vector and the L1 initial motion vector, respectively.

[0563] The encoder or decoder determines a motion vector indicating a position of a reconstructed sample in a reference picture, which exhibits minimum distortion when comparing the reconstructed sample in the reference picture with a bidirectional prediction sample by using a distortion calculation method such as the sum of absolute difference (SAD), the sum of absolute transformed difference (SATD), the sum of squared errors (SSE), the mean square error, and the de-averaged SAD, as a corrected motion vector. In this case, the distortion is calculated for at least one of the luminance component and the chrominance component.

[0564] For example, Fig.36 As shown in , the encoder or decoder finds a case where a minimum error occurs between a prediction block P0 and a prediction block P1, wherein the prediction block P0 is generated by using a motion vector that has moved within a predetermined search range, and the prediction block P1 is generated by using an L1 motion vector derived from an L0 motion vector, wherein the predetermined search range has a predetermined distance from a reference pixel position indicated by an L0 initial motion vector in an L0 reference picture, and the encoder or decoder determines the motion vector that has moved within the predetermined search range as a corrected L0 motion vector.

[0565] Here, the L1 corrected motion vector is a motion vector derived by mirroring or scaling the L0 corrected motion vector.

[0566] Optionally, the L1 corrected motion vector is a motion vector obtained by mirroring or scaling a difference between the L0 initial motion vector and the L0 motion vector that has moved within a predetermined search range in the L0 direction and adding the difference to the L1 initial motion vector.

[0567] The L0 motion vector is a motion vector obtained by adding the difference between the L0 initial motion vector and the L0 motion vector that has moved within a predetermined search range to the L0 initial motion vector. Similarly, the L1 motion vector is a motion vector obtained by adding the difference between the L1 initial motion vector and the L1 motion vector that has moved within a predetermined search range to the L1 initial motion vector. Here, the difference between the initial motion vector and the motion vector that has moved within the predetermined search range represents the above-mentioned modified motion vector.

[0568] On the other hand, when the POC difference between the reference picture for the L0 direction and the encoding / decoding target picture is different from the POC difference between the reference picture for the L1 direction and the encoding / decoding target picture, the difference between the L0 motion vector or the L0 initial motion vector and the L0 motion vector moved within a predetermined search range is not mirrored but scaled, and the value resulting from the scaling is used to derive the L1 motion vector.

[0569] When the POC difference between the encoding / decoding target picture and the reference picture for the L0 direction is different from the POC difference between the encoding / decoding target picture and the reference picture for the L1 direction, the difference between the L0 motion vector or the L0 initial motion vector and the L0 motion vector moved within a predetermined search range is not mirrored but scaled, and the scaled result value is used to derive the L1 motion vector.

[0570] When the POC difference between the encoding / decoding target picture and the reference picture for the L0 direction is different from the POC difference between the encoding / decoding target picture and the reference picture for the L1 direction, the difference between the L1 motion vector or the L1 initial motion vector and the L1 motion vector moving within a predetermined search range is not mirrored but scaled, and the scaled result value is used to derive the L0 motion vector.

[0571] Alternatively, if Fig.37 As shown in , the encoder or decoder finds a case where a minimum error occurs between a prediction block (P1) and a prediction block (P0), wherein the prediction block (P1) is generated by using a motion vector that has moved in a predetermined search range, and the prediction block (P0) is generated by using an L0 motion vector derived from an L1 motion vector, wherein the predetermined search range has a predetermined distance from a reference pixel position indicated by an L1 initial motion vector in an L1 reference picture, and the encoder or decoder determines the motion vector that has moved in the predetermined search range as a corrected L1 motion vector.

[0572] Here, the L0 corrected motion vector is a motion vector obtained by mirroring or scaling the L1 corrected motion vector.

[0573] The L0 motion vector is a motion vector derived by mirroring or scaling the difference between the L1 initial motion vector and the L1 motion vector moved within a predetermined search range in the L0 direction and adding the mirrored or scaled resultant value to the L0 initial motion vector.

[0574] Similarly, the encoder or the decoder finds a case where a minimum error occurs between a prediction block P0 generated by using a motion vector that has moved within a predetermined search range indicated by an L0 initial motion vector in an L0 reference picture and a prediction block P1 generated by using an L1 motion vector derived from the L0 motion vector, and the encoder or the decoder determines the motion vector that has moved within the predetermined search range as a corrected L0 motion vector.

[0575] On the other hand, when the POC difference between the encoding / decoding target picture and the reference picture for the L0 direction is not used for the POC difference between the encoding / decoding target picture and the reference picture for the L1 direction, the encoder or decoder does not mirror the difference between the L1 motion vector or the L1 initial motion vector and the L1 motion vector moving within a predetermined search range, but scales the difference between the L1 motion vector or the L1 initial motion vector and the L1 motion vector moving within the predetermined search range, and uses the scaled result value to derive the L0 motion vector.

[0576] On the other hand, when the Ly direction motion vector is derived from the Lx motion vector, at least one of the reference picture indicated by the Lx motion vector, the picture to which the current block belongs, and the temporal distance (or POC difference) between the reference pictures in the Ly direction is considered. Here, x and y may be different positive integers including zero.

[0577] Regarding mirroring, for example, the encoder or decoder mirrors the L0 motion vector for a reference picture in the L1 reference picture list, wherein the reference picture has the same POC difference as the POC difference between the reference picture indicated by the L0 motion vector and the picture to which the current block belongs, and the encoder or decoder derives the mirrored motion vector as the L1 direction motion vector.

[0578] Regarding scaling, for example, the encoder or decoder scales the L0 motion vector by considering the POC difference of the picture having the minimum POC difference with the picture to which the current block belongs, excluding the reference pictures in the L1 reference picture list that have the same POC difference as the reference picture indicated by the L0 motion vector, and derives the scaled L0 motion vector as the L1 direction motion vector.

[0579] On the other hand, when the motion vector is modified based on the difference between the prediction blocks, the motion vector value to be mirrored or scaled is selected according to the encoding / decoding information. That is, the motion vector value to be mirrored or scaled is selected from the initial motion vector, the motion vector moved in the predetermined search range, and the difference between the initial motion vector and the moved motion vector according to the encoding / decoding information.

[0580] For example, when the current block is a bidirectional predictable block and only an L0 initial motion vector exists, a motion vector obtained by mirroring or scaling the L0 initial motion vector or an L0 motion vector moved within a predetermined search range in the L1 direction is used as the L1 motion vector.

[0581] When the current block has bidirectional prediction information and both the first POC difference value and the second POC difference value (POC_ref0-POC_curr and POC_ref1-POC_curr) have negative values, a motion vector obtained by mirroring or scaling the L0 initial motion vector or the L0 motion vector moved within a predetermined search range in the L1 direction is derived as the L1 motion vector, wherein the first POC difference value is a POC difference value between the encoding / decoding target picture and the first reference picture corresponding to the first direction (e.g., L0 direction), and the second POC difference value is a POC difference value between the encoding / decoding target picture and the second reference picture corresponding to the second direction (e.g., L1 direction). The difference between the L1 initial motion vector and the L1 motion vector moved within the predetermined search range is added to the L0 initial motion vector, and the resulting value is used as the L0 motion vector.

[0582] In addition, for example, when the current block has bidirectional motion information and only one of the first POC difference value and the second POC difference value (POC_ref0-POC_curr and POC_ref1-POC_curr) has a negative value, the difference between the L0 initial motion vector and the L0 motion vector moving within the predetermined search area is mirrored or scaled in the L1 direction, and the resulting value is added to the L1 initial motion vector to obtain a value to be used as the L1 motion vector, wherein the first POC difference value is a POC difference value between the encoding / decoding target picture and the first reference picture corresponding to the first direction (e.g., L0 direction), and the second POC difference value is a POC difference value between the encoding / decoding target picture and the second reference picture corresponding to the second direction (e.g., L1 direction). Optionally, the difference between the L1 initial motion vector and the L1 motion vector moving within the predetermined search area is mirrored or scaled in the L0 direction, and the resulting value is added to the L0 initial motion vector to obtain the L0 motion vector.

[0583] When performing motion correction using a prediction block (hereinafter, referred to as prediction block-based motion correction), the encoder or decoder calculates a weighted sum of a prediction block generated by using an L0 initial motion vector and a prediction block generated by using an L1 initial motion vector to generate a block to be used for motion correction.

[0584] The corrected motion vector based on the motion correction of the prediction block is only used for motion compensation and temporal motion vector prediction.

[0585] When the motion vector is modified using the prediction block of the current block (bilateral template matching), the motion vector can be modified at the decoder side without sending additional context elements.

[0586] When the current block is not related to the unidirectional prediction merge candidate, local illumination compensation mode, affine motion compensation mode, or sub-CU merge mode, motion vector correction (bilateral template matching) based on the prediction block is performed.

[0587] For example, Fig.38 As shown in , the encoder or decoder calculates the weighted sum of the prediction block P0 generated by using the L0 initial motion vector and the prediction block P1 generated by using the L1 initial motion vector, and uses the obtained prediction block Ps as a template. The encoder or decoder generates the prediction block Pr0 by moving the motion vector in a predetermined search range centered on the pixel position indicated by the L0 initial motion vector. The motion vector that produces the minimum error between the prediction block Pr0 and the template Ps is determined as the corrected motion vector for the L0 list.

[0588] The encoder or decoder generates a prediction block Pr1 by moving a motion vector in a predetermined search area centered on the pixel position indicated by the L1 motion vector. The motion vector that produces the minimum error between the prediction block Pr1 and the template Ps is determined as the modified motion vector for the L1 list.

[0589] On the other hand, the prediction block Ps is calculated according to Equation 10.

[0590] [Equation 10]

[0591] Ps=(a1*P0+a2*P1)>>1

[0592] Here, a1 and a2 are weights used in the weight function. The weights are not limited to fixed values, but can be variable values. The weights applied to the respective prediction blocks are equal to or different from each other. In order to use variable weights, information on the weights for the decoding target block is signaled via the bitstream.

[0593] When only the L0 initial motion vector is derived, a prediction block P0 generated by using the L0 initial motion vector is determined as a template. In addition, a motion vector that generates a minimum error between the template and the prediction block Pr0 generated by a motion vector moving in a predetermined search area centered on a pixel position indicated by the L0 initial motion vector is determined as a corrected motion vector for the L0 list direction.

[0594] When calculating the difference between the prediction blocks of the current block, at least one of the distortion value and the cost value for the motion vector is considered.

[0595] For example, when the L0 initial motion vector is used to generate prediction blocks P0 and P1, the cost value is calculated according to Equation 11.

[0596] [Equation 11]

[0597] Cost value = distortion value (prediction block (P0) - prediction block (P1)) + (initial L0 motion vector - modified L0 motion vector) * weight

[0598] For example, when the prediction blocks P0 and P1 are generated by using the L1 initial motion vector, the cost value is calculated according to Equation 12.

[0599] [Equation 12]

[0600] Cost value = distortion value (prediction block (P0) - prediction block (P1)) + (initial L1 motion vector - modified L1 motion vector) * weight

[0601] Here, the weight represents a negative value less than zero or a positive value greater than zero.

[0602] In the calculation of the cost value, a distortion value is calculated using at least one of the SAD, SATD, and MR-SAD of the prediction block.

[0603] The encoder or decoder searches for a new motion vector nMV that produces a minimum error between prediction blocks within a predetermined search range, wherein the predetermined search range is centered at a pixel position indicated by a modified motion vector rMV found based on the initial motion vector.

[0604] Here, when the error between the prediction blocks P0 and P1 obtained by using the new motion vector nMV is greater than the error between the prediction blocks P0 and P1 obtained by using the corrected motion vector rMV, the encoder or decoder stops performing motion vector correction. However, when the error between the prediction blocks P0 and P1 obtained by using the new motion vector nMV is less than the error between the prediction blocks P0 and P1 generated by using the corrected motion vector rMV, the encoder or decoder continues to search for the new motion vector in a predetermined search range centered on the pixel position indicated by the new motion vector nMV.

[0605] When the error between the prediction blocks obtained by using the motion vector is less than the error between the prediction blocks obtained by using the corrected motion vector, the encoder or decoder continues to search for a new motion vector. In this case, the number of times the new motion vector is searched is limited by the motion correction execution frequency information indicating the number of times the motion correction is performed.

[0606] For example, when the motion correction execution frequency information has a value of 2, the number of times of searching for a new vector is limited to 2. The motion correction execution frequency information is inserted into a bitstream so as to be signaled. A predetermined value preset in an encoder and a decoder may be used as the motion correction execution frequency.

[0607] As has been described, there are two methods of correcting a motion vector based on an initial motion vector: one is a method using a template, and the other is a method using a prediction block.

[0608] The encoder or the decoder selects a motion vector correction method according to motion vector correction mode information (MV_REFINE_MODE) indicating the motion vector correction method.

[0609] For example, when the motion vector correction mode information (MV_REFINE_MODE) has a first value of 0, motion vector correction is performed by using a neighboring template of the current block. However, when the motion vector correction mode information (MV_REFINE_MODE) has a second value of 1, motion vector prediction is performed by using a prediction block generated based on a motion vector. Here, the first value and the second value may be set oppositely. That is, the first value and the second value may be set to 1 and 0, respectively.

[0610] The motion vector correction mode information is inserted into the bitstream to be signaled.

[0611] In addition, the motion vector correction method can be adaptively determined according to the encoding parameters.

[0612] For example, the initial motion vector of the current block has a unidirectional motion vector, and the neighboring template is used to correct the initial motion vector. When the initial motion vector of the current block is a bidirectional vector, motion vector correction is performed by using a prediction block signal obtained using the motion vector.

[0613] In another example, only the L0 motion vector or the L1 motion vector is available in the current block, and motion vector correction is performed by using a neighboring template. On the other hand, when both the L0 motion vector and the L1 motion vector are available in the current block, a weighted sum (prediction block) of prediction blocks generated by using the motion vectors is used as a template, and motion vector correction for each prediction direction is performed by using the template.

[0614] In another example, only the L0 motion vector or the L1 motion vector is available in the current block, and motion vector correction is performed using a neighboring template. When both the L0 motion vector and the L1 motion vector are available in the current block, motion vector correction for each prediction direction is performed by using a difference between prediction blocks generated by respectively using motion vectors of the respective prediction directions.

[0615] When deriving a motion vector for a current block, the initial motion vector itself may be used as the motion vector of the current block without performing motion vector correction on the initial motion vector.

[0616] Next, a method of deriving a corrected motion vector for each sub-block will be described in detail. Here, the term "sub-block" has the same meaning as the above-mentioned block.

[0617] Fig.39 and Fig.40 is a diagram showing sub-blocks generated by dividing a current block, and Fig.41 is a diagram illustrating a method of setting an initial motion vector to be used for motion vector correction of each subblock.

[0618] The current block may be divided into one or more sub-blocks.

[0619] For example, the current block may be divided into N sub-blocks in the horizontal direction and M sub-blocks in the vertical direction. That is, the current block may be divided into M×N sub-blocks, where M and N are both integer values ​​equal to or greater than 1, and M and N are the same integer or different integers.

[0620] Alternatively, the current block may be divided into W×H sub-blocks, where there are W pixels in the horizontal direction and H pixels in the vertical direction. Here, W and H are both integers equal to or greater than 2, and W and H are the same integer or different integers.

[0621] The size of the sub-block is determined according to the size of the current block. For example, when the size of the current block is K samples or less, a sub-block of 4×4 size is used. When the size of the current block is greater than N samples, a sub-block of 8×8 size is used. Here, K is a positive integer, for example, 256.

[0622] The size of the sub-block may be a size predefined in the encoder and the decoder. The size of the sub-block is determined according to the sub-block size information. The sub-block size information is inserted into the bitstream so as to be signaled.

[0623] When determining the size of a sub-block, both the sub-block size information and the current block size information are considered.

[0624] For example, when the sub-block size information indicates the depth of the sub-block, the size of the sub-block is determined according to Equation 13 using the width / length of the current block and the depth of the sub-block.

[0625] [Equation 13]

[0626] Sub-block size = (average length of vertical and horizontal lengths of current block >> sub-block depth information)

[0627] For example, Fig.39 As shown in , the average values ​​of the horizontal length and the vertical length of the current block are 64, and the sub-block depth information has a value of 3, and the size of the sub-block is set to 8.

[0628] The sub-block has a square shape or a rectangular shape.

[0629] For example, Fig.40 As shown in , when the current block has a square shape, the sub-block may have a rectangular shape. When the current block has a rectangular shape, the sub-block may have a square shape.

[0630] Furthermore, the encoder or the decoder sets an initial motion vector to be used for sub-block based motion vector correction according to at least one method described below.

[0631] (1) The initial motion vector determined for the current block or the corrected motion vector thereof is set as the initial motion vector of the sub-block. That is, the encoder or decoder sets the derived initial motion vector of the current block as the initial motion vector of each sub-block in the current block. For example, when the initial motion vector of the current block is mv0, and the current block is divided into sub-blocks s1 to s4, the encoder or decoder determines the initial motion vector mv0 of the current block as the initial motion vector of each sub-block in sub-blocks s1 to s4.

[0632] (2) A zero motion vector (0,0) is set as the initial motion vector for each sub-block.

[0633] (3) A motion vector derived from a reconstructed block in a co-located picture with a temporally neighboring block of the sub-block is set as an initial motion vector for each sub-block.

[0634] (4) The motion vector derived by sub-block based merging is set as the initial value of the initial motion vector for each sub-block.

[0635] (5) The motion vector of the sub-block adjacent to the current sub-block is set as the initial motion vector for the current sub-block. Fig.41 As shown in , the motion vector of the left sub-block b, the lower left sub-block a, the upper sub-block d or the upper right sub-block f adjacent to the current sub-block s is used as the initial motion vector of the current sub-block.

[0636] Among the subblock-based initial motion vectors set by any of methods (1) to (5), only the initial motion vector having the same reference picture index information as the motion information determined on a per-block basis can be used as the initial motion vector for the subblock.

[0637] When it is not identical to the reference picture index information of the motion information determined based on each block, a value obtained by scaling based on the temporal distance is used as an initial motion vector for the current subblock.

[0638] When an initial motion vector to be used for sub-block-based motion vector correction is obtained, the reference picture index information of the sub-block is set to a predetermined value, for example, the reference picture index information of all sub-blocks is set to zero.

[0639] Therefore, when reference picture index information derived based on motion information of each block or motion information derived from neighboring blocks does not have a value of 0, a value obtained by scaling based on a temporal distance is used as an initial motion vector of a subblock.

[0640] The encoder or decoder performs motion vector correction on a per-subblock basis by using the derived initial motion vector.

[0641] The encoder or the decoder corrects the initial motion vector of the subblock by using information about spatially neighboring blocks and / or temporally neighboring blocks and one of a template-based motion vector correction method and a prediction block-based motion vector prediction method.

[0642] Motion vector correction utilization information (flag), template size information, search area information, weight information, motion correction execution frequency information, motion vector correction mode information and sub-block size information based on the merge mode that may be used in the above-mentioned motion vector correction may be included in the motion compensation information.

[0643] When the current block uses the AMVP mode instead of the merge mode and there is at least one motion vector estimation candidate, the encoder or the decoder derives a revised motion vector by using the generated motion vector estimation candidate list.

[0644] For example, at least one of the motion vector of a reconstructed neighboring block, the motion vector of a co-located block, and the motion vector of a block adjacent to the co-located block is determined as a motion vector estimation candidate to be included in a motion vector estimation candidate list, the encoder or decoder uses the generated motion vector estimation candidate as an initial motion vector, and a corrected motion vector can be derived from the determined initial motion vector by a motion vector correction method.

[0645] When there are N motion vector candidates, the encoder or decoder uses the motion vector candidate that produces the minimum difference between the template in the reference picture and the neighboring template of the encoding / decoding target block as the corrected motion vector.

[0646] When there are N motion vector estimation candidates, the encoder or decoder uses the motion vector estimation candidate that produces the minimum matching cost for matching the template in the reference picture with the neighboring template of the encoding / decoding target block as the initial motion vector to be used to obtain the revised motion vector.

[0647] When there are N motion vector estimation candidates, the encoder or decoder sets each of the N motion vector estimation candidates as an initial motion vector, derives a corrected motion vector corresponding to each initial motion vector by using a template-based motion vector correction method, and sets the corrected motion vector of the motion vector estimation candidate with the minimum matching cost as the final corrected motion vector.

[0648] When there are N motion vector estimation candidates, the encoder or decoder sets only the nth motion vector estimation candidate as the initial motion vector, and derives the corrected motion vector by performing the template-based motion vector correction method on the nth motion vector estimation candidate (i.e., the initial motion vector). In this case, n is an integer greater than 0 and not greater than N.

[0649] For example, when there are two motion vector estimation candidates, the encoder or decoder sets only the first motion vector estimation candidate as an initial motion vector, and derives a corrected motion vector by performing a template-based motion vector correction method on the initial motion vector.

[0650] When using a revised motion vector candidate, when the revised motion vector candidate has a different motion vector value from the first motion vector candidate in the motion vector candidate list, the encoder or decoder uses the determined revised motion vector candidate as the first candidate in the motion vector candidate list. In this case, all existing motion vector candidates in the list are positionally shifted, or the Nth existing candidate in the list is deleted.

[0651] When there is only one of the motion vector of a reconstructed neighboring block, the motion vector of the same-position block, and the motion vector estimation candidate determined from the motion vector of a block adjacent to the same-position block, the encoder or decoder sets the motion vector estimation candidate as an initial motion vector and performs a template-based motion vector correction method on the initial motion vector to derive a corrected motion vector.

[0652] When using the finally determined corrected motion vector candidate, when it has a corrected motion vector value different from the motion vector value of the first motion vector estimation candidate in the motion vector candidate list, the encoder or decoder uses the corrected motion vector candidate as the second candidate in the motion vector candidate list. When constructing the candidate list and the motion vector estimation candidate list, when encoding / decoding the spatial / temporal candidate block by the motion correction method, the candidate is not inserted into the list.

[0653] When constructing a merge candidate list and a motion vector prediction candidate list, when encoding / decoding a spatial / temporal candidate block by using a prediction block-based motion vector correction method, the encoder or decoder inserts the uncorrected original initial motion vector into the corresponding candidate list instead of the corrected motion vector.

[0654] When constructing a merge candidate list and a motion vector estimation candidate list, when the spatial / temporal candidate block is encoded / decoded by using a prediction block-based motion vector correction method and the horizontal and vertical sizes of the spatial / temporal candidate block are equal to the horizontal and vertical sizes of the current encoding / decoding target block, the encoder or decoder inserts the uncorrected original initial motion vector instead of the corrected motion vector into the corresponding list.

[0655] When constructing a merge candidate list and a motion vector prediction candidate list, when a spatial candidate block is encoded / decoded by using a prediction block-based motion vector correction method and the spatial candidate block is included in the same area as the current encoding / decoding target block, the encoder or decoder inserts the uncorrected original initial motion vector instead of the corrected motion vector into the corresponding list.

[0656] Whether the current encoding / decoding target block and the adjacent block are included in the same area is determined by checking whether the values ​​of the x component and the y component (Cx / grid_size, Cy / grid_size) of the upper left pixel position of the current target block divided by a predetermined size value (grid_size) are respectively equal to the values ​​of the x component and the y component (Nx / grid_size, Ny / grid_size) of the upper left pixel position of the adjacent block divided by the predetermined size value (grid_size). That is, this is determined according to whether the conditions of Cx / grid_size=Nx / grid_size and Cy / grid_size=Ny / grid_size are satisfied. When the values ​​of the former are respectively equal to the values ​​of the latter, the encoder or decoder determines that the encoding / decoding target block and the adjacent block exist in the same area.

[0657] In this case, the predetermined size value is an integer value greater than 0. The predetermined size value is a value preset in the encoder and the decoder, a value entropy encoded / decoded on a per-CTU, CT, PU, ​​or block basis, or a value entropy encoded / decoded at a higher level such as a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, or a slice header.

[0658] When constructing the advanced temporal motion vector prediction information on a per-subblock basis, the position of the block corresponding to the current block in the current co-located picture is derived from the motion vector of the spatial merging candidate of the current block. The co-located picture of the current picture is the same picture used to derive the temporal merging candidate and is entropy encoded / decoded at a higher level (such as a video parameter set, a sequence parameter set, a picture parameter set, an adaptation parameter set, a tile group header, or a slice header).

[0659] For example, Figure 7 As shown in , a block indicating the same picture as the same-position picture is searched in the order of the positions of the spatial merging candidates A1, B1, B0, A0, and B2, and the position of the block corresponding to the current block is derived from the motion vector of the block. Figure 7 In the example shown in , when the reference picture indicated by block A1 is the same as the co-located picture, the block indicated by the motion vector of block A1 within the co-located picture is derived as the corresponding block for constructing the sub-block based temporal motion vector of the current block.

[0660] When deriving the position of the corresponding block in the same position picture, when the motion vector of the spatial merging candidate block of the current block is a modified motion vector, the encoder or decoder derives the position of the corresponding block in the same position picture by using the unmodified initial motion vector. In addition, when deriving the position of the corresponding block in the same position picture, when the current block and the spatial merging candidate block are located in the same CTU and the motion vector of the spatial merging candidate is a modified motion vector, the encoder or decoder derives the position of the corresponding block in the same position picture by using the unmodified initial motion vector.

[0661] When deriving the position of the corresponding block in the same-position picture, when the current block and the spatial merging candidate block are located in different CTUs and the motion vector of the spatial merging candidate is a corrected motion vector, the encoder or the decoder derives the position of the corresponding block in the same-position picture by using the corrected motion vector.

[0662] When deriving the position of a corresponding block in a co-located picture, when the current block and the spatial merging candidate block are located in different CTUs and the spatial merging candidate block is located at the left boundary of the CTU to which the current block belongs and has a corrected motion vector, the encoder or decoder derives the position of the corresponding block in the co-located picture by using an uncorrected initial motion vector.

[0663] When deriving the position of a corresponding block in a co-located picture, when the current block and the spatial merging candidate block are located in different CTUs and the spatial merging candidate block is located at the upper boundary of the CTU to which the current block belongs and has a corrected motion vector, the encoder or decoder derives the position of the corresponding block in the co-located picture by using the corrected motion vector.

[0664] The encoder or decoder inserts information about the current block used during the encoding / decoding process or information about the current block generated after the current block is encoded / decoded into the candidate list. The block information refers to at least one encoding parameter such as an intra prediction mode, a motion vector, etc.

[0665] Unlike a conventional candidate list constructed on a per-block basis, the candidate list in the present invention is maintained during the encoding / decoding process performed for each picture, slice, tile, CTU, CTU row, or CTU column, and can be used in a specific unit such as a picture, slice, tile, CTU, CTU row, or CTU column during the encoding / decoding process, and is used on a per-picture, slice, tile, CTU, CTU row, or CTU column basis. That is, blocks included in a specific unit (e.g., a picture, slice, tile, tile group, CTU, CTU row, or CTU column) share the same candidate list.

[0666] The candidate list includes at least one piece of information about a block encoded / decoded before the current block on a per-picture, slice, tile group, CTU, CTU row, or CTU column basis. The candidate list includes at least one piece of block information about a previously encoded / decoded picture, slice, tile, tile group, CTU, CTU row, or CTU column. When the motion information of the current block is inserted into the candidate list, the corrected motion vector generated by the motion information correction method is not inserted, but the initial motion vector is inserted.

[0667] Inserting information about the current block into the candidate list means inserting both the corrected motion vector generated by the motion information correction method and the initial motion vector into the candidate list.

[0668] Furthermore, overlapped block motion compensation (OMBC), a motion correction method based on bidirectional optical flow (BIO), general bi-prediction, weighted prediction, and the like are not applied to a block encoded / decoded by using the motion correction method.

[0669] Furthermore, local illumination compensation information on a block encoded / decoded by using a motion correction method is derived from the merge index information or a candidate block corresponding to the merge index information.

[0670] Fig.42 is a flowchart illustrating an image decoding method according to an embodiment of the present invention.

[0671] Reference Fig.42 According to an embodiment of the present invention, the image decoding method includes a step of deriving an initial motion vector (S4210), a step of deriving a modified motion vector by using the initial motion vector (S4220), and / or a step of generating a prediction block by using the modified motion vector (S4230).

[0672] The decoder derives an initial motion vector from the merge candidate list of the current block (S4210).

[0673] In step S4210, the decoder derives an initial motion vector from the merge candidates indicated by the merge index information included in the merge candidates in the merge candidate list.

[0674] On the other hand, when the current block is a bidirectional prediction block and the merge candidate indicated by the merge index information has motion information for only one prediction direction, the motion vector of the existing motion information is mirrored or scaled to derive the initial motion vector corresponding to the other prediction direction (motion information that does not exist). Fig.14 A detailed description is given, so redundant description will be avoided.

[0675] The decoder derives a corrected motion vector by using the initial motion vector (S4220).

[0676] Specifically, in the step of deriving the corrected motion vector (S4220), the initial motion vector is corrected by a merge mode-based motion vector correction method, a prediction block-based motion vector correction method, or both a merge mode-based motion vector correction method and a prediction block-based motion vector correction method.

[0677] In the step of deriving a modified motion vector (S4220), a modified motion vector is derived from at least one prediction block indicated by the initial motion vector.

[0678] Here, when the current block is a bidirectional prediction block, the decoder sets a weighted sum of a first prediction block indicated by an initial motion vector in a first prediction direction and a second prediction block indicated by an initial motion vector in a second prediction direction as a template, sets a search area in at least one reference picture indicated by at least one of the initial motion vector in the first prediction direction and the initial motion vector in the second prediction direction, and derives a motion vector indicating a third prediction block in the search area that presents a minimum difference with the template as a modified motion vector.

[0679] Here, when a first search area indicated by an initial motion vector in a first prediction direction and a second search area indicated by an initial motion vector in a second prediction direction are set, the decoder derives a revised motion vector by using motion vectors indicating respective prediction blocks that present a minimum difference with the template in the first search area and the second search area.

[0680] On the other hand, when the first prediction direction initial motion vector or the second prediction direction initial motion vector does not exist, the decoder derives the non-existent initial motion vector by mirroring or scaling the existing initial motion vector.

[0681] Next, the decoder generates a prediction block of the current block by using the corrected motion vector (S4230).

[0682] In the above-mentioned image decoding method, the current block may be a sub-block of the current block to be decoded. In this case, the decoder corrects the motion vector in units of sub-blocks.

[0683] The above embodiments may be performed in the same way in an encoder and a decoder.

[0684] The order applied to the above embodiments may be different between the encoder and the decoder, or the order applied to the above embodiments may be the same in the encoder and the decoder.

[0685] The above embodiments may be performed on each of the luminance signal and the chrominance signal, or may be performed identically on the luminance signal and the chrominance signal.

[0686] The block form to which the above embodiment of the present invention is applied may have a square form or a non-square form.

[0687] The above embodiments of the present invention may be applied according to the size of at least one of a coding block, a prediction block, a transform block, a block, a current block, a coding unit, a prediction unit, a transform unit, a unit, and a current unit. Here, the size may be defined as a minimum size or a maximum size or both a minimum size and a maximum size, so as to apply the above embodiments, or may be defined as a fixed size to which the above embodiments are applied. In addition, in the above embodiments, the first embodiment may be applied to a first size, and the second embodiment may be applied to a second size. In other words, the above embodiments may be applied in combination according to the size. In addition, the above embodiments may be applied when the size is equal to or greater than the minimum size and equal to or less than the maximum size. In other words, the above embodiments may be applied when the block size is included in a specific range.

[0688] For example, when the size of the current block is 8×8 or larger, the above embodiment may be applied. For example, when the size of the current block is 4×4 or larger, the above embodiment may be applied. For example, when the size of the current block is 16×16 or larger, the above embodiment may be applied. For example, when the size of the current block is equal to or larger than 16×16 and equal to or smaller than 64×64, the above embodiment may be applied.

[0689] The above embodiments of the present invention may be applied in terms of time layers. In order to identify the time layers to which the above embodiments may be applied, an additional identifier may be signaled, and the above embodiments may be applied to the specified time layers identified by the corresponding identifiers. Here, the identifier may be defined as the lowest layer or the highest layer or both the lowest layer and the highest layer to which the above embodiments may be applied, or may be defined as a specific layer to which the embodiments may be applied. In addition, a fixed time layer to which the embodiments may be applied may be defined.

[0690] For example, when the temporal layer of the current image is the lowest layer, the above embodiment may be applied. For example, when the temporal layer identifier of the current image is 1, the above embodiment may be applied. For example, when the temporal layer of the current image is the highest layer, the above embodiment may be applied.

[0691] A stripe type to which the above embodiments of the present invention are applied may be defined, and the above embodiments may be applied depending on the corresponding stripe type.

[0692] The above embodiment of the present invention may also be applied when the motion vector has at least one of 16-pel unit, 8-pel unit, 4-pel unit, integer-pel unit, 1 / 8-pel unit, 1 / 16-pel unit, 1 / 32-pel unit, and 1 / 64-pel unit. The motion vector may be selectively used for each pixel unit.

[0693] The present disclosure also has the following configurations:

[0694] 1. An image decoding method, comprising:

[0695] Derivation of the initial motion vector of the current block;

[0696] deriving a revised motion vector by using the initial motion vector; and

[0697] A prediction block of the current block is generated by using the corrected motion vector.

[0698] 2. The method according to Scheme 1, wherein the initial motion vector includes an initial L0 motion vector and an initial L1 motion vector, the corrected motion vector includes a corrected L0 motion vector and a corrected L1 motion vector, and the corrected motion vector is derived by using a merge mode-based motion vector correction method or a prediction block-based motion vector correction method.

[0699] 3. The method according to Scheme 2, wherein, when the corrected motion vector is derived by a motion vector correction method based on a merge mode, the image decoding method further comprises: entropy decoding information indicating an initial motion vector to be used in the motion vector correction method based on a merge mode.

[0700] 4. The method according to Scheme 3 also includes: entropy decoding the size information and direction information of the corrected motion vector.

[0701] 5. The method according to Scheme 3 further includes: performing entropy decoding on the size unit information of the modified motion vector, wherein the size unit of the modified motion vector refers to an integer pixel or a sub-pixel.

[0702] 6. The method according to claim 3, wherein the modified L0 motion vector is derived by adding the difference between the L0 initial motion vector and the L0 motion vector that has moved within the predetermined search area to the L0 initial motion vector.

[0703] 7. The method according to claim 3, wherein the modified L1 motion vector is derived by adding the difference between the L1 initial motion vector and the L1 motion vector moving within a predetermined search area to the L1 initial motion vector.

[0704] 8. A method according to scheme 3, wherein, when the POC difference between the L0 reference picture of the current block and the decoding target picture including the current block and the POC difference between the L1 reference picture and the decoding target picture including the current block are both negative values, the corrected L0 motion vector is derived by adding the difference between the L1 initial motion vector and the L1 motion vector that has moved within a predetermined search area to the L0 initial motion vector.

[0705] 9. A method according to scheme 3, wherein, when only one of the POC difference between the L0 reference picture of the current block and the decoding target picture including the current block or the POC difference between the L1 reference picture and the decoding target picture including the current block has a negative value, the corrected L0 motion vector is derived by mirroring the difference between the L1 initial motion vector and the L1 motion vector that has moved within a predetermined search area and adding the mirrored difference to the L0 initial motion vector.

[0706] 10. A method according to Scheme 3, wherein, when a POC difference between an L0 reference picture of a current block and a decoding target picture including the current block and a POC difference between an L1 reference picture and a decoding target picture including the current block are different from each other, the corrected L0 motion vector is derived by scaling a difference between an L1 initial motion vector and an L1 motion vector that has moved within a predetermined search area and adding the scaled difference to the initial L0 motion vector.

[0707] 11. A method according to Scheme 3, wherein, when a POC difference between an L0 reference picture of a current block and a decoding target picture including the current block and a POC difference between an L1 reference picture and a decoding target picture including the current block are different from each other, the corrected L1 motion vector is derived by scaling a difference between an L0 initial motion vector and an L0 motion vector that has moved within a predetermined search area and adding the scaled difference to the initial L1 motion vector.

[0708] 12. The method according to Scheme 2, wherein, when the corrected motion vector is derived by a prediction block-based motion vector correction method, the image decoding method further comprises: entropy decoding information indicating whether the prediction block-based motion vector correction method is available.

[0709] 13. The method according to scheme 12, wherein the motion vector correction method based on the prediction block is performed only when the current block has a bidirectional prediction merge mode.

[0710] 14. A method according to scheme 12, wherein the motion vector correction method based on the prediction block is performed only when the POC difference between the L0 reference picture of the current block and the decoding target picture including the current block is equal to the POC difference between the L1 reference picture of the current block and the decoding target picture including the current block.

[0711] 15. The method according to scheme 12, wherein the motion vector correction method based on the prediction block is performed only when the vertical size of the current block is 8 or more and the area of ​​the current block is 64 or more.

[0712] 16. A method according to scheme 12, wherein the prediction block is located within a predetermined search area that falls within a predetermined distance from the pixel position indicated by the initial motion vector, and the predetermined search area is set based on each integer pixel and is in the range from -2 pixel positions to 2 pixel positions relative to the pixel position indicated by the initial motion vector in both the horizontal direction and the vertical direction.

[0713] 17. The method according to scheme 12, wherein, when the vertical size or the horizontal size of the current block is greater than 16, the current block is divided into 16×16 sub-blocks, and a motion vector correction method based on a prediction block is performed by using a prediction block based on each sub-block.

[0714] 18. A method according to scheme 12, wherein the modified L0 motion vector is derived from a distortion value between a prediction block generated by using a motion vector that has moved within a predetermined search area centered on a pixel position present in the L0 reference picture and indicated by the L0 initial motion vector and a prediction block generated by using a motion vector that has moved within a predetermined search area centered on a pixel position present in the L1 reference picture and indicated by the L1 initial motion vector.

[0715] 19. The method according to claim 18, wherein the distortion value is calculated by one or more operations selected from the sum of absolute differences (SAD), the sum of absolute transformed differences (SATD), the sum of squared errors (SSE) and the mean square error (MSE).

[0716] 20. An image encoding method, comprising:

[0717] Derivation of the initial motion vector of the current block;

[0718] deriving a revised motion vector by using the initial motion vector; and

[0719] The motion compensation information of the current block is entropy encoded using the modified motion vector.

[0720] 21. A non-temporary storage medium comprising a bit stream generated by an image encoding method, wherein the image encoding method comprises: deriving an initial motion vector of a current block; deriving a revised motion vector by using the initial motion vector; and entropy encoding motion compensation information of the current block using the revised motion vector.

[0721] In the above embodiments, the method is described based on a flow chart with a series of steps or units, but the present invention is not limited to the order of these steps, but some steps can be performed simultaneously with other steps or in different orders. In addition, it should be understood by those skilled in the art that the steps in the flow chart are not mutually exclusive, and other steps can be added to the flow chart or some of the steps can be deleted from the flow chart without affecting the scope of the present invention.

[0722] The embodiments include various aspects of the examples. All possible combinations of the various aspects may not be described, but those skilled in the art will be able to recognize different combinations. Therefore, the present invention may include all substitutions, modifications and changes within the scope of the claims.

[0723] Embodiments of the present invention can be implemented in the form of program instructions, wherein the program instructions can be executed by various computer components and recorded in a computer-readable recording medium. The computer-readable recording medium can include program instructions, data files, data structures, etc. alone, or can include a combination of program instructions, data files, data structures, etc. The program instructions recorded in the computer-readable recording medium can be specially designed and constructed for the present invention, or it is well known to those of ordinary skill in the field of computer software technology. Examples of computer-readable recording media include magnetic recording media (such as hard disks, floppy disks, and magnetic tapes), optical data storage media (such as CD-ROMs or DVD-ROMs), magneto-optical media (such as floppy disks), and hardware devices (such as read-only memories (ROMs), random access memories (RAMs), flash memories, etc.) that are specially constructed to store and implement program instructions. Examples of program instructions include not only machine language codes formatted by compilers, but also high-level language codes that can be implemented by computers using interpreters. The hardware device can be configured to be operated by one or more software modules or vice versa to implement processing according to the present invention.

[0724] Although the present invention has been described in terms of specific items (such as, detailed elements) and limited embodiments and drawings, they are only provided to help a more comprehensive understanding of the present invention, and the present invention is not limited to the above embodiments. It will be appreciated by those skilled in the art that various modifications and changes may be made to the above description.

[0725] Therefore, the spirit of the present invention should not be limited to the above-described embodiments, and the full scope of the appended claims and their equivalents will fall within the scope and spirit of the present invention.

[0726] Industrial Applicability

[0727] The present invention can be used when encoding / decoding an image.

Claims

1. An image decoding method, comprising: Determine the prediction mode of the current block; When the prediction mode of the current block is a merge mode, deriving an initial motion vector of the current block based on a merge candidate list of the current block; deriving a modified motion vector of the current block; deriving a final motion vector of the current block based on the initial motion vector and the revised motion vector; Obtain a prediction block of the current block based on the final motion vector; as well as reconstructing the current block by adding the prediction block to the residual block, Wherein, deriving the modified motion vector of the current block includes: Determining the size of the modified motion vector based on the modified motion vector size index information decoded from the bitstream; and Determining the direction of the modified motion vector based on the modified motion vector direction index information, wherein the modified motion vector magnitude index specifies an index of one of the magnitude candidates predefined in the decoding device, and The size of the modified motion vector is determined by shifting a size candidate specified by the modified motion vector size index.

2. The method according to claim 1, wherein: The method further comprises: Decode motion vector correction information from the bitstream, The motion vector correction utilization information indicates whether the initial motion vector obtained from the merge candidate list is to be corrected, and When the prediction mode of the current block is determined to be a merge mode, the motion vector correction utilization information is decoded from a bitstream.

3. The method according to claim 1, wherein: Shifting the size candidates is performed by using a constant value.

4. The method according to claim 1, wherein: The composition of the size candidates that can be selected using the modified motion vector size index information changes according to the modified motion vector accuracy information decoded from the bitstream.

5. The method according to claim 4, wherein: The modified motion vector precision information indicates whether the modified motion vector should have an integer pixel unit.

6. The method according to claim 1, wherein: The initial motion vector includes an L0 initial motion vector and an L1 initial motion vector, and The corrected motion vector includes an L0 corrected motion vector and an L1 corrected motion vector.

7. The method according to claim 6, wherein: In response to a first picture order count (POC) difference value between the L0 reference picture of the current block and a current picture including the current block being different from a second POC difference value between the L1 reference picture of the current block and the current picture, one of the L0 corrected motion vector and the L1 corrected motion vector is derived by scaling the other.

8. The method according to claim 7, wherein: When the first POC difference is greater than the second POC difference, the L1 corrected motion vector is derived by scaling the L0 corrected motion vector.

9. The method according to claim 7, wherein: When the first POC difference is less than the second POC difference, the L0 corrected motion vector is derived by scaling the L1 corrected motion vector.

10. The method according to claim 2, wherein: In response to an initial motion vector obtained from the merge candidate list being to be corrected, a merge candidate in the merge candidate list is selected based on an initial motion vector flag decoded from a bitstream.

11. An image encoding method, comprising: When the prediction mode of the current block is a merge mode, deriving an initial motion vector of the current block based on a merge candidate list of the current block; deriving a modified motion vector of the current block; deriving a final motion vector of the current block based on the initial motion vector and the revised motion vector; Obtain a prediction block of the current block based on the final motion vector; as well as Obtaining a residual block of the current block by subtracting the predicted block from the original block, Wherein, the method further comprises: encoding the modified motion vector magnitude index information of the modified motion vector; and encoding the corrected motion vector direction information of the corrected motion vector, wherein the modified motion vector magnitude index information specifies an index of one of the magnitude candidates predefined in the encoding device, and The size of the modified motion vector is the same as a value obtained by shifting a size candidate specified by the modified motion vector size index.

12. A non-transitory storage medium comprising a bitstream generated by an image encoding method, the method comprising: When the prediction mode of the current block is a merge mode, deriving an initial motion vector of the current block based on a merge candidate list of the current block; deriving a modified motion vector of the current block; deriving a final motion vector of the current block based on the initial motion vector and the revised motion vector; as well as Obtaining a prediction block of the current block based on the final motion vector, Wherein, the method further comprises: encoding the modified motion vector magnitude index information of the modified motion vector; and encoding the corrected motion vector direction information of the corrected motion vector, wherein the modified motion vector magnitude index information specifies an index of one of the magnitude candidates predefined in the encoding device, and The size of the modified motion vector is the same as a value obtained by shifting a size candidate specified by the modified motion vector size index.