Video encoding/decoding method and apparatus and recording medium storing bitstream

文档序号:1510789 发布日期:2020-02-07 浏览:13次 中文

阅读说明:本技术 视频编码/解码方法和装置以及存储比特流的记录介质 (Video encoding/decoding method and apparatus and recording medium storing bitstream ) 是由 林成昶 姜晶媛 高玄硕 全东山 李镇浩 李河贤 金晖容 于 2018-06-05 设计创作,主要内容包括:公开了一种视频编码方法。本发明的视频编码方法包括以下步骤:从空间邻近块的运动信息、时间邻近块的运动信息、预定义运动信息以及在参考视频中最多出现的运动信息中的至少一个运动信息中推导运动修正候选;对推导出的运动修正候选执行运动信息修正;并且通过使用已被执行运动信息修正的运动修正候选来生成当前块的预测块。(A video encoding method is disclosed. The video encoding method of the present invention includes the steps of: deriving a motion correction candidate from at least one of motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most in a reference video; performing motion information correction on the derived motion correction candidate; and generates a prediction block of the current block by using the motion correction candidate on which the motion information correction has been performed.)

1. An image decoding method, comprising:

deriving motion correction candidates from motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most frequently in a reference picture;

performing motion information correction on the derived motion correction candidate; and is

A prediction block for the current block is generated by using the motion correction candidate on which the motion information correction has been performed.

2. The method of claim 1, wherein the deriving of the motion information candidates is performed by sequentially deriving the motion correction candidates from motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, defined motion information, and motion information that occurs most frequently in a reference picture in a predetermined order.

3. The method of claim 2, wherein the predetermined order represents an order of motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, and defined motion information.

4. The method of claim 1, wherein the performing motion information correction comprises: a process of double-sided template matching is applied to the motion vectors existing in the derived motion correction candidates.

5. The method of claim 4, wherein the bilateral template matching comprises:

generating a bilateral template by using a motion vector existing in the derived motion correction candidate as an initial motion vector; and is

The initial motion vector is modified by comparing samples within the bilateral template with reconstructed samples within the reference picture indicated by the initial motion vector.

6. The method of claim 5, wherein the initial motion vector is a bi-directional predicted motion vector that is a non-zero vector in the derived motion correction candidates.

7. The method of claim 6, wherein the initial motion vector is set to a zero vector when there is no bi-predictive motion vector as a non-zero vector in the derived motion correction candidate.

8. The method of claim 1, wherein the temporally neighboring block is included in a reference picture selected by a reference picture index of a spatially neighboring block.

9. The method of claim 4, wherein the double-sided template matching is performed based on integer pixels and sub-pixels.

10. The method of claim 5, wherein the step of modifying the initial motion vector comprises:

searching for a motion vector indicating a region in a reference picture, wherein the region has a minimum distortion value with respect to a corresponding region in a bilateral template; and is

Setting the found motion vector as a correction value of the initial motion vector.

11. The method of claim 10, wherein the step of searching for the initial motion vector comprises:

the limited search range is searched within the reference picture.

12. The method of claim 11, wherein the limited search range is set to a predetermined range bounded on an integer pixel basis.

13. The method of claim 12, wherein the step of searching for the initial motion vector comprises:

searching for a motion vector in the predetermined range based on the sub-pixels.

14. The method of claim 10, wherein the modification of the initial motion vector is performed recursively.

15. The method of claim 1, wherein when the current block does not correspond to any of the uni-directional prediction merge candidate, the local illumination compensation mode, and the affine motion compensation mode, motion information correction is performed on the derived motion correction candidate.

16. The method of claim 1, further comprising:

decoding the motion correction mode utilization information; and is

Determining a motion correction mode based on the decoded motion correction mode utilization information, wherein the deriving of the motion correction candidate is performed in the motion correction mode.

17. The method of claim 17, wherein the decoding the motion correction mode utilization information comprises:

determining whether to decode the motion correction mode utilization information based on a skip flag or a merge flag.

18. The method of claim 1, wherein, when there are a plurality of spatially neighboring blocks, deriving the motion information candidate comprises: motion information is derived from spatially neighboring blocks having bi-directionally predicted motion vectors, and then motion information is derived from spatially neighboring blocks having uni-directionally predicted motion vectors.

19. An image encoding method comprising:

deriving motion correction candidates from motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most frequently in a reference picture;

performing motion information correction on the derived motion correction candidate; and is

A prediction block for the current block is generated by using the motion correction candidate on which the motion information correction has been performed.

20. A non-transitory storage medium containing a bitstream generated by an image encoding method, the method comprising:

deriving motion correction candidates from motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most frequently in a reference picture;

performing motion information correction on the derived motion correction candidate; and is

A prediction block for the current block is generated by using the motion correction candidate on which the motion information correction has been performed.

Technical Field

The present invention relates to a method and apparatus for encoding/decoding an image. In particular, the present invention relates to a method and apparatus for performing motion compensation by correcting motion information, and a recording medium storing a bitstream generated by the image encoding method/apparatus of the present invention.

Background

Recently, demands for high-resolution and high-quality images such as High Definition (HD) images and Ultra High Definition (UHD) images have increased in various application fields. However, image data of higher resolution and quality has an increased data amount compared to conventional image data. Therefore, when image data is transmitted by using a medium such as a conventional wired and wireless broadband network, or when image data is stored by using a conventional storage medium, the cost of transmission and storage increases. To solve these problems occurring with the improvement of the resolution and quality of image data, efficient image encoding/decoding techniques are required for higher resolution and higher quality images.

Image compression techniques include various techniques including: an inter prediction technique of predicting pixel values included in a current picture from a previous picture or a subsequent picture of the current picture; an intra prediction technique of predicting a pixel value included in a current picture by using pixel information in the current picture; transform and quantization techniques for compressing the energy of the residual signal; an entropy coding technique that assigns short codes to values with high occurrence frequencies and long codes to values with low occurrence frequencies; and so on. Image data can be efficiently compressed by using such image compression techniques and can be transmitted or stored.

Since the conventional image encoding/decoding method and apparatus perform motion compensation based on motion information of a spatial/temporal neighboring block adjacent to a current block (i.e., an encoding/decoding target block), the conventional image encoding/decoding method and apparatus have its limitations in improving encoding efficiency.

Disclosure of Invention

Technical problem

The present invention provides a method and apparatus capable of performing motion compensation by correcting motion information.

Technical scheme

A method of decoding an image according to the present invention may include: deriving motion correction candidates from motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most frequently in a reference picture; performing motion information correction on the derived motion correction candidate; and generates a prediction block of the current block by using the motion correction candidate on which the motion information correction has been performed.

In the method of decoding an image according to the present invention, wherein the deriving of the motion information candidates is performed by sequentially deriving the motion correction candidates in a predetermined order from motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, defined motion information, and motion information that occurs most frequently in a reference picture.

In the method of decoding an image according to the present invention, wherein the predetermined order represents an order of motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, and defined motion information.

In the method of decoding an image according to the present invention, wherein the step of performing motion information correction includes: a process of double-sided template matching is applied to the motion vectors existing in the derived motion correction candidates.

In the method of decoding an image according to the present invention, wherein the double-sided template matching includes: generating a bilateral template by using a motion vector existing in the derived motion correction candidate as an initial motion vector; and correcting the initial motion vector by comparing samples in the bilateral template with reconstructed samples in the reference picture indicated by the initial motion vector.

In the method of decoding an image according to the present invention, wherein the initial motion vector is a bidirectional predictive motion vector as a non-zero vector among the derived motion correction candidates.

In the method of decoding an image according to the present invention, wherein the initial motion vector is set to a zero vector when a bidirectional predictive motion vector as a non-zero vector does not exist in the derived motion correction candidate.

In a method of decoding an image according to the present invention, wherein temporally neighboring blocks are included in reference pictures selected by reference picture indices of spatially neighboring blocks.

In the method of decoding an image according to the present invention, wherein the double-sided template matching is performed based on integer pixels and sub-pixels.

In the method of decoding an image according to the present invention, wherein the step of modifying the initial motion vector comprises: searching for a motion vector indicating a region in a reference picture, wherein the region has a minimum distortion value with respect to a corresponding region in a bilateral template; and sets the found motion vector as a correction value of the initial motion vector.

In the method of decoding an image according to the present invention, wherein the searching for the initial motion vector comprises: the limited search range is searched within the reference picture.

In the method of decoding an image according to the present invention, wherein the limited search range is set to a predetermined range demarcated on an integer pixel basis.

In the method of decoding an image according to the present invention, wherein the searching for the initial motion vector comprises:

the motion vector is searched for in a predetermined range based on the sub-pixels.

In the method of decoding an image according to the present invention, wherein the correction of the initial motion vector is performed recursively.

In the method of decoding an image according to the present invention, wherein when the current block does not correspond to any of the uni-directional prediction merge candidate, the local illumination compensation mode, and the affine motion compensation mode, motion information correction is performed on the derived motion correction candidate.

In the method of decoding an image according to the present invention, further comprising: decoding the motion correction mode utilization information; and determining a motion correction mode in which the derivation of the motion correction candidate is performed based on the decoded motion correction mode utilization information.

In the method of decoding an image according to the present invention, wherein the decoding the motion correction mode using information includes: whether to decode the motion correction mode utilization information is determined based on the skip flag or the merge flag.

In the method of decoding an image according to the present invention, wherein the deriving the motion information candidate when there are a plurality of spatially neighboring blocks comprises: motion information is derived from spatially neighboring blocks having bi-directionally predicted motion vectors, and then motion information is derived from spatially neighboring blocks having uni-directionally predicted motion vectors.

A method of encoding an image according to the present invention may include: deriving motion correction candidates from motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most frequently in a reference picture; performing motion information correction on the derived motion correction candidate; and generates a prediction block of the current block by using the motion correction candidate on which the motion information correction has been performed.

A non-transitory storage medium containing a bitstream generated by an image encoding method, the method comprising: deriving motion correction candidates from motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most frequently in a reference picture; performing motion information correction on the derived motion correction candidate; and generates a prediction block of the current block by using the motion correction candidate on which the motion information correction has been performed.

Advantageous effects

According to the present invention, an image encoding/decoding method and apparatus having improved compression efficiency can be provided.

According to the present invention, the encoding and decoding efficiency of an image can be improved.

According to the present invention, the computational complexity of an image encoder and an image decoder can be reduced.

Drawings

Fig. 1 is a block diagram showing a configuration of an encoding apparatus according to an embodiment of the present invention;

fig. 2 is a block diagram showing a configuration of a decoding apparatus according to an embodiment of the present invention;

fig. 3 is a diagram schematically showing a partition structure of an image when the image is encoded and decoded;

fig. 4 is a diagram illustrating an inter prediction process;

FIG. 5 is a flowchart illustrating an image encoding method according to an embodiment of the present invention;

FIG. 6 is a flowchart illustrating an image decoding method according to an embodiment of the present invention;

FIG. 7 is a flowchart illustrating an image encoding method according to another embodiment of the present invention;

fig. 8 is a flowchart illustrating an image decoding method according to another embodiment of the present invention;

FIG. 9 is a diagram illustrating an exemplary method of deriving a spatial motion vector candidate for a current block;

FIG. 10 is a diagram illustrating an exemplary method of deriving a temporal motion vector candidate for a current block;

fig. 11 is a diagram showing an example of adding a spatial merge candidate to a merge candidate list;

fig. 12 is a diagram showing an example of adding a temporal merge candidate to a merge candidate list;

fig. 13 is a diagram illustrating a method of performing double-sided template matching;

fig. 14 and 15 are diagrams illustrating a search range of a motion vector for performing search correction using double-sided template matching; and

fig. 16 is a flowchart illustrating an image decoding method according to still another embodiment of the present invention.

Detailed Description

Various modifications may be made to the present invention and there are various embodiments of the present invention, examples of which will now be provided with reference to the accompanying drawings and examples of which will be described in detail. However, the present invention is not limited thereto, although the exemplary embodiments may be construed to include all modifications, equivalents, or alternatives within the technical spirit and scope of the present invention. Like reference numerals refer to the same or similar functionality in all respects. In the drawings, the shapes and sizes of elements may be exaggerated for clarity. In the following detailed description of the present invention, reference is made to the accompanying drawings that show, by way of illustration, specific embodiments in which the invention may be practiced. These embodiments are described in sufficient detail to enable those skilled in the art to practice the disclosure. It is to be understood that the various embodiments of the disclosure, although different, are not necessarily mutually exclusive. For example, a particular feature, structure, or characteristic described herein in connection with one embodiment may be implemented within other embodiments without departing from the spirit and scope of the disclosure. In addition, it is to be understood that the location or arrangement of individual elements within each disclosed embodiment may be modified without departing from the spirit and scope of the disclosure. The following detailed description is, therefore, not to be taken in a limiting sense, and the scope of the present disclosure is defined only by the appended claims, appropriately interpreted, along with the full range of equivalents to which the claims are entitled.

The terms "first", "second", and the like, as used in the specification may be used to describe various components, but these components are not to be construed as being limited by these terms. These terms are only used to distinguish one component from another. For example, a "first" component may be termed a "second" component, and a "second" component may be similarly termed a "first" component, without departing from the scope of the present invention. The term "and/or" includes a combination of items or any of items.

It will be understood that, in the present specification, when an element is referred to as being "connected to" or "coupled to" another element only, rather than "directly connected to" or "directly coupled to" another element, the element may be "directly connected to" or "directly coupled to" the other element or connected to or coupled to the other element with the other element therebetween. In contrast, when an element is referred to as being "directly bonded" or "directly connected" to another element, there are no intervening elements present.

Further, the constituent elements shown in the embodiments of the present invention are independently shown so as to exhibit characteristic functions different from each other. Therefore, it does not mean that each constituent element is composed of separate hardware or software constituent units. In other words, for convenience, each component includes each of the enumerated components. Accordingly, at least two components in each component may be combined to form one component, or one component may be divided into a plurality of components for performing each function. An embodiment in which each component is combined and an embodiment in which one component is divided are also included in the scope of the present invention without departing from the essence of the present invention.

The terminology used in the description is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. Expressions used in the singular include plural expressions unless it has a distinctly different meaning in the context. In this specification, it will be understood that terms such as "including … …," "having … …," and the like, are intended to specify the presence of the features, numbers, steps, actions, elements, components, or combinations thereof disclosed in the specification, and are not intended to preclude the possibility that one or more other features, numbers, steps, actions, elements, components, or combinations thereof may be present or may be added. In other words, when a specific element is referred to as being "included", elements other than the corresponding element are not excluded, and instead, additional elements may be included in the embodiments of the present invention or in the scope of the present invention.

Further, some constituent elements may not be indispensable constituent elements that perform the essential functions of the present invention, but optional constituent elements that merely enhance the performance thereof. The present invention can be implemented by excluding constituent elements used in enhancing performance by including only indispensable constituent elements for implementing the essence of the present invention. A structure including only the indispensable constituent elements and excluding optional constituent elements used in only enhancing performance is also included in the scope of the present invention.

Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings. In describing exemplary embodiments of the present invention, well-known functions or constructions are not described in detail since they would unnecessarily obscure the understanding of the present invention. The same constituent elements in the drawings are denoted by the same reference numerals, and a repetitive description of the same elements will be omitted.

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

Hereinafter, the terms "moving picture" and "video" may be used in the same meaning and may be replaced with each other.

Hereinafter, the target image may be an encoding target image as an encoding target and/or a decoding target image as a decoding target. Further, the target image may be an input image input to the encoding apparatus, and an input image input to the decoding apparatus. Here, the target image may have the same meaning as the current image.

Hereinafter, the terms "image", "picture", "frame", and "screen" may be used in the same meaning and in place of each other.

Hereinafter, the target block may be an encoding target block as an encoding target and/or a decoding target block as a decoding target. Further, the target block may be a current block that is a current encoding and/or decoding target. For example, the terms "target block" and "current block" may be used with the same meaning and in place of each other.

Hereinafter, the terms "block" and "unit" may be used in the same meaning and in place of each other. Or "block" may represent a particular unit.

Hereinafter, the terms "region" and "fragment" may be substituted for each other.

Hereinafter, the specific signal may be a signal representing a specific block. For example, the original signal may be a signal representing the target block. The prediction signal may be a signal representing a prediction block. The residual signal may be a signal representing a residual block.

In embodiments, each of the particular information, data, flags, indices, elements, attributes, and the like may have a value. The values of information, data, flags, indices, elements, and attributes equal to "0" may represent a logical false or first predefined value. In other words, the value "0", false, logical false, and the first predetermined value may be replaced with each other. The values of information, data, flags, indices, elements, and attributes equal to "1" may represent a logical true or a second predefined value. In other words, the values "1", true, logically true, and the second predefined value may be substituted for each other.

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 an integer equal to or greater than 1. That is, a column, a row, an index, etc. may start counting from 0, or may start counting from 1.

Description of the terms

An encoder: indicating the device performing the encoding. That is, an encoding apparatus is represented.

A decoder: indicating the device performing the decoding. That is, a decoding apparatus is represented.

Block (2): is an array of M × N samples. Here, M and N may represent positive integers, and a block may represent a two-dimensional form of a sample point array. A block may refer to a unit. The 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. Further, the current block may be at least one of an encoding block, a prediction block, a residual block, and a transform block.

Sampling points are as follows: are the basic units that make up the block. According to the bit depth (Bd), the sampling points can be represented from 0 to 2Bd-a value of 1. In the present invention, a sampling point can be used as a meaning of a pixel. That is, samples, pels, pixels may have the same meaning as each other.

A unit: may refer to encoding and decoding units. When encoding and decoding an image, a unit may be a region generated by partitioning a single image. Also, when a single image is partitioned into sub-division units during encoding or decoding, a unit may represent a sub-division unit. That is, the image may be partitioned into a plurality of cells. When encoding and decoding an image, predetermined processing for each unit may be performed. A single cell may be partitioned into sub-cells that are smaller in size than the cell. Depending on 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. Further, to distinguish a unit from a block, the unit may include a luma component block, a chroma component block associated with the luma component block, and syntax elements for each of the chroma component blocks. The cells may have various sizes and shapes, in particular, the shape of the cells may be a two-dimensional geometric figure, such as a square, rectangle, trapezoid, triangle, pentagon, and the like. In addition, the unit information may include a unit type indicating a coding unit, a prediction unit, a transform unit, etc., and at least one of a unit size, a unit depth, an order of encoding and decoding of the unit, etc.

A 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. Further, the coding tree unit may represent syntax elements including blocks 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, and a ternary tree partitioning method to configure a unit of a lower hierarchy such as a coding unit, a prediction unit, a transform unit, and the like. 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 that is an input image. Here, the quad tree may represent a quad tree.

