EQUIPMENT FOR ENCODING AND DECODING VIDEO SIGNALS AND COMPUTER-READABLE MEDIA (NOT PERMANENT)

VN129337APending Publication Date: 2026-09-15ADVEXT IP LLC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
VN1202606671
Authority / Receiving Office
VN · VN
Patent Type
Applications
Current Assignee / Owner
Priority Date
2018-04-20
Filing Date
2019-03-27
Publication Date
2026-09-15

AI Technical Summary

Technical Problem

Current video signal processing methods for encoding and decoding struggle to enhance coding efficiency and prediction performance, particularly in utilizing reference samples for predicting video blocks, due to limitations in motion vector correction and signaling efficiency.

Method used

A method and device that utilize a merge index to select candidates for predicting video blocks, acquire motion information, compare Picture Order Count (POC) differences between reference pictures, and correct motion vectors based on these comparisons to improve prediction accuracy and efficiency.

Benefits of technology

This approach increases coding efficiency and improves prediction performance by accurately correcting motion vectors, leading to more effective video signal processing and encoding/decoding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure VN1202606671_0
    Figure VN1202606671_0
Patent Text Reader

Abstract

The invention relates to a method and apparatus for processing video signals used to encode or decode video signals. More specifically, the invention relates to a method for processing video signals comprising the following steps: acquiring a unified index representing a candidate for predicting the current block from among the candidates for predicting the current block, contained in a unified candidate list; acquiring motion information of the current block based on motion information corresponding to the candidate represented by the unified index; when the motion information of the current block includes motion vectors corresponding to a list of different reference images, comparing the differences in picture order count (POC) between each of the reference images corresponding to the motion vectors and the current image containing the current block; correcting the motion vectors based on the comparison results; and restoring the current block based on the corrected motion vectors.
Need to check novelty before this filing date? Find Prior Art

Description

Video signal processing method and device using motion compensation

[0001] The present invention relates to a method and device for processing a video signal, and more particularly, to a method and device for processing a video signal for encoding or decoding a video signal.

[0002] Compression coding refers to a series of signal processing techniques for transmitting digitized information over communication lines or storing it in a format suitable for storage media. Objects subject to compression coding include audio, video, and text, and the technology that performs compression coding on video in particular is called video compression. Compression coding of video signals is achieved by removing redundant information by considering spatial, temporal, and probabilistic correlations. However, with the recent advancements in various media and data transmission media, there is a growing demand for more efficient video signal processing methods and devices.

[0003] The present invention aims to improve the coding efficiency of a video signal. Furthermore, the present invention aims to improve signaling efficiency related to prediction of a current block by utilizing reference samples of the current block.

[0004] To solve the above-mentioned problems, the present invention provides the following video signal processing device and video signal processing method.

[0005] First, according to an embodiment of the present invention, a method for processing a video signal is provided, comprising: obtaining a merge index indicating a candidate for prediction of a current block among a plurality of candidates included in a merge candidate list for prediction of the current block; obtaining motion information of the current block based on motion information corresponding to the candidate indicated by the merge index; comparing a picture order count (POC) difference between each of reference pictures corresponding to each of the plurality of motion vectors and a current picture including the current block when the motion information of the current block includes a plurality of motion vectors corresponding to different reference picture lists; correcting the plurality of motion vectors based on a result of the comparison; and restoring the current block based on the corrected plurality of motion vectors.

[0006] In addition, according to an embodiment of the present invention, in a video signal processing device, a processor is provided, wherein the processor obtains a merge index indicating a candidate for prediction of the current block among a plurality of candidates included in a merge candidate list for prediction of the current block, obtains motion information of the current block based on motion information corresponding to the candidate indicated by the merge index, and, when the motion information of the current block includes a plurality of motion vectors corresponding to different reference picture lists, compares a picture order count (POC) difference between each of the reference pictures corresponding to each of the plurality of motion vectors and a current picture including the current block, corrects the plurality of motion vectors based on a result of the comparison, and reconstructs the current block based on the corrected plurality of motion vectors.

[0007] The plurality of motion vectors may include a first motion vector and a second motion vector. At this time, the processor may obtain a first POC difference and a second POC difference, compare the first POC difference and the second POC difference, obtain a specific offset which is a correction value of one of the first motion vector and the second motion vector, and correct the first motion vector and the second motion vector based on the specific offset. The first POC difference may indicate a POC difference between a first reference picture corresponding to the first motion vector and the current picture, and the second POC difference may indicate a POC difference between a second reference picture corresponding to the second motion vector and the current picture.

[0008] The processor may obtain the specific offset earlier than the correction value of the remaining one of the first motion vector and the second motion vector based on a result of comparing the first POC difference and the second POC difference.

[0009] If the first POC difference is greater than the second POC difference, the specific offset may be a correction value of the first motion vector, and if the first POC difference is less than the second POC difference, the specific offset may be a correction value of the second motion vector.

[0010] If the first POC difference is greater than the second POC difference, the specific offset may be a first offset, which is a correction value of the first motion vector. In this case, the processor may correct the first motion vector by adding the first offset, obtain a second offset, which is a correction value of the second motion vector, based on the specific offset, and correct the second motion vector by adding the second offset.

[0011] The processor can generate a first corrected motion vector by adding the first offset to the first motion vector, generate a second corrected motion vector by adding the second offset to the second motion vector, and restore the current block based on the first corrected motion vector and the second corrected motion vector.

[0012] The processor may obtain a specific offset, which is a correction value for one of the first motion vector and the second motion vector, based on a value representing a reference picture list corresponding to each of the first motion vector and the second motion vector, when the first POC difference and the second POC difference are the same.

[0013] The processor can obtain a specific offset, which is a correction value of the first motion vector, when a value indicating a first reference picture list corresponding to the first motion vector is 0 and a value indicating a second reference picture list of the second motion vector is 1.

[0014] The first reference picture list is used in a first upper level area in which at most one motion vector is used for a specific sample and a second upper level area in which at most two motion vectors are used for a specific sample, and the second reference picture list may not be used in the first upper level area.

[0015] According to embodiments of the present invention, the coding efficiency of a video signal can be increased. Furthermore, according to embodiments of the present invention, the prediction performance of inter prediction of the current block can be improved.

[0016] FIG. 1 is a schematic block diagram of a video signal encoding device according to an embodiment of the present invention.

[0017] FIG. 2 is a schematic block diagram of a video signal decoding device according to an embodiment of the present invention.

[0018] Figure 3 illustrates an embodiment in which a coding tree unit within a picture is divided into coding units.

[0019] Figure 4 illustrates one embodiment of a method for signaling the splitting of a quad tree and a multi-type tree.

[0020] Figures 5 and 6 illustrate an intra prediction method according to an embodiment of the present invention.

[0021] Figure 7 illustrates an inter prediction method according to one embodiment of the present invention.

[0022] Figure 8 illustrates a pair prediction method according to one embodiment of the present invention.

[0023] FIG. 9 is a diagram illustrating a method for constructing a merge candidate list according to one embodiment of the present invention.

[0024] FIG. 10 is a drawing showing a method for correcting a motion vector according to one embodiment of the present invention.

[0025] FIG. 11 is a drawing showing a method for correcting a motion vector according to another embodiment of the present invention.

[0026] FIG. 12 is a diagram illustrating motion vector scaling of a candidate included in the MVP candidate list of the current block according to one embodiment of the present invention.

[0027] FIG. 13 is a drawing showing a method for correcting a motion vector according to one embodiment of the present invention.

[0028] FIG. 14 is a diagram showing a search position for correcting a motion vector based on an initial motion vector according to one embodiment of the present invention.

[0029] FIG. 15 is a drawing showing a method for configuring a template for motion vector correction according to one embodiment of the present invention.

[0030] FIG. 16 is a flowchart illustrating a method for correcting a motion vector according to one embodiment of the present invention.

[0031] FIG. 17 is a flowchart illustrating a method for correcting a motion vector according to another embodiment of the present invention.

[0032] FIG. 18 is a diagram illustrating a weighted prediction method using one motion information set according to one embodiment of the present invention.

[0033] FIG. 19 is a diagram illustrating a weighted prediction method of a bi-predicted block according to one embodiment of the present invention.

[0034] FIG. 20 is a flowchart illustrating a method by which a decoder predicts a current block using weighted prediction according to one embodiment of the present invention.

[0035] FIG. 21 is a diagram illustrating a method for updating a set of weighted parameters applied to a reference block when a current block is unidirectionally predicted according to one embodiment of the present invention.

[0036] FIG. 22 is a diagram illustrating a method for predicting a current block based on an additionally searched reference block according to one embodiment of the present invention.

[0037] FIG. 23 is a diagram illustrating a method for updating a set of weighted parameters applied to a reference block when the current block is a bi-predicted block according to one embodiment of the present invention.

[0038] FIG. 24 is a diagram illustrating a method for predicting a current block based on an additionally searched reference block when the current block is a bi-predicted block according to one embodiment of the present invention.

[0039] FIG. 25 is a diagram illustrating a method for predicting a current block based on an additionally searched reference block when the current block is a bi-predicted block according to another embodiment of the present invention.

[0040] Fig. 26 is a drawing showing a template matching method according to one embodiment of the present invention.

[0041] Figure 27 is a diagram showing whether or not a sign matches and a decision according to one embodiment of the present invention.

[0042] FIG. 28 and FIG. 29 are diagrams showing a method of encoding sign information considering context according to one embodiment of the present invention.

[0043] FIG. 30 is a diagram illustrating a method for predicting based on different sets of motion information for each region segmented from a current block according to one embodiment of the present invention.

[0044] FIG. 31 is a diagram illustrating a method for performing intra prediction or inter prediction for each region segmented from a current block according to one embodiment of the present invention.

[0045] The terms used in this specification have been selected from widely used and current terms, taking into account the functions of the present invention. However, these terms may vary depending on the intentions of those skilled in the art, customs, or the emergence of new technologies. Furthermore, in certain cases, the applicant may arbitrarily select terms, in which case their meanings will be described in the description of the relevant invention. Therefore, it should be noted that the terms used in this specification should be interpreted based on their substantive meaning and the overall content of this specification, rather than simply their names.

[0046] In this specification, some terms may be interpreted as follows. Coding may be interpreted as encoding or decoding, depending on the case. In this specification, a device that encodes (encodes) a video signal to generate a video signal bitstream is referred to as an encoding device or encoder, and a device that decodes (decodes) a video signal bitstream to restore a video signal is referred to as a decoding device or decoder. In addition, in this specification, a video signal processing device is used as a term that includes both an encoder and a decoder. Information is a term that includes values, parameters, coefficients, elements, etc., and since the meaning may be interpreted differently depending on the case, the present invention is not limited thereto. 'Unit' is used to mean a basic unit of image processing or a specific location of a picture, and refers to an image area that includes both a luma component and a chroma component. In addition, 'block' refers to an image area that includes a specific component among luma components and chroma components (i.e., Cb and Cr). However, depending on the embodiment, the terms 'unit', 'block', 'partition', and 'area' may be used interchangeably. In addition, in this specification, a unit may be used as a concept that includes all of a coding unit, a prediction unit, and a transformation unit. A picture refers to a field or a frame, and depending on the embodiment, the above terms may be used interchangeably.

[0047] Fig. 1 is a schematic block diagram of a video signal encoding device according to one embodiment of the present invention. Referring to Fig. 1, the encoding device (100) of the present invention includes a transformation unit (110), a quantization unit (115), an inverse quantization unit (120), an inverse transformation unit (125), a filtering unit (130), a prediction unit (150), and an entropy coding unit (160).

[0048] The transform unit (110) obtains a transform coefficient value by transforming the residual signal, which is the difference between the input video signal and the prediction signal generated by the prediction unit (150). For example, a discrete cosine transform (DCT), a discrete sine transform (DST), or a wavelet transform may be used. The discrete cosine transform and the discrete sine transform divide the input picture signal into blocks and perform the transformation. In the transformation, the coding efficiency may vary depending on the distribution and characteristics of the values ​​within the transformation area. The quantization unit (115) quantizes the transform coefficient value output from the transform unit (110).

[0049] In order to increase coding efficiency, rather than coding the picture signal as it is, a method is used to predict a picture using an already coded area through a prediction unit (150), and to obtain a restored picture by adding the residual value between the original picture and the predicted picture to the predicted picture. In order to prevent mismatches from occurring in the encoder and decoder, when the encoder performs prediction, information that is also available to the decoder must be used. To this end, the encoder performs a process of restoring the encoded current block. The inverse quantization unit (120) inversely quantizes the transform coefficient value, and the inverse transform unit (125) restores the residual value using the inverse quantized transform coefficient value. Meanwhile, the filtering unit (130) performs a filtering operation to improve the quality of the restored picture and enhance the coding efficiency. For example, a deblocking filter, a sample adaptive offset (SAO), and an adaptive loop filter may be included. The filtered picture is stored in the Decoded Picture Buffer (DPB, 156) to be output or used as a reference picture.

[0050] The prediction unit (150) includes an intra prediction unit (152) and an inter prediction unit (154). The intra prediction unit (152) performs intra prediction within a current picture, and the inter prediction unit (154) performs inter prediction to predict the current picture using a reference picture stored in a decoded picture buffer (156). The intra prediction unit (152) performs intra prediction from reconstructed samples within the current picture and transfers intra encoding information to the entropy coding unit (160). The intra encoding information may include at least one of an intra prediction mode, an MPM (Most Probable Mode) flag, and an MPM index. The inter prediction unit (154) may be configured to include a motion estimation unit (154a) and a motion compensation unit (154b). The motion estimation unit (154a) obtains a motion vector value of the current region by referring to a specific region of the reconstructed reference picture. The motion estimation unit (154a) transmits a motion information set (reference picture index, motion vector information, etc.) for the reference region to the entropy coding unit (160). The motion compensation unit (154b) performs motion compensation using the motion vector value transmitted from the motion estimation unit (154a). The inter prediction unit (154) transmits inter encoding information including the motion information set for the reference region to the entropy coding unit (160).

[0051] When the picture prediction as above is performed, the transformation unit (110) obtains a transformation coefficient value by transforming the residual value between the original picture and the predicted picture. At this time, the transformation can be performed in units of specific blocks within the picture, and the size of the specific block can be varied within a preset range. The quantization unit (115) quantizes the transformation coefficient value generated by the transformation unit (110) and transmits it to the entropy coding unit (160).

[0052] The entropy coding unit (160) entropy codes quantized transform coefficients, intra-coding information, inter-coding information, etc. to generate a video signal bitstream. The entropy coding unit (160) may use a variable length coding (VLC) method and an arithmetic coding method. The variable length coding (VLC) method converts input symbols into continuous codewords, and the length of the codewords may be variable. For example, frequently occurring symbols are expressed as short codewords, and infrequently occurring symbols are expressed as long codewords. As a variable length coding method, a context-based adaptive variable length coding (CAVLC) method may be used. Arithmetic coding converts continuous data symbols into a single prime number, and arithmetic coding can obtain the optimal prime number bits required to express each symbol. As an arithmetic coding, a context-based adaptive binary arithmetic code (CABAC) may be used.

