Image encoding method, encoding device, decoding method and decoding device

The blending template-based approach for predicting image samples addresses inefficiencies in existing methods by enhancing prediction accuracy and reducing artifacts, leading to improved image compression efficiency.

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

Patent Information

Application Number
PCT/KR2025/095437
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-11-04
Filing Date
2025-06-18
Publication Date
2026-01-08

AI Technical Summary

Technical Problem

Existing image encoding and decoding methods struggle with inefficiencies in predicting and compressing images due to inadequate handling of temporal and spatial redundancies, leading to suboptimal compression and potential artifacts.

Method used

The implementation of a blending template-based approach for obtaining prediction blocks and weights, allowing for improved prediction samples by combining multiple prediction blocks and templates, which enhances the prediction accuracy and reduces artifacts.

Benefits of technology

This method improves the efficiency of image compression by effectively reducing redundancies and minimizing artifacts, resulting in better image quality and compression performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure KR2025095437_08012026_PF_FP_ABST
    Figure KR2025095437_08012026_PF_FP_ABST
Patent Text Reader

Abstract

Provided are an image decoding method, an image decoding device, an image encoding method, and an image encoding device, the image decoding method comprising the steps of: acquiring a first prediction block and a second prediction block for the current block; acquiring a blending template on the basis of a first template of the first prediction block, a second template of the second prediction block and the current template of the current block; acquiring a plurality of weights corresponding to a plurality of samples of the current block on the basis of the blending template; and acquiring a prediction sample of the current block on the basis of the plurality of weights, the first prediction block and the second prediction block.
Need to check novelty before this filing date? Find Prior Art

Description

Image encoding method, encoding device, decoding method and decoding device

[0001] The present disclosure relates to the field of image encoding and decoding. More specifically, it relates to an encoding and decoding method and device for predicting image samples.

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

[0003] 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.

[0004] Intra prediction is a technique for compressing images by removing spatial redundancy within the image. Intra prediction generates a predicted block based on the surrounding pixels of the current block, depending on the prediction mode. The predicted block is then subtracted from the current block to create a residual block.

[0005] The residual block generated through inter-prediction or intra-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. The decoder can filter the reconstructed current block to remove artifacts within it.

[0006] In one embodiment of the present disclosure, a video decoding method is provided. The video decoding method may include a step of obtaining a first prediction block and a second prediction block for a current block. The video decoding method may include a step of obtaining a blending template based on a first template of the first prediction block, a second template of the second prediction block, and a current template of the current block. The video decoding method may include a step of obtaining a plurality of weights corresponding to a plurality of samples of the current block based on the blending template. The video decoding method may include a step of obtaining a prediction sample of the current block based on the plurality of weights, the first prediction block, and the second prediction block.

[0007] In one embodiment of the present disclosure, an image decoding device is provided. The image decoding device may include at least one processor including a processing circuit and a memory including one or more storage media storing instructions. The instructions may be individually or collectively executed by the at least one processor, thereby enabling the image decoding device to obtain a first prediction block and a second prediction block for a current block. The instructions may be individually or collectively executed by the at least one processor, thereby enabling the image decoding device to obtain a blending template based on a first template of the first prediction block, a second template of the second prediction block, and a current template of the current block. The instructions may be individually or collectively executed by the at least one processor, thereby enabling the image decoding device to obtain a plurality of weights corresponding to a plurality of samples of the current block based on the blending template. The instructions may be individually or collectively executed by the at least one processor, thereby enabling the image decoding device to obtain a prediction sample of the current block based on the plurality of weights, the first prediction block, and the second prediction block.

[0008] In one embodiment of the present disclosure, a video encoding method is provided. The video encoding method may include a step of obtaining a first prediction block and a second prediction block for a current block. The video encoding method may include a step of obtaining a blending template based on a first template of the first prediction block, a second template of the second prediction block, and a current template of the current block. The video encoding method may include a step of obtaining a plurality of weights corresponding to a plurality of samples of the current block based on the blending template. The video encoding method may include a step of obtaining a prediction sample of the current block based on the plurality of weights, the first prediction block, and the second prediction block.

[0009] In one embodiment of the present disclosure, a computer-readable recording medium for storing a bitstream generated by an image encoding method is provided. The image encoding method for generating the bitstream may include a step of obtaining a first prediction block and a second prediction block for a current block. The image encoding method for generating the bitstream may include a step of obtaining a blending template based on a first template of the first prediction block, a second template of the second prediction block, and a current template of the current block. The image encoding method for generating the bitstream may include a step of obtaining a plurality of weights corresponding to a plurality of samples of the current block based on the blending template. The image encoding method for generating the bitstream may include a step of obtaining a prediction sample of the current block based on the plurality of weights, the first prediction block, and the second prediction block.

[0010] FIG. 1 is a block diagram of an image decoding device according to one embodiment of the present disclosure.

[0011] FIG. 2 is a block diagram of an image encoding device according to one embodiment of the present disclosure.

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

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

[0014] 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 of the present disclosure.

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

[0016] 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 of the present disclosure.

[0017] 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 of the present disclosure.

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

[0019] FIG. 10 illustrates that the shapes into which a second encoding unit of a non-square shape determined by splitting a first encoding unit is split are limited when a predetermined condition is satisfied, according to one embodiment of the present disclosure.

[0020] 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 of the present disclosure.

[0021] FIG. 12 illustrates that the processing order between a plurality of encoding units may vary depending on the process of splitting the encoding units according to one embodiment of the present disclosure.

[0022] 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 of the present disclosure.

[0023] 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 of the present disclosure.

[0024] 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 of the present disclosure.

[0025] 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 of the present disclosure.

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

[0027] 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 of the present disclosure.

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

[0029] FIG. 20 is a block diagram showing the configuration of an image decoding device according to one embodiment of the present disclosure.

[0030] FIG. 21a is a diagram illustrating a geometric segmentation mode according to one embodiment of the present disclosure.

[0031] FIG. 21b is a diagram showing weights of a geometric segmentation mode according to one embodiment of the present disclosure.

[0032] FIG. 21c is a drawing showing a division direction and division position according to one embodiment of the present disclosure.

[0033] FIG. 22 is a flowchart illustrating an image decoding method according to one embodiment of the present disclosure.

[0034] FIG. 23 is a diagram illustrating a process of obtaining a blending template according to one embodiment of the present disclosure and performing prediction for a current block based on the blending template.

[0035] FIG. 24 is a diagram illustrating a process for obtaining a blending template according to one embodiment of the present disclosure.

[0036] FIG. 25 is a diagram illustrating a process of obtaining weights based on a blending template according to one embodiment of the present disclosure.

[0037] FIG. 26 is a diagram illustrating a process of obtaining weights based on a blending template according to one embodiment of the present disclosure.

[0038] FIG. 27 is a diagram illustrating a process of obtaining weights based on a blending template and a predetermined matrix according to one embodiment of the present disclosure.

[0039] FIG. 28 is a flowchart of a method for obtaining weights based on a blending template and direction information according to one embodiment of the present disclosure.

[0040] FIG. 29 is a diagram illustrating a process for obtaining direction information according to one embodiment of the present disclosure.

[0041] FIG. 30 is a diagram illustrating a process of obtaining direction information using template-based intra-mode derivation (TIMD) according to one embodiment of the present disclosure.

[0042] FIG. 31 is a diagram illustrating a process of obtaining direction information using decoder-side intra mode derivation (DIMD) according to one embodiment of the present disclosure.

[0043] FIG. 32a is a diagram illustrating a method for obtaining prediction samples for a current block when the size of the reference image is the same as the size of the current image.

[0044] FIG. 32b is a diagram illustrating a method for obtaining prediction samples for a current block when the size of a reference image is larger than the size of a current image.

[0045] Figure 33 is a diagram for explaining a method for obtaining prediction samples when the size of the reference image and the size of the current image are different.

[0046] FIG. 34 is a drawing for explaining a template of a current block according to one embodiment of the present disclosure.

[0047] FIG. 35 is a block diagram showing the configuration of an image encoding device according to one embodiment of the present disclosure.

[0048] FIG. 36 is a flowchart illustrating an image encoding method according to one embodiment of the present disclosure.

[0049] 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.

[0050] In the present disclosure, the expression "a, b and / or c" can be replaced with "at least one of a, b or c." That is, the expression "a, b and / or c" can refer to "a," "b," "c," "a and b," "a and c," "b and c," "all of a, b and c," or variations thereof.

[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] The terms used in this disclosure are selected from widely used, common terms, taking into account the functions of the disclosure. However, these terms may vary depending on the intentions of those skilled in the art, precedents, the emergence of new technologies, etc. Furthermore, in certain cases, terms may be arbitrarily selected by the applicant, and in such cases, their meanings can be understood through the relevant description. Therefore, the terms used in this disclosure should not be defined simply as names of terms, but rather based on the meanings of the terms and the overall content of the disclosure.

[0053] In this disclosure, singular expressions may include plural expressions unless the context clearly dictates otherwise. In describing embodiments, detailed descriptions of related known technologies will 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 serve as identifiers to distinguish one component from another.

[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] When a part in this disclosure is said to "include" a certain component, this does not mean that other components are excluded, but rather that other components may be included, unless otherwise specifically stated. Components expressed as "unit" or "module" in this disclosure may be two or more components combined into one component, or one 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 performed exclusively by other components.

[0056] The expression "configured to" as used herein can be used interchangeably with, for example, "suitable for", "having the capacity to", "designed to", "adapted to", "made to", or "capable of", depending on the context. The term "configured to" does not necessarily mean something is "specifically designed to" in terms of hardware. Alternatively, in some contexts, the expression "a system configured to" can include that the system is "capable of" in conjunction with other devices or components. For example, the phrase "a processor configured to perform A, B, and C" can include a dedicated processor for performing the operations (e.g., an embedded processor), or a general-purpose processor (e.g., a CPU or an application processor) that can perform the operations by executing one or more software programs stored in a memory.

[0057] At least one processor according to embodiments of the present disclosure may include various processing circuits and / or multiple processors. For example, the term "processor" as used herein, including in the claims, may include various processing circuits including at least one processor, one or more of which are configured to individually and / or collectively perform the various functions described herein in a distributed manner. As used herein, when "processor," "at least one processor," and "one or more processors" are described as being configured to perform various functions, these terms may include, for example, without limitation, a single processor performing some of the recited functions, other processor(s) performing other of the recited functions, and still other situations where a single processor can perform all of the recited functions. Additionally, the at least one processor may include a combination of processors that perform the various functions enumerated / disclosed, for example, in a distributed manner. The at least one processor may execute program instructions to achieve or perform the various functions.

[0058] In the present disclosure, an 'image' may include a picture, a still image, a frame, a moving image composed of a plurality of consecutive still images, or a video.

[0059] In the present disclosure, a "sample" may include data assigned to a sampling location in an image and may include data to be processed. For example, a sample may include pixels within a frame in a spatial domain. A block may refer to a unit including multiple samples.

[0060] 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 an embodiment of the present disclosure, and an image decoding method and device are disclosed.

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

[0062] 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.

[0063] 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.

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

[0065] 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.

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

[0067] 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.

[0068] 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.

[0069] 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 samples of the picture and the image.

[0070] A single maximum coding block (CTB) may be partitioned into MxN coding blocks containing MxN samples (where M and N are integers). In one embodiment, a coding block may be referred to as a coding unit.

[0071] 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 the 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 the 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 samples of the picture and the image.

[0072] 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.

[0073] 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.

[0074] 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.

[0075] For example, information about the maximum size of a luma coding block that can be 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 that can be split into two. Therefore, by combining the information about the maximum size of a luma coding block that can be 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.

[0076] 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. Alternatively, the maximum size of the 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.

[0077] 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.

[0078] 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.

[0079] 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.

[0080] 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.

[0081] 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.

[0082] 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), when the current encoding unit is split into ternary horizontal split (SPLIT_TT_HOR), when the current encoding unit is split into binaries in the vertical direction can be determined as binary vertical split (SPLIT_BT_VER), and when the current encoding unit is split into ternary vertical split (SPLIT_TT_VER).

[0083] 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.

[0084] 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.

[0085] 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 transform blocks for transformation may be determined from the coding unit. The transform blocks may be equal to or smaller than the coding unit. The transform blocks may be referred to as transform units.

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

[0087] 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.

[0088] 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.

[0089] The above-described embodiment describes operations related to an image decoding method performed by an image decoding device (100). Hereinafter, the operations of an image encoding device (200) that performs an image encoding method corresponding to the reverse process of the image decoding method will be described through one embodiment of the present disclosure.

[0090] 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 of the present disclosure.

[0091] 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.

[0092] 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 a syntax element based on a context model. In one embodiment of the present disclosure, the image encoding device (100) can generate a bitstream according to an image encoding method to be described below. The image encoding device (100) can store the bitstream in a computer-readable storage medium.

[0093] In one embodiment of the present disclosure, the image encoding device (200) can transmit a bitstream to the image decoding device (100). For example, the image encoding device (200) can transmit a bitstream generated by a image encoding method.

[0094] According to one embodiment of the present disclosure, 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.

[0095] According to one embodiment of the present disclosure, 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.

[0096] According to one embodiment of the present disclosure, the encoder (220) can 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) can generate a bitstream including split shape mode information indicating that the encoding unit is not split. In addition, the encoder (220) can split the encoding unit into a plurality of encoding units, and the bitstream generation unit (210) can generate a bitstream including split shape mode information indicating that the encoding unit is split into a plurality of encoding units.

[0097] According to one embodiment of the present disclosure, information indicating the number of coding units to be split into or the direction in which the coding unit is 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.

[0098] 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.

[0099] 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.

[0100] 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.

[0101] 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.

[0102] 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.

[0103] 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 of the present disclosure.

[0104] 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.

[0105] 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.

[0106] 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.

[0107] According to one embodiment of the present disclosure, 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.

[0108] 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 segmentation shape mode information agreed upon in advance based on the block shape information. The image decoding device (100) can determine the segmentation shape mode information agreed upon in advance 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 segmentation shape mode information agreed upon in advance 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.

[0109] According to one embodiment of the present disclosure, 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.

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

[0111] 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 of the present disclosure.

[0112] According to one embodiment of the present disclosure, an image decoding device (100) may utilize block shape information indicating that a current encoding unit is non-square in shape. The image decoding device (100) may determine whether to not split a non-square current 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. A predetermined splitting method by which a non-square encoding unit is split will be described in detail below through an embodiment of the present disclosure.

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

[0114] According to one embodiment of the present disclosure, 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.

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

[0116] According to one embodiment of the present disclosure, 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 length of the width is longer than the length of the height, so the block shape information may be in the horizontal direction. When the ratio of the width and height is 1:4, the length of the width is shorter than the length of the height, so the block shape information may be in the vertical direction. 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).

[0117] According to one embodiment of the present disclosure, 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.

[0118] According to one embodiment of the present disclosure, 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.

[0119] 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 of the present disclosure.

[0120] According to one embodiment of the present disclosure, 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. If the split shape mode information indicates that the first coding unit (500) is split in the horizontal direction according to one embodiment of the present disclosure, 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 of the present disclosure 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. In the following, the relationship between the first encoding unit, the second encoding unit, and the third encoding unit used can be understood as following the above-described characteristics.

[0121] According to one embodiment of the present disclosure, the image decoding device (100) may determine to split or not split the determined second encoding unit (510) into encoding units based on the splitting shape mode information. Referring to FIG. 5, the image decoding device (100) may split the first encoding unit (500) based on the splitting 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 of the present disclosure, 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.

[0122] Referring to FIG. 5, among the odd number of third coding units (520b, 520c, 520d) into which the non-square second coding unit (510) is split, a predetermined coding unit (e.g., a coding unit located in the middle or a square coding unit) may be split recursively. According to one embodiment of the present disclosure, 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. A method that can be used for recursive division of coding units will be described later through an embodiment of the present disclosure.

[0123] According to one embodiment of the present disclosure, the image decoding device (100) may split each of the third encoding units (520a, 520b, 520c, 520d, etc.) into encoding units based on the splitting shape mode information. In addition, the image decoding device (100) may determine not to split the second encoding unit (510) based on the splitting shape mode information. According to one embodiment of the present disclosure, 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.

[0124] 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).

[0125] According to one embodiment of the present disclosure, 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.

[0126] 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 of the present disclosure.

[0127] 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.

[0128] According to one embodiment of the present disclosure, 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 a description of such methods will be provided later through one embodiment of the present disclosure.

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

[0130] According to one embodiment of the present disclosure, 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 split 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).

[0131] According to one embodiment of the present disclosure, 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 a picture. According to one embodiment of the present disclosure, 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 a 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.

[0132] According to one embodiment of the present disclosure, information indicating the position of the sample (630a) at the upper left of the upper encoding unit (620a) may represent coordinates (xa, ya), information indicating the position of the sample (530b) at the upper left of the middle encoding unit (620b) may represent coordinates (xb, yb), and information indicating the position of the sample (630c) at the upper left of the lower encoding unit (620c) may represent coordinates (xc, yc). The image decoding apparatus (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 positions of the upper left samples (630a, 630b, 630c) may indicate coordinates indicating the absolute positions 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), may 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.

[0133] According to one embodiment of the present disclosure, the image decoding device (100) can 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) can select an encoding unit (620b) having a different size from among the encoding units (620a, 620b, 620c).

[0134] According to one embodiment of the present disclosure, the image decoding device (100) can 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 of the present disclosure, 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 of the present disclosure, 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 of the present disclosure, 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.

[0135] 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).

