Method for decoding and encoding an image and device for transmitting a bit stream

By using multiple merge candidate lists and motion vector refinement technology in video signal encoding and decoding, the problem of low coding efficiency of high-resolution video signals is solved, achieving more efficient inter-frame prediction and cost reduction.

CN112204966BActive Publication Date: 2024-10-18KT CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201980035246.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-03-27
Publication Date
2024-10-18
Estimated Expiration
2039-03-27

AI Technical Summary

Technical Problem

When the existing technology processes high-resolution and high-quality video signals, the encoding and decoding efficiency is low, resulting in increased transmission and storage costs, and it is difficult to effectively process stereoscopic image content.

Method used

Motion compensation is performed by using multiple merge candidate lists during video signal encoding and decoding, and motion vectors obtained from merge candidates are refined to improve the efficiency of inter-frame prediction.

Benefits of technology

It improves the inter-frame prediction efficiency of video signals, reduces transmission and storage costs, and is suitable for encoding and decoding of high-resolution and stereoscopic image content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112204966B_ABST
    Figure CN112204966B_ABST
Patent Text Reader

Abstract

The image decoding method according to the present invention may include the following steps: obtaining an initial motion vector of a current block; determining a motion refinement vector of the current block; and determining a motion vector of the current block based on the initial motion vector and the motion refinement vector. The initial motion vector may be obtained according to one of the merge candidates included in the merge candidate list of the current block.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and an apparatus for processing a video signal. Background Art

[0002] Recently, the demand for high-resolution and high-quality images (e.g., high-definition (HD) images and ultra-high-definition (UHD) images) has increased in various application fields. However, compared with conventional image data, higher resolution and quality image data has an increased data amount. Therefore, when the image data is transmitted by using a medium (e.g., conventional wired and wireless broadband networks), or when the image data is stored by using a conventional storage medium, the transmission cost and the storage cost increase. In order to solve these problems arising as the resolution and quality of image data increase, efficient image encoding / decoding technology can be used.

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

[0004] Meanwhile, along with the demand for high-resolution images, the demand for stereoscopic image content as a new image service is also increasing. Discussion is being made on video compression technology for efficiently providing stereoscopic image content with high resolution and ultra-high resolution. Summary of the invention

[0005] Technical issues

[0006] An object of the present invention is to provide a method and apparatus for efficiently performing inter-frame prediction on an encoding / decoding target block when encoding / decoding a video signal.

[0007] Another object of the present invention is to provide a method and apparatus for performing motion compensation by using a plurality of merge candidate lists when encoding / decoding a video signal.

[0008] Another object of the present invention is to provide a method and apparatus for refining a motion vector obtained from a merge candidate when encoding / decoding a video signal.

[0009] Technical problems that can be obtained from the present invention are not limited to the above-mentioned technical tasks, and a person of ordinary skill in the technical field to which the present invention belongs can clearly understand other unmentioned technical tasks according to the following description.

[0010] Technical Solution

[0011] According to the present invention, a method and apparatus for decoding a video signal are provided, wherein an initial motion vector of a current block is obtained, a motion refinement vector of the current block is determined, and a motion vector of the current block is determined based on the initial motion vector and the motion refinement vector. In this article, the initial motion vector is obtained from any one of the merge candidates included in the merge candidate list of the current block.

[0012] According to the present invention, a method and apparatus for encoding a video signal are provided, wherein an initial motion vector of a current block is obtained, a motion refinement vector of the current block is determined, and a motion vector of the current block is determined based on the initial motion vector and the motion refinement vector. In this article, the initial motion vector is obtained from any one of the merge candidates included in the merge candidate list of the current block.

[0013] In the method and apparatus for encoding / decoding a video signal according to the present invention, information for determining a motion refinement vector may be encoded / decoded.

[0014] In the method and apparatus for encoding / decoding a video signal according to the present invention, the information may include size information of the motion refinement vector and direction information of the motion refinement vector.

[0015] In the method and apparatus for encoding / decoding a video signal according to the present invention, the size information may indicate any one of a plurality of candidates, and the plurality of candidates may be determined based on a resolution of a motion vector of a current block.

[0016] In the method and apparatus for encoding / decoding a video signal according to the present invention, the merged refinement vector may be determined based on a result of searching for an area having a lowest rate-distortion cost value in a search area including a position indicated by an initial motion vector.

[0017] In the method and apparatus for encoding / decoding a video signal according to the present invention, a vector from an initial motion vector to a position of a region having a lowest rate-distortion cost value may be determined as a merged refinement vector.

[0018] In the method and apparatus for encoding / decoding a video signal according to the present invention, the motion vector may be a sum of an initial motion vector and a motion refinement vector.

[0019] Effects that can be obtained from the present invention may not be limited to the above-mentioned effects, and other unmentioned effects may be clearly understood by a person of ordinary skill in the technical field to which the present invention pertains from the following description.

[0020] Beneficial effects

[0021] According to the present invention, the efficiency of inter prediction can be improved by performing motion compensation by using a plurality of merge candidate lists.

[0022] According to the present invention, the efficiency of inter-frame prediction can be improved by obtaining motion information based on a plurality of merge candidates.

[0023] According to the present invention, the efficiency of inter-frame prediction can be improved by refining a motion vector obtained from a merge candidate.

[0024] Effects that can be obtained from the present invention may not be limited to the above-mentioned effects, and other unmentioned effects may be clearly understood by a person of ordinary skill in the technical field to which the present invention pertains from the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 is a block diagram showing an apparatus for encoding a video according to an embodiment of the present invention.

[0026] Figure 2 is a block diagram showing an apparatus for decoding a video according to an embodiment of the present invention.

[0027] Figure 3 2 is a diagram showing an example of hierarchical division of coding blocks based on a tree structure as an embodiment to which the present invention is applied.

[0028] Figure 4 : is a diagram showing the partition types allowed based on binary tree partitioning as an embodiment to which the present invention is applied.

[0029] Figure 5 is a diagram showing an example of binary tree-based partitioning that allows only specific shapes.

[0030] Figure 6 is a diagram for describing an example in which information related to the number of times binary tree division is allowed is encoded / decoded according to an embodiment to which the present invention is applied.

[0031] Figure 7 FIG. 5 is a diagram showing a division pattern that can be applied to a coding block as an embodiment to which the present invention is applied.

[0032] Figure 8 : is a flowchart showing an inter-frame prediction method as an embodiment to which the present invention is applied.

[0033] Fig. 9 is a diagram illustrating a process of deriving motion information of a current block when a merge mode is applied to the current block.

[0034] Fig.10 is a diagram showing an example of spatially neighboring blocks.

[0035] Fig.11 is a diagram showing an example of deriving a motion vector of a temporal merging candidate.

[0036] Fig.12 is a diagram showing the positions of candidate blocks that may serve as co-located blocks.

[0037] Fig.13 is a diagram illustrating a process of obtaining motion information of a current block when the AMVP mode is applied to the current block.

[0038] Fig.14 is a diagram showing an example of deriving a merge candidate from a second merge candidate block when a first merge candidate block is unavailable.

[0039] Figures 15 to 18 is a diagram showing the order of searching for merge candidate blocks.

[0040] Fig.19 is a diagram showing an example of obtaining merging candidates of non-square blocks based on square blocks.

[0041] Fig. 20 is a flow chart showing a method of refining a motion vector of a current block.

[0042] Fig.21 is a diagram showing an example of setting a motion refinement vector within a predetermined range.

[0043] Embodiments of the present invention

[0044] Various modifications can 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, and the exemplary embodiments may be interpreted as including all modifications, equivalents or alternatives within the technical concept and technical scope of the present invention. In the accompanying drawings described, similar reference numerals represent similar elements.

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

[0046] In the present disclosure, when an element is referred to as being "connected" or "coupled" to another element, it should be understood that it includes not only that the element is directly connected or coupled to the other element, but also that another element may exist between them. When an element is referred to as being "directly connected" or "directly coupled" to another element, it should be understood that there are no other elements between them.

[0047] The terms used in this specification are only used to describe specific embodiments and are not intended to limit the present invention. Expressions used in the singular include expressions in the plural form unless the expression has a significantly different meaning in the context. In this specification, it should be understood that terms such as "including", "having" etc. are intended to indicate the existence of features, numbers, steps, actions, elements, parts or combinations thereof disclosed in this specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, actions, elements, parts or combinations thereof may exist or may be added.

[0048] Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings. Hereinafter, the same constituent elements in the drawings are denoted by the same reference numerals, and repeated description of the same elements will be omitted.

[0049] Figure 1 is a block diagram showing an apparatus for encoding a video according to an embodiment of the present invention.

[0050] Reference Figure 1 , the device 100 for encoding a video may include: a picture division module 110, prediction modules 120 and 125, a transformation module 130, a quantization module 135, a rearrangement module 160, an entropy coding module 165, an inverse quantization module 140, an inverse transformation module 145, a filter module 150 and a memory 155.

[0051] Figure 1 The components shown in are shown independently to represent the characteristic functions that are different from each other in the device for encoding the video. Therefore, it does not mean that each component is composed of separate hardware or software components. In other words, for convenience, each component includes each of the listed components. Therefore, at least two components in each component can be combined to form a component, or a component can be divided into multiple components to perform each function. Without departing from the essence of the present invention, the embodiment of combining each component and the embodiment of dividing a component are also included in the scope of the present invention.

[0052] In addition, some of the components are not indispensable components for performing the basic functions of the present invention, but are optional components that only improve the performance of the present invention. The present invention can be implemented by excluding components for improving performance and only including indispensable components for realizing the essence of the present invention. Structures that exclude optional components that are only used to improve performance and only include indispensable components are also included in the scope of the present invention.

[0053] The picture partitioning module 110 may partition an input picture into one or more processing units. Here, a processing unit may be a prediction unit (PU), a transform unit (TU), or a coding unit (CU). The picture partitioning module 110 may partition a picture into a combination of a plurality of coding units, prediction units, and transform units, and may encode a picture by selecting a combination of coding units, prediction units, and transform units using a predetermined criterion (e.g., a cost function).

[0054] For example, a picture can be divided into multiple coding units. A recursive tree structure (e.g., a quadtree structure) can be used to divide a picture into coding units. A coding unit divided into other coding units with a picture or a maximum coding unit as the root can be divided into child nodes corresponding to the number of divided coding units. Coding units that cannot be further divided according to predetermined restrictions are used as leaf nodes. That is, when it is assumed that only square division is feasible for a coding unit, a coding unit can be divided into up to four other coding units.

[0055] Hereinafter, in an embodiment of the present invention, a coding unit may mean a unit that performs encoding or a unit that performs decoding.

[0056] The prediction unit may be one of partitions split into square shapes or rectangular shapes having the same size in a single coding unit, or the prediction unit may be one of partitions split into different shapes / sizes in a single coding unit.

[0057] When a prediction unit subject to intra prediction is generated based on a coding unit and the coding unit is not a minimum coding unit, intra prediction may be performed without splitting the coding unit into a plurality of prediction units NxN.

[0058] The prediction modules 120 and 125 may include an inter-frame prediction module 120 that performs inter-frame prediction and an intra-frame prediction module 125 that performs intra-frame prediction. It may be determined whether inter-frame prediction or intra-frame prediction is performed for the prediction unit, and detailed information (e.g., intra-frame prediction mode, motion vector, reference picture, etc.) according to each prediction method may be determined. Here, the processing unit subjected to prediction may be different from the processing unit that determines the prediction method and detailed content. For example, the prediction method, prediction mode, etc. may be determined by the prediction unit, and the prediction may be performed by the transform unit. The residual value (residual block) between the generated prediction block and the original block may be input to the transform module 130. In addition, the prediction mode information, motion vector information, etc. used for prediction may be encoded together with the residual value by the entropy encoding module 165, and may be transmitted to a device for decoding a video. When a specific encoding mode is used, it may be transmitted to a device for decoding a video by encoding the original block as it is without generating a prediction block through the prediction modules 120 and 125.

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

[0060] The reference picture interpolation module may receive reference picture information from the memory 155, and may generate pixel information of integer pixels or less than integer pixels according to the reference picture. In the case of luma pixels, an 8-tap interpolation filter based on DCT with different filter coefficients may be used to generate pixel information of integer pixels or less than integer pixels in units of 1 / 4 pixels. In the case of chrominance signals, a 4-tap interpolation filter based on DCT with different filter coefficients may be used to generate pixel information of integer pixels or less than integer pixels in units of 1 / 8 pixels.

[0061] The motion prediction module can perform motion prediction based on the reference picture interpolated by the reference picture interpolation module. Various methods such as full search based block matching algorithm (FBMA), three-step search (TSS), new three-step search algorithm (NTS), etc. can be used as methods for calculating motion vectors. Based on the interpolated pixels, the motion vector can have a motion vector value in units of 1 / 2 pixel or 1 / 4 pixel. The motion prediction module can predict the current prediction unit by changing the motion prediction method. Various methods such as skip method, merge method, AMVP (Advanced Motion Vector Prediction) method, intra-frame block copy method, etc. can be used as motion prediction methods.

[0062] The intra prediction module 125 may generate a prediction unit based on reference pixel information adjacent to the current block, which is pixel information in the current picture. When the adjacent block of the current prediction unit is a block subject to inter-frame prediction and thus the reference pixel is a pixel subject to inter-frame prediction, the reference pixel information of the adjacent block subject to intra-frame prediction may be used to replace the reference pixel included in the block subject to inter-frame prediction. That is, when the reference pixel is not available, at least one reference pixel among the available reference pixels may be used to replace the unavailable reference pixel information.

