Device and method for encoding image by using template cost, and device and method for decoding image by using template cost

The template cost-based method improves video encoding and decoding by selecting optimal reference blocks, enhancing compression performance, reducing data signaling, and lowering bit rate while improving image quality.

WO2026010409A1PCT designated stage Publication Date: 2026-01-08SAMSUNG ELECTRONICS CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/KR2025/009548
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-12-03
Filing Date
2025-07-03
Publication Date
2026-01-08

AI Technical Summary

Technical Problem

Existing video encoding and decoding technologies face challenges in reducing the amount of data required for signaling intra and inter prediction modes, improving image quality, and optimizing bit rate, while maintaining efficient compression performance.

Method used

The method and device utilize a template cost-based approach to determine a reference block from candidate reference blocks, improving prediction performance by using template costs to select the most suitable reference block for intra and inter prediction.

Benefits of technology

This approach enhances compression performance, reduces data signaling requirements, lowers bit rate, and improves decoding quality by optimizing the selection of reference blocks for prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure KR2025009548_08012026_PF_FP_ABST
    Figure KR2025009548_08012026_PF_FP_ABST
Patent Text Reader

Abstract

A method for decoding an image, according to one embodiment of the present disclosure, may comprise a step of acquiring first sample values corresponding to positions of samples in a current block on the basis of at least one of a template of the current block, a candidate reference block, and a template of the candidate reference block. The method for decoding an image may comprise a step of determining a template cost on the basis of the first sample values and second sample values of samples in the candidate reference block. The method for decoding an image may comprise a step of determining a reference block from among a plurality of candidate reference blocks including the candidate reference block on the basis of the template cost. The image decoding method may comprise a step of acquiring a prediction block of the current block by using the reference block.
Need to check novelty before this filing date? Find Prior Art

Description

Device and method for encoding an image using a template cost, device and method for decoding an image using a template cost

[0001] The present disclosure relates to the field of video encoding and decoding, and more particularly, to a device and method for encoding or decoding a video by encoding or decoding using a template cost.

[0002] In video encoding and decoding, the image is divided into blocks, and each block is predicted and decoded through inter prediction.

[0003] Intra prediction is a technique for compressing images by removing spatial redundancy. Intra prediction, predictions are made based on previously encoded or decoded neighboring blocks within the current image, and the resulting predicted block is subtracted from the current block to produce a residual block.

[0004] Inter prediction is a technique for compressing images by removing temporal redundancy between images. Inter prediction uses a reference image to predict blocks in the current image. The reference block most similar to the current block can be searched within a predetermined search range within the reference image. The current block is predicted based on the reference block, and the predicted block generated as a result of the prediction is subtracted from the current block to generate a residual block.

[0005] Codecs such as H.264 AVC (Advanced Video Coding) and HEVC (High Efficiency Video Coding) use the motion vectors of previously encoded blocks adjacent to the current block or blocks included in a previously encoded image as motion vector predictors of the current block to predict the motion vector of the current block. The difference between the motion vector of the current block and the motion vector predictor, called the motion vector difference, is signaled to the decoder through a predetermined method.

[0006] The residual block generated through intra-prediction or inter-prediction undergoes transformation and quantization and is then passed to the decoder. The decoder dequantizes and inversely transforms the residual block, and combines the predicted block of the current block with the residual block to reconstruct the current block. In certain cases, the decoder can filter the reconstructed current block to remove artifacts within it.

[0007] A method and device for encoding an image, and a method and device for decoding an image, according to one embodiment, aim to improve the performance of predictive encoding and predictive decoding for a current block.

[0008] A method and device for encoding an image, and a method and device for decoding an image, according to one embodiment, aim to reduce the amount of data required for signaling an intra prediction mode or an inter prediction mode.

[0009] A method and device for encoding an image according to one embodiment, and a method and device for decoding an image, have as their object the reduction of the bit rate of a bitstream.

[0010] A method and device for encoding an image, and a method and device for decoding an image, according to one embodiment, aim to improve image quality by making a decoded image more similar to an original image.

[0011] The technical problems to be achieved through the present disclosure are not limited to the technical problems mentioned above, and other technical problems not mentioned will be clearly understood by a person having ordinary skill in the technical field to which the present disclosure pertains from the description below.

[0012] In one embodiment of the present disclosure, a video decoding method is provided. The video decoding method may include a step of obtaining first sample values ​​corresponding to positions of samples within a current block based on at least one of a template of a current block, a candidate reference block, and a template of the candidate reference block. The video decoding method may include a step of determining a template cost based on the first sample values ​​and second sample values ​​of samples within the candidate reference block. The video decoding method may include a step of determining a reference block from among a plurality of candidate reference blocks including the candidate reference block based on the template cost. The video decoding method may include a step of obtaining a prediction block of the current block using the reference block.

[0013] In one embodiment of the present disclosure, an image decoding device may be provided, including at least one memory storing at least one instruction; and at least one processor operating according to the at least one instruction. The at least one processor may obtain first sample values ​​corresponding to positions of samples in a current block based on at least one of a template of a current block, a candidate reference block, and a template of the candidate reference block. The at least one processor may determine a template cost based on the first sample values ​​and second sample values ​​of samples in the candidate reference block. The at least one processor may determine a reference block from among a plurality of candidate reference blocks including the candidate reference block based on the template cost. The at least one processor may obtain a prediction block of the current block using the reference block.

[0014] In one embodiment of the present disclosure, a video encoding method may be provided. The video encoding method may include a step of obtaining first sample values ​​corresponding to positions of samples within a current block based on at least one of a template of a current block, a candidate reference block, and a template of the candidate reference block. The video encoding method may include a step of determining a template cost based on the first sample values ​​and second sample values ​​of samples within the candidate reference block. The video encoding method may include a step of determining a reference block from among a plurality of candidate reference blocks including the candidate reference block based on the template cost. The video encoding method may include a step of obtaining a prediction block of the current block using the reference block.

[0015] In one embodiment of the present disclosure, an image encoding apparatus may be provided, including at least one memory storing at least one instruction; and at least one processor operating according to the at least one instruction. The at least one processor may obtain first sample values ​​corresponding to positions of samples in a current block based on at least one of a template of a current block, a candidate reference block, and a template of the candidate reference block. The at least one processor may determine a template cost based on the first sample values ​​and second sample values ​​of samples in the candidate reference block. The at least one processor may determine a reference block from among a plurality of candidate reference blocks including the candidate reference block based on the template cost. The at least one processor may obtain a prediction block of the current block using the reference block.

[0016] In one embodiment of the present disclosure, a computer-readable recording medium storing a bitstream generated according to the image encoding method performed by the image encoding device may be provided.

[0017] According to one embodiment of the present disclosure, in the process of decoding and encoding an image, the compression performance of the image can be improved, the amount of data required for signaling can be reduced, the bit rate can be reduced, the prediction performance can be improved, and the decoding quality of the image can be improved.

[0018] FIG. 1 is a block diagram of an image decoding device according to one embodiment.

[0019] FIG. 2 is a block diagram of an image encoding device according to one embodiment.

[0020] FIG. 3 illustrates a process of dividing a current encoding unit to determine at least one encoding unit according to one embodiment.

[0021] FIG. 4 illustrates a process of dividing a non-square coding unit to determine at least one coding unit according to one embodiment.

[0022] FIG. 5 illustrates a process of dividing an encoding unit based on at least one of block shape information and segmentation shape mode information according to one embodiment.

[0023] FIG. 6 illustrates a method for determining a predetermined coding unit among an odd number of coding units according to one embodiment.

[0024] FIG. 7 illustrates the order in which multiple encoding units are processed when a current encoding unit is divided to determine multiple encoding units according to one embodiment.

[0025] FIG. 8 illustrates a process for determining that a current encoding unit is split into an odd number of encoding units when encoding units cannot be processed in a predetermined order according to one embodiment.

[0026] FIG. 9 illustrates a process of dividing a first encoding unit to determine at least one encoding unit according to one embodiment.

[0027] FIG. 10 illustrates that, according to one embodiment, the shapes into which a first encoding unit can be divided are limited when a second encoding unit of a non-square shape determined by splitting the first encoding unit satisfies a predetermined condition.

[0028] FIG. 11 illustrates a process of splitting a square-shaped encoding unit when the split shape mode information cannot represent splitting into four square-shaped encoding units according to one embodiment.

[0029] FIG. 12 illustrates that, according to one embodiment, the processing order between multiple encoding units may vary depending on the process of splitting the encoding units.

[0030] FIG. 13 illustrates a process in which the depth of an encoding unit is determined as the shape and size of the encoding unit change when the encoding unit is recursively split to determine a plurality of encoding units according to one embodiment.

[0031] FIG. 14 illustrates an index (part index, hereinafter referred to as PID) for depth and encoding unit distinction that can be determined according to the shape and size of encoding units according to one embodiment.

[0032] FIG. 15 illustrates that a plurality of coding units are determined according to a plurality of predetermined data units included in a picture according to one embodiment.

[0033] FIG. 16 illustrates encoding units that can be determined for each picture when the combination of forms into which encoding units can be divided is different for each picture according to one embodiment.

[0034] FIG. 17 illustrates various forms of encoding units that can be determined based on segmentation form mode information expressed in binary code according to one embodiment.

[0035] FIG. 18 illustrates another form of a coding unit that can be determined based on segmentation mode information expressed in binary code according to one embodiment.

[0036] FIG. 19 is a block diagram of an image encoding and decoding system that performs loop filtering according to one embodiment.

[0037] Fig. 20 is a block diagram illustrating a configuration of an image decoding device according to one embodiment.

[0038] FIG. 21 is a diagram illustrating neighboring blocks temporally and / or spatially related to a current block according to one embodiment.

[0039] Fig. 22 is a drawing for explaining a template in template matching according to one embodiment.

[0040] FIG. 23 is a diagram for explaining an operation of determining a reference block by performing template matching according to one embodiment.

[0041] FIG. 24 is a diagram for explaining an operation of determining a reference block by performing template matching according to one embodiment.

[0042] FIG. 25 is a diagram for explaining an operation of determining a reference block by performing template matching according to one embodiment.

[0043] FIG. 26 is a diagram illustrating a search range for determining a reference block by performing template matching according to one embodiment.

[0044] Fig. 27 is a diagram for explaining an operation of determining a template cost according to one embodiment.

[0045] Fig. 28 is a diagram for explaining an operation of determining a template cost according to one embodiment.

[0046] Fig. 29 is a diagram for explaining an operation of determining a template cost according to one embodiment.

[0047] Fig. 30 is a diagram for explaining an operation of determining a template cost according to one embodiment.

[0048] Figure 31 is a flowchart of an image decoding method according to one embodiment.

[0049] Fig. 32 is a block diagram illustrating a configuration of an image encoding device according to one embodiment.

[0050] Figure 33 is a flowchart of an image encoding method according to one embodiment.

[0051] The present disclosure may be subject to various modifications and various embodiments. Examples are illustrated in the drawings and described in detail in the detailed description. However, this is not intended to limit the embodiments of the present disclosure, and the present disclosure may include all modifications, equivalents, and alternatives that fall within the spirit and technical scope of the various embodiments.

[0052] When describing embodiments, detailed descriptions of related known technologies may be omitted if they are deemed to unnecessarily obscure the gist of the present disclosure. Furthermore, numbers (e.g., "first," "second," etc.) used in the description of embodiments may correspond to identification symbols used to distinguish one component from another.

[0053] In this disclosure, the expression “at least one of a, b or c” may refer to “a”, “b”, “c”, “a and b”, “a and c”, “b and c”, “all of a, b and c”, or variations thereof.

[0054] In the present disclosure, when a component is referred to as being “connected” or “connected” to another component, the component may be directly connected or connected to the other component, but unless there is a specific description to the contrary, the component may also be connected or connected via another component in between.

[0055] In the present disclosure, components expressed as "units", "modules", etc. may be two or more components combined into a single component, or a single component may be divided into two or more more detailed components. In addition, each component described below may additionally perform some or all of the functions performed by other components in addition to its own main function, and some of the main functions performed by each component may be exclusively performed by other components.

[0056] In the present disclosure, 'image' may refer to a picture, a still image, a frame, a moving image composed of a plurality of consecutive still images, or a video.

[0057] In this disclosure, "sample" may refer to data assigned to a sampling location in an image and thus to be processed. For example, a pixel within a frame in a spatial domain may correspond to a sample. A unit containing multiple samples may be defined as a block.

[0058] Hereinafter, with reference to FIGS. 1 to 19, an image encoding method and device based on a tree-structured encoding unit and a transformation unit according to one embodiment, and an image decoding method and device are disclosed.

[0059] FIG. 1 illustrates a block diagram of an image decoding device (100) according to one embodiment.

[0060] The video decoding device (100) may include a bitstream acquisition unit (110) and a decoding unit (120). The bitstream acquisition unit (110) and the decoding unit (120) may include at least one processor. In addition, the bitstream acquisition unit (110) and the decoding unit (120) may include a memory that stores commands to be executed by at least one processor.

[0061] The bitstream acquisition unit (110) can receive a bitstream. The bitstream includes information obtained by encoding an image by an image encoding device (200) described below. In addition, the bitstream can be transmitted from the image encoding device (200). The image encoding device (200) and the image decoding device (100) can be connected by wire or wirelessly, and the bitstream acquisition unit (110) can receive the bitstream by wire or wirelessly. The bitstream acquisition unit (110) can receive the bitstream from a storage medium such as an optical medium, a hard disk, etc. The decoding unit (120) can restore the image based on information obtained from the received bitstream. The decoding unit (120) can obtain syntax elements for restoring the image from the bitstream. The decoding unit (120) can restore the image based on the syntax elements.

[0062] To describe in detail the operation of the video decoding device (100), the bitstream acquisition unit (110) can receive a bitstream.

[0063] The image decoding device (100) may perform an operation of obtaining a binstring corresponding to a splitting shape mode of an encoding unit from a bitstream. In addition, the image decoding device (100) may perform an operation of determining a splitting rule of the encoding unit. In addition, the image decoding device (100) may perform an operation of splitting the encoding unit into a plurality of encoding units based on at least one of the binstring corresponding to the splitting shape mode and the splitting rule. In order to determine the splitting rule, the image decoding device (100) may determine a first allowable range of the size of the encoding unit according to a ratio of the width and height of the encoding unit. In order to determine the splitting rule, the image decoding device (100) may determine a second allowable range of the size of the encoding unit according to the splitting shape mode of the encoding unit.

[0064] Below, the division of encoding units according to one embodiment of the present disclosure is described in detail.

[0065] First, a picture can be divided into one or more slices or one or more tiles. A slice or a tile can be a sequence of one or more maximum coding tree units (CTUs). Depending on the implementation, a slice may include one or more tiles, and a slice may include one or more maximum coding units. A slice including one or more tiles can be determined within a picture.

[0066] The maximum coding block (Coding Tree Block; CTB) is a concept that contrasts with the maximum coding unit (CTU). A CTB is an NxN block containing NxN samples (N is an integer). Each color component can be divided into one or more CTBs.

[0067] When a picture has three sample arrays (sample arrays for Y, Cr, and Cb components), a maximum coding unit (CTU) is a unit that includes a maximum coding block of luma samples, two maximum coding blocks of corresponding chroma samples, and syntax structures used to encode the luma samples and chroma samples. When a picture is a monochrome picture, a maximum coding unit is a unit that includes a maximum coding block of monochrome samples and syntax structures used to encode the monochrome samples. When a picture is a picture that is encoded with a color plane that is separated by color components, a maximum coding unit is a unit that includes syntax structures used to encode the picture and samples of the picture.

[0068] A single maximum coding block (CTB) can be divided into MxN coding blocks containing MxN samples (M, N are integers).

[0069] When a picture has a sample array for each Y, Cr, and Cb component, a coding unit (CU) is a unit that includes a coding block for a luma sample and two coding blocks for corresponding chroma samples, and syntax structures used to encode the luma sample and the chroma samples. When a picture is a monochrome picture, a coding unit is a unit that includes a coding block for a monochrome sample and syntax structures used to encode the monochrome samples. When a picture is a picture that is encoded with a color plane that is separated by color component, a coding unit is a unit that includes syntax structures used to encode the picture and samples of the picture.

[0070] As explained above, the maximum coding block and the maximum coding unit are distinct concepts, and the coding block and the coding unit are distinct concepts. That is, the (maximum) coding unit refers to a data structure including a (maximum) coding block including the corresponding sample and a syntax structure corresponding to it. However, since a person skilled in the art can understand that the (maximum) coding unit or the (maximum) coding block refers to a block of a predetermined size including a predetermined number of samples, the following specification will refer to the maximum coding block and the maximum coding unit, or the coding block and the coding unit, without distinction unless there are special circumstances.

[0071] An image can be divided into Coding Tree Units (CTUs). The size of the CTUs can be determined based on information obtained from the bitstream. The shape of the CTUs can be a square of equal size, but is not limited thereto.

[0072] For example, information about the maximum size of a luma coding block can be obtained from the bitstream. For example, the maximum size of the luma coding block indicated by the information about the maximum size of the luma coding block can be one of 4x4, 8x8, 16x16, 32x32, 64x64, 128x128, and 256x256.

[0073] For example, information about the maximum size of a luma coding block capable of being split into two and the luma block size difference can be obtained from the bitstream. The information about the luma block size difference can indicate the size difference between a luma maximum coding unit and a maximum luma coding block capable of being split into two. Therefore, by combining the information about the maximum size of a luma coding block capable of being split into two obtained from the bitstream and the information about the luma block size difference, the size of the luma maximum coding unit can be determined. Using the size of the luma maximum coding unit, the size of the chroma maximum coding unit can also be determined. For example, if the Y: Cb: Cr ratio is 4:2:0 according to the color format, the size of the chroma block can be half the size of the luma block, and similarly, the size of the chroma maximum coding unit can be half the size of the luma maximum coding unit.

[0074] According to one embodiment, since information about the maximum size of a luma coding block capable of binary splitting is obtained from a bitstream, the maximum size of the luma coding block capable of binary splitting can be determined variably. In contrast, the maximum size of a luma coding block capable of ternary splitting can be fixed. For example, the maximum size of a luma coding block capable of ternary splitting in an I picture may be 32x32, and the maximum size of a luma coding block capable of ternary splitting in a P picture or a B picture may be 64x64.

[0075] Additionally, the maximum coding unit can be hierarchically divided into coding units based on the division shape mode information obtained from the bitstream. As the division shape mode information, at least one of information indicating whether quad division is performed, information indicating whether multi-division is performed, division direction information, and division type information can be obtained from the bitstream.

[0076] For example, information indicating whether a quad split is present may indicate whether the current encoding unit is to be quad split (QUAD_SPLIT) or not to be quad split.

[0077] If the current encoding unit is not quad-split, the information indicating whether it is multi-split may indicate whether the current encoding unit will not be split any further (NO_SPLIT) or whether it will be binary / ternary split.

[0078] When the current encoding unit is binary or ternary split, the split direction information indicates that the current encoding unit is split in either the horizontal or vertical direction.

[0079] When the current encoding unit is split in the horizontal or vertical direction, the split type information indicates that the current encoding unit is split into binary split or ternary split.

[0080] Depending on the split direction information and the split type information, the split mode of the current encoding unit can be determined. The split mode when the current encoding unit is split into binaries in the horizontal direction can be determined as binary horizontal split (SPLIT_BT_HOR), the split mode when the current encoding unit is split into ternary horizontal split (SPLIT_TT_HOR), the split mode when the current encoding unit is split into binaries in the vertical direction can be determined as binary vertical split (SPLIT_BT_VER), and the split mode when the current encoding unit is split into ternary vertical split (SPLIT_TT_VER).

[0081] The image decoding device (100) can obtain segmentation shape mode information from a bitstream from a single binstring. The format of the bitstream received by the image decoding device (100) can include a fixed length binary code, a unary code, a truncated unary code, a predetermined binary code, etc. The binstring represents information as a series of binary numbers. The binstring can be composed of at least one bit. The image decoding device (100) can obtain segmentation shape mode information corresponding to the binstring based on a segmentation rule. The image decoding device (100) can determine whether to quad-segment an encoding unit, whether not to quad-segment, or the segmentation direction and segmentation type based on a single binstring.

[0082] The coding unit may be smaller than or equal to the maximum coding unit. For example, the maximum coding unit is also a coding unit with the maximum size, so it is a coding unit. If the split shape mode information for the maximum coding unit indicates that it is not split, the coding unit determined from the maximum coding unit has the same size as the maximum coding unit. If the split shape mode information for the maximum coding unit indicates that it is split, the maximum coding unit may be split into coding units. In addition, if the split shape mode information for the coding unit indicates splitting, the coding units may be split into coding units of smaller sizes. However, the splitting of the image is not limited thereto, and the maximum coding unit and the coding units may not be distinguished. The splitting of the coding unit is described in more detail with reference to FIGS. 3 to 16.

[0083] Additionally, one or more prediction blocks for prediction may be determined from the coding unit. The prediction blocks may be equal to or smaller than the coding unit. Additionally, one or more transformation blocks for transformation may be determined from the coding unit. The transformation blocks may be equal to or smaller than the coding unit.

[0084] The shape and size of the transformation block and the prediction block may be unrelated.

[0085] In another embodiment, prediction may be performed using the encoding unit as a prediction block. Transformation may also be performed using the encoding unit as a transform block.

[0086] The division of a coding unit is described in more detail with reference to FIGS. 3 to 16. The current block and neighboring blocks of the present disclosure may represent one of a maximum coding unit, a coding unit, a prediction block, and a transform block. In addition, the current block or the current coding unit is a block currently being decoded or encoded, or a block currently being divided. The neighboring block may be a block reconstructed before the current block. The neighboring block may be spatially or temporally adjacent to the current block. The neighboring block may be located on one of the lower left, left, upper left, upper right, upper right, right, and lower right sides of the current block.

[0087] FIG. 3 illustrates a process in which an image decoding device (100) divides a current encoding unit to determine at least one encoding unit according to one embodiment.

[0088] The block shape may include 4Nx4N, 4Nx2N, 2Nx4N, 4NxN, Nx4N, 32NxN, Nx32N, 16NxN, Nx16N, 8NxN or Nx8N, where N may be a positive integer. The block shape information is information indicating at least one of the shape, direction, width and height ratio or size of the encoding unit.

[0089] The shape of the encoding unit may include square and non-square. When the width and height of the encoding unit are equal (i.e., when the block shape of the encoding unit is 4Nx4N), the image decoding device (100) may determine the block shape information of the encoding unit as square. The image decoding device (100) may determine the shape of the encoding unit as non-square.

[0090] When the width and height of the encoding unit are different (i.e., when the block shape of the encoding unit is 4Nx2N, 2Nx4N, 4NxN, Nx4N, 32NxN, Nx32N, 16NxN, Nx16N, 8NxN, or Nx8N), the image decoding device (100) may determine the block shape information of the encoding unit to be non-square. When the shape of the encoding unit is non-square, the image decoding device (100) may determine the ratio of the width and height among the block shape information of the encoding unit to be at least one of 1:2, 2:1, 1:4, 4:1, 1:8, 8:1, 1:16, 16:1, 1:32, and 32:1. Additionally, based on the width length and height length of the encoding unit, the image decoding device (100) can determine whether the encoding unit is in the horizontal or vertical direction. Additionally, based on at least one of the width length, height length, or area of ​​the encoding unit, the image decoding device (100) can determine the size of the encoding unit.

[0091] According to one embodiment, the image decoding device (100) can determine the shape of an encoding unit using block shape information, and can determine the shape into which the encoding unit is divided using segmentation shape mode information. That is, the splitting method of the encoding unit indicated by the segmentation shape mode information can be determined depending on which block shape the block shape information used by the image decoding device (100) indicates.

[0092] The image decoding device (100) can obtain the segmentation shape mode information from the bitstream. However, the present invention is not limited thereto, and the image decoding device (100) and the image encoding device (200) can determine the pre-agreed segmentation shape mode information based on the block shape information. The image decoding device (100) can determine the pre-agreed segmentation shape mode information for the maximum coding unit or the minimum coding unit. For example, the image decoding device (100) can determine the segmentation shape mode information for the maximum coding unit as quad split. In addition, the image decoding device (100) can determine the segmentation shape mode information for the minimum coding unit as “not split.” Specifically, the image decoding device (100) can determine the size of the maximum coding unit as 256x256. The image decoding device (100) can determine the pre-agreed segmentation shape mode information as quad split. Quad splitting is a splitting mode that divides both the width and height of an encoding unit in half. The image decoding device (100) can obtain a coding unit of size 128x128 from a maximum coding unit of size 256x256 based on the splitting mode information. In addition, the image decoding device (100) can determine the size of the minimum coding unit as 4x4. The image decoding device (100) can obtain splitting mode information indicating "not splitting" for the minimum coding unit.

[0093] According to one embodiment, the image decoding device (100) may use block shape information indicating that the current encoding unit is a square shape. For example, the image decoding device (100) may determine whether to not split a square encoding unit, to split it vertically, to split it horizontally, to split it into four encoding units, etc., according to the split shape mode information. Referring to FIG. 3, when the block shape information of the current encoding unit (300) indicates a square shape, the decoding unit (120) may not split an encoding unit (310a) having the same size as the current encoding unit (300) according to the split shape mode information indicating that it is not split, or may determine a split encoding unit (310b, 310c, 310d, 310e, 310f, etc.) based on the split shape mode information indicating a predetermined splitting method.

[0094] Referring to FIG. 3, the image decoding device (100) may determine two coding units (310b) by vertically dividing the current coding unit (300) based on the split shape mode information indicating that the current coding unit (300) is vertically divided, according to an embodiment. The image decoding device (100) may determine two coding units (310c) by horizontally dividing the current coding unit (300) based on the split shape mode information indicating that the current coding unit (300) is horizontally divided, according to an embodiment. The image decoding device (100) may determine four coding units (310d) by vertically and horizontally dividing the current coding unit (300) based on the split shape mode information indicating that the current coding unit (300) is vertically and horizontally divided, according to an embodiment. The image decoding device (100) may determine three coding units (310e) by vertically dividing the current coding unit (300) based on the split shape mode information indicating that the current coding unit (300) is ternary divided, according to an embodiment. The image decoding device (100) can determine three coding units (310f) into which the current coding unit (300) is horizontally divided based on the division shape mode information indicating that the ternary division is horizontally divided. However, the division shapes into which a square coding unit can be divided should not be interpreted as being limited to the above-described shapes, and may include various shapes that can be indicated by the division shape mode information. Specified division shapes into which a square coding unit is divided will be specifically described below through various embodiments.

[0095] FIG. 4 illustrates a process in which an image decoding device (100) divides a non-square coding unit to determine at least one coding unit according to one embodiment.

[0096] According to one embodiment, the image decoding device (100) may utilize block shape information indicating that the current encoding unit is non-square. The image decoding device (100) may determine whether to not split the current non-square encoding unit or to split it using a predetermined method based on the split shape mode information. Referring to FIG. 4, when the block shape information of the current encoding unit (400 or 450) indicates a non-square shape, the image decoding device (100) may determine an encoding unit (410 or 460) having the same size as the current encoding unit (400 or 450) according to the split shape mode information indicating that it is not split, or may determine a split encoding unit (420a, 420b, 430a, 430b, 430c, 470a, 470b, 480a, 480b, 480c) based on the split shape mode information indicating a predetermined splitting method. The predetermined splitting method by which a non-square encoding unit is split will be described in detail through various embodiments below.