And (3) encoding a tree block: may be used as a term for specifying any one of a Y coding tree block, a Cb coding tree block, and a Cr coding tree block.

Adjacent blocks: may represent blocks adjacent to the current block. The blocks adjacent to the current block may represent blocks that are in contact with the boundary of the current block or blocks located within a predetermined distance from the current block. The neighboring blocks may represent blocks adjacent to a vertex of the current block. Here, the block adjacent to the vertex of the current block may mean a block vertically adjacent to a neighboring block horizontally adjacent to the current block or a block horizontally adjacent to a neighboring block vertically adjacent to the current block.

Reconstructed neighboring blocks: may represent neighboring blocks that are adjacent to the current block and have been encoded or decoded in space/time. Here, the reconstructed neighboring blocks may represent reconstructed neighboring cells. The reconstructed spatially neighboring blocks may be blocks that are within the current picture and have been reconstructed by encoding or decoding or both. The reconstructed temporally 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.

Depth of cell: may represent the degree of partitioning of the cell. In the tree structure, the highest node (root node) may correspond to the first unit that is not partitioned. Further, the highest node may have the smallest depth value. In this case, the depth of the highest node may be level 0. A node with a depth of level 1 may represent a unit generated by partitioning the first unit once. A node with a depth of level 2 may represent a unit generated by partitioning the first unit twice. A node with a depth of level n may represent a unit generated by partitioning the first unit n times. A leaf node may be the lowest node and is a node that cannot be partitioned further. The depth of a leaf node may be a maximum level. For example, the predefined value for the maximum level may be 3. The depth of the root node may be the lowest, and the depth of the leaf node may be the deepest. Further, when a cell is represented as a tree structure, the level at which the cell exists may represent the cell depth.

Bit stream: a bitstream including encoded image information may be represented.

Parameter set: corresponding to header information among configurations 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 slice header and parallel block (tile) header information.

And (3) analysis: may represent determining the value of the syntax element by performing entropy decoding, or may represent entropy decoding itself.

Symbol: at least one of a syntax element, a coding parameter, and a transform coefficient value that may represent the encoding/decoding target unit. Further, the symbol may represent an entropy encoding target or an entropy decoding result.

Prediction mode: may be information indicating a mode of encoding/decoding using intra prediction or a mode of encoding/decoding using inter prediction.

A prediction unit: may represent basic units 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 lower level prediction units. The plurality of partitions may be basic units in performing prediction or compensation. The partition generated by dividing the prediction unit may also be the prediction unit.

Prediction unit partitioning: may represent a shape obtained by partitioning a prediction unit.

Reference picture list: may refer to a list including one or more reference pictures used for inter prediction or motion compensation. There are several types of available reference picture lists including LC (list combination), L0 (list 0), L1 (list 1), L2 (list 2), L3 (list 3).

Inter prediction indicator: may refer to a direction of inter prediction (uni-directional prediction, bi-directional prediction, etc.) of the current block. Alternatively, the inter prediction indicator may refer to the number of reference pictures used to generate a prediction block of the current block. Alternatively, the inter prediction indicator may refer to the number of prediction blocks used when performing inter prediction or motion compensation on the current block.

Prediction list utilization flag: indicating whether to use at least one reference picture in a particular reference picture list to generate a prediction block. The inter prediction indicator may be derived using the prediction list utilization flag, and conversely, the prediction list utilization flag may be derived using the inter prediction indicator. For example, when the prediction list utilization flag has a first value of zero (0), it means that the prediction block is not generated using the reference picture in the reference picture list. On the other hand, when the prediction list utilization flag has a second value of one (1), it means that the prediction block is generated using the reference picture list.

Reference picture index: may refer to an index indicating a specific reference picture in the reference picture list.

Reference picture: may represent a reference picture that is referenced by a particular block for purposes of inter-prediction or motion compensation for the particular block. Alternatively, the reference picture may be a picture including a reference block that is referred to by the current block for inter prediction or motion compensation. Hereinafter, the terms "reference picture" and "reference image" have the same meaning and are replaceable with each other.

Motion vector: may be a two-dimensional vector for inter prediction or motion compensation. The motion vector may represent an offset between the encoding/decoding target block and the reference block. For example, (mvX, mvY) may represent a motion vector. Here, mvX may represent a horizontal component, and mvY may represent a vertical component.

The search range is as follows: may be a two-dimensional area searched for retrieving a motion vector during inter prediction. For example, the size of the search range may be M × N. Here, M and N are both integers.

Motion vector candidates: may refer to a prediction candidate block or a motion vector of a prediction candidate block at the time of prediction of a motion vector. Further, the motion vector candidate may be included in a motion vector candidate list.

Motion vector candidate list: a list of one or more motion vector candidates may be represented.

Motion vector candidate index: may represent an indicator indicating a motion vector candidate in the motion vector candidate list. Alternatively, the motion vector candidate index may be an index of a motion vector predictor.

Motion information: information including at least one of a motion vector, a reference picture index, an inter prediction indicator, a prediction list utilization flag, reference picture list information, a reference picture, a motion vector candidate index, a merge candidate, and a merge index may be represented.

Merging the candidate lists: a list consisting of one or more merging candidates may be represented.

Merging candidates: may represent spatial merge candidates, temporal merge candidates, combined bi-predictive merge candidates, or zero merge candidates. The merge candidates may include motion information such as an inter prediction indicator, a reference picture index for each list, a motion vector, a prediction list utilization flag, and an inter prediction indicator.

Merging indexes: may represent an indicator indicating a merge candidate in the merge candidate list. Alternatively, the merge index may indicate a block from which a merge candidate has been derived among reconstructed blocks spatially/temporally adjacent to the current block. Alternatively, the merge index may indicate at least one piece of motion information of the merge candidate.

A transformation unit: may represent a basic unit when encoding/decoding (such as transform, inverse transform, quantization, inverse quantization, transform coefficient encoding/decoding) is performed on the residual signal. A single transform unit may be partitioned into multiple lower-level transform units having smaller sizes. Here, the transform/inverse transform may include at least one of a first transform/first inverse transform and a second transform/second inverse transform.

Zooming: may represent a process of multiplying the quantized level by a factor. The transform coefficients may be generated by scaling the quantized levels. Scaling may also be referred to as inverse quantization.

Quantization parameters: 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 generating a transform coefficient by scaling a level of quantization during inverse quantization. The quantization parameter may be a value mapped on a quantization step.

Incremental quantization parameter: may represent a difference between the predicted quantization parameter and the quantization parameter of the encoding/decoding target unit.

Scanning: a method of ordering coefficients within a cell, block or matrix may be represented. For example, changing a two-dimensional matrix of coefficients into a one-dimensional matrix may be referred to as scanning, and changing a one-dimensional matrix of coefficients into a two-dimensional matrix may be referred to as scanning or inverse scanning.

Transform coefficients: may represent coefficient values generated after performing a transform in an encoder. The transform coefficient may represent a coefficient value generated after at least one of entropy decoding and inverse quantization is performed in a decoder. The quantized level obtained by quantizing the transform coefficient or the residual signal or the quantized transform coefficient level may also fall within the meaning of the transform coefficient.

Level of quantization: may represent values generated by quantizing a transform coefficient or a residual signal in an encoder. Alternatively, the quantized level may represent a value that is an inverse quantization target on which inverse quantization is to be performed in a decoder. Similarly, the quantized transform coefficient levels as a result of the transform and quantization may also fall within the meaning of quantized levels.

Non-zero transform coefficients: may represent transform coefficients having values other than zero, or transform coefficient levels or quantized levels having values other than zero.

Quantization matrix: a matrix used in a quantization process or an inverse quantization process performed to improve subjective image quality or objective image quality may be represented. The quantization matrix may also be referred to as a scaling list.

Quantization matrix coefficients: each element within the quantization matrix may be represented. The quantized matrix coefficients may also be referred to as matrix coefficients.

Default matrix: may represent a predefined quantization matrix predefined in the encoder or decoder.

Non-default matrix: may represent quantization matrices that are not predefined in the encoder or decoder but signaled by the user.

And (3) statistical value: the statistical value for at least one of the variables, coding parameters, constant values, etc. having a particular value that can be calculated may be one or more of an average, a weighted sum, a minimum, a maximum, a most frequently occurring value, a median, an interpolated value of the respective particular value.

Fig. 1 is a block diagram showing a configuration of an encoding apparatus according to an embodiment to which the present invention is applied.

The encoding device 100 may be an encoder, a video encoding device, or an image encoding device. The video may comprise at least one image. The encoding apparatus 100 may sequentially encode at least one image.

Referring to fig. 1, the encoding apparatus 100 may include a motion prediction unit 111, a motion compensation unit 112, an intra 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.

The encoding apparatus 100 may perform encoding on an input image by using an intra mode or an inter mode, or both the intra mode and the inter mode. Further, the encoding apparatus 100 may generate a bitstream including encoding information by encoding an input image and output the generated bitstream. The generated bitstream 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 the prediction mode, the switch 115 may switch to intra. Alternatively, when the inter mode is used as the prediction mode, the switch 115 may switch to the inter mode. Here, the intra mode may mean an intra prediction mode, and the inter mode may mean an inter prediction mode. The encoding apparatus 100 may generate a prediction block for an input block of an input image. Also, the encoding apparatus 100 may encode the residual block using the input block and the residual of the prediction block after generating the prediction block. The input image may be referred to as a current image that is a current encoding target. The input block may be referred to as a current block that is a current encoding target, or as an encoding target block.

When the prediction mode is the intra mode, the intra prediction unit 120 may use samples of blocks that have been encoded/decoded and are adjacent to the current block as reference samples. The intra prediction unit 120 may perform spatial prediction on the current block by using the reference samples or generate prediction samples of the input block by performing spatial prediction. Here, the intra prediction may mean prediction inside a frame.

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

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

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 region of a reference picture. In order to perform inter-picture prediction or motion compensation on a coding unit, it may be determined which mode among 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 on a prediction unit included in the corresponding coding unit. Then, inter-picture prediction or motion compensation may be performed differently depending on the determined mode.

The subtractor 125 may generate a residual block by using the residuals of the input block and the prediction block. The residual block may be referred to as a residual signal. The residual signal may represent a difference between the initial signal and the prediction signal. Further, the residual signal may be a signal generated by transforming or quantizing or transforming and quantizing the difference between the initial signal and the prediction signal. The residual block may be a residual signal of a block unit.

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

The level of quantization may be generated by applying quantization to the transform coefficients or to the residual signal. Hereinafter, the level of quantization may also be referred to as a transform coefficient in embodiments.

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

The entropy encoding unit 150 may generate a bitstream by performing entropy encoding on the values calculated by the quantization unit 140 or on encoding parameter values 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 the sample point information of the image and information for decoding the image. For example, the information for decoding the image may include syntax elements.

When entropy encoding is applied, symbols are represented such that a smaller number of bits are allocated to symbols having a high generation probability and a larger number of bits are allocated to symbols having a low generation probability, and thus, the size of a bit stream for symbols to be encoded can be reduced. The entropy encoding unit 150 may use an encoding method for entropy encoding, such as exponential golomb, Context Adaptive Variable Length Coding (CAVLC), Context Adaptive Binary Arithmetic Coding (CABAC), or the like. For example, the entropy encoding unit 150 may perform entropy encoding by using a variable length coding/code (VLC) table. Further, the entropy encoding unit 150 may derive a binarization method of the target symbol and a probability model of the target symbol/bin, and perform arithmetic encoding by using the derived binarization method and context model.

To encode the transform coefficient levels (quantized levels), the entropy encoding unit 150 may change the two-dimensional block-form coefficients into a one-dimensional vector form by using a transform coefficient scanning method.