[0063] The prediction mode of the intra prediction may include a directional prediction mode using reference pixel information according to a prediction direction and a non-directional prediction mode that does not use directional information when performing prediction. The mode for predicting luminance information may be different from the mode for predicting chrominance information, and in order to predict chrominance information, the intra prediction mode information for predicting luminance information may be used or the predicted luminance signal information may be used.

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

[0065] In the intra prediction method, a prediction block may be generated after applying an AIS (Adaptive Intra Smoothing) filter to a reference pixel according to a prediction mode. The type of the AIS filter applied to the reference pixel may be different. In order to perform the intra prediction method, the intra prediction mode of the current prediction unit may be predicted according to the intra prediction mode of a prediction unit adjacent to the current prediction unit. In predicting the prediction mode of the current prediction unit by using the mode information predicted according to the adjacent prediction unit, when the intra prediction mode of the current prediction unit is the same as the intra prediction mode of the adjacent prediction unit, predetermined flag information may be used to transmit information indicating that the prediction mode of the current prediction unit and the prediction mode of the adjacent prediction unit are the same as each other. When the prediction mode of the current prediction unit is different from the prediction mode of the adjacent prediction unit, entropy coding may be performed to encode the prediction mode information of the current block.

[0066] In addition, a residual block including information on a residual value, which is a difference between the prediction unit subjected to prediction and the original block of the prediction unit, may be generated based on the prediction unit generated by the prediction modules 120 and 125. The generated residual block may be input to the transform module 130.

[0067] The transform module 130 may transform the residual block including information on the residual value between the original block and the prediction unit generated by the prediction modules 120 and 125 by using a transform method such as discrete cosine transform (DCT), discrete sine transform (DST), and KLT. Whether to apply DCT, DST, or KLT in order to transform the residual block may be determined based on intra prediction mode information of the prediction unit used to generate the residual block.

[0068] The quantization module 135 may quantize the value transformed to the frequency domain by the transform module 130. The quantization coefficient may be different according to the block or importance of the picture. The value calculated by the quantization module 135 may be provided to the inverse quantization module 140 and the rearrangement module 160.

[0069] The rearrangement module 160 may rearrange coefficients of the quantized residual value.

[0070] The rearrangement module 160 can change the coefficient of the two-dimensional block form into the coefficient of the one-dimensional vector form by the coefficient scanning method. For example, the rearrangement module 160 can use the zigzag scanning method to scan from the DC coefficient to the coefficient in the high frequency domain so that the coefficient is changed into the one-dimensional vector form. According to the size of the transform unit and the intra-frame prediction mode, the zigzag scanning can be replaced by the vertical direction scanning of the coefficient of the two-dimensional block form in the column direction or the horizontal direction scanning of the coefficient of the two-dimensional block form in the row direction. That is to say, it can be determined according to the size of the transform unit and the intra-frame prediction mode which scanning method to use among the zigzag scanning, the vertical direction scanning and the horizontal direction scanning.

[0071] The entropy encoding module 165 may perform entropy encoding based on the value calculated by the rearrangement module 160. The entropy encoding may use various encoding methods such as exponential Golomb coding, context adaptive variable length coding (CAVLC), and context adaptive binary arithmetic coding (CABAC).

[0072] The entropy coding module 165 can encode various information from the rearrangement module 160 and the prediction modules 120 and 125 (for example, residual value coefficient information and block type information of the coding unit, prediction mode information, partition unit information, prediction unit information, transformation unit information, motion vector information, reference frame information, block interpolation information, filtering information, etc.).

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

[0074] The inverse quantization module 140 may inversely quantize the value quantized by the quantization module 135, and the inverse transform module 145 may inversely transform the value transformed by the transform module 130. The residual values ​​generated by the inverse quantization module 140 and the inverse transform module 145 may be combined with the prediction units predicted by the motion estimation module, the motion compensation module, and the intra prediction module of the prediction modules 120 and 125, so that a reconstructed block may be generated.

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

[0076] The deblocking filter can remove block distortion due to the boundaries between blocks in the reconstructed picture. In order to determine whether to perform deblocking, the pixels in several rows or columns included in the block can be the basis for determining whether to apply the deblocking filter to the current block. When the deblocking filter is applied to the block, a strong filter or a weak filter can be applied according to the required deblocking filter strength. In addition, when applying the deblocking filter, horizontal direction filtering and vertical direction filtering can be processed in parallel.

[0077] The offset correction module can correct the offset from the original picture in units of pixels in the picture subjected to deblocking. In order to perform offset correction on a specific picture, a method of applying an offset in consideration of edge information of each pixel can be used, or a method of dividing the pixels of the picture into a predetermined number of regions, determining the region to be subjected to performing the offset, and applying the offset to the determined region can be used.

[0078] Adaptive loop filtering (ALF) can be performed based on a value obtained by comparing a filtered reconstructed picture with an original picture. The pixels included in the picture can be divided into predetermined groups, a filter to be applied to each group in the group can be determined, and filtering can be performed separately for each group. Information on whether ALF is applied and a luminance signal can be transmitted by a coding unit (CU). The shape and filter coefficients of the filter used for ALF can be different for each block. In addition, regardless of the characteristics of the application target block, the filter for ALF of the same shape (fixed shape) can be applied.

[0079] The memory 155 may store a reconstructed block or a reconstructed picture calculated by the filter module 150. The stored reconstructed block or the reconstructed picture may be provided to the prediction modules 120 and 125 when performing inter prediction.

[0080] Figure 2 is a block diagram showing an apparatus for decoding a video according to an embodiment of the present invention.

[0081] Reference Figure 2The apparatus 200 for decoding a video may include an entropy decoding module 210 , a rearrangement module 215 , an inverse quantization module 220 , an inverse transform module 225 , prediction modules 230 and 235 , a filter module 240 , and a memory 245 .

[0082] When a video bitstream is input from the apparatus for encoding a video, the input bitstream may be decoded according to an inverse process of the apparatus for encoding a video.

[0083] The entropy decoding module 210 may perform entropy decoding according to an inverse process of entropy encoding performed by an entropy encoding module of a device for encoding a video. For example, corresponding to a method performed by a device for encoding a video, various methods such as exponential Golomb coding, context adaptive variable length coding (CAVLC), and context adaptive binary arithmetic coding (CABAC) may be applied.

[0084] The entropy decoding module 210 may decode information about intra prediction and inter prediction performed by the apparatus for encoding a video.

[0085] The rearrangement module 215 may perform rearrangement on the bitstream entropy-decoded by the entropy decoding module 210 based on the rearrangement method used in the apparatus for encoding a video. The rearrangement module may reconstruct and rearrange coefficients in the form of a one-dimensional vector into coefficients in the form of a two-dimensional block. The rearrangement module 215 may receive information related to coefficient scanning performed in the apparatus for encoding a video, and may perform rearrangement via a method of inversely scanning the coefficients based on the scanning order performed in the apparatus for encoding a video.

[0086] The inverse quantization module 220 may perform inverse quantization based on a quantization parameter received from the apparatus for encoding a video and coefficients of the rearranged block.

[0087] The inverse transform module 225 may perform an inverse transform (i.e., inverse DCT, inverse DST, and inverse KLT) on the quantization result by the apparatus for encoding the video, which is an inverse process of the transform (i.e., DCT, DST, and KLT) performed by the transform module. The inverse transform may be performed based on a transmission unit determined by the apparatus for encoding the video. The inverse transform module 225 of the apparatus for decoding the video may selectively perform a transform scheme (e.g., DCT, DST, and KLT) according to multiple pieces of information such as a prediction method, a size of a current block, a prediction direction, and the like.

[0088] The prediction modules 230 and 235 may generate a prediction block based on the information on prediction block generation received from the entropy decoding module 210 and previously decoded block or picture information received from the memory 245 .

[0089] As described above, similar to the operation of the apparatus for encoding a video, when performing intra prediction, when the size of the prediction unit is the same as the size of the transform unit, intra prediction can be performed on the prediction unit based on pixels located on the left, upper left, and upper sides of the prediction unit. When performing intra prediction, when the size of the prediction unit is different from the size of the transform unit, intra prediction can be performed using reference pixels based on the transform unit. In addition, intra prediction using NxN partitioning can be used only for the minimum coding unit.

[0090] The prediction modules 230 and 235 may include a prediction unit determination module, an inter-frame prediction module, and an intra-frame prediction module. The prediction unit determination module may receive various information from the entropy decoding module 210, such as prediction unit information, prediction mode information of an intra-frame prediction method, information on motion prediction of an inter-frame prediction method, etc., may divide the current coding unit into prediction units, and may determine whether to perform inter-frame prediction or intra-frame prediction on the prediction unit. By using the information required in the inter-frame prediction of the current prediction unit received from the device for encoding a video, the inter-frame prediction module 230 may perform inter-frame prediction on the current prediction unit based on information of at least one of a previous picture or a subsequent picture of the current picture including the current prediction unit. Alternatively, inter-frame prediction may be performed based on information of some pre-reconstructed areas in the current picture including the current prediction unit.

[0091] In order to perform inter prediction, which mode of the skip mode, the merge mode, the AMVP mode, and the inter block copy mode to use as a motion prediction method of a prediction unit included in the coding unit may be determined for the coding unit.

[0092] The intra prediction module 235 can generate a prediction block based on pixel information in the current picture. When the prediction unit is a prediction unit subjected to intra prediction, intra prediction can be performed based on intra prediction mode information of the prediction unit received from the device for encoding the video. The intra prediction module 235 may include an adaptive intra smoothing (AIS) filter, a reference pixel interpolation module, and a DC filter. The AIS filter performs filtering on the reference pixels of the current block, and it can be determined whether to apply the filter according to the prediction mode of the current prediction unit. AIS filtering can be performed on the reference pixels of the current block by using the AIS filter information received from the device for encoding the video and the prediction mode of the prediction unit. When the prediction mode of the current block is a mode in which AIS filtering is not performed, the AIS filter may not be applied.

[0093] When the prediction mode of the prediction unit is a prediction mode for performing intra-frame prediction based on pixel values ​​obtained by interpolating reference pixels, the reference pixel interpolation module may interpolate the reference pixels to generate reference pixels that are integer pixels or smaller than integer pixels. When the prediction mode of the current prediction unit is a prediction mode for generating a prediction block without interpolating reference pixels, the reference pixels may not be interpolated. When the prediction mode of the current block is a DC mode, the DC filter may generate a prediction block by filtering.

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

[0095] Information about whether to apply a deblocking filter to a corresponding block or picture and information about which filter of a strong filter and a weak filter to apply when applying the deblocking filter can be received from a device for encoding a video. The deblocking filter of a device for decoding a video can receive information about the deblocking filter from a device for encoding a video, and can perform deblocking filtering on the corresponding block.

[0096] The offset correction module may perform offset correction on the reconstructed picture based on the type of offset correction applied to the picture when encoding is performed and offset value information.

[0097] The ALF may be applied to the coding unit based on information on whether the ALF is applied, ALF coefficient information, etc. received from the apparatus for encoding a video. The ALF information may be provided to be included in a specific parameter set.

[0098] The memory 245 may store the reconstructed picture or the reconstructed block to be used as a reference picture or a reference block, and may provide the reconstructed picture to the output module.

[0099] As described above, in the embodiments of the present invention, for convenience of explanation, a coding unit is used as a term indicating a unit for encoding, but the coding unit may be used as a unit that performs decoding as well as encoding.

[0100] In addition, the current block may represent a target block to be encoded / decoded. Also, according to the encoding / decoding step, the current block may represent a coding tree block (or coding tree unit), a coding block (or coding unit), a transform block (or transform unit), a prediction block (or prediction unit), etc.

[0101] The picture can be encoded / decoded by dividing the picture into basic blocks having a square shape or a non-square shape. At this time, the basic block can be referred to as a coding tree unit. The coding tree unit can be defined as a coding unit of the maximum size allowed within a sequence or slice. Information about whether the coding tree unit has a square shape or a non-square shape or information about the size of the coding tree unit can be signaled through a sequence parameter set, a picture parameter set, or a slice header. The coding tree unit can be divided into partitions of smaller sizes. At this time, if it is assumed that the depth of the partition generated by splitting the coding tree unit is 1, the depth of the partition generated by splitting the partition with a depth of 1 can be defined as 2. That is, the partition generated by splitting the partition with a depth of k in the coding tree unit can be defined as a depth of k+1.

[0102] A partition of any size generated by splitting a coding tree unit may be defined as a coding unit. A coding unit may be recursively split or divided into a basic unit for performing prediction, quantization, transformation, or loop filtering, etc. For example, a partition of any size generated by splitting a coding unit may be defined as a coding unit, or may be defined as a transformation unit or a prediction unit, which is a basic unit for performing prediction, quantization, transformation, or loop filtering, etc.

[0103] The division of the coding tree unit or the coding unit may be performed based on at least one of the vertical lines or the horizontal lines. In addition, the number of vertical lines or horizontal lines that divide the coding tree unit or the coding unit may be at least one. For example, by using one vertical line or one horizontal line, the coding tree unit or the coding unit may be divided into two divisions, or by using two vertical lines or two horizontal lines, the coding tree unit or the coding unit may be divided into three divisions. Alternatively, by using one vertical line and one horizontal line, the coding tree unit or the coding unit may be divided into four divisions with a length and a width of 1 / 2.