[0097] According to one embodiment, the image decoding device (100) may determine a form in which an encoding unit is split using split form mode information, and in this case, the split form mode information may indicate the number of at least one encoding unit generated by splitting the encoding unit. Referring to FIG. 4, when the split form mode information indicates that the current encoding unit (400 or 450) is split into two encoding units, the image decoding device (100) may split the current encoding unit (400 or 450) based on the split form mode information to determine two encoding units (420a, 420b, or 470a, 470b) included in the current encoding unit.

[0098] According to one embodiment, when the image decoding device (100) splits a current encoding unit (400 or 450) having a non-square shape based on split shape mode information, the image decoding device (100) may split the current encoding unit by considering the position of the long side of the non-square current encoding unit (400 or 450). For example, the image decoding device (100) may split the current encoding unit (400 or 450) in a direction that splits the long side of the current encoding unit (400 or 450) by considering the shape of the current encoding unit (400 or 450) to determine a plurality of encoding units.

[0099] According to one embodiment, if the split shape mode information indicates that the coding unit is split into an odd number of blocks (ternary splitting), the image decoding device (100) may determine an odd number of coding units included in the current coding unit (400 or 450). For example, if the split shape mode information indicates that the current coding unit (400 or 450) is split into three coding units, the image decoding device (100) may split the current coding unit (400 or 450) into three coding units (430a, 430b, 430c, 480a, 480b, 480c).

[0100] According to one embodiment, the ratio of the width and height of the current encoding unit (400 or 450) may be 4:1 or 1:4. When the ratio of the width and height is 4:1, the block shape information may be in the horizontal direction because the length of the width is longer than the length of the height. When the ratio of the width and height is 1:4, the block shape information may be in the vertical direction because the length of the width is shorter than the length of the height. The image decoding device (100) may determine to split the current encoding unit into an odd number of blocks based on the split shape mode information. In addition, the image decoding device (100) may determine the splitting direction of the current encoding unit (400 or 450) based on the block shape information of the current encoding unit (400 or 450). For example, if the current encoding unit (400) is in the vertical direction, the image decoding device (100) can divide the current encoding unit (400) in the horizontal direction to determine encoding units (430a, 430b, 430c). Also, if the current encoding unit (450) is in the horizontal direction, the image decoding device (100) can divide the current encoding unit (450) in the vertical direction to determine encoding units (480a, 480b, 480c).

[0101] According to one embodiment, the image decoding device (100) may determine an odd number of coding units included in the current coding unit (400 or 450), and the sizes of the determined coding units may not all be the same. For example, among the determined odd number of coding units (430a, 430b, 430c, 480a, 480b, 480c), the size of a given coding unit (430b or 480b) may have a different size from the other coding units (430a, 430c, 480a, 480c). That is, the encoding units into which the current encoding unit (400 or 450) can be divided and determined can have multiple types of sizes, and in some cases, an odd number of encoding units (430a, 430b, 430c, 480a, 480b, 480c) can each have different sizes.

[0102] According to one embodiment, when the split shape mode information indicates that the coding unit is split into an odd number of blocks, the image decoding device (100) can determine an odd number of coding units included in the current coding unit (400 or 450), and further, the image decoding device (100) can place a predetermined restriction on at least one coding unit among the odd number of coding units generated by splitting. Referring to FIG. 4, the image decoding device (100) can perform a decoding process for a coding unit (430b, 480b) located in the center among three coding units (430a, 430b, 430c, 480a, 480b, 480c) generated by splitting the current coding unit (400 or 450) differently from the decoding process for other coding units (430a, 430c, 480a, 480c). For example, the image decoding device (100) can restrict the encoding unit (430b, 480b) located in the center from being split any further, unlike other encoding units (430a, 430c, 480a, 480c), or can restrict it to be split only a predetermined number of times.

[0103] FIG. 5 illustrates a process in which an image decoding device (100) divides an encoding unit based on at least one of block shape information and division shape mode information according to one embodiment.

[0104] According to one embodiment, the image decoding device (100) may determine whether to split or not to split a first coding unit (500) having a square shape into coding units based on at least one of block shape information and split shape mode information. According to one embodiment, when the split shape mode information indicates splitting the first coding unit (500) in the horizontal direction, the image decoding device (100) may split the first coding unit (500) in the horizontal direction to determine a second coding unit (510). The first coding unit, the second coding unit, and the third coding unit used according to one embodiment are terms used to understand the relationship before and after splitting between coding units. For example, when the first coding unit is split, the second coding unit may be determined, and when the second coding unit is split, the third coding unit may be determined. Hereinafter, the relationship between the first coding unit, the second coding unit, and the third coding unit used may be understood to follow the above-described characteristics.

[0105] According to one embodiment, the image decoding device (100) may determine to split or not split the determined second encoding unit (510) into encoding units based on the split shape mode information. Referring to FIG. 5, the image decoding device (100) may split the first encoding unit (500) based on the split shape mode information to split the determined second encoding unit (510) of a non-square shape into at least one third encoding unit (520a, 520b, 520c, 520d, etc.) or may not split the second encoding unit (510). The image decoding device (100) can obtain split shape mode information, and the image decoding device (100) can split the first encoding unit (500) based on the obtained split shape mode information to split a plurality of second encoding units (e.g., 510) of various shapes, and the second encoding unit (510) can be split according to the way in which the first encoding unit (500) is split based on the split shape mode information. According to one embodiment, when the first encoding unit (500) is split into the second encoding unit (510) based on the split shape mode information for the first encoding unit (500), the second encoding unit (510) can also be split into the third encoding unit (e.g., 520a, 520b, 520c, 520d, etc.) based on the split shape mode information for the second encoding unit (510). That is, the coding unit can be recursively split based on the split shape mode information associated with each coding unit. Accordingly, a square coding unit can be determined from a non-square coding unit, and such a square coding unit can be recursively split to determine a non-square coding unit.

[0106] Referring to FIG. 5, among the odd number of third coding units (520b, 520c, 520d) determined by splitting the second coding unit (510) having a non-square shape, a predetermined coding unit (e.g., a coding unit located in the middle or a coding unit having a square shape) may be split recursively. According to an embodiment, the non-square third coding unit (520b), which is one of the odd number of third coding units (520b, 520c, 520d), may be split horizontally into a plurality of fourth coding units. The non-square fourth coding unit (530b or 530d), which is one of the plurality of fourth coding units (530a, 530b, 530c, 530d), may be split again into a plurality of coding units. For example, the fourth coding unit (530b or 530d) having a non-square shape may be further divided into an odd number of coding units. Methods that can be used for recursive division of coding units will be described later through various embodiments.

[0107] According to one embodiment, the image decoding device (100) may split each of the third encoding units (520a, 520b, 520c, 520d, etc.) into encoding units based on the split shape mode information. In addition, the image decoding device (100) may determine not to split the second encoding unit (510) based on the split shape mode information. According to one embodiment, the image decoding device (100) may split the second encoding unit (510) having a non-square shape into an odd number of third encoding units (520b, 520c, 520d). The image decoding device (100) may place a predetermined restriction on a predetermined third encoding unit among the odd number of third encoding units (520b, 520c, 520d). For example, the image decoding device (100) can limit the encoding unit (520c) located in the middle among an odd number of third encoding units (520b, 520c, 520d) to not be divided any further or to be divided a settable number of times.