The encoding parameters may include information (flags, indices, etc.) such as syntax elements that are encoded in the encoder and signaled to the decoder, as well as information derived when performing encoding or decoding. The encoding parameter may represent information required when encoding or decoding an image. For example, at least one value or a combination of the following may be included in the encoding parameter: unit/block size, unit/block depth, unit/block partition information, unit/block shape, unit/block partition structure, whether or not to perform partition in the form of a quadtree, whether or not to perform partition in the form of a binary tree, the partition direction (horizontal direction or vertical direction) in the form of a binary tree, the partition form (symmetric partition or asymmetric partition) in the form of a binary tree, whether or not the current coding unit is partitioned by partition in the form of a ternary tree, the direction (horizontal direction or vertical direction) of partition in the form of a ternary tree, the type (symmetric type or asymmetric type) of partition in the form of a ternary tree, whether or not the current coding unit is partitioned by partition in the form of a multi-type tree, the direction (horizontal direction or vertical direction) of partition in the form of a multi-type tree, the type (symmetric type or asymmetric type) of partition in the form of a multi-type tree, and the tree structure (binary, Prediction mode (intra prediction or inter prediction), luma intra prediction mode/direction, chroma intra prediction mode/direction, intra partition information, inter partition information, coding block partition flag, prediction block partition flag, transform block partition flag, reference sample filtering method, reference sample filter tap, reference sample filter coefficient, prediction block filtering method, prediction block filter tap, prediction block filter coefficient, prediction block boundary filtering method, prediction block boundary filter tap, prediction block boundary filter coefficient, intra prediction mode, inter prediction mode, motion information, motion vector difference, reference picture index, inter prediction angle, inter prediction indicator, prediction list utilization flag, reference picture list, reference picture, motion vector predictor index, motion vector predictor candidate, chroma intra prediction mode/direction, motion vector candidate list, whether merge mode is used, merge index, merge candidate list, whether skip mode is used, interpolation filter type, interpolation filter tap, interpolation filter coefficient, motion vector size, representation accuracy of motion vector, transform type, transform size, information whether primary (first) transform is used, information whether secondary transform is used, primary transform index, secondary transform index, information whether residual signal is present, coding block pattern, Coding Block Flag (CBF), quantization parameter residual, quantization matrix, whether intra loop filter is applied, intra loop filter coefficient, intra loop filter tap, intra loop filter shape/form, whether deblocking filter is applied, deblocking filter coefficient, deblocking filter tap, deblocking filter shape/form, whether deblocking filter is applied, deblocking filter tap, and the like, Deblocking filter strength, deblocking filter shape/form, whether adaptive sample offset is applied, adaptive sample offset value, adaptive sample offset class, adaptive sample offset type, whether adaptive loop filter is applied, adaptive loop filter coefficients, adaptive loop filter taps, adaptive loop filter shape/form, binarization/inverse binarization method, context model determination method, context model update method, whether normal mode is performed, whether bypass mode is performed, context binary, bypass binary, significant coefficient flag, last significant coefficient flag, coding flag for unit of coefficient group, position of last significant coefficient, flag as to whether value of coefficient is greater than 1, flag as to whether value of coefficient is greater than 2, flag as to whether value of coefficient is greater than 3, coding flag as to unit of coefficient group, position of last significant coefficient, flag as to whether value of coefficient is greater than 1, flag as to whether value of coefficient is greater than 2, flag as to whether value of coefficient, Information on residual coefficient values, sign information, reconstructed luma samples, reconstructed chroma samples, residual luma samples, residual chroma samples, luma transform coefficients, chroma transform coefficients, quantized luma levels, quantized chroma levels, transform coefficient level scanning methods, size of motion vector search area at decoder side, shape of motion vector search area at decoder side, number of motion vector searches at decoder side, information on CTU size, information on minimum block size, information on maximum block depth, information on minimum block depth, image display/output order, slice identification information, slice type, slice partition information, parallel block identification information, parallel block type, parallel block partition information, picture type, bit depth of input samples, image data, and image data, Bit-depth of reconstructed samples, bit-depth of residual samples, bit-depth of transform coefficients, bit-depth of quantized levels, and information on a luminance signal or information on a chrominance signal.

Here, signaling the flag or 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.

When the encoding apparatus 100 performs encoding by inter prediction, the encoded current picture may be used as a reference picture for another picture to be subsequently processed. Accordingly, 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.

The quantized level may be inversely quantized in the inverse quantization unit 160 or may be inversely transformed in the inverse transformation unit 170. The inverse quantized or inverse transformed coefficients, or both, may be added to the prediction block by adder 175. A reconstructed block may be generated by adding the inverse quantized or inverse transformed coefficients or both the inverse quantized and inverse transformed coefficients to the prediction block. Here, the inverse quantized or inverse transformed coefficient or the coefficient subjected to both inverse quantization and inverse transformation may represent a coefficient on which at least one of inverse quantization and inverse transformation is performed, and may represent a reconstructed residual block.

The reconstructed block may pass through the filter unit 180. Filter unit 180 may apply at least one of a deblocking filter, Sample Adaptive Offset (SAO), and Adaptive Loop Filter (ALF) to the reconstructed samples, reconstructed blocks, or reconstructed images. The filter unit 180 may be referred to as an in-loop filter.

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

To compensate for coding errors, an appropriate offset value may be added to the sample value by using a sample adaptive offset. The sample adaptive offset may correct the offset of the deblocked image from the original image in units of samples. A method of applying an offset in consideration of edge information on each sampling point may be used, or the following method may be used: the sampling points of the image are divided into a predetermined number of areas, an area to which an offset is applied is determined, and the offset is applied to the determined area.

The adaptive loop filter may perform filtering based on a comparison of the filtered reconstructed image and the original image. The samples included in the image may be partitioned into predetermined groups, a filter to be applied to each group may be determined, and the differential filtering may be performed on each group. The information whether or not to apply the ALF may be signaled through a Coding Unit (CU), and the form and coefficient of the ALF to be applied to each block may vary.

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 a reference image. That is, the reference image is a reconstructed image composed of the reconstruction blocks processed by the filter unit 180. The stored reference pictures may be used later in inter prediction or motion compensation.

Fig. 2 is a block diagram showing a configuration of a decoding apparatus according to an embodiment to which the present invention is applied.

The decoding apparatus 200 may be a decoder, a video decoding apparatus, or an image decoding apparatus.

Referring to fig. 2, the decoding apparatus 200 may include an entropy decoding unit 210, an inverse quantization unit 220, an inverse transform unit 230, an intra prediction unit 240, a motion compensation unit 250, an adder 225, a filter unit 260, and a reference picture buffer 270.

The decoding apparatus 200 may receive the bitstream output from the encoding apparatus 100. The decoding apparatus 200 may receive a bitstream stored in a computer-readable recording medium or may receive a bitstream streamed through a wired/wireless transmission medium. The decoding apparatus 200 may decode the bitstream by using an intra mode or an inter mode. Further, the decoding apparatus 200 may generate a reconstructed image or a decoded image generated by decoding, and output the reconstructed image or the decoded image.

When the prediction mode used at the time of decoding is an intra mode, the switch may be switched to intra. Alternatively, when the prediction mode used at the time of decoding is an inter mode, the switch may be switched to the inter mode.

The decoding apparatus 200 may obtain a reconstructed residual block by decoding an input bitstream and generate a prediction block. When the reconstructed residual block and the prediction block are obtained, the decoding apparatus 200 may 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.

The entropy decoding unit 210 may generate symbols by entropy decoding the bitstream according to the probability distribution. The generated symbols may comprise symbols in the form of quantized levels. Here, the entropy decoding method may be an inverse process of the above-described entropy encoding method.

To decode the transform coefficient levels (quantized levels), the entropy decoding unit 210 may change the one-directional vector form coefficients into a two-dimensional block form by using a transform coefficient scanning method.

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

When using the intra mode, the intra prediction unit 240 may generate a prediction block by performing spatial prediction on the current block, wherein the spatial prediction uses a sampling value of a block that is adjacent to the decoding target block and has already been decoded.

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

The adder 225 may generate a reconstructed block by adding the reconstructed residual block to the prediction block. Filter unit 260 may 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 may output a reconstructed image. The reconstructed block or reconstructed image may be stored in the reference picture buffer 270 and used when performing inter prediction. The reconstructed block processed by the filter unit 260 may be a part of a reference image. That is, the reference image is a reconstructed image composed of the reconstruction blocks processed by the filter unit 260. The stored reference pictures may be used later in inter prediction or motion compensation.

Fig. 3 is a diagram schematically showing a partition structure of an image when the image is encoded and decoded. FIG. 3 schematically illustrates an example of partitioning a single unit into multiple lower level units.

In order to efficiently partition an image, a Coding Unit (CU) may be used when encoding and decoding. The coding unit may be used as a basic unit when encoding/decoding an image. Further, the encoding unit may be used as a unit for distinguishing an intra prediction mode from an inter prediction mode when encoding/decoding an image. The coding unit may be a basic unit of prediction, transform, quantization, inverse transform, inverse quantization, or encoding/decoding process of transform coefficients.

Referring to fig. 3, a picture 300 is sequentially partitioned by a maximum coding unit (LCU), and the LCU unit is determined as a partition structure. Here, the LCU may be used in the same meaning as a Coding Tree Unit (CTU). A unit partition may refer to partitioning a block associated with the unit. In the block partition information, information of a unit depth may be included. The depth information may represent the number of times or degree the unit is partitioned or both. A single unit may be partitioned into a plurality of lower level units hierarchically associated with depth information based on a tree structure. In other words, a unit and a unit of a lower level 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 representing the size of the CU, and may be stored in each CU. The cell depth represents the number and/or degree of times associated with partitioning a cell. Thus, partition information of a lower-ranked unit may include information about the size of the lower-ranked unit.

The partition structure may represent a distribution of Coding Units (CUs) within LCU 310. Such a distribution may be determined according to whether a single CU is partitioned into multiple (positive integers equal to or greater than 2, including 2, 4, 8, 16, etc.) CUs. The horizontal size and the vertical size of the CU generated by the partitioning may be half of the horizontal size and the vertical size of the CU before the partitioning, respectively, or may have sizes smaller than the horizontal size and the vertical size before the partitioning according to the number of times of the partitioning, respectively. A CU may be recursively partitioned into multiple CUs. By recursively partitioning, at least one of the height and the width of the CU after the partitioning may be reduced compared to at least one of the height and the width of the CU before the partitioning. The partitioning of CUs may be performed recursively until a predefined depth or a predefined size. For example, the depth of an LCU may be 0 and the depth of a minimum coding unit (SCU) may be a predefined maximum depth. Here, as described above, the LCU 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. Partitions start from LCU 310, and CU depth is increased by 1 when the horizontal size or vertical size, or both, of a CU is reduced by partitioning. For example, for each depth, the size of a non-partitioned CU may be 2N × 2N. Further, in the case of a partitioned CU, a CU of size 2N × 2N may be partitioned into four CUs of size N × N. When the depth is increased by 1, the size of N may be reduced by half.

Also, information on whether a CU is partitioned or not may be represented 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 1, the CU may not be partitioned, and when the value of the partition information is 2, the CU may be partitioned.

Referring to fig. 3, an LCU having a depth of 0 may be a 64 × 64 block. 0 may be a minimum depth. The SCU with depth 3 may be an 8 x 8 block. 3 may be the maximum depth. CUs of 32 × 32 blocks and 16 × 16 blocks may be represented as depth 1 and depth 2, respectively.

For example, when a single coding unit is partitioned into four coding units, the horizontal and vertical dimensions of the partitioned four coding units may be half the size of the horizontal and vertical dimensions of the CU before being partitioned. In one embodiment, when a coding unit having a size of 32 × 32 is partitioned into four coding units, each of the partitioned four coding units may have a size of 16 × 16. When a single coding unit is partitioned into four coding units, it may be referred to that the coding units may be partitioned into a quad-tree form.

For example, when one coding unit is partitioned into two sub-coding units, the horizontal size or vertical size (width or height) of each of the two sub-coding units may be half of the horizontal size or vertical size of the original coding unit. For example, when a coding unit having a size of 32 × 32 is vertically partitioned into two sub coding units, each of the two sub coding units may have a size of 16 × 32. For example, when a coding unit having a size of 8 × 32 is horizontally partitioned into two sub coding units, each of the two sub coding units may have a size of 8 × 16. When one coding unit is partitioned into two sub-coding units, it may be said that the coding unit is binary partitioned, or partitioned according to a binary tree partition structure.

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 1:2:1 in the horizontal size or the vertical size. For example, when a coding unit having a size of 16 × 32 is horizontally partitioned 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 vertically divided 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 a left sub-coding unit to a right sub-coding unit. When one coding unit is partitioned into three sub-coding units, it may be said that the coding unit is partitioned by three or partitioned according to a ternary tree partition structure.

In fig. 3, a Coding Tree Unit (CTU)320 is an example of a CTU to which a quad tree partition structure, a binary tree partition structure, and a ternary tree partition structure are all applied.

As described above, in order to partition the CTU, at least one of a quad tree 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 the CTUs according to a predetermined priority order. For example, a quadtree partitioning structure may be preferentially applied to CTUs. Coding units that can no longer be partitioned using the quadtree partition structure may correspond to leaf nodes of the quadtree. The coding units corresponding to leaf nodes of the quadtree may be used as root nodes of a binary and/or ternary tree partition structure. That is, the coding units corresponding to leaf nodes of the quadtree may be further partitioned according to a binary tree partition structure or a ternary tree partition structure, or may not be further partitioned. Accordingly, by preventing an encoding block generated by binary tree partitioning or ternary tree partitioning of encoding units corresponding to leaf nodes of a quadtree from being further subjected to quadtree partitioning, block partitioning and/or signaling of partition information can be efficiently performed.

The fact that the coding units corresponding to the nodes of the quadtree are partitioned may be signaled using the four-partition information. The partition information having a first value (e.g., "1") may indicate that the current coding unit is partitioned according to a quadtree partition structure. The partition information having the second value (e.g., "0") may indicate that the current coding unit is not partitioned according to the quadtree partition structure. The quad-partition information may be a flag having a predetermined length (e.g., one bit).

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 be further performed with any partition among the binary tree partition and the ternary tree partition. Further, the coding units generated by the binary tree partition or the ternary tree partition may be further subjected to the binary tree partition or the ternary tree partition, or may not be further partitioned.

A tree structure in which there is no priority in the binary tree partition and the ternary tree partition is called a multi-type tree structure. The coding units corresponding to leaf nodes of the quadtree may be used as root nodes of the multi-type tree. Whether to partition the coding unit corresponding to the node of the multi-type tree may be signaled using at least one of multi-type tree partition indication information, partition direction information, and partition tree information. To partition coding units corresponding to nodes of the multi-type tree, multi-type tree partition indication information, partition directions, and partition tree information may be sequentially signaled.

The multi-type tree partition indication information having a first value (e.g., "1") may indicate that the current coding unit is to be subjected to multi-type tree partitioning. The multi-type tree partition indication information having the second value (e.g., "0") may indicate that the current coding unit is not to be subjected to the multi-type tree partitioning.

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

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

The partition indication information, the partition tree information, and the partition direction information may each be a flag having a predetermined length (e.g., one bit).

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/entropy-decoded. In order to entropy-encode/entropy-decode those types of information, information on neighboring coding units adjacent to the current coding unit may be used. For example, there is a high likelihood that the partition type (partitioned or not, 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 similar to the partition type of the current coding unit. Accordingly, context information for entropy-encoding/decoding information on the current coding unit may be derived from information on neighboring coding units. The information on the neighboring coding units may include at least any one of four-partition information, multi-type tree partition indication information, partition direction information, and partition tree information.

As another example, in binary tree partitioning and ternary tree partitioning, binary tree partitioning may be performed preferentially. That is, the current coding unit may be preferentially performed for binary tree partitioning, and then coding units corresponding to leaf nodes of the binary tree may be set as root nodes for ternary tree partitioning. In this case, neither quad tree partitioning nor binary tree partitioning may be performed for coding units corresponding to nodes of the ternary tree.

Coding units that cannot be partitioned according to a quadtree partition structure, a binary tree partition structure, and/or a ternary tree partition structure become basic units for coding, prediction, and/or transformation. That is, the coding unit cannot be further partitioned for prediction and/or transform. Therefore, partition structure information and partition information for partitioning a coding unit into prediction units and/or transform units may not exist in a bitstream.

However, when the size of the coding unit (i.e., a basic unit for partitioning) is greater 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 less than the size of the maximum transform block. For example, when the size of a coding unit is 64 × 64 and when the size of a maximum transform block is 32 × 32, the coding unit may be partitioned into four 32 × 32 blocks for transform. For example, when the size of a coding unit is 32 × 64 and the size of a maximum transform block is 32 × 32, the coding unit may be partitioned into two 32 × 32 blocks for transform. In this case, the partition of the coding unit for the transform is not separately signaled, and may be determined by a comparison between a horizontal size or a vertical size of the coding unit and a horizontal size or a 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 divided into two. For example, when the vertical size (length) of the coding unit is larger than that of the maximum transform block, the coding unit may be horizontally divided into two.

Information of the maximum size and/or the minimum size of the coding unit and information of the maximum size and/or the minimum size of the 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, or a slice level. For example, the minimum size of the coding unit may be determined to be 4 × 4. For example, the maximum size of the transform block may be determined to be 64 × 64. For example, the minimum size of the transform block may be determined to be 4 × 4.

Information of a minimum size of the coding unit (quad tree minimum size) corresponding to a leaf node of the quad tree and/or information of a maximum depth of the multi-type tree from a root node to the leaf node (maximum tree depth of the multi-type tree) 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, or a slice level, etc. Information of a minimum size of the quadtree and/or information of a maximum depth of the multi-type tree may be signaled or determined for each of the intra picture slices and the inter picture slices.

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, or a slice level, etc. 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 depending on the type of the strip. For example, for intra-picture stripes, the maximum size of the treble may be 32 x 32. For example, for inter-picture slices, 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 as the minimum size of the coding block.

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 stripe 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.

In accordance with the size information and the depth information of the various blocks described above, the four-partition information, the multi-type tree partition indication information, the partition tree information, and/or the partition direction information may or may not be included in the bitstream.

For example, when the size of the coding unit is not greater than the minimum size of the quadtree, the coding unit does not contain the quadrant information. Therefore, the quadrant information can be derived from the second value.

For example, when the size (horizontal size and vertical size) of the coding unit corresponding to the node of the multi-type tree is larger 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 or tri-partitioned. Accordingly, the multi-type tree partition indication information may not be signaled, but may be derived from the second value.

Alternatively, when the sizes (horizontal and vertical sizes) of the coding units corresponding to the nodes of the multi-type tree are the same as the maximum sizes (horizontal and vertical sizes) of the binary tree and/or are as large as twice the maximum sizes (horizontal and vertical sizes) of the ternary tree, the coding units may not be further bi-partitioned or tri-partitioned. Accordingly, the multi-type tree partition indication information may not be signaled, but may be derived from the second value. This is because, when the coding unit is partitioned according to 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.

Alternatively, 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 bi-partitioned and/or tri-partitioned. Accordingly, the multi-type tree partition indication information may not be signaled, but may be derived from the second value.

Alternatively, the multi-type tree partition indication information may be signaled only when at least one of the vertical direction binary tree partition, the horizontal direction binary tree partition, the vertical direction ternary tree partition, and the horizontal direction ternary tree partition is available for a coding unit corresponding to a node of the multi-type tree. Otherwise, the coding unit may not be bi-partitioned and/or tri-partitioned. Accordingly, the multi-type tree partition indication information may not be signaled, but may be derived from the second value.

Alternatively, the partition direction information may be signaled only when both the vertical direction binary tree partition and the horizontal direction binary tree partition or both the vertical direction ternary tree partition and the horizontal direction ternary tree partition are available for the coding units corresponding to the nodes of the multi-type tree. Otherwise, partition direction information may not be signaled, but may be derived from a value indicating a possible partition direction.

Alternatively, the partition tree information may be signaled only when both the vertical direction binary tree partition and the vertical direction ternary tree partition, or both the horizontal direction binary tree partition and the horizontal direction ternary tree partition, are feasible for the coding tree corresponding to the nodes of the multi-type tree. Otherwise, the partition tree information may not be signaled, but may be derived from values indicating possible partition tree structures.

Fig. 4 is a diagram illustrating an embodiment of inter-picture prediction processing.

In fig. 4, a rectangle may represent a picture. In fig. 4, arrows indicate prediction directions. Pictures can be classified into intra pictures (I pictures), predictive pictures (P pictures), and bidirectional predictive pictures (B pictures) according to the coding type of the picture.

I pictures can be encoded by intra prediction without the need for inter-picture prediction. P pictures can be encoded through inter-picture prediction by using reference pictures existing in one direction (i.e., forward or backward) with respect to a current block. B pictures can be encoded through inter-picture prediction by using reference pictures existing in two directions (i.e., forward and backward) with respect to a 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.

Hereinafter, an embodiment of inter-picture prediction will be described in detail.

Inter-picture prediction or motion compensation may be performed using the reference picture and the motion information.

The motion information of the current block may be derived during inter-picture prediction by each of the encoding apparatus 100 and the decoding apparatus 200. The motion information of the current block may be derived by using motion information of reconstructed neighboring blocks, motion information of a co-located block (also referred to as a col block or a co-located block), and/or motion information of blocks adjacent to the co-located block. The co-located block may represent a block spatially co-located with the current block within a previously reconstructed co-located picture (also referred to as a col picture or a co-located picture). The co-located picture may be one picture among one or more reference pictures included in the reference picture list.

The method of deriving motion information of the current block may vary depending on the prediction mode of the current block. For example, as a prediction mode for inter-picture prediction, there may be an AMVP mode, a merge mode, a skip mode, a current picture reference mode, and the like. The merge mode may be referred to as a motion merge mode.

For example, when AMVP is used as the prediction mode, at least one of a motion vector of a reconstructed neighboring block, a motion vector of a co-located block, a motion vector of a block adjacent to the co-located block, and a (0,0) motion vector may be determined as a motion vector candidate for the current block, and a motion vector candidate list may be generated by using the motion vector candidates. The motion vector candidate of the current block may be derived by using the generated motion vector candidate list. 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 a block adjacent to the co-located block may be referred to as a temporal motion vector candidate, and the reconstructed motion vector of the neighboring block may be referred to as a spatial motion vector candidate.

The encoding apparatus 100 may calculate a Motion Vector Difference (MVD) between the motion vector of the current block and the motion vector candidate, and may perform entropy encoding on the Motion Vector Difference (MVD). Also, the encoding apparatus 100 may perform entropy encoding on the motion vector candidate index and generate a bitstream. The motion vector candidate index may indicate a best motion vector candidate among the motion vector candidates included in the motion vector candidate list. The decoding apparatus may perform entropy decoding on the motion vector candidate index included in the bitstream, and may select a motion vector candidate of the decoding target block from among the motion vector candidates included in the motion vector candidate list by using the entropy-decoded motion vector candidate index. Further, the decoding apparatus 200 may add the entropy-decoded MVD to the motion vector candidate extracted by the entropy decoding, thereby deriving the motion vector of the decoding target block.

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 to the decoding apparatus 200 as a bitstream. The decoding apparatus 200 may generate a prediction block of the decoding target block based on the derived motion vector and the reference picture index information.

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 a plurality of blocks. The merge mode may represent a mode in which motion information of the current block is derived from motion information of neighboring blocks. When the merge mode is applied, the merge candidate list may be generated using motion information of the reconstructed neighboring blocks and/or motion information of the co-located block. 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).

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 one of zero merge candidate and new motion information, wherein the new motion information is a combination of motion information of one neighboring block adjacent to the current block (spatial merge candidate), motion information of a co-located block of the current block included in the reference picture (temporal merge candidate), and motion information existing in the merge candidate list.

The encoding apparatus 100 may generate a bitstream by performing entropy encoding on at least one of the merging flag and the merging index, and may signal the bitstream to the decoding apparatus 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 of 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 disposed above the current block, and a temporal neighboring block temporally adjacent to the current block.

The skip mode may be a mode in which motion information of 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 motion information is to be used as 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 syntax elements regarding at least any one of motion vector difference information, a coded block flag, and a transform coefficient level to the decoding apparatus 200.

The current picture reference mode may represent a prediction mode in which a previously reconstructed region within a current picture to which the current block belongs is used for prediction. Here, the vector may be used to specify a previously reconstructed region. Information indicating whether the current block is to be encoded in the current picture reference mode may be encoded by using a 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 the flag or index may be derived based on a 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 a reference picture list for the current block so that the current picture is located at a fixed position or an arbitrary position in the reference picture list. The fixed position may be, for example, the position indicated by reference picture index 0, or the last position in the list. When the current picture is added to the reference picture list so that the current picture is located at an arbitrary position, a reference picture index indicating the arbitrary position may be signaled.

Based on the above description, an image encoding method and an image decoding method according to an embodiment of the present invention will be described in detail below.

Fig. 5 is a flowchart illustrating an image encoding method according to an embodiment of the present invention. Fig. 6 is a flowchart illustrating an image decoding method according to an embodiment of the present invention.

Referring to fig. 5, the encoding apparatus may derive a motion vector candidate (step S501), and generate a motion vector candidate list based on the derived motion vector candidate (step S502). After the motion vector candidate list is generated, a motion vector may be determined based on the generated motion vector candidate list (step S503), and motion compensation may be performed based on the determined motion vector (step S504). Subsequently, the encoding apparatus may encode information associated with motion compensation (step S505).

Referring to fig. 6, the decoding apparatus may perform entropy decoding on information associated with motion compensation received from the encoding apparatus (step S601), and derive motion vector candidates (step S602). The decoding apparatus may generate a motion vector candidate list based on the derived motion vector candidate (step S603), and determine a motion vector using the generated motion vector candidate list (step S604). Subsequently, the decoding apparatus may perform motion compensation by using the determined motion vector (step S605).

Fig. 7 is a flowchart illustrating an image encoding method according to another embodiment of the present invention. Fig. 8 is a flowchart illustrating an image decoding method according to another embodiment of the present invention.

Referring to fig. 7, the encoding apparatus may derive a merge candidate (step S701), and generate a merge candidate list based on the derived merge candidate. After generating the merge candidate list, the encoding apparatus may determine motion information using the generated merge candidate list (step S702), and may perform motion compensation on the current block using the determined motion information (step S703). Subsequently, the encoding apparatus may perform entropy encoding on the information associated with the motion compensation (step S704).

Referring to fig. 8, the decoding apparatus may perform entropy decoding on information associated with motion compensation received from the encoding apparatus (S801), derive merge candidates (S802), and generate a merge candidate list based on the derived merge candidates. After generating the merge candidate list, the decoding apparatus may determine motion information of the current block by using the generated merge candidate list (S803). Subsequently, the decoding apparatus may perform motion compensation using the motion information (S804).

Fig. 5 and 6 show examples of applying the AMVP shown in fig. 4, and fig. 7 and 8 show examples of applying the merge mode shown in fig. 4.

Hereinafter, each step in fig. 5 and 6 will be described, and each step in fig. 7 and 8 will be described later. However, the motion compensation steps corresponding to S504, S605, S703, and S804 and the entropy encoding/decoding steps corresponding to S505, S601, S704, and S801 will be described collectively.

Hereinafter, each step in fig. 5 and 6 will be described in detail below.

First, the step of deriving the motion vector candidates (S501, S602) will be described in detail.

The motion vector candidate of the current block may include at least one of a spatial motion vector candidate and a temporal motion vector candidate or both the spatial motion vector candidate and the temporal motion vector candidate.

The temporal motion vector of the current block may be derived from reconstructed blocks adjacent to the current block. For example, a motion vector of a reconstructed block adjacent to the current block may be determined as a spatial motion vector candidate of the current block.

Fig. 9 is a diagram illustrating an example of deriving a spatial motion vector candidate of a current block.

Referring to fig. 9, a spatial motion vector candidate of a current block may be derived from neighboring blocks adjacent to the current block X. The neighboring blocks adjacent to the current block X include at least one of a block B1 adjacent to the upper end of the current block, a block A1 adjacent to the left end 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 left corner of the current block. Neighboring blocks adjacent to the current block may have a square shape or a non-square shape. When one of neighboring blocks adjacent to the current block has a motion vector, the motion vector of the neighboring block may be determined as a spatial motion vector candidate of the current block. Whether neighboring blocks have motion vectors or whether motion vectors of the neighboring blocks can be used as spatial motion vector candidates of the current block may be determined based on the determination of whether the neighboring blocks exist or whether the neighboring blocks have been encoded through an inter prediction process. The determination of whether a specific neighboring block has a motion vector or whether the motion vectors of the neighboring blocks can be used as spatial motion vector candidates of the current block may be performed in a predetermined order. For example, as shown in fig. 9, the determination of the availability of the motion vector may be performed in the order of block a0, block a1, block B0, block B1, and block B2.

When a reference picture of a current block and a reference picture of a neighboring block having a motion vector are different from each other, the motion vectors of the neighboring blocks are scaled, and then the scaled motion vectors may be used as spatial motion vector candidates of the current block. The motion vector scaling may be performed based on at least any one of a distance between the current picture and a reference picture of the current block and a distance between the current picture and a reference picture of a neighboring block. Here, the spatial motion vector candidate of the current block may be derived by scaling the motion vector of the neighboring block according to a ratio of a distance between the current picture and a reference picture of the current block and a distance between the current picture and a reference picture of the neighboring block.

However, when the reference picture index of the current block and the reference picture index of the neighboring block having the motion vector are different, the scaled motion vector of the neighboring block may be determined as a spatial motion vector candidate of the current block. Even in this case, the scaling may be performed based on at least one of a distance between the current picture and a reference picture of the current block and a distance between the current picture and a reference picture of an adjacent block.

Regarding the scaling, motion vectors of neighboring blocks may be scaled based on a reference picture indicated by a reference picture index having a predefined value, and the scaled motion vectors may be determined as spatial motion vector candidates of the current block. The predefined value may be zero or a positive integer. For example, the spatial motion vector candidate of the current block may be derived by scaling a motion vector of a neighboring block based on a ratio of a distance between a current picture, which is indicated by a reference picture index having a predefined value, and a reference picture of the current block, which is indicated by a reference picture index having a predefined value, to a distance between the current picture and the reference picture of the neighboring block.

Alternatively, the spatial motion vector candidate of the current block may be derived based on at least one of the encoding parameters of the current block.

The temporal motion vector candidate of the current block may be derived from reconstructed blocks included in a co-located picture of the current picture. The co-located picture is a picture that has been encoded/decoded before the current picture and may be different from the current picture in temporal order.

Fig. 10 is a diagram illustrating an example of deriving a temporal motion vector candidate of a current block.

Referring to fig. 10, a temporal motion vector candidate of a current block may be derived from a block at an outer position of a block spatially co-located with the current block X within a co-located picture (also referred to as a co-located picture) including the current picture or from a block at an inner position of a block spatially co-located with the current block X. Here, the temporal motion vector candidate may represent a motion vector of a co-located block of the current block. For example, the temporal motion vector candidate of the current block X may be derived from a block H adjacent to the lower left corner of a block C spatially located at the same position as the current block X or from a block C3 including the center position of the block C. The block H, the block C3, etc. used to derive the temporal motion vector candidate of the current block are referred to as a co-located block.

Alternatively, at least one of a temporal motion vector candidate, a co-located picture, a co-located block, a prediction list utilization flag, and a reference picture index may be derived based on at least one of the encoding parameters.

When a distance between a current picture including the current block and a reference picture of the current block is different from a distance between a co-located picture including a co-located block and a reference picture of the co-located block, a temporal motion vector candidate of the current block may be obtained by scaling a motion vector of the co-located block. Here, the scaling may be performed based on at least one of a distance between the current picture and a reference picture of the current block and a distance between the co-located picture and a reference picture of the co-located block. For example, the temporal motion vector candidate of the current block may be derived by scaling the motion vector of the co-located block according to a ratio of a distance between the current picture and a reference picture of the current block and a distance between the co-located picture and a reference picture of the co-located block.

Next, the step of generating a motion vector candidate list based on the derived motion vector candidates (S502, S603) will be described.

The step of generating the motion vector candidate list may comprise a process of adding or deleting motion vector candidates to or from the motion vector candidate list and a process of adding a combined motion vector candidate to the motion vector candidate list.

First, a process of adding a derived motion vector candidate to a motion vector candidate list or deleting a derived motion vector candidate from the motion vector candidate list will be described. The encoding apparatus and the decoding apparatus may add the derived motion vector candidates to the motion vector candidate list in the order in which the motion vector candidates were derived.

It is assumed that the motion vector candidate list mvplislx may represent a motion vector candidate list corresponding to the reference picture lists L0, L1, L2, and L3. That is, a motion vector candidate list corresponding to the reference picture list L0 may be represented by mvpListL 0.

In addition to adding the spatial motion vector candidate and the temporal motion vector candidate to the motion vector candidate list, a motion vector having a predetermined value may be added to the motion vector candidate list. For example, when the number of motion vector candidates in the motion vector candidate list is less than the maximum number of motion vector candidates that can be included in the motion vector candidate list, a motion vector having a value of zero may be added to the motion vector candidate list.

Next, a process of adding the combined motion vector candidate to the motion vector candidate list will be described.

When the number of motion vector candidates in the motion vector candidate list is less than the maximum number of motion vector candidates that may be included in the motion vector candidate list, one or more motion vector candidates in the motion vector candidate list are combined to produce one or more combined motion vector candidates, and the generated combined motion vector candidate may be added to the motion vector candidate list. For example, at least one or more of a spatial motion vector candidate, a temporal motion vector candidate, and a zero motion vector candidate included in the motion vector candidate list are used to generate a combined motion vector candidate, and the generated combined motion vector candidate may be added to the motion vector candidate list.

Alternatively, a combined motion vector candidate may be generated based on at least one encoding parameter, and the combined motion vector candidate generated based on the at least one encoding parameter may be added to the motion vector candidate list.

Next, the steps of selecting a predicted motion vector of the current block from the motion vector candidate list (S503, S604) will be described below.

Among the motion vector candidates included in the motion vector candidate list, the motion vector candidate indicated by the motion vector candidate index may be determined as the predicted motion vector of the current block.

The encoding apparatus may calculate a difference between a motion vector of the current block and a predicted motion vector of the current block, thereby generating a motion vector difference. The decoding apparatus may generate the motion vector of the current block by adding the prediction motion vector to the motion vector difference.

Here, the motion information correction may be applied to any one of a motion vector candidate included in the motion vector candidate list, a predicted motion vector, or a motion vector calculated by adding the predicted motion vector to a motion vector difference. A detailed description of the motion information correction will be described later.

The steps of performing motion compensation (S504, S605) and entropy encoding/decoding information associated with motion compensation (S505, S601) shown in fig. 5 and 6, and the steps of performing motion compensation (S703, S804) and entropy encoding/decoding (S704, S801) shown in fig. 7 and 8 will be described together later.

Hereinafter, each step shown in fig. 7 and 8 will be described in detail.

First, the step of deriving a merge candidate (S701, 802) will be described.

The merge candidate of the current block may include at least one of a spatial merge candidate, a temporal merge candidate, and an additional merge candidate. Here, the expression "derivation space merging candidate" denotes a process of deriving a space merging candidate and adding the derived merging candidate to the merging candidate list.

Referring to fig. 9, a spatial merge candidate of a current block may be derived from neighboring blocks adjacent to the current block X. The neighboring blocks adjacent to the current block X may include at least one of a block B1 adjacent to the upper end of the current block, a block A1 adjacent to the left end 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 left corner of the current block.

To derive spatial merge candidates for a current block, it is determined whether each neighboring block adjacent to the current block can be used to derive spatial merge candidates for the current block. Such determination is made for neighboring blocks in a predetermined priority order. For example, the availability of spatial merge candidates may be performed in the order of blocks a1, B1, B0, a0, and B2 in the example of fig. 9. The spatial merge candidates determined based on the availability determination order may be sequentially added to the merge candidate list of the current block.

Fig. 11 is a diagram showing an example of a process of adding a spatial merge candidate to the merge candidate list.

Referring to fig. 11, four spatial merge candidates are derived from four neighboring blocks a1, B0, a0, and B2, and the derived spatial merge candidates may be sequentially added to a merge candidate list.

Alternatively, the spatial merging candidate may be derived based on at least one of the encoding parameters.

Here, the motion information of the spatial merge candidate may include three or more pieces of motion information including L2 motion information and L3 motion information in addition to the L0 motion information and the L1 motion information. Here, there may be at least one reference picture list, for example, including L0, L1, L2, and L3.

Next, a method of deriving a temporal merging candidate of the current block will be described.

The temporal merging candidate of the current block may be derived from reconstructed blocks included in a co-located picture of the current picture. The co-located picture may be a picture that is encoded/decoded before the current picture and may be different from the current picture in temporal order.

The expression "derivation time merge candidate" denotes a process of deriving a time merge candidate and adding the derived time merge candidate to the merge candidate list.

Referring to fig. 10, a temporal merging candidate of a current block may be derived from a block including a position outside a block spatially located at the same position as the current block X, which is disposed in a co-located picture of the current picture (also referred to as a co-located picture), or a block including a position inside a block spatially located at the same position as the current block X, which is disposed in the co-located picture of the current picture. The term "temporal merging candidate" may denote motion information of the co-located block. For example, the temporal merging candidate of the current block X may be derived from a block H adjacent to the lower left corner of a block C spatially located at the same position as the current block X, or from a block C3 including the center position of the block C. The block H, C3 or the like used to derive the temporal merging candidate for the current block is referred to as a collocated block (also referred to as a collocated block).

When a temporal merging candidate of the current block can be derived from a block H including a position arranged outside the block C, the block H is set as a co-located block of the current block. In this case, the temporal merging candidate of the current block may be derived based on the motion information of the block H. In contrast, when the temporal merging candidate of the current block cannot be derived from the block H, the block C3 including a position arranged inside the block C may be set as the co-located block of the current block. In this case, the temporal merging candidate of the current block may be derived based on the motion information of the block C3. When any temporal merging candidate of the current block cannot be derived from neither block H nor block C3 (e.g., both block H and block C3 are intra-coded blocks), the temporal merging candidate of the current block cannot be derived at all, or may be derived from blocks other than block H and block C3.

Alternatively, for example, a plurality of temporal merging candidates of the current block may be derived from a plurality of blocks included within the co-located picture. That is, a plurality of temporal candidates for the current block may be derived from block H, block C3, and the like.

Fig. 12 is a diagram showing an example of a process of adding a temporal merge candidate to the merge candidate list.

Referring to fig. 12, when one temporal merging candidate is derived from the co-located block at position H1, the derived temporal merging candidate may be added to the merging candidate list.

When a distance between a current picture including the current block and a reference picture of the current block is different from a distance between a co-located picture including a co-located block and a reference picture of the co-located block, a motion vector of a temporal merging candidate of the current block may be obtained by scaling a motion vector of the co-located block. Here, the scaling of the motion vector may be performed based on at least one of a distance between the current picture and a reference picture of the current block and a distance between the co-located picture and a reference picture of the co-located block. For example, the motion vector of the temporal merging candidate of the current block may be derived by scaling the motion vector of the co-located block according to a ratio of a distance between the current picture and a reference picture of the current block and a distance between the co-located picture and a reference picture of the co-located block.

Further, 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 may be derived based on at least one of an encoding parameter of the current block, a neighboring block, or a co-located block.

The merge candidate list may be generated by generating at least one of a spatial merge candidate and a temporal merge candidate and sequentially adding the derived merge candidates to the merge candidate list in the derived order.

Next, a method of deriving additional merge candidates for the current block will be described.

The term "additional merge candidate" may denote at least one of a modified spatial merge candidate, a modified temporal merge candidate, a combined merge candidate, and a predetermined merge candidate having a predetermined motion information value. Here, the expression "deriving an additional merge candidate" may denote a process of deriving an additional merge candidate and adding the derived additional merge candidate to the merge candidate list.

The modified spatial merge candidate may represent a merge candidate obtained by modifying at least one of motion information of the derived spatial merge candidate.

The modified temporal merging candidate may represent a modified merging candidate obtained by modifying at least one of motion information of the derived temporal merging candidate.

The combination merge candidate may represent a merge candidate obtained by combining motion information of at least one of a spatial merge candidate, a temporal merge candidate, a modified spatial merge candidate, a modified temporal merge candidate, a combination merge candidate, and a predetermined merge candidate having a predetermined motion information value, all of which are included in the merge candidate list.

Alternatively, the combination merge candidate may represent a merge candidate derived by combining motion information of at least one of the following merge candidates: a spatial merging candidate and a temporal merging candidate which are not included in the merging candidate list but are derived from a block from which at least one of the spatial merging candidate and the temporal merging candidate is derivable; a modified spatial merging candidate and a modified temporal merging candidate derived based on a spatial merging candidate and a temporal merging candidate derived from a block from which the spatial merging candidate and the temporal merging candidate can be derived; combining the merging candidates; and a predetermined merge candidate having a predetermined motion information value.

Alternatively, the combination merging candidate may be derived using motion information obtained by performing entropy decoding on the bitstream in a decoder. In this case, the motion information for deriving the combining candidates may be entropy-encoded into a bitstream in an encoder.

The combined merge candidate may represent a combined bi-predictive merge candidate. The combined bi-predictive merge candidate is a merge candidate using bi-prediction, and it may be a merge candidate having L0 motion information and L1 motion information.

The merge candidate having the predetermined motion information value may be a zero merge candidate having a motion vector of (0, 0). The merge candidates having the predetermined motion information value may be set in such a manner that the predetermined motion information value has the same value in the encoding apparatus and the decoding apparatus.

At least one of a modified spatial merge candidate, a modified temporal merge candidate, a combined merge candidate, and a merge candidate having a predetermined motion information value may be derived or generated based on at least one of encoding parameters of a current block, a neighboring block, or a co-located block. Further, at least one of a modified spatial merge candidate, a modified temporal merge candidate, a combined merge candidate, and a merge candidate having a predetermined motion information value may be added to the merge candidate list based on at least one of encoding parameters of the current block, the neighboring block, or the co-located block.

The size of the merge candidate list may be determined based on encoding parameters of the current block, the neighboring block, or the co-located block, and the size of the merge candidate list may vary depending on the encoding parameters.

Next, the steps of determining motion information of the current block using the generated merge candidate list (S702, S803) will be described.

The encoder may select a merge candidate to be used for motion compensation of the current block from the merge candidate list through motion estimation, and encode a merge candidate index merge _ idx indicating the determined merge candidate as a bitstream.

To generate a prediction block for the current block, the encoder may select a merge candidate from the merge candidate list by using the merge candidate index and determine motion information of the current block. Then, the encoder may perform motion compensation based on the determined motion information, thereby generating a prediction block for the current block.

The decoder may decode the merge candidate index in the received bitstream and determine a merge candidate included in the merge candidate list and indicated by the merge candidate index. The determined merge candidate may be determined as motion information of the current block. The determined motion information is used for motion compensation of the current block. Here, the term "motion compensation" may have the same meaning as inter prediction.

Meanwhile, the motion information modification may be applied to any one of the motion information determined based on the merge candidate index or the merge candidate included in the merge candidate list. A detailed description of the motion information correction will be described later.

Next, the steps (S504, S605, S703, S804) of performing motion compensation using the motion vector or the motion information will be described.

The encoding apparatus and the decoding apparatus may calculate the motion vector of the current block by using the prediction motion vector and the motion vector difference. After calculating the motion vector, the encoding apparatus and the decoding apparatus may perform inter prediction or motion compensation using the calculated motion vector (S504, S605).

The encoding apparatus and the decoding apparatus may perform inter prediction or motion compensation using the determined motion information (S703, S804). Here, the current block may have motion information of the determined merge candidate.

The current block may have one (minimum) to N (maximum) motion vectors according to a prediction direction of the current block. One to N (minimum) to N (maximum) prediction blocks may be generated using one to N motion vectors, and a final prediction block may be selected among the generated prediction blocks.

For example, when the current block has one motion vector, a prediction block generated using the motion vector (or motion information) may be determined as a final prediction block of the current block.

In addition, when the current block has a plurality of motion vectors (or pieces of motion information), a plurality of prediction blocks are generated using the plurality of motion vectors (or pieces of motion information), and a final prediction block of the current block is determined based on a weighted sum of the plurality of prediction blocks. A plurality of reference pictures respectively including a plurality of prediction blocks respectively indicated by a plurality of motion vectors (or a plurality of pieces of motion information) may be listed in different reference picture lists or one reference picture list.

For example, a plurality of prediction blocks of the current block may be generated based on at least one of a spatial motion vector candidate, a temporal motion vector candidate, a motion vector having a predetermined value, and a combined motion vector candidate, and then a final prediction block of the current block may be determined based on a weighted sum of the plurality of prediction blocks.

Alternatively, for example, a plurality of prediction blocks of the current block may be generated based on the motion vector candidates indicated by the preset motion vector candidate index, and then a final prediction block of the current block may be determined based on a weighted sum of the plurality of prediction blocks. Further, a plurality of prediction blocks may be generated based on motion vector candidates indicated by indexes within a predetermined motion vector candidate index range, and then a final prediction block of the current block may be determined based on a weighted sum of the plurality of prediction blocks.

The weighting factors of the respective prediction blocks may be equal to 1/N (here, N is the number of generated prediction blocks). For example, when two prediction blocks are generated, the weighting factor of each prediction block is 1/2. Similarly, when three prediction blocks are generated, the weighting factor of each prediction block is 1/3. When four prediction blocks are generated, the weighting factor of each prediction block may be 1/4. Alternatively, the final prediction block of the current block may be determined in such a manner that different weighting factors are applied to the respective prediction blocks.

The weighting factors for the plurality of prediction blocks may not be fixed but may be variable. The weighting factors for the plurality of prediction blocks may not be equal but may be different. For example, when two prediction blocks are generated, the weighting factors for the two prediction blocks may be equal, such as (1/2 ), or may not be equal, such as (1/3,2/3), (1/4,3/4), (2/5,3/5), or (3/8, 5/8). The weighting factor may be positive real value or negative real value. That is, the value of the weighting factor may comprise a negative real value, such as (-1/2, 3/2), (-1/3, 4/3), or (-1/4, 5/4).

To apply the variable weighting factor, one or more pieces of weighting factor information for the current block may be signaled through a bitstream. The weighting factor information may be signaled on a prediction block-by-prediction block basis or on a reference picture-by-reference picture basis. Alternatively, multiple prediction blocks may share a weighting factor.

The encoding apparatus and the decoding apparatus may determine whether to use the prediction motion vector (or the prediction motion information) based on the prediction block list utilization flag. For example, for each reference picture list, when the prediction block list utilization flag has a first value of one (1), the encoding apparatus and the decoding apparatus may perform inter prediction or motion compensation of the current block using a prediction motion vector for the current block. However, when the prediction block list utilization flag has a second value of zero (0), the encoding apparatus and the decoding apparatus may not perform inter prediction or motion compensation of the current block using the prediction motion vector for the current block. The first and second values of the prediction block list utilization flag may be inversely set to 0 and 1, respectively. Expressions 3 to 5 are examples of a method of generating a final prediction block of the current block when the inter prediction indicator of the current block is PRED _ BI, PRED _ TRI, or PRED _ QUAD and when the prediction direction for each reference picture list is unidirectional.

[ expression 1 ]

P_BI=(WF_LO*P_LO+OFFSET_LO+WF_L1*P_L1+OFFSET_L1+RF)>>1

[ expression 2 ]

P_TRI=(WF_LO*P_LO+OFFSET_LO+WF_L1*P_L1+OFFSET_L1+WF_L2*P_L2+OFFSET_L2+RF)/3

[ expression 3 ]

P_QUAD=(WF_LO*P_LO+OFFSET_LO+WF_L1*P_L1+OFFSET_L1+WF_L2*P_L2+OFFSET_L2+WF_L3*P_L3+OFFSET_L3+RF)>>2

In expressions 1 to 3, each of P _ BI, P _ TRI, and P _ QUAD represents a final prediction block of a current block, and LX (X ═ 0, 1, 2, 3) represents a reference picture list. WF _ LX denotes a weighting factor of a prediction block generated using the LX reference picture list. OFFSET _ LX denotes an OFFSET value for a prediction block generated using an LX reference picture list. P _ LX denotes a prediction block generated using a motion vector (or motion information) of the LX reference picture list of the current block. RF represents a rounding factor and may be set to 0, a positive integer, or a negative integer. The LX reference picture list may include at least one of a long-term reference picture, a reference picture on which deblocking filtering is not performed, a reference picture on which sample adaptive offset is not performed, a reference picture on which adaptive loop filtering is not performed, a reference picture on which only deblocking filtering and adaptive offset are performed, a reference picture on which only deblocking filtering and adaptive loop filtering are performed, a reference picture on which sample adaptive offset and adaptive loop filtering are performed, and a reference picture on which all deblocking filtering, sample adaptive offset, and adaptive loop filtering are performed. In this case, the LX reference picture list may be at least any one of an L2 reference picture list and an L3 reference picture list.

Even when there are a plurality of prediction directions with respect to a predetermined reference picture list, a final prediction block of the current block may be obtained based on a weighted sum of the plurality of prediction blocks. In this case, the weighting factors of the prediction blocks derived using one reference picture list may be equal or different from each other.

At least one of the weighting factors WF _ LX or the OFFSET _ LX of the plurality of prediction blocks may be an encoding parameter to be entropy-encoded/entropy-decoded. Alternatively, for example, the weighting factors and offsets may be derived from previously encoded/decoded neighboring blocks adjacent to the current block. Here, the neighboring blocks adjacent to the current block may include at least one of a block for deriving a spatial motion vector candidate of the current block and a block for deriving a temporal motion vector candidate of the current block.

Further alternatively, the weighting factor and the offset may be determined based on, for example, a display order (picture order count (POC)) of the current picture and a POC of each reference picture. In this case, the value of the weighting factor or offset may decrease as the distance between the current picture and the reference picture increases. That is, when the current picture and the reference picture are close to each other, a larger value may be set as the weighting factor or the offset. For example, when the difference between the POC of the current picture and the POC of the L0 reference picture is 2, the value of the weighting factor applied to the prediction block generated using the L0 reference picture may be set to 1/3. Meanwhile, when the difference between the POC of the current picture and the POC of the L0 reference picture is 1, the value of the weighting factor applied to the prediction block generated using the L0 reference picture may be set to 2/3. As described above, the weighting factor or offset may be inversely proportional to the difference between the display order (POC) of the current picture and the display order (POC) of the reference picture. Alternatively, the weighting factor or offset may be proportional to the difference between the display order (POC) of the current picture and the display order (POC) of the reference picture.

Alternatively, for example, at least one of the weight factor and the offset may be entropy encoded/decoded based on at least one encoding parameter. Furthermore, a weighted sum of the prediction blocks may be calculated based on the at least one coding parameter.

The weighted sum of the plurality of prediction blocks may be applied to only a partial region of the prediction block. The partial region may be a boundary region adjacent to a boundary of each prediction block. As described above, in order to apply the weighting sum to only the partial region, the weighting sum may be calculated on a sub-block-by-sub-block basis in each prediction block.

In a block having a block size indicated by the region information, inter prediction or motion compensation may be performed on sub blocks smaller than the block by using the same prediction block or the same final prediction block.

In a block having a block depth indicated by the region information, inter prediction or motion compensation may be performed on a sub-block having a block depth deeper than the block depth of the block by using the same prediction block or the same final prediction block.

Further, when the weighted sum of the prediction blocks is calculated by motion vector prediction, the weighted sum may be calculated using at least one of the motion vector candidates included in the motion vector candidate list, and the calculation result may be used as the final prediction block of the current block.

For example, a prediction block may be generated using only spatial motion vector candidates, a weighted sum of the prediction blocks may be calculated, and the calculated weighted sum may be used as a final prediction block of the current block.

For example, a prediction block may be generated using a spatial motion vector candidate and a temporal motion vector candidate, a weighted sum of the prediction blocks may be calculated, and the calculated weighted sum may be used as a final prediction block of the current block.

For example, a prediction block may be generated using only the combined motion vector candidates, a weighted sum of the prediction blocks may be calculated, and the calculated weighted sum may be used as a final prediction block of the current block.

For example, a prediction block may be generated using only a motion vector candidate indicated by a specific index, a weighted sum of the prediction blocks may be calculated, and the calculated weighted sum may be used as a final prediction block of the current block.

For example, a prediction block may be generated using only motion vector candidates indicated by indexes within a predetermined index range, a weighted sum of the prediction blocks may be calculated, and the calculated weighted sum may be used as a final prediction block of the current block.

When the weighted sum of the prediction block is calculated using the merge mode, the weighted sum may be calculated using at least one merge candidate among the merge candidates included in the merge candidate list, and the calculation result may be used as a final prediction block of the current block.

For example, a prediction block may be generated using only the spatial merge candidates, a weighted sum of the prediction blocks may be calculated, and the calculated weighted sum may be used as a final prediction block of the current block.

For example, a prediction block may be generated using the spatial merge candidate and the temporal merge candidate, a weighted sum of the prediction blocks may be calculated, and the calculated weighted sum may be used as a final prediction block of the current block.

For example, the prediction block may be generated using only the combined merge candidates, a weighted sum of the prediction blocks may be generated, and the calculated weighted sum may be used as a final prediction block of the current block.

For example, a prediction block may be generated using only the merge candidates indicated by a specific index, a weighted sum of the prediction blocks may be generated, and the calculated weighted sum may be used as a final prediction block of the current block.

For example, the prediction block may be generated using only the merge candidates indicated by the indexes within the predetermined index range, a weighted sum of the prediction blocks may be calculated, and the calculated weighted sum may be used as a final prediction block of the current block.

In the encoder and the decoder, motion compensation may be performed using a motion vector or motion information of the current block. At this time, a final prediction block, which is a result of motion compensation, may be determined using at least one prediction block. Here, the current block may represent at least one of a current encoding block and a current prediction block.

The final prediction block of the current block may be generated by performing overlapped block motion compensation on a boundary region of the current block.

The boundary region of the current block may be a region that is disposed within the current block and is adjacent to a boundary between the current block and a neighboring block of the current block. The boundary region of the current block may include at least one of an upper boundary region, a left boundary region, a lower boundary region, a right boundary region, an upper-right corner region, a lower-right corner region, an upper-left corner region, and a lower-left corner region. The boundary region of the current block may be a region corresponding to a portion of a prediction block of the current block.

The overlapped block motion compensation may represent a process of performing motion compensation by calculating a weighted sum of a prediction block corresponding to a boundary region of the current block and a prediction block generated using motion information of an encoding/decoding block adjacent to the current block.

The calculation of the weighted sum may be performed sub-block by dividing the current block into a plurality of sub-blocks. That is, motion compensation of the current block may be performed sub-block by sub-block using motion information of encoded/decoded sub-blocks adjacent to the current block. The sub-block may represent a lower level block of the current block.

Further, in calculating the weighted sum, a first prediction block generated for each sub-block of the current block using motion information of the current block and a second prediction block generated using motion information of an adjacent sub-block spatially adjacent to the current block may be used. In this case, the expression "use motion information" means "derive motion information". The first prediction block may represent a prediction block generated by using motion information of an encoding/decoding target sub-block within the current block. The second prediction block may be a prediction block generated by using motion information of neighboring sub-blocks spatially adjacent to an encoding/decoding target sub-block within the current block.

A final prediction block for the current block may be generated using a weighted sum of the first prediction block and the second prediction block. That is, overlapped block motion compensation is to find a final prediction block of a current block using motion information of the current block and motion information of another block.

Further, when at least one of an Advanced Motion Vector Prediction (AMVP) mode, a merge mode, an affine motion compensation mode, a decoder-side motion vector derivation mode, an adaptive motion vector resolution mode, a local illumination compensation mode, a bidirectional optical flow mode is used, a current block may be divided into a plurality of sub-blocks, and overlapped block motion compensation may be performed sub-block by sub-block.

When the merge mode is used for motion compensation, overlapped block motion compensation may be performed on at least one of an Advanced Temporal Motion Vector Predictor (ATMVP) candidate and a spatio-temporal motion vector predictor (STMVP) candidate.

Next, a process of performing entropy encoding/decoding on information associated with motion compensation (S505, S601, S704, S801) will be described.

The encoding apparatus may entropy-encode information associated with motion compensation into a bitstream, and the decoding apparatus may decode the information associated with motion compensation included in the bitstream. The information associated with motion compensation, which is a target of entropy encoding or entropy decoding, may include at least one of: inter prediction indicator inter _ pred _ idc, reference picture index ref _ idx _ l0, ref _ idx _ l1, ref _ idx _ l2, and ref _ idx _ l3, motion vector candidate index mvp _ l0, mvp _ l1_ idx, mvp _ l2_ idx, and mvp _ l3_ idx, motion vector difference, skip mode use/non-use information cu _ skip _ flag, merge mode use/non-use information merge _ flag, merge index information merge _ index, weighting factor wf _ l0, wf _ l1, wf _ l2, and wf _ l3, and offset value offset _ l0, offset _ l1, offset _ l2, and offset _ l 3.

When the current block is encoded/decoded by inter prediction, the inter prediction indicator may represent a prediction direction of the inter prediction, the number of prediction directions, or both. For example, the inter prediction indicator may indicate unidirectional prediction or multidirectional prediction (such as bidirectional prediction, three-way prediction, and four-way prediction). The inter prediction indicator may indicate the number of reference pictures used to generate the prediction block for the current block. Alternatively, one reference picture can be used for prediction in multiple directions. In this case, M reference pictures are used to perform prediction in N directions (where N > M). The inter prediction indicator may also represent the number of prediction blocks used for inter prediction or motion compensation of the current block.

The reference picture indicator may indicate one direction PRED _ LX, two directions PRED _ BI, three directions PRED _ TRI, four directions PRED _ QUAD, or more directions according to the number of prediction directions of the current block.

The prediction list of the specific reference picture list indicates whether a prediction block is generated using the reference picture list using a flag.

For example, when the prediction list utilization flag of a specific reference picture list has a first value of one (1), this means that a prediction block is generated using the reference picture list. When the prediction list utilization flag has a second value of zero (0), this means that the reference picture list is not used to generate the prediction block. Here, the first value and the second value of the prediction list utilization flag may be inversely set to 0 and 1, respectively.

That is, when the prediction list utilization flag of a specific reference picture list has a first value, a prediction block of the current block may be generated using motion information corresponding to the reference picture list.

The reference picture index may indicate a specific reference picture that exists in a reference picture list and is referred to by the current block. For each reference picture list, one or more reference picture indices may be entropy encoded/decoded. The current block may be motion compensated using one or more reference picture indices.

The motion vector candidate index indicates a motion vector candidate of the current block among motion vector candidates included in the motion vector candidate list prepared for each reference picture list or each reference picture index. At least one or more motion vector candidate indices may be entropy encoded/decoded for each motion vector candidate list. The current block may be motion compensated using at least one or more motion vector candidate indices.

The motion vector difference represents a difference between the current motion vector and the predicted motion vector. One or more motion vector differences may be entropy-encoded/entropy-decoded for each of the motion vector candidate lists generated for each reference picture list or each reference picture index of the current block. The current block may be motion compensated using one or more motion vector differences.

Regarding the skip mode use/nonuse information cu _ skip _ flag, when it has a first value of one (1), the skip mode may be used. Conversely, when it has a second value of zero (0), the skip mode may not be used. The motion compensation for the current block may be performed using the skip mode according to skip mode use/nonuse information.

With respect to merge mode use/nonuse information merge _ flag, when it has a first value of one (1), a merge mode may be used. Conversely, when it has a second value of zero (0), the merge mode may not be used. The motion compensation for the current block may be performed using the merge mode according to the merge mode use/nonuse information.

The merge index information merge _ index may represent information indicating a merge candidate within the merge candidate list.

Alternatively, the merge index information may represent information on a merge index.

Furthermore, the merge index information may indicate a reconstructed block used to derive the merge candidate among a plurality of reconstructed blocks spatially/temporally adjacent to the current block.

The merge index information may indicate one or more pieces of motion information that the merge candidate has. For example, when the merge index information has a first value of zero (0), the merge index information may indicate a first merge candidate listed as a first item in the merge candidate list; when the merge index information has a second value of one (1), the merge index information may indicate a second merge candidate listed as a second item in the merge candidate list; when the merge index information has a third value of two (2), the merge index information may indicate a third merge candidate listed as a third item in the merge candidate list. Similarly, when the merge index information has a value from the fourth value to the nth value, the merge index information may indicate a merge candidate at a position listed in the merge candidate list according to the order of the values. Here, N may be 0 or a positive integer.

Motion compensation may be performed on the current block based on the merge mode index information using the merge mode.

When two or more prediction blocks are generated during motion compensation of the current block, a final prediction block of the current block may be determined based on a weighted sum of the prediction blocks. When calculating the weighted sum, a weighting factor, an offset, or both may be applied to each prediction block. The weighted sum factors (e.g., weighting factors and offsets) used to calculate the weighted sum may be entropy encoded/entropy decoded by or corresponding to at least one of: reference picture list, reference picture, motion vector candidate index, motion vector difference, motion vector, skip mode use/non-use information, merge index information. Further, the weighted sum factor for each prediction block may be entropy encoded/entropy decoded based on the inter prediction indicator. The weighted sum factor may include at least one of a weighting factor and an offset.

The information associated with motion compensation may be entropy-encoded/entropy-decoded on a block-by-block basis or may be entropy-encoded/entropy-decoded in units of higher-level units. For example, information associated with motion compensation may be entropy encoded/decoded block-by-block (e.g., CTU-by-CTU, CU-by-CU, or PU-by-PU). Alternatively, the information associated with motion compensation may be entropy-encoded/entropy-decoded in units of higher level units, such as a video parameter set, a sequence parameter set, a picture parameter set, an adaptive parameter set, or a slice header.

The information associated with motion compensation may be entropy-encoded/entropy-decoded based on a motion compensation information difference, wherein the motion compensation information difference indicates a difference between the information associated with motion compensation and a prediction value of the information associated with motion compensation.

Information associated with motion compensation of an encoded/decoded block adjacent to the current block may be used as information associated with motion compensation of the current block without entropy-encoding/decoding the information associated with motion compensation of the current block.

At least one piece of information associated with motion compensation may be derived based on at least one encoding parameter.

The bitstream may be decoded based on the at least one encoding parameter to generate at least one piece of information associated with motion compensation. Instead, at least one piece of information associated with motion compensation may be entropy-encoded into a bitstream based on at least one encoding parameter.

The at least one piece of information associated with the motion compensation may include at least one of a motion vector, a motion vector candidate index, a motion vector difference, a motion vector predictor, skip mode use/non-use information skip _ flag, merge mode use/non-use information merge _ flag, merge index information merge _ index, motion vector resolution information, overlapped block motion compensation information, local illumination compensation information, affine motion compensation information, decoder-side motion vector derivation information, and bi-directional optical flow information. Here, the decoder-side motion vector derivation may mean a pattern matching motion vector derivation.

The motion vector resolution information may be information indicating which specific resolution is used for at least one of the motion vector and the motion vector difference. Here, the resolution may represent precision. The specific resolution may be set to at least any one of 16 pixel (16-pel), 8 pixel (8-pel), 4 pixel (4-pel), integer pixel (integer-pel), 1/2 pixel (1/2-pel), 1/4 pixel (1/4-pel), 1/8 pixel (1/8-pel), 1/16 pixel (1/16-pel), 1/32 pixel (1/32-pel), and 1/64 pixel (1/64-pel).

The overlapped block motion compensation information may be information indicating whether a motion vector of a neighboring block spatially adjacent to the current block is additionally used to calculate a weighted sum of the prediction block of the current block during motion compensation of the current block.

The local illumination compensation information may be information indicating whether one of a weighting factor and an offset is applied when generating the prediction block of the current block. Here, at least one of the weighting factor and the offset may be a value calculated based on the reference block.

The affine motion compensation information may be information indicating whether an affine motion model is used for motion compensation of the current block. Here, the affine motion model may be a model that divides one block into a plurality of sub-blocks using a plurality of parameters and calculates motion vectors of the sub-blocks using representative motion vectors.

The decoder-side motion vector derivation information may be information indicating whether a motion vector required for motion compensation is derived by a decoder and then used in the decoder. From the decoder-side motion vector derivation information, the information associated with the motion vector may not be entropy encoded/entropy decoded. When the decoder-side motion vector derivation information indicates that the motion vector is derived by the decoder and then used in the decoder, the information associated with the merge mode may be entropy-encoded/entropy-decoded. That is, the decoder-side motion vector derivation information may indicate whether the merge mode is used in the decoder.

The bi-directional optical flow information may be information indicating whether to modify a motion vector on a pixel-by-pixel basis or a sub-block-by-sub-block basis and then use the modified motion vector for motion compensation. Depending on the bi-directional optical flow information, the motion vectors may be entropy encoded/decoded without pixel-by-pixel or sub-block-by-sub-block. Modifying the motion vector means converting a value of the block-based motion vector into a value of the pixel-based motion vector or a value of the sub-block-based motion vector.

The current block may be motion-compensated based on at least one piece of information associated with motion compensation, and the at least one piece of information associated with motion compensation may be entropy-encoded/entropy-decoded.

When entropy encoding/decoding information associated with motion compensation, a binarization method such as a truncated Rice binarization method, a K-order index Golomb binarization method, a finite K-order index Golomb binarization method, a fixed length binarization method, a unary binarization method, and a truncated unary binarization method may be used.

When entropy encoding/decoding information associated with motion compensation, a context model may be determined based on at least one of: information associated with motion information of a neighboring block neighboring the current block or region information of the neighboring block; previously encoded/decoded information associated with motion compensation or previously encoded/decoded region information; information on a depth of the current block; and information on the size of the current block.

Alternatively, when entropy-encoding/decoding the information associated with the motion compensation, the entropy-encoding/entropy-decoding may be performed by using at least one of information associated with the motion compensation of the neighboring block, previously encoded/decoded information associated with the motion compensation, information regarding the depth of the current block, and information regarding the size of the current block as a prediction value of the information associated with the motion compensation of the current block.

Hereinafter, the motion information correction method will be described in detail with reference to fig. 13 to 15. Here, the motion information correction may mean a process of correcting at least one piece of motion information. That is, the information on which the motion information correction is to be performed may be at least one piece of motion information including: motion vectors, reference picture indices, reference pictures, inter-picture prediction indicators, prediction list utilization flags, weighting factors, offsets, and the like. The motion information modification means modification of a value of at least one of a motion vector, a reference picture index, a reference picture, an inter-picture prediction indicator, a prediction list utilization flag, a weighting factor, and an offset.

The information to be subjected to the motion information correction may be information such as at least one parameter among various encoding parameters. In this case, the motion information modification means modification of a value of information such as at least one parameter among the encoding parameters.

By the motion information modification, modified motion information is generated. The modified motion information modified by the motion information may be used for motion compensation of a current block to be encoded/decoded (hereinafter, also referred to as an encoding/decoding target block) (S504 in fig. 5, S605 in fig. 6, S703 in fig. 7, S804 in fig. 8).

With respect to the timing for performing the motion information correction, the motion information correction may be performed before performing the motion compensation. That is, before performing motion compensation on the encoding/decoding target block, motion information correction is first performed to generate corrected motion information, and then motion compensation will be performed using the generated corrected motion information.

For example, for the AMVP mode, motion information correction may be performed in the step of determining a motion vector (S503 in fig. 5 and S604 in fig. 6). In this case, the motion information correction may be applied to any one of the following information types: a motion vector candidate included in the motion vector candidate list, a prediction motion vector, and a motion vector calculated by adding the prediction motion vector to the motion vector difference.

For example, for the merge mode, motion information correction may be performed in the step of determining motion information (S702 in fig. 7 and S803 in fig. 8). In this case, the motion information modification may be applied to the merge candidates included in the merge candidate list or the motion information extracted from the merge candidate list based on the merge candidate index.

On the other hand, motion information correction can be performed even for the skip mode. In this case, the motion information correction may be applied to skip candidates included in the skip candidate list or motion information extracted from the skip candidate list based on a skip index.

Regarding the timing for performing the motion information correction, the motion information correction may be performed during the motion compensation (S504 in fig. 5, S605 in fig. 6, S703 in fig. 7, S804 in fig. 8) is performed. That is, in performing motion compensation on the encoding/decoding target block, motion information correction is performed to generate corrected motion information, and motion compensation is performed using the corrected motion information.

For example, the encoder/decoder may generate a prediction block based on the motion information determined in the motion vector determination step or the motion information determination step (S503 in fig. 5, 604 in fig. 6, 702 in fig. 7, and S803 in fig. 8), and may generate modified motion information by performing motion information modification using the generated prediction block. Here, the encoder/decoder may generate a final prediction block using the modified motion information.

The motion information can be modified according to the same rule at both the encoder side and the decoder side. Since the motion information is modified according to the same rule at the encoder side and the decoder side, the "information on the use of motion information modification" (hereinafter, referred to as motion information modification utilization information) may not be entropy-encoded/entropy-decoded.

Hereinafter, double-sided template matching, which is an exemplary motion information correction method, will be described as an image decoding method according to an embodiment with reference to fig. 13 to 15.

The double-sided template matching is a method of correcting a motion vector among pieces of motion information. At least one of the two motion vectors used for bi-directional prediction may be modified by double-sided template matching. Here, the double-sided template represents a prediction block obtained by calculating a weighted sum of a plurality of prediction blocks generated using two motion vectors in the bi-prediction process. The term "bi-directional prediction" means prediction in both the forward and backward directions.

Specifically, when the double-sided template matching is performed on the bi-prediction block, at least one of a first motion vector corresponding to the reference picture list 0 and a second motion vector corresponding to the reference picture list 1 may be corrected. At this time, the modified motion vector may have a different motion vector value from the initial motion vector.

Fig. 13 is a diagram for describing double-sided template matching.

Referring to fig. 13, the double-sided template matching includes: (1) generating a double-sided template using the initial motion vector; (2) the samples of the bilateral template are compared with the reconstructed samples of the reference picture to correct the motion vector.

(1) Generation of a two-sided template

The encoder/decoder may generate the bilateral template using a prediction block generated using a first motion vector corresponding to reference picture list 0 and a prediction block generated using a second motion vector corresponding to reference picture list 1. The encoder/decoder may generate the bilateral template using a prediction block generated using a first motion vector corresponding to reference picture list 0 and a prediction block generated using a second motion vector corresponding to reference picture list 0. The encoder/decoder may generate the bilateral template using a prediction block generated using a first motion vector corresponding to reference picture list 1 and a prediction block generated using a second motion vector corresponding to reference picture list 1. Here, the bilateral template may be generated by calculating a weighted sum of the prediction blocks, and a weighting factor used to calculate the weighted sum may be 0.5: 0.5.

The motion vector used in generating the double-sided template is referred to as an initial motion vector. The initial motion vector may represent a motion vector calculated by using at least one motion information derivation method, such as a merge mode, an AMVP mode, and a skip mode.

(2) Correction of motion vectors

The encoder/decoder may modify the motion vectors corresponding to each reference picture list by comparing the values of the samples in the bilateral template to the values of the reconstructed samples in the reference pictures.

A motion vector indicating an internal reference position (i.e., a position within the reference picture) of the reference picture list 0, which has a value of a minimum distortion value with respect to a value of a corresponding position in the bilateral template, may be determined as the modified first motion vector. A motion vector indicating an internal reference position of the reference picture list 1 may be determined as the modified second motion vector, wherein the motion vector has a value of minimum distortion with respect to a corresponding position in the bilateral template.

Specifically, the first motion vector may be modified when a distortion value (difference) between a value of a region in the reference picture indicated by the initial first motion vector and a value of a corresponding region in the bilateral template is larger than a distortion value between a value of a region in the reference picture indicated by the modified first motion vector and a value of a corresponding region in the bilateral template. Similarly, the second motion vector may be modified when a distortion value between a value of a region in the reference picture indicated by the initial second motion vector and a value of the corresponding region in the bilateral template is greater than a distortion value between a value of a region in the reference picture indicated by the modified second motion vector and a value of the corresponding region in the bilateral template.

When comparing the values of the samples (target samples) in the bilateral template with the values of the reconstructed samples (reference samples) in the reference picture, the encoder/decoder calculates the inter-sample distortion value by using a distortion calculation method such as: sum of Absolute Difference (SAD), Sum of Absolute Transformed Difference (SATD), Sum of Squared Error (SSE), Mean Square Error (MSE) or SAD de-averaging (MR-SAD). In this way, the encoder/decoder determines a motion vector indicative of a reference sample position exhibiting a minimum distortion value with respect to a corresponding target sample position as a modified motion vector. In this case, the distortion value may be calculated for at least one of the luminance component and the chrominance component.

When the SAD value of the internal reference region indicated by the initial first motion vector and the internal reference region indicated by the initial second motion vector is greater than a predetermined value, double template matching may be performed to correct the initial first motion vector and the initial second motion vector. In contrast, when the SAD value of the internal reference region indicated by the initial first motion vector and the internal reference region indicated by the initial second motion vector is less than a predetermined value, the double-sided template matching may not be performed.

In the case of performing bi-directional prediction, when the value of the initial first motion vector corresponding to the first prediction direction (e.g., L0 prediction direction) is equal to the value of the corrected first motion vector corrected by motion information, motion information correction may not be performed on the initial second motion vector corresponding to the second direction (e.g., L1 prediction direction).

On the other hand, the two-sided template matching may be performed recursively.

Specifically, after generating the second bilateral template using the modified first motion vector and the modified second motion vector, another bilateral template matching may be performed using the second bilateral template to secondarily modify the previously modified first motion vector and the previously modified second motion vector. In this case, the double-sided template matching-based quadratic correction may be iteratively performed up to M times. Here, M is a positive integer (e.g., 2), and it may be a fixed value preset in the encoder/decoder or a variable value encoded and signaled by the encoder. Alternatively, M may be determined based on the size of the encoding/decoding target block.

For example, when the height or width of the encoding/decoding target block is less than 8, M may be set to 2.

For example, when the height or width of the encoding/decoding target block is 8, M may be set to 2.

For example, when the size of the width of the encoding/decoding target block is 8 and the size of the height is 16 (or vice versa), M may be set to 4.

In addition to the above, M may be set to 8. In this case, the double-sided template matching may be performed four times for the first reference picture (e.g., the L0 reference picture) and four times for the second reference picture (e.g., the L1 reference picture).

On the other hand, in the case where the double-sided template matching is recursively performed on a sub-pixel basis, the double-sided template matching may also be recursively performed on an integer-pixel basis.

The modified motion vector generated by the double-sided template matching may be used for motion compensation of the encoding/decoding target block instead of the initial motion vector. The two-sided template matching may be performed at the encoder side and the decoder side according to the same rule.

In double-sided template matching, only a limited area within the reference picture can be searched for a modified motion vector.

Fig. 14 and 15 are diagrams illustrating an area (hereinafter, referred to as a search range) searched for finding a modified motion vector during double-sided template matching.

Referring to fig. 14, the search range may be determined based on integer pixels, for example, a range of-M to + N pixels in horizontal and vertical directions. Here, M and N are positive integers.

Alternatively, the search range may be determined on a sub-pixel basis, for example, a range of-O to + P sub-pixels in the horizontal direction and the vertical direction. Here, O and P may be fractions. For example, the unit of the sub-pixel may represent 1/2 pixels, 1/4 pixels, 1/8 pixels, 1/16 pixels, 1/32 pixels, and the like. Further, O and P representing a subpixel may have positive integer values.

When the encoder/decoder searches for the modified motion vector on a sub-pixel basis, the area including the neighboring sub-pixels spatially adjacent to the specific integer pixel indicated by the integer pixel motion vector may be a search range. Fig. 14 shows an example in which the unit of the sub-pixel is 1/2 pixels.

Further, the sub-pixel based search range may be limited to reduce memory access bandwidth. For example, the sub-pixel based search range may be limited to only sub-pixels arranged within the integer-pixel based search area.

Fig. 15 is a diagram illustrating a method of limiting a search range of sub-pixels to within an integer-pixel-based search range.

Referring to fig. 15, the sub-pixels represented by the hatched circles are not included in the integer-pixel-based search range in which the search-modified motion vector is performed on the basis of the integer pixels. In this case, the sub-pixel based search range may be limited such that sub-pixels outside the integer-pixel based search range are not searched when finding the modified motion vector. That is, a limit may be imposed on the subpixel-based search range such that only the subpixels represented by the unshaded circles are searched for a modified motion vector. In this case, it is not necessary to acquire information of the integer pixel for generating the hatched sub-pixel, thereby reducing the memory access bandwidth.

On the other hand, the integer-pixel-based search range may include at least one of a center point, an upper point, a lower point, a left point, and a right point.

Here, at least one point may be further searched based on the distortion values of the upper point, the lower point, the left point, and the right point. Here, the at least one point may be at least one of an upper left point, a lower left point, an upper right point, and a lower right point. In this case, the subpixel-based search range may be set to at least one of a center point, an upper point, a lower point, a left point, a right point, an upper left point, a lower left point, an upper right point, and a lower right point. For example, the subpixel-based search range may be set to a center point, an upper point, a lower point, a left point, and a right point.

The shape of the search range around the pixel indicated by the initial motion vector may be a two-dimensional map (such as a square, rectangle, diamond (rhombus), or cross). The search range may have a fixed shape predefined in the encoder/decoder or a variable shape specified by information encoded and signaled by the encoder.

Further, the motion vector value range may be limited for at least one of the initial motion vector and the modified motion vector such that the search range will not extend a certain distance or more outside the boundary of the picture. The range limitation of the motion vector values can be achieved by clipping.

In this case, the range of the motion vector value may be determined to fall within a predetermined range preset in the encoder and the decoder. Here, the predetermined range may represent a critical value limiting the motion vector value, and the critical value may be determined by at least one of a minimum value and a maximum value. Meanwhile, the motion vector value range may be a variable range encoded and signaled by an encoder.

On the other hand, at least one of the integer-pixel based search range and the sub-pixel based search range may be limited to a specific distance or more that does not extend outside the boundary of the picture.

On the other hand, the sub-pixel based motion information correction may be allowed only after the motion information correction is performed on the integer pixel basis.

When using double-sided template matching, the motion vector at the decoder side can be improved without sending additional syntax elements. On the other hand, the double-sided template matching may be used for the bi-predictive merge mode or the decoder motion vector derivation mode.

According to one embodiment, the double-sided template matching may be performed when the current block does not correspond to at least one of a uni-directional prediction merging candidate, a local illumination compensation mode, an affine motion compensation mode, and a sub-CU merging mode.

Hereinafter, a motion correction mode related to motion information correction will be described. Here, the motion correction mode may mean a prediction mode for deriving motion information for inter-picture prediction. For example, the motion correction mode may be a merge mode performed based on the motion information correction using the two-sided template matching described above.

Using the motion correction mode, regions with zero or little motion in the picture can be efficiently encoded.

The motion correction mode is a motion information derivation scheme based on the motion information correction, and the motion information correction method described above may be applied to the motion correction mode.

On the other hand, whether the motion correction mode is available or whether the motion correction mode is applicable may be determined based on information signaled through a bitstream. This information may be signaled on a unit-by-unit basis, where a unit may be a video, a sequence, a picture, a slice, a parallel block, a Coding Tree Unit (CTU), a Coding Unit (CU), a Prediction Unit (PU), a Transform Unit (TU), or a block. Whether the motion correction mode is available or not indicates whether the motion correction mode is available for the corresponding unit. Whether the motion correction mode is applicable may indicate whether the motion correction mode is applicable to the corresponding unit.

The motion correction mode may include the steps of: (1) motion information is derived, and (2) modified motion information is generated by performing motion information modification on the derived motion information. Here, the motion information correction method may include the above-described bilateral template matching. The modified motion information resulting from performing the motion correction mode may be used for motion compensation of a current block to be encoded/decoded (also referred to as an encoding/decoding target block).

Meanwhile, the motion information that can be corrected by the motion correction mode may include at least one of a motion vector, a reference picture, an inter-picture indicator, a reference picture index, a prediction list utilization flag, a weighting factor, and an offset.

(1) Derivation of motion information

In the motion correction mode, motion information may be derived from at least one information type of motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most frequently within a reference picture. Here, the derived motion information may be recorded as a motion correction candidate in a motion correction mode list (motion correction mode list). Motion information derived from motion information of spatially neighboring blocks is referred to as a spatial motion correction candidate, and motion information derived from motion information of temporally neighboring blocks is referred to as a temporal motion correction candidate.

Hereinafter, a method of deriving a motion vector as one piece of motion information will be described in detail.

In the motion correction mode, motion vectors may be derived from motion vectors of spatially neighboring blocks, motion vectors of temporally neighboring blocks, predefined motion vectors, and most frequently occurring motion vectors in a reference picture.

A. Spatially adjacent neighboring blocks

In the motion correction mode, a motion vector may be derived from a motion vector of at least one of spatially neighboring blocks. Here, the neighboring blocks that are spatially adjacent may include the neighboring blocks shown in fig. 9.

In the motion correction mode, a motion vector may be derived from a plurality of motion vectors of neighboring blocks that satisfy at least one of the following conditions among spatially neighboring blocks:

blocks with a coded block flag of 0 (i.e., blocks without residual signal),

-a block corresponding to a merge skip mode,

-blocks in neighboring blocks spatially adjacent to the current block for which the motion vector difference value is zero (e.g. MVD ═ 0,0),

-a block corresponding to a merge mode,

-the inter-picture prediction indicator is a block of PRED _ LX (X is a number of integers including zero), and

-the inter-picture prediction indicator is a block of any one of PRED _ BI, PRED _ TRI and PRED _ QUAD.

In the motion correction mode, a motion vector may be derived from a plurality of motion vectors of at least one of the spatial skip/merge candidates.

For example, when a reference picture of the spatial skip/merge candidate is different from a reference picture of the encoding/decoding target block (i.e., when a Picture Order Count (POC) of the reference picture of the spatial skip/merge candidate is different from a POC of the reference picture of the encoding/decoding target block), a motion vector may be derived by scaling a motion vector derived from a plurality of motion vectors of spatially neighboring blocks based on the POC value of the picture.

B. Adjacent blocks in time

In the motion correction mode, a motion vector may be derived from a plurality of motion vectors of at least one of temporally adjacent neighboring blocks. Here, the temporally adjacent neighboring blocks may include a co-located block within a reference picture and a co-located block within a co-located picture.

Here, the co-located block in the reference picture may be at least one of:

a co-located block (hereinafter, referred to as a co-located reference block) corresponding to an upper left position (0,0) of the encoding/decoding target block in the reference picture,

co-located block in reference picture (C3 in fig. 10),

-co-located block in reference picture (C1 in fig. 10), and

co-located block in reference picture (H in fig. 10).

Here, the co-located block in the co-located picture may be at least one of:

-a co-located block in the co-located picture corresponding to the upper left position (0,0) of the encoding/decoding target block,

co-located blocks in the co-located picture (C3 in fig. 10),

-a parity block in the parity picture (C1 in fig. 10), and

the co-located block in the co-located picture (H in fig. 10).

In the motion correction mode, a motion vector may be derived from a plurality of motion vectors of neighboring blocks satisfying at least one of the following conditions among temporally neighboring blocks:

blocks with coded block flag 0 (i.e., blocks without residual signal) arranged in blocks within and outside the parity block,

blocks corresponding to the merge skip mode arranged in blocks within the parity block and outside the parity block,

blocks in which the motion vector difference value is zero (e.g., MVD ═ 0,0) arranged in blocks inside and outside the parity block,

blocks corresponding to the merge mode arranged in blocks within the parity block and outside the parity block,

-a block with an inter-picture prediction indicator PRED LX (X is one of the integers including zero), and

-a block in which the inter-picture prediction indicator arranged in the block inside the co-located block and outside the co-located block is any one of PRED _ BI, PRED _ TRI, and PRED _ QUAD.

In the motion correction mode, a motion vector may be derived from a plurality of motion vectors of at least one of the temporal skip/merge candidates.

For example, when a reference picture of the temporal skip/merge candidate or a co-located picture is different from a reference picture of the encoding/decoding target block (i.e., when Picture Order Counts (POCs) of the temporal skip/merge candidate and the reference picture of the encoding/decoding target block are different from each other), a motion vector may be derived by scaling a motion vector derived from a plurality of motion vectors of temporally adjacent neighboring blocks based on POC values of the pictures.

In addition, a reference picture index indicating a reference picture including temporally adjacent neighboring blocks and a co-located picture may be derived from reference picture indexes of the spatially adjacent neighboring blocks.

C. Predefined motion vector

In the motion correction mode, a zero motion vector having a value of (0,0) may be derived as a motion vector.

D. Motion vector that occurs most frequently in reference pictures

In the motion correction mode, the most frequently occurring motion vectors in the reference picture can be derived.

In this case, the motion vectors are arranged in order of frequency of occurrence of the motion vectors in the reference picture, and the maximum L motion vectors can be derived from the frequency order. Wherein L is a positive integer. In this case, L may be a fixed value preset in the encoder/decoder, or may be a variable value encoded and signaled by the encoder.

On the other hand, in the motion correction mode, a motion vector can be derived in the order of items A, B, C and D. In this case, the derivation of the motion vectors may be repeatedly performed until a total of M motion vectors are derived. Further, the motion vectors may be sequentially derived in the above order. When there is already a newly derived motion vector in the previously derived motion vectors, the derivation of the motion vectors is stopped, and thus a maximum of M motion vectors can be derived and used in the motion correction mode. Here, M is a positive integer, and it may be a fixed value preset in the encoder/decoder or a variable value encoded and signaled by the encoder. Here, when there are a plurality of spatially adjacent neighboring blocks, a bi-directional predicted motion vector may be preferentially derived and inserted into the motion correction mode list, and then a uni-directional predicted motion vector may be derived and inserted into the motion correction mode list.

The motion vector derivation in the above-described motion correction mode may be performed according to the processing described below.

For example, the motion vector may be derived in the order of the motion vector of the spatially adjacent neighboring block, the motion vector of the temporally adjacent neighboring block, and the zero motion vector (0, 0).

As another example, the motion vector may be derived in the order of the motion vector of the temporally adjacent neighboring block, the motion vector of the spatially adjacent neighboring block, and the zero motion vector (0, 0).

Here, the motion vectors of the neighboring blocks that are spatially adjacent may be derived in the order in which the spatial skip/merge candidates are derived, and the motion vectors of the neighboring blocks that are temporally adjacent may be derived in the order in which the temporal skip/merge candidates are derived.

In the motion correction mode, the derived motion vector can be used only when the value of the motion vector derived by the above-described method is not (0, 0).

For example, when bi-prediction is used in the motion correction mode, the derived motion vector may be used only when neither of the values of the derived first motion vector and the second motion vector is (0, 0).

When N-direction prediction (N is an integer of 2 or more) is used in the motion correction mode, the derived motion vector can be used only when none of the values of the derived N motion vectors is (0, 0).

In the N-direction prediction (N is an integer of 2 or more), among the derived motion vectors, only some motion vectors having a value other than (0,0) can be used for the motion vector in the motion correction mode.

In addition, when bi-prediction is used in the motion correction mode, one or both of the derived first motion vector and the derived second motion vector may be used in the motion correction mode when the derived first motion vector and the derived second motion vector are not equal to each other.

On the other hand, when the inter-picture prediction indicator of a spatially neighboring block or a temporally neighboring block indicates at least one of bi-prediction, three-prediction, and four-prediction, the derived motion vector may be used in the motion correction mode. That is, when the inter-picture prediction indicators of the spatially neighboring blocks or the temporally neighboring blocks do not indicate the uni-directional prediction, the derived motion vector may be used in the motion correction mode.

When the inter-picture prediction indicator of a spatially adjacent neighboring block or a temporally adjacent neighboring block indicates unidirectional prediction, the inter-picture prediction indicator is changed to indicate bidirectional prediction, and the sign of the motion vector of the unidirectional prediction is inversely changed. Therefore, a motion vector for unidirectional prediction having a direction opposite to that of the previous (original) unidirectional prediction is derived and used as a motion vector in the motion correction mode.

For example, when the inter-picture prediction indicator of a spatially neighboring block or a temporally neighboring block indicates L0 uni-directional prediction and the motion vector of the spatially neighboring block or the temporally neighboring block is (-4,6), the inter-picture prediction indicator is changed to indicate bi-directional prediction and a motion vector (4, -6) is derived for L1 directional prediction. Therefore, two motion vectors (-4,6) and (4, -6) can be used as the motion vector in the motion correction mode. In this case, a reference picture located at a first distance from the current picture, which is the same as or proportional to a second distance that is a distance between the current picture and the reference picture for L0 unidirectional prediction, may be determined as the reference picture for L1 unidirectional prediction.

In a motion correction mode using N-direction prediction (N is an integer of 2 or more), when the number of derived motion vectors is not N, one or more motion vectors may be further derived from one or more previously derived motion vectors to obtain a total of N motion vectors. In particular, the motion vector(s) may be generated by scaling previously derived motion vector(s) generated based on picture order counts of the current picture and/or the reference picture.

For example, when bi-prediction is used in motion correction mode and there is only a first motion vector previously derived, the first motion vector is scaled based on the reference pictures in reference picture list 1 to generate a second motion vector. Therefore, the previously derived first motion vector and the newly generated second motion vector can be used as the motion vector in the motion correction mode.

Alternatively, when bi-prediction is used in the motion correction mode and there is only a previously derived second motion vector, the second motion vector is scaled based on the reference pictures in the reference picture list 0 to generate the first motion vector. Therefore, the previously derived second motion vector and the newly generated first motion vector may be used as the motion vector in the motion correction mode.

Hereinafter, a method of deriving a reference picture that is also one piece of motion information will be described in detail.

In the motion correction mode, the reference picture may be derived using at least one of the following methods.

For example, a reference picture having a reference picture index of 0 can be derived from a reference picture included in the reference picture list 0 and a reference picture included in the reference picture list 1 as a reference picture to be used in the motion correction mode. Among the reference pictures included in the reference picture list 0 and the reference picture list 1, there may be a case where the reference pictures having reference picture indexes 0 respectively in the reference picture list 0 and the reference picture list 1 may be identical to each other. In this case, among the reference pictures included in the reference picture list 1, a reference picture different from the reference picture included in the reference picture list 0 and having a reference picture index of 0 may be derived as a reference picture to be used in the motion correction mode. Among the reference pictures included in the reference picture list 0 and the reference picture list 1, there may be a case where the reference pictures having reference picture indexes 0 respectively in the reference picture list 0 and the reference picture list 1 are identical to each other. In this case, among the reference pictures included in the reference picture list 0, a reference picture different from the reference picture included in the reference picture list 1 and having a reference picture index of 0 may be derived as a reference picture to be used in the motion correction mode.

In order to derive a reference picture to be used in the motion correction mode as described above, a reference picture index of 0 may be used. However, the present invention is not limited thereto, and a reference picture index having a non-zero value may be used to derive a reference picture to be used in the motion correction mode.

A method of deriving a reference picture to be used in the motion correction mode by using a non-zero reference picture index will be described below.

A median value of reference picture indexes for at least one of positions a1, B1, B0, a0, and B2 spatially adjacent to the encoding/decoding target block, respectively, may be used as a reference picture index to be used. Here, instead of the median, various statistical values such as a minimum value, a maximum value, an average value, a weighted average value, and a mode may be used. The reference picture indicated by the determined reference picture index may be derived as a reference picture to be used in the motion correction mode. At this time, the reference picture index may be determined for each reference picture list using the above-described method.

When a block exists only at position a1 and the block has an inter-picture prediction mode, a reference picture for the block can be determined only by the reference picture index of position a 1.

When a block exists only at position B1 and the block has an inter-picture prediction mode, a reference picture for the block can be determined only by the reference picture index of position B1.

When a block exists only at position B0 and the block has an inter-picture prediction mode, a reference picture for the block can be determined only by the reference picture index of position B0.

When a block exists only at position a0 and the block has an inter-picture prediction mode, a reference picture for the block can be determined only by the reference picture index of position a 0.

When a block exists only at position B2 and the block has an inter-picture prediction mode, a reference picture for the block can be determined only by the reference picture index of position B2.

A modified reference picture may be generated by applying a motion information modification method to a reference picture derived by using the above-described method, and the modified reference picture may be used as a reference picture for a motion modification mode.

In the above embodiment, it is assumed that two reference picture lists will be used. However, the number of reference picture lists is not limited thereto. There may be N reference picture lists. In this case, N may be an integer of 2 or more. When there are N reference picture lists, the derivation of the reference pictures may be performed in a similar manner to the method described above (i.e., based on the determination of reference picture conformance in the N reference picture lists). That is, N reference pictures different from each other can be derived.

In another embodiment, among reference pictures included in a reference picture list i (i ═ 0, … …, or N, where N is an integer of 0 or more), a reference picture having the smallest Picture Order Count (POC) difference from an encoding/decoding target picture may be derived as a reference picture of a motion correction mode.

Alternatively, among reference pictures included in a reference picture list i (i ═ 0, … …, or N, where N is an integer of 1 or more), a reference picture having the smallest Picture Order Count (POC) difference from an encoding/decoding target picture and/or having the smallest temporal layer identifier value may be derived as a reference picture of the motion correction mode.

Further alternatively, reference pictures of spatially neighboring blocks may be derived as reference pictures for the motion correction mode.

Further alternatively, reference pictures of temporally adjacent neighboring blocks may be derived as reference pictures for the motion correction mode.

Further alternatively, one or more reference pictures selected from the skip/merge candidates may be derived as reference pictures of the motion correction mode.

Further alternatively, motion information correction processing is performed on all or part of the reference pictures included in the reference picture list, and then the reference picture exhibiting the minimum distortion value after the correction processing is derived as a reference picture of a motion correction mode.

Hereinafter, a method of deriving an inter-picture prediction indicator as one piece of motion information will be described in detail.

In the motion correction mode, the inter-picture prediction indicator may be derived using at least one of the following methods.

For example, in the motion correction mode, the inter-picture prediction indicator may be fixed to one of unidirectional prediction, bidirectional prediction, three-way prediction, four-way prediction, and N-way prediction.

As another example, the inter-picture prediction indicator of the spatially neighboring blocks may be derived as an inter-picture prediction indicator to be used in the motion correction mode.

As another example, the inter-picture prediction indicator of a temporally adjacent neighboring block may be derived as an inter-picture prediction indicator to be used in the motion correction mode.

As another example, one or more inter-picture prediction indicators among the skip/merge candidates may be derived as the inter-picture prediction indicator to be used in the motion correction mode.

As yet another example, an inter-picture prediction indicator may be derived from the number of available reference pictures in the reference picture derived by the above-described method as an inter-picture prediction indicator to be used in the motion compensation mode. In particular, when there is only one available reference picture, the inter-picture prediction indicator can be derived by using unidirectional prediction. In particular, when there are two available reference pictures, the inter-picture prediction indicator can be derived by using bi-prediction.

The modified inter-picture prediction indicator is generated by applying a motion information modification method to the previously derived inter-picture prediction indicator, and may be used as the inter-picture prediction indicator in the motion modification mode of the current block.

(2) Correction of motion information

The encoder/decoder generates a modified reference picture by performing motion information modification on a reference picture derived by using the above-described method, and uses the modified motion information as motion information in a motion modification mode. Specifically, the motion compensation may be performed by generating the prediction block using at least one of the modified motion vector, the modified reference picture, and the modified inter-picture prediction indicator. Similarly, the encoder/decoder generates at least one of a modified reference picture index, a modified prediction list utilization flag, a modified weighting factor, and a modified offset by applying a motion information modification method to at least one of a previously derived reference picture index, a previously derived prediction list utilization flag, a previously derived weighting factor, and a previously derived offset, and creates the prediction block by using at least one of the modified reference picture index, the modified prediction list utilization flag, the modified weighting factor, and the modified offset. Here, the motion information correction method may include the above-described double-sided template matching. In this case, a final prediction block is obtained by calculating a weighted sum of prediction blocks based on picture order counts between an encoding/decoding target picture and each reference picture, and thus motion compensation may be performed.

On the other hand, when the motion information correction process is applied to a previously derived motion vector, the previously derived motion vector may be used to determine the initial motion search position. A modified motion vector may be determined based on the initial motion search location.

The encoder/decoder may perform motion information correction on up to M pieces of the derived motion information. In this case, M may be a fixed value preset in the encoder/decoder, or may be a variable value encoded and signaled by the encoder. For example, at least one piece of motion information among the first piece of motion information, the second piece of motion information, … …, and the nth piece of motion information may be corrected. In this case, M is an integer equal to or greater than 4.

Further, the previously derived motion information may be used as the motion information of the motion correction mode without applying motion information correction to all or part of the previously derived motion information. In particular, the prediction block may be generated by using at least one of the derived motion vector, the derived reference picture, and the derived inter-picture prediction indicator to perform motion compensation.

Meanwhile, motion information correction (e.g., double-sided template matching) may be selectively used in the motion correction mode.

According to one embodiment, the motion information correction is performed when the current block is not associated with at least one of a uni-directional prediction merging candidate, a local illumination compensation mode, an affine motion compensation mode, and a sub-CU merging mode.

Motion information modification may be performed when only one of a first difference value and a second difference value is a negative integer value, wherein the first difference value is a POC difference (POC) between a first reference picture corresponding to a first prediction direction (e.g., L0 prediction direction) and an encoding/decoding target pictureref0-POCcurr) And the second difference value is a difference value corresponding to a second prediction direction (e.g.,l1 prediction direction) and a POC difference (POC) between the second reference picture of the L1 prediction direction) and the encoding/decoding target pictureref1-POCcurr)。