[0104] When the coding tree unit or the coding unit is divided into a plurality of partitions using at least one vertical line or at least one horizontal line, the partitions may have a uniform size or may have different sizes. Alternatively, a partition may have a different size from another partition.

[0105] In the embodiments described below, it is assumed that the coding tree unit or the coding unit is divided into a quadtree, ternary tree, or binary tree structure. However, more vertical lines or more horizontal lines may be used to divide the coding tree unit or the coding unit.

[0106] Figure 3 2 is a diagram showing an example of hierarchical division of coding blocks based on a tree structure as an embodiment to which the present invention is applied.

[0107] The input video signal is decoded in units of predetermined blocks, and the basic unit for decoding the input video signal is called a coding block. A coding block may be a unit for performing intra / inter prediction, transformation, and quantization. In addition, a prediction mode (e.g., an intra prediction mode or an inter prediction mode) may be determined in units of coding blocks, and the prediction blocks included in the coding block may share the determined prediction mode. A coding block may be a square block or a non-square block of any size in the range of 8x8 to 64x64, and may be a square block or a non-square block of a size of 128x128, 256x256, or larger.

[0108] Specifically, the coding block can be hierarchically divided based on at least one of a quadtree, a ternary tree, and a binary tree. Here, the quadtree-based division may correspond to a method of dividing a 2Nx2N coding block into four NxN coding blocks, the ternary tree-based division may correspond to a method of dividing a coding block into three coding blocks, and the binary tree-based division may correspond to a method of dividing a coding block into two coding blocks. Even when a ternary tree-based or binary tree-based division is performed, a square coding block may exist at a lower depth. Alternatively, after a ternary tree-based or binary tree-based division is performed, the generation of a square coding block may be limited at a lower depth.

[0109] The binary tree-based partitioning may be performed symmetrically or asymmetrically. The coding block based on the binary tree partitioning may be a square block or a non-square block, for example, a rectangular block. For example, the partitioning type allowing the binary tree-based partitioning may include at least one of 2NxN (horizontal non-square coding unit) or Nx2N (vertical non-square coding unit) as a symmetrical example, nLx2N, nRx2N, 2NxnU, or 2NxnD as an asymmetrical example, as in Figure 4 In the example shown in .

[0110] The binary tree-based partitioning may restrictively allow symmetric partitioning or asymmetric partitioning. In this case, configuring the coding tree unit as a square block may correspond to a quadtree CU partition, and configuring the coding tree unit as a symmetric non-square block may correspond to a binary tree partition. Configuring the coding tree unit into square blocks and symmetric non-square blocks may correspond to quadtree CU partitioning and binary tree CU partitioning.

[0111] Binary tree-based partitioning may be performed on a coding block for which quadtree-based partitioning is no longer performed. A coding block partitioned based on a binary tree may be configured so that at least one of quadtree-based partitioning, ternary tree-based partitioning, or binary tree-based partitioning is no longer performed.

[0112] Alternatively, ternary tree-based partitioning or binary tree-based partitioning may be allowed for a binary tree-based partitioned coding block, and only one of horizontal partitioning or vertical partitioning may be restrictively allowed.

[0113] For example, according to the position, index, shape, other division shapes of adjacent divisions, etc. of the coding block divided based on the binary tree, other divisions or other division directions may be restricted for the coding block divided based on the binary tree. For example, in two coding blocks generated by binary tree-based division, assuming that the index of the coding block with an earlier coding order is 0 (hereinafter, referred to as coding block index 0) and the index of the coding block with a later coding order is 1 (hereinafter, referred to as coding block index 1), when binary tree-based division is applied to both coding blocks with coding block index 0 and coding block index 1, the binary tree-based division direction of the coding block with coding block index 1 may be determined according to the binary tree-based division direction of the coding block with coding block index 0. Specifically, when the binary tree-based division direction of the coding block with coding block index 0 divides the coding block with coding block index 0 into square divisions, the binary tree-based division of the coding block with coding block index 1 may have a different direction from the binary tree-based division of the coding block with coding block index 0. That is, it is limited to divide both coding blocks with coding block index 0 and coding block index 1 into square divisions. In this case, encoding / decoding of information indicating the binary tree division direction of the coding block with coding block index 1 can be omitted. Dividing both coding blocks with coding block index 0 and coding block index 1 into square divisions has the same effect as dividing blocks of a higher depth based on a quadtree, and therefore allowing both coding blocks with coding block index 0 and coding block index 1 to be divided into square divisions is not desirable in terms of coding efficiency.

[0114] Ternary-tree-based partitioning means dividing the coding block into three partitions in the horizontal direction or in the vertical direction. All three partitions generated by the ternary-tree-based partitioning may have different sizes. Alternatively, two of the partitions generated by the ternary-tree-based partitioning may have the same size, while the other partition may have a different size. For example, depending on the partitioning direction, the width ratio or height ratio of the partition generated by partitioning the coding block may be set to 1:n:1, 1:1:n, n:1:1, or m:n:1. Here, m and n may be real numbers 1 or greater than 1, for example, integers such as 2.

[0115] The ternary tree-based partitioning may be performed on the coding block for which the quadtree-based partitioning is no longer performed. For the coding block based on the ternary tree partitioning, it may be configured to no longer perform at least one of the quadtree-based partitioning, the ternary tree-based partitioning or the binary tree-based partitioning.

[0116] Alternatively, ternary tree-based partitioning or binary tree-based partitioning may be allowed for a ternary tree-based partitioned coding block, and only one of horizontal partitioning or vertical partitioning may be restrictively allowed.

[0117] For example, according to the position, index, shape, other division shapes of adjacent divisions of the coding block based on the ternary tree division, etc., other divisions or other division directions may be restricted for the coding block based on the ternary tree division. For example, one of the horizontal divisions or the vertical divisions may be limited to the division with the largest size among the coding blocks generated by the ternary tree-based division. Specifically, for the division with the largest size among the coding blocks generated by the ternary tree-based division, binary tree divisions or ternary tree divisions with the same direction as the ternary tree division direction of the division with a higher depth may not be allowed. In this case, for the division with the largest size among the coding blocks generated by the ternary tree-based division, the encoding / decoding of the information indicating the binary tree division direction or the ternary tree division direction may be omitted.

[0118] Depending on the size or shape of the current block, the partitioning based on a binary tree or a ternary tree may be limited. Here, the size of the current block may be represented based on at least one of the width, height, minimum / maximum value of the width / height, sum of the width and height, product of the width and height, or the number of samples included in the current block. For example, when at least one of the width or height of the current block is greater than a predefined value, the partitioning based on a binary tree or a ternary tree may not be allowed. Here, the predefined value may be an integer such as 16, 32, 64, or 128. As another example, when the aspect ratio of the current block is greater than a predefined value or less than a predefined value, the partitioning based on a binary tree or a ternary tree may not be allowed. When the predefined value is 1, the partitioning based on a binary tree or a ternary tree may be allowed only when the current block is a square block with the same width and height.

[0119] The division at a lower depth can be independently determined based on the shape of the division at a higher depth. For example, when binary tree-based division is allowed in two or more depths, a binary tree-based division of the same shape as the binary tree division at a higher depth can be allowed in a lower depth. For example, when a binary tree-based division of a 2NxN shape is performed at a higher depth, a binary tree-based division of a 2NxN shape can also be performed at a lower depth. Alternatively, when a binary tree-based division of an Nx2N shape is performed at a higher depth, a binary tree-based division of an Nx2N shape can also be performed at a lower depth.

[0120] Additionally, binary tree based partitions having shapes different from those of binary tree partitions at higher depths may be allowed only in lower depths.

[0121] For a sequence, slice, coding tree unit or coding unit, it can be restricted so that only a specific shape of binary tree-based partitioning or a specific shape of ternary tree-based partitioning will be used. For example, it can be restricted to only allow 2NxN or Nx2N shaped binary tree-based partitioning for coding tree units. The allowed partition types can be predefined in the encoder or decoder, or can be signaled via the bitstream by encoding information about the allowed partition types or the disallowed partition types.

[0122] Figure 5 is a diagram showing an example of binary tree-based partitioning that allows only specific shapes. Figure 5 In the figure, (a) shows an example of binary tree-based partitioning that only allows Nx2N shapes, and (b) shows an example of binary tree-based partitioning that only allows 2NxN shapes. In order to implement adaptive partitioning based on quadtrees or binary trees, the following information can be used: information indicating quadtree-based partitioning, information about the size / depth of coding blocks that allow quadtree-based partitioning, information indicating binary tree-based partitioning, information about the size / depth of coding blocks that allow binary tree-based partitioning, information about the size / depth of coding blocks that do not allow binary tree-based partitioning, information about whether binary tree-based partitioning is vertical or horizontal, etc.

[0123] In addition, for a coding tree unit or a predetermined coding unit, the number of times binary tree division / ternary tree division is allowed, the depth of binary tree division / ternary tree division is allowed, the number of depths of binary tree division / ternary tree division allowed, etc. can be obtained. This information can be encoded in the coding tree unit or the unit of the coding unit and can be transmitted to the decoder through the bitstream.

[0124] For example, through the bitstream, syntax 'max_binary_depth_idx_minus1' indicating the maximum depth allowed for binary tree partitioning may be encoded / decoded. In this case, max_binary_depth_idx_minus1+1 may indicate the maximum depth allowed for binary tree partitioning.

[0125] refer to Figure 6 In the example shown in Figure 6 , it is shown that binary tree partitioning is performed for a coding unit having a depth of 2 and a coding unit having a depth of 3. Therefore, at least one of the following may be encoded / decoded through a bitstream: information indicating the number of times binary tree partitioning has been performed in a coding tree unit (2 times), information indicating the maximum depth (depth 3) of binary tree partitioning allowed in a coding tree unit, or the number of depths (2 depths, depth 2 and depth 3) of binary tree partitioning allowed in a coding tree unit.

[0126] As another example, at least one of the following may be obtained for each sequence, picture or slice: the number of times binary tree division / ternary tree division is allowed, the depth of binary tree division / ternary tree division is allowed, or the number of depths of binary tree division / ternary tree division is allowed. For example, the information may be encoded in units of sequence, picture or slice, and may be transmitted through a bitstream. Alternatively, the following items may be predefined for each sequence, picture or slice: the depth of binary tree division / ternary tree division is allowed, the number of depths of binary tree division / ternary tree division is allowed. Therefore, for the first slice and the second slice, at least one of the following may be different: the number of times binary tree division / ternary tree division is allowed, the depth of binary tree division / ternary tree division is allowed, or the number of depths of binary tree division / ternary tree division is allowed. For example, in the first slice, binary tree division may be allowed only at one depth, while in the second slice, binary tree division may be allowed at two depths.

[0127] As another example, at least one of the following may be set differently according to a temporal level identifier (TemporalID) of a slice or picture: the number of times binary / ternary tree partitioning is allowed, the depth of binary / ternary tree partitioning is allowed, or the number of depths of binary / ternary tree partitioning is allowed. Here, the temporal level identifier (TemporalID) is used to identify each of a plurality of layers of an image having scalability of at least one of view, space, time, or quality.

[0128] like Figure 3 As shown in , the first coding block 300 with a division depth (split depth) of k can be divided into multiple second coding blocks based on a quadtree. For example, the second coding blocks 310 to 340 can be square blocks with half the width and half the height of the first coding block, and the division depth of the second coding block can be increased to k+1.

[0129] The second coding block 310 with a division depth of k+1 may be divided into a plurality of third coding blocks with a division depth of k+2. The division of the second coding block 310 may be performed by selectively using one of a quadtree and a binary tree according to a division method. Here, the division method may be determined based on at least one of information indicating a quadtree-based division and information indicating a binary tree-based division.

[0130] When the second coding block 310 is divided based on a quadtree, the second coding block 310 may be divided into four third coding blocks 310a having half the width and half the height of the second coding block, and the division depth of the third coding block 310a may be increased to k+2. In contrast, when the second coding block 310 is divided based on a binary tree, the second coding block 310 may be divided into two third coding blocks. Here, each of the two third coding blocks may be a non-square block having half the width and half the height of the second coding block, and the division depth may be increased to k+2. The second coding block may be determined as a non-square block in the horizontal direction or the vertical direction according to the division direction, and the division direction may be determined based on information about whether the binary tree-based division is performed in the vertical direction or in the horizontal direction.

[0131] Meanwhile, the second coding block 310 may be determined as a leaf coding block that is no longer divided based on a quadtree or a binary tree. In this case, the leaf coding block may be used as a prediction block or a transform block.

[0132] Similar to the division of the second coding block 310, the third coding block 310a may be determined as a leaf coding block, or may be further divided based on a quadtree or a binary tree.

[0133] At the same time, the third coding block 310b based on the binary tree division can be further divided into a coding block 310b-2 in the vertical direction or a coding block 310b-3 in the horizontal direction based on the binary tree, and the division depth of the relevant coding block can be increased to k+3. Alternatively, the third coding block 310b can be determined as a leaf coding block 310b-1 that is no longer divided based on the binary tree. In this case, the coding block 310b-1 can be used as a prediction block or a transform block. However, the above-mentioned division processing can be restrictively performed based on at least one of the following items: information about the size / depth of the coding block that allows quadtree-based division, information about the size / depth of the coding block that allows binary tree-based division, and information about the size / depth of the coding block that does not allow binary tree-based division.