[0108] Referring to FIG. 5, the image decoding device (100) may limit the coding unit (520c) located in the middle among the odd number of third coding units (520b, 520c, 520d) included in the second coding unit (510) having a non-square shape to not be split any further, or to be split in a predetermined split form (for example, to be split only into four coding units or to be split in a form corresponding to the split form of the second coding unit (510), or to be split only a predetermined number of times (for example, to be split only n times, where n>0). However, the above limitations on the coding unit (520c) located in the middle are merely simple embodiments and should not be interpreted as being limited to the above-described embodiments, but should be interpreted as including various limitations in which the coding unit (520c) located in the middle can be decoded differently from the other coding units (520b, 520d).

[0109] According to one embodiment, the image decoding device (100) can obtain the segmentation shape mode information used to segment the current encoding unit from a predetermined location within the current encoding unit.

[0110] FIG. 6 illustrates a method for an image decoding device (100) to determine a predetermined encoding unit among an odd number of encoding units according to one embodiment.

[0111] Referring to FIG. 6, the split shape mode information of the current encoding unit (600, 650) can be obtained from a sample at a predetermined position among a plurality of samples included in the current encoding unit (600, 650) (for example, a sample (640, 690) located in the center). However, the predetermined position within the current encoding unit (600) from which at least one of the split shape mode information can be obtained should not be interpreted as being limited to the center position illustrated in FIG. 6, but should be interpreted as including various positions (for example, top, bottom, left, right, upper left, lower left, upper right, or lower right, etc.) that can be included within the current encoding unit (600). The image decoding device (100) can obtain the split shape mode information obtained from the predetermined position and determine whether or not to split the current encoding unit into encoding units of various shapes and sizes.

[0112] According to one embodiment, the image decoding device (100) may select one of the coding units when the current coding unit is divided into a predetermined number of coding units. Various methods may be used to select one of the multiple coding units, and descriptions of such methods will be provided later through various embodiments.

[0113] According to one embodiment, the image decoding device (100) can divide the current encoding unit into a plurality of encoding units and determine an encoding unit at a predetermined position.

[0114] According to one embodiment, the image decoding device (100) may use information indicating the positions of each of the odd-numbered coding units to determine an coding unit located in the middle of the odd-numbered coding units. Referring to FIG. 6, the image decoding device (100) may divide the current coding unit (600) or the current coding unit (650) to determine odd-numbered coding units (620a, 620b, 620c) or odd-numbered coding units (660a, 660b, 660c). The image decoding device (100) may use information about the positions of the odd-numbered coding units (620a, 620b, 620c) or odd-numbered coding units (660a, 660b, 660c) to determine the middle coding unit (620b) or the middle coding unit (660b). For example, the image decoding device (100) can determine the coding unit (620b) located in the center by determining the positions of the coding units (620a, 620b, 620c) based on information indicating the positions of predetermined samples included in the coding units (620a, 620b, 620c). Specifically, the image decoding device (100) can determine the coding unit (620b) located in the center by determining the positions of the coding units (620a, 620b, 620c) based on information indicating the positions of samples (630a, 630b, 630c) at the upper left of the coding units (620a, 620b, 620c).

[0115] According to one embodiment, information indicating the positions of the upper left samples (630a, 630b, 630c) included in each of the coding units (620a, 620b, 620c) may include information on the positions or coordinates of the coding units (620a, 620b, 620c) within the picture. According to one embodiment, information indicating the positions of the upper left samples (630a, 630b, 630c) included in each of the coding units (620a, 620b, 620c) may include information indicating the width or height of the coding units (620a, 620b, 620c) included in the current coding unit (600), and this width or height may correspond to information indicating the difference between the coordinates of the coding units (620a, 620b, 620c) within the picture. That is, the image decoding device (100) can determine the encoding unit (620b) located in the center by directly using information about the positions or coordinates of the encoding units (620a, 620b, 620c) within the picture or by using information about the width or height of the encoding unit corresponding to the difference between the coordinates.

[0116] According to one embodiment, information indicating the position of the sample (630a) at the upper left of the upper encoding unit (620a) may represent (xa, ya) coordinates, information indicating the position of the sample (530b) at the upper left of the middle encoding unit (620b) may represent (xb, yb) coordinates, and information indicating the position of the sample (630c) at the upper left of the lower encoding unit (620c) may represent (xc, yc) coordinates. The image decoding device (100) may determine the middle encoding unit (620b) using the coordinates of the upper left samples (630a, 630b, 630c) included in the encoding units (620a, 620b, 620c), respectively. For example, when the coordinates of the samples (630a, 630b, 630c) on the upper left are sorted in ascending or descending order, the encoding unit (620b) including the coordinates (xb, yb) of the sample (630b) located in the center can be determined as the encoding unit located in the center among the encoding units (620a, 620b, 620c) determined by dividing the current encoding unit (600). However, the coordinates indicating the position of the upper left samples (630a, 630b, 630c) can indicate coordinates indicating the absolute position within the picture, and further, based on the position of the upper left sample (630a) of the upper left coding unit (620a), the (dxb, dyb) coordinates, which are information indicating the relative position of the sample (630b) of the upper left of the middle coding unit (620b), and the (dxc, dyc) coordinates, which are information indicating the relative position of the sample (630c) of the upper left of the lower coding unit (620c), can be used. In addition, the method of determining the coding unit of a given position by using the coordinates of the corresponding sample as information indicating the position of the sample included in the coding unit should not be interpreted as being limited to the above-described method, but should be interpreted as various arithmetic methods that can utilize the coordinates of the sample.

[0117] According to one embodiment, the image decoding device (100) may divide the current encoding unit (600) into a plurality of encoding units (620a, 620b, 620c), and select an encoding unit from among the encoding units (620a, 620b, 620c) according to a predetermined criterion. For example, the image decoding device (100) may select an encoding unit (620b) having a different size from among the encoding units (620a, 620b, 620c).

[0118] According to one embodiment, the image decoding device (100) may determine the width or height of each of the encoding units (620a, 620b, 620c) by using the (xa, ya) coordinate, which is information indicating the position of the sample (630a) at the upper left of the upper encoding unit (620a), the (xb, yb) coordinate, which is information indicating the position of the sample (630b) at the upper left of the middle encoding unit (620b), and the (xc, yc) coordinate, which is information indicating the position of the sample (630c) at the upper left of the lower encoding unit (620c). The image decoding device (100) can determine the size of each of the encoding units (620a, 620b, 620c) using coordinates (xa, ya), (xb, yb), (xc, yc) indicating the positions of the encoding units (620a, 620b, 620c). According to one embodiment, the image decoding device (100) can determine the width of the upper encoding unit (620a) as the width of the current encoding unit (600). The image decoding device (100) can determine the height of the upper encoding unit (620a) as yb-ya. According to one embodiment, the image decoding device (100) can determine the width of the middle encoding unit (620b) as the width of the current encoding unit (600). The image decoding device (100) may determine the height of the middle encoding unit (620b) as yc-yb. According to one embodiment, the image decoding device (100) may determine the width or height of the lower encoding unit using the width or height of the current encoding unit and the width and height of the upper encoding unit (620a) and the middle encoding unit (620b). The image decoding device (100) may determine an encoding unit having a different size from other encoding units based on the width and height of the determined encoding units (620a, 620b, 620c).Referring to FIG. 6, the image decoding device (100) can determine the middle encoding unit (620b) having a different size from the sizes of the upper encoding unit (620a) and the lower encoding unit (620c) as the encoding unit of a predetermined position. However, the process by which the image decoding device (100) described above determines the encoding unit having a different size from other encoding units is merely an embodiment of determining the encoding unit of a predetermined position using the size of the encoding unit determined based on sample coordinates, and therefore, various processes of determining the encoding unit of a predetermined position by comparing the sizes of the encoding units determined according to predetermined sample coordinates can be used.

[0119] The image decoding device (100) can determine the width or height of each of the encoding units (660a, 660b, 660c) by using the (xd, yd) coordinate, which is information indicating the position of the sample (670a) at the upper left of the left encoding unit (660a), the (xe, ye) coordinate, which is information indicating the position of the sample (670b) at the upper left of the middle encoding unit (660b), and the (xf, yf) coordinate, which is information indicating the position of the sample (670c) at the upper left of the right encoding unit (660c). The image decoding device (100) can determine the size of each of the encoding units (660a, 660b, 660c) by using the (xd, yd), (xe, ye), (xf, yf), which are coordinates indicating the positions of the encoding units (660a, 660b, 660c).

[0120] According to one embodiment, the image decoding device (100) may determine the width of the left encoding unit (660a) as xe-xd. The image decoding device (100) may determine the height of the left encoding unit (660a) as the height of the current encoding unit (650). According to one embodiment, the image decoding device (100) may determine the width of the middle encoding unit (660b) as xf-xe. The image decoding device (100) may determine the height of the middle encoding unit (660b) as the height of the current encoding unit (600). According to one embodiment, the image decoding device (100) may determine the width or height of the right encoding unit (660c) using the width or height of the current encoding unit (650) and the widths and heights of the left encoding unit (660a) and the middle encoding unit (660b). The image decoding device (100) can determine an encoding unit having a different size from other encoding units based on the width and height of the determined encoding units (660a, 660b, 660c). Referring to FIG. 6, the image decoding device (100) can determine a middle encoding unit (660b) having a different size from the sizes of the left encoding unit (660a) and the right encoding unit (660c) as an encoding unit at a predetermined position. However, the process of the image decoding device (100) described above determining an encoding unit having a different size from other encoding units is merely an embodiment of determining an encoding unit at a predetermined position using the size of the encoding unit determined based on sample coordinates, and therefore, various processes of determining an encoding unit at a predetermined position by comparing the sizes of the encoding units determined according to predetermined sample coordinates can be used.

[0121] However, the location of the sample considered for determining the location of the encoding unit should not be interpreted as being limited to the upper left corner described above, and it can be interpreted that information on the location of any sample included in the encoding unit can be used.

[0122] According to one embodiment, the image decoding device (100) may select an encoding unit at a predetermined position from among an odd number of encoding units determined by splitting the current encoding unit, taking into consideration the shape of the current encoding unit. For example, if the current encoding unit has a non-square shape in which the width is longer than the height, the image decoding device (100) may determine an encoding unit at a predetermined position in the horizontal direction. That is, the image decoding device (100) may determine one of the encoding units whose positions vary in the horizontal direction and place a restriction on the corresponding encoding unit. If the current encoding unit has a non-square shape in which the height is longer than the width, the image decoding device (100) may determine an encoding unit at a predetermined position in the vertical direction. That is, the image decoding device (100) may determine one of the encoding units whose positions vary in the vertical direction and place a restriction on the corresponding encoding unit.

[0123] According to one embodiment, the image decoding device (100) may use information indicating the positions of each of the even-numbered coding units to determine the coding unit at a predetermined position among the even-numbered coding units. The image decoding device (100) may determine the even-numbered coding units by dividing the current coding unit (binary dividing) and may determine the coding unit at a predetermined position using information about the positions of the even-numbered coding units. A specific process for this may be a process corresponding to the process of determining the coding unit at a predetermined position (e.g., the center position) among the odd-numbered coding units described above in FIG. 6, and thus will be omitted.

[0124] According to one embodiment, when a current encoding unit having a non-square shape is split into a plurality of encoding units, predetermined information about the encoding unit at a predetermined position may be used during the splitting process to determine an encoding unit at a predetermined position among the plurality of encoding units. For example, the image decoding device (100) may use at least one of block shape information and split shape mode information stored in a sample included in a middle encoding unit during the splitting process to determine an encoding unit located in the middle among the encoding units into which the current encoding unit is split.

[0125] Referring to FIG. 6, the image decoding device (100) can split the current encoding unit (600) into a plurality of encoding units (620a, 620b, 620c) based on the split shape mode information, and can determine the encoding unit (620b) located in the middle among the plurality of encoding units (620a, 620b, 620c). Furthermore, the image decoding device (100) can determine the encoding unit (620b) located in the middle by considering the position where the split shape mode information is acquired. That is, the split shape mode information of the current encoding unit (600) can be obtained from a sample (640) located in the center of the current encoding unit (600), and when the current encoding unit (600) is split into a plurality of encoding units (620a, 620b, 620c) based on the split shape mode information, the encoding unit (620b) including the sample (640) can be determined as the encoding unit located in the center. However, the information used to determine the encoding unit located in the center should not be interpreted as being limited to the split shape mode information, and various types of information can be used in the process of determining the encoding unit located in the center.

[0126] According to one embodiment, predetermined information for identifying a coding unit at a predetermined position may be obtained from a predetermined sample included in the coding unit to be determined. Referring to FIG. 6, the image decoding device (100) may use split shape mode information obtained from a sample at a predetermined position within the current coding unit (600) (e.g., a sample located at the center of the current coding unit (600)) to determine a coding unit at a predetermined position among a plurality of coding units (620a, 620b, 620c) determined by splitting the current coding unit (600) (e.g., a coding unit located at the center of the coding units split into multiple units). That is, the image decoding device (100) can determine the sample at the predetermined position by considering the block shape of the current encoding unit (600), and the image decoding device (100) can determine an encoding unit (620b) that includes a sample from which predetermined information (e.g., division shape mode information) can be obtained among a plurality of encoding units (620a, 620b, 620c) determined by dividing the current encoding unit (600), and can set a predetermined restriction. Referring to FIG. 6, according to one embodiment, the image decoding device (100) can determine a sample (640) located at the center of the current encoding unit (600) as a sample from which predetermined information can be obtained, and the image decoding device (100) can set a predetermined restriction on the encoding unit (620b) that includes such a sample (640) during the decoding process. However, the location of the sample from which certain information can be obtained should not be interpreted as being limited to the above-described location, but may be interpreted as samples at any location included in the encoding unit (620b) to be determined in order to set a limitation.

[0127] According to one embodiment, the position of a sample from which predetermined information can be obtained may be determined according to the shape of the current encoding unit (600). According to one embodiment, the block shape information may determine whether the shape of the current encoding unit is square or non-square, and may determine the position of a sample from which predetermined information can be obtained according to the shape. For example, the image decoding apparatus (100) may determine a sample located on a boundary that divides at least one of the width and height of the current encoding unit in half as a sample from which predetermined information can be obtained, using at least one of information about the width and information about the height of the current encoding unit. As another example, when the block shape information related to the current encoding unit indicates that the shape is non-square, the image decoding apparatus (100) may determine one of the samples adjacent to the boundary that divides the long side of the current encoding unit in half as a sample from which predetermined information can be obtained.

[0128] According to one embodiment, when the image decoding device (100) divides the current encoding unit into a plurality of encoding units, the image decoding device (100) may use the split shape mode information to determine the encoding unit at a predetermined position among the plurality of encoding units. According to one embodiment, the image decoding device (100) may obtain the split shape mode information from a sample at a predetermined position included in the encoding unit, and the image decoding device (100) may divide the plurality of encoding units generated by splitting the current encoding unit using the split shape mode information obtained from the sample at a predetermined position included in each of the plurality of encoding units. That is, the encoding unit may be recursively divided using the split shape mode information obtained from the sample at a predetermined position included in each of the encoding units. Since the recursive division process of the encoding unit has been described above with reference to FIG. 5, a detailed description thereof will be omitted.

[0129] According to one embodiment, the image decoding device (100) can divide a current encoding unit to determine at least one encoding unit, and can determine the order in which the at least one encoding unit is decoded according to a predetermined block (e.g., the current encoding unit).

[0130] FIG. 7 illustrates the order in which multiple encoding units are processed when an image decoding device (100) divides a current encoding unit to determine multiple encoding units according to one embodiment.

[0131] According to one embodiment, the image decoding device (100) may determine second encoding units (710a, 710b) by vertically splitting the first encoding unit (700) according to the splitting shape mode information, determine second encoding units (730a, 730b) by horizontally splitting the first encoding unit (700), or determine second encoding units (750a, 750b, 750c, 750d) by vertically and horizontally splitting the first encoding unit (700).

[0132] Referring to FIG. 7, the image decoding device (100) can determine the order in which the second encoding units (710a, 710b) determined by vertically dividing the first encoding unit (700) are processed in the horizontal direction (710c). The image decoding device (100) can determine the order in which the second encoding units (730a, 730b) determined by horizontally dividing the first encoding unit (700) are processed in the vertical direction (730c). The image decoding device (100) can determine the second encoding units (750a, 750b, 750c, 750d) determined by dividing the first encoding unit (700) in the vertical and horizontal directions according to a predetermined order (e.g., raster scan order (750e) or z scan order (z scan order)) in which encoding units located in one row are processed and then encoding units located in the next row are processed.

[0133] According to one embodiment, the image decoding device (100) can recursively split the encoding units. Referring to FIG. 7, the image decoding device (100) can split the first encoding unit (700) to determine a plurality of encoding units (710a, 710b, 730a, 730b, 750a, 750b, 750c, 750d), and can recursively split each of the determined plurality of encoding units (710a, 710b, 730a, 730b, 750a, 750b, 750c, 750d). A method for splitting a plurality of coding units (710a, 710b, 730a, 730b, 750a, 750b, 750c, 750d) may be a method corresponding to a method for splitting the first coding unit (700). Accordingly, the plurality of coding units (710a, 710b, 730a, 730b, 750a, 750b, 750c, 750d) may each be independently split into a plurality of coding units. Referring to FIG. 7, the image decoding device (100) may split the first coding unit (700) in the vertical direction to determine the second coding units (710a, 710b), and further may determine to independently split or not split each of the second coding units (710a, 710b).

[0134] According to one embodiment, the image decoding device (100) may horizontally divide the second encoding unit (710a) on the left into third encoding units (720a, 720b), and may not divide the second encoding unit (710b) on the right.

[0135] According to one embodiment, the processing order of the coding units may be determined based on the splitting process of the coding units. In other words, the processing order of the split coding units may be determined based on the processing order of the coding units immediately before splitting. The image decoding device (100) may determine the processing order of the third coding units (720a, 720b) ​​determined by splitting the second coding unit (710a) on the left, independently from the second coding unit (710b) on the right. Since the second coding unit (710a) on the left is split horizontally and the third coding units (720a, 720b) ​​are determined, the third coding units (720a, 720b) ​​may be processed in the vertical direction (720c). In addition, since the order in which the second encoding unit (710a) on the left and the second encoding unit (710b) on the right are processed corresponds to the horizontal direction (710c), the right encoding unit (710b) can be processed after the third encoding units (720a, 720b) ​​included in the second encoding unit (710a) on the left are processed in the vertical direction (720c). Since the above-described content is intended to explain the process in which the processing order of the encoding units is determined according to the encoding units before splitting, it should not be interpreted as being limited to the above-described embodiment, but should be interpreted as being used in various ways in which encoding units that are split and determined in various forms can be independently processed according to a predetermined order.

[0136] FIG. 8 illustrates a process for determining that a current encoding unit is divided into an odd number of encoding units when the encoding units cannot be processed in a predetermined order, according to one embodiment of the present invention.

[0137] According to one embodiment, the image decoding device (100) may determine that the current encoding unit is split into an odd number of encoding units based on the acquired split shape mode information. Referring to FIG. 8, a first encoding unit (800) having a square shape may be split into second encoding units (810a, 810b) having a non-square shape, and the second encoding units (810a, 810b) may each be independently split into third encoding units (820a, 820b, 820c, 820d, 820e). According to one embodiment, the image decoding device (100) can determine a plurality of third encoding units (820a, 820b) by horizontally dividing the left encoding unit (810a) among the second encoding units, and can divide the right encoding unit (810b) into an odd number of third encoding units (820c, 820d, 820e).

[0138] According to one embodiment, the image decoding device (100) can determine whether there is an odd number of split encoding units by determining whether the third encoding units (820a, 820b, 820c, 820d, 820e) can be processed in a predetermined order. Referring to FIG. 8, the image decoding device (100) can determine the third encoding units (820a, 820b, 820c, 820d, 820e) by recursively splitting the first encoding unit (800). The image decoding device (100) can determine whether the first encoding unit (800), the second encoding unit (810a, 810b), or the third encoding unit (820a, 820b, 820c, 820d, 820e) is divided into an odd number of encoding units based on at least one of the block shape information and the split shape mode information. For example, the encoding unit located on the right side of the second encoding unit (810a, 810b) can be divided into an odd number of third encoding units (820c, 820d, 820e). The order in which the plurality of encoding units included in the first encoding unit (800) are processed can be a predetermined order (e.g., z-scan order (830)), and the image decoding device (100) can determine whether the third encoding unit (820c, 820d, 820e) determined by dividing the second encoding unit (810b) on the right into odd numbers satisfies the condition that it can be processed according to the predetermined order.

[0139] According to one embodiment, the image decoding device (100) may determine whether the third encoding units (820a, 820b, 820c, 820d, 820e) included in the first encoding unit (800) satisfy a condition that they can be processed in a predetermined order, and the condition is related to whether at least one of the width and height of the second encoding unit (810a, 810b) is split in half according to the boundary of the third encoding unit (820a, 820b, 820c, 820d, 820e). For example, the third encoding unit (820a, 820b) determined by splitting the height of the left second encoding unit (810a) of a non-square shape in half may satisfy the condition. Since the boundaries of the third encoding units (820c, 820d, 820e) determined by dividing the right second encoding unit (810b) into three encoding units do not divide the width or height of the right second encoding unit (810b) in half, it may be determined that the third encoding units (820c, 820d, 820e) do not satisfy the condition. In the case where this condition is not satisfied, the image decoding device (100) may determine that there is a disconnection in the scanning order, and may determine that the right second encoding unit (810b) is divided into an odd number of encoding units based on the determination result. According to an embodiment, the image decoding device (100) may place a predetermined restriction on an encoding unit at a predetermined position among the divided encoding units when the encoding unit is divided into an odd number of encoding units. Since the contents of such restrictions or predetermined positions have been described above through various embodiments, a detailed description thereof will be omitted.

[0140] FIG. 9 illustrates a process in which an image decoding device (100) divides a first encoding unit (900) to determine at least one encoding unit according to one embodiment.

[0141] According to one embodiment, the image decoding device (100) may split the first coding unit (900) based on the split shape mode information acquired through the bitstream acquisition unit (110). The first coding unit (900) having a square shape may be split into four coding units having a square shape or may be split into a plurality of coding units having a non-square shape. For example, referring to FIG. 9, when the first coding unit (900) is square and the split shape mode information indicates that it is split into non-square coding units, the image decoding device (100) may split the first coding unit (900) into a plurality of non-square coding units. Specifically, when the split shape mode information indicates that the first encoding unit (900) is split in the horizontal direction or the vertical direction to determine an odd number of encoding units, the image decoding device (100) can split the first encoding unit (900) having a square shape into second encoding units (910a, 910b, 910c) determined by splitting them in the vertical direction into an odd number of encoding units or second encoding units (920a, 920b, 920c) determined by splitting them in the horizontal direction.

[0142] According to one embodiment, the image decoding device (100) can determine whether the second encoding units (910a, 910b, 910c, 920a, 920b, 920c) included in the first encoding unit (900) satisfy a condition that allows them to be processed in a predetermined order, and the condition is related to whether at least one of the width and height of the first encoding unit (900) is split in half according to the boundary of the second encoding units (910a, 910b, 910c, 920a, 920b, 920c). Referring to FIG. 9, since the boundaries of the second coding units (910a, 910b, 910c) determined by vertically dividing the first coding unit (900) in a square shape do not divide the width of the first coding unit (900) in half, it may be determined that the first coding unit (900) does not satisfy the condition that it can be processed in a predetermined order. In addition, since the boundaries of the second coding units (920a, 920b, 920c) determined by horizontally dividing the first coding unit (900) in a square shape do not divide the height of the first coding unit (900) in half, it may be determined that the first coding unit (900) does not satisfy the condition that it can be processed in a predetermined order. If such a condition is not satisfied, the image decoding device (100) may determine that the scan order is disconnected, and based on the determination result, may determine that the first encoding unit (900) is divided into an odd number of encoding units. According to one embodiment, the image decoding device (100) may place a predetermined restriction on an encoding unit at a predetermined position among the divided encoding units when the encoding unit is divided into an odd number of encoding units. Since the contents of such restrictions or predetermined positions, etc. have been described above through various embodiments, a detailed description thereof will be omitted.

[0143] According to one embodiment, the image decoding device (100) can divide the first encoding unit to determine encoding units of various shapes.

[0144] Referring to FIG. 9, the image decoding device (100) can divide the first encoding unit (900) having a square shape and the first encoding unit (930 or 950) having a non-square shape into encoding units of various shapes.

[0145] FIG. 10 illustrates that, according to one embodiment, a video decoding device (100) limits the shapes into which a second encoding unit can be divided when a non-square shape of a second encoding unit determined by splitting a first encoding unit (1000) satisfies a predetermined condition.

[0146] According to one embodiment, the image decoding device (100) may determine to split a first coding unit (1000) having a square shape into second coding units (1010a, 1010b, 1020a, 1020b) having a non-square shape based on the split shape mode information acquired through the bitstream acquisition unit (110). The second coding units (1010a, 1010b, 1020a, 1020b) may be split independently. Accordingly, the image decoding device (100) may determine to split or not split into a plurality of coding units based on the split shape mode information related to each of the second coding units (1010a, 1010b, 1020a, 1020b). According to one embodiment, the image decoding device (100) may determine third encoding units (1012a, 1012b) by horizontally dividing the left second encoding unit (1010a) having a non-square shape determined by vertically dividing the first encoding unit (1000). However, when the image decoding device (100) divides the left second encoding unit (1010a) in the horizontal direction, the right second encoding unit (1010b) may be restricted from being horizontally divided in the same direction as the direction in which the left second encoding unit (1010a) is divided. If the second encoding unit on the right (1010b) is split in the same direction to determine the third encoding unit (1014a, 1014b), the second encoding unit on the left (1010a) and the second encoding unit on the right (1010b) may be independently split in the horizontal direction to determine the third encoding unit (1012a, 1012b, 1014a, 1014b). However, this is the same result as the image decoding device (100) splitting the first encoding unit (1000) into four square-shaped second encoding units (1030a, 1030b, 1030c, 1030d) based on the split shape mode information, which may be inefficient in terms of image decoding.

[0147] According to one embodiment, the image decoding device (100) may determine third coding units (1022a, 1022b, 1024a, 1024b) by vertically dividing a second coding unit (1020a or 1020b) having a non-square shape determined by dividing a first coding unit (1000) in a horizontal direction. However, when the image decoding device (100) vertically divides one of the second coding units (e.g., the upper second coding unit (1020a)), the other second coding units (e.g., the lower coding unit (1020b)) may be restricted from being vertically divided in the same direction as the direction in which the upper second coding unit (1020a) is divided, for the reasons described above.

[0148] FIG. 11 illustrates a process in which an image decoding device (100) divides a square-shaped encoding unit when the split shape mode information cannot indicate that the encoding unit is divided into four square-shaped encoding units according to one embodiment.

[0149] According to one embodiment, the image decoding device (100) may split the first encoding unit (1100) based on the split shape mode information to determine the second encoding units (1110a, 1110b, 1120a, 1120b, etc.). The split shape mode information may include information about various shapes into which the encoding unit may be split, but the information about various shapes may not include information for splitting the encoding unit into four encoding units having a square shape. According to this split shape mode information, the image decoding device (100) cannot split the first encoding unit (1100) having a square shape into four second encoding units having a square shape (1130a, 1130b, 1130c, 1130d). Based on the segmentation shape mode information, the image decoding device (100) can determine a second encoding unit (1110a, 1110b, 1120a, 1120b, etc.) of a non-square shape.

[0150] According to one embodiment, the image decoding device (100) can independently split each of the second encoding units (1110a, 1110b, 1120a, 1120b, etc.) having a non-square shape. Each of the second encoding units (1110a, 1110b, 1120a, 1120b, etc.) can be split in a predetermined order using a recursive method, which may be a splitting method corresponding to a method in which the first encoding unit (1100) is split based on splitting shape mode information.

[0151] For example, the image decoding device (100) can determine third coding units (1112a, 1112b) having a square shape by splitting the left second coding unit (1110a) in the horizontal direction, and can determine third coding units (1114a, 1114b) having a square shape by splitting the right second coding unit (1110b) in the horizontal direction. Furthermore, the image decoding device (100) can also determine third coding units (1116a, 1116b, 1116c, 1116d) having a square shape by splitting both the left second coding unit (1110a) and the right second coding unit (1110b) in the horizontal direction. In this case, the encoding unit can be determined in the same form as the first encoding unit (1100) being divided into four square-shaped second encoding units (1130a, 1130b, 1130c, 1130d).

[0152] As another example, the image decoding device (100) may determine third coding units (1122a, 1122b) having a square shape by vertically splitting the upper second coding unit (1120a), and may determine third coding units (1124a, 1124b) having a square shape by vertically splitting the lower second coding unit (1120b). Furthermore, the image decoding device (100) may determine third coding units (1126a, 1126b, 1126a, 1126b) having a square shape by vertically splitting both the upper second coding unit (1120a) and the lower second coding unit (1120b). In this case, the encoding unit can be determined in the same form as the first encoding unit (1100) being divided into four square-shaped second encoding units (1130a, 1130b, 1130c, 1130d).

[0153] FIG. 12 illustrates that, according to one embodiment, the processing order between multiple encoding units may vary depending on the process of dividing the encoding units.

[0154] According to one embodiment, the image decoding device (100) may split the first encoding unit (1200) based on the split shape mode information. If the block shape is square and the split shape mode information indicates that the first encoding unit (1200) is split in at least one of the horizontal direction and the vertical direction, the image decoding device (100) may split the first encoding unit (1200) to determine second encoding units (e.g., 1210a, 1210b, 1220a, 1220b, etc.). Referring to FIG. 12, the second encoding units (1210a, 1210b, 1220a, 1220b) having a non-square shape determined by splitting the first encoding unit (1200) only in the horizontal direction or the vertical direction may be independently split based on the split shape mode information for each. For example, the image decoding device (100) can determine third encoding units (1216a, 1216b, 1216c, 1216d) by horizontally dividing second encoding units (1210a, 1210b) generated by vertically dividing the first encoding unit (1200), and can determine third encoding units (1226a, 1226b, 1226c, 1226d) by vertically dividing second encoding units (1220a, 1220b) generated by horizontally dividing the first encoding unit (1200). Since the process of dividing the second encoding units (1210a, 1210b, 1220a, 1220b) has been described above with reference to FIG. 11, a detailed description thereof will be omitted.

[0155] According to one embodiment, the image decoding device (100) can process encoding units according to a predetermined order. Since the characteristics of processing encoding units according to a predetermined order have been described above with reference to FIG. 7, a detailed description thereof will be omitted. Referring to FIG. 12, the image decoding device (100) can divide a first encoding unit (1200) having a square shape and determine four third encoding units (1216a, 1216b, 1216c, 1216d, 1226a, 1226b, 1226c, 1226d) having a square shape. According to one embodiment, the image decoding device (100) can determine the processing order of the third encoding units (1216a, 1216b, 1216c, 1216d, 1226a, 1226b, 1226c, 1226d) depending on the form in which the first encoding unit (1200) is divided.

[0156] According to one embodiment, the image decoding device (100) may determine third encoding units (1216a, 1216b, 1216c, 1216d) by horizontally dividing the second encoding units (1210a, 1210b) generated by vertically dividing them, and the image decoding device (100) may process the third encoding units (1216a, 1216b, 1216c, 1216d) according to an order (1217) of first processing the third encoding units (1216a, 1216c) included in the left second encoding unit (1210a) in the vertical direction and then processing the third encoding units (1216b, 1216d) included in the right second encoding unit (1210b) in the vertical direction.

[0157] According to one embodiment, the image decoding device (100) may determine third encoding units (1226a, 1226b, 1226c, 1226d) by vertically dividing the second encoding units (1220a, 1220b) generated by being divided in the horizontal direction, and the image decoding device (100) may process the third encoding units (1226a, 1226b, 1226c, 1226d) according to an order (1227) of first processing the third encoding units (1226a, 1226b) included in the upper second encoding unit (1220a) in the horizontal direction and then processing the third encoding units (1226c, 1226d) included in the lower second encoding unit (1220b) in the horizontal direction.

[0158] Referring to FIG. 12, the second encoding units (1210a, 1210b, 1220a, 1220b) can be divided into third encoding units (1216a, 1216b, 1216c, 1216d, 1226a, 1226b, 1226c, 1226d) having a square shape. The second encoding units (1210a, 1210b) determined by being split in the vertical direction and the second encoding units (1220a, 1220b) determined by being split in the horizontal direction are split into different shapes, but according to the third encoding units (1216a, 1216b, 1216c, 1216d, 1226a, 1226b, 1226c, 1226d) determined later, the first encoding unit (1200) is ultimately split into encoding units of the same shape. Accordingly, even if the image decoding device (100) determines encoding units of the same shape as a result by recursively splitting the encoding units through different processes based on the split shape mode information, it can process a plurality of encoding units determined in the same shape in different orders.

[0159] FIG. 13 illustrates a process in which the depth of an encoding unit is determined as the shape and size of the encoding unit change when the encoding unit is recursively divided to determine a plurality of encoding units according to one embodiment.

[0160] According to one embodiment, the image decoding device (100) may determine the depth of an encoding unit according to a predetermined criterion. For example, the predetermined criterion may be the length of a long side of the encoding unit. If the length of the long side of the current encoding unit is split to be 2n (n>0) times the length of the long side of the encoding unit before splitting, the image decoding device (100) may determine that the depth of the current encoding unit is increased by n compared to the depth of the encoding unit before splitting. Hereinafter, an encoding unit with an increased depth is expressed as an encoding unit of a lower depth.

[0161] Referring to FIG. 13, according to one embodiment, based on block shape information indicating a square shape (for example, the block shape information may indicate '0: SQUARE'), the image decoding device (100) may divide a first coding unit (1300) having a square shape to determine a second coding unit (1302), a third coding unit (1304), etc. of a lower depth. If the size of the first coding unit (1300) having a square shape is 2Nx2N, the second coding unit (1302) determined by dividing the width and height of the first coding unit (1300) by half may have a size of NxN. Furthermore, the third coding unit (1304) determined by dividing the width and height of the second coding unit (1302) by half may have a size of N / 2xN / 2. In this case, the width and height of the third encoding unit (1304) correspond to 1 / 4 of the width and height of the first encoding unit (1300). When the depth of the first encoding unit (1300) is D, the depth of the second encoding unit (1302), which is 1 / 2 of the width and height of the first encoding unit (1300), may be D+1, and the depth of the third encoding unit (1304), which is 1 / 4 of the width and height of the first encoding unit (1300), may be D+2.

[0162] In one embodiment, based on block shape information indicating a non-square shape (for example, the block shape information may indicate '1: NS_VER' indicating a non-square shape in which the height is longer than the width or '2: NS_HOR' indicating a non-square shape in which the width is longer than the height), the image decoding device (100) may split a first coding unit (1310 or 1320) having a non-square shape to determine a second coding unit (1312 or 1322), a third coding unit (1314 or 1324) of a lower depth, etc.

[0163] The image decoding device (100) can determine a second encoding unit (e.g., 1302, 1312, 1322, etc.) by splitting at least one of the width and height of the first encoding unit (1310) having a size of Nx2N. That is, the image decoding device (100) can split the first encoding unit (1310) in the horizontal direction to determine a second encoding unit (1302) having a size of NxN or a second encoding unit (1322) having a size of NxN / 2, and can also split the first encoding unit (1310) in the horizontal direction and the vertical direction to determine a second encoding unit (1312) having a size of N / 2xN.

[0164] According to one embodiment, the image decoding device (100) may determine a second coding unit (e.g., 1302, 1312, 1322, etc.) by splitting at least one of the width and the height of the first coding unit (1320) having a size of 2NxN. That is, the image decoding device (100) may split the first coding unit (1320) in the vertical direction to determine a second coding unit (1302) having a size of NxN or a second coding unit (1312) having a size of N / 2xN, and may also split the first coding unit (1320) in the horizontal direction and the vertical direction to determine a second coding unit (1322) having a size of NxN / 2.

[0165] According to one embodiment, the image decoding device (100) may determine a third encoding unit (e.g., 1304, 1314, 1324, etc.) by splitting at least one of the width and the height of the second encoding unit (1302) having a size of NxN. That is, the image decoding device (100) may split the second encoding unit (1302) in the vertical direction and the horizontal direction to determine a third encoding unit (1304) having a size of N / 2xN / 2, a third encoding unit (1314) having a size of N / 4xN / 2, or a third encoding unit (1324) having a size of N / 2xN / 4.

[0166] According to one embodiment, the image decoding device (100) may determine a third encoding unit (e.g., 1304, 1314, 1324, etc.) by splitting at least one of the width and the height of the second encoding unit (1312) having a size of N / 2xN. That is, the image decoding device (100) may split the second encoding unit (1312) in the horizontal direction to determine a third encoding unit (1304) having a size of N / 2xN / 2 or a third encoding unit (1324) having a size of N / 2xN / 4, or split the second encoding unit (1312) in the vertical direction and the horizontal direction to determine a third encoding unit (1314) having a size of N / 4xN / 2.

[0167] According to one embodiment, the image decoding device (100) may determine a third encoding unit (e.g., 1304, 1314, 1324, etc.) by splitting at least one of the width and the height of the second encoding unit (1322) having a size of NxN / 2. That is, the image decoding device (100) may split the second encoding unit (1322) in the vertical direction to determine a third encoding unit (1304) having a size of N / 2xN / 2 or a third encoding unit (1314) having a size of N / 4xN / 2, or split the second encoding unit (1322) in the vertical direction and the horizontal direction to determine a third encoding unit (1324) having a size of N / 2xN / 4.

[0168] According to one embodiment, the image decoding device (100) may split a square-shaped encoding unit (e.g., 1300, 1302, 1304) in a horizontal direction or a vertical direction. For example, a first encoding unit (1300) having a size of 2Nx2N may be split in the vertical direction to determine a first encoding unit (1310) having a size of Nx2N, or may be split in the horizontal direction to determine a first encoding unit (1320) having a size of 2NxN. According to one embodiment, when the depth is determined based on the length of the longest side of the encoding unit, the depth of the encoding unit determined by splitting the first encoding unit (1300) having a size of 2Nx2N in the horizontal direction or the vertical direction may be the same as the depth of the first encoding unit (1300).

[0169] According to one embodiment, the width and height of the third coding unit (1314 or 1324) may be 1 / 4 times that of the first coding unit (1310 or 1320). When the depth of the first coding unit (1310 or 1320) is D, the depth of the second coding unit (1312 or 1322), which is 1 / 2 times the width and height of the first coding unit (1310 or 1320), may be D+1, and the depth of the third coding unit (1314 or 1324), which is 1 / 4 times the width and height of the first coding unit (1310 or 1320), may be D+2.

[0170] FIG. 14 illustrates an index (part index, hereinafter referred to as PID) for depth and encoding unit distinction that can be determined according to the shape and size of encoding units according to one embodiment.

[0171] According to one embodiment, the image decoding device (100) may split a first encoding unit (1400) having a square shape to determine second encoding units of various shapes. Referring to FIG. 14, the image decoding device (100) may split the first encoding unit (1400) in at least one of a vertical direction and a horizontal direction according to the split shape mode information to determine second encoding units (1402a, 1402b, 1404a, 1404b, 1406a, 1406b, 1406c, 1406d). That is, the image decoding device (100) can determine the second encoding unit (1402a, 1402b, 1404a, 1404b, 1406a, 1406b, 1406c, 1406d) based on the split shape mode information for the first encoding unit (1400).

[0172] According to one embodiment, the depth of the second coding units (1402a, 1402b, 1404a, 1404b, 1406a, 1406b, 1406c, 1406d) determined according to the split shape mode information for the first coding unit (1400) having a square shape may be determined based on the length of the long side. For example, since the length of one side of the first coding unit (1400) having a square shape and the length of the long side of the second coding unit (1402a, 1402b, 1404a, 1404b) having a non-square shape are the same, the depth of the first coding unit (1400) and the second coding units (1402a, 1402b, 1404a, 1404b) having a non-square shape may be considered to be the same as D. In contrast, when the image decoding device (100) divides the first encoding unit (1400) into four square-shaped second encoding units (1406a, 1406b, 1406c, 1406d) based on the split shape mode information, the length of one side of the square-shaped second encoding units (1406a, 1406b, 1406c, 1406d) is half the length of one side of the first encoding unit (1400), so the depth of the second encoding units (1406a, 1406b, 1406c, 1406d) may be a depth of D+1, which is one depth lower than D, the depth of the first encoding unit (1400).

[0173] According to one embodiment, the image decoding device (100) may split a first encoding unit (1410) having a height greater than its width into a plurality of second encoding units (1412a, 1412b, 1414a, 1414b, 1414c) in a horizontal direction according to the splitting shape mode information. According to one embodiment, the image decoding device (100) may split a first encoding unit (1420) having a width greater than its height into a plurality of second encoding units (1422a, 1422b, 1424a, 1424b, 1424c) in a vertical direction according to the splitting shape mode information.

[0174] According to one embodiment, the depth of the second coding unit (1412a, 1412b, 1414a, 1414b, 1414c. 1422a, 1422b, 1424a, 1424b, 1424c) determined based on the split shape mode information for the first coding unit (1410 or 1420) of a non-square shape may be determined based on the length of the long side. For example, since the length of one side of the second encoding unit (1412a, 1412b) in the shape of a square is half the length of one side of the first encoding unit (1410) in the shape of a non-square having a height longer than a width, the depth of the second encoding unit (1412a, 1412b) in the shape of a square is D+1, which is one depth lower than the depth D of the first encoding unit (1410) in the shape of a non-square.

[0175] Furthermore, the image decoding device (100) can split a non-square first encoding unit (1410) into an odd number of second encoding units (1414a, 1414b, 1414c) based on the split shape mode information. The odd number of second encoding units (1414a, 1414b, 1414c) can include non-square second encoding units (1414a, 1414c) and square second encoding units (1414b). In this case, since the length of the long side of the second encoding unit (1414a, 1414c) of a non-square shape and the length of one side of the second encoding unit (1414b) of a square shape are half the length of one side of the first encoding unit (1410), the depth of the second encoding unit (1414a, 1414b, 1414c) may be a depth of D+1, which is one depth lower than D, which is the depth of the first encoding unit (1410). The image decoding device (100) may determine the depth of the encoding units associated with the first encoding unit (1420) of a non-square shape, in which the width is longer than the height, in a manner corresponding to the above method of determining the depth of the encoding units associated with the first encoding unit (1410).

[0176] According to one embodiment, when determining an index (PID) for distinguishing divided coding units, the image decoding device (100) may determine the index based on a size ratio between the coding units when the coding units divided into an odd number are not of the same size. Referring to FIG. 14, among the coding units (1414a, 1414b, 1414c) divided into an odd number, the coding unit (1414b) located in the middle may have the same width as the other coding units (1414a, 1414c) but may have a height that is twice the height of the coding units (1414a, 1414c) that are different in height. That is, in this case, the coding unit (1414b) located in the middle may include two of the other coding units (1414a, 1414c). Accordingly, if the index (PID) of the encoding unit (1414b) located in the middle according to the scanning order is 1, the index of the encoding unit (1414c) located in the next order may be 3, which is an increase of 2. In other words, there may be a discontinuity in the index value. According to one embodiment, the image decoding device (100) may determine whether the encoding units divided into an odd number are not of the same size based on the presence or absence of discontinuity in the index for distinguishing between the divided encoding units.

[0177] According to one embodiment, the image decoding device (100) may determine whether the current encoding unit is divided into a specific split shape based on the value of an index for distinguishing a plurality of encoding units determined by division. Referring to FIG. 14, the image decoding device (100) may divide a first encoding unit (1410) having a rectangular shape in which a height is longer than a width, to determine an even number of encoding units (1412a, 1412b) or an odd number of encoding units (1414a, 1414b, 1414c). The image decoding device (100) may use an index (PID) indicating each encoding unit to distinguish each of the plurality of encoding units. According to one embodiment, the PID may be obtained from a sample (e.g., an upper left sample) at a predetermined position of each encoding unit.

[0178] According to one embodiment, the image decoding device (100) may determine an coding unit at a predetermined position among the coding units that are divided and determined using an index for distinguishing the coding units. According to one embodiment, when the split shape mode information for the first coding unit (1410) having a rectangular shape with a height longer than the width indicates that the first coding unit (1410) is divided into three coding units, the image decoding device (100) may divide the first coding unit (1410) into three coding units (1414a, 1414b, 1414c). The image decoding device (100) may assign an index to each of the three coding units (1414a, 1414b, 1414c). The image decoding device (100) may compare the indexes for each coding unit to determine the middle coding unit among the coding units divided into an odd number of coding units. The image decoding device (100) may determine a coding unit (1414b) having an index corresponding to a middle value among the indices of the coding units as a coding unit at a middle position among the coding units determined by splitting the first coding unit (1410). According to an embodiment, when determining an index for distinguishing the split coding units, the image decoding device (100) may determine the index based on a size ratio between the coding units when the coding units do not have the same size. Referring to FIG. 14, the coding unit (1414b) generated by splitting the first coding unit (1410) may have the same width as other coding units (1414a, 1414c) but may be twice the height of the coding units (1414a, 1414c) that are different in height. In this case, if the index (PID) of the encoding unit (1414b) located in the middle is 1, the index of the encoding unit (1414c) located in the next order may be 3, which is an increase of 2.In cases like this where the index increases uniformly and then the increase amount changes, the image decoding device (100) may determine that the current encoding unit is divided into a plurality of encoding units including encoding units having different sizes from other encoding units. According to one embodiment, when the split shape mode information indicates that the current encoding unit is divided into an odd number of encoding units, the image decoding device (100) may divide the current encoding unit into a form in which an encoding unit at a predetermined position among the odd number of encoding units (for example, a middle encoding unit) has a different size from the other encoding units. In this case, the image decoding device (100) may determine a middle encoding unit having a different size using an index (PID) for the encoding unit. However, the above-described index, the size or position of the encoding unit at the predetermined position to be determined are specific for explaining one embodiment and should not be interpreted as being limited thereto, and it should be interpreted that various indexes, positions and sizes of encoding units can be used.

[0179] According to one embodiment, the image decoding device (100) may utilize a predetermined data unit from which recursive division of the encoding unit begins.

[0180] FIG. 15 illustrates that a plurality of coding units are determined according to a plurality of predetermined data units included in a picture according to one embodiment.

[0181] According to one embodiment, a predetermined data unit may be defined as a data unit from which a coding unit begins to be recursively split using split shape mode information. That is, it may correspond to a coding unit of the highest depth used in the process of determining multiple coding units for splitting the current picture. For convenience of explanation, this predetermined data unit will be referred to as a reference data unit hereinafter.

[0182] In one embodiment, the reference data unit may exhibit a predetermined size and shape. In one embodiment, the reference data unit may include MxN samples, where M and N may be the same and may be integers expressed as powers of 2. That is, the reference data unit may exhibit a square or non-square shape, and may be subsequently divided into an integer number of coding units.

[0183] According to one embodiment, the video decoding device (100) can divide the current picture into a plurality of reference data units. According to one embodiment, the video decoding device (100) can divide the plurality of reference data units into which the current picture is divided using division type mode information for each reference data unit. This division process of the reference data units can correspond to a division process using a quad-tree structure.

[0184] According to one embodiment, the image decoding device (100) may determine in advance the minimum size that a reference data unit included in the current picture may have. Accordingly, the image decoding device (100) may determine reference data units of various sizes having a size greater than or equal to the minimum size, and may determine at least one encoding unit using segmentation mode information based on the determined reference data unit.

[0185] Referring to FIG. 15, the image decoding device (100) may use a reference coding unit (1500) having a square shape, or may use a reference coding unit (1502) having a non-square shape. According to one embodiment, the shape and size of the reference coding unit may be determined according to various data units (e.g., sequence, picture, slice, slice segment, tile, tile group, maximum coding unit, etc.) that may include at least one reference coding unit.

[0186] According to one embodiment, the bitstream acquisition unit (110) of the image decoding device (100) can acquire at least one of information on the shape of the reference coding unit and information on the size of the reference coding unit from the bitstream for each of the various data units. The process of determining at least one coding unit included in the square-shaped reference coding unit (1500) has been described above through the process of splitting the current coding unit (300) of FIG. 3, and the process of determining at least one coding unit included in the non-square-shaped reference coding unit (1502) has been described above through the process of splitting the current coding unit (400 or 450) of FIG. 4, so a detailed description thereof will be omitted.

[0187] According to one embodiment, the image decoding device (100) may use an index for identifying the size and shape of the reference coding unit to determine the size and shape of the reference coding unit according to some data units that are predetermined based on a predetermined condition. That is, the bitstream acquisition unit (110) may acquire only an index for identifying the size and shape of the reference coding unit for each slice, slice segment, tile, tile group, maximum coding unit, etc., among the various data units (e.g., sequences, pictures, slices, slice segments, tiles, tile groups, maximum coding units, etc.) that satisfy a predetermined condition (e.g., data units having a size smaller than a slice) from the bitstream. The image decoding device (100) may determine the size and shape of the reference data unit for each data unit that satisfies the predetermined condition by using the index. When information about the shape of the reference coding unit and information about the size of the reference coding unit are obtained from the bitstream for each relatively small-sized data unit and used, the efficiency of the bitstream may not be good. Therefore, instead of directly obtaining information about the shape of the reference coding unit and information about the size of the reference coding unit, only the index may be obtained and used. In this case, at least one of the size and shape of the reference coding unit corresponding to the index indicating the size and shape of the reference coding unit may be determined in advance. That is, the image decoding device (100) can determine at least one of the size and shape of the reference coding unit included in the data unit that serves as the basis for obtaining the index by selecting at least one of the sizes and shapes of the predetermined reference coding units according to the index.

[0188] According to one embodiment, the image decoding device (100) may use at least one reference coding unit included in one maximum coding unit (1510). That is, a maximum coding unit for dividing an image may include at least one reference coding unit, and a coding unit may be determined through a recursive splitting process of each reference coding unit. According to one embodiment, at least one of the width and the height of the maximum coding unit may correspond to an integer multiple of at least one of the width and the height of the reference coding unit. According to one embodiment, the size of the reference coding unit may be a size obtained by splitting the maximum coding unit n times according to a quad tree structure. That is, the image decoding device (100) may split the maximum coding unit n times according to the quad tree structure to determine the reference coding unit, and may split the reference coding unit based on at least one of block shape information and split shape mode information according to various embodiments.

[0189] According to one embodiment, the video decoding device (100) may obtain and use block shape information indicating the shape of the current encoding unit or split shape mode information indicating a method of splitting the current encoding unit from the bitstream. The split shape mode information may be included in a bitstream related to various data units. For example, the video decoding device (100) may use split shape mode information included in a sequence parameter set, a picture parameter set, a video parameter set, a slice header, a slice segment header, a tile header, and a tile group header. Furthermore, the video decoding device (100) may obtain and use a syntax element corresponding to block shape information or split shape mode information from the bitstream for each maximum encoding unit and each reference encoding unit.

[0190] Hereinafter, a method for determining a partitioning rule according to one embodiment of the present disclosure will be described in detail.

[0191] The video decoding device (100) can determine a segmentation rule of the video. The segmentation rule may be predetermined between the video decoding device (100) and the video encoding device (200). The video decoding device (100) can determine the segmentation rule of the video based on information obtained from a bitstream. The video decoding device (100) can determine the segmentation rule based on information obtained from at least one of a sequence parameter set, a picture parameter set, a video parameter set, a slice header, a slice segment header, a tile header, and a tile group header. The video decoding device (100) can determine the segmentation rule differently according to a frame, a slice, a tile, a temporal layer, a maximum coding unit, or an coding unit.

[0192] The image decoding device (100) can determine a segmentation rule based on the block shape of the encoding unit. The block shape can include the size, shape, width and height ratio, and direction of the encoding unit. The image encoding device (200) and the image decoding device (100) can determine in advance that the segmentation rule will be determined based on the block shape of the encoding unit. However, the present invention is not limited thereto. The image decoding device (100) can determine the segmentation rule based on information obtained from the bitstream received from the image encoding device (200).

[0193] The shape of the encoding unit may include a square and a non-square shape. If the width and height of the encoding unit are equal, the image decoding device (100) may determine the shape of the encoding unit as a square. In addition, if the width and height of the encoding unit are not equal, the image decoding device (100) may determine the shape of the encoding unit as a non-square shape.

[0194] The size of the coding unit may include various sizes such as 4x4, 8x4, 4x8, 8x8, 16x4, 16x8, ..., 256x256. The size of the coding unit may be classified according to the length of the long side, the length of the short side, or the area of ​​the coding unit. The image decoding device (100) may apply the same splitting rule to the coding units classified into the same group. For example, the image decoding device (100) may classify the coding units having the same long side length into the same size. In addition, the image decoding device (100) may apply the same splitting rule to the coding units having the same long side length.

[0195] The ratio of the width to the height of the coding unit may include 1:2, 2:1, 1:4, 4:1, 1:8, 8:1, 1:16, 16:1, 32:1, or 1:32, etc. In addition, the direction of the coding unit may include a horizontal direction and a vertical direction. The horizontal direction may indicate a case where the length of the width of the coding unit is longer than the length of the height. The vertical direction may indicate a case where the length of the width of the coding unit is shorter than the length of the height.

[0196] The image decoding device (100) can adaptively determine a splitting rule based on the size of the encoding unit. The image decoding device (100) can determine a different allowable splitting mode based on the size of the encoding unit. For example, the image decoding device (100) can determine whether splitting is allowed based on the size of the encoding unit. The image decoding device (100) can determine a splitting direction based on the size of the encoding unit. The image decoding device (100) can determine an allowable splitting type based on the size of the encoding unit.

[0197] Determining the splitting rule based on the size of the encoding unit may be a splitting rule predetermined between the image encoding device (200) and the image decoding device (100). In addition, the image decoding device (100) may determine the splitting rule based on information obtained from the bitstream.

[0198] The image decoding device (100) can adaptively determine a segmentation rule based on the position of the encoding unit. The image decoding device (100) can adaptively determine a segmentation rule based on the position that the encoding unit occupies in the image.

[0199] Additionally, the image decoding device (100) can determine a splitting rule so that encoding units generated through different splitting paths do not have the same block shape. However, this is not limited thereto, and encoding units generated through different splitting paths may have the same block shape. Encoding units generated through different splitting paths may have different decoding processing orders. Since the decoding processing order has been described together with FIG. 12, a detailed description thereof will be omitted.

[0200] FIG. 16 illustrates encoding units that can be determined for each picture when the combination of forms into which encoding units can be divided is different for each picture according to one embodiment.

[0201] Referring to FIG. 16, the image decoding device (100) can determine a different combination of partitioning shapes into which a coding unit can be partitioned for each picture. For example, the image decoding device (100) can decode an image using a picture (1600) that can be partitioned into four coding units, a picture (1610) that can be partitioned into two or four coding units, and a picture (1620) that can be partitioned into two, three, or four coding units, among at least one picture included in the image. The image decoding device (100) can only use partitioning shape information indicating that the picture (1600) is partitioned into four square coding units to partition the picture (1600) into a plurality of coding units. The image decoding device (100) can only use partitioning shape information indicating that the picture (1610) is partitioned into two or four coding units to partition the picture. The video decoding device (100) can only use the segmentation type information indicating that the picture (1620) is segmented into two, three, or four encoding units. The above-described combination of segmentation types is merely an example for explaining the operation of the video decoding device (100), and therefore the above-described combination of segmentation types should not be interpreted as being limited to the above-described example, but should be interpreted as being capable of using various combinations of segmentation types for each predetermined data unit.

[0202] According to one embodiment, the bitstream acquisition unit (110) of the image decoding device (100) can acquire a bitstream including an index indicating a combination of segmentation type information for each predetermined data unit (e.g., a sequence, a picture, a slice, a slice segment, a tile, a tile group, etc.). For example, the bitstream acquisition unit (110) can acquire an index indicating a combination of segmentation type information from a sequence parameter set, a picture parameter set, a slice header, a tile header, or a tile group header. The image decoding device (100) can determine a combination of segmentation types into which an encoding unit can be segmented for each predetermined data unit using the acquired index, and thus can use different combinations of segmentation types for each predetermined data unit.

[0203] FIG. 17 illustrates various forms of encoding units that can be determined based on segmentation mode information that can be expressed in binary code according to one embodiment.

[0204] According to one embodiment, the image decoding device (100) can split an encoding unit into various shapes using block shape information and split shape mode information acquired through the bitstream acquisition unit (110). The shapes of the encoding unit that can be split may correspond to various shapes including the shapes described through the above-described embodiments.

[0205] Referring to FIG. 17, the image decoding device (100) can split a square-shaped encoding unit in at least one of the horizontal direction and the vertical direction based on the split shape mode information, and can split a non-square-shaped encoding unit in the horizontal direction or the vertical direction.

[0206] According to one embodiment, when the image decoding device (100) can divide a square-shaped encoding unit into four square encoding units by horizontally and vertically splitting the encoding unit, there may be four types of splitting modes that the splitting mode information for the square encoding unit can indicate. According to one embodiment, the splitting mode information may be expressed as a two-digit binary code, and a binary code may be assigned to each splitting mode. For example, when the encoding unit is not split, the splitting mode information may be expressed as (00)b, when the encoding unit is split in the horizontal direction and the vertical direction, the splitting mode information may be expressed as (01)b, when the encoding unit is split in the horizontal direction, the splitting mode information may be expressed as (10)b, and when the encoding unit is split in the vertical direction, the splitting mode information may be expressed as (11)b.

[0207] According to one embodiment, when the image decoding device (100) splits a non-square coding unit in a horizontal direction or a vertical direction, the type of split shape that the split shape mode information can indicate may be determined depending on the number of coding units into which the coding unit is split. Referring to FIG. 17, the image decoding device (100) may split a non-square coding unit into up to three according to one embodiment. The image decoding device (100) may split the coding unit into two coding units, in which case the split shape mode information may be expressed as (10)b. The image decoding device (100) may split the coding unit into three coding units, in which case the split shape mode information may be expressed as (11)b. The image decoding device (100) may determine not to split the coding unit, in which case the split shape mode information may be expressed as (0)b. That is, the image decoding device (100) can use variable length coding (VLC) rather than fixed length coding (FLC) to use a binary code representing segmentation mode information.

[0208] According to one embodiment, referring to FIG. 17, the binary code of the partition shape mode information indicating that the coding unit is not split may be expressed as (0)b. If the binary code of the partition shape mode information indicating that the coding unit is not split is set to (00)b, all binary codes of the 2-bit partition shape mode information must be used even if there is no partition shape mode information set to (01)b. However, as illustrated in FIG. 17, if three partition shapes for a non-square coding unit are used, the image decoding device (100) can determine that the coding unit is not split even if it uses a 1-bit binary code (0)b as the partition shape mode information, and thus can efficiently use the bitstream. However, the partition shapes of the non-square coding unit indicated by the partition shape mode information should not be interpreted as being limited to only the three shapes illustrated in FIG. 17, but should be interpreted as various shapes including the above-described embodiments.

[0209] FIG. 18 illustrates another form of a coding unit that can be determined based on segmentation mode information that can be expressed in binary code according to one embodiment.

[0210] Referring to FIG. 18, the image decoding device (100) can split a square-shaped encoding unit in the horizontal direction or the vertical direction based on the split shape mode information, and can split a non-square-shaped encoding unit in the horizontal direction or the vertical direction. That is, the split shape mode information can indicate that a square-shaped encoding unit is split in one direction. In this case, the binary code of the split shape mode information indicating that a square-shaped encoding unit is not split can be expressed as (0)b. If the binary code of the split shape mode information indicating that the encoding unit is not split is set to (00)b, all binary codes of the 2-bit split shape mode information must be used even though there is no split shape mode information set to (01)b. However, as illustrated in FIG. 18, if three types of division forms for a square-shaped encoding unit are used, the image decoding device (100) can determine that the encoding unit is not divided even if it uses a 1-bit binary code (0)b as the division form mode information, and thus can efficiently use the bitstream. However, the division forms of the square-shaped encoding unit indicated by the division form mode information should not be interpreted as being limited to only the three types illustrated in FIG. 18, but should be interpreted as various types including the embodiments described above.

[0211] In one embodiment, block shape information or segmentation shape mode information may be expressed using binary code, and such information may be directly generated as a bitstream. Furthermore, block shape information or segmentation shape mode information that may be expressed using binary code may not be directly generated as a bitstream, but may instead be used as a binary code input into CABAC (context adaptive binary arithmetic coding).

[0212] According to one embodiment, the image decoding device (100) describes a process of obtaining syntax for block shape information or segmentation shape mode information through CABAC. A bitstream including a binary code for the syntax can be obtained through a bitstream obtaining unit (110). The image decoding device (100) can detect a syntax element indicating block shape information or segmentation shape mode information by de-binarizing a bin string included in the obtained bitstream. According to one embodiment, the image decoding device (100) can obtain a set of binary bin strings corresponding to syntax elements to be decoded, and decode each bin using probability information, and the image decoding device (100) can repeat the process until a bin string composed of the decoded bins becomes equal to one of the previously obtained bin strings. The image decoding device (100) can determine syntax elements by performing inverse binarization of an empty string.

[0213] According to one embodiment, the image decoding device (100) may perform a decoding process of adaptive binary arithmetic coding to determine a syntax for a bin string, and the image decoding device (100) may update a probability model for bins acquired through the bitstream acquisition unit (110). Referring to FIG. 17, the bitstream acquisition unit (110) of the image decoding device (100) may acquire a bitstream representing a binary code representing segmentation mode information according to one embodiment. Using the acquired binary code having a size of 1 or 2 bits, the image decoding device (100) may determine a syntax for the segmentation mode information. In order to determine the syntax for the segmentation mode information, the image decoding device (100) may update a probability for each bit of the 2-bit binary code. That is, the image decoding device (100) can update the probability of having a value of 0 or 1 when decoding the next bin, depending on whether the value of the first bin among the 2-bit binary codes is 0 or 1.

[0214] According to one embodiment, the image decoding device (100) may, in the process of determining the syntax, update the probability for the bins used in the process of decoding the bins of the empty string for the syntax, and the image decoding device (100) may determine that certain bits among the empty strings have the same probability without updating the probability.

[0215] Referring to FIG. 17, in the process of determining a syntax using an empty string indicating split shape mode information for a non-square coding unit, the image decoding device (100) may determine the syntax for the split shape mode information using one bin having a value of 0 when the non-square coding unit is not split. That is, when the block shape information indicates that the current coding unit is a non-square shape, the first bin of the empty string for the split shape mode information may be 0 when the non-square coding unit is not split, and may be 1 when it is split into 2 or 3 coding units. Accordingly, the probability that the first bin of the empty string of the split shape mode information for the non-square coding unit is 0 may be 1 / 3, and the probability that it is 1 may be 2 / 3. As described above, the image decoding device (100) can only express a 1-bit empty string having a value of 0 for the partition shape mode information indicating that a non-square-shaped encoding unit is not partitioned, so the image decoding device (100) can determine the syntax for the partition shape mode information by determining whether the second bin is 0 or 1 only when the first bin of the partition shape mode information is 1. According to one embodiment, the image decoding device (100) can decode the bin by considering that the probability that the second bin is 0 or 1 when the first bin for the partition shape mode information is 1 is the same probability.

[0216] According to one embodiment, the image decoding device (100) may use various probabilities for each bin in the process of determining a bin of a bin string for the partition shape mode information. According to one embodiment, the image decoding device (100) may determine the probability of a bin for the partition shape mode information differently depending on the direction of a non-square block. According to one embodiment, the image decoding device (100) may determine the probability of a bin for the partition shape mode information differently depending on the area or the length of the long side of the current encoding unit. According to one embodiment, the image decoding device (100) may determine the probability of a bin for the partition shape mode information differently depending on at least one of the shape and the length of the long side of the current encoding unit.

[0217] According to one embodiment, the image decoding device (100) may determine that the bin probability for the segmentation shape mode information is the same for encoding units of a predetermined size or larger. For example, the bin probability for the segmentation shape mode information may be determined to be the same for encoding units of a size of 64 samples or larger based on the length of the long side of the encoding unit.

[0218] According to one embodiment, the image decoding device (100) may determine the initial probability for bins constituting the empty string of the segmentation shape mode information based on the slice type (e.g., I slice, P slice, or B slice).

[0219] Figure 19 is a block diagram of an image encoding and decoding system that performs loop filtering.

[0220] The encoding unit (1910) of the image encoding and decoding system (1900) transmits an encoded bitstream of an image, and the decoding unit (1950) receives the bitstream and decodes it to output a restored image. Here, the encoding unit (1910) may have a configuration similar to that of the image encoding device (200) described below, and the decoding unit (1950) may have a configuration similar to that of the image decoding device (100).

[0221] In the encoding unit (1910), the prediction encoding unit (1915) outputs prediction data through inter prediction and intra prediction, and the transformation and quantization unit (1920) outputs quantized transformation coefficients of residual data between the prediction data and the current input image. The entropy encoding unit (1925) encodes and transforms the quantized transformation coefficients and outputs them as a bitstream. The quantized transformation coefficients are restored to spatial domain data through the inverse quantization and inverse transformation unit (1930), and the restored spatial domain data are output as a restored image through the deblocking filtering unit (1935) and the loop filtering unit (1940). The restored image can be used as a reference image of the next input image through the prediction encoding unit (1915).

[0222] The encoded image data among the bitstreams received by the decoding unit (1950) is restored to residual data in the spatial domain through the entropy decoding unit (1955) and the inverse quantization and inverse transformation unit (1960). The prediction data and residual data output from the prediction decoding unit (1975) are combined to form image data in the spatial domain, and the deblocking filtering unit (1965) and the loop filtering unit (1970) can perform filtering on the image data in the spatial domain to output a restored image for the current original image. The restored image can be used as a reference image for the next original image by the prediction decoding unit (1975).

[0223] The loop filtering unit (1940) of the encoding unit (1910) performs loop filtering using filter information input according to user input or system settings. The filter information used by the loop filtering unit (1940) is output to the entropy encoding unit (1925) and transmitted to the decoding unit (1950) together with the encoded image data. The loop filtering unit (1970) of the decoding unit (1950) can perform loop filtering based on the filter information input from the decoding unit (1950).

[0224] The various embodiments described above describe operations related to the image decoding method performed by the image decoding device (100). Hereinafter, the operations of the image encoding device (200), which performs the image encoding method corresponding to the reverse process of the image decoding method, will be described through various embodiments.

[0225] FIG. 2 illustrates a block diagram of an image encoding device (200) capable of encoding an image based on at least one of block shape information and segmentation shape mode information according to one embodiment.

[0226] The video encoding device (200) may include an encoding unit (220) and a bitstream generation unit (210). The encoding unit (220) may receive an input image and encode the input image. The encoding unit (220) may encode the input image to obtain at least one syntax element. The syntax element may include at least one of a skip flag, a prediction mode, a motion vector difference, a motion vector prediction method (or index), a transform quantized coefficient, a coded block pattern, a coded block flag, an intra prediction mode, a direct flag, a merge flag, a delta QP, a reference index, a prediction direction, and a transform index. The encoding unit (220) may determine a context model based on block shape information including at least one of a shape, a direction, a ratio of width and height, or a size of an encoding unit.

[0227] The bitstream generation unit (210) can generate a bitstream based on an encoded input image. For example, the bitstream generation unit (210) can generate a bitstream by entropy encoding syntax elements based on a context model. In addition, the image encoding device (200) can transmit the bitstream to the image decoding device (100).

[0228] According to one embodiment, the encoding unit (220) of the image encoding device (200) can determine the shape of an encoding unit. For example, the encoding unit may be square or have a non-square shape, and information indicating such shape may be included in the block shape information.

[0229] According to one embodiment, the encoding unit (220) can determine the shape into which the encoding unit is to be split. The encoding unit (220) can determine the shape of at least one encoding unit included in the encoding unit, and the bitstream generation unit (210) can generate a bitstream including split shape mode information including information about the shape of such encoding unit.

[0230] According to one embodiment, the encoder (220) may determine whether the encoding unit is split or not. If the encoder (220) determines that the encoding unit includes only one encoding unit or that the encoding unit is not split, the bitstream generation unit (210) may generate a bitstream including split shape mode information indicating that the encoding unit is not split. In addition, the encoder (220) may split the encoding unit into a plurality of encoding units, and the bitstream generation unit (210) may generate a bitstream including split shape mode information indicating that the encoding unit is split into a plurality of encoding units.

[0231] According to one embodiment, information indicating the number of encoding units to be split into or the direction in which the encoding unit is to be split may be included in the splitting mode information. For example, the splitting mode information may indicate splitting in at least one of the vertical and horizontal directions, or may indicate no splitting.

[0232] The video encoding device (200) determines information about the segmentation shape mode based on the segmentation shape mode of the encoding unit. The video encoding device (200) determines a context model based on at least one of the shape, direction, width, and height ratio or size of the encoding unit. Then, the video encoding device (200) generates information about the segmentation shape mode for segmenting the encoding unit based on the context model as a bitstream.

[0233] In order to determine a context model, the video encoding device (200) may obtain an array for matching at least one of the shape, direction, width and height ratio or size of the encoding unit with an index for the context model. The video encoding device (200) may obtain an index for the context model based on at least one of the shape, direction, width and height ratio or size of the encoding unit in the array. The video encoding device (200) may determine the context model based on the index for the context model.

[0234] The video encoding device (200) may further determine the context model based on block shape information including at least one of the shape, direction, width, and height ratio or size of a neighboring encoding unit adjacent to the encoding unit, in order to determine the context model. In addition, the neighboring encoding unit may include at least one of encoding units located on the lower left, left, upper left, upper right, right, or lower right of the encoding unit.

[0235] In addition, the video encoding device (200) may compare the length of the width of the upper peripheral encoding unit with the length of the width of the encoding unit to determine the context model. In addition, the video encoding device (200) may compare the length of the height of the left and right peripheral encoding units with the length of the height of the encoding unit. In addition, the video encoding device (200) may determine the context model based on the comparison results.

[0236] Since the operation of the video encoding device (200) includes similar contents to the operation of the video decoding device (100) described in FIGS. 3 to 19, a detailed description is omitted.

[0237] FIG. 20 is a block diagram illustrating the configuration of an image decoding device (2000) according to one embodiment.

[0238] Referring to FIG. 20, the image decoding device (2000) may include a memory (2010) and a processor (2030).

[0239] In one embodiment of the present disclosure, the memory (2010) and the processor (2030) of the present disclosure may be implemented with at least one memory and at least one processor, respectively. In one embodiment of the present disclosure, when instructions are stored in the memory (2010), the operations of the bitstream acquisition unit (110), the decoding unit (120) illustrated in FIG. 1, and the entropy decoding unit (1955) and the prediction decoding unit (1975) illustrated in FIG. 19 may be implemented according to instructions called by at least one process.

[0240] In one embodiment of the present disclosure, the image decoding device (2000) may include a storage medium that stores input / output data of at least one of the bitstream acquisition unit (110), the decoding unit (120) illustrated in FIG. 1, and the entropy decoding unit (1955) and the prediction decoding unit (1975) illustrated in FIG. 19. The storage medium may be included in the memory (2010) or may be a storage medium different from the memory (2010).

[0241] Additionally, the image decoding device (2000) may include a storage medium control unit that controls data input / output of the storage medium. The storage medium control unit may be included in the processor (2030), or may be a control unit different from the processor (2030).

[0242] In one embodiment of the present disclosure, an image decoding device (2000) can obtain a bitstream generated as a result of encoding an image.

[0243] In one embodiment of the present disclosure, the bitstream may include encoded data generated by encoding a current block. The encoded data included in the bitstream may be used to reconstruct the current block. The current block may be a maximum coding unit, coding unit, transformation unit, or prediction unit segmented from the current image to be decoded.

[0244] In one embodiment of the present disclosure, the video decoding device (2000) can determine a current block based on information associated with a block included in a bitstream corresponding to at least one level of a sequence parameter set, a picture parameter set, a video parameter set, a slice header, and a slice segment header, and / or information about a block segmentation mode.

[0245] In one embodiment of the present disclosure, the image decoding device (2000) can receive a bitstream from the image encoding device via a network.

[0246] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a bitstream from a data storage medium including a magnetic medium such as a hard disk, a floppy disk, and a magnetic tape, an optical recording medium such as a CD-ROM and a DVD, a magneto-optical medium such as a floptical disk, and the like.

[0247] In one embodiment of the present disclosure, an image decoding device (2000) can obtain syntax elements for decoding an image from a bitstream. Values ​​corresponding to the syntax elements can be included in the bitstream according to the hierarchical structure of the image.

[0248] In one embodiment of the present disclosure, an image decoding device (2000) can obtain bins of syntax elements by parsing bits included in a bitstream. The parsing process can include at least one of entropy decoding and inverse binarization.

[0249] In one embodiment of the present disclosure, a bitstream may include prediction information of a current block. The prediction information may include at least one of information about a prediction mode of a current block in a current image, information about a reference picture list used for inter prediction of the current block (e.g., information about an index indicating whether a first reference picture list (L0) is used, a second reference picture list (L1) is used, or bi-prediction (LO and L1) is used), information about a reference picture index, information about a motion vector predictor, and information about a motion vector difference. Meanwhile, without being limited to the disclosed example, the prediction information may include all information for reconstructing the current block through inter prediction.

[0250] In one embodiment of the present disclosure, the prediction information may include at least one of information regarding the intra-prediction mode of the current block and information indicating how the intra-prediction mode is determined. Furthermore, without being limited to the disclosed example, the prediction information may include all information required to restore the current block through intra-prediction.

[0251] In one embodiment of the present disclosure, the bitstream may include information indicating the prediction mode of the current block within the current image. The prediction mode of the current block may include an intra mode, an inter mode, etc. Intra mode is an operation of predicting a block based on spatial similarity, and is a mode in which the current block is predicted or restored based on spatial similarity within the current image, while inter mode is a mode in which the current block is predicted or restored based on a reference image to reduce temporal redundancy between images.

[0252] In one embodiment of the present disclosure, the image decoding device (2000) can perform intra prediction or inter prediction on the current block according to the prediction mode of the current block to generate a prediction block of the current block, and restore the current block using the prediction block.

[0253] In one embodiment of the present disclosure, the image decoding device (2000) can obtain information about the intra prediction mode of the current block from the bitstream when the prediction mode of the current block is the intra mode.

[0254] In one embodiment of the present disclosure, information about the intra prediction mode of the current block may include information indicating a method for determining the intra prediction mode. In one embodiment, the method for determining the intra prediction mode may include a method for determining the intra prediction mode using a reference block, a method for determining the intra prediction mode using a template, or a method for determining the intra prediction mode using information obtained from a bitstream.

[0255] In one embodiment of the present disclosure, information indicating a method for determining an intra prediction mode may be included in a sequence parameter set, a picture parameter set, a slice header, or slice data of a bitstream.

[0256] In one embodiment of the present disclosure, information indicating a method for determining an intra prediction mode may not be included in the bitstream, in which case the image decoding device (2000) may determine the intra prediction mode of the current block according to a predetermined method.

[0257] In one embodiment of the present disclosure, when the method of determining the intra prediction mode is a method of using information obtained from a bitstream, the image decoding device (2000) may determine an intra prediction mode indicated by information obtained from the bitstream among a plurality of intra prediction modes as the intra prediction mode of the current block. For example, information indicating the intra prediction mode of the current block may include a flag or index indicating any one of the plurality of intra prediction modes.

[0258] In one embodiment of the present disclosure, when the method of determining the intra prediction mode is a method of using a reference block or a template, the image decoding device (2000) may determine the intra prediction mode of the current block by using a reference block (hereinafter, referred to as a spatial reference block) within the current image that has been restored before the current block or a template of the reference block within the current image.

[0259] In one embodiment of the present disclosure, when the prediction mode of the current block is inter mode, the image decoding device (2000) can obtain information about a reference picture list indicating which reference picture list among a plurality of reference picture lists to use for prediction of the current block from the bitstream.

[0260] In one embodiment of the present disclosure, when the image decoding device (2000) reconstructs the current block based on the reference image, it may use one reference image (e.g., unidirectional prediction) or two reference images (e.g., bi-prediction). This may be determined through information about the reference picture list, which indicates which reference picture list among a plurality of reference picture lists is to be used for prediction of the current block for inter prediction of the current block.

[0261] In one embodiment of the present disclosure, the video decoding device (2000) may determine one reference picture list used for inter prediction of the current block based on information about a reference picture list indicating which reference picture list among a plurality of reference picture lists is used for prediction of the current block for inter prediction of the current block. For example, the video decoding device (2000) may obtain information about an index indicating whether a first reference picture list (L0), a second reference picture list (L1), or bi-prediction (LO and L1) is used for inter prediction of the current block.

[0262] In one embodiment of the present disclosure, a bitstream may include a reference picture index indicating one of the reference pictures included in a reference picture list. For example, when unidirectional prediction is performed on a current block, the image decoding device (2000) may obtain a reference picture index indicating which reference picture among at least one reference picture included in the reference picture list to use from the bitstream. When pair prediction is performed on a current block, the image decoding device (2000) may obtain a first reference picture index indicating a reference picture included in a first reference picture list for the current block and a second reference picture index indicating a reference picture included in a second reference picture list, respectively.

[0263] In one embodiment of the present disclosure, a bitstream may include information for determining a motion vector. For example, the video decoding device (2000) may obtain an index indicating one of the candidates included in the candidate block list from the bitstream. For example, when unidirectional prediction is performed on the current block, the video decoding device (2000) may obtain a first index indicating a first candidate block among at least one candidate block included in the first candidate block list from the bitstream. When pair prediction is performed on the current block, the video decoding device (2000) may obtain a first index indicating a first candidate block among at least one candidate block included in the first candidate block list and a second index indicating a second candidate block among at least one candidate block included in the second candidate block list from the bitstream. Meanwhile, the first candidate block list and the second candidate block list may be the same or different.

[0264] In one embodiment of the present disclosure, the video decoding device (2000) may obtain an index (e.g., a first index or a second index) indicating one of the candidates included in the candidate block list, and determine a motion vector of the current block using a motion vector of the candidate block indicated by the index.

[0265] In one embodiment of the present disclosure, the image decoding device (2000) can obtain or determine a motion vector of the current block by using the motion vectors of previously decoded blocks spatially adjacent to the current block or blocks included in a previously decoded image.

[0266] In one embodiment of the present disclosure, the video decoding device (2000) can determine the motion vector of a candidate block as the motion vector of the current block. The video decoding device (2000) can obtain or determine the motion vector of the current block by combining information about the motion vector difference obtained from the bitstream and the motion vector of the candidate block.

[0267] In one embodiment of the present disclosure, when a motion vector is adjusted or corrected by template matching, the motion vector of the current block obtained according to the motion vector and / or motion vector difference of previously decoded blocks spatially adjacent to the current block or blocks included in a previously decoded image may be referred to as an initial motion vector. That is, the motion vector before being adjusted or corrected by template matching may be referred to as an initial motion vector.

[0268] In one embodiment of the present disclosure, the image decoding device (2000) can determine a reference block within a reference image using a motion vector of a current block. The image decoding device (2000) can determine a reference image for the current block from a reference picture list. The image decoding device (2000) can determine a motion vector of any candidate block from a candidate block list of the current block as an initial motion vector of the current block. The image decoding device (2000) can also determine a reference block by performing template matching with the current block using the initial motion vector of the current block.

[0269] In one embodiment of the present disclosure, template matching with a current block may be an operation of comparing each template of candidate reference blocks within a predetermined area including a block pointed to by an initial motion vector of the current block with a template of the current block, and determining a candidate reference block with a lowest template cost as the reference block of the current block. Meanwhile, a template for which comparison is performed with the template of the current block may be within a predetermined area including a block pointed to by an initial motion vector of the current block, but is not limited to the disclosed example. The operation of determining a template cost by comparing the template of the candidate reference block with the template of the current block may utilize an operation of determining a template cost according to the present disclosure.

[0270] In one embodiment of the present disclosure, the video decoding device (2000) can determine one candidate among a plurality of candidates included in the candidate block list without obtaining an index indicating one of the candidates included in the candidate block list. For example, the video decoding device (2000) can compare templates corresponding to positions indicated by the motion vectors of each of the candidate blocks included in the candidate block list with the template cost of the template of the current block, and determine the motion vector of the candidate block with the lowest template cost as the motion vector of the current block for determining the reference block. In order to determine one candidate among the plurality of candidates included in the candidate block list through template matching, the operation of determining the template cost can utilize the operation of determining the template cost according to the present disclosure.

[0271] In one embodiment of the present disclosure, the prediction information may be included in a sequence parameter set, a picture parameter set, a slice header, or slice data of a bitstream.

[0272] In one embodiment of the present disclosure, information on whether to perform template matching to obtain a prediction block of a current block or information related to template matching performed on the current block may be included in a sequence parameter set, a picture parameter set, a slice header, or slice data of a bitstream. However, the present disclosure is not limited to the disclosed example, and information on whether to perform template matching and information related to template matching performed on the current block may not be included in the bitstream. Meanwhile, information related to template matching performed on the current block may include information on a method for determining a template cost, etc. The bitstream may include an index or flag indicating any one of a template cost list. Meanwhile, the template cost list may represent a list reordered in ascending order using the template cost. The template cost may also be referred to as a template matching cost.

[0273] In one embodiment of the present disclosure, the image decoding device (2000) may determine any one of a plurality of candidate reference blocks within a search range based on a block vector in intra prediction or a motion vector in inter prediction as a reference block. The image decoding device (2000) may perform template matching on the plurality of candidate reference blocks and determine the candidate reference block with the lowest template cost as the reference block.

[0274] In one embodiment of the present disclosure, the image decoding device (2000) can reconstruct the current block using a reference block. For example, the image decoding device (2000) can generate a prediction block using the reference block, and reconstruct or generate the current block using the prediction block and residual data.

[0275] Meanwhile, with regard to the operation of determining a reference block through template matching, this is described in FIGS. 23 to 26, and with regard to the specific operation of determining a template cost to determine a reference block, this is described later with reference to FIGS. 27 to 29.

[0276] In standards such as HEVC (High Efficiency Video Coding) and VVC (Versatile video coding), a prediction block is generated based on prediction information obtained from a bitstream, which may increase the amount of data required for signaling in intra-prediction mode and inter-prediction mode. Therefore, in one embodiment of the present disclosure, the video decoding device (2000) determines an initial motion vector and performs template matching using a template within a search range based on a block indicated by the initial motion vector, or performs template matching using a template within a search range based on an initial block vector or a current block, thereby reducing the amount of data required for signaling. By performing template matching to reduce the amount of residual data, the amount of data required for signaling can be reduced.

[0277] Below, with reference to FIG. 21, the inter prediction performed on the current block is described.

[0278] FIG. 21 is a diagram illustrating neighboring blocks temporally and / or spatially related to a current block according to one embodiment.

[0279] Referring to FIG. 21, a reference image having a different POC (Picture Order Count) from the POC of the current image including the current block (2115) may be a collocated image. A temporal neighboring block may include a collocated block (Col) (hereinafter referred to as a "collocated block") located at a point corresponding to the current block (2115) within the collocated image. The collocated block may be a block including a sample (Br) corresponding to a position of a sample diagonally adjacent to the lower right of the current block (2115) within the collocated image, or a block including a sample (Ctr) corresponding to a central position of the current block (2115). Meanwhile, without being limited to the disclosed example, a collocated block may be a block including a given sample in a collocated image at a position corresponding to a given sample included in a current block of a current image, and may be determined as any block within a block having a position and size corresponding to the current block in the collocated image, or may be determined as a block adjacent to a block having a position and size corresponding to the current block.

[0280] In one embodiment of the present disclosure, a spatial neighboring block spatially adjacent to the current block (2115) may include at least one of blocks including a lower left outer sample (A0), a lower left sample (A1), an upper right outer sample (B0), an upper right sample (B1), and an upper left outer sample (B2).

[0281] The locations of the temporal neighboring blocks and spatial neighboring blocks illustrated in FIG. 21 are an example, and the locations and numbers of the temporal neighboring blocks and spatial neighboring blocks may vary depending on the implementation example.

[0282] In one embodiment of the present disclosure, when constructing a candidate block list, the video decoding device (2000) may construct the candidate block list by using temporal neighboring blocks and / or spatial neighboring blocks as candidate blocks. The video decoding device (2000) may determine the initial motion vector of the current block through template matching between the template corresponding to the position indicated by the motion vector of the candidate blocks included in the candidate block list and the template of the current block. Alternatively, the video decoding device (2000) may determine the initial motion vector of the current block by obtaining an index or flag indicating any one of the candidates in the candidate block list.

[0283] In one embodiment of the present disclosure, the image decoding device (2000) can adjust the initial motion vector by comparing the template of the current block with the template of an area within a predetermined range centered on the point indicated by the initial motion vector.

[0284] FIG. 22 is a diagram for explaining a template of a template matching prediction mode according to one embodiment.

[0285] Referring to FIG. 22, the templates (2210, 2220, 2230, 2240) of the current block (2200) may have multiple shapes. In one embodiment of the present disclosure, the shape of the template to be compared in the restored area may also be determined based on the template of the current block (2200). In one embodiment of the present disclosure, a template having a shape similar to that of the templates (2210, 2230) may be referred to as an L-shape.

[0286] In one embodiment of the present disclosure, the image decoding device (2000) may determine a template of the current block (2200) to include at least one of a first template located on the left side of the current block, a second template located on the upper side of the current block, and a third template located on the upper left side of the current block. For example, the template (2210) may include the first template located on the left side of the current block, the second template located on the upper side of the current block, and the third template located on the upper left side of the current block, and the template (2220) may include the first template and the second template excluding the third template. However, the present invention is not limited thereto, and the template may include a template located on the right side of the current block (2200).

[0287] In one embodiment of the present disclosure, the image decoding device (2000) can perform template matching prediction using a template (2230) including at least some of a right reference sample, an upper reference sample, and an upper-right reference sample. The image decoding device (2000) can determine the template based on the coding order (or coding direction) of the block. For example, when coding of the block is performed from right to left, the image decoding device (2000) can determine a reference block of the current block (2200) or perform template matching prediction using the template (2230).

[0288] In one embodiment of the present disclosure, the image decoding device (2000) can determine a reference block of the current block (2200) or perform template matching prediction using a template (2240) including at least some of a right reference sample, an upper reference sample, a left reference sample, an upper-left reference sample, and an upper-right reference sample.

[0289] In one embodiment of the present disclosure, when the coding order (or coding direction) of a block changes, the image decoding device (2000) can determine a reference block of the current block (2200) or perform template matching prediction using a template (2240) including a referenceable sample.

[0290] In one embodiment of the present disclosure, the template of the current block (2200) may include one or more reference lines. A first template may include m reference lines (wherein m is an integer greater than or equal to 1), and a second template may include n reference lines (wherein n is an integer greater than or equal to 1).

[0291] In one embodiment of the present disclosure, if some samples of a template corresponding to a reference block are not restored, the image decoding device (2000) may determine the unrestored samples as virtual values. For example, if some of the first template is not restored, the image decoding device (2000) may determine the values ​​of the unrestored samples and determine a template including the determined samples.

[0292] FIG. 22 is a drawing for explaining a template according to one embodiment of the present disclosure, and is not limited thereto, and various forms of templates may be determined. In addition, although the present disclosure describes that the image decoding device (2000) performs template matching using a template (2210) including all of a left reference sample, an upper reference sample, and an upper-left reference sample, the present disclosure is not limited thereto, and template matching prediction may be performed using templates of various shapes as described in FIG. 22.

[0293] FIG. 23 is a diagram for explaining an operation of determining a reference block based on template matching according to one embodiment.

[0294] In one embodiment of the present disclosure, the image decoding device (2000) can determine a reference block within a reference image (2330) by using a motion vector of a current block obtained through prediction information.

[0295] A candidate block list for a current block (2315) in a current image (2310) can be constructed, and an index or flag indicating one of the candidates in the candidate block list can be obtained to determine an initial motion vector (2325) of the current block. In addition, the image decoding device (2000) can determine an initial motion vector (2325) of the current block by comparing a template corresponding to a point indicated by the motion vectors of candidate blocks included in the candidate block list with a template of the current block. In addition, the image decoding device (2000) can determine a reference block in a reference image (2330) using the determined initial motion vector (2325).

[0296] In one embodiment of the present disclosure, the video decoding device (2000) may determine a motion vector corresponding to a given candidate block as an initial motion vector (2325) of the current block, based on template costs corresponding to points pointed to by the motion vectors of each of the candidate blocks. For example, the video decoding device (2000) may determine a motion vector of a candidate block corresponding to the lowest template cost as an initial motion vector (2325) for the current block, based on template costs for points pointed to by the motion vectors of the candidate blocks included in the candidate block list.

[0297] In one embodiment of the present disclosure, the image decoding device (2000) performs template matching using the motion vector of a predetermined candidate block as an initial motion vector (2325), thereby correcting or adjusting the initial motion vector to determine a final motion vector. Meanwhile, the block pointed to by the final motion vector may be a reference block of the present disclosure.

[0298] Meanwhile, in the operation of determining a motion vector using one of the candidate blocks included in the candidate block list through template matching, the description of the motion vector difference is omitted for convenience of explanation, and the image decoding device (2000) can determine a reference block by performing template matching for the current block using the motion vector of the candidate block combined with the motion vector difference.

[0299] In one embodiment of the present disclosure, the video decoding device (2000) can determine a reference block of the current block (2315) by adjusting or correcting the initial motion vector (2325) based on comparing the current template (2316) with a reference template (2336) within a predetermined area (2337) including a point indicated by the initial motion vector. Meanwhile, the motion vector before being adjusted according to template matching may be referred to as the initial motion vector (2325). The predetermined area (2337) may be referred to as a search area or a search range.

[0300] Meanwhile, the search area may represent a point from a point where the x-coordinate and y-coordinate are each -8 sample distances away to a point where the y-coordinate is +8 sample distances away from the point indicated by the initial motion vector (2325), but is not limited to the disclosed example.

[0301] Hereinafter, an operation of an image decoding device (2000) determining a reference block by performing template matching around a location indicated by an initial motion vector (2325) is described.

[0302] In one embodiment of the present disclosure, the image decoding device (2000) can perform template matching using the initial motion vector (2325) of the current block (2315), thereby determining the reference block of the current block (2315) as a block pointed to by the motion vector corrected or adjusted according to the template matching.

[0303] In one embodiment of the present disclosure, the video decoding device (2000) may obtain blocks spatially adjacent to the current block (2315) to construct a candidate block list, and may also obtain blocks that are not spatially adjacent to the current block (2315) as candidate blocks. The candidate block list may include blocks that are spatially adjacent to the current block (2315) or blocks that are not spatially adjacent to the current block (2315) as motion vector candidates.

[0304] In one embodiment of the present disclosure, the image decoding device (2000) may obtain a collocated block and / or a neighboring block of the collocated block within the collocated image of the current block (2315) as candidate blocks to construct a candidate block list. The candidate block list may include a collocated block and / or a neighboring block of the collocated block within the collocated image of the current block (2315) as candidate blocks.

[0305] In one embodiment of the present disclosure, a reference image (2330) including a reference block is an image restored before the current image (2310) and may be an image included in a reference picture list.

[0306] In one embodiment of the present disclosure, neighboring samples restored before the current block (2315) may be used as templates in template matching. The current template (2316), which is the template of the current block (2315), may include at least some of the neighboring samples of the current block (2315). Hereinafter, the template of the current block (2315) may be referred to as the current template (2316), and the template of the reference block may be referred to as the reference template (2336).

[0307] In one embodiment of the present disclosure, the image decoding device (2000) may search for a template that is most similar to the current template (2316) within a reference image (2330) using the current template (2316), and determine a block adjacent to the reference template (2336), which is the most similar template as a result of the search, as a reference block. In FIG. 23, since the current template (2316) is located to the left and above the current block (2315), a block located to the right and below the reference template (2336) that is most similar as a result of the search within the reference image (2330) may be determined as a reference block.

[0308] Meanwhile, the left and upper samples of the current block are explained as an example of a case where the current block is used as a template, and the positional relationship between the template and the reference block may vary depending on the shape of the template.

[0309] In one embodiment of the present disclosure, the operation of searching for a template most similar to the current template (2316) may be an operation of performing template matching with the current block (2315) by determining a candidate reference block corresponding to a reference template with the smallest difference as a reference block by using the difference between sample values ​​included in the current template (2316) of the current block (2315) and sample values ​​included in a reference template corresponding to a candidate location for template matching.

[0310] In one embodiment of the present disclosure, template matching can be performed using various search patterns and search sizes based on the initial motion vector (2325). For example, template matching can search a predetermined area (2337) using a diamond pattern or a cross pattern, and can search the predetermined area (2337) in units of 4 pixels, 1 pixel, 1 / 2 pixel, 1 / 4 pixel, or 1 / 8 pixel. A candidate location for template matching can be a location for comparing a current template (2316) and a template determined according to the search pattern and search size within a predetermined range for template matching.

[0311] In one embodiment of the present disclosure, the image decoding device (2000) can determine the similarity between samples included in candidate reference templates having the same shape as the current template and the current template, and differences between sample values ​​can be used to determine the similarity. The image decoding device (2000) can determine a template including sample values ​​most similar to the sample values ​​included in the current template (2316) as a reference template within the reference image (2330). Meanwhile, a template cost can be used as a measure for determining the similarity.

[0312] In one embodiment of the present disclosure, the image decoding device (2000) may use a cost function to determine the similarity between the current template and the candidate reference template. For example, the image decoding device (2000) may use difference values ​​between the sample values ​​of the template of the current block and the sample values ​​of the template of the candidate reference block to determine the template having the minimum template cost value as the most similar template. The template cost may be determined using at least one cost function among the Sum of Absolute Difference (SAD), the Sum of Absolute Transformed Difference (SATD), the Sum of Squared Error (SSE), the Mean Removed SAD (MR-SAD), the Mean Removed SSE (MR-SSE), the Histogram of Oriented Gradient (HoG), or a template cost calculation method according to the present disclosure, and may be variously changed within a range apparent to those skilled in the art.

[0313] In one embodiment of the present disclosure, the image decoding device (2000) can determine a block corresponding to a template with the lowest template cost as a reference block by comparing the current template with templates within a search range using at least one cost function. The image decoding device (2000) can determine a block adjacent to a template most similar to the current template (2316) within a reference image (2330) as a reference block.

[0314] FIG. 24 is a diagram for explaining an operation of determining a reference block based on template matching according to one embodiment.

[0315] In one embodiment of the present disclosure, the image decoding device (2000) may obtain information about a reference picture list from a bitstream and determine to perform bi-prediction for prediction of the current block (2415).

[0316] In one embodiment of the present disclosure, when pair prediction is performed on a current block (2415) in a current image (2410), the image decoding device (2000) may obtain a first reference image index indicating a reference image included in a first reference picture list for the current block (2415) and a second reference image index indicating a reference image included in a second reference picture list, respectively. In addition, the image decoding device (2000) may determine an image corresponding to the first reference image index as a first reference image (2430), and may determine an image corresponding to the second reference image index as a second reference image (2450).

[0317] In one embodiment of the present disclosure, when pair prediction is performed on a current block (2415), the image decoding device (2000) can obtain a first index indicating a first candidate block among at least one candidate block included in a first candidate block list from a bitstream, and a second index indicating a second candidate block among at least one candidate block included in a second candidate block list.

[0318] In one embodiment of the present disclosure, the image decoding device (2000) can determine a first initial motion vector indicated by a first index in a first reference image and a second initial motion vector indicated by a second index in a second reference image.

[0319] In one embodiment of the present disclosure, the video decoding device (2000) may perform template matching on templates corresponding to points indicated by motion vectors of candidate blocks included in a first candidate block list and a template of a current block to determine a motion vector corresponding to a template with the lowest template cost as a first initial motion vector. The video decoding device (2000) may perform template matching on templates corresponding to points indicated by motion vectors of candidate blocks included in a second candidate block list and a template of a current block to determine a motion vector corresponding to a template with the lowest template cost as a second initial motion vector.

[0320] In one embodiment of the present disclosure, the image decoding device (2000) can determine the first motion vector by performing template matching on the current template (2416), which is a template of the current block (2415), and the template of the block pointed to by the first initial motion vector within the first reference image (2430). The image decoding device (2000) can determine the second motion vector by performing template matching on the current template and the template of the block pointed to by the second initial motion vector within the second reference image (2450).

[0321] In one embodiment of the present disclosure, the video decoding device (2000) can determine a first reference block of the current block (2415) by adjusting or correcting the first initial motion vector based on comparing the current template (2416) with a first reference template (2436) within a predetermined area including a point pointed to by the first initial motion vector. The video decoding device (2000) can determine a second reference block of the current block (2415) by adjusting or correcting the second initial motion vector based on comparing the current template (2416) with a second reference template (2456) within a predetermined area including a point pointed to by the second initial motion vector.

[0322] In one embodiment of the present disclosure, the image decoding device (2000) can search for a template most similar to the current template (2416) in each search area within the first reference image (2430) and the second reference image (2450). The image decoding device (2000) can determine blocks located at the lower right of the first reference template (2436) and the second reference template (2456), which are the most similar templates as a result of the search, as the first reference block and the second reference block, respectively. Meanwhile, a case in which the left samples and the upper samples of the current block (2415) are used as the template of the current block (2415) will be described as an example, and the positional relationship between the template and the reference block may vary depending on the shape of the template.

[0323] Meanwhile, template matching for pair prediction is not limited to the disclosed example, and the search positions or search directions for the first initial motion vector and the second initial motion vector may be dependent on each other.

[0324] Meanwhile, with respect to template matching, each of the operations for determining the first motion vector and the second motion vector can correspond to the operation for determining the motion vector in Fig. 23, and therefore the same content is omitted.

[0325] Meanwhile, FIGS. 23 and 24 describe template matching for inter prediction. Hereinafter, FIGS. 25 and 26 describe template matching for intra prediction.

[0326] FIG. 25 is a diagram for explaining an operation of determining a reference block by performing template matching according to one embodiment.

[0327] In one embodiment of the present disclosure, the image decoding device (2000) can determine a reference block (2530) of the current block (2510) based on template matching for a restored region within the current image including the current block (2510).

[0328] In one embodiment of the present disclosure, the image decoding device (2000) may determine a template similar to the current template (2520) among the restored regions within the search region, determine the template similar to the determined current template (2520) as a reference template (2540), and determine a block corresponding to the reference template (2540) as a reference block (2530).

[0329] In one embodiment of the present disclosure, the image decoding device (2000) can search for a template most similar to the template of the current block (2510) in a search area. The search area may include one or more predefined search areas. Meanwhile, the search area will be described in detail in FIG. 26.

[0330] In one embodiment of the present disclosure, the image decoding device (2000) may perform a comparison of samples included in a restored area with a current template (2520). For example, the image decoding device (2000) may determine the similarity between samples included in a candidate reference template having the same shape as the current template (2220) and the template (2220).

[0331] In one embodiment of the present disclosure, the image decoding device (2000) can determine the similarity between templates using a cost function. For example, the image decoding device (2000) can determine the similarity between templates using at least one cost function among sum of absolute difference (SAD), sum of absolute transformed difference (SATD), sum of squared error (SSE), mean removed SAD (MR-SAD), mean removed SSE (MR-SSE), histogram of oriented gradient (HoG), or a cost calculation method according to the present disclosure.

[0332] In one embodiment of the present disclosure, the image decoding device (2000) can calculate a template cost using at least one cost function and determine a block corresponding to a template having the lowest template cost as a reference block for the current block (2510).

[0333] In one embodiment of the present disclosure, the image decoding device (2000) may determine the template most similar to the current block (2510) among all possible templates in the reconstructed area. For example, the image decoding device (2000) may compare all or some of the templates including the reconstructed samples included in the reconstructed area with the current template (2520) to determine the most similar template. In one embodiment, the image decoding device (2000) may determine a portion of the reconstructed area and perform template matching only on the determined portion. Meanwhile, the portion of the reconstructed area may be referred to as a search area.

[0334] In one embodiment of the present disclosure, the image decoding device (2000) may determine a template similar to the current template (2520) based on a block unit of the restored area. For example, the image decoding device (2000) may compare templates corresponding to blocks of the restored area (e.g., transform blocks or encoding blocks, etc.) with the current template (2520) to determine a similar template.

[0335] In one embodiment of the present disclosure, the image decoding device (2000) can identify templates at predetermined distance intervals within a search range. For example, the image decoding device (2000) can identify templates at three-sample intervals and determine template costs by comparing them with the current template (2520), thereby constructing a list of block vector candidates.

[0336] In one embodiment of the present disclosure, the image decoding device (2000) can construct a candidate list in ascending order of template cost for templates within a search area. For example, the image decoding device (2000) can include 30 block vectors corresponding to templates with low template cost at 3-sample intervals in the candidate list, and perform a fine search at 1-sample intervals in a surrounding 3 X 3 area among the 30 block vectors to ultimately construct a candidate list including 19 candidates.

[0337] In one embodiment of the present disclosure, the image decoding device (2000) may determine one reference template from a candidate list. The image decoding device (2000) may compare templates within a search range with the current template (2520) of the current block (2510) to determine the most similar reference template. The image decoding device (2000) may determine a reference block corresponding to the template determined to be most similar to the current template (2520), such as the relationship between the current template (2520) and the current block (2510).

[0338] In one embodiment of the present disclosure, the image decoding device (2000) may obtain an index indicating one block vector among a plurality of candidates included in a candidate list from a bitstream, and determine a reference block using the block vector corresponding to the index.

[0339] In one embodiment of the present disclosure, the image decoding device (2000) can determine a plurality of reference templates using a candidate list. The image decoding device (2000) can determine a plurality of reference templates having a high degree of similarity with the current template (2520) among the templates of blocks corresponding to the candidate list. Meanwhile, without being limited to the disclosed example, the image decoding device (2000) can also determine a reference template based on obtaining a plurality of indices.

[0340] In one embodiment of the present disclosure, the image decoding device (2000) can predict the current block (2510) using a weighted sum for a plurality of reference blocks. In one embodiment of the present disclosure, the weights for each reference template for the weighted sum for the plurality of reference blocks can be determined based on a template cost or based on a Wiener filter.

[0341] In one embodiment of the present disclosure, the video decoding device (2000) can reconstruct the candidate list to include more precise candidate block vectors by using the block vectors included in the candidate list. For example, the video decoding device (2000) can rearrange the candidate list in ascending order by calculating template costs with respect to templates of blocks located at surrounding 1 / 2 sample intervals, 1 / 4 sample intervals, and 3 / 4 sample intervals for the block vectors included in the candidate list. The video decoding device (2000) can determine a reference block by using two candidate block vectors included in the rearranged candidate list.

[0342] In one embodiment of the present disclosure, the image decoding device (2000) can predict the current block by applying a 6-tap filter with added bias to a 5-tap filter learned based on the relationship between the current template (2520) and the reference template to the determined reference block.

[0343] In one embodiment of the present disclosure, the image decoding device (2000) may perform template matching using, in addition to a predefined search area, a block vector of a block adjacent to a current block (2510) in a current image or a block vector of a block non-adjacent to the current block (2510).

[0344] For example, the image decoding device (2000) may obtain a block vector of a current block (2510) that points to an area excluding a predefined search area from surrounding blocks, and relocated block vectors that represent block vectors of a block pointed to by the block vector of the current block (2510), and may construct a candidate list to include the block vector of the current block and the relocated block vector. The image decoding device (2000) may determine a block vector pointing to any one point among the block vectors included in the candidate list through template matching, and may determine a reference block (2530) of the current block (2510) by correcting the determined block vector through template matching.

[0345] Meanwhile, without being limited to the disclosed example, the image decoding device (2000) can determine a candidate block vector by obtaining an index indicating any one candidate block vector included in the candidate list.

[0346] Meanwhile, the relocated block vectors included in the candidate list can be recursively obtained until a preset number is reached or until no additional relocated block vectors are obtained.

[0347] FIG. 26 is a diagram for explaining a search range of a template matching prediction mode according to one embodiment of the present disclosure.

[0348] In one embodiment of the present disclosure, the image decoding device (2000) may search for a template most similar to the template of the current block (2600) in a search area. The search area may include one or more predefined search areas. For example, an area located a predetermined distance away from the position of the current block may be predefined as the search area in the image encoding device and the image decoding device.

[0349] In one embodiment of the present disclosure, the search area may be determined based on at least one of the width (W) or height (H) of the current block (2600). Referring to FIG. 26, the first search area (R1) may include an area further than the height (H) of the current block (2600) from the boundary of the maximum coding unit (CTU) including the current block (2600). The width of the first search area may be determined based on the width (W) of the current block (2600).

[0350] In one embodiment of the present disclosure, the search area may be an area including a first search area, a second search area (R2), a third search area (R3), a fourth search area (R4), a fifth search area (R5), and a sixth search area (R6), as shown in FIG. 24. For example, the width of the first search area may be determined as twice the maximum value of 5*W and 64. The height of the first search area may be determined based on at least one of the height of the current block (2600) or the position (Xc, Yc) of the current block (2600). The height of the first search area may be determined as the difference between the "maximum value of 5*H and 64" and the height and the vertical position (Yc) of the current block (2600). Similarly, the second search area (R2), the third search area (R3), the fourth search area (R4), the fifth search area (R5), and the sixth search area (R6) can be determined based on the width, height, or position of the current block (2600). Meanwhile, the search areas are not limited to those disclosed in FIG. 26.

[0351] In one embodiment of the present disclosure, the search area may be determined based on a maximum coding unit (CTU), unlike the disclosure of FIG. 24. For example, the search area may include a first search area included in a maximum coding unit such as the current block (2600), a second search area representing a maximum coding unit located to the upper left of the maximum coding unit including the current block (2600), a third search area representing a maximum coding unit located above, and a fourth search area representing a maximum coding unit located to the left. The search area may be determined based on the height or width of the current block (2600).

[0352] In one embodiment of the present disclosure, the image decoding device (2000) can perform template matching by determining a template cost using a cost function. The image decoding device (2000) can determine a template at predetermined intervals. For example, a candidate can be determined in a sample window of a predetermined size. The image decoding device (2000) can identify a sampling factor associated with the predetermined interval and perform template matching based on the sampling factor. For example, when the sampling factor is 3, the image decoding device (2000) can determine a candidate in a 3 x 3 pixel window.

[0353] In one embodiment of the present disclosure, the image decoding device (2000) may perform template matching prediction based on the width or height of the current block (2600). For example, the image decoding device (2000) may perform template matching prediction for a coding unit in which the width and height of the current block (2600) are less than or equal to 64. A flag regarding template matching prediction may be signaled through the coding unit syntax.

[0354] Below, the method for determining the template cost is described in detail through Figs. 27 to 29.

[0355] Fig. 27 is a diagram for explaining an operation of determining a template cost according to one embodiment.

[0356] In one embodiment of the present disclosure, the image decoding device (2000) repeatedly performs a process of finding a template similar to the template (2720, 2725) of the current block (2710) during the process of performing template matching. For example, the image decoding device (2000) may determine template costs corresponding to templates of predetermined candidate reference positions, respectively, by using sample values ​​of samples included in templates of candidate reference blocks corresponding to a plurality of candidate positions and sample values ​​of samples included in templates (2720, 2725) of the current block (2710).

[0357] Meanwhile, for convenience of explanation, in the preceding disclosure, the templates (2720, 2725) of the current block (2710) may be described as the current template, and the templates of the candidate reference blocks or reference blocks may be described as the reference templates. In addition, a block at a candidate location corresponding to a template within a search range for template matching for the current block (2710) may be referred to as a candidate reference block (2730).

[0358] In one embodiment of the present disclosure, the image decoding device (2000) may use a Sum of Absolute Difference (SAD), a Sum of Absolute Transformed Difference (SATD), a Sum of Squared Error (SSE), a Mean Removed SAD (MR-SAD), a Mean Removed SSE (MR-SSE), and a Histogram of Oriented Gradient (HoG) as cost functions for determining a template cost for each sample included in a template (2720, 2725) of a current block (2710) and each sample included in a template (2740, 2745) of a candidate reference block (2730) at a location corresponding to each sample included in the template (2720, 2725) of the current block (2710).

[0359] In one embodiment of the present disclosure, when the image decoding device (2000) determines the cost function as SAD, the template cost () is determined according to the following mathematical expression 1. ) can be determined.