Further, when the first prediction direction and the second prediction direction are different from each other, motion information correction may be performed.

The encoder/decoder may perform double-sided template matching on at least one piece of derived motion information obtained through the above-described method, generate a prediction block using one piece of motion information having the minimum distortion, and perform motion compensation. At this time, the at least one piece of motion information may include at least one of L0 motion information and L1 motion information.

The encoder/decoder may perform double-sided template matching on one or more candidates existing in the skip candidate list or the merge candidate list, generate a prediction block using one candidate having the smallest distortion, and perform motion compensation.

The encoder/decoder may perform double-sided template matching on at least one piece of derived motion information obtained by the above-described method, generate M prediction blocks by using M pieces of motion information each having the minimum distortion, calculate a weighted sum of the M prediction blocks, and use the weighted sum as a final prediction block of the encoding/decoding target block. Here, M may be a positive integer, and may be equal to or greater than 2.

The encoder/decoder may perform double-sided template matching on one or more candidates included in the skip candidate list or the merge candidate list, generate M prediction blocks using the M candidates each having the minimum distortion, calculate a weighted sum of the M prediction blocks, and use the weighted sum as a final prediction block of the encoding/decoding target block. Here, M may be a positive integer, and may be equal to or greater than 2.

The encoder/decoder may perform entropy encoding/decoding on a skip index or a merge index for a unidirectional prediction candidate existing in a skip candidate list or a merge candidate list, and may generate a prediction block by using at least one candidate having a minimum distortion among the M or more bidirectional prediction candidates, thereby performing motion compensation. In this case, one flag or one index is entropy-encoded/entropy-decoded to indicate M or more bidirectional prediction candidates. That is, a skip index or a merge index is allocated to each unidirectional prediction candidate, and one skip index or one merge index is commonly allocated to M or more bidirectional prediction candidates. For M or more bidirectional prediction candidates, since at least one candidate representing the smallest distortion may be determined by using the two-sided template matching, a skip index or a merge index may not be assigned to each bidirectional prediction candidate.