[0134] The number of candidates representing the size of the coding block may be limited to a predetermined number, or the size of the coding block in a predetermined unit may have a fixed value. As an example, the size of the coding block in a sequence or a picture may be limited to 256x256, 128x128, or 32x32. Information indicating the size of the coding block in the sequence or in the picture may be signaled via a sequence header or a picture header.

[0135] As a result of quadtree, binary tree, and ternary tree based partitioning, the coding unit may be represented in a square or rectangular shape of an arbitrary size.

[0136] The coding block may be encoded / decoded using at least one of a skip mode, intra prediction, inter prediction, or a skip method.

[0137] As another example, intra prediction or inter prediction may be performed by dividing the coding block into units having a size equal to or smaller than the coding block. To this end, when the coding block is determined, the prediction block may be determined by predicting the coding block. The prediction partitioning of the coding block may be performed by a partitioning mode (Part_mode) indicating the partitioning type of the coding block. The size or shape of the prediction block may be determined according to the partitioning mode of the coding block. For example, the size of the prediction block determined according to the partitioning mode may have a value equal to or smaller than the size of the coding block.

[0138] Figure 7 is a diagram showing a partitioning mode that can be applied to a coding block when the coding block is encoded by inter prediction.

[0139] When a coding block is encoded by inter-frame prediction, any of the eight partitioning modes can be applied to the coding block, such as Figure 7 In the example shown in .

[0140] When a coding block is encoded by intra prediction, a partitioning mode PART_2Nx2N or PART_NxN may be applied to the coding block.

[0141] When the coding block has a minimum size, PART_NxN can be applied. Here, the minimum size of the coding block can be predefined in the encoder and decoder. Alternatively, information about the minimum size of the coding block can be sent via a bitstream signal. For example, the minimum size of the coding block can be sent via a slice header signal, and thus the minimum size of the coding block can be defined for each slice.

[0142] Generally, the size of the prediction block may have a size of 64×64 to 4×4. However, when the coding block is encoded by inter-frame prediction, when motion compensation is performed, in order to reduce memory bandwidth, the prediction block may not have a size of 4×4.

[0143] Figure 8 : is a flowchart showing an inter-frame prediction method as an embodiment to which the present invention is applied.

[0144] Reference Figure 8 , the motion information of the current block may be determined S810. The motion information of the current block may include at least one of a motion vector of the current block, a reference picture index of the current block, or an inter-prediction direction of the current block or a weight of weighted prediction. The weight of weighted prediction may represent a weight applied to the L0 reference block and a weight applied to the L1 reference block.

[0145] The motion vector of the current block may be determined based on information signaled via a bitstream. The precision of the motion vector represents the basic unit used to express the motion vector of the current block. For example, the precision of the motion vector of the current block may be determined as one of integer pixels, 1 / 2 pixels, 1 / 4 pixels, or 1 / 8 pixels. The precision of the motion vector may be determined based on each picture, each slice, each tile group, each tile, or each block. The block may represent a coding tree unit, a coding unit, a prediction unit, or a transform unit.

[0146] The motion information of the current block may be obtained based on at least one of information transmitted via a bitstream signal or motion information of a neighboring block adjacent to the current block.

[0147] Fig. 9 is a diagram illustrating a process of obtaining motion information of a current block when a merge mode is applied to the current block.

[0148] The merge mode indicates a method of obtaining motion information of the current block from neighboring blocks.

[0149] When the merge mode is applied to the current block, a spatial merge candidate may be obtained from the spatial neighboring blocks of the current block S910. The spatial neighboring blocks may include at least one of the blocks adjacent to the upper boundary, left boundary, or corner (e.g., at least one of the upper left corner, upper right corner, or lower left corner) of the current block.

[0150] Fig.10 is a diagram showing an example of spatially neighboring blocks.

[0151] As Fig.10 In the example shown in , the spatial adjacent blocks may include at least one of the following: an adjacent block A1 adjacent to the left side of the current block, an adjacent block B1 adjacent to the upper side of the current block, an adjacent block A0 adjacent to the lower left corner of the current block, an adjacent block B0 adjacent to the upper right corner of the current block, and an adjacent block B2 adjacent to the upper left corner of the current block. For example, assuming that the position of the upper left corner sample of the current block is (0, 0), the width of the current block is W, and the height of the current block is H. Block A1 may include a sample at a position (-1, H-1). Block B1 may include a sample at a position (W-1, -1). Block A0 may include a sample at a position (-1, H). Block B0 may include a sample at a position (W, -1). Block B2 may include a sample at a position (-1, -1).

[0152] Further expansion Fig.10In the example of , the spatial merge candidate can be derived from a block adjacent to the upper left sample of the current block or a block adjacent to the upper center sample of the current block. For example, the block adjacent to the upper left sample of the current block may include at least one of a block containing a sample at position (0, -1) or a block containing a sample at position (-1, 0). Alternatively, the spatial merge candidate can be obtained from at least one of a block adjacent to the upper center sample of the current block or a block adjacent to the left center sample of the current block. For example, a block adjacent to the upper center sample of the current block may include a sample at position (W / 2, -1). A block adjacent to the left center sample of the current block may include a sample at position (-1, H / 2).

[0153] According to the shape of the current block, the availability of the extended spatial neighboring blocks can be determined. In the example, when the current block is a non-square block with a width greater than a height, it can be determined that the block adjacent to the upper left sample of the current block, the block adjacent to the left center sample, or the block adjacent to the lower left sample of the current block is unavailable. At the same time, when the current block is a block with a height greater than a width, it can be determined that the block adjacent to the upper left sample of the current block, the block adjacent to the upper center sample, or the block adjacent to the upper right sample of the current block is unavailable.

[0154] The motion information of the spatial merging candidate may be set to be the same as the motion information of the spatial neighboring blocks.

[0155] Spatial merging candidates may be determined by searching adjacent blocks in a predetermined order. Fig.10 In the example shown in , a search may be performed in the order of blocks A1, B1, B0, A0, and B2 for determining spatial merge candidates. In this article, block B2 may be used when at least one of the remaining blocks (i.e., A1, B1, B0, and A0) is not present or at least one is encoded by an intra prediction mode.

[0156] The order of search space merging candidates may be predefined in the encoder / decoder. Alternatively, the order of search space merging candidates may be adaptively determined according to the size or shape of the current block. Alternatively, the order of search space merging candidates may be determined based on information sent via a bitstream signal.

[0157] A temporal merge candidate S920 may be obtained from a temporal neighboring block of the current block. A temporal neighboring block may mean a co-located block included in a co-located picture. A co-located picture has a different POC from a current picture including the current block. A co-located picture may be determined as a picture having a predefined index in a reference picture list, or as a picture that minimizes the POC difference with the current picture. Alternatively, a co-located picture may be determined by information transmitted via a bitstream signal. The information transmitted via a bitstream signal may include at least one of: information indicating a reference picture list (e.g., an L0 reference picture list or an L1 reference picture list) including a co-located picture and an index indicating a co-located picture within the reference picture list. Information for determining a co-located picture may be transmitted in at least one of a picture parameter set, a slice header, and a block level.

[0158] The motion information about the temporal merge candidate may be determined based on the motion information of the co-located block. In an example, the motion vector of the temporal merge candidate may be determined based on the motion vector of the co-located block. For example, the motion vector of the temporal merge candidate may be set to be the same as the motion vector of the co-located block. Alternatively, the motion vector of the temporal merge candidate may be obtained by scaling the motion vector of the co-located block based on at least one of a POC difference between a current picture of the current block and a reference picture and a POC difference between a co-located picture and a reference picture of the co-located block.

[0159] Fig.11 is a diagram showing an example of deriving a motion vector of a temporal merging candidate.

[0160] exist Fig.11 In the example shown in , tb represents the POC difference between the current picture curr_pic and the reference picture curr_ref of the current block, and td represents the POC difference between the co-located picture col_pic and the reference picture col_ref of the co-located block. The motion vector of the temporal merge candidate can be obtained by scaling the motion vector of the co-located block col_PU based on tb and / or td.

[0161] Alternatively, considering whether the co-located block is available, the motion vector of the co-located block and the motion vector obtained by scaling the motion vector of the co-located block can be used as the motion vector of the temporal merge candidate. In an example, the motion vector of the co-located block is set as the motion vector of the first temporal merge candidate, and the value obtained by scaling the motion vector of the co-located block can be set as the motion vector of the second temporal merge candidate.

[0162] The inter-frame prediction direction of the temporal merge candidate may be set to be the same as the inter-frame prediction direction of the temporal neighboring block. However, the reference picture index of the temporal merge candidate may have a fixed value. In the example, the reference picture index of the temporal merge candidate may be set to "0". Alternatively, the reference picture index of the temporal merge candidate may be adaptively determined based on at least one of the reference picture index of the spatial merge candidate and the reference picture index of the current picture.

[0163] A specific block having the same position and size as the current block in the co-located picture, or a block adjacent to a block having the same position and size as the current block may be determined as the co-located block.

[0164] Fig.12 is a diagram showing the locations of candidate blocks that may serve as co-located blocks.

[0165] The candidate blocks may include at least one of: a block adjacent to the upper left corner of the current block in the same picture, a block adjacent to the center sample of the current block in the same picture, and a block adjacent to the lower left corner of the current block in the same picture.

[0166] In an example, the candidate blocks may include at least one of: a block TL including the position of an upper left sample of the current block within the same picture, a block BR ​​including the position of a lower right sample of the current block within the same picture, a block H adjacent to the lower right corner of the current block within the same picture, a block C3 including the position of a center sample of the current block within the same picture, and a block C0 adjacent to the center sample of the current block within the same picture (for example, a block including the position of a sample separated from the center sample of the current block by (-1, -1)).

[0167] Apart from Fig.12 In addition to the example shown in , a block including the position of a neighboring block adjacent to a predetermined boundary of the current block within the co-located picture may be selected as the co-located block.

[0168] The number of temporal merging candidates may be 1 or more. In an example, at least one temporal merging candidate may be derived based on at least one co-located block.

[0169] Information about the maximum number of temporal merge candidates may be encoded by an encoder and sent by a signal. Alternatively, the maximum number of temporal merge candidates may be obtained based on the maximum number of merge candidates that may be included in the merge candidate list and / or the maximum number of spatial merge candidates. Alternatively, the maximum number of temporal merge candidates may be determined based on the number of available co-located blocks.

[0170] Whether the candidate block is available can be determined according to a predetermined priority, and at least one co-located block can be determined based on the above determination and the maximum number of candidates for temporal merging. In the example, when block C3 including the position of the center sample of the current block and block H adjacent to the lower right corner of the current block are candidate blocks, any one of block C3 and block H can be determined as a co-located block. When block H is available, block H can be determined as a co-located block. However, when block H is not available (for example, when block H is encoded by intra-frame prediction, when block H is not available, or when block H is located outside the maximum coding unit (LCU), etc.), block C3 can be determined as a co-located block.

[0171] In another example, when at least one of the plurality of blocks adjacent to the lower right corner position of the current block in the co-located picture is unavailable (e.g., block H and / or block BR), the unavailable block may be replaced with another available block. The other available block replacing the unavailable block may include at least one block adjacent to the center sample position of the current block in the co-located picture (e.g., C0 and / or C3) and a block adjacent to the lower left corner of the current block in the co-located picture (e.g., TL).

[0172] When at least one of the multiple blocks adjacent to the center sample position of the current block in the same picture is unavailable, or when at least one of the multiple blocks adjacent to the upper left corner position of the current block in the same picture is unavailable, the unavailable block can be replaced by another available block.

[0173] Subsequently, a merge candidate list including the spatial merge candidate and the temporal merge candidate may be generated S930. When configuring the merge candidate list, a merge candidate having the same motion information as an existing merge candidate may be removed from the merge candidate list.

[0174] Information about the maximum number of merge candidates may be sent via a bitstream signal. In an example, information indicating the maximum number of merge candidates may be sent via a sequence parameter or a picture parameter signal. In an example, when the maximum number of merge candidates is six, a total of six may be selected from the spatial merge candidates and the temporal merge candidates. For example, five spatial merge candidates may be selected from five merge candidates, and one temporal merge candidate may be selected from two temporal merge candidates.

[0175] Alternatively, the maximum number of merge candidates may be predefined in the encoder and the decoder. For example, the maximum number of merge candidates may be 2, 3, 4, 5, or 6. Alternatively, the maximum number of merge candidates may be determined based on at least one of whether a merge with MVD (MMVD) is performed, whether combined prediction is performed, or whether triangulation is performed.

[0176] If the number of merge candidates included in the merge candidate list is less than the maximum number of merge candidates, the merge candidates included in the second merge candidate list may be added to the merge candidate list. A detailed description of the second merge candidate list will be described later.

[0177] The second merge candidate list may include merge candidates obtained based on motion information of a block encoded / decoded using inter-frame prediction before the current block. For example, when motion compensation of a block whose coding mode is inter-frame prediction is performed, a merge candidate obtained based on the motion information of the block is added to the second merge candidate list. When encoding / decoding of the current block is completed, the motion information of the current block is added to the second merge candidate list for inter-frame prediction of subsequent blocks.

[0178] The second merge candidate list may be initialized based on each CTU, each tile, or each slice. The maximum number of merge candidates that the second merge candidate list can include may be predefined in the encoder and the decoder. Alternatively, information indicating the maximum number of merge candidates that the second merge candidate list can include may be sent via a bitstream signal.