[0360] [Mathematical Formula 1]

[0361]

[0362] Looking at mathematical formula 1, represents the sample values ​​for the upper samples (2740) among the templates of the candidate reference block (2730), represents the sample values ​​for the upper samples (2720) among the templates of the current block (2710), represents the sample values ​​for the left samples (2745) among the templates of the candidate reference block (2730), can represent sample values ​​for the left samples (2725) among the templates of the current block (2710).

[0363] Meanwhile, the template cost may be determined by performing an operation on all blocks included in the template, or may be determined by performing the operation on samples at every two-sample interval. However, this is not limited to the disclosed example.

[0364] In one embodiment of the present disclosure, when the image decoding device (2000) determines the cost function as MR-SAD, it can determine the template cost according to the following mathematical expression 2.

[0365] [Equation 2]

[0366]

[0367] In mathematical expression 2, the description of the same parameters as in mathematical expression 1 is omitted. In addition, in mathematical expression 2, represents the average of the sample values ​​of the upper samples (2740) of the template of the candidate reference block used to determine the template cost, represents the average of the sample values ​​of the upper samples (2720) of the template of the current block (2710) used to determine the template cost, represents the average of the sample values ​​of the left samples (2745) of the template of the candidate reference block used to determine the template cost, may represent the average of the sample values ​​of the left samples (2725) of the template of the current block (2710) used to determine the template cost.