[0053] The above generated bitstream is encapsulated as a basic unit of a Network Abstraction Layer (NAL) unit. A NAL unit includes an integer number of encoded coding tree units. In order to decode a bitstream in a video decoder, the bitstream must first be divided into NAL units, and then each divided NAL unit must be decoded. Meanwhile, information required for decoding a video signal bitstream can be transmitted through a Raw Byte Sequence Payload (RBSP) of a higher-level set, such as a Picture Parameter Set (PPS), a Sequence Parameter Set (SPS), or a Video Parameter Set (VPS).

[0054] Meanwhile, the block diagram of FIG. 1 illustrates an encoding device (100) according to one embodiment of the present invention, and the blocks shown separately logically distinguish elements of the encoding device (100). Accordingly, the elements of the encoding device (100) described above may be mounted as one chip or as multiple chips depending on the design of the device. According to one embodiment, the operations of each element of the encoding device (100) described above may be performed by a processor (not shown).

[0055] Fig. 2 is a schematic block diagram of a video signal decoding device (200) according to one embodiment of the present invention. Referring to Fig. 2, the decoding device (200) of the present invention includes an entropy decoding unit (210), an inverse quantization unit (220), an inverse transformation unit (225), a filtering unit (230), and a prediction unit (250).

[0056] The entropy decoding unit (210) entropy decodes the video signal bitstream to extract transform coefficients, intra-coding information, inter-coding information, etc. for each region. The inverse quantization unit (220) inversely quantizes the entropy-decoded transform coefficients, and the inverse transform unit (225) restores the residual value using the inverse quantized transform coefficients. The video signal processing device (200) restores the original pixel value by adding the residual value obtained from the inverse transform unit (225) with the predictor obtained from the prediction unit (250).

[0057] Meanwhile, the filtering unit (230) performs filtering on the picture to improve the image quality. This may include a deblocking filter to reduce block distortion and / or an adaptive loop filter to remove distortion from the entire picture. The filtered picture is output or stored in the decoded picture buffer (DPB, 256) to be used as a reference picture for the next picture.

[0058] The prediction unit (250) includes an intra prediction unit (252) and an inter prediction unit (254). The prediction unit (250) generates a prediction picture by utilizing the encoding type decoded through the entropy decoding unit (210) described above, the transform coefficients for each region, intra / inter encoding information, etc. In order to restore the current block in which decoding is performed, the decoded region of the current picture or other pictures including the current block may be used. A picture (or tile / slice) that uses only the current picture for restoration, i.e., performs only intra prediction, is called an intra picture or I picture (or tile / slice), and a picture (or tile / slice) that can perform both intra prediction and inter prediction is called an inter picture (or tile / slice). A picture (or tile / slice) that uses at most one motion vector and reference picture index to predict sample values ​​of each block among inter-pictures (or tiles / slices) is called a predictive picture or P-picture (or tile / slice), and a picture (or tile / slice) that uses at most two motion vectors and reference picture indices is called a bi-predictive picture or B-picture (or tile / slice). In other words, a P-picture (or tile / slice) uses at most one motion information set to predict each block, and a B-picture (or tile / slice) uses at most two motion information sets to predict each block. Here, a motion information set includes one or more motion vectors and one reference picture index.

[0059] The intra prediction unit (252) generates a prediction block using intra encoding information and reconstructed samples within the current picture. As described above, the intra encoding information may include at least one of an intra prediction mode, a Most Probable Mode (MPM) flag, and an MPM index. The intra prediction unit (252) predicts sample values ​​of the current block using reconstructed samples located on the left and / or above the current block as reference samples. In the present disclosure, the reconstructed samples, the reference samples, and the samples of the current block may represent pixels. Additionally, the sample values ​​may represent pixel values.

[0060] According to one embodiment, the reference samples may be samples included in a neighboring block of the current block. For example, the reference samples may be samples adjacent to a left boundary of the current block and / or samples adjacent to an upper boundary. In addition, the reference samples may be samples located on a line within a preset distance from a left boundary of the current block and / or samples located on a line within a preset distance from an upper boundary of the current block among samples of neighboring blocks of the current block. In this case, the neighboring blocks of the current block may include at least one of a left (L) block, an upper (A) block, a lower left (BL) block, an above right (AR) block, or an above left (AL) block adjacent to the current block.

[0061] The inter prediction unit (254) generates a prediction block using the reference picture and inter encoding information stored in the decoded picture buffer (256). The inter encoding information may include a set of motion information (reference picture index, motion vector information, etc.) of the current block with respect to the reference block. Inter prediction may include L0 prediction, L1 prediction, and bi-prediction. L0 prediction is prediction using one reference picture included in the L0 picture list, and L1 prediction means prediction using one reference picture included in the L1 picture list. For this, one set of motion information (e.g., motion vector and reference picture index) may be required. In the bi-prediction method, up to two reference areas can be used, and these two reference areas may exist in the same reference picture or may exist in different pictures, respectively. That is, in the bi-prediction method, up to two sets of motion information (e.g., motion vectors and reference picture indices) can be used, and the two motion vectors may correspond to the same reference picture index or different reference picture indices. In this case, the reference pictures can be displayed (or output) either temporally before or after the current picture.

[0062] The inter prediction unit (254) can obtain a reference block of the current block using a motion vector and a reference picture index. The reference block exists in a reference picture corresponding to the reference picture index. In addition, a sample value of a block specified by the motion vector or an interpolated value thereof can be used as a predictor of the current block. For motion prediction with sub-pel unit pixel accuracy, for example, an 8-tap interpolation filter can be used for a luma signal and a 4-tap interpolation filter can be used for a chroma signal. However, the interpolation filter for sub-pel unit motion prediction is not limited thereto. In this way, the inter prediction unit (254) performs motion compensation to predict the texture of the current unit from a previously restored picture. At this time, the inter prediction unit can use a motion information set.

[0063] A restored video picture is generated by adding the predictor output from the intra prediction unit (252) or inter prediction unit (254) and the residual value output from the inverse transformation unit (225). That is, the video signal decoding device (200) restores the current block using the prediction block generated from the prediction unit (250) and the residual obtained from the inverse transformation unit (225).

[0064] Meanwhile, the block diagram of FIG. 2 illustrates a decoding device (200) according to one embodiment of the present invention, and the blocks shown separately logically distinguish the elements of the decoding device (200). Accordingly, the elements of the aforementioned decoding device (200) may be mounted as one chip or as multiple chips depending on the design of the device. According to one embodiment, the operations of each element of the aforementioned decoding device (200) may be performed by a processor (not shown).

[0065] FIG. 3 illustrates an embodiment in which a Coding Tree Unit (CTU) within a picture is divided into Coding Units (CUs). During the coding process of a video signal, a picture may be divided into a sequence of Coding Tree Units (CTUs). A Coding Tree Unit consists of NXN blocks of luma samples and two blocks of corresponding chroma samples. A Coding Tree Unit may be divided into multiple Coding Units. A Coding Tree Unit may not be divided and may become a leaf node. In this case, the Coding Tree Unit itself may become a Coding Unit. A Coding Unit refers to a basic unit for processing a picture in the video signal processing process described above, such as intra / inter prediction, transformation, quantization, and / or entropy coding. The size and shape of a Coding Unit within a picture may not be constant. A Coding Unit may have a square or rectangular shape. A rectangular coding unit (or rectangular block) includes a vertical coding unit (or vertical block) and a horizontal coding unit (or horizontal block). In this specification, a vertical block is a block whose height is greater than its width, and a horizontal block is a block whose width is greater than its height. In addition, a non-square block in this specification may refer to a rectangular block, but the present invention is not limited thereto.

[0066] Referring to Fig. 3, the coding tree unit is first partitioned into a Quad Tree (QT) structure. That is, in the Quad Tree structure, one node with a size of 2NX2N can be partitioned into four nodes with a size of NXN. In this specification, the Quad Tree may also be referred to as a quaternary tree. The Quad Tree partitioning can be performed recursively, and not all nodes need to be partitioned to the same depth.

[0067] Meanwhile, the leaf node of the aforementioned quad tree can be further divided into a multi-type tree (MTT) structure. According to an embodiment of the present invention, in the multi-type tree structure, one node can be divided into a binary or ternary tree structure of horizontal or vertical division. That is, the multi-type tree structure has four division structures: vertical binary division, horizontal binary division, vertical ternary division, and horizontal ternary division. According to an embodiment of the present invention, in each of the above tree structures, the width and height of the node can both have a power of 2 value. For example, in the binary tree (BT) structure, a node of size 2NX2N can be divided into two NX2N nodes by vertical binary division, and can be divided into two 2NXN nodes by horizontal binary division. Also, in a Ternary Tree (TT) structure, a node of size 2NX2N can be split into nodes of size (N / 2)X2N, NX2N, and (N / 2)X2N by vertical ternary splitting, and into nodes of size 2NX(N / 2), 2NXN, and 2NX(N / 2) by horizontal ternary splitting. This multi-type tree splitting can be performed recursively.

[0068] A leaf node of a multi-type tree can be a coding unit. If no splitting is indicated for a coding unit or the coding unit is not larger than the maximum transformation length, the coding unit is used as a unit for prediction and transformation without further splitting. Meanwhile, in the quad tree and multi-type tree described above, at least one of the following parameters may be predefined or transmitted via a RBSP of a higher-level set, such as a PPS, SPS, or VPS. 1) CTU size: The size of the root node of the quad tree, 2) MinQtSize: The minimum allowed QT leaf node size, 3) MaxBtSize: The maximum allowed BT root node size, 4) MaxTT size (MaxTtSize): The maximum allowed TT root node size, 5) MaxMttDepth: The maximum allowed depth of an MTT split from a leaf node of a QT, 6) MinBT size (MinBtSize): The minimum allowed BT leaf node size, 7) MinTT size (MinTtSize): The minimum allowed TT leaf node size.

[0069] Fig. 4 illustrates one embodiment of a method for signaling splitting of a quad tree and a multi-type tree. Pre-configured flags may be used to signal splitting of the quad tree and the multi-type tree described above. Referring to Fig. 4, at least one of a flag 'qt_split_flag' indicating whether to split a quad tree node, a flag 'mtt_split_flag' indicating whether to split a multi-type tree node, a flag 'mtt_split_vertical_flag' indicating a splitting direction of a multi-type tree node, or a flag 'mtt_split_binary_flag' indicating a splitting shape of a multi-type tree node may be used.

[0070] According to an embodiment of the present invention, a coding tree unit is a root node of a quad tree and can be first split into a quad tree structure. In the quad tree structure, 'qt_split_flag' is signaled for each node 'QT_node'. If the value of 'qt_split_flag' is 1, the node is split into four square nodes, and if the value of 'qt_split_flag' is 0, the node becomes a leaf node 'QT_leaf_node' of the quad tree.

[0071] Each quad tree leaf node 'QT_leaf_node' can be further split into a multi-type tree structure. In the multi-type tree structure, 'mtt_split_flag' is signaled for each node 'MTT_node'. If the value of 'mtt_split_flag' is 1, the node is split into multiple rectangular nodes, and if the value of 'mtt_split_flag' is 0, the node becomes a leaf node 'MTT_leaf_node' of the multi-type tree. If the multi-type tree node 'MTT_node' is split into multiple rectangular nodes (i.e., if the value of 'mtt_split_flag' is 1), 'mtt_split_vertical_flag' and 'mtt_split_binary_flag' for the node 'MTT_node' can be additionally signaled. If the value of 'mtt_split_vertical_flag' is 1, vertical splitting of node 'MTT_node' is indicated, and if the value of 'mtt_split_vertical_flag' is 0, horizontal splitting of node 'MTT_node' is indicated. In addition, if the value of 'mtt_split_binary_flag' is 1, node 'MTT_node' is split into two rectangular nodes, and if the value of 'mtt_split_binary_flag' is 0, node 'MTT_node' is split into three rectangular nodes.

[0072] Figures 5 and 6 illustrate an intra prediction method according to an embodiment of the present invention. As described above, the intra prediction unit predicts sample values ​​of the current block using restored samples located to the left and / or above the current block as reference samples.

[0073] First, FIG. 5 illustrates an embodiment of reference samples used for prediction of a current block in an intra prediction mode. According to an embodiment, the reference samples may be samples adjacent to a left boundary of the current block and / or samples adjacent to an upper boundary. As illustrated in FIG. 5, when the size of the current block is WXH and samples of a single reference line adjacent to the current block are used for intra prediction, reference samples may be set using at most 2W+2H+1 surrounding samples located on the left and / or upper sides of the current block.

[0074] According to a further embodiment of the present invention, samples on a plurality of reference lines may be used for intra prediction of a current block. The plurality of reference lines may be composed of n lines located within a preset distance from the boundary of the current block. In this case, separate reference line information indicating at least one reference line used for intra prediction of the current block may be signaled. Specifically, the reference line information may include an index indicating any one of the plurality of reference lines. In addition, if at least some of the samples to be used as reference samples have not yet been reconstructed, the intra prediction unit may perform a reference sample padding process to obtain the reference sample. In addition, the intra prediction unit may perform a reference sample filtering process to reduce an error in intra prediction. That is, filtering may be performed on neighboring samples and / or reference samples obtained by the reference sample padding process to obtain filtered reference samples. The intra prediction unit predicts samples of the current block using unfiltered reference samples or filtered reference samples. In the present disclosure, the neighboring samples may include samples on at least one reference line. For example, the surrounding samples may include adjacent samples on a line adjacent to the boundary of the current block.

[0075] Next, FIG. 6 illustrates an embodiment of prediction modes used for intra prediction. For intra prediction, intra prediction mode information indicating an intra prediction direction may be signaled. The intra prediction mode information indicates any one of a plurality of intra prediction modes constituting an intra prediction mode set. If the current block is an intra-predicted block, the decoder receives intra prediction mode information of the current block from the bitstream. The intra prediction unit of the decoder performs intra prediction on the current block based on the extracted intra prediction mode information.

[0076] According to an embodiment of the present invention, an intra-prediction mode set may include all intra-prediction modes used for intra-prediction (e.g., a total of 67 intra-prediction modes). More specifically, the intra-prediction mode set may include a planar mode, a DC mode, and a plurality of (e.g., 65) angular modes (i.e., directional modes). In some embodiments, the intra-prediction mode set may be composed of some of all intra-prediction modes. Each intra-prediction mode may be indicated by a preset index (i.e., an intra-prediction mode index). For example, as illustrated in FIG. 6, an intra-prediction mode index 0 indicates a planar mode, and an intra-prediction mode index 1 indicates a DC mode. In addition, intra-prediction mode indexes 2 to 66 may indicate different angular modes, respectively. At this time, intra prediction mode index 2 indicates horizontal diagonal (HDIA) mode, intra prediction mode index 18 indicates horizontal (HOR) mode, intra prediction mode index 34 indicates diagonal (DIA) mode, intra prediction mode index 50 indicates vertical (VER) mode, and intra prediction mode index 66 indicates vertical diagonal (VDIA) mode.