[0179] The indexes of the merge candidates included in the second merge candidate list may be determined based on the order in which the merge candidates are added to the second merge candidate list. For example, the index assigned to the merge candidate added to the second merge candidate list in the Nth order may have a lower value than the index assigned to the merge candidate added to the second merge candidate list in the N+1th order. For example, the index of the N+1th merge candidate may be set to have a value that is 1 higher than the index of the Nth merge candidate. Alternatively, the index of the Nth merge candidate may be set to the index of the N+1th merge candidate, and the value of the index of the Nth merge candidate may be reduced by 1.

[0180] Alternatively, the index assigned to the merge candidate added to the second merge candidate list in the Nth order may have a higher value than the index assigned to the merge candidate added to the second merge candidate list in the N+1th order. For example, the index of the Nth merge candidate may be set to the index of the N+1th merge candidate, and the value of the index of the Nth merge candidate may be increased by 1.

[0181] Based on whether the motion information of the block subjected to motion compensation is the same as the motion information of the merge candidate included in the second merge candidate list, it can be determined whether to add the merge candidate obtained from the block to the second merge candidate list. For example, when a merge candidate having the same motion information as the block is included in the second merge candidate list, the merge candidate obtained based on the motion information of the block is not added to the second merge candidate list. Alternatively, when a merge candidate having the same motion information as the block is included in the second merge candidate list, the merge candidate is deleted from the second merge candidate list, and the merge candidate obtained based on the motion information of the block is added to the second merge candidate list.

[0182] When the number of merge candidates included in the second merge candidate list is the same as the maximum number of merge candidates, the merge candidate with the lowest index or the merge candidate with the highest index is deleted from the second merge candidate list, and the merge candidate obtained based on the motion information of the block is added to the second merge candidate list. That is, after deleting the oldest merge candidate among the merge candidates included in the second merge candidate list, the merge candidate obtained based on the motion information of the block can be added to the second merge candidate list.

[0183] When the number of merge candidates included in the merge candidate list has not reached the maximum number of merge candidates, a combined merge candidate obtained by combining two or more merge candidates or a merge candidate having a (0, 0) motion vector (zero motion vector) is included in the merge candidate list.

[0184] Alternatively, an average merge candidate obtained by calculating the average motion vector of at least two merge candidates may be included in the merge candidate list. The average merge candidate may be obtained by calculating the average motion vector of at least two merge candidates included in the merge candidate list. In the example, when the first merge candidate and the second merge candidate are added to the merge candidate list, the average of the motion vector of the first merge candidate and the motion vector of the second merge candidate may be calculated to obtain the average merge candidate. In detail, the L0 motion vector of the average merge candidate may be obtained by calculating the average of the L0 motion vector of the first merge candidate and the L0 motion vector of the second merge candidate, and the L1 motion vector of the average merge candidate may be derived by calculating the average of the L1 motion vector of the first merge candidate and the L1 motion vector of the second merge candidate. When bidirectional prediction is applied to any one of the first merge candidate and the second merge candidate, and unidirectional prediction is performed on the other merge candidate, the motion vector of the bidirectional merge candidate may be set as is to the L0 motion vector or the L1 motion vector of the average merge candidate. In the example, when the LO direction prediction and the L1 direction prediction are performed on the first merge candidate, but the LO direction prediction is performed on the second merge candidate, the L0 motion vector of the average merge candidate can be obtained by calculating the average of the L0 motion vector of the first merge candidate and the L0 motion vector of the second merge candidate. At the same time, the L1 motion vector of the average merge candidate can be derived as the L1 motion vector of the first merge candidate.

[0185] When the reference picture of the first merge candidate is different from the second merge candidate, the motion vector of the first merge candidate or the second merge candidate may be scaled according to the distance between the reference picture of each merge candidate and the current picture (i.e., POC difference). For example, after scaling the motion vector of the second merge candidate, the average merge candidate may be obtained by calculating the average of the motion vector of the first merge candidate and the scaled motion vector of the second merge candidate. In this article, priority may be set based on the value of the reference picture index of each merge candidate, the distance between the reference picture of each merge candidate and the current block, or whether bidirectional prediction is applied, and scaling may be applied to the motion vector of the merge candidate with a high (or low) priority.

[0186] The reference picture index of the average merge candidate may be set to indicate a reference picture at a specific position within the reference picture list. In an example, the reference picture index of the average merge candidate may indicate the first reference picture or the last reference picture within the reference picture list. Alternatively, the reference picture index of the average merge candidate may be set to be the same as the reference picture index of the first merge candidate or the second merge candidate. In an example, when the reference picture index of the first merge candidate is the same as the second merge candidate, the reference picture index of the average merge candidate may be set to be the same as the reference picture index of the first merge candidate and the second merge candidate. When the reference picture index of the first merge candidate is different from the second merge candidate, the priority may be set based on the value of the reference picture index of each merge candidate, the distance between the reference picture of each merge candidate and the current block, or whether bidirectional prediction is applied, and the reference picture index of the merge candidate with high (or low) priority may be set to the reference picture index of the average merge candidate. In an example, when bidirectional prediction is applied to the first merge candidate and unidirectional prediction is applied to the second merge candidate, the reference picture index of the first merge candidate to which bidirectional prediction is applied may be determined as the reference picture index of the average merge candidate.

[0187] Based on the priority between the combinations of merge candidates, a sequence of combinations for generating average merge candidates can be determined. The priorities can be predefined in the encoder and the decoder. Alternatively, the sequence of combinations can be determined based on whether bidirectional prediction of the merge candidates is performed. For example, a combination of merge candidates encoded using bidirectional prediction can be set to have a higher priority than a combination of merge candidates encoded using unidirectional prediction. Alternatively, the sequence of combinations can be determined based on the reference pictures of the merge candidates. For example, a combination of merge candidates with the same reference picture can have a higher priority than a combination of merge candidates with different reference pictures.

[0188] The merge candidates may be included in the merge candidate list according to a predefined priority. A merge candidate with a high priority may be assigned to have a small index value. In the example, the spatial merge candidate may be added to the merge candidate list before the temporal merge candidate. In addition, the spatial merge candidates may be added to the merge candidate list in the order of spatial merge candidates for the left neighboring block, spatial merge candidates for the upper neighboring block, spatial merge candidates for the block adjacent to the upper right corner, spatial merge candidates for the block adjacent to the lower left corner, and spatial merge candidates for the block adjacent to the upper left corner. Alternatively, it may be set so that the spatial merge candidates are added to the merge candidate list in the order of spatial merge candidates for the left neighboring block ( Fig.10 The spatial merge candidate obtained by B2) is added to the merge candidate list later than the temporal merge candidate.

[0189] In another example, the priority between the merge candidates may be determined according to the size or shape of the current block. In the example, when the current block has a rectangular shape with a width greater than a height, the spatial merge candidate of the left neighboring block may be added to the merge candidate list before the spatial merge candidate of the upper neighboring block. In other words, when the current block has a rectangular shape with a height greater than a width, the spatial merge candidate of the upper neighboring block may be added to the merge candidate list before the spatial merge candidate of the left neighboring block.

[0190] In another example, the priority between the merge candidates can be determined according to the motion information of each merge candidate. In the example, the merge candidate with bidirectional motion information can have a higher priority than the merge candidate with unidirectional motion information. Therefore, the merge candidate with bidirectional motion information can be added to the merge candidate list before the merge candidate with unidirectional motion information.

[0191] In another example, a merge candidate list may be generated according to a predefined priority, and then the merge candidates may be rearranged. The rearrangement may be performed based on the motion information of the merge candidate. In the example, the rearrangement may be performed based on whether the merge candidate has bidirectional motion information, the size of the motion vector, the accuracy of the motion vector, or the POC difference between the current picture and the reference picture of the merge candidate. In detail, a merge candidate with bidirectional motion information may be rearranged to have a higher priority than a merge candidate with unidirectional motion information. Alternatively, a merge candidate with a motion vector having a precision value of fractional pixels may be rearranged to have a higher priority than a merge candidate with a motion vector having an accuracy of integer pixels.

[0192] When the merge candidate list is generated, at least one of the merge candidates included in the merge candidate list may be specified based on the merge candidate index S940.

[0193] The motion information of the current block may be set to be the same as the motion information of the merge candidate specified by the merge candidate index S950. In the example, when a spatial merge candidate is selected by the merge candidate index, the motion information of the current block may be set to be the same as the motion information of the spatial adjacent block. Alternatively, when a temporal merge candidate is selected by the merge candidate index, the motion information of the current block may be set to be the same as the motion information of the temporal adjacent block.

[0194] Fig.13 is a diagram illustrating a process of obtaining motion information of a current block when the AMVP mode is applied to the current block.

[0195] When the AMVP mode is applied to the current block, at least one of the inter prediction direction and the reference picture index of the current block may be decoded according to the bitstream S1310. In other words, when the AMVP mode is applied, at least one of the inter prediction direction and the reference picture index of the current block may be determined based on information encoded by the bitstream.

[0196] A spatial motion vector candidate may be determined based on the motion vector of the spatial neighboring block of the current block S1320. The spatial motion vector candidate may include at least one of the following: a first spatial motion vector candidate derived from an upper neighboring block of the current block and a second spatial motion vector candidate obtained from a left neighboring block of the current block. In this article, the upper neighboring block may include at least one of the blocks adjacent to the upper side and the upper right corner of the current block, and the left neighboring block of the current block includes at least one of the blocks adjacent to the left side and the lower left corner of the current block. The block adjacent to the upper left corner of the current block may be used as an upper neighboring block or may be used as a left neighboring block.

[0197] Alternatively, the spatial motion vector candidate may be derived from a spatial non-adjacent block that is not adjacent to the current block. In an example, the spatial motion vector candidate for the current block may be derived by using at least one of: a block located on the same vertical line as a block adjacent to the upper side, upper right corner, or upper left corner of the current block; a block located on the same horizontal line as a block adjacent to the left side, lower left corner, or upper left corner of the current block; and a block located on the same diagonal line as a block adjacent to a corner of the current block. When spatially adjacent blocks are not available, spatial motion vector candidates may be derived by using spatially non-adjacent blocks.

[0198] In another example, at least two spatial motion vector candidates may be obtained by using spatial adjacent blocks and spatial non-adjacent blocks. In an example, a first spatial motion vector candidate and a second spatial motion vector candidate may be obtained by using adjacent blocks adjacent to the current block. Meanwhile, a third spatial motion vector candidate and / or a fourth spatial motion vector candidate may be obtained based on blocks that are not adjacent to the current block but are adjacent to the above adjacent blocks.

[0199] When the current block is different from the spatial neighboring blocks on the reference picture, the spatial motion vector may be obtained by scaling the motion vectors of the spatial neighboring blocks. A temporal motion vector candidate may be determined based on the motion vectors of the temporal neighboring blocks of the current block S1330. When the current block is different from the temporal neighboring blocks on the reference picture, the temporal motion vector may be obtained by scaling the motion vectors of the temporal neighboring blocks. In this article, when the number of spatial motion vector candidates is equal to or less than a predetermined number, the temporal motion vector candidate may be obtained.

[0200] A motion vector candidate list including spatial motion vector candidates and temporal motion vector candidates may be generated S1340.

[0201] When the motion vector candidate list is generated, at least one of the motion vector candidates included in the motion vector candidate list may be specified based on information specifying at least one of the motion vector candidate list S1350.

[0202] The motion vector candidate specified by the information may be set as a prediction value of the motion vector of the current block, and the motion vector of the current block may be obtained by adding the residual value of the motion vector to the prediction value of the motion vector S1360. Herein, the residual value of the motion vector may be parsed through the bitstream.

[0203] When the motion information of the current block is obtained, motion compensation for the current block may be performed based on the obtained motion information S820. In detail, motion compensation for the current block may be performed based on the inter prediction direction, the reference picture index, and the motion vector of the current block. The inter prediction direction indicates whether L0 directional prediction is performed, whether L1 directional prediction is performed, or whether bidirectional prediction is performed. When the current block is encoded using bidirectional prediction, a prediction block of the current block is obtained based on a weighted sum operation or an average operation of the L0 reference block and the L1 reference block.

[0204] When the prediction sample is obtained by performing motion compensation, the current block can be reconstructed based on the generated prediction sample. In detail, the reconstructed sample can be obtained by adding the prediction sample of the current block to the residual sample.

[0205] As in the above example, based on the motion information of the block encoded / decoded using inter-frame prediction before the current block, the merge candidate of the current block can be obtained. For example, based on the motion information of the neighboring block at the predefined position adjacent to the current block, the merge candidate of the current block can be obtained. Examples of neighboring blocks may include at least one of the following: a block adjacent to the left side of the current block, a block adjacent to the upper side of the current block, a block adjacent to the upper left corner of the current block, a block adjacent to the upper right corner of the current block, and a block adjacent to the lower left corner of the current block.

[0206] The merging candidate of the current block can be obtained based on the motion information of the blocks other than the adjacent blocks. For ease of description, the adjacent block at a predefined position adjacent to the current block is called the first merging candidate block, and the block at a different position from the first merging candidate block is called the second merging candidate block.

[0207] Examples of the second merge candidate block may include at least one of the following: a block encoded / decoded using inter-frame prediction before the current block, a block adjacent to the first merge candidate block, or a block on the same line as the first merge candidate block. The block on the same line as the first merge candidate block may include at least one of the following: a block on the same horizontal line as the first merge candidate block, a block on the same vertical line as the first merge candidate block, or a block on the same diagonal line as the first merge candidate block. The y coordinate positions of the blocks on the same horizontal line are the same. The x coordinate positions of the blocks on the same vertical line are the same. The difference between the x coordinate positions of the blocks on the same diagonal line is the same as the difference between the y coordinate positions.