[0368] In one embodiment of the present disclosure, the image decoding device (2000) may determine a cost function for calculating a template cost for templates of a plurality of candidate reference blocks differently for each candidate reference block. For example, the image decoding device (2000) may determine a cost function for determining a template cost for a template of a first candidate reference block as SAD, a cost function for determining a template cost for a template of a second candidate reference block as SSE, and a cost function for determining a template cost for a template of a third candidate reference block as SATD. Meanwhile, without being limited to the disclosed example, the cost function for determining a template cost for a template of a candidate reference block may be determined in various ways for each candidate reference block.

[0369] In one embodiment of the present disclosure, the image decoding device (2000) may determine a cost function for calculating a template cost for templates of some candidate reference blocks as MR-SAD, and may determine a cost function for templates of other candidate reference blocks as SAD. For example, if a first candidate reference block is predicted using Local Illumination Compensation (LIC), the image decoding device (2000) may determine a cost function for determining a template cost as MR-SAD, and if a second candidate reference block is predicted without using Local Illumination Compensation, the cost function for determining a template cost may be determined as SAD.

[0370] Meanwhile, if the cost function for determining the template cost for the templates of multiple candidate reference blocks is determined using different cost functions, it may be difficult to accurately compare the costs. Therefore, the image decoding device (2000) may impose a penalty on the template cost according to a predetermined cost function, thereby determining a higher template cost for templates with relatively low similarity.