[0136] According to one embodiment of the present disclosure, the image decoding device (100) may determine the width of the left coding unit (660a) as xe-xd. The image decoding device (100) may determine the height of the left coding unit (660a) as the height of the current coding unit (650). According to one embodiment of the present disclosure, the image decoding device (100) may determine the width of the middle coding unit (660b) as xf-xe. The image decoding device (100) may determine the height of the middle coding unit (660b) as the height of the current coding unit (600). According to one embodiment of the present disclosure, the image decoding device (100) may determine the width or height of the right coding unit (660c) using the width or height of the current coding unit (650) and the widths and heights of the left coding unit (660a) and the middle coding 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.

[0137] 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.

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

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

[0140] According to one embodiment of the present disclosure, 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.

[0141] 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.

[0142] According to one embodiment of the present disclosure, 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 apparatus (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 an embodiment of the present disclosure, 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 this 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.

[0143] According to one embodiment of the present disclosure, 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 of the present disclosure, 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.

[0144] According to one embodiment of the present disclosure, when the image decoding device (100) divides a current encoding unit into a plurality of encoding units, the image decoding device (100) may use the split shape mode information to determine an encoding unit at a predetermined position among the plurality of encoding units. According to one embodiment of the present disclosure, 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 a 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 a 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.

[0145] According to one embodiment of the present disclosure, 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).

[0146] FIG. 7 illustrates the order in which multiple encoding units are processed when an image decoding device (100) determines multiple encoding units by dividing a current encoding unit according to one embodiment of the present disclosure.

[0147] According to one embodiment of the present disclosure, 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).

[0148] 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.

[0149] According to one embodiment of the present disclosure, the image decoding device (100) can recursively split encoding units. Referring to FIG. 7, the image decoding device (100) can split a 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).

[0150] According to one embodiment of the present disclosure, 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.

[0151] According to one embodiment of the present disclosure, the processing order of 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 apparatus (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.

[0152] FIG. 8 illustrates a process of 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 disclosure, by an image decoding device (100).

[0153] According to one embodiment of the present disclosure, the image decoding device (100) may determine that a 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 of the present disclosure, 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).

[0154] According to one embodiment of the present disclosure, the image decoding device (100) can determine whether there is an odd number of split coding units by determining whether the third coding 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 coding units (820a, 820b, 820c, 820d, 820e) by recursively splitting the first coding 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.

[0155] According to one embodiment of the present disclosure, the image decoding device (100) can 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 can 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 one embodiment of the present disclosure, when the image decoding device (100) is divided into an odd number of encoding units, a predetermined restriction may be placed on an encoding unit at a predetermined position among the divided encoding units. Since the contents of such restrictions or predetermined positions, etc. have been described above through one embodiment of the present disclosure, a detailed description thereof will be omitted.

[0156] 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 of the present disclosure.

[0157] According to one embodiment of the present disclosure, the image decoding device (100) can 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 can be split into four coding units having a square shape or can 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 coding units having a non-square shape, the image decoding device (100) can split the first coding unit (900) into a plurality of coding units having a non-square shape. 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.

[0158] According to one embodiment of the present disclosure, 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 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 first encoding unit (900) is split in half according to the boundary of the second encoding unit (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 of the present disclosure, when the image decoding device (100) is divided into an odd number of encoding units, a predetermined restriction may be placed on an encoding unit at a predetermined position among the divided encoding units. Since the contents of such restriction or the predetermined position, etc. have been described above through one embodiment of the present disclosure, a detailed description thereof will be omitted.

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

[0160] 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.

[0161] FIG. 10 illustrates that, according to one embodiment of the present disclosure, 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 dividing a first encoding unit (1000) satisfies a predetermined condition.

[0162] According to one embodiment of the present disclosure, 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 independently split. 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 of the present disclosure, the image decoding device (100) may determine third coding units (1012a, 1012b) by horizontally dividing the left second coding unit (1010a) having a non-square shape determined by vertically dividing the first coding unit (1000). However, when the image decoding device (100) horizontally divides the left second coding unit (1010a), the right second coding unit (1010b) may be restricted from being horizontally divided in the same direction as the direction in which the left second coding 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.

[0163] According to one embodiment of the present disclosure, 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.

[0164] 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 of the present disclosure.

[0165] According to one embodiment of the present disclosure, 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.

[0166] According to one embodiment of the present disclosure, 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.

[0167] 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).

[0168] 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).

[0169] FIG. 12 illustrates that the processing order between a plurality of encoding units may vary depending on the process of splitting the encoding units according to one embodiment of the present disclosure.

[0170] According to one embodiment of the present disclosure, the image decoding device (100) can 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) can 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 can 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.

[0171] According to one embodiment of the present disclosure, 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 of the present disclosure, 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.

[0172] According to one embodiment of the present disclosure, the image decoding device (100) can 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) can 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.

[0173] According to one embodiment of the present disclosure, the image decoding device (100) can 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) can 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.

[0174] 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.

[0175] 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 of the present disclosure.

[0176] According to one embodiment of the present disclosure, 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, the encoding unit with increased depth will be expressed as an encoding unit of a lower depth.

[0177] Referring to FIG. 13, according to one embodiment of the present disclosure, 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.

[0178] According to one embodiment of the present disclosure, 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.

[0179] 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.

[0180] According to one embodiment of the present disclosure, 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.

[0181] According to one embodiment of the present disclosure, 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.

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

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

[0184] According to one embodiment of the present disclosure, the image decoding device (100) can 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 can be split in the vertical direction to determine a first encoding unit (1310) having a size of Nx2N, or can be split in the horizontal direction to determine a first encoding unit (1320) having a size of 2NxN. When the depth is determined based on the length of the longest side of the encoding unit according to one embodiment of the present disclosure, 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 can be the same as the depth of the first encoding unit (1300).

[0185] According to one embodiment of the present disclosure, 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.

[0186] 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 of the present disclosure.

[0187] According to one embodiment of the present disclosure, the image decoding device (100) can 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) can 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).

[0188] According to one embodiment of the present disclosure, 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).

[0189] According to one embodiment of the present disclosure, the image decoding device (100) can horizontally split a first encoding unit (1410) having a height longer than width according to split shape mode information into a plurality of second encoding units (1412a, 1412b, 1414a, 1414b, 1414c). According to one embodiment of the present disclosure, the image decoding device (100) can vertically split a first encoding unit (1420) having a width longer than height according to split shape mode information into a plurality of second encoding units (1422a, 1422b, 1424a, 1424b, 1424c).

[0190] According to one embodiment of the present disclosure, the second coding units (1412a, 1412b, 1414a, 1414b, 1414c. 1422a, 1422b, 1424a, 1424b, 1424c) determined according to the split shape mode information for the first coding unit (1410 or 1420) of a non-square shape may have their depths determined based on the length of their long sides. 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.

[0191] 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).

[0192] According to one embodiment of the present disclosure, when determining an index (PID) for distinguishing 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 split into an odd number of units do not have the same size. Referring to FIG. 14, among the coding units (1414a, 1414b, 1414c) split into an odd number of units, 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 value of the index. According to one embodiment of the present disclosure, 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.

[0193] According to one embodiment of the present disclosure, 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 of the present disclosure, the PID may be obtained from a sample (e.g., an upper left sample) at a predetermined position of each encoding unit.

[0194] According to one embodiment of the present disclosure, the image decoding device (100) can 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 of the present disclosure, 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) can divide the first coding unit (1410) into three coding units (1414a, 1414b, 1414c). The image decoding device (100) can assign an index to each of the three coding units (1414a, 1414b, 1414c). The image decoding device (100) can 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 of the present disclosure, 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 of the present disclosure, 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.

[0195] According to one embodiment of the present disclosure, an image decoding device (100) can use a predetermined data unit from which recursive division of an encoding unit begins.

[0196] 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 of the present disclosure.

[0197] According to one embodiment of the present disclosure, 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.

[0198] According to one embodiment of the present disclosure, a reference data unit may have a predetermined size and shape. According to one embodiment of the present disclosure, 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 have a square or non-square shape, and may be subsequently divided into an integer number of coding units.

[0199] According to one embodiment of the present disclosure, an image decoding device (100) may divide a current picture into a plurality of reference data units. According to one embodiment of the present disclosure, an image decoding device (100) may divide a plurality of reference data units into which a current picture is divided using division shape mode information for each reference data unit. This division process of the reference data units may correspond to a division process using a quad-tree structure.

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

[0201] 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 of the present disclosure, 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.

[0202] According to one embodiment of the present disclosure, 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.

[0203] According to one embodiment of the present disclosure, the image decoding device (100) may use an index for identifying the size and shape of the reference coding unit in order 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.

[0204] According to one embodiment of the present disclosure, the image decoding device (100) may use at least one reference coding unit included in one maximum coding unit (1510). That is, the maximum coding unit (1510) for dividing an image may include at least one reference coding unit, and the coding unit may be determined through a recursive splitting process of each reference coding unit. According to one embodiment of the present disclosure, at least one of the width and the height of the maximum coding unit (1510) 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 of the present disclosure, the size of the reference coding unit may be a size obtained by splitting the maximum coding unit (1510) n times according to a quad tree structure. That is, the image decoding device (100) may determine the reference coding unit by splitting the maximum coding unit (1510) n times according to the quad tree structure, and may split the reference coding unit based on at least one of block shape information and split shape mode information according to one embodiment of the present disclosure.

[0205] According to one embodiment of the present disclosure, the video decoding device (100) can obtain and use block shape information indicating the shape of a current encoding unit or split shape mode information indicating a method of splitting the current encoding unit from a bitstream. The split shape mode information may be included in a bitstream related to various data units. For example, the video decoding device (100) can 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) can 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.

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

[0207] 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.

[0208] 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).

[0209] 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.

[0210] 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.

[0211] 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.

[0212] 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.

[0213] 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.

[0214] 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.

[0215] 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.

[0216] 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 of the present disclosure.

[0217] Referring to FIG. 16, the image decoding device (100) can determine a different combination of partitioning shapes into which encoding units 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 encoding units, a picture (1610) that can be partitioned into two or four encoding units, and a picture (1620) that can be partitioned into two, three, or four encoding 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 encoding units to partition the picture (1600) into a plurality of encoding units. The image decoding device (100) can only use partitioning shape information indicating that the picture (1610) is partitioned into two or four encoding 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.

[0218] According to one embodiment of the present disclosure, 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 by which an encoding unit can be divided for each predetermined data unit using the acquired index, and thus can use different combinations of segmentation types for each predetermined data unit.

[0219] 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 of the present disclosure.

[0220] According to one embodiment of the present disclosure, 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.

[0221] 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.

[0222] According to one embodiment of the present disclosure, 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 of the present disclosure, 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.

[0223] According to one embodiment of the present disclosure, 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 of the present disclosure. 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.

[0224] According to one embodiment of the present disclosure, 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 division form of the non-square-shaped encoding unit indicated by the division form mode information should not be interpreted as being limited to only the three forms illustrated in FIG. 17, but should be interpreted as various forms including the embodiments described above.

[0225] 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 of the present disclosure.

[0226] 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.

[0227] According to one embodiment of the present disclosure, block shape information or segmentation shape mode information can be expressed using binary code, and such information can be directly generated as a bitstream. In addition, block shape information or segmentation shape mode information that can be expressed using binary code may not be directly generated as a bitstream, but may be used as a binary code input in CABAC (context adaptive binary arithmetic coding).

[0228] According to one embodiment of the present disclosure, a video 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 video 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 of the present disclosure, the video 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 video decoding device (100) can repeat the process until a bin string composed of these 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.

[0229] According to one embodiment of the present disclosure, 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 of the present disclosure. 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.

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

[0231] 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 of the present disclosure, when the first bin for the partition shape mode information is 1, the image decoding device (100) can decode the bin by considering that the probability that the second bin is 0 or 1 is the same probability.

[0232] According to one embodiment of the present disclosure, the image decoding device (100) may utilize 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 of the present disclosure, 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 of the present disclosure, 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 of the present disclosure, 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.

[0233] According to one embodiment of the present disclosure, the image decoding device (100) may determine that the bin probability for the partition shape mode information is the same for encoding units of a predetermined size or larger. For example, the bin probability for the partition 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.

[0234] According to one embodiment of the present disclosure, 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).

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

[0236] 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).

[0237] 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 transformed coefficients (or quantized coefficients) of residual data between the prediction data and the current input image. For example, the transform coefficients may be generated using a transform kernel including at least one of a Discrete Cosine Transform (DCT), a Discrete Sine Transform (DST), a Hadamard transform, a Karhunen-Loeve Transform (KLT), or a Wavelet Transform. The residual data may have information compressed by performing the transformation. For example, the residual data may be expressed using a small number of frequencies by performing the transformation. In one embodiment, the transform and quantization unit (1920) may omit transforming the residual data between the prediction data and the current input image. For example, if the distribution of the residual data makes it inefficient to perform transform, the transform process for the residual data may be omitted and the quantization process may be performed. In one embodiment, whether transform is omitted (or whether transform is performed) may be transmitted to the decoding unit (1950) through the bitstream. The entropy encoding unit (1925) encodes and transforms the quantized transform coefficients and outputs them as a bitstream. The quantized transform coefficients may be restored to data in the spatial domain through the inverse quantization and inverse transform unit (1930). The inverse quantization and inverse transform unit (1930) may perform inverse quantization on the quantized transform coefficients and apply a transform kernel to determine the residual data. In one embodiment, the inverse quantization and inverse transform unit (1930) may not perform inverse transform.For example, if transformation on residual data is omitted, the inverse quantization and inverse transformation unit (1930) may not perform inverse transformation. The inverse quantization and inverse transformation unit (1930) may determine residual data by performing inverse quantization on quantized transform coefficients. The data of the restored spatial domain is output as a restored image through the deblocking filtering unit (1935) and the loop filtering unit (1940). The restored image may be used as a reference image for the next input image through the predictive encoding unit (1915).

[0238] 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).

[0239] 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).

[0240] FIG. 20 is a block diagram showing the configuration of an image decoding device according to one embodiment of the present disclosure.

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

[0242] In one embodiment of the present disclosure, the processor (2010) may include processing circuitry and / or multiple processors. For example, the processor (2010) may include various processing circuitry, including at least one processor, wherein one or more of the at least one processor may be configured to individually and / or collectively perform various functions described in the present disclosure in a distributed manner.

[0243] In one embodiment of the present disclosure, the memory (2020) may include one or more storage media storing at least one instruction. The processor (2010) may control the image decoding device (2000) by executing the instructions stored in the memory (2020). For example, the processor (2010) may control the image decoding device (2000) to perform operations by individually or collectively executing the instructions stored in the memory (2020). In one embodiment of the present disclosure, the operations performed by the image decoding device (2000) may be operations performed by the processor (2010) of the image decoding device (2000).

[0244] In one embodiment of the present disclosure, the image decoding device (2000) may correspond to the image decoding device (100) illustrated in FIG. 1 and / or the decoding unit (1950) illustrated in FIG. 19.

[0245] The image decoding device (2000) can obtain a bitstream generated as a result of encoding an image. The bitstream can include an encoding result for a current block. In one embodiment of the present disclosure, the image decoding device (2000) can receive the bitstream from the image encoding device through a network. In one embodiment of the present disclosure, the image decoding device (2000) can obtain the bitstream from a data storage medium including at least one of 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, or a magneto-optical medium such as a floptical disk.

[0246] The video decoding device (2000) can obtain syntax elements for decoding the video from the bitstream. The values ​​corresponding to the syntax elements can be included in the bitstream according to the hierarchical structure of the video. In one embodiment of the present disclosure, the video decoding device (2000) can obtain the syntax elements by entropy decoding the bins included in the bitstream.

[0247] In one embodiment of the present disclosure, a bitstream may include information about a prediction mode of a current block in a current image. The current block may include at least one of a maximum coding unit, an encoding unit, a transformation unit, or a prediction unit segmented from a current image to be decoded. In one embodiment of the present disclosure, the prediction mode of the current block may include at least one of an intra mode, an inter mode, a combined mode, a geometric partitioning mode (GPM), a block copy mode, or a template matching prediction mode.