[0208] When the first merge candidate block is not available, the merge candidate obtained based on the motion information of the second merge candidate block is added to the merge candidate list. Alternatively, even if at least one of the spatial merge candidate and the temporal merge candidate is added to the merge candidate list, when the number of merge candidates included in the merge candidate list is less than the maximum number of merge candidates, the merge candidate obtained based on the motion information of the second merge candidate block is added to the merge candidate list.

[0209] Fig.14 is a diagram showing an example of deriving a merge candidate from a second merge candidate block when a first merge candidate block is unavailable.

[0210] When the first merge candidate block AN (in this article, N ranges from 0 to 4) is unavailable, the merge candidate of the current block is obtained based on the motion information of the second merge candidate block BM (in this article, M ranges from 0 to 6). That is, the merge candidate of the current block can be obtained by replacing the unavailable first merge candidate block with the second merge candidate block.

[0211] Among the blocks adjacent to the first merge candidate block, a block placed in a predefined direction from the first merge candidate block may be set as a second merge candidate block. The predefined direction may be a left direction, a right direction, an upward direction, a downward direction, or a diagonal direction. The predefined direction may be set for each first merge candidate block. For example, the predefined direction of the first merge candidate block adjacent to the left side of the current block may be a left direction. The predefined direction of the first merge candidate block adjacent to the upper side of the current block may be an upward direction. The predefined direction of the first merge candidate block adjacent to the corner of the current block may include at least one of a left direction, an upward direction, or a diagonal direction.

[0212] For example, when A0 adjacent to the left side of the current block is not available, a merge candidate for the current block is obtained based on B0 adjacent to A0. When A1 adjacent to the top side of the current block is not available, a merge candidate for the current block is obtained based on B1 adjacent to A1. When A2 adjacent to the upper right corner of the current block is not available, a merge candidate for the current block is obtained based on B2 adjacent to A2. When A3 adjacent to the lower left corner of the current block is not available, a merge candidate for the current block is obtained based on B3 adjacent to A3. When A4 adjacent to the upper left corner of the current block is not available, a merge candidate for the current block is obtained based on at least one of B4 to B6 adjacent to A4.

[0213] Fig.14 The example shown in is only used to describe the embodiments of the present invention, but does not limit the present invention. The position of the second merge candidate block may be set to Fig.14 For example, a second merge candidate block adjacent to a first merge candidate block adjacent to the left side of the current block may be located in an upward direction or a downward direction of the first merge candidate block. Alternatively, a second merge candidate block adjacent to a first merge candidate block adjacent to the upper side of the current block may be located in a left direction or a right direction of the first merge candidate block.

[0214] A first merge candidate list and a second merge candidate list may be constructed, and motion compensation of the current block may be performed based on at least one of the first merge candidate list or the second merge candidate list.

[0215] The first merge candidate list may include at least one of: a spatial merge candidate obtained based on motion information of a neighboring block at a predefined position adjacent to the current block, or a temporal merge candidate obtained based on motion information of a co-located block.

[0216] The second merge candidate list may include merge candidates obtained based on the motion information of the second merge candidate block.

[0217] As an embodiment of the present invention, the first merge candidate list may be constructed to include merge candidates obtained from the first merge candidate block, and the second merge candidate list may be constructed to include merge candidates obtained from the second merge candidate block. Fig.14 In the example shown in , merge candidates obtained from blocks A0 to A4 may be added to the first merge candidate list, and merge candidates obtained from blocks B0 to B6 may be added to the second merge candidate list.

[0218] Alternatively, the second merge candidate list may include merge candidates obtained based on motion information of a block encoded / decoded using inter-prediction before the current block.

[0219] The second merge candidate list may be initialized based on each CTU, each tile, or each slice. The maximum number of merge candidates that the second merge candidate list can include may be predefined in the encoder and the decoder. Alternatively, information indicating the maximum number of merge candidates that the second merge candidate list can include may be sent via a bitstream signal.

[0220] The second merge candidate list may include merge candidates obtained based on motion information of a block encoded / decoded using inter-frame prediction before the current block. For example, when motion compensation of a block whose coding mode is inter-frame prediction is performed, a merge candidate obtained based on the motion information of the block is added to the second merge candidate list. When encoding / decoding of the current block is completed, the motion information of the current block is added to the second merge candidate list for inter-frame prediction of subsequent blocks.

[0221] The indexes of the merge candidates included in the second merge candidate list may be determined based on the order in which the merge candidates are added to the second merge candidate list. For example, the index assigned to the Nth merge candidate added to the second merge candidate list may have a lower value than the index assigned to the N+1th merge candidate added to the second merge candidate list. For example, the index of the N+1th merge candidate may be set to have a value that is 1 higher than the index of the Nth merge candidate. Alternatively, the index of the Nth merge candidate may be set to the index of the N+1th merge candidate, and then the value of the index of the Nth merge candidate is reduced by 1.

[0222] Alternatively, the index assigned to the Nth merge candidate added to the second merge candidate list may have a higher value than the index assigned to the N+1th merge candidate added to the second merge candidate list. For example, the index of the Nth merge candidate may be set to the index of the N+1th merge candidate, and then the value of the index of the Nth merge candidate is increased by 1.

[0223] Based on whether the motion information of the block subjected to motion compensation is the same as the motion information of the merge candidate included in the second merge candidate list, it can be determined whether to add the merge candidate obtained from the block to the second merge candidate list. For example, when a merge candidate having the same motion information as the block is included in the second merge candidate list, the merge candidate obtained based on the motion information of the block is not added to the second merge candidate list. Alternatively, when a merge candidate having the same motion information as the block is included in the second merge candidate list, the merge candidate is deleted from the second merge candidate list, and the merge candidate obtained based on the motion information of the block is added to the second merge candidate list.

[0224] When the number of merge candidates included in the second merge candidate list is the same as the maximum number of merge candidates, the merge candidate with the lowest index or the merge candidate with the highest index is deleted from the second merge candidate list, and the merge candidate obtained based on the motion information of the block is added to the second merge candidate list. That is, after deleting the oldest merge candidate among the merge candidates included in the second merge candidate list, the merge candidate obtained based on the motion information of the block can be added to the second merge candidate list.

[0225] The first merge candidate list or the second merge candidate list can be selected, and the selected merge candidate list can be used to perform inter-frame prediction of the current block. Specifically, based on the index information, any one of the merge candidates included in the selected merge candidate list can be selected, and the motion information of the current block can be obtained from the selected merge candidate.

[0226] Information specifying the first merge candidate list or the second merge candidate list may be transmitted via a bitstream signal, and the decoder may select the first merge candidate list or the second merge candidate list based on the information.

[0227] Alternatively, among the first merge candidate list and the second merge candidate list, a merge candidate list including a larger number of available merge candidates may be selected.

[0228] Alternatively, the first merge candidate list or the second merge candidate list may be selected based on at least one of the size, shape, and split depth of the current block.

[0229] Alternatively, to any one of the first merge candidate list and the second merge candidate list, the other may be added (or appended).

[0230] For example, inter prediction may be performed based on a merge candidate list including at least one merge candidate included in the first merge candidate list and at least one merge candidate included in the second merge candidate list.

[0231] For example, the merge candidates included in the second merge candidate list may be added to the first merge candidate list. Alternatively, the merge candidates included in the first merge candidate list may be added to the second merge candidate list.

[0232] When the number of merge candidates included in the first merge candidate list is less than the maximum number, or when the first merge candidate block is unavailable, merge candidates included in the second merge candidate list are added to the first merge candidate list.

[0233] Alternatively, when the first merge candidate block is not available, a merge candidate obtained from a block adjacent to the first merge candidate block among the merge candidates included in the second merge candidate list is added to the first merge candidate list. Fig.14 , when A0 is not available, the merge candidate obtained based on the motion information of B0 among the merge candidates included in the second merge candidate list is added to the first merge candidate list. When A1 is not available, the merge candidate obtained based on the motion information of B1 among the merge candidates included in the second merge candidate list is added to the first merge candidate list. When A2 is not available, the merge candidate obtained based on the motion information of B2 among the merge candidates included in the second merge candidate list is added to the first merge candidate list. When A3 is not available, the merge candidate obtained based on the motion information of B3 among the merge candidates included in the second merge candidate list is added to the first merge candidate list. When A4 is not available, the merge candidate obtained based on the motion information of B4, B5 or B6 among the merge candidates included in the second merge candidate list is added to the first merge candidate list.

[0234] Alternatively, the merge candidate to be added to the first merge candidate list may be determined according to the priority of the merge candidates included in the second merge candidate list. The priority may be determined based on the index value. For example, when the number of merge candidates included in the first merge candidate list is less than the maximum number, or when the first merge candidate block is unavailable, the merge candidate with the lowest index value or the merge candidate with the highest index value among the merge candidates included in the second merge candidate list is added to the first merge candidate list.

[0235] When a merge candidate having the same motion information as a merge candidate included in the second merge candidate list is included in the first merge candidate list, a merge candidate assigned an index value one higher than the index value or a merge candidate assigned an index value one lower than the index value is added to the first merge candidate list.

[0236] A merge candidate list including a merge candidate obtained based on the motion information of the first merge candidate block and a merge candidate obtained based on the motion information of the second merge candidate block may be generated. The merge candidate list may be a combination of the first merge candidate list and the second merge candidate list.

[0237] For example, according to a predetermined search order, a merge candidate list may be generated by searching the first merge candidate block and the second merge candidate block.

[0238] Figures 15 to 18 is a diagram showing the order of searching for merge candidate blocks.

[0239] Figures 15 to 18 The order of searching for merge candidates is shown as follows.

[0240] A0→A1→A2→A3→A4→B0→B1→B2→B3→B4→(B5)→(B6).

[0241] Only when block B4 is unavailable or when the number of merge candidates included in the merge candidate list is equal to or less than a preset number, the search for blocks B5 and B6 is performed.

[0242] Can be set with Figures 15 to 18 The examples shown in the different search orders.

[0243] A combined merge candidate list including at least one merge candidate included in a first merge candidate list and at least one merge candidate included in a second merge candidate list may be generated. For example, the combined merge candidate list may include N merge candidates included in the first merge candidate list and M merge candidates included in the second merge candidate list. The letters N and M may represent the same number or different numbers. Alternatively, at least one of N and M may be determined based on at least one of the number of merge candidates included in the first merge candidate list and the number of merge candidates included in the second merge candidate list. Alternatively, information for determining at least one of N and M may be sent via a bitstream signal. Either of N and M may be obtained by subtracting the other from the maximum number of merge candidates in the combined merge candidate list.

[0244] The merge candidates to be added to the combined merge candidate list may be determined according to a predefined priority. The predefined priority may be determined based on an index assigned to the merge candidate.

[0245] Alternatively, the merge candidates to be added to the combined merge candidate list may be determined based on the association between the merge candidates. For example, when A0 included in the first merge candidate list is added to the combined merge candidate list, a merge candidate at a position adjacent to A0 (e.g., B0) is not added to the combined merge list.

[0246] When the number of merge candidates included in the first merge candidate list is less than N, merge candidates greater than M among the merge candidates included in the second merge candidate list are added to the combined merge candidate list. For example, when N is four and M is two, four of the merge candidates included in the first merge candidate list are added to the combined merge candidate list, and two of the merge candidates included in the second merge candidate list are added to the combined merge candidate list. When the number of merge candidates included in the first merge candidate list is less than four, two or more merge candidates among the merge candidates included in the second merge candidate list are added to the combined merge candidate list. When the number of merge candidates included in the second merge candidate list is less than two, four or more merge candidates among the merge candidates included in the first merge candidate list are added to the combined merge candidate list.

[0247] That is, the value of N or M may be adjusted according to the number of merge candidates included in each merge candidate list. By adjusting the value of N or M, the total number of merge candidates included in the combined merge candidate list may be fixed. When the total number of merge candidates included in the combined merge candidate list is less than the maximum number of merge candidates, a combined merge candidate, an average merge candidate, or a zero motion vector candidate is added.

[0248] The merging candidate may be obtained based on a block having a predetermined shape or a predetermined size or larger. When the current block is not in the predetermined shape, or when the size of the current block is smaller than the predetermined size, the merging candidate of the current block is obtained based on a block including the current block and in the predetermined shape or in the predetermined size or larger. The predetermined shape may be a square shape or a non-square shape.

[0249] When the predetermined shape is a square shape, a merge candidate of a non-square shaped coding unit is obtained based on the square shaped coding units including the non-square shaped coding units.

[0250] Fig.19 is a diagram showing an example of obtaining merging candidates of non-square blocks based on square blocks.

[0251] A merge candidate of a non-square block can be obtained based on a square block including a non-square block. For example, a merge candidate of a non-square shaped coding block 0 and a non-square shaped coding block 1 can be obtained based on a square shaped block including coding block 0 and coding block 1. That is, the position of the spatially adjacent block can be determined based on the position, width / height or size of the square shaped block. A merge candidate of coding block 0 and coding block 1 can be obtained based on at least one of the spatially adjacent blocks A0, A1, A2, A3 and A4 adjacent to the square shaped block.