[0371] For example, according to mathematical expression 3, the image decoding device (2000) can determine the final template cost when a constant greater than or equal to 1 is applied by imposing a penalty on the initial template cost according to a predetermined cost function. In mathematical expression 3, is the initial template cost, may be the final template cost. Also, the penalty is It can have values ​​such as 1.005, 1.010, etc., but is not limited to the disclosed examples.

[0372] [Equation 3]

[0373]

[0374] In one embodiment of the present disclosure, for each template of a current block and a candidate reference block, the MR-SAD may measure a difference between the values ​​obtained by subtracting the average value of the samples from each sample value, and the value may be measured to be smaller than the SAD measuring the difference between the sample values. The image decoding device (2000) may reduce a difference caused by a difference between the template cost of the template of the first candidate reference block using MR-SAD as a cost function and the cost function of the second candidate reference block using SAD as a cost function by applying a constant greater than 1 to the template cost.

[0375] For example, in the above mathematical expression 3, can be the final template cost for the template of the first candidate reference block using MR-SAD as a cost function, can be the initial template cost for the template of the first candidate reference block using MR-SAD as a cost function.

[0376] In one embodiment of the present disclosure, the image decoding device (2000) determines the template cost for templates of multiple candidate reference blocks as different cost functions, so that an accurate comparison of costs may not be possible. Therefore, the final template cost may be determined by assigning weights to template costs according to multiple cost functions for the template of one candidate reference block.

[0377] In one embodiment of the present disclosure, the image decoding device (2000) can determine the template cost for the first candidate reference block by assigning a first cost weight to a first template cost according to a first cost function for the template of the first candidate reference block, and assigning a second cost weight to a second template cost according to a second cost function for the template of the first candidate reference block.

[0378] [Equation 4]

[0379]

[0380] In the above mathematical formula 4, represents the first template cost according to the first cost function, represents the first template cost according to the second cost function, represents the first cost weight, can represent the second cost weight.

[0381] For example, if a candidate reference block (2730) is predicted using local illumination compensation, the image decoding device (2000) may determine a first template cost and a second template cost using SAD and MR-SAD as a first cost function and a second cost function, respectively, and the image decoding device (2000) may determine a final template matching cost for the candidate reference block by applying a first cost weight to the first template cost and a second cost weight to the second template cost. At this time, the first template cost may be determined according to mathematical expression 1, and the second template cost may be determined according to mathematical expression 2.

[0382] In one embodiment of the present disclosure, although omitted for convenience of explanation, when pair prediction is performed, the operation of determining a reference block according to a previous or subsequent disclosure may be performed respectively to determine a first reference block and a second reference block. The image decoding device (2000) may perform an operation of determining or calculating a template cost according to the present disclosure to determine a first reference block, and may perform an operation of determining and calculating a template cost according to the present disclosure to determine a second reference block.

[0383] In one embodiment of the present disclosure, when a first candidate block for determining a first reference block based on a current block and a second candidate block for determining a second reference block are spatially dependent, the image decoding device (2000) may determine the template cost by replacing the average of information associated with the template of the first candidate block and information associated with the template of the second candidate block with information associated with the template of the candidate reference block, for an operation of calculating a template cost according to the present disclosure.

[0384] In one embodiment of the present disclosure, when a first candidate block and a second candidate block are spatially dependent, the image decoding device (2000) may determine the template cost by assigning a predetermined weight to each of information associated with the template of the first candidate block and information associated with the template of the second candidate block, in place of the information associated with the template of the candidate reference block, for calculating the template cost of the present disclosure.

[0385] Meanwhile, the disclosure for the above-described pair prediction can be applied to the operation of determining the template cost according to the disclosure below when determining the template cost in pair prediction, but is omitted for convenience of explanation.

[0386] Fig. 28 is a diagram for explaining an operation of determining a template cost according to one embodiment.

[0387] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction block of the current block (2810) based on at least one of a template (2820, 2825) of the current block (2810), a candidate reference block (2830), and a template (2840, 2845) of the candidate reference block (2830). The image decoding device (2000) can reconstruct the current block (2810) using the prediction block.

[0388] In one embodiment of the present disclosure, the image decoding device (2000) may obtain first sample values ​​corresponding to positions of samples within the current block (2810) based on templates (2820, 2825) of the current block (2810), candidate reference blocks (2830), and templates (2840, 2845) of the candidate reference blocks (2830). The first sample values ​​may be sample values ​​for samples corresponding to predetermined positions within the current block (2810). For example, the first sample values ​​may be sample values ​​for samples (2823, 2828) adjacent to the template (2720, 2725) of the current block (2810) within the current block (2810), as illustrated in FIG. 28, may be sample values ​​for all samples adjacent to the template (2820, 2825) of the current block (2810), or may be sample values ​​for some samples adjacent to the template of the current block (2810).

[0389] In one embodiment of the present disclosure, the image decoding device (2000) may obtain second sample values ​​of samples within a candidate reference block (2830). The second sample values ​​may be sample values ​​within the candidate reference block (2830) at locations corresponding to samples within the current block (2810). In addition, the second sample values ​​may be sample values ​​for samples (2843, 2848) adjacent to templates (2840, 2845) of the candidate reference block (2830) within the candidate reference block (2830). The second sample values ​​may be sample values ​​for all samples adjacent to the templates (2840, 2845) of the candidate reference block (2830), or may be sample values ​​for some samples adjacent to the templates (2840, 2845) of the candidate reference block (2830). The second sample values ​​may be determined depending on the positions of the samples (2823, 2828) for the first sample values, as sample values ​​within the candidate reference block (2830) corresponding to the first sample values. In addition, the second sample values ​​may include samples within the previously restored candidate reference block (2830).

[0390] In one embodiment of the present disclosure, the image decoding device (2000) can determine a template cost based on the first sample values ​​and the second sample values.

[0391] In one embodiment of the present disclosure, the image decoding device (2000) can determine a template cost by using first current template samples (2822, 2827) adjacent to the current block (2810) among the samples included in the templates (2820, 2825) of the current block (2810) and first reference template samples (2842, 2847) adjacent to the candidate reference block (2830) among the samples included in the templates (2840, 2845) of the candidate reference block (2830).

[0392] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the difference between the first current template sample values ​​of the first current template samples (2822, 2827) and the first sample values, respectively, and the difference between the first reference template sample values ​​of the first reference template samples (2842, 2847) and the second sample values, respectively. The difference between the first current template sample values ​​and the first sample values, respectively, may represent differences between adjacent samples. The difference between the first reference template sample values ​​and the second sample values, respectively, may represent differences between adjacent samples. Meanwhile, the difference between each sample in the preceding or following present disclosure may represent differences between adjacent samples or differences between samples at corresponding positions.

[0393] In one embodiment of the present disclosure, the image decoding device (2000) may calculate the template cost between the current block (2810) and the candidate reference block (2830) based on the difference between the first current template sample values ​​of the first current template samples (2822, 2827) and the first sample values, respectively, and the difference between the first reference template sample values ​​of the first reference template samples (2842, 2847) and the second sample values, respectively. For example, the image decoding device (2000) may calculate the template cost ( ) according to the following mathematical expression 5. ) can be determined.

[0394] [Equation 5]

[0395]

[0396] Looking at mathematical formula 5, Since it is identical to mathematical expression 1, the identical content is omitted.

[0397] In mathematical equation 5, represents sample values ​​of samples (2842) adjacent to the candidate reference block (2830) within the upper template (2840) of the candidate reference block (2830), may represent sample values ​​of samples (2843) within a candidate reference block (2830) adjacent to an upper template (2840) of the candidate reference block (2830). represents the sample values ​​of samples (2847) adjacent to the candidate reference block (2830) within the left template (2845) of the candidate reference block (2830), may represent sample values ​​of samples (2848) within a candidate reference block (2830) adjacent to a left template (2845) of the candidate reference block (2830).

[0398] In mathematical equation 5, represents the sample values ​​of samples (2822) adjacent to the current block (2810) within the upper template (2820) of the current block (2810), may represent sample values ​​corresponding to the positions of samples (2823) within the current block (2810) adjacent to the upper template (2820) of the current block (2810). represents the sample values ​​of the samples (2827) adjacent to the current block (2810) within the left template (2825) of the current block (2810), may represent sample values ​​corresponding to the positions of samples (2828) within the current block (2810) adjacent to the left template (2825) of the current block (2810).

[0399] Meanwhile, the first current template samples (2822, 2827) are and , and the first reference template samples (2842, 2847) are and can be expressed as . In addition, the samples (2823, 2848) corresponding to the positions of the samples in the current block (2810) corresponding to the first sample values ​​are and , and the samples (2843, 2848) in the candidate reference block (2830) corresponding to the second sample values ​​are and can be expressed as

[0400] Meanwhile, the template cost according to the above mathematical expression 5 need not be calculated using all of the samples arranged sequentially as illustrated in FIG. 28, and may be calculated using only some of the samples illustrated in FIG. 28. In addition, for convenience of explanation, the template is described as being located on the left and upper sides of the block as an example, but the template may be located on one or more sides of the block, and is not limited to the disclosed example.

[0401] In one embodiment of the present disclosure, the image decoding device (2000) may calculate a template cost between a current block (2810) and a candidate reference block (2830) based on applying a first weight to the difference between the first current template sample values ​​of the first current template samples (2822, 2827) and the first sample values, respectively, and applying a second weight to the difference between the first reference template sample values ​​of the first reference template samples (2842, 2847) and the second sample values, respectively. For example, the image decoding device (2000) may calculate the template cost ( ) according to the following mathematical expression 6. ) can be determined.

[0402] [Equation 6]

[0403]

[0404] In mathematical expression 6, the same content as mathematical expression 5 is omitted.

[0405] Referring to mathematical expression 6, the weights for the differences between the first current template sample values ​​and the first sample values ​​of the first current template samples (2822, 2842) are ( is a real number greater than or equal to 0 and less than or equal to 1), and a weight is applied to the difference between the first reference template sample values ​​and the second sample values ​​of the first reference template samples (2842, 2847). By applying , the template cost between the current block (2810) and the candidate reference block (2830) can be calculated.

[0406] Referring to mathematical expression 6, the weight As the weight increases, the template cost is determined by considering the tendency for the candidate reference block (2830) more, and the weight As it gets lower, it may be possible to consider the template cost by taking into account the tendency for the current block (2810).

[0407] In one embodiment of the present disclosure, the image decoding device (2000) may determine a template cost according to Equations 5 and 6 after performing an operation of acquiring or determining first sample values.

[0408] In one embodiment of the present disclosure, the image decoding device (2000) may determine the first sample values ​​to have the same values ​​as the second sample values ​​of the samples (2843, 2848) within the candidate reference block (2830). The first sample values ​​may be determined to have the same values ​​as the second sample values ​​of the samples (2843, 2848) within the candidate reference block (2830) corresponding to the positions of the samples within the current block (2810).

[0409] For example, the image decoding device (2000) may determine, among the first sample values, the sample values ​​corresponding to the positions of the samples (2823) in the current block (2810) adjacent to the upper template (2820) of the current block (2810), as the sample values ​​of the samples (2843) in the candidate reference block (2830) adjacent to the upper template (2840) of the candidate reference block (2830). This is can be expressed in the form of

[0410] For example, the image decoding device (2000) may determine, among the first sample values, the sample values ​​corresponding to the positions of the samples (2828) in the current block (2810) adjacent to the left template (2825) of the current block (2810), as the sample values ​​of the samples (2848) in the candidate reference block (2830) adjacent to the left template (2845) of the candidate reference block (2830). This is can be expressed in the form of

[0411] In one embodiment of the present disclosure, the image decoding device (2000) may obtain first sample values ​​based on intra prediction information for blocks surrounding the current block (2810). For example, if the image decoding device (2000) identifies blocks surrounding the current block (2810) as having been reconstructed through intra prediction, the image decoding device (2000) may obtain first sample values ​​corresponding to the locations of samples within the current block (2810) by using the intra prediction mode of the corresponding blocks surrounding the current block.

[0412] In one embodiment of the present disclosure, a neighboring block may be at least one of a spatial neighboring block and a temporal neighboring block in relation to the current block (2810), but is not limited to the disclosed example. Meanwhile, a spatial neighboring block may be adjacent or non-adjacent to the current block (2810).

[0413] In one embodiment of the present disclosure, by calculating the template cost according to FIG. 28, subjective image quality can be improved by considering not only the sample change in the temporal direction between templates of each block, but also the continuity between each block and template, thereby considering the sample change in the spatial direction.

[0414] Fig. 29 is a diagram for explaining an operation of determining a template cost according to one embodiment.

[0415] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction block of the current block (2910) based on at least one of a template (2920, 2925) of the current block (2910), a candidate reference block (2930), and a template (2940, 2945) of the candidate reference block (2930), and can reconstruct the current block (2910) using the prediction block.

[0416] In one embodiment of the present disclosure, the image decoding device (2000) can obtain first sample values ​​corresponding to positions of samples (2923, 2928) within the current block (2910) based on templates (2920, 2925) of the current block (2910), candidate reference blocks (2930), and templates (2940, 2945) of the candidate reference blocks (2930). The image decoding device (2000) can obtain second sample values ​​of samples (2943, 2948) within the candidate reference block (2830).

[0417] In one embodiment of the present disclosure, the image decoding device (2000) can determine a template cost based on first sample values ​​and second sample values. Meanwhile, since the first sample values ​​and second sample values ​​have been described in detail in FIG. 28, the same details will be omitted.

[0418] In one embodiment of the present disclosure, the image decoding device (2000) may determine the template cost by using the difference between the first sample values ​​and the second sample values ​​at the positions corresponding to the first sample values. For example, the image decoding device (2000) may determine the template cost () between the current block (2910) and the candidate reference block (2930) according to the following mathematical expression 7. ) can be determined.

[0419] [Equation 7]

[0420]

[0421] Looking at mathematical formula 7, Since it is the same as mathematical expression 1, the same content is omitted. , , and As it is the same as the content described in Fig. 28 and mathematical formula 5, it is omitted.

[0422] In one embodiment of the present disclosure, the image decoding device (2000) may determine a template cost according to mathematical expression 7 after performing an operation of acquiring or determining first sample values.

[0423] In one embodiment of the present disclosure, the image decoding device (2000) can obtain first sample values ​​based on at least one of first current template sample values ​​for first current template samples (2922, 2927) adjacent to the current block among the samples included in the templates (2920, 2925) of the current block (2910) and second current template sample values ​​for second current template samples (2921, 2926) adjacent to the first current template samples among the samples included in the templates (2920, 2925) of the current block (2910).

[0424] In one embodiment of the present disclosure, referring to FIG. 29, the first current template samples (2922, 2927) are: and , and the second current template samples (2921, 2926) are and can be expressed as represents sample values ​​for adjacent samples (2921) of the current block (2910) and adjacent samples (2922) within the upper template (2920) of the current block (2910), may represent sample values ​​for adjacent samples (2926) of the current block (2910) and adjacent samples (2927) within the left template (2925) of the current block (2910).

[0425] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the first sample values ​​by using the difference between the first current template sample values ​​and the second current template sample values ​​at positions corresponding to (adjacent to) the first current template sample values.

[0426] For example, among the first sample values, the samples (2923,) adjacent to the upper template (2920) of the current block (2910) )silver, Based on the assumption of, It can be determined according to the formula. Among the first sample values, the samples (2928, ) adjacent to the left template (2925) of the current block (2910) )silver, Based on the assumption of, It can be determined by consciousness.

[0427] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the first sample values ​​by using linearity for the first current template sample values ​​and the second current template sample values ​​at positions corresponding to (adjacent to) the first current template sample values. The image decoding device (2000) can obtain the first linear parameter and the second linear parameter by performing linear regression analysis on the first current template sample values ​​and the second current template sample values.

[0428] In one embodiment of the present disclosure, the image decoding device (2000) may obtain first sample values ​​using a first linear parameter, a second linear parameter, and first current template sample values. The first linear parameter and the second linear parameter may be determined or obtained for each of the upper template (2920) and the left template (2925) of the current block (2910), or may be determined or obtained as parameters integrated into both the upper template (2920) and the left template (2925).

[0429] In one embodiment of the present disclosure, the image decoding device (2000) The first linear parameter satisfying and the second linear parameter The first sample values ​​can be determined by using the sample values ​​for the samples (2922) included in the upper template (2920) of the current block (2910) among the first linear parameter, the second linear parameter, and the first current template sample values ​​obtained through linear regression analysis. The image decoding device (2000) According to the formula, among the first sample values, the samples (2923, ) adjacent to the upper template (2920) of the current block (2910) ) can be obtained as sample values.

[0430] In one embodiment of the present disclosure, the image decoding device (2000) The first linear parameter satisfying and the second linear parameter The image decoding device (2000) can obtain the first linear parameter, the second linear parameter, and the first current template sample values ​​by using the samples included in the left template (2925) of the current block (2910) through linear regression analysis, and determine the first sample values. According to the formula, among the first sample values, the samples (2928, ) adjacent to the left template (2925) of the current block (2910) ) can be obtained as sample values.

[0431] In one embodiment of the present disclosure, the image decoding device (2000) and The first linear parameter satisfying and the second linear parameter The image decoding device (2000) can obtain the first sample values ​​by using linear regression analysis, and determine the first sample values ​​by using the first linear parameter, the second linear parameter, and the first current template sample values. and According to the consciousness, the first sample values ​​can be obtained.