[0248] In one embodiment of the present disclosure, the intra mode may include a non-directional Planar mode of number 0 (or Intra_Planar mode), a non-directional DC mode of number 1 (or Intra_DC mode), and directional Angular modes of number 2 to 66 (or Intra-directional mode) (e.g., (Intra_Angular2... Intra_Angular66). In one embodiment of the present disclosure, the intra-planar mode may mean a mode that determines a prediction sample based on a weighted average value according to the distance of a left reference sample, an upper reference sample, a lower-left sample, and an upper-right sample of the current block. In one embodiment of the present disclosure, the intra-DC mode may mean a mode that determines an average value of reference samples as a prediction sample. In one embodiment of the present disclosure, in the intra-directional modes, the positions of reference samples for generating prediction samples of samples in the current block may be identified in consideration of the direction indicated by the intra-directional modes. For example, in mode 34, the position of reference samples may be identified at 45 degrees to the upper left with respect to the samples in the current block. Reference samples located in the direction can be identified. In one embodiment of the present disclosure, the intra mode can include Wide-Angular modes (Intra_Wide_Angular) of -14 to -1 and 67 to 80. The Wide-Angular modes can be used to identify reference samples of samples in a non-square current block. In one embodiment of the present disclosure, the image decoding apparatus (2000) can determine one of the Wide-Angular modes as an intra prediction mode of the non-square current block. The image decoding apparatus (2000) can determine the Wide-Angular mode based on the width and height of the current block. If the width of the current block is greater than the height, the image decoding apparatus (2000) can replace the lower-left directional mode with the upper-right extended directional mode.For example, the video decoding device (2000) can replace the index value "predModeIntra" of the intra prediction mode that is greater than or equal to 2 and less than or equal to a predetermined value with "predModeIntra + 65". If the height of the current block is greater than the width, the video decoding device (2000) can replace the upper-right directional mode with the lower-left extended directional mode. For example, the video decoding device (2000) can replace the index value "predModeIntra" of the intra prediction mode that is greater than or equal to a predetermined value and less than or equal to 66 with "predModeIntra - 67". The number and types of intra prediction modes that can be used in the intra mode by the video decoding device (2000) according to an embodiment of the present disclosure can be set in various ways. For example, the image decoding device (2000) can determine the Wide-Angular mode using a predetermined method according to the ratio of the height and width of the block (e.g., 16, 8, 4, 2, 1 / 2, 1 / 4, 1 / 8, or 1 / 16).

[0249] In one embodiment of the present disclosure, the video decoding device (2000) can determine an intra prediction mode using MPM (most probable modes). The video decoding device (2000) can determine whether to use MPM. The video decoding device (2000) can obtain information related to whether to use MPM from a bitstream. When using MPM, the video decoding device (2000) can determine an MPM list. In one embodiment of the present disclosure, the video decoding device (2000) can determine the MPM list using neighboring blocks of the current block. The video decoding device (2000) can determine the MPM list based on the intra mode of the upper block of the current block and the intra mode of the left block. If the neighboring blocks of the current block are not available (for example, if the intra prediction mode of the neighboring blocks is not determined), the intra prediction mode of the unavailable neighboring blocks can be set to a predetermined mode (for example, the Planar mode). The video decoding device (2000) can determine one of the MPM lists as the intra prediction mode of the current block. The video decoding device (2000) can obtain information (e.g., index information) indicating the intra prediction mode of the current block from the MPM list from the bitstream.

[0250] In one embodiment of the present disclosure, the video decoding device (2000) may determine an intra prediction mode using a template. The video decoding device (2000) may determine a template of a current block. The template of the current block may include a left sample, an upper left sample, and / or an upper sample of the current block. The video decoding device (2000) may determine surrounding samples of the template of the current block. The surrounding samples of the template may include a left sample, an upper left sample, and / or an upper sample of the template. The video decoding device (2000) may perform prediction on the template using the surrounding samples of the template as reference samples. In one embodiment of the present disclosure, a process in which the video decoding device (2000) determines an intra prediction mode by performing prediction on the template may be referred to as template-based intra mode derivation (TIMD).

[0251] In one embodiment of the present disclosure, the image decoding device (2000) can infer an intra prediction mode of the current block using surrounding samples of the current block. The image decoding device (2000) can determine a slope using surrounding samples of the current block. The image decoding device (2000) can determine a plurality of 3 x 3 blocks adjacent to the current block. The image decoding device (2000) can obtain horizontal variations and vertical variations of samples included in each of the determined 3 x 3 blocks. The image decoding device (2000) can determine a slope based on the horizontal variations and vertical variations. The image decoding device (2000) can determine the horizontal variations and vertical variations using a Sobel filter. The image decoding device (2000) can determine an intra prediction mode corresponding to the slope. The video decoding device (2000) can determine the intra prediction mode of the current block based on a plurality of intra prediction modes determined for a plurality of 3 x 3 blocks. In one embodiment of the present disclosure, the video decoding device (2000) can determine the intra prediction mode that is determined most frequently as the intra prediction mode of the current block. In one embodiment of the present disclosure, the video decoding device (2000) can determine the amplitude based on horizontal variation and vertical variation. The video decoding device (2000) can determine the intra prediction mode of the current block based on the amplitude. The video decoding device (2000) can determine the weight of the intra prediction mode corresponding to the slope as the amplitude. For example, the video decoding device (2000) can increase the weight of the intra prediction mode determined based on the slope as the horizontal variation and vertical variation increase. The video decoding device (2000) can determine the intra prediction mode of the current block based on a result reflecting a weight determined according to the size.In one embodiment of the present disclosure, the process by which the image decoding device (2000) determines an intra prediction mode based on a slope may be referred to as decoder side intra mode derivation (DIMD).

[0252] In one embodiment of the present disclosure, the block copy mode may include an intra block copy mode. In one embodiment, the block copy mode may include an intra block copy mode. In one embodiment, the intra block copy mode may be a sub-mode of the intra mode, but is not limited thereto, and may represent a mode separate from the intra mode. In one embodiment, the template matching prediction mode may include a template matching intra prediction mode. The combined mode may include a Combined Inter-Intra Prediction (CIIP) mode that performs prediction by combining prediction according to the intra mode and prediction according to the inter mode. The geometric partitioning mode may include a mode that partitions to include directionality within a block. The geometric partitioning mode may perform prediction using inter prediction or intra prediction for each of the divided regions that are blocked.

[0253] The video decoding device (2000) can restore the current block by performing prediction according to the prediction mode for the current block according to the prediction mode of the current block.

[0254] In one embodiment of the present disclosure, the image decoding device (2000) can obtain information regarding the prediction mode of the current block from the bitstream. For example, the image decoding device (2000) can obtain index information indicating the prediction mode of the current block from the bitstream.

[0255] In one embodiment of the present disclosure, when the prediction mode of the current block is the CIIP mode, the video decoding device (2000) can reconstruct the current block by combining inter prediction and intra prediction. For example, the video decoding device (2000) can perform intra prediction according to the planar mode. For example, the video decoding device (2000) can perform inter prediction using a motion vector (MV). The video decoding device (2000) can reconstruct the current block using a weighted sum of a prediction block according to inter prediction and a prediction block according to intra prediction. The weight can be determined based on whether a block adjacent to the current block has been intra predicted.

[0256] In one embodiment of the present disclosure, when the prediction mode of the current block is a geometric segmentation mode, the image decoding device (2000) can perform prediction by segmenting the current block. The image decoding device (2000) can obtain a segmentation angle and a segmentation distance for a boundary at which segmentation is performed within the current block. The image decoding device (2000) can segment the current block based on the segmentation angle and the segmentation distance. The image decoding device (2000) can reconstruct the current block by performing inter prediction or intra prediction on each of the segmented regions within the current block. The image decoding device (2000) can (i) perform intra prediction on both segmented regions, (ii) perform inter prediction on one region and intra prediction on the other region, or (iii) perform inter prediction on both segmented regions.

[0257] In one embodiment of the present disclosure, when the prediction mode of the current block is block copy mode, the image decoding device (2000) can reconstruct the current block based on a reference block included in the current image. In one embodiment of the present disclosure, when the prediction mode of the current block is block copy mode, the image decoding device (2000) can determine information about a block vector (BV) representing the reference block. In one embodiment of the present disclosure, the image decoding device (2000) can determine a prediction block based on the reference block. For example, the image decoding device (2000) can determine a prediction block that is identical to the reference block or by performing filtering on the reference block.

[0258] In one embodiment of the present disclosure, when the prediction mode of the current block is the template matching prediction mode, the image decoding device (2000) can reconstruct the current block using a reference block. The image decoding device (2000) can obtain information related to whether the template matching prediction mode is used. The image decoding device (2000) can determine whether the template matching prediction mode is used based on the obtained information. The reference block can be determined based on at least one of an area included in the current image or an area included in a previously decoded image. In one embodiment of the present disclosure, the image decoding device (2000) can determine the reference block using a cost function. The cost function can include at least one of a sum of absolute difference (SAD), a sum of squared difference (SSD), a sum of absolute transformed difference (SATD), a sum of squared error (SSE), or a mean removed SAD (MR-SAD). For example, the image decoding device (2000) can determine the error between templates using at least one cost function among SAD, SATD, SSE, and MR-SAD. When the cost function is SAD, the image decoding device (2000) can determine the error based on the sum of the absolute values ​​of the differences between each sample of the template of the current block and each sample of the template of the candidate block. When the cost function is SSD, the image decoding device (2000) can determine the error based on the sum of the squares of the differences between each sample of the template of the current block and each sample of the template of the candidate block. The cost function may include a function representing the number of identical samples. The image decoding device (2000) can determine a block with a small error among the candidate blocks as a reference block.The video decoding device (2000) can determine a prediction block by performing template matching intra prediction on the current image. In the present disclosure, the process of determining a reference block for the current block using a template may be referred to as template matching (TM). In the present disclosure, performing prediction on the current block based on template matching may be referred to as template matching prediction (TMP) or intra template matching prediction (Intra Template Matching Prediction).

[0259] In one embodiment of the present disclosure, the image decoding device (2000) can restore (or predict) the current block using a Matrix-based Intra Prediction (MIP) mode.

[0260] The image decoding device (2000) may determine a left downscaled sample and an upper downscaled sample using a left reference sample and an upper reference sample of a current block. In one embodiment of the present disclosure, the image decoding device (2000) may determine an average of the left reference samples as a left downscaled sample, and may determine an average of the upper reference samples as an upper downscaled sample. For example, one left downscaled sample may be determined as an average of a plurality of left reference samples, and one upper downscaled sample may be determined as an average of a plurality of upper reference samples. In one embodiment of the present disclosure, the number of left downscaled samples and the number of upper downscaled samples may be determined based on the size and shape of the current block. The image decoding device (2000) may determine a boundary vector using the left downscaled sample and the upper downscaled sample. In one embodiment of the present disclosure, the boundary vector may mean a one-dimensional vector including both the left downscaled sample and the upper downscaled sample. For example, if the current block is a 4 x 4 block, the number of left reduction samples and the number of upper reduction samples are each 2, and the boundary vector may be a vector including 4 samples. Also, for example, if the current block is not a 4 x 4 block, the boundary vector may be a vector including 8 samples. The image decoding apparatus (2000) may determine at least one of a matrix or an offset vector based on at least one of a width, a height, or an intra prediction mode of the current block. In one embodiment of the present disclosure, the intra prediction mode may be referred to as a matrix index. The image decoding apparatus (2000) may predict some samples of the current block using the matrix, the offset vector, and the boundary vector. The image decoding apparatus (2000) may predict the remaining samples of the current block using the samples predicted using the matrix and the boundary vector, the left reference samples, and the upper reduction samples.In one embodiment of the present disclosure, the image decoding device (2000) can obtain the remaining samples by performing interpolation in the vertical and horizontal directions. The image decoding device (2000) can obtain vertical samples of the prediction sample by performing vertical interpolation on the prediction sample and the upper reduced sample. The image decoding device (2000) can obtain the remaining samples by performing horizontal interpolation using the left reference sample, the prediction sample, and the vertical samples obtained by interpolation.

[0261] The video decoding device (2000) can generate a reconstructed current block using a prediction block. In one embodiment of the present disclosure, the video decoding device (2000) can determine the prediction block as the reconstructed current block. In one embodiment of the present disclosure, the video decoding device (2000) can generate a reconstructed current block by combining the prediction block with residual data obtained from a bitstream by the video decoding device (2000). The reconstructed current block can be used as a reference block for the next block.

[0262] In one embodiment, the image decoding apparatus (2000) can obtain residual data from a bitstream. The residual data can include information about the difference between an original image (or an original sample) and a predicted image (or a predicted sample). In one embodiment, the image decoding apparatus (2000) can obtain a transform coefficient of a residual block corresponding to a transform unit from the bitstream. In one embodiment, the image decoding apparatus (2000) can obtain a residual sample of the residual block based on the transform coefficient of the residual block. For example, the image decoding apparatus (2000) can obtain a residual sample of the residual block by performing at least one of inverse quantization or inverse transformation on the transform coefficient of the residual block. In one embodiment, the image decoding apparatus (2000) can determine a residual sample of the coding unit using at least a portion of a portion of the residual samples of the residual block. The image decoding device (2000) may determine some of the residual samples of the residual block as residual samples of the coding unit when the size of the residual block is larger than the size of the transformation unit. Alternatively, the image decoding device (2000) may determine some of the residual samples of the residual block on which filtering has been performed as residual samples of the coding unit. The image decoding device (2000) may reconstruct the samples of the coding unit based on the residual samples of the coding unit.

[0263] In a prediction mode (e.g., intra mode) that uses reference samples included in a current image, a prediction block of the current block can be generated based on the surrounding samples of the current block according to the prediction mode, assuming that there will be continuity between the surrounding samples of the current block and the samples within the current block. An image decoding apparatus (2000) according to an embodiment of the present disclosure can use not only the surrounding samples of the current block included in the current image but also the spatial reference samples included in the current image for intra prediction. When using samples reconstructed before the current block, the size of residual data can be reduced by predicting the samples of the current block using not only the samples immediately adjacent to the current block but also samples far from the current block. In an embodiment of the present disclosure, the image decoding apparatus (2000) performs intra prediction using a reference block including unreconstructed samples, thereby increasing the range of an area that can be determined as a reference block. An image decoding apparatus (2000) according to an embodiment of the present disclosure can improve compression efficiency by increasing the efficiency of intra prediction.

[0264] In a prediction mode (e.g., inter mode) that utilizes reference samples included in a reference image rather than the current image, a prediction block of the current block can be generated based on a reference block (or reference sample) of the reference image according to the prediction mode, under the assumption that there will be continuity between the current image and the reference image. An image decoding apparatus (2000) according to an embodiment of the present disclosure can improve compression efficiency by increasing the efficiency of intra prediction.

[0265] The image decoding device (2000) can improve prediction accuracy by considering both a reference block (or reference sample) included in the current image and a reference block (or reference sample) included in an image other than the current image. The image decoding device (2000) according to one embodiment of the present disclosure can improve prediction accuracy by considering both the current image and an image other than the current image.

[0266] The video decoding device (2000) can perform deblocking filtering. The deblocking filter can improve video quality by smoothing edges between blocks.

[0267] The video decoding device (2000) can perform filtering on samples of a current block on which deblocking filtering has been performed using a Sample Adaptive Offset (SAO) filter and / or a Bilateral Filter (BIF). The SAO filter and BIF can improve image quality by reducing the error between the restored image and the original image. The SAO filter and BIF can perform filtering on a sample-by-sample basis.

[0268] The image decoding device (2000) can perform filtering using an adaptive loop filter (ALF). ALF can improve image quality by reducing the error between the restored image and the original image. ALF can perform filtering on a block-by-block basis.

[0269] FIG. 21a is a diagram illustrating a geometric segmentation mode according to one embodiment of the present disclosure.

[0270] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction block or a prediction sample of the current block (2110) using a geometric segmentation mode. For example, the image decoding device (2000) can obtain a prediction block or a prediction sample using a weighted sum of a first prediction block (2120) and a second prediction block (2130).

[0271] In one embodiment of the present disclosure, the image decoding device (2000) can divide the current block (2110). For example, the current block (2110) can be divided into a first sub-block (2112) and a second sub-block (2114). For example, the first sub-block (2112) can include features corresponding to the first prediction block (2120), and the second sub-block (2114) can include features corresponding to the second prediction block (2130). In this example, it can be efficient for the prediction of the current block for the first sub-block (2112) to be predicted based on the first prediction block (2120), and for the second sub-block (2114) to be predicted based on the second prediction block (2130).

[0272] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction block or a prediction sample of the current block (2110) using a plurality of predictors. The image decoding device (2000) can obtain a plurality of predictors corresponding to the current block (2110) and obtain a final predictor by applying weights to the plurality of predictors. For example, the image decoding device (2000) can obtain a prediction block or a prediction sample by using weight information corresponding to the first prediction block (2120) and / or the second prediction block (2130). For example, the image decoding device (2000) can obtain a prediction block or a prediction sample by applying weights to the first prediction block (2120) and the second prediction block (2130). Weight information of the current block (2110) according to one embodiment of the present disclosure will be described with reference to FIG. 21B.

[0273] In one embodiment of the present disclosure, the image decoding device (2000) can obtain information for segmenting the current block (2110). For example, the image decoding device (2000) can obtain information corresponding to a segmentation angle and a segmentation distance. Information for segmenting the current block (2110) according to one embodiment of the present disclosure is described with reference to FIG. 21c.

[0274] FIG. 21b is a diagram showing weights of a geometric segmentation mode according to one embodiment of the present disclosure.

[0275] Referring to FIG. 21b, a first weight matrix (2140) and a second weight matrix (2150) including weight information according to one embodiment of the present disclosure are illustrated.

[0276] In one embodiment of the present disclosure, the first weight matrix (2140) and the second weight matrix (2150) may have the same size as the current block. For example, the first weight matrix (2140) and the second weight matrix (2150) may include weight values ​​for predicting each sample of the current block.

[0277] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction sample by applying a first weight matrix (2140) to a first prediction block (2120) and a second weight matrix (2150) to a second prediction block (2130). For example, the image decoding device (2000) can obtain a prediction sample of a current block by applying a weight of the first weight matrix (2140) corresponding to a first prediction sample of the first prediction block (2120) to the first prediction sample and applying a weight of the second weight matrix (2150) corresponding to a second prediction sample of the second prediction block (2130) to the second prediction sample.

[0278] In one embodiment of the present disclosure, a weight for the first prediction block (2120) of the first weight matrix (2140) may be greater than a weight for the second prediction block (2130). For example, the weight for the second prediction block (2130) of the first weight matrix (2140) may be 0. For example, the weight for the second prediction block (2130) of the first weight matrix (2140) may have a smaller value as it moves away from the segmentation boundary. Without being limited to the first weight matrix (2140), a weight for the second prediction block (2130) of the second weight matrix (2150) may be greater than a weight for the first prediction block (2120).

[0279] In one embodiment of the present disclosure, a process in which the image decoding device (2000) obtains prediction samples using a plurality of weight matrices (2140, 2150) has been described, but is not limited thereto. For example, the image decoding device (2000) may obtain a first weight matrix (2140) corresponding to a first prediction block (2120), and may obtain a second weight matrix (2150) corresponding to a second prediction block (2130) using the first weight matrix (2140). For example, the value of the second weight matrix (2150) may be determined such that the sum of the first weight matrix (2140) and the second weight matrix (2150) becomes a predetermined value.

[0280] FIG. 21c is a drawing showing a division direction and division position according to one embodiment of the present disclosure.

[0281] In one embodiment of the present disclosure, the image decoding device (2000) can determine a segmentation boundary based on information for segmenting the current block (2110). For example, the image decoding device (2000) can determine a segmentation boundary based on a segmentation angle and a segmentation distance.

[0282] Referring to Figure 21c, segmentation boundaries are illustrated based on the segmentation angle and segmentation distance. For example, i=0 may indicate vertical segmentation, and one of multiple segmentation boundaries may be selected based on the segmentation distance. The segmentation distance may be determined based on the distance of the segmentation boundary from the center of the current block.

[0283] In one embodiment of the present disclosure, the image decoding device (2000) can obtain index information on a segmentation boundary. The image decoding device (2000) can determine a segmentation angle (e.g., angleIdx) and a segmentation distance (e.g., distanceIdx) based on the index information (e.g., merge_gpm_partition_idx). For example, the segmentation angle and the segmentation distance may be predetermined to correspond to the index information.

[0284] In one embodiment of the present disclosure, when the image decoding device (2000) performs prediction using a geometric segmentation mode, weights may be determined based on segmentation boundaries. In one embodiment of the present disclosure, the geometric segmentation mode described with reference to FIGS. 21A to 21C performs prediction based on segmentation boundaries having a straight line shape. The image decoding device (2000) can increase prediction efficiency by determining weights independently of a segmentation boundary having a predetermined shape. In one embodiment of the present disclosure, a process in which the image decoding device (2000) determines weights for a plurality of prediction blocks and performs prediction using the determined weights is described with reference to FIGS. 22 to 36.

[0285] FIG. 22 is a flowchart illustrating an image decoding method according to one embodiment of the present disclosure.

[0286] In one embodiment of the present disclosure, the image decoding method may be performed by the image decoding device (2000). For example, the image decoding device (2000) may perform each step of the image decoding method by having the processor of the image decoding device (2000) execute at least one instruction contained in a memory.

[0287] In step S2210, the method may include an operation of obtaining a first prediction block and a second prediction block for the current block. For example, the image decoding device (2000) may obtain a plurality of prediction blocks for the current block.

[0288] In one embodiment of the present disclosure, the image decoding device (2000) may perform prediction on a current block using an inter prediction mode. For example, the image decoding device (2000) may obtain a plurality of prediction blocks included in a current image including the current block and a plurality of reference images.

[0289] In one embodiment of the present disclosure, the image decoding device (2000) can perform prediction on a current block using a block copy mode. For example, the image decoding device (2000) can obtain multiple prediction blocks included in the same current image as the current block.

[0290] In one embodiment of the present disclosure, the image decoding device (2000) can perform prediction on the current block using block copy mode and inter prediction mode. For example, the image decoding device (2000) can obtain a prediction block included in a reference image different from the current image including the current block, and a prediction block included in the current image.

[0291] The video decoding device (2000) can obtain a prediction block included in a reference image different from the current image by using a motion vector. For example, the video decoding device (2000) can obtain a prediction sample based on the motion vector. The video decoding device (2000) can determine a pixel position corresponding to the motion vector and obtain a prediction sample based on the pixel position. The video decoding device (2000) can determine a pixel position included in the reference image based on at least one of an upper left sample of the current block, the position of the current sample, or the motion vector. The video decoding device (2000) can obtain a prediction sample based on an integer value and a fractional value of the pixel position. For example, the video decoding device (2000) can obtain a prediction sample by performing interpolation on reference samples around the pixel position by using a filter coefficient corresponding to a fractional value of the pixel position.

[0292] The image decoding device (2000) can obtain a prediction block included in a current image using a block vector. For example, the image decoding device (2000) can obtain a prediction sample based on the block vector. The image decoding device (2000) can determine the position of the prediction block included in the current image or the position of the prediction sample included in the prediction block based on the position of the current sample of the current block and the block vector. The image decoding device (2000) can determine the pixel position of the block vector corresponding to the position of the current sample and obtain a prediction sample around the pixel position. For example, the image decoding device (2000) can obtain a prediction sample corresponding to a pixel position that is an integer value. For example, the image decoding device (2000) can obtain a prediction sample adjacent to the left of the pixel position or a prediction sample adjacent to the right of the pixel position. For example, the image decoding device (2000) can obtain a prediction sample that is closer to the left or right of the pixel position.

[0293] The image decoding device (2000) can obtain a prediction block using the template of the current block. The image decoding device (2000) can obtain a prediction block included in the current image or another image based on the template of the current block. For example, the image decoding device (2000) can obtain a prediction block having a template with a small cost compared to the template of the current block. The image decoding device (2000) can determine a cost between a reconstructed sample included in the template of the current block and a reconstructed sample of the template included in the current image, and determine a block corresponding to the template with a small cost as a prediction block.

[0294] In one embodiment of the present disclosure, a prediction block may include multiple prediction samples. For example, the prediction block may be a matrix including multiple prediction samples. For example, the sizes of the current block and the prediction block may be the same, and the prediction block may include the same number of samples as the current block.

[0295] In step S2220, the method may include an operation of obtaining a blending template based on a first template of a first prediction block, a second template of a second prediction block, and a current template of a current block. For example, the image decoding device (2000) may obtain a blending template based on the templates of each of a plurality of prediction blocks and the current template of the current block.

[0296] In one embodiment of the present disclosure, a template of a block may include samples at predetermined locations adjacent or non-adjacent to the block. For example, the template of a block may include samples adjacent to the top and left of the block. For example, the template of a block may include non-adjacent samples to the top and left of the block. For example, the template of a block may be L-shaped. The template of a block may include a plurality of reconstructed samples. In one embodiment of the present disclosure, the template of a block may include a template of a current block and / or a template of a predicted block.

[0297] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a sample of a blending template based on a sample of a first template, a sample of a second template, and a sample of a current template. In one embodiment of the present disclosure, the size of the blending template may be the same as the size of the current template. In one embodiment of the present disclosure, an example of the image decoding device (2000) obtaining a blending template is described with reference to FIG. 24.

[0298] In step S2230, the method may include an operation of obtaining a plurality of weights corresponding to a plurality of samples of the current block based on a blending template. In one embodiment of the present disclosure, the plurality of weights corresponding to a plurality of samples of the current block may be referred to as a blending map, a blending matrix, weight information, or a weight matrix. For example, the image decoding device (2000) may obtain a blending map based on a blending template.

[0299] In one embodiment of the present disclosure, the image decoding device (2000) may obtain weights for predicting the current block using a prediction block. For example, the image decoding device (2000) may obtain weights corresponding to each sample of the current block. For example, the weights corresponding to each sample of the current block may refer to weights applied to prediction samples to obtain each sample.

[0300] In one embodiment of the present disclosure, the video decoding device (2000) may obtain a weight for one prediction block. For example, the video decoding device (2000) may obtain a weight for a first prediction block based on a blending template. The video decoding device (2000) may obtain a weight for a second prediction block based on the weight for the first prediction block. For example, when the weight for the first prediction block is w, the video decoding device (2000) may determine the weight for the second prediction block as 2k-w. In this example, k may be an integer greater than or equal to 0. In one embodiment of the present disclosure, the sum of the weight for the first prediction block and the weight for the second prediction block may be determined to be a predetermined value. For example, the sum of the weight for the first prediction block and the weight for the second prediction block may be determined to be 2k, and 2k or k may be a predetermined value. In one embodiment of the present disclosure, the determined value may be a value determined based on the size of the current block or may include a predetermined constant.

[0301] In one embodiment of the present disclosure, the image decoding device (2000) can obtain weights for a plurality of prediction blocks. For example, the image decoding device (2000) can obtain weights for a first prediction block and a second prediction block, respectively, based on a blending template.

[0302] In step S2240, the method may include an operation of obtaining a prediction sample of a current block based on a plurality of weights, a first prediction block, and a second prediction block. For example, the image decoding device (2000) may obtain a prediction sample of the current block based on a plurality of prediction blocks and a plurality of weights. For example, the image decoding device (2000) may obtain the current block by applying a weight included in a blending map to a prediction sample of a prediction block.

[0303] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction sample of a current block by applying a plurality of weights to a first prediction block and a second prediction block. For example, the image decoding device (2000) can obtain a first weight for a first prediction sample of a first prediction block corresponding to the current sample, and a second weight for a second prediction sample of a second prediction block corresponding to the current sample. The image decoding device (2000) can obtain a prediction sample of the current block based on a value obtained by multiplying the first prediction sample by the first weight and adding a value obtained by multiplying the second prediction sample by the second weight.

[0304] FIG. 23 is a diagram illustrating a process of obtaining a blending template according to one embodiment of the present disclosure and performing prediction for a current block based on the blending template.

[0305] In one embodiment of the present disclosure, the image decoding device (2000) may obtain a current template (2312) of a current block (2310). In one embodiment of the present disclosure, the image decoding device (2000) may obtain a current template (2312) that includes at least one of an adjacent sample or a non-adjacent sample to the current block (2310). For example, referring to FIG. 23, the current template (2312) may include a reconstructed sample adjacent to the current block (2310). Without being limited thereto, the current template (2312) may include a non-adjacent reconstructed sample to the current block (2310). For example, the current template (2312) may include a reconstructed sample whose distance from the current block (2310) is 2 or more.

[0306] In one embodiment of the present disclosure, the current template (2312) may include a top template (Top templatec) and a left template (Left templatec). The width of the top template may be the same as the width of the current block (2310). The height of the top template may be 1. Without being limited thereto, the width of the top template may be determined as a multiple of the width of the current block (2310), and the height of the top template may be determined as a multiple of 2 or 2. The height of the left template may be the same as the height of the current block (2310). The width of the left template may be 1. Without being limited thereto, the height of the left template may be determined as a multiple of the height of the current block (2310), and the width of the left template may be determined as a multiple of 2 or 2.

[0307] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a plurality of prediction blocks (2320, 2330) for the current block (2310). For example, the image decoding device (2000) can obtain a first prediction block (2320) and a second prediction block (2330). Each of the first prediction block (2320) and the second prediction block (2330) can be included in the current image including the current block (2310) or in at least one of other reference images.

[0308] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a first prediction block (2320) and a second prediction block (2330) based on at least one of a motion vector, a block vector, and a template matching. For convenience of explanation, the first prediction block (2320) is described below as being obtained using a motion vector, a block vector, and a template matching, but the present invention is not limited thereto, and the second prediction block (2330) can also be obtained using one of a motion vector, a block vector, and a template matching.

[0309] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a motion vector for obtaining a prediction sample of the first prediction block (2320). The image decoding device (2000) can obtain the motion vector based on at least one of the upper left position of the current block (2310), the width of the current block (2310), and the height of the current block (2310). The image decoding device (2000) can determine a pixel position corresponding to a current sample of the current block (2310) using the motion vector. The image decoding device (2000) can determine the pixel position based on the position of the upper left sample of the current block (2310), the position of the current sample included in the current block (2310), and the motion vector. The image decoding device (2000) can obtain a first prediction sample included in the first prediction block (2320) corresponding to the current sample based on the pixel position. The image decoding device (2000) can obtain a filter coefficient set based on a pixel position. The filter coefficient set can include a plurality of filter coefficients. The filter coefficient set can be selected from a plurality of predetermined filter coefficient sets based on a fractional value of the pixel position. For example, the image decoding device (2000) can obtain a filter coefficient set corresponding to a fractional value of the pixel position. The image decoding device (2000) can obtain a first prediction sample corresponding to a current sample based on a reference sample and a filter coefficient set around the pixel position. The image decoding device (2000) can obtain a plurality of first prediction samples corresponding to each of a plurality of current samples included in the current block (2310).

[0310] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a block vector for obtaining a prediction sample of the first prediction block (2320). The image decoding device (2000) can obtain the block vector based on at least one of the upper left position of the current block (2310), the width of the current block (2310), and the height of the current block (2310). The first prediction block (2320) can be included in the same image as the current block (2310). The image decoding device (2000) can obtain a first prediction sample included in the first prediction block (2320) corresponding to the current sample of the current block (2310) using the block vector. The image decoding device (2000) can determine the position of the first prediction sample indicated by the block vector based on the position of the current sample. The video decoding device (2000) can obtain a plurality of first prediction samples corresponding to each of a plurality of current samples included in the current block (2310).

[0311] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a first prediction block (2320) based on a current template (2312) of a current block (2310). The image decoding device (2000) can determine a cost between the current template (2312) and a plurality of templates. The image decoding device (2000) can obtain a first template (2322) having the lowest cost. The first block (2320) can include an area determined based on the first template (2322).

[0312] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a blending template (2340). The image decoding device (2000) can obtain the blending template (2340) based on the current template (2312), the first template (2322), and the second template (2332). For example, the image decoding device (2000) can obtain a sample of the blending template (2340) based on a sample of the current template (2312), a sample of the first template (2322), and a sample of the second template (2332).

[0313] In one embodiment of the present disclosure, the size of the blending template (2340) may be the same as that of at least one of the current block (2310), the first prediction block (2320), and the second prediction block (2330). For example, the size of the blending template (2340) may be the same as that of the current block (2310). For example, the size of the blending template (2340) may be the same as that of the first prediction block (2320) and / or the second prediction block (2330).

[0314] In one embodiment of the present disclosure, the video decoding device (2000) can obtain the blending template (2340) based on the difference between the current template (2312) and the first template (2322) or the second template (2332). In one embodiment of the present disclosure, the video decoding device (2000) can obtain the blending template (2340) based on at least one of the sum or difference between the first template (2322) and the second template (2332). In one embodiment of the present disclosure, an exemplary method by which the video decoding device (2000) obtains the blending template (2340) is described with reference to FIG. 24.

[0315] In one embodiment of the present disclosure, the image decoding device (2000) may obtain weight information (2350). The weight information (2350) may include a plurality of weights corresponding to a plurality of current samples of the current block (2310). The weights of the weight information (2350) may be applied to a first prediction sample of a first prediction block (2320) and / or a second prediction sample of a second prediction block (2330) to obtain a current sample of the current block (2310). The weight information (2350) may be referred to as a blending map, a weight map, or a weight matrix.

[0316] In one embodiment of the present disclosure, the image decoding device (2000) can obtain weight information (2350) based on the blending template (2340). The image decoding device (2000) can determine a weight based on at least one sample of the blending template (2340). The image decoding device (2000) can obtain the weight of the weight information (2350) according to a predetermined procedure using the samples of the blending template (2340). In one embodiment of the present disclosure, an exemplary method by which the image decoding device (2000) obtains the weight information (2350) based on the blending template (2340) is described with reference to FIGS. 25 to 31.

[0317] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction block for the current block (2310) based on weight information (2350). In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction block for the current block (2310) based on weight information (2350), a first prediction block (2320), and a second prediction block (2330).

[0318] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction block for the current block (2310) by applying the weight of the weight information (2350) to at least one of the first prediction block (2320) and the second prediction block (2330). For example, the image decoding device (2000) can obtain a prediction block for the current block (2310) by applying the weight of the weight information (2350) to at least one of the first sample of the first prediction block (2320) and the second sample of the second prediction block (2330).

[0319] In one embodiment of the present disclosure, the weight information (2350) may include a weight corresponding to the first prediction block (2320) or the second prediction block (2330). The image decoding device (2000) may obtain a first weight corresponding to the first prediction block (2320) or the second prediction block (2330) from the weight information (2350), and obtain a second weight for the remaining prediction blocks based on the first weight. For example, the second weight may be determined as a value obtained by subtracting the first weight from a predetermined value. The image decoding device (2000) may obtain a current sample of the current block (2310) by applying the first weight and the second weight to the prediction sample of the first prediction block (2320) and the prediction sample of the second prediction block (2330).

[0320] In one embodiment of the present disclosure, the weight information (2350) may include a first weight and a second weight corresponding to the first prediction block (2320) and the second prediction block (2330). The image decoding device (2000) may obtain the first weight and the second weight corresponding to the first prediction block (2320) and the second prediction block (2330) from the weight information (2350). The image decoding device (2000) may obtain the current sample of the current block (2310) by applying the first weight and the second weight to the prediction sample of the first prediction block (2320) and the prediction sample of the second prediction block (2330).

[0321] In one embodiment of the present disclosure, the image decoding device (2000) can adaptively apply weights for each sample by obtaining weight information (2350) for predicting each sample of the current block (2310). While the related technology, GPM, is limited to linear boundaries, the image decoding device (2000) according to one embodiment of the present disclosure can improve prediction accuracy in that it can obtain adaptive weights for each sample without being limited to the shape of the boundary of the current block (2310). When the current block and the prediction block are similar, the difference between the templates can also be reduced. The image decoding device (2000) according to one embodiment of the present disclosure can obtain a blending template using the template of the current block and the templates of a plurality of prediction blocks, and determine a weight for each sample of the prediction block based on the blending template. The image decoding device (2000) can improve prediction accuracy for the current block by obtaining weights for each sample of the prediction block by using the blending template.

[0322] FIG. 24 is a diagram illustrating a process for obtaining a blending template according to one embodiment of the present disclosure.

[0323] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a blending template (2442) based on the current template (2412), the first template (2422), and the second template (2432). The image decoding device (2000) can obtain a first prediction block (2420) and a second prediction block (2430) corresponding to the current block (2410).

[0324] The image decoding device (2000) can obtain a current template (2412) corresponding to the current block (2410). The current template (2412) can include at least one of a sample adjacent to the current block (2410) and a non-adjacent sample. For example, the current template (2412) can include samples adjacent to the left boundary and the upper boundary of the current block (2410). For example, the current template (2412) can include samples not adjacent to the left boundary and the upper boundary of the current block (2410). For example, the current template (2412) can include samples adjacent to the left boundary and the upper boundary of the current block (2410) and non-adjacent samples. If the position of the upper left sample of the current block (2410) is (0, 0), the adjacent samples can include a sample located at (-1, y) and a sample located at (x, -1). Non-adjacent samples include samples located at (-a, y) and samples located at (x, -b), where a and b can have values ​​greater than 1.

[0325] In one embodiment of the present disclosure, the image decoding device (2000) can obtain information indicating the type of template. For example, the image decoding device (2000) can obtain a flag indicating whether the current template (2412) is a template adjacent to the current block (2410) from the bitstream. In this example, the image decoding device (2000) can obtain the current template (2412) based on the flag. If the flag indicates that the current template (2412) is not adjacent to the current block (2410), the image decoding device (2000) can obtain a predetermined non-adjacent template as the current template (2412). In addition, for example, the image decoding device (2000) can obtain an index indicating the current template (2412) from the bitstream based on the flag. In this example, the image decoding device (2000) can obtain a current template (2412) corresponding to the index.

[0326] The video decoding device (2000) can obtain a first template (2422) and a second template (2432) corresponding to the first prediction block (2420) and the second prediction block (2430). The video decoding device (2000) can obtain the first template (2422) and the second template (2432) having the same shape as the current block (2410). For example, the upper template of the current block (2410) may have the same size as the upper template of the first template (2422) and the upper template of the second template (2432), and the left template of the current block (2410) may have the same size as the left template of the first template (2422) and the left template of the second template (2432). For example, if the current template (2412) includes non-adjacent samples of the current block (2410), the first template (2422) and the second template (2432) may include non-adjacent samples of the first prediction block (2420) and the second prediction block (2430).

[0327] Referring to FIG. 24, for example, samples with similar brightness may indicate similar values, and samples with a large difference in brightness may indicate a large difference in values. For example, since the brightness of samples located on the upper left side of the current block (2410) is similar to the brightness of samples located on the upper left side of the first prediction block (2420), the values ​​of samples located on the upper left side of the current block (2410) may be understood as being similar to the values ​​of samples located on the upper left side of the first prediction block (2420). For example, since the brightness of samples located on the lower left side of the current block (2410) is different from the brightness of samples located on the lower left side of the first prediction block (2420) and is similar to the brightness of samples located on the lower left side of the second prediction block (2430), the values ​​of samples located on the lower left side of the current block (2410) may be understood as being similar to the values ​​of samples located on the lower left side of the second prediction block (2430). For example, since the brightness of the samples located at the upper right of the current block (2410) is similar to the brightness of the samples located at the upper right of the first prediction block (2420) and the brightness of the samples located at the upper right of the second prediction block (2430), the values ​​of the samples located at the upper right of the current block (2410), the values ​​of the samples located at the upper right of the first prediction block (2420), and the values ​​of the samples located at the upper right of the second prediction block (2430) can all be understood to be similar.

[0328] Since the template of a block is located close to the boundary of the block, if the predicted block and the current block are similar, the template of the predicted block and the template of the current block may also be similar. For example, since the values ​​of the samples located at the upper left of the current block (2410) are similar to the values ​​of the samples located at the upper left of the first predicted block (2420), the upper left of the current template (2412) may have values ​​similar to the upper left of the first template (2422). That is, the values ​​of the left samples of the upper template of the current template (2412) and the left samples of the upper template of the first template (2422) may be similar, and the values ​​of the upper samples of the left template of the current template (2412) and the upper samples of the left template of the first template (2422) may be similar.

[0329] When predicting a sample of a current block (2410), the image decoding device (2000) can increase prediction accuracy by using a more similar sample between the first prediction block (2420) and the second prediction block (2430). However, since the image decoding device (2000) has not yet predicted the sample value of the current block (2410), it cannot use the current block (2410) to determine a block that is more similar to the current block (2410) between the first prediction block (2420) and the second prediction block (2430). The image decoding device (2000) can obtain a sample that is more similar to the current block (2410) between the first prediction block (2420) and the second prediction block (2430) based on the result of comparing the current template (2412), the first template (2422), and the second template (2432). The video decoding device (2000) can increase prediction accuracy by giving greater weight to more similar prediction blocks.

[0330] The video decoding device (2000) can obtain a blending template (2442) based on the current template (2412), the first template (2422), and the second template (2432). The video decoding device (2000) can obtain a blending sample (2444) of the blending template (2442) based on the current sample (2414) of the current template (2412), the first sample (2424) of the first template (2422), and the second sample (2434) of the second template (2432).

[0331] In one embodiment of the present disclosure, the blending sample (2444) may represent a weight or similarity for the first prediction block (2420) and / or the second prediction block (2430). For example, the blending sample (2444) may be assigned a large value if it is similar to the first prediction block (2420), and a small value if it is not similar to the first prediction block (2420). For example, the blending sample (2444) may be assigned a large value if it is similar to the first prediction block (2420), and a small value if it is similar to the second prediction block (2420).

[0332] In one embodiment of the present disclosure, the video decoding device (2000) can obtain the blending template (2442) based on the average of the first template (2422) and the second template (2432). The video decoding device (2000) can obtain the blending template (2442) based on the difference between the average of the current block (2410) and the first template (2422) and the second template (2432). For example, the video decoding device (2000) can obtain the absolute value of the blending template (2442) based on the difference between the average of the current block (2410) and the first template (2422) and the second template (2432). The video decoding device (2000) can obtain the blending template (2442) based on the difference between the first template (2422) and the second template (2432). For example, the video decoding device (2000) can determine the sign of the blending template (2442) based on the difference between the first template (2422) and the second template (2432). The video decoding device (2000) can obtain the blending template (2442) based on the difference between the average of the current block (2410) and the first template (2422) and the second template (2432) and the difference between the first template (2422) and the second template (2432). For example, the video decoding device (2000) can obtain the blending template (2442) using Equations 1 to 3.

[0333] [Mathematical Formula 1]

[0334] Tavg = (T0 + T1 + 1) >> 1

[0335] [Equation 2]

[0336] Tsign = (T1 - T0) > 0 ? 1:-1

[0337] [Equation 3]

[0338] Tbt = (T - Tavg) * Tsign

[0339] T may represent the current template (2412), T0 may represent the first template (2422), T1 may represent the second template (2432), and Tbt may represent the blending template (2442).

[0340] In one embodiment of the present disclosure, the image decoding device (2000) can obtain weights using a method for predicting samples of the current block (2410). For example, the predicted block of the current block (2410) can be obtained using mathematical expression 4.

[0341] [Equation 4]

[0342] P = P0*(1-W0) + P1*W0

[0343] T may represent the current block (2410) or a sample of the current block (2410), T0 may represent the first prediction block (2420) or a sample of the first prediction block (2420), T1 may represent the second prediction block (2430) or a sample of the second prediction block (2430), and W0 may represent a weight for T0. If mathematical expression 4 is rearranged for the weight W0, it may be expressed as mathematical expression 5.

[0344] [Equation 5]

[0345] W0 = (P - P1) / (P1 - P-0)

[0346] The image decoding device (2000) can obtain a blending template (2442) using mathematical expression 5. For example, the image decoding device (2000) can obtain a blending template (2442) using mathematical expression 6.

[0347] [Equation 6]

[0348] Tbt = (T - T0) / (T1 - T0)

[0349] T may represent the current template (2412), T0 may represent the first template (2422), T1 may represent the second template (2432), and Tbt may represent the blending template (2442).

[0350] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the blending template (2442) based on at least one of the difference between the current block (2410) and the first template (2422) or the second template (2432) and the difference between the first template (2422) and the second template (2432). For example, the image decoding device (2000) can obtain the blending template (2442) based on a value obtained by dividing the difference between the current block (2410) and the first template (2422) or the second template (2432) by the difference between the first template (2422) and the second template (2432).

[0351] In one embodiment of the present disclosure, the video decoding device (2000) can obtain a blending sample (2444) of a blending template (2442). For example, T may represent a current sample (2414) of a current template (2412), T0 may represent a first sample (2424) of a first template (2422), T1 may represent a second sample (2434) of a second template (2432), and Tbt may represent a blending sample (2444) of the blending template (2442). The video decoding device (2000) can obtain a blending template (2442) including a plurality of blending samples (2444) by obtaining a plurality of blending samples (2444).

[0352] In one embodiment of the present disclosure, the video decoding device (2000) can modify the value of the blending template (2442). For example, the video decoding device (2000) can add an offset value to the blending template (2442). For example, the video decoding device (2000) can obtain the modified blending template (2442) by applying an upper or lower limit of the blending template (2442). In one embodiment of the present disclosure, the video decoding device (2000) can apply the upper or lower limit using a clipping function.

[0353] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a blending sample (2444) based on the value of the first sample (2424) and the value of the second sample (2434) being the same. The image decoding device (2000) can obtain a blending sample (2444) set to 0.5 based on the value of the first sample (2424) and the value of the second sample (2434) being the same. The image decoding device (2000) can obtain a blending sample (2444) having the same value as a sample adjacent to the blending sample (2444) based on the value of the first sample (2424) and the value of the second sample (2434) being the same.

[0354] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the value of the blending sample (2444) by using the average of a plurality of surrounding samples of the blending sample (2444). For example, the image decoding device (2000) can obtain the value of the blending sample (2444) by using the arithmetic mean, geometric mean, harmonic mean, or root mean square of a plurality of surrounding samples of the blending sample (2444).

[0355] FIG. 25 is a diagram illustrating a process of obtaining weights based on a blending template according to one embodiment of the present disclosure.

[0356] Referring to FIG. 25, a blending map (2500) and a blending template (2505) are illustrated. The blending map (2500) may include a plurality of weights corresponding to a plurality of samples of the current block. The blending map (2500) may correspond to the weight information (2350) of FIG. 23. The distance between the blending map (2500) and the blending template (2505) may be determined based on the current block and the template of the current block. For example, if the current block and the template of the current block are adjacent, the blending map (2500) and the blending template (2505) may also be adjacent, and if the current block and the template of the current block are not adjacent, the blending map (2500) and the blending template (2505) may also be spaced apart by the distance between the current block and the template of the current block.

[0357] The video decoding device (2000) can obtain a weight (2510) corresponding to the current sample based on a plurality of blending samples (2520, 2530) of the blending template (2505). The video decoding device (2000) can obtain the weight (2510) using an average of a first blending sample (2520) and a second blending sample (2530). The first blending sample (2520) can be located above the weight (2510), and the second blending sample (2530) can be located to the left of the weight (2510). For example, if the current sample is located at (x, y) based on the upper left sample of the current block, the weight corresponding to the current sample can be located at (x, y) based on the upper left weight of the blending map. In this example, the first blending sample (2520) may correspond to (x, -1) in the blending template (2505), and the second blending sample (2530) may correspond to (-1, y) in the blending template (2505). For example, the first blending sample (2520) may have the same x-coordinate as the current sample of the current block, and the second blending sample (2530) may have the same y-coordinate as the current sample of the current block. For convenience of explanation, the blending template (2505) and the blending map (2500) are described as being adjacent, but the present invention is not limited thereto, and the blending template (2505) may not be adjacent to the blending map (2500), in which case the coordinates of the first blending sample (2520) and the second blending sample (2530) may also be different.

[0358] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a weight (2510) using a weighted average of a first blending sample (2520) and a second blending sample (2530). The image decoding device (2000) can obtain a blending template by performing a weighted average based on a vertical distance between the weight (2510) and the first blending sample (2520) and a horizontal distance between the weight (2510) and the second blending sample (2530).

[0359] FIG. 26 is a diagram illustrating a process of obtaining weights based on a blending template according to one embodiment of the present disclosure.

[0360] Referring to FIG. 26, a blending map and a blending template are illustrated. The description of the blending map and blending template with reference to FIG. 25 can also be applied to FIG. 26.

[0361] In one embodiment of the present disclosure, the image decoding device (2000) can obtain multiple weights based on multiple blending samples. The image decoding device (2000) can obtain a final weight based on the multiple weights.

[0362] The video decoding device (2000) can obtain a first weight (2610) corresponding to the current sample based on the first blending sample (2620) of the blending template and the upper right sample (2630) of the blending template. In one embodiment of the present disclosure, the upper right sample (2630) of the blending template can be determined to be identical to the blending sample (2635) located at the far right among the upper templates of the blending template.

[0363] The image decoding device (2000) can obtain a first weight (2610) using a weighted average of the first blending sample (2620) and the upper right sample (2630). The first blending sample (2620) can be located to the left of the first weight (2610). The image decoding device (2000) can obtain the first weight (2610) based on the horizontal distance between the first blending sample (2620) and the first weight (2610) and the horizontal distance between the upper right sample (2630) and the first weight (2610). For example, the image decoding device (2000) can obtain the first weight (2610) based on a product of a horizontal distance between the first blending sample (2620) and the first weight (2610) and the upper right sample (2630), and a product of the first blending sample (2620) and the horizontal distance between the upper right sample (2630) and the first weight (2610). For example, if the weight (2610) is located at (x, y), the first weight (2610) can be determined based on a product of x+1, which is a horizontal distance between the first blending sample (2620) and the first weight (2610), and the upper right sample (2630), and a product of nT-1-x, which is a horizontal distance between the upper right sample (2630) and the first weight (2610), and the first blending sample (2620).

[0364] The video decoding device (2000) can obtain a second weight (2640) corresponding to the current sample based on the second blending sample (2650) of the blending template and the lower left sample (2660) of the blending template. In one embodiment of the present disclosure, the lower left sample (2660) of the blending template can be determined to be identical to the blending sample (2665) located at the lowest position among the left templates of the blending template.

[0365] The image decoding device (2000) can obtain the second weight (2640) by using the weighted average of the second blending sample (2650) and the lower left sample (2660). The second blending sample (2650) can be located above the second weight (2640). The image decoding device (2000) can obtain the second weight (2640) based on the vertical distance between the second blending sample (2650) and the second weight (2640) and the vertical distance between the lower left sample (2660) and the second weight (2640). For example, the image decoding device (2000) can obtain the second weight (2640) based on a product of the vertical distance between the second blending sample (2650) and the second weight (2640) and the lower left sample (2660), and a product of the second blending sample (2650) and the vertical distance between the lower left sample (2660) and the second weight (2640). For example, if the weight (2610) is located at (x, y), the second weight (2640) can be determined based on a product of the lower left sample (2660) and y+1, which is the vertical distance between the second blending sample (2650) and the second weight (2640), and a product of the second blending sample (2650) and nT-1-y, which is the vertical distance between the lower left sample (2660) and the second weight (2640).

[0366] The image decoding device (2000) can obtain a weight corresponding to the current sample based on the first weight (2610) and the second weight (2640). The image decoding device (2000) can obtain a prediction block using the average of the first weight (2610) and the second weight (2640). The image decoding device (2000) can obtain a weight corresponding to the current sample based on a value obtained by dividing the first weight (2610) and the second weight (2640) by the size of the blending map. For example, the image decoding device (2000) can obtain a weight corresponding to the current sample based on a value obtained by dividing the first weight (2610) and the second weight (2640) by log2(nT)+1. When the blending map is non-square, different values ​​may be assigned to the first weight (2610) and the second weight (2640). For example, the width of the blending map may be divided into the first weight (2610) and the height of the blending map may be divided into the second weight (2640).

[0367] FIG. 27 is a diagram illustrating a process of obtaining weights based on a blending template and a predetermined matrix according to one embodiment of the present disclosure.

[0368] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a blending map (2730) based on a blending template (2710) and a matrix (2720). The image decoding device (2000) can obtain a matrix (2720) corresponding to the current template and / or blending template (2710) of the current block.

[0369] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a matrix (2720) based on the size of the current block. The image decoding device (2000) can obtain a matrix (2720) corresponding to the size of the current block from among a plurality of predetermined matrices.

[0370] In one embodiment of the present disclosure, the image decoding device (2000) can obtain information indicating a matrix (2720). For example, the image decoding device (2000) can obtain an index indicating the matrix (2720) from a bitstream. The image decoding device (2000) can obtain a matrix (2720) corresponding to the index from among a plurality of predetermined matrices.

[0371] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a blending map (2730) based on a vector-matrix operation between a blending template (2710) and a matrix (2720). The image decoding device (2000) can obtain a one-dimensional vector corresponding to the blending template (2710). For example, the image decoding device (2000) can obtain the one-dimensional vector to sequentially include samples of the blending template (2710). The image decoding device (2000) can obtain the blending map (2730) using an operation between the one-dimensional vector corresponding to the blending template (2710) and the two-dimensional matrix (2720). For example, the image decoding device (2000) can obtain a one-dimensional vector by using an operation between a one-dimensional vector corresponding to a blending template (2710) and a two-dimensional matrix (2720), and can rearrange the one-dimensional vector to obtain a two-dimensional blending map (2730).

[0372] FIG. 28 is a flowchart illustrating a process for obtaining weights based on a blending template and direction information according to one embodiment of the present disclosure.

[0373] In one embodiment of the present disclosure, step S2230 may include steps S2810 and S2820. For example, the image decoding device (2000) may perform steps S2810 and S2820 by having the processor of the image decoding device (2000) execute at least one instruction contained in a memory.

[0374] In step S2810, the method may include an operation of obtaining direction information based on the current template. For example, the image decoding device (2000) may obtain direction information based on the current template.

[0375] In one embodiment of the present disclosure, the image decoding device (2000) can determine direction information from among the directional modes used in the intra prediction mode. For example, the image decoding device (2000) can determine direction information from among 65 directional modes used in the intra prediction mode.

[0376] In one embodiment of the present disclosure, the image decoding device (2000) may determine direction information from among predetermined candidate directions. For example, the image decoding device (2000) may determine one of the predetermined candidate directions as direction information for use in generating a blending map.

[0377] In one embodiment of the present disclosure, the image decoding device (2000) can obtain direction information using a sample included in the current template. Exemplary processes by which the image decoding device (2000) obtains direction information based on the current template are described with reference to FIGS. 29 to 31.

[0378] In step S2820, the method may include an operation of obtaining a plurality of weights based on direction information and a blending template.

[0379] The video decoding device (2000) can obtain a plurality of weights from the blending template along an angle or direction corresponding to the direction information. In one embodiment of the present disclosure, the video decoding device (2000) can obtain one or more blending samples of the blending template corresponding to the first weight based on the direction information. For example, the first weight may correspond to one or more blending samples of the blending template from the position of the first weight according to the direction or angle corresponding to the direction information. The first weight may correspond to at least one of a blending sample located above the blending template and a blending sample located to the left of the blending template.

[0380] In one embodiment of the present disclosure, the video decoding device (2000) may determine a first weight based on one or more blending samples. For example, the video decoding device (2000) may determine an average of a plurality of blending samples as the first weight. For example, the video decoding device (2000) may determine a first weight having the same value as the blending sample. For example, the video decoding device (2000) may determine the first weight by performing a weighted sum according to a distance of the plurality of blending samples. For example, the video decoding device (2000) may perform a weighted sum using a weight that is determined to be larger as the weight is closer to the first weight among the plurality of blending samples.

[0381] FIG. 29 is a diagram illustrating a process for obtaining direction information according to one embodiment of the present disclosure.

[0382] The image decoding device (2000) can obtain direction information using a plurality of restoration sample sets (2910, 2920, 2930, 2940) located around the current block (2900). Referring to FIG. 29, the current image can include a right restoration sample set (2910) located to the right of the upper left restoration sample of the current block (2910), an upper restoration sample set (2920) located above, a left restoration sample set (2930) located on the left, and a lower restoration sample set (2940) located below. The right restoration sample set (2910), the upper restoration sample set (2920), the left restoration sample set (2930), and the lower restoration sample set (2940) can each include a predetermined number of restoration samples. For example, the right restoration sample set (2910), the upper restoration sample set (2920), the left restoration sample set (2930), and the lower restoration sample set (2940) may include the same number of restoration samples, or may each include a different predetermined number of restoration samples.

[0383] In one embodiment of the present disclosure, the image decoding device (2000) can predict another set corresponding to a directional mode (2950) based on one of a plurality of restored sample sets (2910, 2920, 2930, 2940). For example, the image decoding device (2000) can obtain a prediction sample of an upper restored sample set (2910) corresponding to a directional mode (2950) based on a lower restored sample set (2940). The directional mode (2950) is an angle ( ) can be corresponded to.

[0384] The image decoding device (2000) can obtain prediction samples for a second reconstruction sample set corresponding to each of a plurality of directional modes based on the first reconstruction sample set. The first reconstruction sample set and the second reconstruction sample may be one of a right reconstruction sample set (2910), an upper reconstruction sample set (2920), a left reconstruction sample set (2930), and a lower reconstruction sample set (2940). The image decoding device (2000) can obtain directional information based on the prediction samples for the second reconstruction sample set and the reconstruction samples of the second reconstruction sample set. The image decoding device (2000) can select a directional mode (2950) based on a difference between the prediction samples for the second reconstruction sample set and the second reconstruction sample set. For example, the image decoding device (2000) can select a directional mode (2950) in which a difference between the prediction samples for the second reconstruction sample set and the second reconstruction sample set is the smallest among the plurality of directional modes. The image decoding device (2000) can obtain directional information based on the difference between the predicted sample for the second reconstructed sample set and the second reconstructed sample set among multiple directional modes. For example, the image decoding device (2000) can obtain the selected directional mode (2950) as directional information. In one embodiment of the present disclosure, the image decoding device (2000) can obtain the difference using the cost function described in FIG. 20 .

[0385] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a blending map (2970) based on direction information and a blending template (2960). The image decoding device (2000) can obtain one or more blending samples (2962, 2964) corresponding to weights (2972) included in the blending map (2970) using the direction information. The image decoding device (2000) can obtain the weights (2972) using one or more blending samples (2962, 2964). For example, the image decoding device (2000) can determine a weight (2972) having the same value as the blending sample (2962) or the blending sample (2964). For example, the image decoding device (2000) can determine a weight (2972) having a value equal to the average of the blending sample (2962) and the blending sample (2964). For example, the image decoding device (2000) can determine a weight (2972) having a value equal to the weighted sum of the blending sample (2962) and the blending sample (2964).

[0386] FIG. 30 is a diagram illustrating a process of obtaining direction information using template-based intra-mode derivation (TIMD) according to one embodiment of the present disclosure.

[0387] In one embodiment of the present disclosure, an image decoding device (2000) can obtain direction information using template-based intra mode derivation. The image decoding device (2000) can obtain direction information based on a template (3010) and a reference sample (3020).

[0388] Referring to FIG. 30, a current block may have a square or non-square shape with a width of N and a height of M. In one embodiment of the present disclosure, an image decoding device (2000) may obtain a template (3010) of the current block. The template (3010) of the current block may include a left sample, an upper left sample, and / or an upper sample of the current block. The template (3010) of the current block may include an upper template having a width of N equal to that of the current block and a height of L1, and a left template having a height of M equal to that of the current block and a width of L2. However, the present invention is not limited thereto, and the width of the upper template may be wider than that of the current block, and the height of the left template may also be wider than that of the current block.

[0389] The image decoding device (2000) can determine a reference sample (3020) of the template (3010) of the current block. The reference sample (3020) can include a left sample, an upper left sample, and / or an upper sample of the template. For example, the reference sample (3020) can include 2(L1+M)+1 left reference samples and 2(L2+N)+1 upper reference samples adjacent to the template (3010). The image decoding device (2000) can perform prediction on the template (3010) of the current block using the reference sample (3020). For example, the image decoding device (2000) can perform prediction on the template (3010) of the current block according to a plurality of directional modes using the reference sample (3020). For example, the image decoding device (2000) can perform prediction on the template (3010) of the current block according to a plurality of predetermined modes using the reference sample (3020).

[0390] The image decoding device (2000) can obtain direction information based on a sample predicted by the reference sample (3020) and a reconstructed sample of the template (3010). The image decoding device (2000) can obtain direction information based on a difference between a sample predicted by the reference sample (3020) and a reconstructed sample of the template (3010). For example, the image decoding device (2000) can select a directional mode or a predetermined mode in which the difference between a sample predicted by the reference sample (3020) and a reconstructed sample of the template (3010) is the smallest among a plurality of directional modes or a plurality of predetermined modes. In one embodiment of the present disclosure, the image decoding device (2000) can obtain the difference using the cost function described in FIG. 20.

[0391] The image decoding device (2000) can obtain direction information based on a selected directional mode or a predetermined mode. For example, the image decoding device (2000) can obtain direction information corresponding to the selected directional mode or a predetermined mode. The image decoding device (2000) can obtain a blending map from a blending template based on the obtained directional information.

[0392] FIG. 31 is a diagram illustrating a process of obtaining direction information using decoder-side intra mode derivation (DIMD) according to one embodiment of the present disclosure.

[0393] In one embodiment of the present disclosure, the image decoding device (2000) can obtain direction information using decoder-side intra mode derivation.

[0394] In one embodiment of the present disclosure, the image decoding device (2000) can obtain direction information based on a template (3120) of a current block (3110). In one embodiment of the present disclosure, the template (3120) may be different from the template of the current block (3110) for generating a blending template described according to one embodiment of the present disclosure. For example, the template (3120) of the current block (3110) may include the template of the current block (3110) for generating a blending template. For example, the image decoding device (2000) can obtain direction information of the current block (3110) by using the template of the current block (3110) for generating a blending template and the template (3120) including surrounding samples of the current block (3110).

[0395] In one embodiment of the present disclosure, the image decoding device (2000) can determine a window block (3130) included in a template (3120) of a current block (3110). For example, the image decoding device (2000) can determine a plurality of 3 x 3 blocks included in the template (3120) of the current block (3110). The image decoding device (2000) can obtain a plurality of variations based on samples included in each of the determined window blocks (3130). For example, the image decoding device (2000) can obtain horizontal variations and vertical variations of samples included in each of the determined 3 x 3 blocks. For example, the image decoding device (2000) can determine the horizontal variations and vertical variations using a Sobel filter.

[0396] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a slope based on a horizontal change amount and a vertical change amount. For example, the image decoding device (2000) can determine a ratio between the horizontal change amount and the vertical change amount as the slope. The image decoding device (2000) can obtain a directional mode corresponding to the slope. The image decoding device (2000) can determine direction information based on a plurality of directional modes determined for a plurality of 3 x 3 blocks.

[0397] In one embodiment of the present disclosure, the image decoding device (2000) can obtain frequency information using the gradients of a plurality of window blocks (3130). For example, the image decoding device (2000) can obtain a histogram of gradients (HOG) (3140) using the gradients of the plurality of window blocks (3130). The HOG (3140) can include information indicating the frequency (or amplitude) of a directional mode (ipm) corresponding to the gradients of the plurality of window blocks (3130). For example, the HOG (3140) can be information including the frequency (or amplitude) corresponding to the directional mode.

[0398] In one embodiment of the present disclosure, the magnitude (or frequency) of the directional mode of HOG (3140) may be determined based on the horizontal variation and vertical variation. For example, the greater the horizontal variation and vertical variation, the greater the magnitude of the directional mode. For example, the magnitude may be determined based on the sum of the absolute values ​​of the horizontal variation and vertical variation.

[0399] In one embodiment of the present disclosure, the image decoding device (2000) can obtain direction information based on frequency information. For example, the image decoding device (2000) can determine direction information based on the magnitude of the frequency information. The image decoding device (2000) can determine the direction mode of the current block (3110) based on a result in which a weight determined according to the magnitude is reflected.

[0400] In one embodiment of the present disclosure, the image decoding device (2000) can obtain direction information based on the amount of change or slope obtained for a plurality of window blocks (3130). For example, the image decoding device (2000) can obtain first direction information using the amount of change between a plurality of first samples including the current template (3120) of the current block (3110), and can obtain second direction information using the amount of change between a plurality of second samples. The image decoding device (2000) can obtain direction information based on the first direction information and the second direction information.

[0401] FIG. 32a is a diagram illustrating a method for obtaining prediction samples for a current block when the size of the reference image is the same as the size of the current image.

[0402] The image decoding device (2000) can obtain a current block (3220a) included in a current image (3210a). In one embodiment of the present disclosure, the size of the current block (3220a) may be 2x2, but is not limited thereto, and the size of the current block (3220a) may be MxN. The number of prediction samples (3240a) may be the same as the number of current samples included in the current block. For example, four prediction samples may be used to restore the values ​​of four current samples. In one embodiment of the present disclosure, an area or matrix including prediction samples (3240a) may be referred to as a prediction block or a predictor. For example, a prediction block having a size of 2x2 may mean that four prediction samples (3240a) are configured in a 2x2 matrix. The fact that the current image (3210a) and the reference image (3230a) are the same size means that their width and height are the same.

[0403] The video decoding device (2000) can obtain the position of the upper left prediction sample (3245a) within the reference image (3230a) by applying the motion vector (mv) of the current block (3220a) to the position of the upper left current sample (3225a) located at the upper left among the current samples included in the current block (3220a). The video decoding device (2000) can obtain the position of a 2 x 2 prediction block including the remaining prediction samples adjacent to the upper left prediction sample (3245a).

[0404] In FIG. 32a, since the sizes of the reference image (3230a) and the current image (3210a) are the same, the prediction samples (3240a) may be adjacent to each other. For example, among the prediction samples (3240a), the first prediction sample may be spaced apart from the second prediction sample, which is closest to the first prediction sample, by a distance (or coordinate value) of 1. For example, when the position of the first prediction sample is (a, b), the position of the second prediction sample located to the right of the first prediction sample may be (a+1, b), and the position of the third prediction sample located below the first prediction sample may be (a, b+1).

[0405] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction sample by performing filtering using reference samples located around prediction samples (3240a). For example, the image decoding device (2000) can obtain a first prediction sample by using reference samples located around a first prediction sample. The image decoding device (2000) can obtain a prediction sample based on filtering the reference samples using an n-tap filter (n is a natural number, for example, 6 or 8). For example, the image decoding device (2000) can obtain the first prediction sample by applying an n-tap filter to a reference sample located on the left side of the first prediction sample and a reference sample located on the right side.

[0406] In one embodiment of the present disclosure, the image decoding device (2000) may select a filter coefficient set based on the position of a prediction sample. For example, the image decoding device (2000) may obtain a filter coefficient set corresponding to a sub-pixel position of a prediction sample from among a plurality of filter coefficient sets. The filter coefficient set may include a plurality of filter coefficients corresponding to surrounding reference samples. For example, the image decoding device (2000) may obtain a prediction sample by applying a plurality of filter coefficients included in the filter coefficient set to a plurality of corresponding reference samples. The sub-pixel position may be determined as a fractional value from among positions determined based on a motion vector and a current sample.

[0407] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a template of a prediction block corresponding to the template of a current block (3220a). For example, the image decoding device (2000) can obtain the template of the prediction block based on the position of the upper left prediction sample (3245a) of the reference image (3230a). For example, the image decoding device (2000) can determine the position of the template of the prediction block using the position of the upper left prediction sample (3245a) of the reference image (3230a). For example, since the sizes of the reference image (3230a) and the current image (3210a) are the same, the templates of the prediction blocks may be adjacent to each other. For example, a first sample in the template of the prediction block may be spaced apart from a second sample, which is closest to the first sample, by a distance (or coordinate value) of 1. For example, if the position of the upper left prediction sample (3254a) is (a, b), the position of the first sample (3260a) among the templates of the prediction block may be (a, b-1), and the position of the second sample (3265a) closest to the first sample (3260a) may be (a+1, b-1).

[0408] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a template of a prediction block based on the distance between a current block (3220a) and a template of the current block (3220a). For example, the image decoding device (2000) can obtain a template of a prediction block based on the distance between the position of the upper left current sample (3225a) of the current block (3220a) and the closest sample (3250a) among the templates of the current block (3220a). For example, in FIG. 32a, the current block (3220a) and the template are adjacent, and the distance between the current block (3220a) and the template of the current block (3220a) is 1. However, the present invention is not limited thereto, and in the case where the current block (3220a) and the template are not adjacent, the distance between the current block (3220a) and the template of the current block (3220a) may be greater than 1. In this case, the image decoding device (2000) may obtain the template of the prediction block spaced apart from the prediction samples (3245a) by the distance between the current block (3220a) and the template of the current block (3220a).

[0409] FIG. 32b is a diagram illustrating a method for obtaining prediction samples for a current block when the size of a reference image is larger than the size of a current image.

[0410] The image decoding device (2000) can obtain a current block (3220b) included in a current image (3210b). The image decoding device (2000) can obtain an area (3240b) corresponding to the current block (3220b) from a reference image (3230b). For example, when the size of the current block (3220b) is 2x2 and the width and height of the reference image (3230b) are each twice the width and height of the current image (3210b), the size of the area (3240b) corresponding to the current block (3220b) within the reference image (3230b) is 4x4. Since the number of prediction samples is the same as the number of current samples, prediction samples of the prediction block can be obtained within an area (3240b) having a size of 4x4.

[0411] The video decoding device (2000) can obtain the position of the upper left prediction sample (3245b) within the reference image (3230b) by applying the motion vector (mv) of the current block (3220b) to the position of the upper left current sample (3225b) located at the upper left among the current samples included in the current block (3220b).

[0412] Since the size of the reference image (3230b) is twice as large as that of the current image (3210b), the position (3235b) pointed to by the motion vector must be changed based on the ratio between the size of the reference image (3230b) and the size of the current image (3210b). In one embodiment of the present disclosure, the image decoding device (2000) can obtain the position of the upper left prediction sample (3241b) of the reference image (3230b) corresponding to the upper left current sample (3225b) of the current block (3210b) based on the position of the upper left current sample (3225b), the motion vector, and the ratio between the size of the reference image (3230b) and the size of the current image (3210b). For example, the image decoding device (2000) can determine the position of the upper left prediction sample (3241b) based on the result of multiplying the position (3235b) where the motion vector is applied to the position of the upper left current sample (3225b) by the ratio between the size of the reference image (3230b) and the size of the current image (3210b). The ratio between the reference image (3230b) and the current image (3210b) can include the ratio between the width of the reference image (3230b) and the width of the current image (3210b) or the ratio between the height of the reference image (3230b) and the height of the current image (3210b).

[0413] The video decoding device (2000) can determine the position (3235b) (refxSb, refySb) indicated by the motion vector in the reference image (3230b) based on the value obtained by adding the motion vector (mvx, mvy) to the position (xSb, ySb) of the upper left current sample (3225b) of the current image (3210b). For example, referring to FIG. 32b, when the motion vector is (0,0), the position where the motion vector (0,0) is applied to the position (2,2) of the upper left current sample (3225b) becomes (2,2). The image decoding device (2000) can obtain the position of the upper left prediction sample (3245b) within the reference image (3230b) by applying the ratio of the reference image (3230b) and the current image (3210b) to the position of the upper left current sample (3225b). For example, if the x-coordinate in (2, 2) is multiplied by 2, which is the ratio between the height of the reference image (3230b) and the height of the current image (3210b), and if the y-coordinate in (2, 2) is multiplied by 2, which is the ratio between the width of the reference image (3230b) and the width of the current image (3210b), the position of (4, 4) can be derived. For example, if the ratio between the height of the reference image (3230b) and the height of the current image (3210b) is 2, and the ratio between the width of the reference image (3230b) and the width of the current image (3210b) is 1, the upper left predicted sample at position (4, 2) derived by multiplying (2, 2) by 2 and 1 can be identified.

[0414] The video decoding device (2000) can obtain the positions of the remaining prediction samples (3242b, 3243b, 3244b) based on the position of the upper left prediction sample (3241b). For example, the video decoding device (2000) can obtain the positions of the remaining prediction samples (3242b, 3243b, 3244b) by applying an interval to the position of the upper left prediction sample (3241b). The video decoding device (2000) can obtain the position of the first prediction sample corresponding to the first current sample based on the distance between the upper left current sample (3225b) of the current block (3220b) and the first current sample. For example, the image decoding device (2000) can determine the interval for the upper left prediction sample (3241b) by applying the ratio of the reference image (3230b) and the current image (3210b) to the distance between the upper left current sample (3225b) and the first current sample of the current block (3220b). For example, if the ratio between the height of the reference image (3230b) and the height of the current image (3210b) is 2, and the ratio between the width of the reference image (3230b) and the width of the current image (3210b) is 2, the predetermined interval can be determined as 2 in the height direction and 2 in the width direction.

[0415] The video decoding device (2000) can select prediction samples (3242b, 3243b, 3244b) spaced apart from the upper left prediction sample (3241b) by a predetermined distance according to the number of current samples. Referring to FIG. 32b, the video decoding device (2000) can obtain the position (4, 4) of the upper left prediction sample (3241b), the position (6, 4) of the first prediction sample (3242b), the position (4, 6) of the second prediction sample (3243b), and the position (6, 6) of the third prediction sample (3244b).

[0416] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction sample by performing filtering using reference samples located around prediction samples (3241b, 3242b, 3243b, 3244b). For example, the image decoding device (2000) can obtain a first prediction sample by using reference samples located around a first prediction sample. The image decoding device (2000) can obtain a prediction sample based on filtering the reference samples with an n-tap filter (n is a natural number, for example, 6 or 8). For example, the image decoding device (2000) can obtain the first prediction sample by applying an n-tap filter to reference samples located on the left side and reference samples located on the right side of the first prediction sample.

[0417] In one embodiment of the present disclosure, the image decoding device (2000) may select a filter coefficient set based on the position of a prediction sample. For example, the image decoding device (2000) may obtain a filter coefficient set corresponding to a sub-pixel position of a prediction sample from among a plurality of filter coefficient sets. The filter coefficient set may include a plurality of filter coefficients corresponding to surrounding reference samples. For example, the image decoding device (2000) may obtain a prediction sample by applying a plurality of filter coefficients included in the filter coefficient set to a plurality of corresponding reference samples. The sub-pixel position may be determined as a fractional value from among positions determined based on a motion vector and a current sample.

[0418] The image decoding device (2000) can obtain a filter coefficient set based on the ratio between the current image (3210b) and the reference image (3230b). For example, the image decoding device (2000) can obtain a plurality of filter coefficient sets corresponding to the ratio between the current image (3210b) and the reference image (3230b). For example, the image decoding device (2000) can obtain a plurality of first filter coefficient sets corresponding to a plurality of sub-pixel positions when the ratio between the current image (3210b) and the reference image (3230b) is less than a first predetermined value, and can obtain a plurality of second filter coefficient sets corresponding to a plurality of sub-pixel positions when the ratio is greater than the first predetermined value. The image decoding device (2000) can obtain a plurality of filter coefficient sets corresponding to the ratio between the current image (3210b) and the reference image (3230b), and obtain a filter coefficient set corresponding to a sub-pixel position of a prediction sample from among the plurality of filter coefficient sets. For example, if the subpixel locations of the first prediction sample and the second prediction sample are different, the image decoding device (2000) can obtain different filter coefficient sets for the first prediction sample and the second prediction sample from among a plurality of first filter coefficient sets.

[0419] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a template of a prediction block corresponding to the template of the current block (3220b). For example, the image decoding device (2000) can obtain the template of the prediction block based on the position of the upper left prediction sample (3245b) of the reference image (3230b). For example, the image decoding device (2000) can determine the position of the template of the prediction block using the position of the upper left prediction sample (3245b) of the reference image (3230b). For example, since the size of the reference image (3230b) is larger than the size of the current image (3210b), the templates of the prediction blocks may not be adjacent to each other. For example, since the size of the reference image (3230b) is twice the size of the current image (3210b), the first sample in the template of the prediction block may be spaced apart from the second sample closest to the first sample by a distance (or coordinate value) of 2. For example, if the position of the upper left prediction sample (3254b) is (a, b), the position of the first sample (3260b) in the template of the prediction block may be (a, b-2), and the position of the second sample (3265b) closest to the first sample (3260b) may be (a+2, b-2).

[0420] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a template of a prediction block based on the distance between the current block (3220b) and the template of the current block (3220b). For example, the image decoding device (2000) can obtain a template of a prediction block based on the distance between the position of the upper left current sample (3225b) of the current block (3220b) and the closest sample (3250b) among the templates of the current block (3220b). For example, in FIG. 32b, the current block (3220b) and the template are adjacent, and the distance between the current block (3220b) and the template of the current block (3220b) is 1. However, the present invention is not limited thereto, and in the case where the current block (3220b) and the template are not adjacent, the distance between the current block (3220b) and the template of the current block (3220b) may be greater than 1. In this case, the image decoding device (2000) may obtain the template of the prediction block spaced apart from the prediction samples (3245b) by applying the ratio between the size of the reference image (3230b) and the size of the current image (3210b) to the distance between the current block (3220b) and the template of the current block (3220b).

[0421] Figure 33 is a diagram for explaining a method for obtaining prediction samples when the size of the reference image and the size of the current image are different.

[0422] Referring to Fig. 33, r0 to r15 may represent integer pixels within a reference image, and c0 to c9 may represent integer pixels within a current image. Fig. 33 assumes that the size ratio between the reference image and the current image is 1.6, but the size ratio is not limited thereto, and the reference image may be smaller than or equal to the current image.

[0423] In one embodiment of the present disclosure, the video decoding device (2000) can determine the positions of prediction samples (p3, p4, p5, p6) corresponding to current samples (c3, c4, c5, c6). The video decoding device (2000) can determine the positions of the prediction samples corresponding to the current samples based on the motion vector and the ratio of the current image to the reference image. For example, the prediction sample (p3) can be located between the reference sample (r5) and the reference sample (r6). For example, the position of the prediction sample (p6) can be the same as the position of the reference sample (r10).

[0424] In one embodiment of the present disclosure, the image decoding device (2000) can obtain the subpixel positions of the prediction samples. For example, when interpolation is performed in units of 1 / 16 pixels, the image decoding device (2000) can determine the positions of the subpixels corresponding to the prediction samples (p3, p4, p5, and p6) as 3, 13, 6, and 0, respectively. The image decoding device (2000) can obtain a filter coefficient set corresponding to the encoded pixel positions. For example, since the subpixel positions of the prediction samples (p3, p4, p5, and p6) are all different, they can correspond to different filter coefficient sets, respectively. For example, when interpolation is performed in units of 1 / 16 pixels, the image decoding device (2000) can obtain a first filter coefficient set corresponding to the position of the subpixel of the prediction sample (p3) 3 among 16 filter coefficient sets, and obtain the prediction sample (p3) by applying the first filter coefficient set to surrounding reference samples of the prediction sample (p3). The reference sample can represent a sample at an integer position included in the reference image.

[0425] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a plurality of surrounding reference samples centered on the positions of the prediction samples (p3, p4, p5, p6). For example, the image decoding device (2000) can obtain a plurality of surrounding reference samples including four reference samples located to the left of the prediction samples (p3, p4, p5, p6) and four reference samples located to the right of the prediction samples (p3, p4, p5, p6). The image decoding device (2000) can obtain the prediction samples by applying a plurality of filter coefficients included in a filter coefficient set to each of the plurality of surrounding reference samples.

[0426] In one embodiment of the present disclosure, the image decoding device (2000) may determine whether to apply a filter coefficient set based on the position of the prediction sample. For example, if the subpixel position of the prediction sample is 0, the image decoding device (2000) may obtain the value of the prediction sample using a reference sample at the same position as the prediction sample without applying the filter coefficient set to the surrounding reference samples.

[0427] In one embodiment of the present disclosure, the image decoding device (2000) can obtain filter coefficient sets for each of the vertical direction and the horizontal direction. For example, the image decoding device (2000) can obtain a vertical direction filter coefficient set based on a ratio of a height of a reference image and a height of a current image, and obtain a prediction block based on applying the vertical direction filter coefficients to surrounding reference samples arranged in the vertical direction (i.e., surrounding reference samples having the same x coordinate). For example, the image decoding device (2000) can obtain a horizontal direction filter coefficient set based on a ratio of a width of a reference image and a width of a current image, and obtain a prediction block based on applying the horizontal direction filter coefficients to surrounding reference samples arranged in the horizontal direction (i.e., surrounding reference samples having the same y coordinate).

[0428] In one embodiment of the present disclosure, the image decoding device (2000) can independently apply filtering for horizontal and vertical directions. For example, the image decoding device (2000) can apply filtering only for the horizontal direction, filtering only for the vertical direction, or filtering for both the horizontal and vertical directions.

[0429] Although FIG. 33 describes one-dimensional samples having the same x-coordinate or y-coordinate among the samples included in the current image and the reference image, the present invention is not limited thereto, and the location of the predicted sample can be determined with reference to the contents described in FIG. 33 for a two-dimensional image.

[0430] In one embodiment of the present disclosure, the image decoding device (2000) can obtain a prediction sample of the current block using a prediction sample obtained from a reference image using a motion vector. For example, the image decoding device (2000) can obtain a prediction sample of the current block using a first prediction sample obtained from a first reference image and a second prediction sample obtained from a second reference image.

[0431] FIG. 34 is a drawing for explaining a template of a current block according to one embodiment of the present disclosure.

[0432] Referring to FIG. 34, the template of the current block (3410) may take various forms. Although the image decoding device (2000) according to one embodiment of the present disclosure has been described as performing prediction of the current block (3410) using the first template (3420) including both the left reconstruction sample and the upper reconstruction sample, the present disclosure is not limited thereto, and the intra prediction mode of the current block (3410) may be determined or prediction may be performed using a template including various reconstruction samples. In one embodiment of the present disclosure, the template may include one or more reconstruction sample lines in the current block (3410). For example, the template may include reconstruction samples adjacent to the current block (3410). For example, as illustrated in FIG. 34, the template may include a plurality of reconstruction samples included in four lines.

[0433] In one embodiment, the image decoding device (2000) can determine an intra prediction mode of a current block (3410) or perform prediction using a second template (3430) including a left reconstruction sample, an upper reconstruction sample, and an upper-left reconstruction sample.

[0434] In one embodiment, the image decoding device (2000) can determine an intra prediction mode of a current block (3410) or perform a prediction using a third template (3440) including a left reconstruction sample, an upper reconstruction sample, an upper left reconstruction sample, a lower left reconstruction sample, and an upper right reconstruction sample.

[0435] In one embodiment, the video decoding device (2000) can determine the intra prediction mode of the current block (3410) or perform prediction using a fourth template (3450) that includes at least some of the right reconstruction sample, the upper reconstruction sample, and the upper-right reconstruction sample. The video decoding device (2000) can determine the template based on the coding order (or coding direction) of the block. In one embodiment, when coding of the block is performed from right to left, the video decoding device (2000) can determine the intra prediction mode of the current block (3410) or perform prediction using the fourth template (3450).

[0436] FIG. 35 is a block diagram showing the configuration of an image encoding device according to one embodiment of the present disclosure.

[0437] Referring to FIG. 35, the image encoding device (3500) may include a processor (3510) and a memory (3520).

[0438] In one embodiment of the present disclosure, the processor (3510) may include processing circuitry and / or multiple processors. For example, the processor (3510) may include various processing circuitry, including at least one processor, wherein one or more of the at least one processor may be configured to individually and / or collectively perform various functions described in the present disclosure in a distributed manner.

[0439] In one embodiment of the present disclosure, the memory (3520) may include one or more storage media storing at least one instruction. The processor (3510) may control the image encoding device (3500) by executing the instructions stored in the memory (3520). For example, the processor (3510) may control the image encoding device (3500) to perform operations by individually or collectively executing the instructions stored in the memory (3520). In one embodiment of the present disclosure, the operations performed by the image encoding device (3500) may be operations performed by the processor (3510) of the image decoding device (3500).

[0440] In one embodiment of the present disclosure, the image encoding device (3500) may correspond to the image encoding device (200) illustrated in FIG. 2 and / or the encoding unit (1910) illustrated in FIG. 19.

[0441] The image encoding device (3500) can determine the prediction mode of the current block. The current block can include at least one of a maximum coding unit, an encoding unit, a transformation unit, or a prediction unit segmented from a current image to be encoded. In one embodiment of the present disclosure, the prediction mode of the current block can include at least one of an intra mode, an inter mode, a combined mode, a geometric segmentation mode, a block copy mode, or a template matching prediction mode.

[0442] In one embodiment of the present disclosure, the intra mode may include a non-directional Planar mode of number 0 (or Intra_Planar mode), a non-directional DC mode of number 1 (or Intra_DC mode), and directional Angular modes of number 2 to 66 (or Intra-directional mode) (e.g., (Intra_Angular2... Intra_Angular66). In one embodiment of the present disclosure, the intra-planar mode may mean a mode that determines a prediction sample based on a weighted average value according to the distance of a left reference sample, an upper reference sample, a lower-left sample, and an upper-right sample of the current block. In one embodiment of the present disclosure, the intra-DC mode may mean a mode that determines an average value of reference samples as a prediction sample. In one embodiment of the present disclosure, in the intra-directional modes, the positions of reference samples for generating prediction samples of samples in the current block may be identified in consideration of the direction indicated by the intra-directional modes. For example, in mode 34, the position of reference samples may be identified at 45 degrees to the upper left with respect to the samples in the current block. Reference samples located in the direction can be identified. In one embodiment of the present disclosure, the intra mode can include Wide-Angular modes (Intra_Wide_Angular) of -14 to -1 and 67 to 80. The Wide-Angular modes can be used to identify reference samples of samples in a non-square current block. In one embodiment of the present disclosure, the video encoding device (3500) can determine one of the Wide-Angular modes as an intra prediction mode of the non-square current block. The video encoding device (3500) can determine the Wide-Angular mode based on the width and height of the current block. If the width of the current block is greater than the height, the video encoding device (3500) can replace the lower-left directional mode with the upper-right extended directional mode.For example, the video encoding device (3500) can replace the index value "predModeIntra" of the intra prediction mode that is greater than or equal to 2 and less than or equal to a predetermined value with "predModeIntra + 65". If the height of the current block is greater than the width, the video encoding device (3500) can replace the upper-right directional mode with the lower-left extended directional mode. For example, the video encoding device (3500) can replace the index value "predModeIntra" of the intra prediction mode that is greater than or equal to a predetermined value and less than or equal to 66 with "predModeIntra - 67". The number and types of intra prediction modes that can be used in the intra mode by the video encoding device (3500) according to an embodiment of the present disclosure can be set in various ways. For example, the video encoding device (3500) can determine the Wide-Angular mode using a predetermined method according to the ratio of the height and width of the block (e.g., 16, 8, 4, 2, 1 / 2, 1 / 4, 1 / 8, or 1 / 16).

[0443] In one embodiment of the present disclosure, the video encoding device (3500) may determine an intra prediction mode using MPM (most probable modes). The video encoding device (3500) may determine whether to use MPM. The video encoding device (3500) may generate a bitstream including information related to whether to use MPM. When using MPM, the video encoding device (3500) may determine an MPM list. In one embodiment of the present disclosure, the video encoding device (3500) may determine the MPM list using neighboring blocks of the current block. The video encoding device (3500) may determine the MPM list based on the intra mode of the upper block of the current block and the intra mode of the left block. If the neighboring blocks of the current block are not available (for example, if the intra prediction mode of the neighboring blocks is not determined), the intra prediction mode of the unavailable neighboring blocks may be set to a predetermined mode (for example, the Planar mode). The video encoding device (3500) can determine one of the MPM lists as the intra prediction mode of the current block. The video encoding device (3500) can generate a bitstream including information (e.g., index information) indicating the intra prediction mode of the current block from the MPM list.

[0444] In one embodiment of the present disclosure, the video encoding device (3500) can determine an intra prediction mode using a template. The video encoding device (3500) can determine a template of a current block. The template of the current block can include a left sample, an upper left sample, and / or an upper sample of the current block. The video encoding device (3500) can determine a surrounding sample of the template of the current block. The surrounding sample of the template can include a left sample, an upper left sample, and / or an upper sample of the template. The video encoding device (3500) can perform prediction on the template using the surrounding sample of the template as a reference sample. The video encoding device (3500) can compare the predicted template with the template of the reconstructed current block to determine an intra mode for the reference block. The video encoding device (3500) can determine an intra mode with the smallest error between the predicted template and the template of the reconstructed current block as the intra mode for the reference block. In one embodiment of the present disclosure, the process of determining an intra prediction mode by performing prediction on a template by the image encoding device (3500) may be referred to as template-based intra mode derivation (TIMD).

[0445] In one embodiment of the present disclosure, the video encoding device (3500) can infer an intra prediction mode of the current block using surrounding samples of the current block. The video encoding device (3500) can determine a gradient using the surrounding samples of the current block. The video encoding device (3500) can determine a plurality of 3 x 3 blocks adjacent to the current block. The video encoding device (3500) can obtain horizontal variations and vertical variations of samples included in each of the determined 3 x 3 blocks. The video encoding device (3500) can determine a gradient based on the horizontal variations and vertical variations. The video encoding device (3500) can determine the horizontal variations and vertical variations using a Sobel filter. The video encoding device (3500) can determine an intra prediction mode corresponding to the gradient. The video encoding device (3500) can determine the intra prediction mode of the current block based on a plurality of intra prediction modes determined for the plurality of 3 x 3 blocks. In one embodiment of the present disclosure, the video encoding device (3500) may determine the most frequently determined intra prediction mode as the intra prediction mode of the current block. In one embodiment of the present disclosure, the video encoding device (3500) may determine the size based on the horizontal variation and the vertical variation. The video encoding device (3500) may determine the intra prediction mode of the current block based on the size. The video encoding device (3500) may determine the weight of the intra prediction mode corresponding to the slope as the size. For example, the video encoding device (3500) may increase the weight of the intra prediction mode determined based on the slope as the horizontal variation and the vertical variation increase. The video encoding device (3500) may determine the intra prediction mode of the current block based on the result in which the weight determined according to the size is reflected.In one embodiment of the present disclosure, the process by which the video encoding device (3500) determines an intra prediction mode based on a slope may be referred to as decoder side intra mode derivation (DIMD).

[0446] In one embodiment of the present disclosure, the block copy mode may include an intra block copy mode. In one embodiment, the block copy mode may include an intra block copy mode. In one embodiment, the intra block copy mode may be a sub-mode of the intra mode, but is not limited thereto, and may represent a mode separate from the intra mode. In one embodiment, the template matching prediction mode may include a template matching intra prediction mode. The combined mode may include a Combined Inter-Intra Prediction (CIIP) mode that performs prediction by combining prediction according to the intra mode and prediction according to the inter mode. The geometric partitioning mode may include a mode that partitions to include directionality within a block. The geometric partitioning mode may perform prediction using inter prediction or intra prediction for each of the divided regions that are blocked.

[0447] In one embodiment of the present disclosure, when the prediction mode of the current block is the CIIP mode, the video encoding device (3500) can perform prediction on the current block by combining inter prediction and intra prediction. For example, the video encoding device (3500) can perform intra prediction according to the Planar mode. For example, the video encoding device (3500) can determine a motion vector of a reference block for the current block. The video encoding device (3500) can perform inter prediction using the motion vector. The video encoding device (3500) can predict the current block using a weighted sum of a prediction block according to inter prediction and a prediction block according to intra prediction. The weight can be determined based on whether a block adjacent to the current block was intra-predicted (or inter-predicted).

[0448] In one embodiment of the present disclosure, when the prediction mode of the current block is a geometric segmentation mode, the image encoding device (3500) can perform prediction by segmenting the current block. The image encoding device (3500) can determine a segmentation angle and a segmentation distance for a boundary at which segmentation is performed within the current block. The image encoding device (3500) can segment the current block based on the segmentation angle and the segmentation distance. The image encoding device (3500) can predict the current block by performing inter prediction or intra prediction on each of the segmented regions within the current block. The image encoding device (3500) can (i) perform intra prediction on both segmented regions, (ii) perform inter prediction on one region and intra prediction on the other region, or (iii) perform inter prediction on both segmented regions.

[0449] In one embodiment of the present disclosure, when the prediction mode of the current block is the template matching prediction mode, the image encoding device (3500) can reconstruct the current block using a reference block. The image encoding device (3500) can generate information related to whether the template matching prediction mode is used. The image encoding device (3500) can determine whether the template matching prediction mode is used based on the acquired information. The reference block can be determined based on at least one of a region included in the current image or a region included in a previously decoded image. In one embodiment of the present disclosure, the image encoding device (3500) can determine the reference block using a cost function. The cost function can include at least one of a sum of absolute difference (SAD), a sum of squared difference (SSD), a sum of absolute transformed difference (SATD), a sum of squared error (SSE), or a mean removed SAD (MR-SAD). For example, the video encoding device (3500) can determine the error between templates using at least one cost function among SAD, SATD, SSE, and MR-SAD. When the cost function is SAD, the video encoding device (3500) can determine the error based on the sum of the absolute values ​​of the differences between each sample of the template of the current block and each sample of the template of the candidate block. When the cost function is SSD, the video encoding device (3500) can determine the error based on the sum of the squares of the differences between each sample of the template of the current block and each sample of the template of the candidate block. The cost function may include a function representing the number of identical samples. The video encoding device (3500) can determine a block with a small error among the candidate blocks as a reference block.The video encoding device (3500) can determine a prediction block by performing template matching intra prediction on the current image. In the present disclosure, the process of determining a reference block for the current block using a template may be referred to as template matching (TM). In the present disclosure, performing prediction on the current block based on template matching may be referred to as template matching prediction (TMP) or intra template matching prediction (Intra Template Matching Prediction).

[0450] In one embodiment of the present disclosure, the image encoding device (3500) can determine the intra prediction mode of the current block when the prediction mode of the current block is the intra mode.

[0451] In one embodiment of the present disclosure, the video encoding device (3500) can determine information about a block vector representing a reference block when the prediction mode of the current block is a block copy mode.

[0452] In one embodiment of the present disclosure, the image encoding device (3500) can perform intra prediction or inter prediction on the current block according to the prediction mode of the current block, and encode the current block using a prediction block generated as a result of performing the intra prediction or inter prediction.

[0453] In one embodiment of the present disclosure, when the prediction mode of the current block is block copy mode, the image encoding device (3500) can determine a prediction block from a reference block. For example, the image encoding device (3500) can determine a prediction block that is identical to the reference block or by performing filtering on the reference block. The reference block can be determined based on at least one of a region included in the current image or a region included in a previously decoded image.

[0454] In one embodiment of the present disclosure, when the prediction mode of the current block is a template matching prediction mode, the image encoding device (3500) can reconstruct the current block using a reference block. The image encoding device (3500) can determine a prediction block using the reference block.

[0455] The video encoding device (3500) can perform deblocking filtering. The deblocking filter can improve video quality by smoothing edges between blocks.

[0456] The video encoding device (3500) can perform filtering on samples of a current block on which deblocking filtering has been performed using a Sample Adaptive Offset (SAO) filter and / or a Bilateral Filter (BIF). The SAO filter and BIF can improve image quality by reducing the error between the restored image and the original image. The SAO filter and BIF can perform filtering on a sample-by-sample basis.

[0457] The video encoding device (3500) can perform filtering using an adaptive loop filter (ALF). ALF can improve image quality by reducing the error between the restored image and the original image. ALF can perform filtering on a block-by-block basis.

[0458] 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.

[0459] In one embodiment of the present disclosure, the video encoding device (3500) 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.

[0460] The image encoding device (3500) can generate a bitstream including an encoding result of an image. The bitstream can include an encoding result for a current block.

[0461] In one embodiment, the video encoding device (3500) can generate a bitstream including residual data. The residual data can include information about the difference between an original image (or an original sample) and a predicted image (or a predicted sample). In one embodiment, the video encoding device (3500) can generate a bitstream including transform coefficients of a residual block corresponding to a transform unit. In one embodiment, the video encoding device (3500) can obtain transform coefficients of the residual block based on residual samples of the residual block. For example, the video encoding device (3500) can obtain transform coefficients of the residual block by performing at least one of transforming or quantizing the residual samples of the residual block. In one embodiment, the video encoding device (3500) may determine a transform coefficient of a residual block using a residual sample of a transformation unit. If the size of a residual block corresponding to a transformation unit is larger than the size of the transformation unit, the video encoding device (3500) may determine some of the residual samples of the residual block as residual samples of the transformation unit. Alternatively, the video encoding device (3500) may determine the residual samples of the residual block as residual samples of the transformation unit on which filtering is performed. The video encoding device (3500) may generate a bitstream including the residual samples of the transformation unit.

[0462] In one embodiment of the present disclosure, the video encoding device (3500) can generate a bitstream including information about a block vector representing a reference block when the prediction mode of the current block is a block copy mode.

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

[0464] In one embodiment of the present disclosure, the image encoding device (3500) can store a bitstream in a data storage medium including at least one of 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, or a magneto-optical medium such as a floptical disk.

[0465] An image encoding device (3500) can generate a bitstream including syntax elements generated through image encoding. Values ​​corresponding to the syntax elements can be included in the bitstream according to the hierarchical structure of the image.

[0466] The video encoding device (3500) can obtain bins included in a bitstream by entropy encoding syntax elements.

[0467] In one embodiment of the present disclosure, the bitstream may include information about a prediction mode of a current block within a current image.

[0468] In one embodiment of the present disclosure, when the prediction mode of the current block is an intra mode, the bitstream may include information indicating the intra prediction mode of the current block.

[0469] In a prediction mode (e.g., intra mode) that uses reference samples included in a current image, a prediction block of the current block can be generated based on the surrounding samples of the current block according to the intra prediction mode, assuming that there will be continuity between the surrounding samples of the current block and the samples within the current block. An image encoding device (3500) according to an embodiment of the present disclosure can use not only the surrounding samples of the current block included in the current image but also the spatial reference samples included in the current image for intra prediction. When using samples reconstructed before the current block, the size of residual data can be reduced by predicting the samples of the current block using not only the samples immediately adjacent to the current block but also samples far from the current block. In an embodiment of the present disclosure, the image encoding device (3500) performs intra prediction using a reference block including unreconstructed samples, thereby increasing the range of an area that can be determined as a reference block. An image encoding device (3500) according to an embodiment of the present disclosure can improve compression efficiency by increasing the efficiency of intra prediction.

[0470] In a prediction mode (e.g., inter mode) that utilizes reference samples included in a reference image rather than the current image, a prediction block of the current block can be generated based on a reference block (or reference sample) of the reference image according to the prediction mode, under the assumption that there will be continuity between the current image and the reference image. An image encoding device (3500) according to an embodiment of the present disclosure can improve compression efficiency by increasing the efficiency of intra prediction.

[0471] The image encoding device (3500) can improve prediction accuracy by considering both a reference block (or reference sample) included in the current image and a reference block (or reference sample) included in an image other than the current image. The image encoding device (3500) according to one embodiment of the present disclosure can improve prediction accuracy by considering both the current image and an image other than the current image.

[0472] FIG. 36 is a flowchart illustrating an image encoding method according to one embodiment of the present disclosure.

[0473] In one embodiment of the present disclosure, the image encoding method may be performed by the image encoding device (3500). For example, the image encoding device (3500) may perform each step of the image decoding method by having the processor of the image encoding device (3500) execute at least one instruction contained in the memory. For convenience of explanation, the details described through the aforementioned image decoding method are omitted.

[0474] In step S3610, the method may include an operation of obtaining a first prediction block and a second prediction block for the current block. For example, the image encoding device (3500) may obtain a plurality of prediction blocks for the current block.

[0475] In one embodiment of the present disclosure, the image encoding device (3500) may perform prediction on a current block using an inter prediction mode. For example, the image encoding device (3500) may ob...

Claims

1. In the video decryption method, A step of obtaining a first prediction block and a second prediction block for the current block (S2210); A step (S2220) of obtaining a blending template based on a first template of the first prediction block, a second template of the second prediction block, and a current template of the current block; A step (S2230) of obtaining a plurality of weights corresponding to a plurality of samples of the current block based on the blending template; and An image decoding method, comprising a step (S2240) of obtaining a prediction sample of the current block based on the plurality of weights, the first prediction block, and the second prediction block.

2. In paragraph 1, The step (S2220) of obtaining the above blending template is as follows: A step of determining an average of the first template and the second template; A step of determining a sign of the blending template based on a difference between the first template and the second template; An image decoding method comprising a step of obtaining the blending template based on the difference between the current template and the average and the sign of the blending template.

3. In any one of paragraphs 1 and 2, The step (S2220) of obtaining the above blending template is as follows: A step of determining a first difference between the first template and the second template; An image decoding method, comprising the step of obtaining the blending template based on the second difference between the current template and the first template or the second template and the first difference.

4. In any one of paragraphs 1 to 3, The above blending template includes an upper blending template corresponding to the upper template of the current block and a left blending template corresponding to the left template of the current block, The step of obtaining the above multiple weights (S2230) is An image decoding method comprising the step of obtaining a first weight corresponding to the first sample by using an upper blending sample of the upper blending template corresponding to the first sample of the current block and a left blending sample of the left blending template corresponding to the first sample.

5. In paragraph 4, The above upper blending sample has the same x-coordinate as the first sample, The above left blending sample has the same y-coordinate as the above first sample, An image decoding method, characterized in that the first weight is determined as an average of the upper blending sample and the left blending sample.

6. In any one of paragraphs 4 to 5, The step of obtaining the above first weight is: A step of obtaining a vertical weight using a weighted sum between the lower left sample located at the lower side of the left blending template and the upper blending sample; A step of obtaining a horizontal weight using a weighted sum between the upper right sample located on the right side of the upper blending template and the left blending sample; and An image decoding method, comprising a step of determining the first weight using an average of the vertical weight and the horizontal weight.

7. In any one of paragraphs 1 to 6, The step of obtaining the above multiple weights (S2230) is A step of obtaining a predetermined matrix corresponding to at least one of the current template or the blending template; and An image decoding method comprising a step of obtaining the plurality of weights using the above-determined matrix and the blending template.

8. In any one of paragraphs 1 to 7, The step of obtaining the above multiple weights (S2230) is A step of obtaining direction information based on the current template; and An image decoding method, comprising a step of obtaining the plurality of weights based on the direction information and the blending template.

9. In paragraph 8, The current image includes an upper restoration sample set located above the upper left restoration sample of the current block, a left restoration sample set located on the left, a lower restoration sample set located below, and a right restoration sample set located on the right, The step of obtaining the above direction information is: A step of obtaining a first prediction sample for a second set of restored samples corresponding to each of a plurality of directional modes based on a first set of restored samples; selecting a directional mode based on the difference between the first predicted sample and the second restored sample set; and A step of obtaining the direction information corresponding to the selected direction mode is included, The first restoration sample set corresponds to one of the upper restoration sample set, the left restoration sample set, the lower restoration sample set, and the right restoration sample set, An image decoding method, wherein the second restored sample set corresponds to one of the upper restored sample set, the left restored sample set, the lower restored sample set, and the right restored sample set, and is different from the first restored sample set.

10. In paragraph 8, The step of obtaining the above direction information is: A step of obtaining a second prediction sample for the current template corresponding to each of a plurality of intra prediction modes based on the upper restoration sample and the left restoration sample of the current template; selecting a directional mode based on the difference between the second prediction sample and the current template; and An image decoding method, comprising a step of obtaining the direction information corresponding to the selected directional mode.

11. In paragraph 8, The step of obtaining the above direction information is: A step of obtaining first direction information by using the amount of change between a plurality of first samples of the current template; A step of obtaining second direction information by using the variation between a plurality of second samples of the current template; and An image decoding method, comprising a step of obtaining the direction information based on the first direction information and the second direction information.

12. In any one of paragraphs 1 to 11, The step (S2240) of obtaining a prediction sample of the current block is as follows: A step of determining a first prediction sample of the first prediction block and a second prediction sample of the second prediction block corresponding to the prediction sample of the current block; and An image decoding method, comprising a step of obtaining the prediction sample by weighting the first prediction sample and the second prediction sample using a weight corresponding to the first prediction sample or the second prediction sample among a plurality of weights.

13. In the video decryption device, At least one processor (2010) comprising a processing circuit; and A memory (2020) comprising one or more storage media for storing instructions, The image decoding device, by executing the above instructions individually or collectively by the at least one processor (2010), Obtain the first prediction block and the second prediction block for the current block, Obtain a blending template based on a first template of the first prediction block, a second template of the second prediction block, and a current template of the current block, Obtaining multiple weights corresponding to multiple samples of the current block based on the blending template, An image decoding device that obtains a prediction sample of the current block based on the plurality of weights, the first prediction block, and the second prediction block.

14. In the video encoding method, Step (S3610) of obtaining a first prediction block and a second prediction block for the current block; A step (S3620) of obtaining a blending template based on a first template of the first prediction block, a second template of the second prediction block, and a current template of the current block; A step (S3630) of obtaining a plurality of weights corresponding to a plurality of samples of the current block based on the blending template; and An image encoding method, comprising a step (S3640) of obtaining a prediction sample of the current block based on the plurality of weights, the first prediction block, and the second prediction block.

15. In the bitstream transmission method, A step of obtaining a first prediction block and a second prediction block for the current block; A step of obtaining a blending template based on a first template of the first prediction block, a second template of the second prediction block, and a current template of the current block; A step of obtaining a plurality of weights corresponding to a plurality of samples of the current block based on the blending template; A step of obtaining a prediction sample of the current block based on the plurality of weights, the first prediction block, and the second prediction block; generating a bitstream including information about the prediction mode of the current block; and A bitstream transmission method comprising a step of transmitting the generated bitstream to a decoding device.

Citation Information

Patent Citations

  • Picture prediction method and related apparatus

    KR102005007B1

  • A multi camera assembly

    KR1020250145791A

  • System for directly charging battery of photovoltaic module using super-capacitor

    KR1020250156961A

  • Method and apparatus for encoding / decoding image and recording medium for storing bitstream

    KR102595070B1

  • Asymmetric Multi-Level Control of Pulse Generator

    KR102850760B1