Whether to use the motion correction mode may be determined according to the motion correction mode utilization information. Here, the motion correction mode utilization information may be entropy-encoded/entropy-decoded using at least one of the flag information and the index information.

Encoding/decoding of the motion correction mode utilization information may be performed based on the value of the skip flag. The encoding/decoding timing of the motion correction mode utilization information may be determined based on the encoding/decoding timing of the skip flag. For example, when the skip flag is 1 (i.e., when the skip mode is used), the motion correction mode utilization information may be entropy-encoded/entropy-decoded. In this case, the motion correction mode utilization information may be entropy-encoded/entropy-decoded after entropy-encoding/entropy-decoding the skip flag.

Instead, encoding/decoding of the skip flag may be performed using the value of the information based on the motion correction mode. For example, when the motion correction mode utilization information is 1 (i.e., when the motion correction mode is used), the skip flag may be entropy-decoded/entropy-decoded. In this case, the motion correction mode utilization information may be entropy-encoded/entropy-decoded before entropy-encoding/entropy-decoding the skip flag.

Encoding/decoding of the motion correction mode utilization information may be performed based on the value of the merge flag. The encoding/decoding timing of the motion correction mode utilization information may be determined based on the encoding/decoding timing of the merge flag. For example, when the merge flag is 1 (i.e., when the merge mode is used), the motion correction mode utilization information may be entropy-encoded/entropy-decoded. In this case, the motion correction mode utilization information may be entropy-encoded/entropy-decoded after the merging flag is entropy-encoded/entropy-decoded.