[0432] In one embodiment of the present disclosure, the image decoding device (2000) may obtain first sample values ​​by using the difference or linearity between the first current template sample values ​​and the second current template sample values, respectively, and determine a template cost between the current block (2910) and the candidate reference block (2930) by using the difference between the first sample values ​​and the second sample values.

[0433] Fig. 30 is a diagram for explaining an operation of determining a template cost according to one embodiment.

[0434] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction block of the current block (3010) based on at least one of a template (3020, 3025) of the current block (3010), a candidate reference block (3030), and a template (3040, 3045) of the candidate reference block (3030), and can reconstruct the current block (3010) using the prediction block.

[0435] In one embodiment of the present disclosure, the image decoding device (2000) can obtain first sample values ​​corresponding to positions of samples (3023, 3028) within the current block (3010) based on templates (3020, 3025) of the current block (3010), candidate reference blocks (3030), and templates (3040, 3045) of the candidate reference blocks (3030). The image decoding device (2000) can obtain second sample values ​​of samples (3043, 3048) within the candidate reference block (2830).

[0436] In one embodiment of the present disclosure, the image decoding device (2000) can determine a template cost based on first sample values ​​and second sample values. Meanwhile, since the first sample values ​​and second sample values ​​have been described in detail in FIGS. 28 and 29 , the same details will be omitted.

[0437] In one embodiment of the present disclosure, the image decoding device (2000) may determine the template cost by using the difference between the first sample values ​​and the second sample values ​​at the positions corresponding to the first sample values. For example, the image decoding device (2000) may determine the template cost () between the current block (3010) and the candidate reference block (3030) according to Equation 7 of FIG. 29. ) can be determined. The same content as Fig. 29 is omitted as it is redundant.

[0438] In one embodiment of the present disclosure, the image decoding device (2000) can obtain first sample values ​​based on at least one of first current template sample values ​​for first current template samples (3022, 3027) adjacent to the current block among the samples included in the templates (3020, 3025) of the current block (3010) and second current template sample values ​​for second current template samples (3021, 3026) adjacent to the first current template samples (3022, 3027) among the samples included in the templates (3020, 3025) of the current block (3010).

[0439] In one embodiment of the present disclosure, the image decoding device (2000) can obtain second sample values ​​based on at least one of first reference template sample values ​​for first reference template samples (3042, 3047) adjacent to the candidate reference block (3030) among the samples included in the templates (3040, 3045) of the candidate reference block (3030) and second reference template sample values ​​for second reference template samples (3041, 3046) adjacent to the first reference template samples (3042, 3047) among the samples included in the templates (3040, 3045) of the candidate reference block (3030).

[0440] In one embodiment of the present disclosure, referring to FIG. 30, the first reference template samples (3042, 3047) are: and , and the second reference template samples (3041, 3046) are and can be expressed as represents sample values ​​of adjacent samples (3042) and adjacent samples (3041) within the upper template (3040) of the candidate reference block (3030), can represent sample values ​​of adjacent samples (3046) of the candidate reference block (3030) and adjacent samples (3047) within the left template (3045) of the candidate reference block (3030).

[0441] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the first linear parameter and the second linear parameter through linear regression analysis on the samples included in the template (3020, 3025) of the current block (3010) and the samples included in the template (3040, 3045) of the candidate reference block (3030). Each of the samples included in the template (3020, 3025) of the current block (3010) and the samples included in the template (3040, 3045) of the candidate reference block (3030) is: i) first current template samples (3022, 3027) and first reference template samples (3042, 3047) adjacent to the candidate reference block among the samples included in the template of the candidate reference block, ii) second current template samples (3021, 3026) and second reference template samples (3041, 3046) adjacent to the first reference template samples among the samples included in the template of the candidate reference block, and iii) first current template samples (3022, 3027) and second current template samples (3021, 3026) and first reference template samples (3042, 3047) and second reference template samples (3042, 3047) It can be any one of the samples (3041, 3046).

[0442] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a first linear parameter and a second linear parameter through linear regression analysis on the first current template sample values ​​of the first current template samples (3022, 3027) and the first reference template sample values ​​of the first reference template samples (3042, 3047).

[0443] For example, the video decoding device (2000) and The first linear parameter satisfying at least one of the equations is and the second linear parameter can be obtained through linear regression analysis. That is, parameters satisfying the above equation can be obtained only for the upper templates, parameters satisfying the above equation can be obtained only for the left templates, or parameters satisfying the above equation can be obtained for the upper templates and the left templates.

[0444] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a first linear parameter and a second linear parameter through linear regression analysis on the second current template sample values ​​of the second current template samples (3021, 3026) and the second reference template sample values ​​of the second reference template samples (3041, 3046).

[0445] For example, the video decoding device (2000) and The first linear parameter satisfying at least one of the equations is and the second linear parameter can be obtained through linear regression analysis. That is, parameters satisfying the above equation can be obtained only for the upper templates, parameters satisfying the above equation can be obtained only for the left templates, or parameters satisfying the above equation can be obtained for the upper templates and the left templates.

[0446] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a first linear parameter and a second linear parameter through linear regression analysis on the first current template sample values, the second current template sample values, and the first reference template sample values ​​and the second reference template sample values.

[0447] For example, the video decoding device (2000) class , and class The first linear parameter satisfying at least one of the equations is and the second linear parameter can be obtained through linear regression analysis. That is, parameters satisfying the above equation can be obtained only for the upper templates, parameters satisfying the above equation can be obtained only for the left templates, or parameters satisfying the above equation can be obtained for the upper templates and the left templates.

[0448] In one embodiment of the present disclosure, the image decoding device (2000) can obtain or determine first sample values ​​by using first linear parameters and second linear parameters obtained through linear regression analysis on samples included in templates (3020, 3025) of a current block (3010) and samples included in templates (3040, 3045) of a candidate reference block (3030). The image decoding device (2000) can obtain the first sample values ​​by using the first linear parameter, the second linear parameter, and the second sample values.

[0449] For example, the image decoding device (2000) obtains the first linear parameter and the second linear parameter using the method described above, and By applying the first linear parameter, the second linear parameter, and the second sample values ​​to the equation, the first sample values ​​can be obtained.

[0450] In one embodiment of the present disclosure, the video decoding device (2000) can identify whether to use a method for calculating a template cost according to Equation 7. The video decoding device (2000) can determine whether to use a method for calculating a template cost according to Equations 5 to 7 by verifying templates (3040, 3045) of a candidate reference block (3030) and sample values ​​for the candidate reference block (3030).

[0451] In one embodiment of the present disclosure, the image decoding device (2000) may obtain third sample values ​​corresponding to positions of samples (3043, 3048) within the candidate reference block (3030) by using the difference between first reference template sample values ​​for first reference template samples (3042, 3047) adjacent to the candidate reference block (3030) among the samples included in the template (3040, 3045) of the candidate reference block (3030) and second reference template sample values ​​for second reference template samples (3041, 3046) adjacent to the first reference template samples (3042, 3047) among the samples included in the template of the candidate reference block (3030).

[0452] In one embodiment of the present disclosure, the image decoding device (2000) can obtain third sample values ​​by using the difference between the second reference template sample values ​​and the first reference template sample values ​​at positions corresponding to the second reference template sample values.

[0453] Meanwhile, the third sample values ​​may be sample values ​​corresponding to the positions of the second sample values. The second sample values ​​may represent restored sample values ​​within the candidate reference block (3030), but the third sample values ​​may represent sample values ​​corresponding to the positions of samples within the candidate reference block predicted using the template (3040, 3045) of the candidate reference block (3030). The third sample values ​​are sample values ​​predicted using the template (3040, 3045) of the candidate reference block (3030). and , and the second sample values ​​may be restored sample values ​​within the candidate reference block. and These may be sample values ​​corresponding to .

[0454] In one embodiment of the present disclosure, samples adjacent to the upper template (3040) of the candidate reference block (3030) among the third sample values )silver, Based on the assumption of, It can be determined according to the formula. Among the third sample values, samples adjacent to the left template (3045) of the candidate reference block (3030) )silver, Based on the assumption of, It can be determined by consciousness.

[0455] In one embodiment of the present disclosure, the image decoding device (2000) can obtain third sample values ​​by using linearity for the first reference template sample values ​​and the second reference template sample values ​​at positions corresponding to (adjacent to) the first reference template sample values. The image decoding device (2000) can obtain the first reference parameter and the second reference parameter through linear regression analysis for the first reference template sample values ​​and the second reference template sample values. The first reference parameter and the second reference parameter may be determined or obtained for each of the upper template (3040) and the left template (3045) of the candidate reference block (3030), or may be determined or obtained as parameters integrated into both the upper template (3040) and the left template (3045).

[0456] In one embodiment of the present disclosure, the image decoding device (2000) The first reference parameter that satisfies and the second reference parameter The image decoding device (2000) may obtain the first reference parameter, the second reference parameter, and the third sample values ​​by using the sample values ​​for the samples (3042) included in the upper template (3040) of the candidate reference block (3030) among the first reference parameter, the second reference parameter, and the first reference template sample values. According to the formula, among the third sample values, samples adjacent to the upper template (3040) of the candidate reference block (3030) ) can be obtained as sample values.

[0457] In one embodiment of the present disclosure, the image decoding device (2000) The first reference parameter that satisfies and the second reference parameter The image decoding device (2000) may obtain the first reference parameter, the second reference parameter, and the third sample values ​​by using the sample values ​​for the samples (3047) included in the left template (3045) of the candidate reference block (3030) among the first reference parameter, the second reference parameter, and the first reference template sample values. According to the formula, among the third sample values, the samples adjacent to the left template (3045) of the candidate reference block (3030) ) can be obtained as sample values.

[0458] In one embodiment of the present disclosure, the image decoding device (2000) and The first reference parameter that satisfies and the second reference parameter The image decoding device (2000) can obtain the first reference parameter, the second reference parameter, and the first reference template sample values ​​through linear regression analysis, and determine the third sample values ​​using the first reference parameter, the second reference parameter, and the first reference template sample values. and According to the consciousness, third sample values ​​can be obtained.

[0459] In one embodiment of the present disclosure, the image decoding device (2000) can obtain third sample values ​​by using the difference or linearity between the first reference template sample values ​​and the second reference template sample values, respectively, and identify whether the difference between the second sample values ​​and the third sample values ​​is less than or equal to a threshold value.

[0460] In one embodiment of the present disclosure, the image decoding device (2000) may perform a verification process by identifying whether the difference between the second sample values ​​and the third sample values ​​for all samples included in the samples at positions included in the candidate reference block (3030) is less than or equal to a threshold value. The image decoding device (2000) may perform a verification process by identifying whether the difference between the second sample values ​​and the third sample values ​​for some samples included in the samples at positions included in the candidate reference block is less than or equal to a threshold value. For example, the unit at which the verification process is performed may be a 2-sample interval.

[0461] Meanwhile, a threshold value may be predefined between the image decoding device (2000) and the image encoding device. For example, the threshold value may be predefined as N*Template_width for the left templates and N*Template_height for the upper templates. N is an integer greater than or equal to 1, and Template_width and Template_height may represent template sizes. For example, Template_width or Template_height may be 4, but is not limited to the disclosed example. However, the threshold value is not limited to the disclosed example, and may be arbitrarily designated or experimentally determined.

[0462] In one embodiment of the present disclosure, if the difference between the second sample values ​​and the third sample values ​​is less than or equal to a threshold value, the image decoding device (2000) may obtain the first sample values ​​by using the difference or linearity between the first current template sample values ​​and the second current template sample values, and may determine the template cost between the current block (3010) and the candidate reference block (3030) by using the difference between the first sample values ​​and the second sample values.

[0463] In one embodiment of the present disclosure, if the difference between the second sample values ​​and the third sample values ​​exceeds a threshold, the image decoding device (2000) may determine a template cost between the current block (3010) and the candidate reference block (3030) using one of the cost functions of SAD, SATD, SSE, MR-SAD, MR-SSE, and HoG.

[0464] In one embodiment of the present disclosure, the image decoding device (2000) may determine the template cost for the candidate reference block as a specific value for not determining the candidate reference block as a reference block among a plurality of candidate reference blocks based on the identification result of whether the difference between the second sample values ​​and the third sample values ​​is less than or equal to a threshold value. For example, if the difference between the second sample values ​​and the third sample values ​​exceeds the threshold value, the image decoding device (2000) may determine the template cost for the candidate reference block (3030) as the maximum template cost value among a pre-configured template cost list for the plurality of candidate reference blocks.

[0465] Figure 31 is a flowchart of an image decoding method according to one embodiment.

[0466] In step S3110, the image decoding device (2000) can obtain first sample values ​​corresponding to positions of samples within the current block based on at least one of the template of the current block, the candidate reference block, and the template of the candidate reference block.

[0467] In one embodiment of the present disclosure, the image decoding device (2000) can obtain first sample values ​​corresponding to positions of samples within the current block based on the template of the current block, the candidate reference block, and the template of the candidate reference block. The image decoding device (2000) can obtain second sample values ​​of samples within the candidate reference block.

[0468] In one embodiment of the present disclosure, the first sample values ​​may be sample values ​​for samples adjacent to the template of the current block within the current block. The second sample values ​​may be samples adjacent to the template of the candidate reference block within the candidate reference block.

[0469] In one embodiment of the present disclosure, the image decoding device (2000) can obtain first sample values ​​based on at least one of first current template sample values ​​for first current template samples adjacent to the current block among samples included in the template of the current block and second current template sample values ​​for second current template samples adjacent to the first current template samples among samples included in the template of the current block.

[0470] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the first sample values ​​by using the difference between the first current template sample values ​​and the second current template sample values ​​at positions corresponding to the first current template sample values.

[0471] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the first sample values ​​by using linearity for the first current template sample values ​​and the second current template sample values ​​located adjacent to the first current template sample values. The image decoding device (2000) can obtain the first linear parameter and the second linear parameter by performing linear regression analysis on the first current template sample values ​​and the second current template sample values.

[0472] In one embodiment of the present disclosure, the image decoding device (2000) may obtain a first linear parameter and a second linear parameter through linear regression analysis on samples included in a template of a current block and samples included in a template of a candidate reference block. Each of the samples included in the template of the current block and the samples included in the template of the candidate reference block may be any one of: i) first reference template samples adjacent to the candidate reference block among the first current template samples and the samples included in the template of the candidate reference block, ii) second reference template samples adjacent to the first reference template samples among the second current template samples and the samples included in the template of the candidate reference block, and iii) the first current template samples and the second current template samples and the first reference template samples and the second reference template samples.

[0473] In one embodiment of the present disclosure, the image decoding device (2000) can obtain first sample values ​​using a first linear parameter, a second linear parameter, and first current template sample values.

[0474] In one embodiment of the present disclosure, the image decoding device (2000) may determine the first sample values ​​to have the same values ​​as the second sample values ​​of the samples within the candidate reference block. The first sample values ​​may be determined to have the same values ​​as the second sample values ​​of the samples within the candidate reference block corresponding to the positions of the samples within the current block.

[0475] In one embodiment of the present disclosure, the image decoding device (2000) may obtain first sample values ​​based on intra prediction information for blocks surrounding the current block. For example, if the image decoding device (2000) identifies blocks surrounding the current block as having been reconstructed through intra prediction, the device may obtain first sample values ​​corresponding to the positions of samples within the current block using the intra prediction mode of the blocks surrounding the current block.

[0476] Meanwhile, since the operation of obtaining the first sample values ​​has been described in detail in FIGS. 20 to 30, the same description is omitted.

[0477] In step S3120, the image decoding device (2000) can determine a template cost based on the first sample values ​​and the second sample values ​​of the samples in the candidate reference block.

[0478] In one embodiment of the present disclosure, the image decoding device (2000) may use SAD (Sum of Absolute Difference), SATD (Sum of Absolute Transformed Difference), SSE (Sum of Squared Error), MR-SAD (Mean Removed SAD), MR-SSE (Mean Removed SSE), and HoG (Histogram of Oriented Gradient) as cost functions for determining template cost in the process of performing template matching between a current block and a candidate reference block.

[0479] In one embodiment of the present disclosure, the image decoding device (2000) can determine a template cost using the above cost function between the first sample values ​​and the second sample values.

[0480] In one embodiment of the present disclosure, the image decoding device (2000) can determine a template cost by using the difference between each of the first sample values ​​and the second sample values ​​at positions corresponding to the first sample values.

[0481] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the difference between the first current template sample values ​​of the first current template samples and the first sample values, respectively, and the image decoding device (2000) can obtain the difference between the first reference template sample values ​​of the first reference template samples and the second sample values, respectively.

[0482] In one embodiment of the present disclosure, the image decoding device (2000) can calculate a template cost between a current block and a candidate reference block based on a difference between the first current template sample values ​​of the first current template samples and the first sample values, respectively, and a difference between the first reference template sample values ​​of the first reference template samples and the second sample values, respectively.

[0483] In one embodiment of the present disclosure, the image decoding device (2000) can calculate a template cost between a current block and a candidate reference block based on applying a first weight to a difference between the first current template sample values ​​of the first current template samples and the first sample values, and applying a second weight to a difference between the first reference template sample values ​​of the first reference template samples and the second sample values, respectively.

[0484] In one embodiment of the present disclosure, the image decoding device (2000) can determine the template cost without considering the K least significant bits (LSBs). K may be 2, but is not limited to the disclosed example. A method of considering the least significant bits can be used to increase the compression speed.

[0485] Meanwhile, since the operation of determining the template cost has been described in detail in FIGS. 20 to 30, the same description is omitted.

[0486] In step S3130, the image decoding device (2000) can determine a reference block from among a plurality of candidate reference blocks including the candidate reference block based on the template cost.

[0487] In one embodiment of the present disclosure, the image decoding device (2000) repeatedly performs a process of finding a template similar to the template of the current block during the process of performing template matching.

[0488] In one embodiment of the present disclosure, the image decoding device (2000) may obtain first sample values ​​and second sample values ​​corresponding to each of the candidate reference blocks by using a current block, candidate reference blocks corresponding to a plurality of candidate locations, and templates corresponding to each of the candidate reference blocks. In addition, the image decoding device (2000) may calculate template costs corresponding to each of the candidate reference blocks.

[0489] In one embodiment of the present disclosure, the video decoding device (2000) may construct a template cost list according to template costs of candidate reference blocks. The video decoding device (2000) may sort the template cost list in ascending order according to templates, and may determine a candidate reference block corresponding to the lowest template cost among a plurality of candidate reference blocks as a reference block.

[0490] In one embodiment of the present disclosure, the image decoding device (2000) can obtain an index for a template cost list and determine a candidate reference block corresponding to a predetermined template cost in the template cost list indicated by the index for the template cost list as a reference block.

[0491] Meanwhile, in one embodiment of the present disclosure, template costs corresponding to a plurality of candidate reference blocks included in the template cost list may be determined in different ways for each candidate reference block. For example, the first template cost may be determined through SAD, and the second template cost may be determined through MR-SAD. Additionally, the third template cost may be determined according to Equation 5 of the present disclosure, and the fourth template cost may be determined according to Equation 6 of the present disclosure. Meanwhile, the template costs may be determined in various ways, not limited to the disclosed examples.

[0492] In step S3140, the image decoding device (2000) can obtain a prediction block of the current block using a reference block.

[0493] In one embodiment of the present disclosure, the image decoding device (2000) can determine a reference block within a current image including the current block or within an image different from the current image through steps S3110 to S3130.

[0494] In one embodiment of the present disclosure, the image decoding device (2000) can determine or obtain a predicted block by performing prediction on a current block using a reference block. The prediction on the current block may be inter-prediction or intra-prediction, but is not limited to the disclosed example.

[0495] Meanwhile, in one embodiment of the present disclosure, in step S3110, before the step of obtaining the first sample values, the image decoding device (2000) may determine whether to use the template cost calculation method according to mathematical equations 5 to 7 of the present disclosure after performing verification on the template of the candidate reference block and the sample values ​​for the candidate reference block. The image decoding device (2000) may determine whether to perform the steps of step S3110 to step S3140 after performing verification on the template of the candidate reference block and the sample values ​​for the candidate reference block.

[0496] In one embodiment of the present disclosure, the image decoding device (2000) can obtain third sample values ​​by using the difference between the second reference template sample values ​​and the first reference template sample values ​​at positions corresponding to the second reference template sample values.

[0497] In one embodiment of the present disclosure, the image decoding device (2000) can obtain third sample values ​​by using linearity for the first reference template sample values ​​and the second reference template sample values ​​located adjacent to the first reference template sample values. The image decoding device (2000) can obtain the first reference parameter and the second reference parameter through linear regression analysis for the first reference template sample values ​​and the second reference template sample values.

[0498] In one embodiment of the present disclosure, the image decoding device (2000) can obtain third sample values ​​by using the difference or linearity between the first reference template sample values ​​and the second reference template sample values, respectively, and identify whether the difference between the second sample values ​​and the third sample values ​​is less than or equal to a threshold value.

[0499] In one embodiment of the present disclosure, the image decoding device (2000) may determine the template cost for a candidate reference block as a specific value so as not to determine the candidate reference block as a reference block among a plurality of candidate reference blocks, based on the identification result of whether the difference between the second sample values ​​and the third sample values ​​is less than or equal to a threshold value.

[0500] Meanwhile, the operations of steps S3110 to S3140 can be used in any situation as long as it is a process of determining or calculating a template cost, regardless of intra prediction or inter prediction.

[0501] 본 개시의 일 실시예에서, 템플릿 코스트를 결정 또는 계산하는 동작은, TM-AMVP(Template Matching based Advanced Motion Vector Prediction mode), TM-MRG(Template Matching based Merge mode), GPM-TM(Geometric Partitioning Mode using Template Matching), OBMC-TM(Overlapped Block Motion Compensation mode using Template Matching), CIIP-TM(Combined Inter-Intra Prediction mode using Template Matching), Reordering for TMVP(Temporal Motion Vector Prediction) and non-adjacent MVP (Motion Vector Prediction), TM-MMVD(TM based Merge mode with Motion Vector Difference), GPM(Geometric Partitioning Mode) split mode reordering, ARMC(Adaptive Reordering of Merge Candidate), Refined motion for ARMC(Adaptive Reordering of Merge Candidate), Diversity criterion for ARMC(Adaptive Reordering of Merge Candidate), Reference picture reordering, MVD(Motion Vector Difference) prediction, Sub-block TM(Template Matching), TMRL(Template-based Multiple Reference Line), TIMD(Template-based Intra Mode Derivation),and IntraTMP (Intra Template Matching Prediction) can be performed in at least one of the disclosed examples.

[0502] In one embodiment of the present disclosure, the template cost may be determined to perform correction or adjustment on a motion vector or a block vector, and may also be determined to perform re-ordering on a given list.

[0503] Meanwhile, the operation of determining or calculating the template cost may differ in the way the search pattern and template cost are used for each mode.

[0504] Fig. 32 is a block diagram illustrating a configuration of an image encoding device according to one embodiment.

[0505] In one embodiment of the present disclosure, the memory (3210) and the processor (3230) may be implemented as at least one memory and at least one processor. In one embodiment of the present disclosure, when instructions are stored in the memory (3210), the operations of the prediction encoding unit (1915) and the entropy encoding unit (1925) illustrated in FIG. 19 may be implemented according to instructions called by at least one process.

[0506] In one embodiment of the present disclosure, the video encoding device (3200) may include a storage medium that stores input / output data of at least one of the prediction encoding unit (1915) and the entropy encoding unit (1925) illustrated in FIG. 19. The storage medium may be included in the memory (3210) or may be a different storage medium separate from the memory (3210).

[0507] Additionally, the image encoding device (3200) may include a storage medium control unit that controls data input / output of the storage medium. The storage medium control unit may be included in the processor (3230), or may be a control unit different from the processor (3230).

[0508] In one embodiment of the present disclosure, the image encoding device (3200) can determine a prediction mode of a current block within a current image. The prediction mode of the current block can include an inter mode. The inter mode is a mode that predicts or reconstructs the current block based on a reference image to reduce temporal redundancy between images. The current block can be a maximum coding unit, coding unit, transformation unit, or prediction unit split from a current image to be encoded.

[0509] In one embodiment of the present disclosure, the prediction mode of the current block may be determined as an intra mode. The image encoding device (3200) may perform intra prediction on the current block according to the prediction mode of the current block, and may encode the current block using a prediction block generated as a result of performing the intra prediction.

[0510] In one embodiment of the present disclosure, the prediction mode of the current block may be determined as an inter mode. The image encoding device (3200) may perform inter prediction on the current block according to the prediction mode of the current block, and may encode the current block using the prediction block generated as a result of performing the inter prediction. The bitstream may include information regarding the prediction mode of the current block.

[0511] In one embodiment of the present disclosure, the image decoding device (2000) may obtain information about the intra prediction mode of the current block from the bitstream when the prediction mode of the current block is the intra mode. The information about the intra prediction mode of the current block may include information indicating a method for determining the intra prediction mode.

[0512] In one embodiment of the present disclosure, a method for determining an intra prediction mode may include a method for determining an intra prediction mode using a reference block, a method for determining an intra prediction mode using a template, or a method for determining an intra prediction mode using information obtained from a bitstream.

[0513] In one embodiment of the present disclosure, information indicating a method for determining an intra prediction mode may be included in a sequence parameter set, a picture parameter set, a slice header, or slice data of a bitstream.

[0514] In one embodiment of the present disclosure, information indicating a method for determining an intra prediction mode may not be included in the bitstream. In this case, the image encoding device (3200) may determine the intra prediction mode of the current block according to a method predetermined between the image encoding device (2000).

[0515] In one embodiment of the present disclosure, if the method of determining the intra prediction mode is a method of using information stored in the bitstream, the video encoding device (3200) may determine an intra prediction mode indicated by the information stored in the bitstream among a plurality of intra prediction modes as the intra prediction mode of the current block. For example, information indicating the intra prediction mode of the current block among the information stored in the bitstream may include a flag or index indicating any one of the plurality of intra prediction modes.

[0516] In one embodiment of the present disclosure, when the method of determining the intra prediction mode is a method of using a reference block or a template, the image encoding device (3200) may determine the intra prediction mode of the current block by using a reference block in the current image that was restored before the current block or a template of the reference block in the current image.

[0517] In one embodiment of the present disclosure, when encoding a current block based on a reference image, the image encoding device (3200) may use one reference image (e.g., unidirectional prediction) or two reference images (e.g., bidirectional prediction). Whether the current block is unidirectionally predicted or bidirectionally predicted may be determined based on a flag or index indicating which reference picture list among a plurality of reference picture lists in the bitstream is to be used.

[0518] In one embodiment of the present disclosure, the video encoding device (3200) may determine an index indicating a reference picture list indicating which reference picture list among a plurality of reference picture lists is to be used for prediction of the current block. For example, the video encoding device (3200) may determine an index indicating a reference picture list including a reference picture used for prediction of the current block among the plurality of reference picture lists. When encoding the current block through pair prediction, the video encoding device (3200) may determine an index indicating that two reference picture lists are to be used.

[0519] In one embodiment of the present disclosure, the bitstream may include information about a reference picture list indicating which reference picture list among a plurality of reference picture lists is to be used for prediction of the current block. The information about the reference picture list may include an index indicating a reference picture list among the plurality of reference picture lists that includes a reference image used for prediction of the current block.