[0077] FIG. 7 illustrates an inter prediction method according to an embodiment of the present invention. As described above, the decoder can predict the current block by referring to the reconstructed samples of another decoded picture. Referring to FIG. 7, the decoder obtains a reference block (702) in a reference picture (720) based on a motion information set of a current block (701). At this time, the motion information set may include a reference picture index (ref_idx_lx) and a motion vector (MV). The reference picture index (ref_idx_lx) indicates a reference picture (720) that includes a reference block for inter prediction of the current block in the reference picture list (lx). The motion vector (MV) represents an offset between the coordinate value of the current block (701) in the current picture (710) and the coordinate value of the reference block (702) in the reference picture (720). The decoder obtains a predictor of the current block (701) based on the sample values ​​of the reference block (702) and reconstructs the current block (701) using the predictor.

[0078] Specifically, the encoder can obtain the aforementioned reference block by searching for a block similar to the current block in pictures that are earlier in the restoration order. For example, the encoder can search for a reference block that minimizes the sum of the sample value differences from the current block within a preset search area. At this time, at least one of the Sum of Absolute Difference (SAD) or the Sum of Hadamard Transformed Difference (SATD) can be used to measure the similarity between the samples of the current block and the reference block. Here, the SAD can be a value obtained by adding all the absolute values ​​of the differences between the sample values ​​included in the two blocks. In addition, the SATD can be a value obtained by adding all the absolute values ​​of the Hadamard transform coefficients obtained by performing a Hadamard transform on the differences between the sample values ​​included in the two blocks.

[0079] Meanwhile, the current block may be predicted using one or more reference regions. As described above, the current block may be inter-predicted using a bi-prediction method using up to two reference regions. Fig. 8 illustrates a bi-prediction method according to an embodiment of the present invention. Referring to Fig. 8, the decoder may obtain two reference blocks (802, 803) based on two sets of motion information of the current block (801). In addition, the decoder may obtain a first predictor and a second predictor of the current block based on the sample values ​​of the two obtained reference blocks, respectively. In addition, the decoder may reconstruct the current block (801) using the first predictor and the second predictor.

[0080] According to one embodiment, the decoder can reconstruct the current block (801) based on the sample-wise average of the first predictor and the second predictor. According to another embodiment, the decoder can reconstruct the current block (801) by applying different weight values ​​to each of the first predictor and the second predictor. In this case, whether or not to use the weight values ​​can be signaled through the PPS or the SPS. The weight values ​​and offset values ​​used for predicting the current block (801) can be transmitted on a slice / tile basis through the slice / tile header. Alternatively, the weight values ​​and offset values ​​used for predicting the current block (801) can be transmitted on a coding unit basis. A method for predicting the current block using weight values ​​will be described later with reference to FIGS. 18 to 25.

[0081] As described above, one or more motion information sets may be signaled for motion compensation of the current block. In a method for signaling the motion information set of the current block, redundancy between the motion information sets used for motion compensation of each of the plurality of blocks may be utilized. This is because the motion information set used for prediction of the current block may be derived from the motion information set used for prediction of any of the other previously reconstructed samples.

[0082] For example, there may be a plurality of candidate blocks that are likely to have been predicted based on a motion information set that is identical or similar to the motion information set of the current block. The decoder may generate a merge candidate list based on the plurality of candidate blocks. Here, the merge candidate list may include candidates corresponding to samples that are likely to have been predicted based on a motion information set related to the motion information set of the current block, among samples reconstructed before the current block. The encoder and the decoder may construct a merge candidate list of the current block according to predefined rules. At this time, the merge candidate lists constructed by the encoder and the decoder respectively may be identical. For example, the encoder and the decoder may construct a merge candidate list of the current block based on the position of the current block within the current picture. A method by which the encoder and the decoder construct the merge candidate list of the current block will be described later with reference to FIG. 9. In the present disclosure, the position of a specific block indicates the relative position of the top-left sample of the specific block within a picture including the specific block.

[0083] According to one embodiment, when a current block is predicted using a merge candidate list, the current block can be reconstructed based on a set of motion information corresponding to any one of the candidates included in the merge candidate list. For example, a motion vector of the current block can be obtained based on a motion vector of any one of the candidates included in the merge candidate list. Additionally, a reference picture to be referred to for prediction of the current block can be obtained based on a reference picture list and a reference picture index corresponding to any one of the candidates.

[0084] Specifically, a merge index indicating any one of a plurality of candidates included in a merge candidate list may be signaled. The decoder may receive the signaled merge index from the encoder. The decoder may perform motion compensation of the current block based on a motion information set corresponding to the candidate indicated by the merge index. The candidate indicated by the merge index may be referred to as a merge target. The decoder may obtain a motion information set of the current block based on the motion information set corresponding to the merge target. That is, motion compensation of the current block may be performed based on a reference picture index of the merge target and a motion vector of the merge target. Through this, the encoder and the decoder may reduce motion information signaling overhead.

[0085] According to one embodiment, a prediction method using a merge candidate list may be divided into skip mode and merge mode. For example, if the prediction method of the current block is skip mode, the residual signal of the current block may not be signaled. In this case, the decoder can reconstruct the current block based on a predictor of the current block generated based on the merge index. If the prediction method of the current block is merge mode, the merge index and the residual signal may be signaled from the encoder. In this case, the decoder can reconstruct the current block based on the merge index and the residual signal of the current block. The decoder can generate a predictor of the current block based on a set of motion information of a merge target indicated by the merge index of the current block. Next, the decoder can reconstruct the current block based on the generated predictor of the current block and the received residual signal.

[0086] Hereinafter, a method for constructing a merge candidate list according to an embodiment of the present invention will be described in detail with reference to FIG. 9. FIG. 9 is a diagram illustrating a method for constructing a merge candidate list according to an embodiment of the present invention. According to an embodiment, the merge candidate list may include at least one of a spatial candidate and a temporal candidate. Here, the spatial candidate may indicate a candidate constructed based on neighboring blocks of the current block. This is because the motion information set for the current block may be identical to or similar to the motion information set used for prediction of any one of the neighboring blocks of the current block. In the present disclosure, the spatial candidate or the temporal candidate may be referred to as a block corresponding to each other, respectively.

[0087] Referring to FIG. 9, a spatial candidate of a merge candidate list may be constructed based on available neighboring blocks (A0, A1, B0, B1, B2) corresponding to preset positions among neighboring blocks adjacent to the current block. Specifically, the spatial candidate of the merge candidate list may include at least one of a lower left block (A0), a left block (A1), an upper right block (B0), an upper block (B1), or an upper left block (B2). At this time, the decoder may sequentially search A1, B1, B0, A0, and B2 to construct up to four spatial candidates. In addition, if a specific block among the neighboring blocks has been intra-predicted, a specific block does not exist, or a prediction mode of a specific block is not available, the block may be set as not available.

[0088] For example, if A1 is not available, the decoder may not include A1 in the merge candidate list. Next, the decoder may determine whether B1 is available. If B1 is available, the decoder may construct a merge candidate list including B1. The decoder may search the remaining neighboring blocks (B0, A0, B2) so that the merge candidate list of the current block includes up to four spatial candidates. In addition, the motion information set of a specific neighboring block may be identical to the motion information sets of other neighboring blocks that were searched before the specific neighboring block and are included in the merge candidate list. In this case, the decoder may not include the neighboring block in the merge candidate list.

[0089] As described above, the merge candidate list may include temporal candidates. The temporal candidates may represent candidates constructed based on blocks corresponding to the location of the current block within a picture other than the current picture. This is because the motion information set for the current block may be identical or similar to the motion information set used to predict blocks contained in other pictures. For example, the picture other than the current picture may be a preset reference picture (R0). The preset reference picture (R0) may be signaled through a header of a higher level that includes the current block. Here, the higher level may represent a slice / tile, a picture, or a CTU or CTB (coding tree block) that includes the current block. Specifically, the encoder may insert a reference picture index indicating the preset reference picture (R0) in a specific reference picture list into the header of the higher level.

[0090] Referring to FIG. 9, a temporal candidate may include either a co-located block (C3) corresponding to the same position as the position of the current block in the current picture within the preset reference picture (R0) or a lower right block (H) of the co-located block (C3). At this time, the decoder may search H preferentially over C3. For example, if H is not available, the decoder may not include H in the merge candidate list. Next, the decoder may determine whether C3 is available. Furthermore, if C3 is available, the decoder may construct a merge candidate list including C3. On the other hand, if H is available, the decoder may not perform an operation of determining whether C3 is available. That is, the merge candidate list may include at most one temporal candidate.

[0091] In addition, the decoder can scale the motion vector of the temporal candidate and use it as the motion vector of the current block. The decoder can scale the motion vector of the temporal candidate according to the temporal distance between reference pictures. This is because the candidate block corresponding to the temporal candidate belongs to a different picture from the current block. Specifically, the decoder can obtain a first value (td) obtained by subtracting the POC of the picture referenced for prediction of the temporal candidate from the picture order count (POC) of the picture including the temporal candidate. The decoder can obtain a second value (tb) obtained by subtracting the POC of the reference picture to be referenced for prediction of the current picture from the POC of the current picture. In addition, the decoder can scale the motion vector of the temporal candidate based on the first value (td) and the second value (tb). At this time, the decoder can perform the operation in a fixed-point manner using an offset value and a shift operation. This allows the decoder to avoid using division operations.

[0092] According to one embodiment, if the sum of the number of spatial candidates and the number of temporal candidates is less than the maximum number of candidates that the merge candidate list can include, the decoder may include a candidate corresponding to an additional prediction method in the merge candidate list. In this case, the maximum number of merge candidates constituting the merge candidate list may be signaled through a higher-level header including the current block. According to one embodiment, a separate motion information list including motion information sets used in blocks reconstructed before the current block may be managed. Specifically, the motion information list may include motion information sets used for each of a plurality of blocks reconstructed before the current block in the current picture. In this case, the decoder may use at least some of the motion information sets included in the motion information list as candidates for the merge candidate list.

[0093] In another embodiment, the decoder may select two candidates in a preset order from among the candidates included in the merge candidate list. Furthermore, the decoder may generate an average motion vector based on the average of the motion vectors used for prediction of each of the two selected candidates. The decoder may generate an average motion information set based on the average motion vector. Furthermore, the decoder may use the generated average motion information set as a candidate in the merge candidate list.

[0094] In another embodiment, the decoder can combine unidirectional prediction information to generate bidirectional prediction information. Specifically, if there are multiple candidates predicted based on unidirectional prediction information, the decoder can generate bidirectional prediction information by combining the unidirectional prediction information of the candidates. Furthermore, the decoder can add the generated bidirectional prediction information to a merge candidate list. Furthermore, the decoder can include a candidate corresponding to a zero motion vector in the merge candidate list.

[0095] As described above, an encoder and a decoder according to an embodiment can reduce the overhead for signaling motion information by using a merge candidate list and a merge index. However, it may be difficult to accurately express the motion of a current block with the motion vectors of the merge candidates included in the merge candidate list. According to an embodiment of the present invention, a motion vector corrected from the motion vector of a merge candidate indicated by a merge index can be used as the motion vector of the current block. Through this, the encoder and the decoder can improve the prediction performance of a prediction method using a merge candidate list. Hereinafter, a method for correcting a motion vector of a current block according to an embodiment of the present invention will be described in detail.

[0096] According to one embodiment of the present invention, a decoder can correct a motion vector of a current block. For example, if the current block is predicted using a merge candidate list, the decoder can correct the motion vector of the current block. At this time, the motion vector of the current block may be a merge motion vector obtained from a motion vector of a merge target. In the present disclosure, the merge motion vector may represent a motion vector of the current block obtained from a motion information set corresponding to the merge target. The decoder can correct the merge motion vector to generate a corrected motion vector. In addition, the decoder can predict the current block based on the corrected motion vector.

[0097] In one embodiment, the merged motion vector may be compensated based on a motion vector offset. Here, the motion vector offset represents the difference between the motion vector before compensation and the compensated motion vector. For example, the decoder may generate a compensated motion vector by adding the motion vector offset to the merged motion vector. The motion vector offset may be signaled or derived according to a preset rule.

[0098] According to one embodiment, information indicating a motion vector offset may be signaled separately. In this case, the information indicating the motion vector offset may include at least one of an absolute value of the motion vector offset and a sign of the motion vector offset. The absolute value of the motion vector offset may represent a distance between a motion vector before correction and a motion vector after correction. Specifically, the absolute value of the motion vector offset may be obtained through a distance index. For example, the encoder may signal a distance index corresponding to a specific distance based on a table predefined between the encoder and the decoder. Additionally, the decoder may determine the absolute value of the motion vector offset based on the received distance index and the table predefined between the encoder and the decoder.

[0099] Additionally, the sign of the motion vector offset can be obtained through a sign index. The sign index can indicate a sign set including signs corresponding to each of the x-axis component and the y-axis component at the coordinates (x, y) representing the motion vector. For example, a sign information table including a specific sign set mapped to a specific sign index can be managed. The sign information table can be the same table between the encoder and the decoder.

[0100] Next, the decoder can reconstruct the current block based on the corrected motion vector. The decoder can generate a predictor for the current block based on the corrected motion vector. Furthermore, if the prediction mode of the current block is the aforementioned merge mode, the decoder can reconstruct the current block based on the predictor of the current block and the residual signal of the current block. If the prediction mode of the current block is the aforementioned skip mode, the decoder can reconstruct the current block based on the predictor of the current block without the residual signal.

[0101] Meanwhile, as described above, inter prediction can be performed based on multiple motion information sets. For example, the decoder can obtain the motion information set of the current block based on the motion information set of the merge target block indicated by the merge index of the current block. In this case, if the merge target is predicted based on multiple motion information sets, multiple motion vectors can also be used for predicting the current block. Hereinafter, a method for correcting multiple motion vectors of the current block will be described. In particular, the present disclosure describes a case where the current block is predicted based on two motion information sets obtained through a merge candidate list as an example, but the present disclosure is not limited thereto.

[0102] According to one embodiment of the present invention, when a merge target includes multiple motion information sets, multiple motion vector offsets corresponding to each of the multiple motion vectors may be required. In this case, the decoder may first obtain a specific motion vector offset among the multiple motion vector offsets, and then obtain another motion vector offset based on the specific motion vector offset. This may reduce the decoder complexity or signaling overhead associated with obtaining the motion vector offset. Hereinafter, a method for determining a motion vector whose motion vector offset is obtained first among the multiple motion vectors according to one embodiment of the present invention will be described with reference to FIG. 10.