Instead, encoding/decoding of the merge flag may be performed using the value of the information based on the motion correction mode. For example, when the motion correction mode utilization information is 1 (i.e., when the motion correction mode is used), the merging flag may be entropy-encoded/entropy-decoded. In this case, the motion correction mode utilization information may be entropy-encoded/entropy-decoded before entropy-encoding/entropy-decoding the merge flag.

Encoding/decoding of the motion correction mode utilization information may be performed based on a specific motion compensation mode. For example, when the affine motion compensation mode is not used, the motion correction mode utilization information may be entropy-encoded/entropy-decoded.

The decoder motion vector derivation mode flag may be encoded/decoded based on the motion correction mode using the value of the information. That is, when the motion correction mode utilization information is 0 (i.e., when the motion correction mode is not used), the decoder-side motion vector derivation mode flag may be entropy-encoded/entropy-decoded.

Further, the motion correction mode utilization information may be encoded/decoded based on motion correction mode utilization information of one or more neighboring blocks of the encoding/decoding target block. For example, the one or more neighboring blocks of the encoding/decoding target block may include one or more spatially neighboring blocks and/or temporally neighboring blocks. The one or more spatially adjacent blocks may include a block located at the left side of the encoding/decoding target block and/or a block located above the encoding/decoding target block.