[0520] In one embodiment of the present disclosure, the video encoding device (3200) may identify or determine prediction information used to determine a reference block of the current block when the current block is inter-predicted. The prediction information of the current block may be included in a bitstream. The prediction information of the current block may include at least one of information about a prediction mode of the current block in the current image, information about a reference picture list (for example, information about an index indicating whether a first reference picture list (L0), a second reference picture list (L1), or a pair of predictions (L0 and L1) are used for inter-prediction of the current block), information about a reference image index, information about a motion vector predictor, and information about a motion vector difference, and may include all information for determining a motion vector of the current block without being limited to the disclosed examples.

[0521] In one embodiment of the present disclosure, the video encoding device (3200) can encode the current block by determining a predetermined candidate block from a candidate block list consisting of candidate blocks of previously encoded blocks adjacent to the current block, previously encoded blocks not adjacent to the current block, blocks included in a collocated image, or neighboring blocks of the collocated image, and obtaining or determining a motion vector of the predetermined candidate block as a motion vector predictor of the current block. The video encoding device (3200) can determine or obtain an index indicating a candidate block for determining a motion vector of the current block and store the index in a bitstream.

[0522] For example, the video encoding device (3200) can determine a reference block in the reference image of the current block when the current block is inter-predicted. For example, the video encoding device (3200) can determine the reference block of the current block by performing template matching based on the point indicated by the motion vector of the determined current block. The video encoding device may determine to perform template matching by comparing before and after performing template matching by performing a rate-distortion cost operation, and may obtain an index indicating that template matching is performed; however, without being limited to the disclosed example, it may be preset to perform or not perform template matching in a certain area regardless of the index indicating that template matching is performed.

[0523] In one embodiment of the present disclosure, the video encoding device (3200) can determine a reference block of the current block by adjusting or correcting an initial motion vector of the current block by comparing the current template with a template within a predetermined area including the block pointed to by the determined motion vector. Meanwhile, a motion vector before being adjusted by template matching may be referred to as an initial motion vector. In the process in which the video encoding device (3200) performs template matching, an operation of determining a template cost according to the present disclosure may be used. Meanwhile, in template matching, surrounding sample values ​​encoded before the current block may be used as templates.

[0524] In one embodiment of the present disclosure, the prediction information may be included in a sequence parameter set, a picture parameter set, a slice header, or slice data of a bitstream.

[0525] In one embodiment of the present disclosure, encoding of a current block may refer to a process of generating information that enables an image decoding device (2000) to restore the current block. The information generated through encoding may be included in a bitstream after undergoing additional processing.

[0526] In one embodiment of the present disclosure, when a prediction block is generated through inter prediction or intra prediction for the current block, the image encoding device (3200) can encode the current block using the prediction block.

[0527] In one embodiment of the present disclosure, the video encoding device (3200) may generate residual data corresponding to the difference between the predicted block and the current block. If the predicted block is determined to be the current block, residual data may not be generated.

[0528] In one embodiment of the present disclosure, an image encoding device (3200) may generate a bitstream including information generated according to image encoding. The bitstream may include data generated as a result of encoding the current block. The bitstream may include prediction information for the current block.

[0529] In one embodiment of the present disclosure, the image encoding device (3200) can transmit a bitstream to the image decoding device (2000) via a network.

[0530] In one embodiment of the present disclosure, the image encoding device (3200) can store a bitstream in a data storage medium including a magnetic medium such as a hard disk, a floppy disk, and a magnetic tape, an optical recording medium such as a CD-ROM and a DVD, a magneto-optical medium such as a floptical disk, and the like.

[0531] In one embodiment of the present disclosure, an image encoding device (3200) may generate a bitstream including syntax elements generated through encoding of an image. Values ​​corresponding to the syntax elements may be included in the bitstream according to the hierarchical structure of the image.

[0532] In one embodiment of the present disclosure, a video encoding device (3200) may encode bins of syntax elements and include them in a bitstream. The encoding operation may include at least one of binarization and entropy encoding operations.

[0533] In one embodiment of the present disclosure, the video encoding device (3200) may search for and determine the template most similar to the current template within a predetermined range centered on a point indicated by a block vector of the current block or a point indicated by a motion vector of the current block. The video encoding device (3200) may also search for and determine the template most similar to the current template within a predetermined range based on the current block. The process of searching for the most similar template may be performed while determining the template cost of the template within the search range, which is a predetermined range, and the template of the current block, and the candidate reference block with the lowest template cost may be determined as the reference block.

[0534] In one embodiment of the present disclosure, information on whether to perform template matching with a current block or information related to template matching performed on the current block may be included in a sequence parameter set, a picture parameter set, a slice header, or slice data of a bitstream. However, this is not limited to the disclosed example, and information on whether to perform template matching and information related to template matching performed on the current block may not be included in the bitstream. Meanwhile, information related to template matching performed on the current block may include information on a method for determining a template cost, etc.

[0535] In one embodiment of the present disclosure, the bitstream may include an index or flag indicating a template cost for any one of the candidate reference blocks in the template cost list. The video encoding device (3200) may perform a rate-distortion cost (RD cost) calculation on the candidate reference blocks in the template cost list to determine an index or flag indicating a template cost for an optimal candidate reference block.

[0536] In one embodiment of the present disclosure, the video encoding device (3200) can obtain a reference block through an index indicating information about a given candidate reference block in a template cost list.

[0537] In one embodiment of the present disclosure, the video encoding device (3200) can reconstruct a current block using a reference block. For example, the video encoding device (3200) can generate a prediction block using the reference block, and reconstruct or generate a current block using the prediction block and residual data.

[0538] In one embodiment of the present disclosure, the operation of the image encoding device (3200) may be the same as the operation of the image decoding device (2000), and therefore, the same content is omitted.

[0539] Figure 33 is a flowchart of an image encoding method according to one embodiment.

[0540] In step S3310, the image encoding device (3200) can obtain first sample values ​​corresponding to positions of samples within the current block based on at least one of the template of the current block, the candidate reference block, and the template of the candidate reference block.

[0541] In one embodiment of the present disclosure, the video encoding device (3200) can obtain first sample values ​​corresponding to positions of samples within the current block based on the template of the current block, the candidate reference block, and the template of the candidate reference block. The video encoding device (3200) can obtain second sample values ​​of samples within the candidate reference block.

[0542] In one embodiment of the present disclosure, the first sample values ​​may be sample values ​​for samples adjacent to the template of the current block within the current block. The second sample values ​​may be samples adjacent to the template of the candidate reference block within the candidate reference block.

[0543] In one embodiment of the present disclosure, the video encoding device (3200) may obtain first sample values ​​based on at least one of first current template sample values ​​for first current template samples adjacent to the current block among samples included in the template of the current block and second current template sample values ​​for second current template samples adjacent to the first current template samples among samples included in the template of the current block.

[0544] In one embodiment of the present disclosure, the video encoding device (3200) can obtain the first sample values ​​by using the difference between the first current template sample values ​​and the second current template sample values ​​at positions corresponding to the first current template sample values.

[0545] In one embodiment of the present disclosure, the image encoding device (3200) can obtain the first sample values ​​by using linearity for the first current template sample values ​​and the second current template sample values ​​located adjacent to the first current template sample values. The image encoding device (3200) can obtain the first linear parameter and the second linear parameter by performing linear regression analysis on the first current template sample values ​​and the second current template sample values.

[0546] In one embodiment of the present disclosure, the video encoding device (3200) may obtain a first linear parameter and a second linear parameter through linear regression analysis on samples included in a template of a current block and samples included in a candidate reference block. Each of the samples included in the template of the current block and the samples included in the candidate reference block may be any one of: i) first reference template samples adjacent to the candidate reference block among the first current template samples and the samples included in the template of the candidate reference block, ii) second reference template samples adjacent to the first reference template samples among the second current template samples and the samples included in the template of the candidate reference block, and iii) the first current template samples and the second current template samples and the first reference template samples and the second reference template samples.

[0547] In one embodiment of the present disclosure, the image encoding device (3200) can obtain first sample values ​​using the first linear parameter, the second linear parameter, and the first current template sample values.

[0548] In one embodiment of the present disclosure, the video encoding device (3200) may determine the first sample values ​​to have the same values ​​as the second sample values ​​of the samples within the candidate reference block. The first sample values ​​may be determined to have the same values ​​as the second sample values ​​of the samples within the candidate reference block corresponding to the positions of the samples within the current block.

[0549] In one embodiment of the present disclosure, the video encoding device (3200) may obtain first sample values ​​based on intra prediction information for blocks surrounding the current block. For example, if the video encoding device (3200) identifies blocks surrounding the current block as having been reconstructed through intra prediction, the video encoding device (3200) may obtain first sample values ​​corresponding to the positions of samples within the current block using the intra prediction mode of the corresponding blocks surrounding the current block.

[0550] Meanwhile, since the operation of obtaining the first sample values ​​has been described in detail in FIGS. 20 to 30, the same description is omitted.

[0551] In step S3320, the image encoding device (3200) can determine a template cost based on the first sample values ​​and the second sample values ​​of the samples in the candidate reference block.

[0552] In one embodiment of the present disclosure, the video encoding device (3200) may use SAD (Sum of Absolute Difference), SATD (Sum of Absolute Transformed Difference), SSE (Sum of Squared Error), MR-SAD (Mean Removed SAD), MR-SSE (Mean Removed SSE), and HoG (Histogram of Oriented Gradient) as cost functions for determining template cost in the process of performing template matching between a current block and a candidate reference block.

[0553] In one embodiment of the present disclosure, the image encoding device (3200) can determine a template cost using the above cost function between the first sample values ​​and the second sample values.

[0554] In one embodiment of the present disclosure, the image encoding device (3200) can determine the template cost by using the difference between each of the first sample values ​​and the second sample values ​​at positions corresponding to the first sample values.

[0555] In one embodiment of the present disclosure, the video encoding device (3200) can obtain the difference between the first current template sample values ​​of the first current template samples and the first sample values, respectively, and the video encoding device (3200) can obtain the difference between the first reference template sample values ​​of the first reference template samples and the second sample values, respectively.

[0556] In one embodiment of the present disclosure, the video encoding device (3200) can calculate a template cost between a current block and a candidate reference block based on a difference between the first current template sample values ​​of the first current template samples and the first sample values, respectively, and a difference between the first reference template sample values ​​of the first reference template samples and the second sample values, respectively.

[0557] In one embodiment of the present disclosure, the video encoding device (3200) can calculate a template cost between a current block and a candidate reference block based on applying a first weight to a difference between the first current template sample values ​​of the first current template samples and the first sample values, and applying a second weight to a difference between the first reference template sample values ​​of the first reference template samples and the second sample values, respectively.

[0558] In one embodiment of the present disclosure, the video encoding device (3200) can determine the template cost without considering the K least significant bits (LSBs). K may be 2, but is not limited to the disclosed example. A method that considers the least significant bits can be used to increase the compression speed.

[0559] Meanwhile, since the operation of determining the template cost has been described in detail in FIGS. 20 to 30, the same description is omitted.

[0560] In step S3330, the image encoding device (3200) can determine a reference block from among a plurality of candidate reference blocks including the candidate reference block based on the template cost.

[0561] In one embodiment of the present disclosure, the image encoding device (3200) repeatedly performs a process of finding a template similar to the template of the current block during the process of performing template matching.

[0562] In one embodiment of the present disclosure, the video encoding device (3200) may obtain first sample values ​​and second sample values ​​corresponding to each of the candidate reference blocks by using a current block, candidate reference blocks corresponding to a plurality of candidate positions, and templates corresponding to each of the candidate reference blocks. In addition, the video encoding device (3200) may calculate template costs corresponding to each of the candidate reference blocks.

[0563] In one embodiment of the present disclosure, the video encoding device (3200) may construct a template cost list according to template costs of candidate reference blocks. The video encoding device (3200) may sort the template cost list in ascending order according to templates, and may determine a candidate reference block corresponding to the lowest template cost among a plurality of candidate reference blocks as a reference block.

[0564] In one embodiment of the present disclosure, the video encoding device (3200) can determine an index for a candidate reference block to be used as a reference block for a current block from among the template cost list, and can obtain a bitstream including the determined index. In addition, the video encoding device (3200) can determine a candidate reference block corresponding to a predetermined template cost within the template cost list indicated by the index for the template cost list as the reference block.

[0565] Meanwhile, in one embodiment of the present disclosure, template costs corresponding to a plurality of candidate reference blocks included in the template cost list may be determined in different ways for each candidate reference block. For example, the first template cost may be determined through SAD, and the second template cost may be determined through MR-SAD. Additionally, the third template cost may be determined according to Equation 5 of the present disclosure, and the fourth template cost may be determined according to Equation 6 of the present disclosure. Meanwhile, the template costs may be determined in various ways, not limited to the disclosed examples.

[0566] In step S3340, the image encoding device (3200) can obtain a prediction block of the current block using a reference block.

[0567] In one embodiment of the present disclosure, the image encoding device (3200) can determine a reference block within a current image including the current block or within an image different from the current image through steps S3310 to S3330.

[0568] In one embodiment of the present disclosure, the video encoding device (3200) may determine or obtain a predicted block by performing prediction on a current block using a reference block. The prediction on the current block may be inter-prediction or intra-prediction, but is not limited to the disclosed example.

[0569] Meanwhile, in one embodiment of the present disclosure, in step S3310, before the step of obtaining the first sample values, the video encoding device (3200) may determine whether to use the template cost calculation method according to mathematical equations 5 to 7 of the present disclosure after performing verification on the template of the candidate reference block and the sample values ​​for the candidate reference block. The video encoding device (3200) may determine whether to perform the steps of step S3310 to step S3340 after performing verification on the template of the candidate reference block and the sample values ​​for the candidate reference block.

[0570] In one embodiment of the present disclosure, the image encoding device (3200) can obtain third sample values ​​by using the difference between the second reference template sample values ​​and the first reference template sample values ​​at positions corresponding to the second reference template sample values.

[0571] In one embodiment of the present disclosure, the video encoding device (3200) can obtain third sample values ​​by using linearity for the first reference template sample values ​​and the second reference template sample values ​​located adjacent to the first reference template sample values. The video encoding device (3200) can obtain the first reference parameter and the second reference parameter through linear regression analysis for the first reference template sample values ​​and the second reference template sample values.

[0572] In one embodiment of the present disclosure, the image encoding device (3200) can obtain third sample values ​​by using the difference or linearity between the first reference template sample values ​​and the second reference template sample values, respectively, and identify whether the difference between the second sample values ​​and the third sample values ​​is less than or equal to a threshold value.

[0573] In one embodiment of the present disclosure, the image encoding device (3200) may determine the template cost for a candidate reference block as a specific value so as not to determine the candidate reference block as a reference block among a plurality of candidate reference blocks based on the identification result of whether the difference between the second sample values ​​and the third sample values ​​is less than or equal to a threshold value.

[0574] Meanwhile, the operations of steps S3310 to S3340 can be used in any situation as long as it is a process of calculating template cost, regardless of intra prediction or inter prediction.

[0575] 본 개시의 일 실시예에서, 템플릿 코스트를 계산하는 동작은, TM-AMVP(Template Matching based Advanced Motion Vector Prediction mode), TM-MRG(Template Matching based Merge mode), GPM-TM(Geometric Partitioning Mode using Template Matching), OBMC-TM(Overlapped Block Motion Compensation mode using Template Matching), CIIP-TM(Combined Inter-Intra Prediction mode using Template Matching), Reordering for TMVP(Temporal Motion Vector Prediction) and non-adjacent MVP (Motion Vector Prediction), TM-MMVD(TM based Merge mode with Motion Vector Difference), GPM(Geometric Partitioning Mode) split mode reordering, ARMC(Adaptive Reordering of Merge Candidate), Refined motion for ARMC(Adaptive Reordering of Merge Candidate), Diversity criterion for ARMC(Adaptive Reordering of Merge Candidate), Reference picture reordering, MVD(Motion Vector Difference) prediction, Sub-block TM(Template Matching), TMRL(Template-based Multiple Reference Line), TIMD(Template-based Intra Mode Derivation),and IntraTMP (Intra Template Matching Prediction) can be performed in at least one of the disclosed examples.

[0576] In one embodiment of the present disclosure, a video decoding method is provided. The video decoding method may include a step of obtaining first sample values ​​corresponding to positions of samples within a current block based on at least one of a template of a current block, a candidate reference block, and a template of the candidate reference block. The video decoding method may include a step of determining a template cost based on the first sample values ​​and second sample values ​​of samples within the candidate reference block. The video decoding method may include a step of determining a reference block from among a plurality of candidate reference blocks including the candidate reference block based on the template cost. The video decoding method may include a step of obtaining a prediction block of the current block using the reference block.

[0577] In one embodiment of the present disclosure, the first sample values ​​may be sample values ​​for samples adjacent to the template of the current block within the current block. The second sample values ​​may be sample values ​​for samples adjacent to the template of the candidate reference block within the candidate reference block.

[0578] In one embodiment of the present disclosure, the image decoding method may include a step of determining a template cost using a difference between first sample values ​​and second sample values ​​at positions corresponding to the first sample values.

[0579] In one embodiment of the present disclosure, a method for decoding an image may include a step of obtaining first sample values ​​based on at least one of first current template sample values ​​for first current template samples adjacent to a current block among samples included in a template of a current block and second current template sample values ​​for second current template samples adjacent to the first current template samples among samples included in the template of the current block.

[0580] In one embodiment of the present disclosure, the image decoding method may include a step of obtaining first sample values ​​by using a difference between first current template sample values ​​and second current template sample values ​​at positions corresponding to the first current template sample values.

[0581] In one embodiment of the present disclosure, an image decoding method may include a step of obtaining a first linear parameter and a second linear parameter through linear regression analysis on first current template sample values ​​and second current template sample values. The image decoding method may include a step of obtaining first sample values ​​using the first linear parameter, the second linear parameter, and the first current template sample values.

[0582] In one embodiment of the present disclosure, a method for decoding an image may include a step of obtaining a first linear parameter and a second linear parameter through a linear regression analysis on samples included in a template of a current block and samples included in a template of a candidate reference block. Each of the samples included in the template of the current block and the samples included in the candidate reference block may be any one of: first reference template samples adjacent to the candidate reference block among the first current template samples and the samples included in the template of the candidate reference block; second reference template samples adjacent to the first reference template samples among the second current template samples and the samples included in the template of the candidate reference block; and first current template samples and second current template samples and first reference template samples and second reference template samples.

[0583] In one embodiment of the present disclosure, the image decoding method may further include a step of obtaining third sample values ​​corresponding to positions of samples within the candidate reference block by using a difference between first reference template sample values ​​for first reference template samples adjacent to the candidate reference block among samples included in the template of the candidate reference block and second reference template sample values ​​for second reference template samples adjacent to the first reference template samples among samples included in the template of the candidate reference block. The image decoding method may include a step of identifying whether a difference between the second sample values ​​and the third sample values ​​at positions corresponding to the second sample values ​​is less than or equal to a threshold value.

[0584] In one embodiment of the present disclosure, a method for decoding an image may include a step of obtaining a first reference parameter and a second reference parameter through a linear regression analysis on first reference template samples adjacent to the candidate reference block among samples included in a template of a candidate reference block and second reference template samples adjacent to the first reference template samples among samples included in the template of the candidate reference block. The method for decoding an image may include a step of obtaining third sample values ​​corresponding to positions of samples within the candidate reference block using the first reference parameter, the second reference parameter, and the first reference template samples. The method for decoding an image may include a step of identifying whether a difference between the second sample values ​​and the third sample values ​​at positions corresponding to the second sample values ​​is less than or equal to a threshold value.

[0585] In one embodiment of the present disclosure, the image decoding method may include a step of determining, based on the identification result, a template cost for a candidate reference block as a specific value so as not to determine the candidate reference block as a reference block among a plurality of candidate reference blocks.

[0586] In one embodiment of the present disclosure, a video decoding method may include a step of obtaining a difference between first current template sample values ​​and first sample values ​​for first current template samples adjacent to the current block among samples included in a template of the current block, and a difference between first reference template sample values ​​and second sample values ​​for first reference template samples adjacent to the candidate reference block among samples included in a template of the candidate reference block.

[0587] In one embodiment of the present disclosure, the first sample values ​​may have the same value as the second sample values ​​of the samples in the candidate reference block corresponding to the positions of the samples in the current block corresponding to the first sample values.

[0588] In one embodiment of the present disclosure, the first sample values ​​can be obtained based on intra prediction information for surrounding blocks of the current block.

[0589] In one embodiment of the present disclosure, an image decoding device may be provided, including at least one memory storing at least one instruction; and at least one processor operating according to the at least one instruction. The at least one processor may obtain first sample values ​​corresponding to positions of samples in a current block based on at least one of a template of a current block, a candidate reference block, and a template of the candidate reference block. The at least one processor may determine a template cost based on the first sample values ​​and second sample values ​​of samples in the candidate reference block. The at least one processor may determine a reference block from among a plurality of candidate reference blocks including the candidate reference block based on the template cost. The at least one processor may obtain a prediction block of the current block using the reference block.

[0590] In one embodiment of the present disclosure, a video encoding method may be provided. The video encoding method may include a step of obtaining first sample values ​​corresponding to positions of samples within a current block based on at least one of a template of a current block, a candidate reference block, and a template of the candidate reference block. The video encoding method may include a step of determining a template cost based on the firs...

Claims

1. In the video decryption method, A step (S3110) of obtaining first sample values ​​corresponding to positions of samples within the current block based on at least one of a template of the current block, a candidate reference block, and a template of the candidate reference block; A step (S3120) of determining a template cost based on the first sample values ​​and the second sample values ​​of the samples in the candidate reference block; and A step (S3130) of determining a reference block among a plurality of candidate reference blocks including the candidate reference block based on the template cost; A method comprising: a step (S3140) of obtaining a prediction block of the current block using the reference block.

2. In paragraph 1, The above first sample values ​​are sample values ​​for samples adjacent to the template of the current block within the current block, The above second sample values ​​are sample values ​​for samples adjacent to the template of the candidate reference block within the candidate reference block, 3. In paragraphs 1 and 2, The step of determining the template cost based on the first sample values ​​and the second sample values ​​of the samples in the candidate reference block is as follows: A method comprising: a step of determining a template cost by using the difference between the first sample values ​​and the second sample values ​​at positions corresponding to the first sample values.

4. In any one of paragraphs 1 to 3, The step of obtaining first sample values ​​corresponding to the positions of samples within the current block is: A method comprising the step of obtaining the first sample values ​​based on at least one of first current template sample values ​​for first current template samples adjacent to the current block among samples included in the template of the current block and second current template sample values ​​for second current template samples adjacent to the first current template samples among samples included in the template of the current block.

5. In paragraph 4, The step of obtaining the above first sample values ​​is: A method comprising the step of obtaining the first sample values ​​by using the difference between the first current template sample values ​​and the second current template sample values ​​at positions corresponding to the first current template sample values.

6. In paragraph 4, The step of obtaining the above first sample values ​​is: A step of obtaining a first linear parameter and a second linear parameter through linear regression analysis on the first current template sample values ​​and the second current template sample values; and A method comprising: obtaining the first sample values ​​using the first linear parameter, the second linear parameter, and the first current template sample values; 7. In paragraph 4, The step of obtaining the above first sample values ​​is: A step of obtaining a first linear parameter and a second linear parameter through linear regression analysis on samples included in the template of the current block and samples included in the template of the candidate reference block, Each of the samples included in the template of the current block and the samples included in the candidate reference block, Among the first current template samples and the samples included in the template of the candidate reference block, the first reference template samples adjacent to the candidate reference block, Second reference template samples adjacent to the first reference template samples among the samples included in the template of the second current template samples and the candidate reference block, and A method, wherein any one of the first current template samples, the second current template samples, the first reference template samples, and the second reference template samples.

8. In paragraph 5, A step of obtaining third sample values ​​corresponding to the positions of samples within the candidate reference block by using the difference between first reference template sample values ​​for first reference template samples adjacent to the candidate reference block among the samples included in the template of the candidate reference block and second reference template sample values ​​for second reference template samples adjacent to the first reference template samples among the samples included in the template of the candidate reference block; and A method further comprising: a step of identifying whether the difference between the second sample values ​​and the third sample values ​​at positions corresponding to the second sample values ​​is less than or equal to a threshold value.

9. In paragraph 6, A step of obtaining a first reference parameter and a second reference parameter through linear regression analysis on first reference template samples adjacent to the candidate reference block among the samples included in the template of the candidate reference block and second reference template samples adjacent to the first reference template samples among the samples included in the template of the candidate reference block; and A step of obtaining third sample values ​​corresponding to the positions of samples within the candidate reference block using the first reference parameter, the second reference parameter, and the first reference template samples; and A method further comprising: a step of identifying whether the difference between the second sample values ​​and the third sample values ​​at positions corresponding to the second sample values ​​is less than or equal to a threshold value.

10. In any one of paragraphs 8 to 9, The step of determining the above template cost is: A method comprising: a step of determining a template cost for the candidate reference block as a specific value so as not to determine the candidate reference block as the reference block among the plurality of candidate reference blocks based on the identification result; 11. In any one of paragraphs 1 and 2, The step of determining the above template cost is: A method comprising: obtaining a difference between first current template sample values ​​and each of the first sample values ​​for first current template samples adjacent to the current block among samples included in the template of the current block, and a difference between first reference template sample values ​​and each of the second sample values ​​for first reference template samples adjacent to the candidate reference block among samples included in the template of the candidate reference block.

12. In paragraph 11, The above first sample values ​​are, A method in which the second sample values ​​of the samples in the candidate reference block corresponding to the positions of the samples in the current block corresponding to the first sample values ​​have the same value as the second sample values.

13. In any one of paragraphs 11 to 12, The above first sample values ​​are, A method obtained based on intra prediction information for surrounding blocks of the current block.

14. In the video encoding method, A step (S3310) of obtaining first sample values ​​corresponding to positions of samples within the current block based on at least one of a template of the current block, a candidate reference block, and a template of the candidate reference block; A step (S3320) of determining a template cost based on the first sample values ​​and the second sample values ​​of the samples in the candidate reference block; and A step (S3330) of determining a reference block among a plurality of candidate reference blocks including the candidate reference block based on the template cost; A method comprising: a step (S3340) of obtaining a prediction block of the current block using the reference block.

15. A computer-readable recording medium storing a bitstream generated according to an image encoding method performed by an image encoding device, wherein the image encoding method comprises: A step (S3310) of obtaining first sample values ​​corresponding to positions of samples within the current block based on at least one of a template of the current block, a candidate reference block, and a template of the candidate reference block; A step (S3320) of determining a template cost based on the first sample values ​​and the second sample values ​​of the samples in the candidate reference block; and A step (S3330) of determining a reference block among a plurality of candidate reference blocks including the candidate reference block based on the template cost; A method comprising: a step (S3340) of obtaining a prediction block of the current block using the reference block.

Citation Information

Patent Citations

  • Wearable apparatus and electronic apparatus providing feedback to user

    KR1020240095102A

  • Apparatus for increasing Grid - Connected Distributed Generation and Operation method thereof

    KR1020250146053A

  • Remote assistance apparatus using augmented reality

    KR102312015B1

  • Conveyor Controller based on Non PLC

    KR102508543B1

  • Composition for improving prostate containing rosavin

    KR102768059B1