[0103] FIG. 10 is a diagram illustrating a method for correcting a motion vector according to an embodiment of the present invention. According to an embodiment of the present invention, a plurality of merge motion vectors can be corrected based on a POC of at least one reference picture of a merge target. A decoder can correct the plurality of merge motion vectors based on a POC difference between each of the reference pictures corresponding to each of the plurality of merge motion vectors and a current picture. For example, the decoder can compare the POC difference between each of the reference pictures corresponding to each of the plurality of merge motion vectors and the current picture. In addition, the decoder can correct the plurality of motion vectors based on the comparison result. The POC difference can mean an absolute value of a value obtained by subtracting the POC of the reference picture from the POC of the current picture or an absolute value opposite to the absolute value.

[0104] According to one embodiment, the plurality of motion vectors may include a first motion vector and a second motion vector. In this case, the decoder may obtain a first POC difference between a first reference picture corresponding to the first motion vector and a current picture. Furthermore, the decoder may obtain a second POC difference between a second reference picture corresponding to the second motion vector and the current picture. The decoder may compare the first POC difference and the second POC difference to obtain a specific motion vector offset, which is a correction value of one of the first motion vector and the second motion vector. The decoder may obtain the motion vector offset of one of the first motion vector and the second motion vector before the motion vector offset of the other.

[0105] For example, among the first POC difference and the second POC difference, the motion vector offset of the motion vector corresponding to the reference picture having a larger POC difference may be obtained first compared to the motion vector offset of the motion vector corresponding to the reference picture having a smaller POC difference. This is because the larger the POC difference between the current picture and the reference picture including the reference block, the greater the temporal distance between the reference block and the current block and the lower the correlation may be. Accordingly, the larger the absolute value of the motion vector offset of the motion vector corresponding to the reference picture having a larger POC difference from the current picture may be. The decoder may obtain a specific motion vector offset of a specific motion vector, the absolute value of which is expected to be relatively large, first compared to other motion vector offsets. Specifically, only the specific motion vector offset may be signaled to the decoder or may be preferentially determined by the decoder. The motion vector corresponding to the reference picture having a relatively small POC difference from the current picture may be corrected based on a motion vector offset scaled from the specific motion vector offset.

[0106] For example, if the first POC difference is greater than or equal to the second POC difference, the specific motion vector offset may be a correction value for the first motion vector. Conversely, if the first POC difference is less than the second POC difference, the specific motion vector offset may be a correction value for the second motion vector. In this case, the first motion vector may be a motion vector corresponding to the reference picture list L0, and the second motion vector may be a motion vector corresponding to the reference picture list L1.

[0107] In the embodiment of FIG. 10, the motion information set of the current block may include a first motion information set including a first motion vector (MV0) and a second motion information set including a second motion vector (MV1). Additionally, the first motion information set may include a first reference picture index, and the second motion information set may include a second reference picture index. According to one embodiment, the decoder may obtain the motion information set of the current block based on the motion information set of the merge target. The decoder may obtain the motion vector of the current block by correcting MV0 and MV1.

[0108] Referring to FIG. 10(a), if the first POC difference between the first reference picture corresponding to MV0 and the current picture is greater than or equal to the second POC difference between the second reference picture corresponding to MV1 and the current picture, the decoder may first obtain the first motion vector offset applied to MV0 compared to the second motion vector offset applied to MV1. In addition, the decoder may correct MV0 based on the first motion vector offset. Next, the second motion vector offset may be obtained based on the first motion vector offset. In addition, the decoder may correct MV1 based on the second motion vector offset.

[0109] Conversely, if the first POC difference is smaller than the second POC difference, the decoder may preferentially obtain the second motion vector offset over the first motion vector offset. In addition, the decoder may correct MV1 based on the second motion vector offset. Next, the first motion vector offset may be obtained based on the second motion vector offset. In addition, the decoder may correct MV0 based on the first motion vector offset.

[0110] Specifically, in step S1001, the decoder can obtain the POC (poc_curr) of the current block, the POC (poc_RefPic0) of the first reference picture, and the POC (poc_RefPic1) of the second reference picture. Here, the first reference picture and the second reference picture may be reference pictures corresponding to reference picture lists L0 and L1, respectively. For example, the decoder can obtain the first reference picture indicated by the first reference picture index in the reference picture list L0. The decoder can obtain the POC (poc_RefPic0) of the first reference picture. In addition, the decoder can obtain the second reference picture indicated by the second reference picture index in the reference picture list L1. The decoder can obtain the POC (poc_RefPic1) of the second reference picture.

[0111] In step S1002, the decoder can obtain a first POC difference (pocDiff0) based on the POC of the first reference picture and the POC of the current picture. pocDiff0 may be the absolute value of the value obtained by subtracting poc_curr from poc_RefPic0. In addition, the decoder can obtain a second POC difference (pocDiff1) based on the POC of the second reference picture and the POC of the current picture. pocDiff1 may be the absolute value of the value obtained by subtracting poc_curr from poc_RefPic1.

[0112] In step S1003, the decoder can compare the first POC difference and the second POC difference. The decoder can determine whether the first POC difference is greater than the second POC difference. In step S1003, if the first POC difference is greater than the second POC difference, the decoder can preferentially obtain the first motion vector offset corresponding to MV0. The decoder can correct MV0 based on the first motion vector offset. Next, the decoder can generate a second motion vector offset scaled from the first motion vector offset. In addition, the decoder can correct MV1 based on the second motion vector offset.

[0113] In step S1003, if the first POC difference is not greater than the second POC difference, the decoder can determine whether the first POC difference and the second POC difference are the same, as in step S1004. In step S1004, if the first POC difference and the second POC difference are not the same, the decoder can preferentially obtain the second motion vector offset corresponding to MV1. The decoder can correct MV1 based on the second motion vector offset. Next, the decoder can generate a scaled first motion vector offset from the second motion vector offset. In addition, the decoder can correct MV0 based on the first motion vector offset.

[0114] In step S1004, if the first POC difference and the second POC difference are the same, the decoder can obtain the motion vector offset of MV0 corresponding to the reference picture list L0 before the motion vector offset of MV1 corresponding to the reference picture list L1. For example, if the first POC difference and the second POC difference are the same, the decoder can determine a motion vector for which a motion vector offset is preferentially obtained based on a value indicating a reference picture list corresponding to each of the motion vectors. Here, the value indicating the reference picture list may be an index that identifies each of a plurality of reference picture lists. For example, the reference picture list L(i) may be identified through a value i indicating the reference picture list. The value indicating the reference picture list L0 may be '0', and the value indicating the reference picture list L1 may be '1'. Specifically, the decoder can preferentially obtain the motion vector offset of the motion vector corresponding to a reference picture list having a smaller value indicating the reference picture list. Therefore, when the first POC difference and the second POC difference are the same, the decoder can obtain the first motion vector offset before the second motion vector offset. At this time, the reference picture list L0 may be a list used in the first upper level region where at most one motion vector is used for a specific sample and the second upper level region where at most two motion vectors are used for the specific sample. In addition, the reference picture list L1 may be a list used only in the second upper level region where at most two motion vectors are used for the specific sample. That is, the reference picture list L1 may be a list that is not used in the first upper level region where at most one motion vector is used for the specific sample. Here, the upper level region may represent a slice / tile or a picture including the current block.

[0115] [Mathematical expression 1] shows an embodiment of a method for determining a motion vector (MVl) from which a motion vector offset is to be acquired first. According to [Mathematical expression 1], the decoder can acquire the lth motion vector MVl having the largest POC difference among MV0, MV1, ..., MVk-1. In [Mathematical expression 1], POCi represents the POC of the reference picture corresponding to the ith motion vector among k motion vectors, and POCcur represents the POC of the current block.

[0116] [Mathematical Formula 1]

[0117]

[0118] That is, through steps S1003 and S1004, the decoder can determine whether the first POC difference is greater than or equal to the second POC difference. If the first POC difference is greater than or equal to the second POC difference, the decoder can preferentially obtain the first motion vector offset corresponding to MV0. In addition, the decoder can correct MV0 based on the first motion vector offset. Next, the decoder can obtain the second motion vector offset corresponding to MV1. In addition, the decoder can correct MV1 based on the second motion vector offset.

[0119] Conversely, if the first POC difference is smaller than the second POC difference, the decoder can preferentially obtain the second motion vector offset corresponding to MV1. Furthermore, the decoder can compensate MV1 based on the second motion vector offset. Next, the decoder can obtain the first motion vector offset corresponding to MV0. Furthermore, the decoder can compensate MV0 based on the first motion vector offset.

[0120] According to an additional embodiment, the plurality of merge motion vectors can be corrected based on the magnitude of each of the plurality of merge motion vectors. For example, the decoder can correct the plurality of merge motion vectors according to a priority order based on a result of comparing the magnitudes of the plurality of merge motion vectors. This is because the larger the magnitude of the motion vector, the greater the spatial distance between the reference block and the current block, and thus the lower the correlation. Referring to Fig. 10(b), the decoder can obtain the absolute values ​​of each of MV0 and MV1. Next, the decoder can compare the absolute values ​​of each of MV0 and MV1. If the absolute value of MV0 is greater than or equal to the absolute value of MV1, the decoder can obtain the first motion vector offset corresponding to MV0 before the second motion vector offset corresponding to MV1. If the absolute value of MV0 is less than the absolute value of MV1, the decoder can obtain the second motion vector offset before the first motion vector offset. [Mathematical expression 2] shows an embodiment of a method for determining a motion vector (MVl) from which a motion vector offset is preferentially obtained. In [Mathematical expression 2], MVi represents the ith motion vector among k motion vectors.

[0121] [Equation 2]

[0122]

[0123] Referring to Fig. 10(c), the merge motion vector can be corrected based on the size of each of the merge motion vectors and the POC of the reference picture. First, the decoder can determine a motion vector from which a motion vector offset is preferentially obtained based on a result of comparing the first POC difference and the second POC difference. For example, the decoder can perform the operations of steps S1001 to S1003 described above. Next, when the first POC difference and the second POC difference are the same, the decoder can determine a motion vector from which a motion vector offset is preferentially obtained based on a result of comparing the absolute value of MV0 and the absolute value of MV1.

[0124] FIG. 11 is a diagram illustrating a method for correcting a motion vector according to another embodiment of the present invention. According to one embodiment, the decoder may determine a motion vector from which a motion vector offset is preferentially obtained among a plurality of motion vectors by using a template matching method. Referring to FIG. 11, when the width of the current block is W and the height is H, the decoder may construct an L-shaped template including a W0xH region on the left side of the target block and a WxH0 region on the upper side of the target block. At least one of W0 or H0 may be determined based on the size of the current block. The decoder may construct an L-shaped template for each of the current block (1101), the first reference block (1102), and the second reference block (1103). In this case, the first reference block (1102) may be a reference block specified by a motion vector (MV0) of the reference picture list L0. Additionally, the second reference block (1103) may be a reference block specified by a motion vector (MV1) of the reference picture list L1.

[0125] Next, the decoder can determine a motion vector from which a motion vector offset is preferentially obtained among MV0 and MV1 based on a value difference between the configured plurality of templates. Specifically, the decoder can calculate a first template value difference between the template corresponding to MV0 and the template of the current block and a second template value difference between the template corresponding to MV1 and the template of the current block. The value difference between the templates can be calculated through the above-described SAD, mean-normalized SAD, or sum of squared error (SSE). If the first template value difference is greater than or equal to the second template value difference, the decoder can obtain the first motion vector offset corresponding to MV0 before the second motion vector offset corresponding to MV1. If the first template value difference is less than the second template value difference, the decoder can obtain the second motion vector offset before the first motion vector offset. [Mathematical Formula 3] shows one embodiment of a method for determining a motion vector (MVl) from which a motion vector offset is preferentially obtained. In [Mathematical Formula 3], cost_i represents the difference in value between the template of reference block i and the template of the current block. Specifically, reference block i represents a reference block specified by the ith motion vector among k motion vectors.

[0126] [Equation 3]

[0127]

[0128] According to an additional embodiment, the decoder may determine a motion vector from which a motion vector offset is preferentially obtained among a plurality of motion vectors based on the characteristics of the merge candidate. For example, if a motion vector scaled from a temporal candidate exists among a plurality of motion vectors corresponding to a merge target, the decoder may first obtain the motion vector offset of the motion vector scaled from the temporal candidate. Furthermore, if a zero motion vector exists among a plurality of motion vectors corresponding to a merge target, the decoder may first obtain the motion vector offset of the zero motion vector. The motion vector determination methods described through FIG. 11 may be combined with the motion vector determination method described through FIG. 10.

[0129] Meanwhile, the motion information set of the current block can also be obtained in a manner other than the method using the merge candidate list described above. In this case, the motion vector of the current block can be obtained through a motion vector predictor (MVP) and a motion vector difference (mvd). The MVP of the current block can be signaled using the MVP candidate list. Additionally, the mvd and reference picture index of the current block can be signaled separately. The MVP candidate list can be obtained in a manner similar to the merge candidate list described above. This inter prediction method can be referred to as the MVP mode.

[0130] According to one embodiment, the MVP candidate list may include at least one of a spatial candidate and a temporal candidate. The spatial candidate may be formed based on available neighboring blocks among neighboring blocks of the current block, similar to the merge candidate list described above with reference to FIG. 9. Specifically, the decoder may sequentially search A0, A1, scaled A0, and scaled A1 of FIG. 9 to generate at most one first spatial candidate. Next, the decoder may sequentially search B0, B1, B2, scaled B0, and scaled B1 of FIG. 9 to generate at most one second spatial candidate. Here, scaled A0, scaled A1, scaled B0, and scaled B1 represent motion vectors obtained by scaling the corresponding motion vectors according to a temporal relationship, respectively. For example, if A0 is available, A1 is not available, and the reference picture referred to in the prediction of A1 is different from the reference picture of the current picture, scaled A0 may be determined as the first spatial candidate. In this case, the reference picture of the current picture may be a picture determined based on a signaled reference picture index. In addition, the MVP candidate list may include at most one temporal candidate. The MVP candidate list may include a zero motion vector.

[0131] In one embodiment, the encoder may signal an MVP index, an mvd, and a reference picture index, each indicating one of the candidates in the MVP candidate list. The decoder may use the motion vector of the candidate indicated by the MVP index as the MVP of the current block. The decoder may obtain the motion vector of the current block based on the obtained MVP and the received mvd. For example, the motion vector of the current block may be the MVP plus the mvd. Next, the decoder may reconstruct the current block based on the motion vector and the reference picture of the current block.