Further, when the motion correction mode utilization information is not signaled, the motion correction mode utilization information may be derived based on motion correction mode utilization information of one or more neighboring blocks of the encoding/decoding target block. The one or more neighboring blocks of the encoding/decoding target block may include one or more spatially neighboring blocks and/or temporally neighboring blocks. The one or more spatially adjacent blocks may include a block located at the left side of the encoding/decoding target block and/or a block located above the encoding/decoding target block.

When at least one of the blocks spatially adjacent to the encoding/decoding target block uses the skip mode, the motion correction mode utilization information may be entropy-encoded/entropy-decoded.

When at least one of the blocks spatially adjacent to the encoding/decoding target block uses the merge mode, the motion correction mode utilization information may be entropy-encoded/entropy-decoded.

When at least one of the blocks spatially adjacent to the encoding/decoding target block uses the inter-picture mode, the motion correction mode utilization information may be entropy-encoded/entropy-decoded.

The motion correction mode utilization information may be entropy encoded/entropy decoded using a bypass mode.

When the motion correction mode and the skip mode are used together, the residual signal may not be entropy-encoded/entropy-decoded.

When the motion correction mode and the merge mode are used together, the residual signal may be entropy-encoded/entropy-decoded.

In the motion correction mode, only a portion of the residual signal may be entropy encoded/entropy decoded for use. In this case, the portion of the residual signal may be a DC quantization level (DC transform coefficient).