[0252] Temporal merge candidates may be determined based on square-shaped blocks. That is, temporal neighboring blocks may be determined based on the position, width / height, or size of the square-shaped blocks. For example, merge candidates for coding block 0 and coding block 1 may be derived based on temporal neighboring blocks determined based on square-shaped blocks.

[0253] Alternatively, any one of the spatial merge candidate and the temporal merge candidate can be derived based on a square block, and the other merge candidate can be derived based on a non-square block. For example, a spatial merge candidate for coding block 0 can be derived based on a square block, and a temporal merge candidate for coding block 0 can be derived based on coding block 0.

[0254] A plurality of blocks included in a block of a predetermined shape or a predetermined size or larger may share a merge candidate. Fig.19 In the example shown in , at least one of the spatial merging candidates and the temporal merging candidates of coding block 0 and coding block 1 may be the same.

[0255] The predetermined shape may be a non-square shape, such as 2NxN, Nx2N, etc. When the predetermined shape is a non-square shape, a merge candidate of the current block may be obtained based on a non-square block including the current block. For example, when the current block is in a 2Nxn shape (herein, n is 1 / 2N), a merge candidate of the current block is obtained based on a non-square block of a 2NxN shape. Alternatively, when the current block is in an nx2N shape, a merge candidate of the current block is obtained based on a non-square block of an Nx2N shape.

[0256] The information indicating the predetermined shape or the predetermined size may be transmitted via a bitstream signal. For example, the information indicating any one of a non-square shape or a square shape may be transmitted via a bitstream signal.

[0257] Alternatively, the predetermined shape or the predetermined size may be determined according to a rule predefined in an encoder and a decoder.

[0258] When the child node does not meet the predetermined condition, a merge candidate of the child node is obtained based on the parent node that meets the predetermined condition. In this article, the predetermined condition may include at least one of the following: whether the block is a block generated due to quadtree partitioning; whether the size of the block, the shape of the block, and the picture boundary are exceeded; and whether the depth difference between the child node and the parent node is equal to or greater than a predetermined value.

[0259] For example, the predetermined condition may include whether the block is a block generated due to quadtree partitioning, and whether the block is a coded block of a square shape of a predetermined size or larger. When the current block is generated by binary tree partitioning or ternary tree partitioning, a merge candidate of the current block is obtained based on a high-level node block that includes the current block and satisfies the predetermined condition. When there is no high-level node block that satisfies the predetermined condition, a merge candidate of the current block is obtained based on the current block, a block that includes the current block and is of a predetermined size or larger, or a high-level node block that includes the current block and has a depth difference of 1 with the current block.

[0260] In the embodiment described below, among the multiple merge candidates included in the merge candidate list, the N merge candidates selected to determine the motion vector of the current block will be respectively referred to as the first merge candidate, the second merge candidate, ..., the Nth merge candidate. The order of the names can be determined by the merge index of the merge candidate. For example, the first merge candidate refers to the merge candidate with the lowest merge index among the N merge candidates, and the Nth merge candidate refers to the merge candidate with the highest merge index among the N merge candidates.

[0261] The motion vector of the current block may be determined based on a value obtained by adding motion vectors of multiple merging candidates or a value obtained by scaling at least one motion vector. Alternatively, the motion vector of the current block may be determined based on a weighted sum operation or an average operation of motion vectors of multiple merging candidates.

[0262] Equation 1 represents an example of deriving a motion vector of a current block by adding a motion vector of a first merge candidate and a motion vector of a second merge candidate.

[0263] [Equation 1]

[0264] mvL0=mvL0_1+mvL0_2

[0265] mvL1=mvL1_1+mvL1_2

[0266] In the above Equation 1, mvL0 represents the motion vector L0 of the current block, and mvL1 represents the motion vector L1 of the current block. Expression mvL0_N (N is 1 or 2) represents the motion vector L0 of the Nth merge candidate, and expression mvL1_N represents the motion vector L1 of the Nth merge candidate.

[0267] The motion vector of the current block may be obtained by adding a value obtained by scaling the first motion vector and the second motion vector. Equation 2 represents an example of obtaining the motion vector of the current block by adding the motion vector of the first merge candidate and the scaled motion vector of the second merge candidate.

[0268] [Equation 2]

[0269] mvL0=mvL0_1+(mvL0_2>>M)

[0270] mvL1=mvL1_1+(mvL1_2>>M)

[0271] In Equation 2, the letter M represents a scaling parameter. Information for determining the scaling parameter may be transmitted via a bitstream signal. The scaling parameter may be determined based on each slice or each block. Alternatively, the scaling parameter may be determined based on the difference in output order (e.g., POC) between the reference picture of the first merge candidate and the reference picture of the second merge candidate. Alternatively, the scaling parameter may be determined based on the difference in merge index between the first merge candidate and the second merge candidate. For example, when the merge index of the first merge candidate is n and the merge index of the second merge candidate is m, the scaling parameter M is determined to be mn.

[0272] The average of the motion vectors of the plurality of merge candidates may be determined as the motion vector of the current block. Equation 3 represents an example of determining the average of the motion vectors of the first merge candidate and the second merge candidate as the motion vector of the current block. Equation 3 represents an example of obtaining the motion vector of the current block by adding the motion vector of the first merge candidate and the scaled motion vector of the second merge candidate.

[0273] [Equation 3]

[0274] mvL0=(mvL0_1+mvL0_2)>>1

[0275] mvL1=(mvL1_1+mvL1_2)>>1

[0276] At least one of the reference picture index, bidirectional prediction flag, and bidirectional prediction weight of the current block may be set to be the same as at least one of the reference picture index, bidirectional prediction flag, and bidirectional prediction weight of any one of the multiple merge candidates. For example, at least one of the reference picture index, bidirectional prediction flag, and bidirectional prediction weight of the current block may be set to be the same as at least one of the reference picture index, bidirectional prediction flag, and bidirectional prediction weight of the merge candidate with the lowest merge index or the merge candidate with the highest index among the multiple merge candidates. Alternatively, at least one of the reference picture index, bidirectional prediction flag, and bidirectional prediction weight of the current block may be obtained from the merge candidate selected by the first index information or the last index information among the multiple index information.

[0277] Information indicating whether the motion information of the current block is determined based on multiple merge candidates may be sent via a bitstream signal. The information may be a 1-bit flag. Alternatively, the information may indicate the number of merge candidates used to determine the motion information of the current block. For example, information with a value of 1 may indicate that the motion information of the current block is determined based on one merge candidate. Information with a value of 01 may indicate that the motion information of the current block is determined based on two merge candidates. Information with a value of 11 may indicate that the motion information of the current block is determined based on three merge candidates. More than three merge candidates may be used.

[0278] Alternatively, it may be set when the merge candidate indicated by the index information of the current block is encoded using unidirectional prediction (ie, has only unidirectional motion information), selecting another merge candidate.

[0279] Index information identifying each of the plurality of merge candidates may be sent via a bitstream signal. For example, a first merge candidate may be selected based on the first index information, and a second merge candidate may be selected based on the second index information. In this article, the second index information may indicate any one of the merge candidates other than the first merge candidate.

[0280] Alternatively, the first merge candidate may be determined based on the index information, and the second merge candidate may be determined by adding / subtracting an offset from the merge index of the first merge candidate. The offset may be a natural number of 1, 2, 3, 4, etc. The offset value may be predefined in the encoder and the decoder. Alternatively, information for determining the offset value may be transmitted via a bitstream signal.

[0281] Alternatively, the first merge candidate may be determined based on the index information, and a merge candidate spatially adjacent to the first merge candidate may be determined as the second merge candidate. For example, when the first merge candidate corresponds to a neighboring block adjacent to the left side of the current block, a merge candidate obtained from a block adjacent to the lower left corner of the current block, or a merge candidate obtained from a block adjacent to the upper left corner of the current block is determined as the second merge candidate.

[0282] Alternatively, the first merge candidate may be determined based on the index information, and a merge candidate predetermined in the encoder and the decoder may be determined as the second merge candidate. The predetermined merge candidate may be a merge candidate with a lowest merge index or a merge candidate with a highest merge index among the merge candidates included in the merge candidate list.

[0283] Alternatively, the first merge candidate may be determined based on the index information, and a merge candidate having the same reference picture as the first merge candidate may be determined as the second merge candidate. When there are multiple merge candidates having the same reference picture as the first merge candidate, a merge candidate having the lowest index value, a merge candidate having the smallest index value difference from the first merge candidate, or a merge candidate using bidirectional predictive coding is selected.

[0284] Alternatively, when a first merge candidate determined based on index information is encoded using first directional prediction, a merge candidate having second directional motion information is selected as a second merge candidate. When there are multiple merge candidates having first directional motion information, a merge candidate having the lowest index value, a merge candidate having the smallest index value difference with the first merge candidate, or a merge candidate encoded using bidirectional prediction is selected.

[0285] Instead of selecting multiple merge candidates, a merge candidate generated by combining multiple merge candidates may be added to the merge candidate list. For example, when the number of merge candidates included in the merge candidate list is less than the maximum number of merge candidates, the average of the motion vectors of the multiple merge candidates is added to the merge candidate list as the average merge candidate of the motion vector.

[0286] The motion vector of the current block may be obtained by an initial vector determination step (first step) and / or an initial vector refinement step (second step). The first step may include obtaining the motion vector of the current block by a merge mode or an AMVP mode. The second step may include determining the motion vector of the current block by refining the initial motion vector.

[0287] Information indicating whether to perform the initial vector refinement step may be sent via a bitstream signal. The information may be a 1-bit flag. When the initial vector refinement step is not performed, motion compensation is performed based on the motion vector of the current block obtained in the first step (i.e., the initial motion vector). When the initial vector refinement step is performed, motion compensation is performed based on the refined initial motion vector. Alternatively, it may be determined whether to perform the initial vector refinement step based on the size of the current block, the shape of the current block, the inter-frame prediction mode of the current block, the position of the current block, or the accuracy of the motion information of the current block. For example, information indicating whether to perform the initial vector refinement step is encoded only when the inter-frame prediction mode of the current block is encoded using the merge mode.

[0288] Hereinafter, a process of obtaining a refined initial motion vector will be described in detail.

[0289] Fig. 20 is a flow chart showing a method of refining a motion vector of a current block.

[0290] The initial motion vector of the current block can be obtained S2010. When the inter prediction mode of the current block is the merge mode, the motion vector of the merge candidate indicated by the index information of the current block is determined as the initial motion vector of the current block. When the inter prediction mode of the current block is the AMVP mode, the sum of the motion vector candidate indicated by the index information of the current block and the motion vector difference is determined as the initial motion vector.

[0291] When the current block is encoded using the merge mode, the maximum number of merge candidates is changed to a predefined number. For example, one of the N merge candidates is determined as the initial motion vector of the current block. In this article, N can be a natural number such as 2, 3, etc. That is, when the initial motion vector is refined, the maximum number of merge candidates that the merge candidate list can include is reduced.

[0292] The initial motion vector of the current block may be refined S2020. As a result of the refinement of the initial motion vector, a motion vector of the current block may be determined S2030.

[0293] The refinement of the initial motion vector may be performed based on the initial motion vector and the motion refinement vector. The motion vector of the current block may be obtained by adding the initial motion vector and the motion refinement vector. Alternatively, the refinement of the initial motion vector may be performed by adjusting the resolution of the initial motion vector.

[0294] Information indicating at least one of the two methods may be transmitted via a bitstream signal. Depending on the value of the information, the initial motion vector may be refined using either one of the two methods or a combination of the two methods. Alternatively, the method for refining the initial motion vector may be determined based on at least one of the size of the initial motion vector of the current block, whether bidirectional prediction of the current block is performed, or the position of the current block.

[0295] First, a method of obtaining a motion vector of a current block based on a motion refinement vector will be described.

[0296] Information for determining the motion refinement vector may be transmitted via a bitstream signal. The information may include at least one of information indicating the size of the motion refinement vector or information indicating the direction of the motion refinement vector. Alternatively, the motion refinement vector may be obtained by searching a predetermined area based on the initial motion vector. Alternatively, the motion refinement vector may be determined based on motion information of a spatial neighboring block or a temporal neighboring block.

[0297] Alternatively, the motion refinement vector may be determined by searching a predetermined search area based on the initial motion vector of the current block. The search area may be a rectangular area within the reference picture including the position indicated by the initial motion vector. The size of the search area may be predefined in the encoder and the decoder. Alternatively, information indicating the size of the search area may be sent via a bitstream signal. Alternatively, the size of the search area may be determined based on at least one of the size of the initial motion vector, the resolution of the motion vector of the current block, the difference in output order (POC) between the current picture and the reference picture, or whether bidirectional prediction of the current block is performed.

[0298] A position where a rate-distortion cost (RD cost) is the lowest may be searched in a predetermined area. For example, a rate-distortion cost between a reference block included in a predetermined area of ​​an L0 reference picture and a reference block included in a predetermined area of ​​an L1 reference picture may be calculated, and a combination of an L0 reference block and an L1 reference block having a lowest rate-distortion cost may be determined. In addition, a vector from an L0 reference block indicated by an L0 initial motion vector to an L0 reference block having a lowest rate-distortion cost may be set as an L0 motion refinement vector. A distance from an L1 reference block indicated by an L1 initial motion vector to an L1 reference block having a lowest rate-distortion cost may be set as an L1 motion refinement vector.