[0132] FIG. 12 is a diagram illustrating motion vector scaling of a candidate included in an MVP candidate list of a current block according to an embodiment of the present invention. Hereinafter, an MVP candidate block represents a candidate block corresponding to any one of the candidates included in the MVP candidate list. Referring to FIG. 10, a first temporal distance (tb) between a current picture and a picture referenced by the current block can be obtained. In addition, a second temporal distance (td) between a picture including an MVP candidate block and a picture referenced by the MVP candidate block can be obtained. The decoder can scale a motion vector corresponding to the corresponding MVP candidate block based on a value obtained by dividing the first temporal distance (tb) by the second temporal distance (td). At this time, the temporal distances tb and td can be expressed as a POC difference. In addition, the decoder can calculate tb and td using a fixed-point method to avoid using a division operation. The fixed-point method can be a method using an offset value and a shift operation.

[0133] Meanwhile, the aforementioned motion vector offset can be obtained by the decoder according to a predefined rule. According to one embodiment of the present invention, the decoder can obtain the motion vector offset based on a template matching method. For example, the decoder can obtain the motion vector offset by searching surrounding sample values ​​based on a block specified by the merge motion vector obtained through the merge index. In addition, the decoder can correct the merge motion vector based on the obtained motion vector offset. This can reduce signaling overhead.

[0134] FIG. 13 is a diagram illustrating a method for correcting a motion vector according to an embodiment of the present invention. According to an embodiment, when a current block is a bi-prediction block, a decoder may correct a plurality of motion vectors used for the bi-prediction block. For example, when the current block is a bi-prediction block, a first initial motion vector (MV0) corresponding to a first reference picture list (L0) and a second initial motion vector (MV1) corresponding to a second reference picture list (L1) may be used for predicting the current block. Here, the initial motion vector may represent a merge motion vector derived based on the merge index described above. The decoder may correct the first initial motion vector (MV0) and the second initial motion vector (MV1), respectively, to generate a first corrected motion vector (MV0') and a second corrected motion vector (MV1').

[0135] According to one embodiment of the present invention, a first initial motion vector (MV0) and a second initial motion vector (MV1) can be corrected based on a template matching method. The decoder can obtain a first template based on a first reference block indicated by the first initial motion vector and a second reference block indicated by the second initial motion vector. For example, the first template can be a sample-by-sample average between the first reference block (P0) and the second reference block (P1). That is, a specific sample of the first template can be expressed in the form of (p0+p1) / 2. In this case, p0 and p1 can be samples at corresponding positions within the first reference block (P0) and the second reference block (P1), respectively. In addition, the decoder can construct the first template using a bit shift operation, such as (p0+p1)>>1. Through this, the decoder can construct the first template without a division operation.

[0136] In an additional embodiment, when a weighted prediction method is used for the current block, the first template may be a sample-wise sum of a first reference block and a second reference block to which weight values ​​are applied. In this case, the first template may be expressed as in [Mathematical Formula 4]. In [Mathematical Formula 4], W0 and O0 may be a weight value and an offset value applied to the reference block P0, respectively. In addition, W1 and O1 may be a weight value and an offset value applied to the reference block P1, respectively. w_shift represents a parameter for a bit shift operation. At this time, the method by which the weight value and the offset value are determined will be described later with reference to FIGS. 18 to 25.

[0137] [Equation 4]

[0138]

[0139] Next, the decoder can correct the first initial motion vector and the second initial motion vector based on the first template. According to one embodiment, the decoder can set a first comparison target area based on a first reference block indicated by the first initial motion vector. In addition, the decoder can compare the first template with a plurality of comparison target templates that can be configured within the first comparison target area. At this time, the comparison target template can be configured to have the same size and shape as the first template. In addition, the comparison target template can be configured with integer pixels or pixels in units of subpels (1 / 2, 1 / 4, 1 / 16-pel).

[0140] According to one embodiment, the decoder may determine a second template, among the configurable comparison target templates within the first comparison target area, that has the smallest value difference from the first template. Furthermore, the decoder may generate a first corrected motion vector (MV0') based on the second template. Specifically, the motion vector offset between the first initial motion vector (MV0) and the first corrected motion vector (MV0') may be the difference between a coordinate value indicating a position of the first reference block and a coordinate value indicating a position of the second template.

[0141] At this time, the value difference between the templates can be calculated through SAD (Sum of Absolute Difference) or mean-normalized SAD. SAD can be expressed as in [Mathematical Formula 5]. In addition, mean-normalized SAD can be expressed as in [Mathematical Formula 6]. In [Mathematical Formula 5] and [Mathematical Formula 6], M represents the width of the template or block, and N represents the height of the template or block. In addition, T(x, y) represents a sample of the template, and P(x, y) represents a sample of the block to be compared. mean(X) can be a function that outputs the mean value of 'X'.

[0142] [Equation 5]

[0143]

[0144] [Equation 6]

[0145]