When the motion correction mode is used, information other than the motion correction mode utilization information may not be entropy-encoded/entropy-decoded. Here, the information other than the motion correction mode utilization information may be at least one piece of information on motion compensation.

In the above, the motion correction mode related to the motion information correction has been described. Hereinafter, the motion correction candidate derived under the motion correction mode will be described.

The motion correction candidate may be motion information including at least one of the following information: a derived motion vector derived by the motion correction mode, a derived reference picture and a derived inter-picture prediction indicator. The encoder/decoder may add the motion correction candidate as a skip candidate to a skip candidate list or add the motion correction candidate as a merge candidate to a merge candidate list in either skip mode or merge mode.

An embodiment of adding motion correction candidates to the skip/merge candidate list will be described below.

When there is a skip/merge candidate identical to the motion correction candidate in the skip/merge candidate list, the motion correction candidate may not be added to the skip/merge candidate list. When the same motion correction candidate as the skip/merge candidate exists in the skip/merge candidate list, the skip/merge candidate may not be added to the skip/merge candidate list.

The motion correction candidate may be derived earlier than the spatial skip/merge candidate and may be added to the skip/merge candidate list.

The motion correction candidate may be derived earlier than the spatial skip/merge candidate derived from the particular location and may then be added to the skip/merge candidate list. Here, the specific position may be at least one of positions a1, B1, B0, a0, and B2 in fig. 10.

Further, the motion correction candidate may be derived earlier than at least one of the temporal skip/merge candidate, the combined merge candidate, and the merge candidate having the predetermined motion information value, and the motion correction candidate may be added to the skip/merge candidate list.

The encoder/decoder may determine motion information including at least one of a modified motion vector obtained by motion information modification of the motion modification mode, a modified reference picture, and a modified inter-picture prediction indicator as a motion modification candidate. The encoder/decoder may add the motion correction candidate as a skip candidate to the skip candidate list in the skip mode or add the motion correction candidate as a merge candidate to the merge candidate list in the merge mode.

A motion correction mode may be used instead of the skip mode. That is, a picture may be encoded/decoded by using a motion correction mode instead of a skip mode. A motion correction mode may be used instead of the merge mode. That is, a picture can be encoded/decoded by using a motion correction mode instead of a merge mode.

At least one of an overlapped block motion compensation mode, a local illumination compensation mode, and a bi-directional optical flow mode may be applied to the final prediction block generated using the motion correction mode.

Further, in the motion correction mode, the motion information correction method may be applied to only one piece of motion information or a part of the motion information without generating a list of motion information candidates.

Hereinafter, a condition for performing motion information correction in the motion correction mode (MRM) will be described.

Whether to perform motion information modification may be determined based on Picture Order Count (POC) of a reference picture of the motion vector.

For example, the motion information correction method may be performed when there are two motion vectors: a first motion vector indicating a reference picture whose picture order count is smaller than that of the encoding/decoding target picture; and a second motion vector indicating a reference picture whose picture order count is greater than that of the encoding/decoding target picture.

Alternatively, when there are two motion vectors indicating a reference picture whose picture order count is smaller than that of the encoding/decoding target picture, the motion information correction method may be performed.

Further alternatively, when there are two motion vectors indicating a reference picture whose picture order count is larger than that of the encoding/decoding target picture, the motion information correction method may be performed.

When at least one of the affine motion compensation mode, the decoder motion vector derivation mode, and the local illumination compensation mode is not used, motion information correction may be performed on the encoding/decoding target block.

The motion information correction may be performed when a difference between the picture order count of the encoding/decoding target picture and the picture order count of the first reference picture or a difference between the picture order count of the encoding/decoding target picture and the picture order count of the second reference picture is less than N (N is an integer greater than or equal to 0). In this case, the first reference picture may refer to a reference picture indicated by the first motion vector, and the second reference picture may refer to a reference picture indicated by the second motion vector.

The motion information correction may be performed based on the first motion vector and the second motion vector that are targets of the motion information correction.

For example, when the first motion vector is the same as the second motion vector and when the reference picture indicated by the first motion vector is the same as the reference picture indicated by the second motion vector, motion information correction may not be performed. That is, motion information correction may be performed only when the first motion information and the second motion information are different from each other and/or when the reference pictures indicated by the first motion information and the second motion information are different from each other. Further, when the first motion vector is the same as the second motion vector, motion information correction may not be performed. That is, the motion information correction may be performed only when the first motion vector and the second motion vector are different from each other.

Alternatively, the motion information correction may be performed only when the reference picture indicated by the first motion vector is the same as the reference picture indicated by the second motion vector. In contrast, motion information correction may be performed only when the reference picture indicated by the first motion vector is different from the reference picture indicated by the second motion vector.

As another example, motion information correction may be performed on a motion vector whose motion vector value is not (0, 0). Here, when the inter prediction indicator indicates bi-direction and when both values of the first motion vector and the second motion vector are not (0,0), motion information correction may be performed. Further, when the inter-picture prediction indicator indicates an N direction (N is an integer equal to or greater than 2) and when the values of all or a predetermined number of N motion vectors are not (0,0), motion information correction may not be performed.

Motion information correction may be performed only when the inter-picture prediction indicator indicates a certain number of directions. For example, motion information correction may be performed only when the inter-picture prediction indicator of the skip/merge candidate indicates bi-direction.

The motion information correction may be performed only when the reference picture index of the reference picture indicated by the first motion vector is 0 and the reference picture index of the reference picture indicated by the second motion vector is 0. Alternatively, the motion information correction is performed only when the reference picture index of the reference picture indicated by each motion vector has a specific value.

The motion information modification may be performed only on at least one of a spatial skip/merge candidate, a temporal skip/merge candidate, a combined skip/merge candidate, and a skip/merge candidate having a predetermined motion information value.

The encoding/decoding target block may be divided into sub-blocks, and motion information modification may be performed on a per sub-block basis.

On the other hand, when the encoding/decoding target block has motion information or a motion vector for each sub-block, motion information modification may be performed on a per sub-block basis to improve encoding efficiency. There may be a case where all sub-blocks of the encoding/decoding target block have different motion information or motion vectors or the same motion information or motion vector. Therefore, motion information correction may be performed only when all sub-blocks of the encoding/decoding target block have different motion information or motion vectors or have the same motion information or motion vectors.

When the encoding/decoding target block has motion information or a motion vector on a per sub-block basis, motion information modification may not be performed on the per sub-block basis in order to reduce computational complexity. The motion information modification may be performed only when all sub-blocks of the encoding/decoding target block have the same motion information or motion vector to reduce computational complexity.

The motion information correction may be performed on a per sample basis or on a per block basis.

In the case where the encoding/decoding target block is to be encoded using N-directional prediction (such as three-directional prediction and four-directional prediction), motion information correction may be performed by calculating a template using N motion vectors (such as three motion vectors and four motion vectors). In this case, M is an integer equal to or greater than 3.

When the double-sided template matching is used as the motion information correction method, new motion information may be generated by scaling previously derived motion information.

For example, when there is only one piece of motion information (i.e., first motion information) or only a first motion vector in a spatially adjacent neighboring block or a temporally adjacent neighboring block, scaling is performed based on the first motion information or the first motion vector to generate second motion information or a second motion vector, and then motion information correction may be performed.

Similarly, when there is only one piece of motion information (i.e., second motion information) or only a second motion vector in a spatially adjacent neighboring block or a temporally adjacent neighboring block, scaling is performed based on the second motion information or the second motion vector to generate first motion information or a first motion vector, and then motion information correction may be performed.

As another example, when the reference picture indicated by the initial motion vector is different from the reference picture indicated by the revised motion vector candidate, the initial motion vector is scaled based on the Picture Order Count (POC) values of the respective reference pictures to obtain the revised motion vector candidate. Here, the modified motion vector candidate means a motion vector indicating a region where a search is performed to find a modified motion vector. To obtain a modified motion vector, a two-sided template matching may be performed by comparing a distortion value for a position indicated by the modified motion vector with a distortion value for a position indicated by the initial motion vector.

On the other hand, a modified motion vector may be calculated by applying motion information modification to one motion vector of the luminance component and at least one of two motion vectors of the chrominance component.

On the other hand, motion information correction is performed on all or part of the reference pictures included in the reference picture list, and then the reference picture exhibiting the minimum distortion value after the correction process may be derived as a corrected reference picture.

The same condition for performing motion information correction can be applied to motion information correction for the decoder-side motion vector derivation mode.

Fig. 16 is a flowchart illustrating an image decoding method according to still another embodiment of the present invention.

Referring to fig. 16, the decoder may derive a motion correction candidate from at least one of motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information that occurs most frequently in a reference picture (S1601).

In this case, the motion correction candidates may be derived in a predetermined order: motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, predefined motion information, and motion information occurring with the highest probability within a reference picture. The predetermined order may represent an order of motion information of spatially neighboring blocks, motion information of temporally neighboring blocks, and predefined motion information. Here, the predefined motion information may include a zero vector.

The temporally adjacent neighboring blocks may be included in a reference picture selected based on reference picture indexes of the spatially adjacent neighboring blocks.

Next, motion information correction may be performed on the previously derived motion correction candidate (S1602).

In this case, the motion information correction may be performed by applying the double-sided template matching to the motion vector existing in the derived motion correction candidate.

Here, the double-sided template matching may include the steps of: generating a bilateral template by using a motion vector selected from the derived motion correction candidates as an initial motion vector; and the initial motion vector is modified by comparing the values of the samples in the bilateral template with the values of the reconstructed reference samples in the reference picture indicated by the initial motion vector.

Here, the step of correcting the initial motion vector may be recursively performed.

The initial motion vector may be a bi-directional predicted motion vector that is a non-zero motion vector and is selected from the derived motion correction candidates. Here, when there is no bidirectional predictive motion vector as a non-zero vector in the derived motion correction candidates, the initial motion vector may be set to a zero vector.

On the other hand, the step of correcting the initial motion vector includes the steps of: searching for a motion vector indicating a minimum distortion region in the reference picture compared to a corresponding region in the bilateral template; and sets the found motion vector as a correction value of the initial motion vector.

Here, the step of searching for the motion vector may be performed within a limited search range in the reference picture.

In this case, the limited search range may be set as a predetermined area demarcated on an integer pixel basis, and the step of searching for the motion vector may be performed on a sub-pixel basis within the predetermined search range demarcated on an integer pixel basis.

In one aspect, double-sided template matching may be performed based on integer pixels and sub-pixels. In this case, the step of searching for the motion vector may be performed to search for the motion vector on a sub-pixel basis within a predetermined search range delimited on an integer pixel basis.

Meanwhile, when the block does not correspond to any one of the unidirectional prediction merge candidate, the local illumination compensation mode, and the affine motion compensation mode, the step of performing motion information correction on the derived motion correction candidate may be performed.

Next, a prediction block of the encoding/decoding target block (i.e., the current block) is generated by using the motion correction candidate corrected by the motion information (S1603).

The image decoding method may further include the steps of: decoding the motion correction mode utilization information performed before step S1601; and determining a motion correction mode based on the decoded motion correction mode utilization information. Step S1601 may be performed only when the current block is determined as corresponding to the motion correction mode as a result of the determining step.

Here, whether to perform the step of decoding the motion correction mode utilization information may be determined based on the skip flag or the merge flag.

In case there are a plurality of spatially adjacent neighboring blocks, the step of deriving the motion correction candidates may be performed such that motion information is firstly derived from the spatially adjacent neighboring blocks having bi-directionally predicted motion vectors and secondly derived from the spatially adjacent neighboring blocks having uni-directionally predicted motion vectors.

The image decoding method according to the present invention has been described above. Each step of the above-described image decoding method may be performed in the same manner as the image encoding method.

The above embodiments can be performed in the same way in both the encoder and the decoder.

The order in which the above embodiments are applied may be different between the encoder and the decoder, or the order in which the above embodiments are applied may be the same in the encoder and the decoder.

The above embodiment 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.

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

The above embodiments of the present invention may be applied according to the size of at least one of an encoding block, a prediction block, a transform block, a current block, an encoding 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 of the minimum size and the maximum size such that the above embodiment is applied, or may be defined as a fixed size to which the above embodiment is applied. Further, in the above embodiments, the first embodiment may be applied to the first size, and the second embodiment may be applied to the second size. In other words, the above embodiments may be applied in combination according to the size. Further, 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, when the block size is included in a specific range, the above embodiment may be applied.

For example, when the size of the current block is 8 × 8 or more, the above embodiment may be applied. For example, when the size of the current block is 4 × 4 or more, the above embodiment may be applied. For example, when the size of the current block is 16 × 16 or more, the above embodiment may be applied. For example, the above embodiment may be applied when the size of the current block is equal to or greater than 16 × 16 and equal to or less than 64 × 64.

The above embodiments of the present invention may be applied according to temporal layers. To identify temporal layers to which the above embodiments may be applied, the above embodiments may be applied to a specified temporal layer identified by a respective identifier. 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 embodiment can be applied, or may be defined to indicate a specific layer to which the embodiment is applied. Further, a fixed temporal layer to which the embodiments are applied may be defined.

For example, when the temporal layer of the current image is the lowest layer, the above embodiment can be applied. For example, when the temporal layer identifier of the current picture is 1, the above embodiment can be applied. For example, when the temporal layer of the current image is the highest layer, the above embodiment can be applied.

The band type to which the above embodiments of the present invention are applied may be defined, and the above embodiments may be applied according to the corresponding band type.

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

In the above-described embodiments, the method is described based on the flowchart having a series of steps or units, but the present invention is not limited to the order of the steps, and some steps may be performed simultaneously with other steps or in a different order. Further, those of ordinary skill in the art will appreciate that the steps in the flowcharts are not mutually exclusive, and that other steps may be added to the flowcharts or some of the steps may be deleted from the flowcharts without affecting the scope of the present invention.

60页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:使用多核变换的视频解码方法和设备以及使用多核变换的视频编码方法和设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类