[0299] Alternatively, a rate-distortion cost between an adjacent template region adjacent to the current block and a reference template region adjacent to the reference block may be calculated. The adjacent template region adjacent to the current block may include at least one of an area adjacent to the upper side of the current block or an area adjacent to the left side of the current block. A reference template region having a lowest rate-distortion cost with the adjacent template region may be determined, and a vector from the reference block indicated by the initial motion vector to the reference block adjacent to the reference template region may be set as a motion refinement vector.

[0300] By using the same rule, the encoder and the decoder can calculate the rate-distortion cost within the predetermined region and can determine the motion refinement vector. The above method of obtaining the motion refinement vector can be defined as a decoder-side merge refinement method.

[0301] Information indicating whether to perform the decoder-side merge refinement method may be sent via a bitstream signal. The information may be a 1-bit flag.

[0302] The decoder side merge refinement method may be performed on a per sub-block basis. For example, a coding block may be divided into a plurality of sub-blocks, and a motion refinement vector may be determined on a per sub-block basis. Although an initial motion vector may be determined on a per coding unit basis, a motion refinement vector may also be determined on a per sub-block basis. Alternatively, an initial motion vector may be determined on a per sub-block basis, and a motion refinement vector for each of the sub-blocks may be determined based on the initial motion vector for each of the sub-blocks.

[0303] Alternatively, information for determining a motion refinement vector may be transmitted via a bitstream signal. The information may include at least one of information indicating the magnitude of a motion refinement vector or information indicating the direction of a motion refinement vector. The information indicating the magnitude of a motion refinement vector may be index information indicating any one of a plurality of candidates. For example, the index information may indicate any one of {1 / 4, 1 / 2, 1, 2, 4}. The candidates for the magnitude may be determined based on the precision (or resolution) of the motion vector of the current block. For example, when the precision of the motion vector of the current block is 1 / 4 pixel, the candidates for the magnitude are {1 / 4, 1 / 2, 1, 2, 4}. When the precision of the motion vector of the current block is 1 pixel, the candidates for the magnitude of the motion refinement vector are {1, 2, 4, 8, 16}. That is, for each of the precisions of the motion vector of the current block, at least one of the minimum value of the candidate for the size, the maximum value of the candidate for the size, or the number of candidates for the size may be different.

[0304] The information indicating the direction of the motion refinement vector may be index information indicating any one of a plurality of candidates. For example, the index information may indicate any one of {(+, 0), (-, 0), (0, +), (0, -)}. The symbol + represents a positive direction relative to the x-axis or y-axis, and the symbol - represents a negative direction relative to the x-axis or y-axis. The number 0 indicates that the x-axis or y-axis displacement is zero. A combination of directions in which both the x-axis displacement and the y-axis displacement are not zero may be used. For example, the candidates of {(+, +), (+, -), (-, +), (-, -)} may be used.

[0305] Determining the motion refinement vector based on information related to the motion refinement vector transmitted from the encoder can be defined as an encoder-side merge refinement method. Information indicating whether the encoder-side merge refinement method is performed can be sent via a bitstream signal. The information can be a 1-bit flag. The decoder can decode the information related to the motion refinement vector from the bitstream, and can use the decoded information to determine the motion refinement vector.

[0306] The magnitude of the motion refinement vector may be set to be no greater than the magnitude of the initial motion vector. Alternatively, the magnitude of the motion refinement vector may be set to be no greater than 1 / (2n) of the magnitude of the initial motion vector. Alternatively, the magnitude of the motion refinement vector may be set to be no greater than a predetermined value. Depending on the setting, the size of the search area or the candidate for the magnitude of the motion refinement vector may be determined.

[0307] As described above, the motion refinement vector value may be determined within a predetermined range.

[0308] Fig.21 is a diagram showing an example of setting a motion refinement vector within a predetermined range.

[0309] As in Fig.21 In the example shown in (a), the absolute value of the x-axis or y-axis of the motion refinement vector may be set to not exceed N. The letter N may represent a natural number such as 1, 2, 4, 8, etc., or may represent a decimal such as 1 / 2, 1 / 4, 1 / 8, 1 / 16, etc. N may be determined based on at least one of the size of the current block, the size of the initial motion vector, the shape of the current block, the resolution of the motion vector of the current block, or the difference in output order between the current picture and the reference picture. Alternatively, information for determining N may be transmitted via a bitstream signal. For example, Fig.21 (b) is a diagram showing a case where N is set to 1.

[0310] The motion refinement vector value may be set to not exceed an integer pixel of the initial motion vector. For example, when the precision of the motion vector of the current block is 1 / 4 pixel, the motion refinement vector value does not exceed 4. Alternatively, when the precision of the motion vector of the current block is 1 / 8 pixel, the motion refinement vector value does not exceed 8.

[0311] Multiple refinement vectors of the current block may be obtained. When multiple refinement vectors exist, the motion vector of the current block is determined by adding the multiple refinement vectors to the initial motion vector.

[0312] For example, the motion vector of the current block determined by step S1710 of the current block may be determined as the first initial motion vector. The first motion refinement vector may be determined based on information transmitted via a bitstream signal. Alternatively, the first motion refinement vector may be determined by searching a predetermined search area based on the first initial motion vector.

[0313] The second initial motion vector may be determined by adding the first initial motion vector and the first motion refinement vector. The second motion refinement vector may be determined based on information transmitted via the bitstream signal. Alternatively, the second motion refinement vector may be determined based on the second initial motion vector by searching a predetermined search area.

[0314] By adding the second initial motion vector and the second motion refinement vector, the motion vector of the current block may be obtained.

[0315] The method of obtaining multiple motion refinement vectors can be the same. For example, the first motion refinement vector and the second motion refinement vector can be determined using a decoder-side merge refinement method. Alternatively, the first motion refinement vector and the second motion refinement vector can be determined using an encoder-side merge refinement method.

[0316] Alternatively, a plurality of motion refinement vectors may be determined by combining a decoder-side merge refinement method and an encoder-side merge refinement method. For example, any one of a first motion refinement vector and a second motion refinement vector may be determined using the decoder-side merge refinement method, and the other may be determined using the encoder-side merge refinement method. A motion vector refinement method combining the decoder-side merge refinement method and the encoder-side merge refinement method may be defined as an encoder-decoder-side merge refinement method.

[0317] The order in which the encoder-side merge refinement method and the decoder-side merge refinement method are applied may be predefined in the encoder and the decoder. For example, a first motion refinement vector may be determined by the decoder-side merge refinement method, and a second motion refinement vector may be determined by the encoder-side merge refinement method. Alternatively, the first motion refinement vector may be determined by the encoder-side merge refinement method, and the second motion refinement vector may be determined by the decoder-side merge refinement method. Alternatively, information about the order of application may be signaled via a bitstream.

[0318] Next, a method of obtaining a motion vector of a current block by adjusting the resolution of the motion vector will be described.

[0319] The motion vector of the current block may be determined by changing the resolution of the initial motion vector of the current block. The resolution of the initial motion vector may be determined based on information transmitted via a bitstream signal. Alternatively, the resolution of the initial motion vector may be determined based on at least one of the size, shape, partition-related information, or inter-frame prediction method of the current block or an adjacent block.

[0320] The change of resolution may include a reduction in resolution from a high resolution to a low resolution, or an increase in resolution from a low resolution to a high resolution. For example, changing an initial motion vector based on integer pixels to fractional pixels corresponds to a reduction in resolution, and changing an initial motion vector based on fractional pixels to integer pixels corresponds to a reduction in resolution. The change in resolution may be performed based on a round-down operation, a round-up operation, or a round-off operation. Alternatively, the change in resolution may be performed by adding / subtracting a motion refinement vector sent via a bitstream signal.

[0321] Information indicating whether to change the resolution may be sent via a bitstream signal. The information may be a 1-bit flag. Information indicating a unit may be sent via a bitstream signal. The unit may be any one of the resolution candidates. For example, the information may indicate any one of integer pixels, 1 / 2 pixels, 1 / 4 pixels, 1 / 8 pixels, or 1 / 16 pixels. The resolution of the initial motion vector may be changed to the resolution indicated by the information.

[0322] Alternatively, whether to change the resolution or the unit of resolution change may be determined based on at least one of the size, shape, partition-related information, or an inter-prediction method of the current block or a neighboring block.

[0323] The application of the embodiments described focusing on the decoding process or the encoding process to the encoding process or the decoding process is included in the scope of the present invention. Changing the embodiments described in a predetermined order to a different order is also included in the scope of the present invention.

[0324] Although the above embodiments have been described based on a series of steps or flow charts, the above embodiments are not intended to limit the time series order of the present invention, and can be executed simultaneously or in different orders. In addition, each of the components (e.g., units, modules, etc.) constituting the block diagram in the above embodiments can be implemented as a hardware device or software, and multiple components can be combined into one hardware device or software. The above embodiments can be implemented in the form of program instructions, which can be executed by various computer components and recorded in a computer-readable recording medium. Computer-readable storage media can include program instructions, data files, data structures, etc., individually or in combination. Examples of computer-readable storage media include: magnetic recording media, such as hard disks, floppy disks, and tapes; optical data storage media, such as CD-ROMs or DVD-ROMs; magneto-optical media, such as optical disks; and hardware devices, such as read-only memories (ROMs), random access memories (RAMs), and flash memories, which are specially structured to store and implement program instructions. The hardware device can be configured to be operated by one or more software modules or vice versa to perform processing according to the present invention.

[0325] Industrial Applicability

[0326] The present invention can be applied to electronic devices capable of encoding / decoding images.

Claims

1. A method for decoding an image, the method comprising: Determines whether to apply merge mode to the current block; When the merge mode is applied to the current block, an initial motion vector of the current block is obtained from the merge candidate list of the current block; determining whether to apply a refinement of the initial motion vector to a current block; When applying the refinement of the initial motion vector to the current block, determining a motion refinement vector for the current block; as well as determining a motion vector of the current block based on the initial motion vector and the motion refinement vector, wherein the initial motion vector is obtained based on one of the merge candidates included in the merge candidate list, and Therein, the maximum size of the motion refinement vector varies according to the motion vector resolution of the motion refinement vector.

2. The method according to claim 1, wherein: The motion refinement vector is determined based on size information and direction information decoded from a bitstream.

3. The method according to claim 2, wherein: The size information specifies one of a plurality of size candidates, and The multiple size candidates are pre-defined in the decoding device.

4. The method according to claim 2, wherein: The direction information specifies one of four direction candidates, and The four direction candidates include a positive horizontal direction, a negative horizontal direction, a positive vertical direction and a negative vertical direction.

5. The method according to claim 1, wherein: Selecting one of the merge candidates for obtaining the initial motion vector by the merge index, and Among them, the number of merge candidates that can be selected by the merge index is different when refinement of the initial motion vector is applied to the current block and when refinement of the initial motion vector is not applied to the current block.

6. The method according to claim 5, wherein: When the refinement of the initial motion vector is applied to the current block, the number of merge candidates that can be selected by the merge index is 2.

7. The method according to claim 1, wherein: The motion vector is obtained as the sum of the initial motion vector and the motion refinement vector.

8. A method for encoding an image, the method comprising: encoding merge mode information indicating whether a merge mode is applied to a current block; When the merge mode is applied to the current block, an initial motion vector of the current block is obtained from the merge candidate list of the current block; encoding refinement information indicating whether to apply a refinement of the initial motion vector to a current block; When applying the refinement of the initial motion vector to the current block, determining a motion refinement vector for the current block; as well as determining a motion vector of the current block based on the initial motion vector and the motion refinement vector, wherein the initial motion vector is obtained based on one of the merge candidates included in the merge candidate list, and Therein, the maximum size of the motion refinement vector varies according to the motion vector resolution of the motion refinement vector.

9. The method according to claim 8, wherein: Size information and direction information for motion refinement vectors are encoded into the bitstream.

10. The method according to claim 9, wherein: The size information specifies one of a plurality of size candidates, and The multiple size candidates are pre-defined in the encoding device.

11. The method according to claim 9, wherein: The direction information specifies one of four direction candidates, and The four direction candidates include a positive horizontal direction, a negative horizontal direction, a positive vertical direction and a negative vertical direction.

12. The method according to claim 8, wherein: The number of selectable merge candidates of the current block is different when refinement of the initial motion vector is applied to the current block and when refinement of the initial motion vector is not applied to the current block.

13. The method according to claim 12, wherein: When the refinement of the initial motion vector is applied to the current block, the number of selectable merge candidates for the current block is 2.

14. The method according to claim 8, wherein: The motion vector is obtained as the sum of the initial motion vector and the motion refinement vector.

15. An apparatus for transmitting a bit stream, the apparatus comprising: One or more hardware configured to: A bit stream is obtained by encoding a video signal; as well as transmitting the bit stream, The encoding of the video signal includes: encoding merge mode information indicating whether a merge mode is applied to a current block; When the merge mode is applied to the current block, an initial motion vector of the current block is obtained from the merge candidate list of the current block; encoding refinement information indicating whether to apply a refinement of the initial motion vector to a current block; When applying the refinement of the initial motion vector to the current block, determining a motion refinement vector for the current block; and determining a motion vector of the current block based on the initial motion vector and the motion refinement vector, wherein the initial motion vector is obtained based on one of the merge candidates included in the merge candidate list, and Therein, the maximum size of the motion refinement vector varies according to the motion vector resolution of the motion refinement vector.

Citation Information

Patent Citations

  • Method and apparatus for video coding using prediction data refinement

    CN101711481A

  • Sub-prediction unit (PU) based temporal motion vector prediction in HEVC and sub-PU design in 3D-HEVC

    CN105580364A