[0146] According to a specific embodiment, the decoder may generate a first corrected motion vector (MV0') based on a second template that minimizes SAD or SAD' of the mathematical expression. In addition, the decoder may reconstruct the current block based on the reference block indicated by the first corrected motion vector (MV0').

[0147] The method described above with respect to the method of generating a first corrected motion vector (MV0') by correcting a first initial motion vector (MV0) can also be applied in the same or corresponding manner to the method of generating a second corrected motion vector (MV1') by correcting a second initial motion vector (MV1).

[0148] FIG. 14 is a diagram showing a search position for correcting a motion vector based on an initial motion vector according to an embodiment of the present invention. In FIG. 14(a), P0 represents a sample position indicated by the initial motion vector. According to an embodiment of the present invention, a decoder may configure eight templates corresponding to eight sample positions (P1, P2, P3, P4, P5, P6, P7, P8) adjacent to P0 based on P0. In addition, the decoder may determine one template among the eight templates, which has the smallest value difference between the template of the current block generated based on the initial motion vector and the template. In addition, the decoder may generate a corrected motion vector based on the sample position corresponding to the one template.

[0149] For example, an initial motion vector indicating P0 may be represented by coordinate values ​​(x, y). At this time, if the value difference between the template corresponding to P5 (a position shifted by +1 in the x-axis direction from P0) and the template of the current block is the smallest, the decoder may correct the initial motion vector (x, y) to (x+1, y). According to another embodiment, if the value difference between the template corresponding to P6 (a position shifted by -1 in the x-axis direction and +1 in the y-axis direction from P0) and the template of the current block is the smallest, the decoder may correct the initial motion vector (x, y) to (x-1, y+1). According to another embodiment, if the value difference between the template corresponding to P0 and the template of the current block is the smallest, the initial motion vector may not be updated.

[0150] Fig. 14(b) illustrates an embodiment in which only some of the sample positions described in Fig. 14(a) are searched. According to one embodiment of the present invention, the decoder may perform template matching on only some of the sample positions adjacent to P0. This is because, if template matching cost calculations are performed on all samples adjacent to P0, the amount of decoding computation may be excessive and the decoding complexity may increase. Specifically, motion vector compensation may be performed based on four templates corresponding to each of four sample positions (P2, P4, P5, P7) adjacent vertically and horizontally with respect to P0. That is, templates corresponding to each of sample positions (P1, P3, P6, P8) adjacent diagonally with respect to P0 may be excluded from the search target.

[0151] According to another embodiment, the decoder can additionally perform template matching on any one of the diagonally adjacent sample positions (P1, P3, P6, P8). The decoder can determine the sample position at which to perform template matching according to a preset rule. For example, if the value difference between the template corresponding to P2 and the template of the current block is less than the value difference between the template corresponding to P7 and the template of the current block, and the value difference between the template corresponding to P5 and the template of the current block is less than the value difference between the template corresponding to P4 and the template of the current block, the decoder can perform template matching on P2, P4, P5, P7, and P3.

[0152] In Figure 13, the template for predicting the current block is depicted as having the same size as the width and height of the current block. According to another embodiment of the present invention, the template for the current block may be configured to have a size and / or shape different from that of the current block. For example, the size of the template for the current block may be expanded compared to the size of the current block. This can improve the accuracy of template matching.

[0153] FIG. 15 is a diagram illustrating a method for constructing a template for motion vector correction according to one embodiment of the present invention. According to one embodiment, the width of the current block may be W and the height may be H. In this case, a reference block (1501) having the same shape as the current block with the width W and the height H may be constructed based on a sample position indicated by an initial motion vector. In addition, the sample position indicated by the initial motion vector may be constructed such that it is the upper leftmost sample within the reference block. At this time, a template (1502) having a shape in which the left boundary of the reference block (1501) and the upper boundary of the reference block are extended may be constructed. Specifically, a width (W0) extending from the left boundary of the reference block (1501) to the outside of the block and a height (H0) extending from the upper boundary of the reference block (1501) to the outside of the block may be determined based on the size of the reference block (1501). Even when the decoder uses an extended template, the decoder can correct the initial motion vector in a manner identical to or equivalent to the method described through FIGS. 13 and 14.

[0154] FIG. 16 is a flowchart illustrating a method for correcting motion vectors according to an embodiment of the present invention. As described above, a current block can be predicted based on multiple sets of motion information. In the embodiment of FIG. 16, the current block can be predicted based on k motion vectors. The decoder can correct the k initial motion vectors using a template matching method. Furthermore, the decoder can generate a final predicted block of the current block based on the k corrected motion vectors. Hereinafter, a method for correcting the k initial motion vectors will be described in detail.

[0155] According to one embodiment, a template of a current block may be constructed based on a plurality of reference blocks corresponding to initial motion vectors MV0, MV1, …, MVk-1, respectively. Next, MV0, MV1, …, MVk-1 may be corrected based on the template of the current block. For example, the decoder may generate MV0' based on a template having a smallest template value difference from the template of the current block among the comparison target templates within a comparison target area set based on MV0. At this time, the decoder may generate a corrected motion vector while increasing an iteration value for each initial motion vector. A reference motion vector for setting a comparison target area may be changed depending on the iteration value.

[0156] Specifically, for each repetition order, a plurality of comparison target templates corresponding to each of the plurality of sample positions described through FIG. 14 may be configured based on the sample position indicated by the reference motion vector. At this time, the reference motion vector of the current repetition order may be a motion vector corrected through the previous repetition order. When the repetition order value is '0', the reference motion vector may be an initial motion vector. For each repetition order, the decoder may calculate the value difference between each of the plurality of comparison target templates and the template of the current block. In addition, the decoder may generate a corrected motion vector of the current repetition order based on the comparison target template with the smallest value difference between the templates. Next, when the current repetition order value is less than a preset maximum number of repetitions (max_iteration), the decoder may perform template matching of the next repetition order based on the corrected motion vector of the current repetition order. The initial motion vector may be repeatedly corrected in the above-described manner until the repetition order value becomes a preset maximum number of repetitions (max_iteration).

[0157] In further embodiments, motion vector correction can be performed on an integer pixel basis and a subpel basis (1 / 2, 1 / 4, 1 / 16-pel basis). First, the decoder can generate a corrected motion vector (MVi') on an integer pixel basis from the ith initial motion vector (MVi). Next, the decoder can update a motion vector on a subpel basis using the corrected motion vector (MVi') on an integer pixel basis as a reference motion vector. At this time, the decoder can configure templates corresponding to each of a plurality of sample positions on a subpel basis adjacent to P0, similar to the method of correcting a motion vector on an integer pixel basis. In addition, the decoder can perform motion vector correction on a subpel basis based on the configured templates.

[0158] The motion vector compensation method based on the template matching described above may increase the complexity of the decoder because the decoder repeatedly accesses the memory. Accordingly, in order to alleviate the increase in the complexity of the decoder, a method may be used in which multiple motion vectors are compensated based on a single offset. In this case, if the motion vector offset of the first initial motion vector, which is acquired first among the multiple initial motion vectors, is '0', the remaining initial motion vectors may not be compensated either. In this case, the target for which the motion vector offset is acquired first among the multiple initial motion vectors may be determined by the method described through FIGS. 10 and 11 described above.

[0159] Figure 17 is a flowchart illustrating a method for correcting motion vectors according to another embodiment of the present invention. As described above, the current block can be predicted based on multiple sets of motion information. In the embodiment of Figure 17, the current block can be predicted based on k motion vectors.

[0160] First, the decoder can determine the motion vector from which the motion vector offset is first obtained. Among the multiple initial motion vectors, the one from which the motion vector offset is first obtained can be determined using the method described with reference to FIGS. 10 and 11 described above. Referring to FIG. 17, the decoder can determine the MVl from which the motion vector offset is first obtained.

[0161] Next, the decoder can compensate MVl according to the method described above through FIG. 16. For example, a template of the current block can be constructed based on a plurality of reference blocks corresponding to initial motion vectors MV0, MV1, ..., MVk-1, respectively. In addition, the decoder can obtain a motion vector offset corresponding to MVl based on a template having the smallest template value difference from the template of the current block among the comparison target templates within the comparison target area set based on MVl. The decoder can generate MVl' based on the motion vector offset corresponding to MVl.

[0162] Next, the decoder can determine whether MVl is corrected. If MVl is not corrected, the decoder can predict the current block using the initial motion vectors MV0, MV1, …, MVk-1 as the final motion vector. This is because the motion vector offset corresponding to MVl is ‘0’. Conversely, if MVl is corrected, the decoder can sequentially correct the initial motion vectors excluding MVl, as shown in Fig. 16. For example, if l is 2, if MV2 is corrected, correction can be sequentially performed for MV0, MV1, MV3, …, MVk-1 excluding MV2.

[0163] In addition, when sequentially correcting the initial motion vectors excluding MVl, if the ith motion vector is not corrected, the decoder can terminate the motion vector correction early. For example, the decoder can predict the current block by using the corrected motion vectors for MVl and the motion vectors prior to the (i+1)th, and using the initial motion vectors for the motion vectors from the (i+1)th to the kth.

[0164] In another embodiment, if all k initial motion vectors are corrected and the iteration order is less than the maximum number of iterations (max_iteration), the decoder can update the template of the current block. In this case, the decoder can update the template of the current block based on a plurality of reference blocks corresponding to each of the corrected motion vectors. That is, the template of the current block used in the current iteration order can be iteratively updated up to max_iteration using the motion vectors corrected through the previous iteration order. In another additional embodiment, in the first correction round, the method of early termination of the correction algorithm depending on whether MVl or other motion vectors are corrected can be set not to be used. Whether to use early termination can also be adaptively determined depending on the size of the current block.

[0165] Hereinafter, a weighted prediction method for applying weight values ​​and offset values ​​to a reference block according to one embodiment of the present invention will be described.

[0166] FIG. 18 is a diagram illustrating a weighted prediction method using a single motion information set according to an embodiment of the present invention. As described above, a reference block used for inter prediction of a current block can be determined by searching for a block with a high similarity to the current block in pictures having a different POC from the current picture. At this time, the picture with a different POC from the current picture may be a picture in the past direction whose POC is earlier than the current picture, or a picture in the future direction whose POC is later than the current picture. At this time, a block with a high similarity to the current block can be searched for in integer pixel units or subpel units (1 / 2, 1 / 4, 1 / 16-pel).

[0167] According to one embodiment of the present invention, a motion information set of a specific block may include bi-prediction information. Here, the bi-prediction information may be information indicating whether the corresponding block is a block predicted using both reference picture lists. For example, an encoder may signal the bi-prediction information. In addition, the motion information set may include a reference picture list, a reference picture index, and a motion vector. In the embodiments described below with reference to FIGS. 18 to 26, the motion vector and the initial motion vector may represent a merge motion vector derived based on a merge index from the aforementioned merge candidate list.

[0168] In further embodiments, the motion information set may include unidirectional / bidirectional information. The unidirectional / bidirectional information may be information indicating whether the block is predicted based on a picture in either the past or future direction relative to the POC of the current picture, or based on a picture in both directions.

[0169] According to one embodiment of the present invention, a decoder can predict a current block using a weighted prediction method that applies weight values ​​and offset values ​​to a reference block. At this time, the weighted prediction method can be divided into a first weighted prediction method and a second weighted prediction method. First, in the first weighted prediction method, whether to use weighted prediction and a weight parameter set can be signaled in units of PPS. Hereinafter, a weight parameter set can be used as a term including at least one of a weight value and an offset value applied to a reference block. Next, in the second weighted prediction method, whether to use weighted prediction can be signaled in units of SPS. Furthermore, in the second weighted prediction method, a weight parameter set can be signaled for each coding unit. The first weighted prediction method and the second weighted prediction method may not be applied redundantly to a single coding unit. For example, the second weighted prediction method can be applied to coding units included in a picture to which the first weighted prediction method is not applied.

[0170] According to one embodiment, the second weighted prediction method may be used only when the size of the coding unit is larger than a preset size or the number of samples of the coding unit is greater than a preset number. In the second weighted prediction method, a weight value may be indicated through an index (gbi_idx[x0][y0]) of a preset table. Whether to use weighted prediction for single prediction may be indicated by weighted_pred_flag. Whether to use weighted prediction for pair prediction may be indicated through weighted_bipred_flag. Hereinafter, embodiments of the present invention are described based on the first weighted prediction method, but the present disclosure is not limited thereto. The second weighted prediction method described above may be applied to the embodiments described below in the same or corresponding manner.

[0171] In Figure 18, P0 represents a sample value of a reference block, W0 represents a weight value, and O0 represents an offset value. Additionally, Wshift represents a parameter for a bit shift operation. The decoder can obtain information indicating whether weighted prediction is used based on the received bitstream. Furthermore, the decoder can predict the current block based on the information indicating whether weighted prediction is used.

[0172] FIG. 19 is a diagram illustrating a weighted prediction method of a bi-predicted block according to an embodiment of the present invention. According to an embodiment of the present invention, a current block can be predicted based on a reference block (P0) included in a picture based on a first reference picture list (L0) and a reference block (P1) included in a picture based on a second reference picture list (L1). In FIG. 19, W0 and O0 may be a weight value and an offset value applied to the reference block P0, respectively. In addition, W1 and O1 may be a weight value and an offset value applied to the reference block P1, respectively. Wshift represents a parameter for a bit shift operation. The decoder can obtain the corresponding information based on the bitstream and predict the current block.

[0173] FIG. 20 is a flowchart illustrating a method for a decoder to predict a current block using weighted prediction according to an embodiment of the present invention. In step S2001 of FIG. 20(a), the decoder may obtain an initial motion vector and weighted prediction-related information. At this time, the decoder may obtain the initial motion vector and weighted prediction-related information from a received bitstream. In step S2003, the decoder may obtain a first reference block based on the initial motion vector and weighted prediction-related information obtained in step S2001. In step S2005, the decoder may configure a template of the current block and a template of the first reference block.

[0174] In step S2007, the decoder may determine a set of weighted parameters to be applied to the first reference block using a template matching method. For example, the decoder may determine a set of weighted parameters to be applied to the first reference block based on a value difference between a template of the current block and a template of the first reference block. Furthermore, the decoder may apply the determined set of weighted parameters to the first reference block to generate an inter-predicted prediction block. Meanwhile, depending on whether the inter-prediction method of the current block is a pair prediction, information on value differences between additional templates or a similarity determined based on at least one of value differences between a plurality of reference blocks may be used for predicting the current block.

[0175] Steps S2002 and S2004 of FIG. 20(b) may be identical to steps S2001 and S2003 of FIG. 20(a). The decoder may obtain initial motion vector and weighted prediction-related information, and obtain a first reference block based thereon. In step S2006, the decoder may perform a search to determine a second reference block based on the template of the current block. For example, the decoder may determine the second reference block based on the template of the current block and additional information. Specifically, the additional information may be a template of a comparison target block. The decoder may set a comparison target region based on the first reference block. In this case, the decoder may configure a template of a specific comparison target block within the comparison target region. In addition, the decoder may use the specific comparison target block as the second reference block if the value difference between the template of the specific comparison target block and the template of the current block is less than or equal to a preset value.

[0176] In step S2008, the decoder may determine a set of weighting parameters to be applied to each of the first reference block and the second reference block using a template matching method. For example, the decoder may determine a set of weighting parameters to be applied to each of the first reference block and the second reference block using a template of the current block, a template of the first reference block, and a template of the second reference block. Specifically, the decoder may determine a set of weighting parameters to be applied to each of the first reference block and the second reference block based on a value difference between the template of the current block and the template of the first reference block or a value difference between the template of the current block and the template of the second reference block. Additionally, the decoder may determine a set of weighting parameters to be applied to each of the first reference block and the second reference block based on samples of each of the current block, the first reference block, and the second reference block.

[0177] FIG. 21 is a diagram illustrating a method for updating a set of weighted parameters applied to a reference block when a current block is unidirectionally predicted according to one embodiment of the present invention. According to one embodiment of the present invention, a decoder may construct a template of a current block based on samples surrounding the current block. Hereinafter, the template of the current block may be referred to as a first template. In FIG. 21, the template of the current block is constructed using samples surrounding the upper and left sides of the current block, but the present disclosure is not limited thereto.

[0178] Additionally, the decoder can determine the first reference block based on the motion vector (MV0) of the current block. The decoder can construct a second template, which is a template of the first reference block, based on surrounding samples of the first reference block. The second template can be constructed in a manner identical to or corresponding to the manner in which the template of the current block is constructed.

[0179] Next, the decoder can calculate the difference in values ​​between the first template and the second template. Here, the difference in values ​​between the templates may be a value determined using either SAD or SATD. In a further embodiment, the difference in values ​​between the templates may be a value determined based on the ratio between the sum of the sample values ​​of all samples included in the first template and the sum of the sample values ​​of all samples included in the second template.

[0180] The decoder can update the set of weight parameters based on the value difference between the templates determined in the aforementioned manner. For example, if the signaled weight value is a first weight value (W0), the decoder can change the first weight value (W0) to a second weight value (W0') based on the value difference between the templates. Specifically, the decoder can compare the value difference between the first template and the second template with a preset value. Furthermore, the decoder can change the first weight value (W0) to the second weight value (W0') based on the comparison result. The decoder can change the first weight value (W0) to the second weight value (W0'), which is a weight value corresponding to the value difference between the templates, based on a predefined table. At this time, the predefined table can be shared between the encoder and the decoder and can be a common table. Next, the decoder can generate a prediction block of the current block by applying the second weight value (W0') to the sample value of the first reference block. Additionally, the decoder can reconstruct the current block based on the predicted block.

[0181] In a further embodiment, the decoder may use a linear model between the first template and the second template to determine a set of weighting parameters to be applied to the first reference block. Specifically, the decoder may generate a linear model that minimizes differences between sample values ​​at each position of the samples in the first template and the second template. For example, if the linear model is y=ax+b, the decoder may apply a weight value a and an offset value b to the first reference block. Furthermore, in the linear model, x and y may correspond to sample values ​​of the second template and sample values ​​of the first template, respectively. Furthermore, the decoder may use a linear / nonlinear regression model instead of the linear model.

[0182] In another embodiment, the decoder may determine a set of weighting parameters corresponding to the difference in values ​​between the obtained templates based on a predefined table. In another embodiment, the offset value applied to the first reference block may be updated to an offset value within a preset range according to the change in the weight value and the motion vector.

[0183] In additional embodiments, the use of a weighted prediction method may be determined based on the difference in values ​​between the first and second templates. For example, if the difference in values ​​between the templates is less than or equal to a preset value, the weighted prediction method may not be used. Conversely, if the difference in values ​​between the templates is greater than or equal to a preset value, the weighted prediction method may be used.

[0184] Meanwhile, although FIG. 21 describes a method for updating a weighted parameter set applied to a first reference block, the motion vector of the current block may also be corrected using a method identical to or corresponding to the method for updating the weighted parameter set. According to one embodiment of the present invention, the motion vector correction described with reference to FIGS. 9 to 17 may be performed together with the updating of the aforementioned weighted parameter set.

[0185] For example, the decoder can update at least one of the motion vector of the current block, the weight value applied to the reference block, or the offset value applied to the reference block. The decoder can update at least one of the motion vector of the current block, the weight value applied to the reference block, or the offset value applied to the reference block based on the template of the current block and the template of the reference block.

[0186] FIG. 22 is a diagram illustrating a method for predicting a current block based on an additionally searched reference block according to an embodiment of the present invention. According to an embodiment of the present invention, an encoder may signal an additional reference flag indicating that an additional reference block having a higher similarity to the current block than a first reference block indicated by a motion vector (MV0) of the current block exists. In this case, the additional reference flag may be 1 bit. A decoder may determine whether to correct the motion vector of the current block based on the additional reference flag. For example, if the additional reference flag is disabled, the decoder may generate a prediction block of the current block based on the first reference block.

[0187] On the other hand, when the additional reference flag is enabled, the decoder can compensate the motion vector of the current block by searching for an additional reference block that is more similar to the current block and the first reference block. That is, the decoder can obtain a compensated motion vector (MV0'') that indicates an additional reference block other than the first reference block within the reference picture. At this time, the additional reference block can be searched for based on the position of the first reference block. For example, the decoder can set a comparison target area based on the position of the first reference block. In this case, the decoder can configure a template of a specific comparison target block within the comparison target area. In addition, the decoder can compare the template of the specific comparison target block with the template of the current block, and if the difference is less than or equal to a preset value, the specific comparison target block can be used as an additional reference block.

[0188] Referring to FIG. 22, the decoder can compare the template of each of the comparison target blocks within the comparison target area with the first template to obtain the second reference block having the smallest value difference between the templates. At this time, the decoder can obtain the second reference block having the smallest value difference between the templates in integer pixel, 1 / 2-pel, 1 / 4-pel, or 1 / 16-pel units. In addition, when a weighted prediction method is used for the current block, the decoder can obtain a set of weighting parameters to be applied to the second reference block based on the value difference between the first reference block and the second reference block. For example, the decoder can determine the weight value (W0'') to be applied to the second reference block based on the value difference between the first reference block and the second reference block. At this time, the method for determining the value difference between templates described through FIG. 21 and the weighted prediction method based on the value difference between templates can be applied in the same or corresponding manner. For example, the decoder can determine a weight value (W0'') to be applied to the second reference block based on a difference in values ​​between at least two of the first template of the current block, the second template of the first reference block, or the third template of the second reference block.

[0189] Additionally, the decoder can predict the current block based on at least one of the first reference block and the second reference block. For example, the decoder can generate a first prediction block of the current block by applying a first weight value (W0) to the sample value of the first reference block. Additionally, the decoder can generate a second prediction block of the current block by applying a second weight value (W0'') to the sample value of the second reference block. Additionally, the decoder can reconstruct the current block based on at least one of the first prediction block or the second prediction block.

[0190] In an additional embodiment, the decoder may determine whether to use a weighted prediction method by comparing the amount of change in the corrected motion vector (MV0'') indicating the second reference block with respect to the initial motion vector (MV0) with a preset value. In addition, whether to update the weighted parameter set may also be determined based on the amount of change in the corrected motion vector (MV0'') indicating the second reference block with respect to the initial motion vector (MV0).

[0191] FIG. 23 is a diagram illustrating a method for updating a weight parameter set applied to a reference block when the current block is a bi-predicted block according to an embodiment of the present invention. According to an embodiment of the present invention, when the current block is a bi-predicted block, the decoder can predict the current block based on two sets of motion information. In this case, the first set of motion information corresponding to the reference picture list L0 can include a first motion vector (MV0). In addition, the second set of motion information corresponding to the reference picture list L1 can include a second motion vector (MV1).

[0192] According to one embodiment of the present invention, a decoder can predict a current block based on a first reference block indicated by a first motion vector (MV0) and a second reference block indicated by a second motion vector (MV1). For example, the decoder can configure a first template of the current block, a second template of the first reference block, and a third template of the second reference block using the method described above with reference to FIGS. 18 to 22. Next, the decoder can compare the first template and the second template to determine a first template value difference. Furthermore, the decoder can compare the first template and the third template to determine a second template value difference. Next, the decoder can determine a first parameter set to be applied to the first reference block based on the first template value difference. Furthermore, the decoder can determine a second parameter set to be applied to the second reference block based on the second template value difference. Next, the decoder can reconstruct the current block based on the first parameter set and the second parameter set.

[0193] FIG. 24 is a diagram illustrating a method for predicting a current block based on an additionally searched reference block when the current block is a bi-predicted block according to an embodiment of the present invention. According to an embodiment of the present invention, the current block can be predicted based on a reference block generated by a plurality of reference blocks. First, the decoder can obtain a first reference block and a second reference block based on an initial motion vector (MV0, MV1) for the current block. Next, the decoder can generate a fifth reference block based on the first reference block and the second reference block. For example, the decoder can generate the fifth reference block as a sample-by-sample average of the first reference block and the second reference block.

[0194] Next, the decoder can correct the initial motion vector based on the sample values ​​of the fifth reference block. For example, the decoder can search for a block having a similar sample value to the fifth reference block in each of the first reference picture and the second reference picture. Here, the first reference picture and the second reference picture can be reference pictures corresponding to the initial motion vectors (MV0, MV1), respectively. The decoder can perform the search to obtain a third reference block, which is the block most similar to the fifth reference picture in the first reference picture, and a fourth reference block, which is the block most similar to the fifth reference picture in the second reference picture. According to one embodiment, the decoder can correct the initial motion vector MV0 to MV0' based on the position of the third reference block. Additionally, the decoder can correct the initial motion vector MV1 to MV1' based on the position of the fourth reference block.

[0195] Next, the decoder can determine whether to perform weighted prediction or determine the parameter sets applied to the third reference sample and the parameter sets applied to the fourth reference sample based on at least one of the value difference between the fifth reference block and the third reference block or the value difference between the fifth reference block and the fourth reference block. Next, the decoder can reconstruct the current block based on the parameter sets applied to the third reference sample and the parameter sets applied to the fourth reference sample.

[0196] FIG. 25 is a diagram illustrating a method for predicting a current block based on an additionally searched reference block when the current block is a bi-predicted block according to another embodiment of the present invention. First, the decoder can obtain a first reference block and a second reference block based on initial motion vectors (MV0, MV1) for the current block. Next, the decoder can generate a fifth reference block based on the first reference block and the second reference block. For example, the decoder can generate the fifth reference block using a sample-by-sample sum of the first reference block and the second reference block to which a sample-by-sample average or weighted value of the first reference block and the second reference block is applied.

[0197] Next, the decoder can correct the initial motion vector based on the sample values ​​of the fifth reference block. Here, the first reference picture and the second reference picture can be reference pictures corresponding to the initial motion vectors (MV0, MV1), respectively. The decoder can perform a search to obtain a third reference block, which is the block most similar to the fifth reference picture in the first reference picture, and a fourth reference block, which is the block most similar to the fifth reference picture in the second reference picture.

[0198] Next, the decoder can construct a first template composed of surrounding samples of the current block. In addition, the decoder can construct a second template composed of surrounding samples of a third reference block, and the decoder can construct a third template composed of surrounding samples of a fourth reference block. Next, the decoder can determine a parameter set applied to the third reference sample and a parameter set applied to the fourth reference sample based on a value difference between any two of the first template, the second template, and the third template. Next, the decoder can also reconstruct the current block based on the parameter set applied to the third reference sample and the parameter set applied to the fourth reference sample.

[0199] According to one embodiment of the present invention, efficient methods for signaling a motion information set used for inter prediction can be provided. According to one embodiment, a motion information set for a current block can be derived based on a motion information set used for prediction of neighboring blocks of the current block, such as in the aforementioned merge mode, skip mode, and MVP mode.

[0200] As described above, the motion vector of the current block can be determined based on the motion vector predictor and the motion vector differential value. For example, the decoder can obtain the motion vector of the current block by adding the motion vector differential value to the motion vector predictor. According to one embodiment, the encoder and the decoder can determine the motion vector predictor according to a rule predefined between the encoder and the decoder. In addition, the encoder can obtain the motion vector differential value based on the determined motion vector predictor. In addition, the encoder can signal the obtained motion vector differential value. The decoder can obtain the motion vector based on the determined motion vector predictor and the motion vector differential value. When the motion vector differential value is signaled instead of the motion vector as described above, the bits used to obtain the motion vector can be reduced.

[0201] The aforementioned motion vector predictor can be obtained based on a list of motion vector predictor candidates. The list of motion vector predictor candidates can be composed of spatial predictor candidates and temporal predictor candidates. Furthermore, the encoder and decoder can construct the list of motion vector predictor candidates based on predefined rules between the encoder and decoder.

[0202] According to one embodiment of the present invention, the order of candidates within the aforementioned merge candidate list and / or motion vector predictor candidate list (hereinafter, referred to as candidate list) may be rearranged. That is, indices indicating candidates within the candidate list may be redefined. In the present disclosure, rearranging the order of candidates within the candidate list may be referred to as motion candidate reorder (MCR). Motion candidate reordering may be performed according to reordering rules predefined by each of the encoder and decoder. Through this, the encoder and decoder according to one embodiment of the present invention may improve the encoding efficiency of a video signal.

[0203] In one embodiment, the reordering rule may be based on a preset cost. For example, the reordering rule may be one that orders a specific cost from lowest to highest (or highest to lowest). For example, the preset cost may represent a template matching cost. Below, a template matching method according to one embodiment of the present invention will be described with reference to FIG. 26.

[0204] FIG. 26 is a diagram illustrating a template matching method according to one embodiment of the present invention. According to one embodiment, template matching may be an operation of comparing a template of a first block with a template of a second block. That is, the encoder and decoder can determine a value difference between the first block and the second block by comparing the template of the first block with the template of the second block. This is because it can be assumed that there is a similarity of a preset level or higher between a specific block and its template. For example, the encoder and decoder can perform template matching based on a sample value difference between templates of multiple blocks.

[0205] According to one embodiment of the present invention, the template of a specific block may be an area or samples within the area, or a region of a preset location and range based on the location of the block. For example, the template of a specific block may be composed of surrounding samples adjacent to the boundary of the block. Specifically, the template of a current block may be composed of surrounding samples adjacent to the boundary of the current block. In addition, the template of a comparison target block to be compared with the current block may be composed of surrounding samples adjacent to the boundary of the comparison target block. In addition, the template may be determined from among the areas in which samples restored before the current block exist.

[0206] The aforementioned template matching cost may be the sum of the differences between sample values ​​corresponding to the same position in each of the multiple templates. In this case, a smaller sum may be determined as a more similar template. That is, the decoder may determine that a smaller sum indicates a better template match. Furthermore, a smaller sum may lower the template matching cost. Furthermore, template matching may be performed based on the absolute value or square of the difference between sample values ​​corresponding to the same position in each of the multiple templates. Template matching may be an operation of searching for a candidate block corresponding to the template with the smallest value difference from the template of the current block among candidate blocks to find a block similar to the current block. For example, when multiple candidate blocks exist, the lower the template matching cost between the template of the current block and the candidate block, the higher the probability that the candidate block will be selected as a merge or MVP target block. Furthermore, as the template matching cost decreases, the index of the candidate list may be set to a smaller value. For example, the candidate list can be rearranged so that among multiple candidate blocks included in the candidate list, a candidate with a smaller template matching cost has an index with a smaller value.

[0207] Referring to FIG. 26, the template of the current block may be composed of upper adjacent samples and left adjacent samples of the current block. However, the present disclosure is not limited thereto, and may be composed in other ways depending on at least one of a block scan order, a decoding order, or the availability of surrounding samples of the current block. According to one embodiment, the template of the current block and the template of the comparison target block may be compared. In FIG. 26, the comparison target block of the current block may be a block indicated by a motion vector of a co-located block located in a reference picture of the current block. In this case, the template (2701) of the current block and the template (2702) of the comparison target block may be compared. In addition, the decoder may determine a value difference between the current block and the comparison target block based on the comparison result. The decoder may reorder the candidate list or determine the target block based on the value difference between the current block and the comparison target block.

[0208] According to one embodiment of the present invention, MCR can be applied to any inter prediction method or motion vector acquisition method described in the present disclosure. For example, it can be applied to at least one of merge mode, pattern-matched motion vector refinement (PMVR) mode, or MVP mode. An encoder and decoder according to one embodiment of the present invention can acquire a motion information set by selecting a candidate indicated by a specific index from a candidate list reordered through the aforementioned MCR. At this time, a candidate corresponding to a smaller index value within the candidate list can be signaled using a smaller number of bits. Accordingly, a candidate with a higher probability of being selected can be arranged to correspond to a smaller index value within the candidate list.

[0209] FIG. 27 is a diagram illustrating whether or not a sign match is performed and a determination thereof according to an embodiment of the present invention. According to an embodiment of the present invention, an encoder may not explicitly signal a sign bit indicating sign information of a specific value. In this case, a decoder may estimate the sign information based on other signaled information. This may reduce signaling overhead when the sign information is not signaled via a separate bit. For example, an encoder may not explicitly signal sign information of a motion vector or a motion vector differential value. Furthermore, a decoder may estimate sign information of a motion vector or a motion vector differential value based on the signaled information.

[0210] According to a specific embodiment, when a decoder estimates sign information including n sign bits, the number of possible sign information types is 2^n. According to an embodiment of the present invention, an encoder and a decoder can construct a sign information list including possible sign information according to a rule predefined between the encoder and the decoder. The sign information list can include a plurality of candidate sign information. For example, as in FIG. 27, when two signs are estimated, the sign information list can include four pieces of candidate sign information.

[0211] According to one embodiment, the encoder may signal any one of the candidate code information included in the code information list. According to another embodiment, the encoder may signal transformation information indicating how each piece of candidate code information is transformed based on the reference code information. Specifically, the transformation information may indicate 'Hit' if the reference code information is not transformed, 'Vertical flip' if it is a vertical transformation that transforms the sign of the y-axis component, 'Horizontal flip' if it is a horizontal transformation that transforms the sign of the x-axis component, and 'Diagonal flip' if it is a diagonal transformation that transforms the signs of the x-axis and y-axis components, but the present disclosure is not limited thereto. For example, when the number of estimated code bits is three or more, another transformation method may be added.

[0212] Referring to FIG. 27, the reference code information may be the candidate code information with the lowest preset cost among the candidate code information included in the code information list. The encoder and decoder may determine the candidate code information with the lowest preset cost based on predefined rules. The preset cost may be the template matching cost described above with reference to FIG. 26.

[0213] Specifically, the decoder can obtain transformation information '10' indicating a transformation method from the encoder. In this case, the decoder can determine reference code information that serves as a reference among the candidate code information. That is, the decoder can determine candidate code information corresponding to a Hit among the candidate code information. For example, the decoder can use candidate code information with the smallest template matching cost among the candidate code information as reference code information. Next, the decoder can select candidate code information that is vertically flipped (10) from the reference code information. According to one embodiment, when the above-described sign information indicates the sign of the motion vector differential value of the current block, the sign information can include signs for each of the x-axis component and the y-axis component of (x, y), which are coordinates defining the motion vector. In this case, the decoder can use the selected candidate code information as sign information of the motion vector differential value to restore the current block.

[0214] Although FIG. 27 illustrates that the sign information list is structured in the order of vertical deformation, horizontal deformation, and diagonal deformation, the present disclosure is not limited thereto. For example, the sign information list may be structured so that horizontal deformation is signaled by a smaller number of bits than vertical deformation.

[0215] Additionally, information indicating each of the plurality of transformation methods may be signaled via at least one bit. In this case, the number of bits signaled to indicate the transformation method may be variable. The more likely a symbol is to be selected from the symbol information list, the fewer bits may be signaled. For example, the transformation method may be encoded using at least one of truncated unary binarization, unary binarization, or exp-Golomb binarization.

[0216] In further embodiments, information indicating a transformation method may be encoded based on context. This can reduce signaling overhead. For example, in FIG. 27, information corresponding to a specific transformation may be signaled using 2 bits, while information indicating other transformation methods other than the specific transformation method may be signaled using 3 bits. In this case, the information signaled using 2 bits may be determined based on context. Below, a method for encoding information indicating a transformation method based on context will be described with reference to FIGS. 28 and 29.

[0217] FIG. 28 and FIG. 29 are diagrams illustrating a method of encoding sign information considering context according to an embodiment of the present invention. In the embodiment of FIG. 28 and FIG. 29, information indicating a transformation method from reference sign information may be signaled via bits of variable length. According to an embodiment of the present invention, the transformation information indicating a transformation method from reference sign information may be determined based on the absolute value of the x-axis component and the absolute value of the y-axis component. For example, when the estimated sign information is sign information for a motion vector differential value of a current block, the transformation information may be determined based on the absolute value of the x-axis component and the absolute value of the y-axis component of the motion vector differential value.

[0218] Referring to FIG. 28, the transformation information for transforming the sign of the component corresponding to the smaller value among the absolute value of the x-axis component and the absolute value of the y-axis component can be signaled through a smaller number of bits. This is because the sign of the component corresponding to the smaller value among the absolute value of the x-axis component and the absolute value of the y-axis component can be flipped so that the distance is close to the value before the sign transformation. The closer the distance, the smaller the difference in the cost value can be. Specifically, the distance between positions (x, y) and positions (-x, y) can be a first distance, and the distance between positions (x, y) and positions (x, -y) can be a second distance. In this case, when the absolute value of y is smaller than the absolute value of x, the second distance can be closer than the first distance. In this case, the transformation information for transforming the sign of the y-axis component from the reference sign information can be signaled through a smaller number of bits than the transformation information for transforming the sign of the x-axis component.

[0219] In Fig. 28, the case of |x| < |y| and the case of |x| >= |y| are distinguished and explained, but the method of signaling transformation information may differ depending on the case of |x| <= |y| and the case of |x| > |y|. Alternatively, when |x| and |y| are not equal, a flip considering the absolute value of Fig. 10 may be performed, and when they are equal, the transformation information may be signaled according to a preset method. At this time, the preset method may be the method described through Fig. 27. According to an additional embodiment, a reordering process considering the absolute value may be added in the process of MCRing the aforementioned candidate list.

[0220] Also, referring to FIG. 28, the transformation information (diagonal flip) that flips the signs of both the x-axis and y-axis components can be signaled by '110'. Also, the transformation information (large absolute value flip) that does not flip the signs of the components with small absolute values ​​can be signaled by '111'. That is, the 'diagonal flip' can be signaled with a smaller value than the 'large absolute value flip'. Meanwhile, referring to FIG. 29, the 'diagonal flip' can be signaled by '111', and the 'large absolute value flip' can be signaled by '110'.

[0221] As in FIG. 27, the aforementioned sign information may be information indicating the sign of the motion vector or motion vector differential value of the current block. When the aforementioned sign information indicates the sign of the motion vector differential value of the current block, the sign information may include signs for each of the x-axis component and the y-axis component of the coordinates (x, y) defining the motion vector. According to one embodiment, the decoder may determine reference sign information corresponding to a Hit based on a template matching cost. For example, the decoder may use candidate sign information having the smallest template matching cost among candidate sign information as the reference sign information. Next, the decoder may compare the absolute value of the x-axis component and the absolute value of the y-axis component of the motion vector differential value of the current block. The decoder may obtain a transformation method based on the comparison result and the signaled transformation information. Next, the decoder may obtain final sign information to be applied to the absolute value of the motion vector differential value of the current block based on the obtained transformation method and the reference sign information. Additionally, the decoder can generate a final motion vector differential value by applying the final sign information obtained to the absolute value of the motion vector differential value. The decoder can reconstruct the current block based on the final motion vector differential value.

[0222] In the above-described embodiment, a method for estimating 2-bit sign information is described as an example, but the present disclosure is not limited thereto. The above-described method for estimating and signaling sign information can be applied in the same or corresponding manner even when estimating sign information including a number of sign bits exceeding 2 bits. For example, when estimating n signs, transformation information can be signaled based on the absolute value corresponding to each of the n signs. For example, the smaller the magnitude of the absolute value of a component, the transformation information for flipping the sign of the corresponding component can be signaled through a smaller number of bits.

[0223] Meanwhile, according to one embodiment of the present invention, a current block can be predicted by being divided into multiple regions to which different sets of motion information are applied. At this time, the current block can be divided based on boundary information. For example, a decoder can detect an edge within the current block. The decoder can detect the edge within the current block using a gradient-based Sobel operator. Next, the decoder can obtain boundary information based on the detected edge. At this time, the current block can be divided into at least two regions based on the detected edge. The decoder can divide the current block into at least two regions to which different sets of motion information are applied based on the boundary information. Hereinafter, a method for performing inter prediction based on different sets of motion information for each region divided from a current block according to one embodiment of the present invention will be described.

[0224] FIG. 30 is a diagram illustrating a method for predicting based on different motion information sets for each region segmented from a current block according to one embodiment of the present invention. Referring to FIG. 30, a current block (310) may be segmented into a first region (311) and a second region (312) based on boundary information of the current block (310). First, a motion information set corresponding to the first region (311) may include a motion vector and a reference picture index indicating a first reference block (320) including a region similar to the first region (311) of the current block (310). That is, a first motion information set may be obtained based on original sample values ​​of the first region (311) of the current block (310) and sample values ​​of a first partial region (321) corresponding to the first region within the first reference block (320). SAD or SATD can be calculated based on the original sample value of the first region (311) of the current block (310) and the sample value corresponding to the first partial region (321). In addition, the first motion information set of the first region (311) of the current block (310) can be represented as {MV_R1, ref_idx_R1}.

[0225] Similarly, the above-described embodiment can be applied to the second region (312) of the current block (310). For example, a second motion information set can be obtained based on the original sample value of the second region (312) of the current block (310) and the sample value of the second partial region (332) corresponding to the second region within the second reference block (330). The second motion information set corresponding to the second region (312) can be represented as {MV_R2, ref_idx_R2}. Meanwhile, the reference picture index for the first region (311) and the reference picture index for the second region (312) can be the same.

[0226] A decoder according to one embodiment of the present invention can obtain a final prediction block of a current block based on the first motion information set and the second motion information set obtained through the above-described method. For example, the decoder can generate a first prediction block for a first region (311) based on the first motion information set. Additionally, the decoder can generate a second prediction block for a second region (312) based on the second motion information set.

[0227] Next, the decoder can generate a final prediction block for the current block by merging the first prediction block and the second prediction block. For example, the decoder can generate a first prediction block in which the sample value corresponding to an area other than the first partial area (321) is '0'. In addition, the decoder can generate a second prediction block in which the sample value corresponding to an area other than the second partial area (322) is '0'. In this case, the final prediction block can be expressed as the sum of the first prediction block and the second prediction block. Additionally, the decoder can generate the first prediction block and the second prediction block using boundary information. The encoder and the decoder can generate boundary information according to a predefined rule. In this case, the boundary information generated by the encoder and the decoder respectively can be identical. In addition, the decoder can generate a prediction block identical to the prediction block predicted by the encoder based on the boundary information.

[0228] In an additional embodiment, the decoder may perform vertical / horizontal filtering on samples around the boundary between the first region (311) and the second region (312). In this case, the samples around the boundary may be samples adjacent to the boundary. In addition, the decoder may perform filtering using a low-pass filter that passes a frequency band lower than a reference frequency. In addition, the decoder may perform filtering using a low-pass 3-tap filter. The filter coefficients of the low-pass 3-tap filter may be {1 / 4, 2 / 4, 1 / 4}.

[0229] Meanwhile, when the current block is divided into multiple regions as in FIG. 30, some of the multiple regions may be intra-predicted, and the remaining parts may be inter-predicted. FIG. 31 is a diagram illustrating a method for performing intra-prediction or inter-prediction on each region divided from the current block according to an embodiment of the present invention. As in the embodiment of FIG. 30, the current block may be divided based on boundary information. For example, the current block may be divided into a first region (3201) and a second region (3202) based on boundary information.

[0230] In a specific embodiment, the first region (3201) may be encoded according to an intra prediction method, and the second region (3202) may be encoded according to an inter prediction method. In this case, the decoder may obtain a motion information set corresponding to the second region (3202) and generate a second prediction block corresponding to the second region (3202) based on the motion information set {MV_R2, ref_idx_R2}.

[0231] Additionally, the decoder can generate a first prediction block corresponding to the first region (3201) based on reference samples on the left or upper side of the current block. The decoder can generate the first prediction block based on the intra prediction mode of the current block. At this time, the intra prediction mode for predicting the first region (3201) in the encoder can be determined using the following formula.

[0232] [Equation 7]

[0233]

[0234] In [Mathematical Formula 7], SATD may be a value obtained by performing a Hadamard transform on the residual signal between the current block and the first prediction block. That is, SATD represents the difference between the original signal and the prediction signal corresponding to the first region. bit(i) represents the number of bits required to encode the ith intra prediction mode, and λ may be a parameter that adjusts the unit between the residual signal and the encoding rate. The encoder may signal the intra prediction mode that minimizes cost(i) of [Mathematical Formula 7]. In addition, the decoder may generate the first prediction block for the first region (3201) using the parsed intra prediction mode.

[0235] Next, the decoder can merge the first prediction block and the second prediction block to generate a final prediction block for the current block. The decoder can merge the first prediction block and the second prediction block based on boundary information. At this time, the sample value of the area excluding the first region (3201) in the first prediction block can be set to '0'. Additionally, the sample value of the area excluding the second region (3202) in the second prediction block can be set to '0'. In this case, the final prediction block can be expressed as the sum of the first prediction block and the second prediction block.

[0236] FIG. 31(a) illustrates a method for performing intra prediction on a first region when the boundary between the first region and the second region forms a closed curve according to one embodiment of the present invention. When the width of the current block is W and the height is H, the decoder can perform intra prediction using at most 2*W + 2*H + 1 reconstructed samples existing around the current block.

[0237] FIG. 31(b) illustrates a method for performing intra prediction on a first region when the boundary between the first region and the second region intersects the current block in an arbitrary shape, according to one embodiment of the present invention. Similar to FIG. 31(a), the decoder can perform intra prediction using at most 2*W + 2*H + 1 reconstructed samples existing around the current block.

[0238] FIGS. 31(c) to 31(e) illustrate a method for performing intra prediction on a first region based on padded reference samples when the boundary between the first region and the second region intersects the current block in an arbitrary shape, according to one embodiment of the present invention. For example, if the first region and the second region within the current block are images representing different objects, it may be efficient to utilize only the portions of the surrounding samples of the current block that are continuous with the first region.

[0239] In Fig. 31(c), the point where the boundary within the current block meets the upper boundary of the current block and the point where the boundary within the current block meets the left boundary of the current block may be (x', 0) and (0, y'), respectively. At this time, the decoder may perform reference sample padding in the right direction based on the reconstructed sample at the position (x', -1). The decoder may construct upper reference samples using the padded samples on the right of (x', -1) and (x' + 1) reconstructed samples. In addition, the decoder may perform reference sample padding in the downward direction based on the reconstructed sample at the position (-1, y'). The decoder may construct left reference samples using the padded samples on the lower side of (-1, y') and (y' + 1) reconstructed samples.

[0240] Figure 31(d) illustrates a case where the boundary within the current block intersects the upper boundary of the current block, but does not intersect the left boundary. In this case, the point where the boundary between the first region and the second region intersects the upper boundary of the current block may be (x'', 0). The decoder may perform rightward reference sample padding based on the reconstructed sample at the position (x'', -1). The decoder may construct upper reference samples using the padded samples on the right from (x'', -1) and (x'' + 1) reconstructed samples. Additionally, the left reference samples may use existing reconstructed samples.

[0241] Figure 31(e) illustrates a case where the boundary within the current block intersects the left boundary of the current block, but does not intersect the upper boundary. In this case, the point where the boundary between the first region and the second region intersects the left boundary of the current block may be (0, y''). The decoder may perform downward reference sample padding based on the reconstructed sample at the position (-1, y''). The decoder may construct left reference samples using the padded samples from (-1, y') downward and (y'' + 1) reconstructed samples. Additionally, the upper reference samples may use existing reconstructed samples.

[0242] The embodiments of the present invention described above may be implemented through various means. For example, the embodiments of the present invention may be implemented through hardware, firmware, software, or a combination thereof.

[0243] In the case of hardware implementation, the method according to embodiments of the present invention may be implemented by one or more ASICs (Application Specific Integrated Circuits), DSPs (Digital Signal Processors), DSPDs (Digital Signal Processing Devices), PLDs (Programmable Logic Devices), FPGAs (Field Programmable Gate Arrays), processors, controllers, microcontrollers, microprocessors, etc.

[0244] When implemented via firmware or software, the methods according to embodiments of the present invention may be implemented in the form of modules, procedures, or functions that perform the functions or operations described above. The software code may be stored in memory and executed by the processor. The memory may be located internally or externally to the processor and may exchange data with the processor via various known means.

[0245] The foregoing description of the present invention is for illustrative purposes only, and those skilled in the art will readily appreciate that the present invention can be readily modified into other specific forms without altering the technical spirit or essential characteristics of the present invention. Therefore, the embodiments described above should be construed as illustrative and not restrictive in all respects. For example, components described as being single may be implemented in a distributed manner, and similarly, components described as being distributed may be implemented in a combined manner.

[0246] The scope of the present invention is indicated by the claims described below rather than the detailed description above, and all changes or modifications derived from the meaning and scope of the claims and their equivalent concepts should be interpreted as being included in the scope of the present invention.

Claims

1. In a video signal processing method, A step of obtaining a merge index indicating a candidate for prediction of the current block among a plurality of candidates included in a merge candidate list for prediction of the current block; A step of obtaining motion information of the current block based on motion information corresponding to a candidate indicated by the merge index; When the motion information of the current block includes a plurality of motion vectors corresponding to different reference picture lists, a step of comparing a picture order count (POC) difference between each of the reference pictures corresponding to each of the plurality of motion vectors and the current picture including the current block; a step of correcting the plurality of motion vectors based on the comparison results; and A video signal processing method, comprising a step of restoring the current block based on the plurality of corrected motion vectors.

2. In paragraph 1, The above plurality of motion vectors include a first motion vector and a second motion vector, The step of correcting the above plurality of motion vectors is: A step of obtaining a first POC difference and a second POC difference, wherein the first POC difference represents a POC difference between a first reference picture corresponding to the first motion vector and the current picture, and the second POC difference represents a POC difference between a second reference picture corresponding to the second motion vector and the current picture; A step of comparing the first POC difference and the second POC difference to obtain a specific offset which is a correction value of one of the first motion vector and the second motion vector; and A video signal processing method, comprising the step of correcting the first motion vector and the second motion vector based on the specific offset.

3. In paragraph 2, The step of correcting the above plurality of motion vectors is: A video signal processing method, comprising a step of obtaining the specific offset before a correction value of the remaining one of the first motion vector and the second motion vector based on a result of comparing the first POC difference and the second POC difference.

4. In paragraph 3, If the first POC difference is greater than the second POC difference, the specific offset is a correction value of the first motion vector, A video signal processing method, wherein if the first POC difference is smaller than the second POC difference, the specific offset is a correction value of the second motion vector.

5. In paragraph 3 If the first POC difference is greater than the second POC difference, the specific offset is a first offset which is a correction value of the first motion vector, The step of correcting the above plurality of motion vectors is: A step of correcting the first motion vector by adding the first offset; A step of obtaining a second offset, which is a correction value of the second motion vector, based on the specific offset; and A video signal processing method, comprising the step of correcting the second motion vector by adding the second offset.

6. In paragraph 5, The step of correcting the above plurality of motion vectors is: A step of generating a first corrected motion vector by adding the first offset to the first motion vector, and generating a second corrected motion vector by adding the second offset to the second motion vector; and The steps to restore the current block above are: A video signal processing device, comprising a step of restoring the current block based on the first corrected motion vector and the second corrected motion vector.

7. In paragraph 3 The step of obtaining the above specific offset is: A video signal processing method, comprising the step of obtaining a specific offset, which is a correction value for one of the first motion vector and the second motion vector, based on a value representing a reference picture list corresponding to each of the first motion vector and the second motion vector, when the first POC difference and the second POC difference are the same.

8. In paragraph 7, The step of obtaining the above specific offset is: A video signal processing method, comprising the step of obtaining a specific offset, which is a correction value of the first motion vector, when a value indicating a first reference picture list corresponding to the first motion vector is 0 and a value indicating a second reference picture list of the second motion vector is 1.

9. In paragraph 8, A video signal processing method, wherein the first reference picture list is used in a first upper level area in which at most one motion vector is used for a specific sample and a second upper level area in which at most two motion vectors are used for a specific sample, and the second reference picture list is not used in the first upper level area.

10. In a video signal processing device, Includes a processor, The above processor, Obtain a merge index indicating a candidate for prediction of the current block among multiple candidates included in a merge candidate list for prediction of the current block, Obtaining motion information of the current block based on motion information corresponding to the candidate indicated by the merge index, If the motion information of the current block includes a plurality of motion vectors corresponding to different reference picture lists, the picture order count (POC) difference between each of the reference pictures corresponding to each of the plurality of motion vectors and the current picture including the current block is compared, Based on the above comparison results, the plurality of motion vectors are corrected, A video signal processing device that restores the current block based on the plurality of corrected motion vectors.

11. In paragraph 10, The above plurality of motion vectors include a first motion vector and a second motion vector, The above processor, Obtain the first POC difference and the second POC difference, By comparing the first POC difference and the second POC difference, a specific offset which is a correction value of one of the first motion vector and the second motion vector is obtained, Correcting the first motion vector and the second motion vector based on the specific offset, A video signal processing device, wherein the first POC difference represents a POC difference between a first reference picture corresponding to the first motion vector and the current picture, and the second POC difference represents a POC difference between a second reference picture corresponding to the second motion vector and the current picture.

12. In paragraph 11, The above processor, A video signal processing device, wherein the specific offset is acquired before the correction value of the remaining one of the first motion vector and the second motion vector based on the result of comparing the first POC difference and the second POC difference.

13. In paragraph 12, If the first POC difference is greater than the second POC difference, the specific offset is a correction value of the first motion vector, A video signal processing device, wherein when the first POC difference is smaller than the second POC difference, the specific offset is a correction value of the second motion vector.

14. In paragraph 12 If the first POC difference is greater than the second POC difference, the specific offset is a first offset which is a correction value of the first motion vector, The above processor, Compensate the first motion vector by adding the first offset, Obtaining a second offset, which is a correction value of the second motion vector, based on the specific offset; A video signal processing device that corrects the second motion vector by adding the second offset.

15. In paragraph 14, The above processor, Generating a first corrected motion vector by adding the first offset to the first motion vector, and generating a second corrected motion vector by adding the second offset to the second motion vector, A video signal processing device that restores the current block based on the first corrected motion vector and the second corrected motion vector.

16. In paragraph 12 The above processor, A video signal processing device that obtains a specific offset, which is a correction value for one of the first motion vector and the second motion vector, based on a value representing a reference picture list corresponding to each of the first motion vector and the second motion vector, when the first POC difference and the second POC difference are the same.

17. In paragraph 16, The above processor, A video signal processing device that obtains a specific offset, which is a correction value of the first motion vector, when a value indicating a first reference picture list corresponding to the first motion vector is 0 and a value indicating a second reference picture list of the second motion vector is 1.

18. In paragraph 17, A video signal processing device, wherein the first reference picture list is used in a first upper level area in which at most one motion vector is used for a specific sample and a second upper level area in which at most two motion vectors are used for a specific sample, and the second reference picture list is not used in the first upper level area.