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

By optimizing the image encoding/decoding method and using the transformation type and combination to determine the secondary transformation matrix set, the quality and efficiency issues in high-resolution and high-quality image encoding/decoding are solved, and more efficient data transmission and storage are achieved.

CN114600455BActive Publication Date: 2025-10-17ELECTRONICS & TELECOMM RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202080074073.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2020-01-13
Filing Date
2020-11-26
Publication Date
2025-10-17
Estimated Expiration
2040-11-26

AI Technical Summary

Technical Problem

The existing technologies have limitations in objective and subjective image quality in high-resolution and high-quality image encoding/decoding, especially the inefficiency caused by the single transform type and signaling overhead in the transform/inverse transform method.

Method used

The image encoding/decoding process is optimized by determining a reduced set of sub-transform/inverse transform matrices based on whether transform is used, one-dimensional transform type, and two-dimensional transform combination, and deciding whether to perform sub-transform/inverse transform in combination with intra prediction mode, prediction mode, color component, and size.

Benefits of technology

It improves the objective and subjective quality of images, reduces the amount of data, and lowers transmission and storage costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114600455B_ABST
    Figure CN114600455B_ABST
Patent Text Reader

Abstract

A video decoding method is provided in the present disclosure, comprising the steps of: obtaining a transform skip mode flag indicating whether a transform skip mode is applied to a current block; determining that a secondary transform / inverse transform is not applied to the current block when, according to the transform skip mode flag, the transform skip mode is applied to the current block; and obtaining a transform matrix index for the secondary transform / inverse transform of the current block and determining whether the secondary transform / inverse transform is applied to the current block according to the transform matrix index when, according to the transform skip mode flag, the transform skip mode is not applied to the current block.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to an image encoding / decoding method and apparatus and a recording medium for storing a bitstream. More particularly, the present application relates to a method and apparatus for encoding / decoding a video image based on a transform. BACKGROUND

[0002] Recently, the demand for high resolution and high quality images such as high definition (HD) or ultra-high definition (UHD) images has increased in various applications. As the resolution and quality of images increase, the amount of data increases accordingly. This is one of the reasons for an increase in transmission cost and storage cost when image data is transmitted through an existing transmission medium such as a wired or wireless broadband channel or when the image data is stored. In order to solve these problems of high resolution and high quality image data, an efficient image encoding / decoding technique is required.

[0003] There are various video compression techniques such as an inter prediction technique of predicting a value of a pixel in a current picture from values of pixels in a previous picture or a subsequent picture, an intra prediction technique of predicting a value of a pixel in a region of a current picture from values of pixels in another region of the current picture, a transform and quantization technique of compressing energy of a residual signal, and an entropy encoding technique of assigning a shorter code to a frequently occurring pixel value and a longer code to a less frequently occurring pixel value.

[0004] In a conventional transform / inverse transform method, there are limitations in both objective quality and subjective quality of an image because of the use of a single transform / inverse transform type or overhead required for signaling of various transform / inverse transform types. SUMMARY

[0005] TECHNICAL PROBLEM

[0006] In order to improve the objective quality and subjective quality of an image, the present application provides a video encoding / decoding method and apparatus, in which at least one of a reduced secondary transform / inverse transform matrix set, a reduced secondary transform / inverse transform matrix, and whether to perform a reduced secondary transform / inverse transform is determined based on whether a transform is used, a one-dimensional transform type, and at least one of a two-dimensional transform combination, in which whether the transform is used, the one-dimensional transform type, and the two-dimensional transform combination are further based on an intra prediction mode, a prediction mode, a color component, a size, and a form.

[0007] TECHNICAL SOLUTION

[0008] The present disclosure provides a video decoding method, comprising: obtaining a transform skip mode flag indicating whether transform / inverse transform is skipped in a current block; determining that secondary transform / inverse transform is skipped in the current block when transform / inverse transform is skipped in the current block according to the transform skip mode flag; and obtaining a transform matrix index of secondary transform / inverse transform for the current block when transform / inverse transform is not skipped in the current block according to the transform skip mode flag; and determining whether secondary transform / inverse transform is skipped in the current block based on the transform matrix index.

[0009] According to an embodiment, the step of obtaining the transform skip mode flag comprises: obtaining a transform skip mode flag for a luma component, a transform skip mode flag for a Cb component, and a transform skip mode flag for a Cr component.

[0010] According to an embodiment, the step of determining whether secondary transform / inverse transform is skipped in the current block comprises: when a tree structure of the current block is a single tree type, the transform skip mode flag for the luma component indicates that transform skip mode is applied to the luma component, the transform skip mode flag for the Cb component indicates that transform skip mode is applied to the Cb component, and the transform skip mode flag for the Cr component indicates that transform skip mode is applied to the Cr component, determining that secondary transform / inverse transform is skipped in the current block.

[0011] According to an embodiment, the step of determining that secondary transform / inverse transform is skipped in the current block comprises: when the tree structure of the current block is a dual tree luma type, and the transform skip mode flag for the luma component indicates that transform skip mode is applied to the luma component, determining that secondary transform / inverse transform is skipped in the current block.

[0012] According to an embodiment, the step of determining that secondary transform / inverse transform is skipped in the current block comprises: when the tree structure of the current block is a dual tree chroma type, the transform skip mode flag for the Cb component indicates that transform skip mode is applied to the Cb component, and the transform skip mode flag for the Cr component indicates that transform skip mode is applied to the Cr component, determining that secondary transform / inverse transform is skipped in the current block.

[0013] According to an embodiment, the video decoding method can further comprise: when secondary transform / inverse transform is applied to the current block, determining a secondary transform matrix of the current block according to the transform matrix index, and applying secondary transform / inverse transform to the current block according to the secondary transform matrix.

[0014] According to an embodiment, the step of determining the secondary transform matrix of the current block comprises:

[0015] The secondary transform matrix for the current block is determined according to at least one of the transform matrix index, the transform matrix set index of the current block, and the size of the current block.

[0016] According to an embodiment, the video decoding method can further comprise obtaining information on whether an intra residual DPCM method is used, and determining that a transform / inverse transform is skipped in the current block when the information on whether the intra residual DPCM method is used indicates that the intra residual DPCM method is used for the current block, wherein the step of obtaining the transform skip mode flag comprises obtaining the transform skip mode flag when the information on whether the intra residual DPCM method is used indicates that the intra residual DPCM method is not used for the current block.

[0017] According to an embodiment, the transform matrix index of the secondary transform / inverse transform for the current block is obtained when the current block is predicted according to an intra prediction mode that is not a matrix-based intra prediction mode.

[0018] According to an embodiment, the step of determining whether the secondary transform / inverse transform is skipped in the current block according to the transform matrix index comprises determining whether the secondary transform / inverse transform is skipped in the current block according to at least one of the transform matrix index, the size of the current block, and the transform skip mode flag.

[0019] The present disclosure provides a video encoding method, comprising: encoding a transform skip mode flag indicating whether a transform / inverse transform is skipped in a current block; determining that a secondary transform / inverse transform is skipped in the current block when the transform skip mode is skipped in the current block according to the transform skip mode flag; and determining whether the secondary transform / inverse transform is skipped in the current block when the transform skip mode is not skipped in the current block according to the transform skip mode flag; and encoding a transform matrix index of the secondary transform / inverse transform for the current block according to whether the secondary transform / inverse transform is skipped in the current block.

[0020] According to an embodiment, the step of encoding the transform skip mode flag comprises:

[0021] The transform skip mode flag for a luma component, the transform skip mode flag for a Cb component, and the transform skip mode flag for a Cr component are encoded.

[0022] According to an embodiment, the step of determining that the secondary transform / inverse transform is skipped in the current block comprises determining that the secondary transform / inverse transform is skipped in the current block when the tree structure of the current block is a single tree type, the transform skip mode flag for the luma component indicates that the transform skip mode is applied to the luma component, the transform skip mode flag for the Cb component indicates that the transform skip mode is applied to the Cb component, and the transform skip mode flag for the Cr component indicates that the transform skip mode is applied to the Cr component.

[0023] According to an embodiment, the step of determining that the secondary transform / inverse transform is skipped in the current block comprises determining that the secondary transform / inverse transform is skipped in the current block when the tree structure of the current block is a dual tree luma type, and the transform skip mode flag for the luma component indicates that the transform skip mode is applied to the luma component.

[0024] According to an embodiment, the step of determining that the secondary transform / inverse transform is skipped in the current block comprises determining that the secondary transform / inverse transform is skipped in the current block when the tree structure of the current block is a dual tree chroma type, the transform skip mode flag for the Cb component indicates that the transform skip mode is applied to the Cb component, and the transform skip mode flag for the Cr component indicates that the transform skip mode is applied to the Cr component.

[0025] According to an embodiment, the step of encoding the transform matrix index comprises determining a secondary transform matrix of the current block when the secondary transform / inverse transform is applied to the current block, and encoding the transform matrix index according to whether the secondary transform / inverse transform is applied to the current block.

[0026] According to an embodiment, the step of determining a secondary transform matrix of the current block comprises determining the secondary transform matrix of the current block according to at least one of the transform matrix index, the transform matrix set index of the current block, and the size of the current block.

[0027] According to an embodiment, the video coding method can further comprise encoding information on whether an intra residual DPCM method is used for the current block, and determining that the transform / inverse transform is skipped in the current block when the information on whether the intra residual DPCM method is used indicates that the intra residual DPCM method is used for the current block, wherein the step of encoding the transform skip mode flag comprises encoding the transform skip mode flag when the information on whether the intra residual DPCM method is used indicates that the intra residual DPCM method is not used for the current block.

[0028] According to an embodiment, the step of encoding the transform matrix index for the secondary transform / inverse transform of the current block includes encoding the transform matrix index when the current block is predicted according to an intra prediction mode that is not a matrix-based intra prediction mode.

[0029] The present disclosure provides a computer-readable recording medium for storing a bitstream generated by encoding a video using a video encoding method, wherein the video encoding method includes encoding a transform skip mode flag indicating whether a transform / inverse transform is skipped in a current block, determining that a secondary transform / inverse transform is skipped in the current block when a transform skip mode is skipped in the current block according to the transform skip mode flag, and determining whether a secondary transform / inverse transform is skipped in the current block when a transform skip mode is not skipped in the current block according to the transform skip mode flag, and encoding a transform matrix index for a secondary transform / inverse transform of the current block according to whether a secondary transform / inverse transform is skipped in the current block.

[0030] Advantageous Effects

[0031] The present disclosure can improve the objective and subjective quality of an image by providing an image encoding / decoding method and apparatus that determines at least one of a reduced secondary transform / inverse transform matrix set, a reduced secondary transform / inverse transform matrix, and whether to perform a reduced secondary transform / inverse transform based on at least one of whether a transform is used, a one-dimensional transform type, and a two-dimensional transform combination, wherein the whether a transform is used, the one-dimensional transform type, and the two-dimensional transform combination are further based on an intra prediction mode, a prediction mode, a color component, a size, and a form. BRIEF DESCRIPTION OF DRAWINGS

[0032] FIG. 1 FIG. 1 is a block diagram illustrating a configuration of an encoding apparatus according to an embodiment to which the present disclosure is applied.

[0033] FIG. 2 FIG. 2 is a block diagram illustrating a configuration of a decoding apparatus according to an embodiment to which the present disclosure is applied.

[0034] FIG. 3 FIG. 3 is a diagram schematically illustrating a partition structure of an image when the image is encoded and decoded.

[0035] FIG. 4 FIG. 4 is a diagram illustrating an intra prediction process.

[0036] FIG. 5 FIG. 5 is a diagram illustrating an embodiment of an inter prediction process.

[0037] FIG. 6is a diagram illustrating transform and quantization processing.

[0038] FIG. 7 is a diagram showing reference samples that can be used for intra prediction.

[0039] FIG. 8 is a diagram illustrating an embodiment of a decoding method using an SDST method according to the present invention.

[0040] FIG. 9 is a diagram illustrating an embodiment of an encoding method using an SDST method according to the present invention.

[0041] FIG. 10 to FIG. 12 is a diagram illustrating an embodiment of a first subblock partitioning mode according to the present invention.

[0042] FIG. 13 is a diagram illustrating an embodiment of a second subblock partitioning mode according to the present invention.

[0043] FIG. 14 is a diagram illustrating an embodiment of diagonal scanning.

[0044] FIG. 15 is a diagram illustrating an example of horizontal scanning.

[0045] FIG. 16 is a diagram illustrating an embodiment of vertical scanning.

[0046] FIG. 17 is a diagram illustrating an embodiment of block-based diagonal scanning.

[0047] FIG. 18 is a diagram illustrating an embodiment of block-based horizontal scanning.

[0048] FIG. 19 is a diagram illustrating an embodiment of block-based vertical scanning.

[0049] FIG. 20 are diagrams illustrating various embodiments of block-based shape scanning.

[0050] FIG. 21 is a diagram illustrating an intra prediction mode.

[0051] FIG. 22 to FIG. 26 is a diagram illustrating an example of an encoding process or a decoding process using transform according to an embodiment of the present invention.

[0052] FIG. 27 An embodiment is shown in which a sub-transform and / or a sub-inverse transform is performed in an encoder / decoder.

[0053] FIG. 28 An embodiment of a secondary transformation matrix is ​​shown.

[0054] FIG. 29 A reduced secondary transform / inverse transform process is shown.

[0055] FIG. 30 to FIG. 32 Multiple embodiments of deriving a transform matrix according to a block size, a transform matrix set index, and a transform matrix index are shown.

[0056] FIG. 33 to FIG. 36 Syntax of a bitstream of a recording medium storing a bitstream of an encoding / decoding method and apparatus using a transform according to embodiments of the present invention is shown.

[0057] FIG. 37 to FIG. 54 Various embodiments for signaling conditions of a transform matrix index are provided.

[0058] FIG. 55 Syntax of a bitstream of a recording medium storing a bitstream of an encoding / decoding method and apparatus using a transform according to embodiments of the present invention is shown.

[0059] FIG. 56 A video decoding method according to embodiments of the present invention is shown.

[0060] FIG. 57 A video encoding method according to embodiments of the present invention is shown.

[0061] Optimal mode

[0062] The present disclosure provides a video decoding method, comprising: obtaining a transform skip mode flag indicating whether a transform skip mode is applied to a current block; determining, according to the transform skip mode flag, that a secondary transform / inverse transform is not applied to the current block when the transform skip mode is applied to the current block; and obtaining, according to the transform skip mode flag, a transform matrix index for a secondary transform / inverse transform of the current block when the transform skip mode is not applied to the current block, and determining, based on the transform matrix index, whether the secondary transform / inverse transform is applied to the current block. DETAILED DESCRIPTION

[0063] Various modifications can be made to the disclosure and there are many embodiments of the disclosure, of which examples will now be provided with reference to the drawings. However, the disclosure is not limited to the example embodiments, although the example embodiments can be interpreted as including all modifications, equivalents, or alternatives within the technical concept and technical scope of the disclosure. In various aspects, like reference numerals refer to the same or similar functions. In the drawings, the shapes and sizes of elements can be exaggerated for clarity. In the following detailed description of the disclosure, reference is made to the accompanying drawings that illustrate a specific embodiment in which the disclosure can be practiced. These embodiments are described in sufficient detail to enable those skilled in the art to practice the disclosure. It is to be understood that various embodiments of the disclosure, although different, are not necessarily mutually exclusive. For example, a specific feature, structure, or characteristic described herein in connection with one embodiment can be implemented in other embodiments without departing from the spirit and scope of the disclosure. In addition, it is to be understood that the position or arrangement of individual elements within each disclosed embodiment can be modified without departing from the spirit and scope of the disclosure. Therefore, the following detailed description is not to be taken in a limiting sense and the scope of the disclosure is defined only by the appended claims, properly interpreted, along with the full range of equivalents to which the claims are entitled.

[0064] The terms "first", "second", and the like used in the specification can be used to describe various components, but the components should not be construed as being limited to the terms. The terms are used only to distinguish one component from another component. For example, a "first" component can be named a "second" component without departing from the scope of the disclosure, and a "second" component can also be similarly named a "first" component. The term "and / or" includes a combination of a plurality of items or any one of the plurality of items.

[0065] It will be understood that, in this specification, when an element is simply referred to as being "connected to" or "coupled to" another element without being "directly connected to" or "directly coupled to" the other element, the element can be "directly connected to" or "directly coupled to" the other element, or connected or coupled to the other element with other elements interposed therebetween. In contrast, it is to be understood that when an element is referred to as being "directly coupled" or "directly connected" to another element, there is no intervening element.

[0066] Further, the constituent elements shown in the embodiments of the present application are independently shown to represent different characteristic functions from each other. Thus, this does not mean that each of the constituent elements is configured as a separate hardware or software constituent unit. In other words, each of the constituent elements includes each of the enumerated constituent elements for convenience. Thus, at least two of the constituent elements of each of the constituent elements can be combined to form one constituent element, or one constituent element can be divided into multiple constituent elements to perform each function. Embodiments in which each of the constituent elements is combined and embodiments in which one constituent element is divided are also included in the scope of the present application, if it does not depart from the essence of the present application.

[0067] The terms used in the present specification are merely used to describe particular embodiments, and are not intended to limit the present application. Unless otherwise explicitly described, the expression used in the singular encompasses the expression in the plural. In the present specification, it is to be understood that the terms such as "include" of "have" are intended to indicate that there are the features, numbers, steps, actions, elements, parts, or combinations thereof described in the specification, and are not intended to exclude the possibility that there are additional one or more other features, numbers, steps, actions, elements, parts, or combinations thereof. In other words, when a certain element is referred to as being "included", it does not mean that an additional element is excluded, but it is possible that another element is further included in the embodiment of the present application or the scope of the present application.

[0068] Further, some of the constituent elements can not be essential elements to perform the essential functions of the present application, but can be optional elements to improve the performance thereof. The present application can be implemented by including only the essential elements to achieve the nature of the present application, without including the elements to improve the performance. A structure including only the essential elements, without including the optional elements to improve the performance, is also included in the scope of the present application.

[0069] Hereinafter, embodiments of the present application will be described in detail with reference to the accompanying drawings. In describing the exemplary embodiments of the present application, a well-known function or construction will not be described in detail since it can unnecessarily obscure the understanding of the present application. The same constituent elements in the drawings are designated by the same reference numerals and repeated description of the same elements will be omitted.

[0070] Hereinafter, an image can refer to a picture constituting a video, or can refer to a video itself. For example, "encoding or decoding or both encoding and decoding an image" can refer to "encoding or decoding or both encoding and decoding a moving picture", and can refer to "encoding or decoding or both encoding and decoding one of the pictures of a moving picture".

[0071] Hereinafter, the terms "moving picture" and "video" can be used as the same meaning and can be replaced with each other.

[0072] Hereinafter, a target image can be an encoding target image as an encoding target and / or a decoding target image as a decoding target. Also, the target image can be an input image input to an encoding apparatus and an input image input to a decoding apparatus. Here, the target image can have the same meaning as a current image.

[0073] Hereinafter, the terms "image", "picture", "frame", and "screen" can be used as the same meaning and can be replaced with each other.

[0074] Hereinafter, a target block can be an encoding target block as an encoding target and / or a decoding target block as a decoding target. Also, the target block can be a current block as a target of current encoding and / or decoding. For example, the terms "target block" and "current block" can be used as the same meaning and can be replaced with each other.

[0075] Hereinafter, the terms "block" and "unit" can be used as the same meaning and can be replaced with each other. Or, the "block" can mean a specific unit.

[0076] Hereinafter, the terms "region" and "segment" can be replaced with each other.

[0077] Hereinafter, a specific signal can be a signal representing a specific block. For example, an original signal can be a signal representing a target block. A prediction signal can be a signal representing a prediction block. A residual signal can be a signal representing a residual block.

[0078] In an embodiment, each of a specific information, data, flag, index, element, and attribute, etc. can have a value. A value of the information, data, flag, index, element, and attribute, etc. equal to "0" can mean a logical false or a first predefined value. In other words, the value "0", false, logical false, and the first predefined value can be replaced with each other. A value of the information, data, flag, index, element, and attribute, etc. equal to "1" can mean a logical true or a second predefined value. In other words, the value "1", true, logical true, and the second predefined value can be replaced with each other.

[0079] When a variable i or j is used to represent a column, a row, or an index, a value of i can be an integer equal to or greater than 0, or an integer equal to or greater than 1. That is, the column, the row, the index, etc. can be counted from 0, or can be counted from 1.

[0080] Description of terms

[0081] Encoder: means an apparatus performing encoding. That is, means an encoding apparatus.

[0082] Decoder: means an apparatus performing decoding. That is, means a decoding apparatus.

[0083] Block: is an array of samples of MxN. Here, M and N can represent positive integers, and the block can represent an array of samples in two-dimensional form. The block can refer to a unit. The current block can represent a coding target block that becomes a target at the time of encoding, or a decoding target block that becomes a target at the time of decoding. In addition, the current block can be at least one of a coding block, a prediction block, a residual block, and a transform block.

[0084] Sample: is a basic unit constituting a block. According to a bit depth (Bd), the sample can be represented as a value from 0 to 2 Bd -1. In the present invention, the sample can be used as the meaning of a pixel. That is, the sample, pel, pixel can have the same meaning as each other.

[0085] Unit: can refer to a coding and decoding unit. When an image is encoded and decoded, the unit can be an area generated by partitioning a single image. In addition, when a single image is partitioned into sub-partition units during encoding or decoding, the unit can represent a sub-partition unit. That is, an image can be partitioned into a plurality of units. When an image is encoded and decoded, a predetermined process for each unit can be performed. A single unit can be partitioned into sub-units having a size smaller than that of the unit. According to a function, the unit can represent a block, a macroblock, a coding tree unit, a coding tree block, a coding unit, a coding block, a prediction unit, a prediction block, a residual unit, a residual block, a transform unit, a transform block, etc. In addition, in order to distinguish the unit from the block, the unit can include a luma component block, a chroma component block associated with the luma component block, and a syntax element of each color component block. The unit can have various sizes and shapes, and specifically, the shape of the unit can be a two-dimensional geometric figure such as a square, a rectangle, a trapezoid, a triangle, a pentagon, etc. In addition, unit information can include at least one of a unit type indicating a coding unit, a prediction unit, a transform unit, etc., and a unit size, a unit depth, an order of coding and decoding of the unit, etc.

[0086] Coding tree unit: is configured with a single coding tree block of a luma component Y and two coding tree blocks related to chroma components Cb and Cr. In addition, the coding tree unit can represent a block and a syntax element of each block. A lower-level unit such as a coding unit, a prediction unit, a transform unit, etc. can be configured by partitioning each coding tree unit using at least one of a quad-tree partitioning method, a binary-tree partitioning method, and a ternary-tree partitioning method. The coding tree unit can be used as a term for designating a sample block that becomes a processing unit at the time of encoding / decoding an image as an input image. Here, the quad-tree can represent a quad.

[0087] When the size of the coding block is within a predetermined range, it is possible to perform division using only the quad-tree partitioning. Here, the predetermined range can be defined as at least one of a maximum size and a minimum size of the coding block that can be divided using only the quad-tree partitioning. Information indicating the maximum / minimum size of the coding block that allows the quad-tree partitioning can be signaled through a bitstream, and the information can be signaled in at least one of a sequence, a picture parameter, a parallel block group, or a slice (segment). Alternatively, the maximum / minimum size of the coding block can be a fixed size predetermined in an encoder / decoder. For example, when the size of the coding block corresponds to 256x256 to 64x64, it is possible to perform division using only the quad-tree partitioning. Alternatively, when the size of the coding block is greater than the size of the maximum transform block, it is possible to perform division using only the quad-tree partitioning. Here, the block to be divided can be at least one of the coding block and the transform block. In this case, information (e.g., split_flag) indicating the division of the coding block can be a flag indicating whether the quad-tree partitioning is performed. When the size of the coding block falls within a predetermined range, it is possible to perform division using only the binary or ternary tree partitioning. In this case, the above description of the quad-tree partitioning can be applied to the binary or ternary tree partitioning in the same manner.

[0088] coding tree block: can be used as a term for specifying any one of a Y coding tree block, a Cb coding tree block, and a Cr coding tree block.

[0089] neighboring block: can mean a block adjacent to a current block. The block adjacent to the current block can mean a block in contact with a boundary of the current block, or a block located within a predetermined distance from the current block. The neighboring block can mean a block adjacent to a vertex of the current block. Here, the block adjacent to the vertex of the current block can mean a block vertically adjacent to a neighboring block horizontally adjacent to the current block, or a block horizontally adjacent to a neighboring block vertically adjacent to the current block.

[0090] reconstructed neighboring block: can mean a neighboring block adjacent to a current block and having been spatially / temporally encoded or decoded. Here, the reconstructed neighboring block can mean a reconstructed neighboring unit. The reconstructed spatial neighboring block can be a block within a current picture and having been reconstructed through encoding or decoding, or both encoding and decoding. The reconstructed temporal neighboring block is a block or a neighboring block of the block at a position corresponding to a current block of a current picture within a reference picture.

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

[0092] Bitstream: can represent a bitstream including encoded image information.

[0093] Parameter set: corresponds to header information among configurations within a bitstream. At least one of a video parameter set, a sequence parameter set, a picture parameter set, and an adaptation parameter set can be included in the parameter set. Also, the parameter set can include slice header, tile group header, and tile header information. The term "tile group" represents a group of tiles and has the same meaning as a slice.

[0094] Adaptation parameter set can represent a parameter set that can be shared by being referred to in different pictures, sub-pictures, slices, tile groups, tiles, or bricks. Also, information in the adaptation parameter set can be used by referring to different adaptation parameter sets for sub-pictures, slices, tile groups, tiles, or bricks within a picture.

[0095] Also, with respect to the adaptation parameter set, different adaptation parameter sets can be referred to by using identifiers for different adaptation parameter sets for sub-pictures, slices, tile groups, tiles, or bricks within a picture.

[0096] Also, with respect to the adaptation parameter set, different adaptation parameter sets can be referred to by using identifiers for different adaptation parameter sets for slices, tile groups, tiles, or bricks within a sub-picture.

[0097] Also, with respect to the adaptation parameter set, different adaptation parameter sets can be referred to by using identifiers for different adaptation parameter sets for tiles or bricks within a slice.

[0098] Also, with respect to the adaptation parameter set, different adaptation parameter sets can be referred to by using identifiers for different adaptation parameter sets for bricks within a tile.

[0099] Information on an adaptive parameter set identifier can be included in a parameter set or a header of a sub-picture, and an adaptive parameter set corresponding to the adaptive parameter set identifier can be used for the sub-picture.

[0100] Information on an adaptive parameter set identifier can be included in a parameter set or a header of a parallel block, and an adaptive parameter set corresponding to the adaptive parameter set identifier can be used for the parallel block.

[0101] Information on an adaptive parameter set identifier can be included in a header of a tile, and an adaptive parameter set corresponding to the adaptive parameter set identifier can be used for the tile.

[0102] A picture can be partitioned into one or more parallel block rows and one or more parallel block columns.

[0103] A sub-picture can be partitioned into one or more parallel block rows and one or more parallel block columns within a picture. The sub-picture can be a region having a rectangular / square form within the picture, and can include one or more CTUs. In addition, at least one or more parallel blocks / tiles / stripes can be included within one sub-picture.

[0104] A parallel block can be a region having a rectangular / square form within a picture, and can include one or more CTUs. In addition, the parallel block can be partitioned into one or more tiles.

[0105] A tile can represent one or more CTU rows within a parallel block. The parallel block can be partitioned into one or more tiles, and each tile can have at least one or more CTU rows. A parallel block that is not partitioned into two or more can represent a tile.

[0106] A stripe can include one or more parallel blocks within a picture, and can include one or more tiles within the parallel blocks.

[0107] Parsing: can mean determining a value of a syntax element by performing entropy decoding, or can mean entropy decoding itself.

[0108] Symbol: can mean at least one of a syntax element, a coding parameter, and a transform coefficient value of a coding / decoding target unit. In addition, the symbol can mean an entropy coding target or an entropy decoding result.

[0109] Prediction mode: can be information indicating a mode coded / decoded using intra prediction or a mode coded / decoded using inter prediction.

[0110] Prediction unit: can mean a basic unit when performing prediction such as inter prediction, intra prediction, inter compensation, intra compensation, and motion compensation. A single prediction unit can be partitioned into multiple partitions having smaller sizes, or can be partitioned into multiple lower-level prediction units. The multiple partitions can be basic units when performing prediction or compensation. The partitions generated by partitioning the prediction unit can also be prediction units.

[0111] Prediction unit partition: can mean a shape obtained by partitioning a prediction unit.

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

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

[0114] Prediction list utilization flag: can mean whether at least one reference picture in a specific reference picture list is used to generate a prediction block. The prediction list utilization flag can be used to derive the inter prediction indicator, and conversely, the inter prediction indicator can be used to derive the prediction list utilization flag. For example, when the prediction list utilization flag has a first value of zero (0), it means that the reference picture in the reference picture list is not used to generate the prediction block. On the other hand, when the prediction list utilization flag has a second value of one (1), it means that the reference picture list is used to generate the prediction block.

[0115] Reference picture index: can mean an index indicating a specific reference picture in a reference picture list.

[0116] Reference picture: can mean a reference picture referred to by a specific block for the purpose of inter prediction or motion compensation of the specific block. Alternatively, the reference picture can be a picture including a reference block referred to by the current block for the purpose of inter prediction or motion compensation. Hereinafter, the terms "reference picture" and "reference image" have the same meaning and are interchangeable.

[0117] Motion vector: can be a two-dimensional vector used for inter prediction or motion compensation. The motion vector can mean an offset between a coding / decoding target block and a reference block. For example, (mvX, mvY) can mean a motion vector. Here, mvX can mean a horizontal component, and mvY can mean a vertical component.

[0118] A search range can be a two-dimensional region searched during inter prediction to retrieve a motion vector. For example, the size of the search range can be MxN. Here, M and N are both integers.

[0119] A motion vector candidate can refer to a prediction candidate block or a motion vector of a prediction candidate block when a motion vector is predicted. Also, a motion vector candidate can be included in a motion vector candidate list.

[0120] A motion vector candidate list can denote a list consisting of one or more motion vector candidates.

[0121] A motion vector candidate index can denote an indicator indicating a motion vector candidate in a motion vector candidate list. Alternatively, it can be an index of a motion vector predictor.

[0122] Motion information can denote information including at least one of items including a motion vector, a reference picture index, an inter prediction indicator, a prediction list utilization flag, reference picture list information, a reference picture, a motion vector candidate, a motion vector candidate index, a merge candidate, and a merge index.

[0123] A merge candidate list can denote a list consisting of one or more merge candidates.

[0124] A merge candidate can denote a spatial merge candidate, a temporal merge candidate, a combined merge candidate, a combined bi-predictive merge candidate, or a zero merge candidate. A merge candidate can include motion information such as an inter prediction indicator, a reference picture index per list, a motion vector, a prediction list utilization flag, and an inter prediction indicator.

[0125] A merge index can denote an indicator indicating a merge candidate in a merge candidate list. Alternatively, a merge index can indicate a block in a reconstructed block spatially / temporally neighboring a current block, wherein the merge candidate has been derived from the block. Alternatively, a merge index can indicate at least one piece of motion information of a merge candidate.

[0126] A transform unit: can denote a basic unit when encoding / decoding a residual signal such as a transform, an inverse transform, a quantization, a dequantization, a transform coefficient encoding / decoding. A single transform unit can be partitioned into a plurality of lower-level transform units having smaller sizes. Here, a transform / inverse transform can include at least one of a first transform / first inverse transform and a second transform / second inverse transform.

[0127] Scaling: can denote a process of multiplying a quantized level by a factor. A transform coefficient can be generated by scaling a quantized level. Scaling can also be referred to as dequantization.

[0128] Quantization parameter: can denote a value used when generating quantized levels using transform coefficients during quantization. The quantization parameter can also denote a value used when generating transform coefficients by scaling quantized levels during inverse quantization. The quantization parameter can be a value mapped on a quantization step.

[0129] Delta quantization parameter: can denote a difference value between a predicted quantization parameter and a quantization parameter of a coding / decoding target unit.

[0130] Scan: can denote a method of ordering coefficients within a unit, a block, or a matrix. For example, changing a two-dimensional matrix of coefficients into a one-dimensional matrix can be referred to as a scan, and changing a one-dimensional matrix of coefficients into a two-dimensional matrix can be referred to as a scan or inverse scan.

[0131] Transform coefficient: can denote a coefficient value generated after performing a transform in an encoder. The transform coefficient can denote a coefficient value generated after performing at least one of entropy decoding and inverse quantization in a decoder. A quantized level obtained by quantizing a transform coefficient or a residual signal or a quantized transform coefficient level can also fall within the meaning of a transform coefficient.

[0132] Quantized level: can denote a value generated by quantizing a transform coefficient or a residual signal in an encoder. Alternatively, the quantized level can denote a value that is an inverse quantization target that undergoes inverse quantization in a decoder. Similarly, a quantized transform coefficient level that is a result of a transform and quantization can also fall within the meaning of a quantized level.

[0133] Non-zero transform coefficient: can denote a transform coefficient having a value other than zero, or a transform coefficient level or a quantized level having a value other than zero.

[0134] Quantization matrix: can denote a matrix used in a quantization process or an inverse quantization process performed for improving subjective image quality or objective image quality. The quantization matrix can also be referred to as a scaling list.

[0135] Quantization matrix coefficient: can denote each element within a quantization matrix. The quantization matrix coefficient can also be referred to as a matrix coefficient.

[0136] Default matrix: can denote a predetermined quantization matrix that is predefined in an encoder or a decoder.

[0137] Non-default matrix: can denote a quantization matrix that is not predefined in an encoder or a decoder but is signaled by a user.

[0138] Statistical value: a statistical value for at least one among a variable having a specific value that can be calculated, a coding parameter, a constant value, etc. can be one or more among an average value, a summation value, a weighted average value, a weighted summation value, a minimum value, a maximum value, a most frequently occurring value, a median value, an interpolation value, etc. corresponding to the specific value.

[0139] FIG. 1 is a block diagram illustrating a configuration of an encoding apparatus according to an embodiment to which the present application is applied.

[0140] The encoding apparatus 100 can be an encoder, a video encoding apparatus, or an image encoding apparatus. The video can include at least one image. The encoding apparatus 100 can sequentially encode the at least one image.

[0141] Referring to FIG. 1 , the encoding apparatus 100 can include a motion prediction unit 111, a motion compensation unit 112, an intra prediction unit 120, a switch 115, a subtractor 125, a transform unit 130, a quantization unit 140, an entropy encoding unit 150, a dequantization unit 160, an inverse transform unit 170, an adder 175, a filter unit 180, and a reference picture buffer 190.

[0142] The encoding apparatus 100 can perform encoding of an input image by using an intra mode or an inter mode or both the intra mode and the inter mode. Further, the encoding apparatus 100 can generate a bitstream including encoded information by encoding the input image, and output the generated bitstream. The generated bitstream can be stored in a computer-readable recording medium, or can be streamed through a wired / wireless transmission medium. When the intra mode is used as a prediction mode, the switch 115 can be switched to intra. Alternatively, when the inter mode is used as the prediction mode, the switch 115 can be switched to the inter mode. Here, the intra mode can denote an intra prediction mode, and the inter mode can denote an inter prediction mode. The encoding apparatus 100 can generate a prediction block for an input block of an input image. Further, the encoding apparatus 100 can encode a residual block using a residual of the input block and the prediction block after the prediction block is generated. The input image can be referred to as a current image which is a current encoding target. The input block can be referred to as a current block which is a current encoding target, or as an encoding target block.

[0143] When the prediction mode is the intra mode, the intra prediction unit 120 can use samples of a block which has been encoded / decoded and is adjacent to the current block as reference samples. The intra prediction unit 120 can perform spatial prediction on the current block by using the reference samples, or generate prediction samples of the input block by performing the spatial prediction. Here, the intra prediction can denote prediction within a frame.

[0144] When the prediction mode is the inter mode, the motion prediction unit 111 can retrieve a region most matching the input block from a reference picture when performing motion prediction, and derive a motion vector by using the retrieved region. In this case, the search region can be used as the region. The reference picture can be stored in the reference picture buffer 190. Here, when encoding / decoding of the reference picture is performed, the reference picture can be stored in the reference picture buffer 190.

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

[0146] When a value of the motion vector is not an integer, the motion prediction unit 111 and the motion compensation unit 112 can generate a prediction block by applying an interpolation filter to a partial region of a reference picture. In order to perform inter-picture prediction or motion compensation on a coding unit, it can be determined which mode among a skip mode, a merge mode, an advanced motion vector prediction (AMVP) mode, and a current picture reference mode is used for motion prediction and motion compensation of a prediction unit included in the corresponding coding unit. Then, according to the determined mode, the inter-picture prediction or the motion compensation can be differently performed.

[0147] The subtractor 125 can generate a residual block by using a difference between the input block and the prediction block. The residual block can be referred to as a residual signal. The residual signal can mean a difference between an original signal and a prediction signal. Also, the residual signal can be a signal generated by transforming or quantizing or transforming and quantizing a difference between the original signal and the prediction signal. The residual block can be a residual signal of a block unit.

[0148] The transform unit 130 can generate transform coefficients by performing a transform on the residual block, and output the generated transform coefficients. Here, the transform coefficients can be coefficient values generated by performing a transform on the residual block. When a transform skip mode is applied, the transform unit 130 can skip the transform on the residual block.

[0149] A quantized level can be generated by applying quantization to the transform coefficients or to the residual signal. Hereinafter, the quantized level can also be referred to as a transform coefficient in an embodiment.

[0150] The quantization unit 140 can generate a quantized level by quantizing the transform coefficients or the residual signal according to a parameter, and output the generated quantized level. Here, the quantization unit 140 can quantize the transform coefficients by using a quantization matrix.

[0151] The entropy encoding unit 150 can generate a bitstream by performing entropy encoding on the values calculated by the quantization unit 140 or on the encoding parameter values calculated when encoding is performed according to a probability distribution, and output the generated bitstream. The entropy encoding unit 150 can perform entropy encoding on the sample information of the image and information used to decode the image. For example, the information used to decode the image can include syntax elements.

[0152] When entropy encoding is applied, the symbols are represented such that a smaller number of bits is allocated to symbols having a high generation probability, and a larger number of bits is allocated to symbols having a low generation probability, and thus, the size of the bitstream of the symbols to be encoded can be reduced. The entropy encoding unit 150 can use an encoding method for entropy encoding such as exponential Golomb, context adaptive variable length coding (CAVLC), context adaptive binary arithmetic coding (CABAC), or the like. For example, the entropy encoding unit 150 can perform entropy encoding by using a variable length coding / code (VLC) table. Furthermore, the entropy encoding unit 150 can derive a binarization method of a target symbol and a probability model of the target symbol / binary bit, and perform arithmetic encoding by using the derived binarization method and context model.

[0153] In order to encode the transform coefficient levels (quantized levels), the entropy encoding unit 150 can change the coefficients in the form of a two-dimensional block into the form of a one-dimensional vector by using a transform coefficient scanning method.

[0154] The coding parameters can include information such as syntax elements (flags, indices, etc.) that are coded in the encoder and signaled to the decoder, and information derived when performing encoding or decoding. The coding parameters can represent information needed when encoding or decoding an image. For example, at least one value or combination of the following can be included in the coding parameters: unit / block size, unit / block depth, unit / block partition information, unit / block shape, unit / block partition structure, whether partitioning in a quad-tree form is performed, whether partitioning in a binary tree form is performed, partitioning direction in a binary tree form (horizontal direction or vertical direction), partitioning form in a binary tree form (symmetric partitioning or asymmetric partitioning), whether the current coding unit is partitioned by triple tree partitioning, triple tree partitioning direction (horizontal direction or vertical direction), triple tree partitioning type (symmetric type or asymmetric type), whether the current coding unit is partitioned by multi-type tree partitioning, multi-type tree partitioning direction (horizontal direction or vertical direction), multi-type tree partitioning type (symmetric type or asymmetric type), multi-type tree partitioning tree (binary tree or triple tree) structure, prediction mode (intra prediction or inter prediction), luma intra prediction mode / direction, chroma intra prediction mode / direction, intra partition information, inter partition information, coding block partition flag, prediction block partition flag, transform block partition flag, reference sample filtering method, reference sample filter tap, reference sample filter coefficient, prediction block filtering method, prediction block filter tap, prediction block filter coefficient, prediction block boundary filtering method, prediction block boundary filter tap, prediction block boundary filter coefficient, intra prediction mode, inter prediction mode, motion information, motion vector, motion vector difference, reference picture index, inter prediction angle, inter prediction indicator, prediction list utilization flag, reference picture list, reference picture, motion vector predictor index, motion vector predictor candidate, motion vector candidate list, whether to use merge mode, merge index, merge candidate, merge candidate list, whether to use skip mode, interpolation filter type, interpolation filter tap, interpolation filter coefficient, motion vector size, representation precision of motion vector, transform type, transform size, information whether primary (first) transform is used, information whether secondary transform is used, primary transform index, secondary transform index, information whether residual signal exists, coding block pattern, coding block flag (CBF), quantization parameter, quantization parameter residual, quantization matrix, whether to apply intra loop filter, intra loop filter coefficient, intra loop filter tap, intra loop filter shape / form, whether to apply deblocking filter, deblocking filter coefficient, deblocking filter tap, deblocking filter strength, deblocking filter shape / form, whether to apply adaptive sample offset, adaptive sample offset value, adaptive sample offset class, adaptive sample offset type, whether to apply adaptive in-loop filter, adaptive in-loop filter coefficient, adaptive in-loop filter tap, adaptive in-loop filter shape / form,binarization / de-binarization method, context model determination method, context model update method, whether to perform normal mode, whether to perform bypass mode, context bin, bypass bin, significant coefficient flag, last significant coefficient flag, coding flag for a unit of coefficient group, position of last significant coefficient, flag on whether a value of a coefficient is greater than 1, flag on whether a value of a coefficient is greater than 2, flag on whether a value of a coefficient is greater than 3, information on remaining coefficient values, sign information, reconstructed luma sample, reconstructed chroma sample, residual luma sample, residual chroma sample, luma transform coefficient, chroma transform coefficient, quantized luma level, quantized chroma level, transform coefficient level scanning method, size of motion vector search region at decoder side, shape of motion vector search region at decoder side, number of times of motion vector search at decoder side, information on CTU size, information on minimum block size, information on maximum block size, information on maximum block depth, information on minimum block depth, image display / output order, slice identification information, slice type, slice partition information, parallel block identification information, parallel block type, parallel block partition information, parallel block group identification information, parallel block group type, parallel block group partition information, picture type, bit depth of input sample, bit depth of reconstructed sample, bit depth of residual sample, bit depth of transform coefficient, bit depth of quantized level, and information on luma signal or information on chroma signal.

[0155] Here, signaling a flag or an index can mean that the corresponding flag or index is entropy coded by the encoder and included in the bitstream, and can mean that the corresponding flag or index is entropy decoded from the bitstream by the decoder.

[0156] When the encoding apparatus 100 performs encoding through inter prediction, the encoded current picture can be used as a reference picture for another picture which is processed later. Accordingly, the encoding apparatus 100 can reconstruct or decode the encoded current picture, or store the reconstructed or decoded picture in the reference picture buffer 190 as a reference picture.

[0157] The quantized level can be dequantized in the dequantization unit 160, or can be inverse transformed in the inverse transform unit 170. The coefficient which is dequantized or inverse transformed or both can be added to the prediction block by the adder 175. By adding the coefficient which is dequantized or inverse transformed or both to the prediction block, the reconstructed block can be generated. Here, the coefficient which is dequantized or inverse transformed or both can mean a coefficient which has undergone at least one of dequantization and inverse transformation, and can mean a reconstructed residual block.

[0158] The reconstructed block can pass through a filter unit 180. The filter unit 180 can apply at least one of a deblocking filter, a sample adaptive offset (SAO), and an adaptive loop filter (ALF) to the reconstructed sample, the reconstructed block, or the reconstructed picture. The filter unit 180 can be referred to as an in-loop filter.

[0159] The deblocking filter can remove block distortion generated in a boundary between blocks. In order to determine whether to apply the deblocking filter, it can be determined whether to apply the deblocking filter to the current block based on samples included in a number of rows or columns included in the block. When the deblocking filter is applied to the block, another filter can be applied according to a required deblocking filter strength.

[0160] In order to compensate for encoding errors, a suitable offset value can be added to a sample value by using a sample adaptive offset. The sample adaptive offset can correct an offset of a de-blocked picture from an original picture in units of samples. A method of applying an offset considering edge information about each sample can be used, or a method of partitioning samples of a picture into a predetermined number of regions, determining a region to which an offset is applied, and applying the offset to the determined region can be used.

[0161] The adaptive loop filter can perform filtering based on a comparison result of a filtered reconstructed picture and an original picture. Samples included in the picture can be partitioned into a predetermined group, a filter to be applied to each group can be determined, and differential filtering can be performed on each group. Information on whether to apply the ALF can be signaled through a coding unit (CU), and a form and coefficients of the ALF to be applied to each block can vary.

[0162] The reconstructed block or the reconstructed picture that has passed through the filter unit 180 can be stored in a reference picture buffer 190. The reconstructed block processed by the filter unit 180 can be a part of a reference picture. That is, the reference picture is a reconstructed picture composed of the reconstructed blocks processed by the filter unit 180. The stored reference picture can be used later in inter prediction or motion compensation.

[0163] FIG. 2 FIG. 1 is a block diagram illustrating a configuration of a decoding apparatus according to an embodiment and to which the present application is applied.

[0164] The decoding apparatus 200 can be a decoder, a video decoding apparatus, or a picture decoding apparatus.

[0165] Referring to FIG. 2 , the decoding apparatus 200 can include an entropy decoding unit 210, an inverse quantization unit 220, an inverse transform unit 230, an intra prediction unit 240, a motion compensation unit 250, a summer 255, a filter unit 260, and a reference picture buffer 270.

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

[0167] When the prediction mode used at the time of decoding is the intra mode, the switch can be switched to the intra. Alternatively, when the prediction mode used at the time of decoding is the inter mode, the switch can be switched to the inter mode.

[0168] The decoding apparatus 200 can obtain a reconstructed residual block by decoding an input bitstream, and generate a prediction block. When the reconstructed residual block and the prediction block are obtained, the decoding apparatus 200 can generate a reconstructed block that is a decoding target by adding the reconstructed residual block to the prediction block. The decoding target block can be referred to as a current block.

[0169] The entropy decoding unit 210 can generate a symbol by entropy-decoding a bitstream according to a probability distribution. The generated symbol can include a quantized level form of a symbol. Here, the entropy-decoding method can be inverse processing of the above-described entropy-encoding method.

[0170] In order to decode a transform coefficient level (quantized level), the entropy decoding unit 210 can change a coefficient in a one-dimensional vector form to a two-dimensional block form by using a transform coefficient scanning method.

[0171] The quantized level can be inverse quantized in the inverse quantization unit 220, or can be inverse transformed in the inverse transform unit 230. The quantized level can be a result of inverse quantization or inverse transformation, or both inverse quantization and inverse transformation, and can be generated as a reconstructed residual block. Here, the inverse quantization unit 220 can apply a quantization matrix to the quantized level.

[0172] When the intra mode is used, the intra prediction unit 240 can generate a prediction block by performing spatial prediction on the current block, in which the spatial prediction uses sample values of blocks adjacent to the decoding target block and already decoded.

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

[0174] The adder 255 can generate a reconstructed block by adding the reconstructed residual block to the prediction block. The filter unit 260 can apply at least one of a deblocking filter, a sample adaptive offset, and an adaptive loop filter to the reconstructed block or the reconstructed picture. The filter unit 260 can output the reconstructed picture. The reconstructed block or the reconstructed picture can be stored in the reference picture buffer 270 and used when performing inter prediction. The reconstructed block processed by the filter unit 260 can be a part of a reference picture. That is, the reference picture is a reconstructed picture composed of the reconstructed blocks processed by the filter unit 260. The stored reference picture can be used later in inter prediction or motion compensation.

[0175] FIG. 3 FIG. 1 is a diagram schematically illustrating a partition structure of a picture when encoding and decoding the picture. FIG. 3 FIG. 2 schematically illustrates an example of partitioning a single unit into a plurality of lower-level units.

[0176] To effectively partition a picture, a coding unit (CU) can be used when encoding and decoding. The coding unit can be used as a basic unit when encoding / decoding a picture. Also, the coding unit can be used as a unit for distinguishing an intra prediction mode from an inter prediction mode when encoding / decoding a picture. The coding unit can be a basic unit for prediction, transform, quantization, inverse transform, dequantization, or encoding / decoding processing of transform coefficients.

[0177] Referring to FIG. 3 , the picture 300 is sequentially partitioned in a maximum coding unit (LCU) and the LCU unit is determined as a partition structure. Here, the LCU can be used in the same meaning as a coding tree unit (CTU). The unit partitioning can denote partitioning of a block associated with the unit. In the block partitioning information, information of a unit depth can be included. The depth information can denote either or both of a number or degree of partitioning of a unit or a number and degree of partitioning of a unit. A single unit can be partitioned into a plurality of lower-level units hierarchically associated with the depth information based on a tree structure. In other words, the unit and the lower-level units generated by partitioning the unit can correspond to a node and child nodes of the node, respectively. Each of the partitioned lower-level units can have the depth information. The depth information can be information denoting a size of a CU and can be stored in each CU. The unit depth denotes a number and / or degree related to partitioning of a unit. Accordingly, the partitioning information of the lower-level units can include information on a size of the lower-level units.

[0178] The partition structure can represent a distribution of coding units (CUs) within the LCU 310. The distribution can be determined according to whether a single CU is partitioned into a plurality of CUs (including a positive integer equal to or greater than 2, such as 2, 4, 8, 16, etc.). The horizontal and vertical sizes of the CUs generated by the partitioning can be half of the horizontal and vertical sizes of the CU before the partitioning, respectively, or can have sizes smaller than the horizontal and vertical sizes before the partitioning, respectively, according to the number of times of partitioning. The CU can be recursively partitioned into a plurality of CUs. At least one of the height and width of the CU after the partitioning can be reduced compared to at least one of the height and width of the CU before the partitioning by the recursive partitioning. The partitioning of the CU can be recursively performed until a predefined depth or a predefined size. For example, the depth of the LCU can be 0, and the depth of a smallest coding unit (SCU) can be a predefined maximum depth. Here, as described above, the LCU can be a coding unit having a maximum coding unit size, and the SCU can be a coding unit having a minimum coding unit size. The partitioning starts from the LCU 310, and the CU depth is increased by 1 when the horizontal size or the vertical size, or both, of the CU is reduced by the partitioning. For example, for each depth, the size of the CU that is not partitioned can be 2Nx2N. Also, in the case of the CU that is partitioned, the CU having a size of 2Nx2N can be partitioned into four CUs having a size of NxN. As the depth is increased by 1, the size of N can be halved.

[0179] Also, information on whether the CU is partitioned can be represented by using partitioning information of the CU. The partitioning information can be 1-bit information. All CUs except for the SCU can include the partitioning information. For example, when the value of the partitioning information is a first value, the CU can not be partitioned, and when the value of the partitioning information is a second value, the CU can be partitioned.

[0180] Referring to FIG. 3 The LCU having a depth of 0 can be a 64x64 block. 0 can be a minimum depth. The SCU having a depth of 3 can be an 8x8 block. 3 can be a maximum depth. The CUs of the 32x32 block and the 16x16 block can be represented as depths 1 and 2, respectively.

[0181] For example, when a single coding unit is partitioned into four coding units, the horizontal and vertical sizes of the partitioned four coding units can be half the size of the horizontal and vertical sizes of the CU before being partitioned. In one embodiment, when a coding unit having a size of 32x32 is partitioned into four coding units, each of the partitioned four coding units can have a size of 16x16. When a single coding unit is partitioned into four coding units, the coding unit can be said to be partitioned in a quad-tree form.

[0182] For example, when one coding unit is partitioned into two sub-coding units, each of the two sub-coding units can have a horizontal size or a vertical size (width or height) that is half of the horizontal size or the vertical size of the original coding unit. For example, when a coding unit having a size of 32x32 is vertically partitioned into two sub-coding units, each of the two sub-coding units can have a size of 16x32. For example, when a coding unit having a size of 8x32 is horizontally partitioned into two sub-coding units, each of the two sub-coding units can have a size of 8x16. When one coding unit is partitioned into two sub-coding units, the coding unit can be referred to as being bipartitioned or partitioned according to a binary tree partitioning structure.

[0183] For example, when one coding unit is partitioned into three sub-coding units, the horizontal size or the vertical size of the coding unit can be partitioned in a ratio of 1:2:1, thereby resulting in three sub-coding units having a ratio of 1:2:1 in horizontal size or vertical size. For example, when a coding unit having a size of 16x32 is horizontally partitioned into three sub-coding units, the three sub-coding units can have sizes of 16x8, 16x16, and 16x8, respectively, in order from the topmost sub-coding unit to the bottommost sub-coding unit. For example, when a coding unit having a size of 32x32 is vertically partitioned into three sub-coding units, the three sub-coding units can have sizes of 8x32, 16x32, and 8x32, respectively, in order from the leftmost sub-coding unit to the rightmost sub-coding unit. When one coding unit is partitioned into three sub-coding units, the coding unit can be referred to as being tripartitoned or partitioned according to a ternary tree partitioning structure.

[0184] In FIG. 3 In the above-described example, the coding tree unit (CTU) 320 is an example of a CTU to which all of the quad-tree partitioning structure, the binary tree partitioning structure, and the ternary tree partitioning structure are applied.

[0185] As described above, in order to partition a CTU, at least one of the quad-tree partitioning structure, the binary tree partitioning structure, and the ternary tree partitioning structure can be applied. The various tree partitioning structures can be applied to the CTU sequentially according to a predetermined priority order. For example, the quad-tree partitioning structure can be applied to the CTU first. A coding unit that cannot be partitioned any more using the quad-tree partitioning structure can correspond to a leaf node of the quad-tree. The coding unit corresponding to the leaf node of the quad-tree can be used as a root node of the binary tree and / or the ternary tree partitioning structure. That is, the coding unit corresponding to the leaf node of the quad-tree can be further partitioned according to the binary tree partitioning structure or the ternary tree partitioning structure, or can not be further partitioned. Accordingly, by preventing coding units resulting from binary tree partitioning or ternary tree partitioning of coding units corresponding to leaf nodes of the quad-tree from undergoing further quad-tree partitioning, the block partitioning operation and / or the operation of signaling partitioning information can be efficiently performed.

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

[0187] There can be no priority between the binary tree partition and the ternary tree partition. That is, a coding unit corresponding to a leaf node of the quadtree can further undergo any partitioning of the binary tree partition and the ternary tree partition. Further, a coding unit generated by the binary tree partition or the ternary tree partition can undergo further binary tree partitioning or further ternary tree partitioning, or can not be further partitioned.

[0188] A tree structure in which there is no priority between the binary tree partition and the ternary tree partition is referred to as a multi-type tree structure. A coding unit corresponding to a leaf node of the quadtree can be used as a root node of the multi-type tree. Whether a coding unit corresponding to a node of the multi-type tree is partitioned can be signaled using at least one of multi-type tree partitioning indication information, partition direction information, and partition tree information. In order to partition a coding unit corresponding to a node of the multi-type tree, the multi-type tree partitioning indication information, the partition direction information, and the partition tree information can be sequentially signaled.

[0189] The multi-type tree partitioning indication information having a first value (e.g., "1") can indicate that the current coding unit will undergo multi-type tree partitioning. The multi-type tree partitioning indication information having a second value (e.g., "0") can indicate that the current coding unit will not undergo multi-type tree partitioning.

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

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

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

[0193] At least any one of the quad-tree partition indication information, the multi-type tree partition indication information, the partition direction information, and the partition tree information can be entropy coded / decoded. In order to entropy code / decode those types of information, information about neighboring coding units adjacent to the current coding unit can be used. For example, it is highly likely that the partition type (partitioned or not partitioned, partition tree, and / or partition direction) of a left neighboring coding unit and / or an above neighboring coding unit of the current coding unit is similar to that of the current coding unit. Thus, context information used for entropy coding / decoding information about the current coding unit can be derived from information about the neighboring coding units. The information about the neighboring coding units can include at least any one of the quad-tree partition information, the multi-type tree partition indication information, the partition direction information, and the partition tree information.

[0194] As another example, in the binary tree partition and the ternary tree partition, the binary tree partition can be preferentially performed. That is, the current coding unit can first undergo the binary tree partition, and then the coding unit corresponding to a leaf node of the binary tree can be set as a root node for the ternary tree partition. In this case, for a coding unit corresponding to a node of the ternary tree, neither the quad-tree partition nor the binary tree partition can be performed.

[0195] A coding unit that cannot be partitioned according to the quad-tree partition structure, the binary tree partition structure, and / or the ternary tree partition structure becomes a basic unit for encoding, prediction, and / or transform. That is, the coding unit cannot be further partitioned for prediction and / or transform. Thus, in a bitstream, there can be no partition structure information and partition information for partitioning a coding unit into a prediction unit and / or a transform unit.

[0196] However, when the size of a coding unit (i.e., a basic unit for partitioning) is larger than the size of the maximum transform block, the coding unit can be recursively partitioned until the size of the coding unit is reduced to be equal to or smaller than the size of the maximum transform block. For example, when the size of the coding unit is 64x64 and when the size of the maximum transform block is 32x32, the coding unit can be partitioned into four 32x32 blocks for transform. For example, when the size of the coding unit is 32x64 and the size of the maximum transform block is 32x32, the coding unit can be partitioned into two 32x32 blocks for transform. In this case, the partitioning of the coding unit for transform is not signaled separately and can be determined by a comparison between the horizontal size or the vertical size of the coding unit and the horizontal size or the vertical size of the maximum transform block. For example, when the horizontal size (width) of the coding unit is larger than the horizontal size (width) of the maximum transform block, the coding unit can be vertically bisected. For example, when the vertical size (height) of the coding unit is larger than the vertical size (height) of the maximum transform block, the coding unit can be horizontally bisected.

[0197] The information of the maximum and / or minimum size of the coding unit and the information of the maximum and / or minimum size of the transform block can be signaled or determined at a higher level of the coding unit. The higher level can be, for example, a sequence level, a picture level, a slice level, a tile group level, a tile level, etc. For example, the minimum size of the coding unit can be determined to be 4x4. For example, the maximum size of the transform block can be determined to be 64x64. For example, the minimum size of the transform block can be determined to be 4x4.

[0198] The information of the minimum size of the coding unit corresponding to the leaf node of the quad tree (quad tree minimum size) and / or the information of the maximum depth of the multi-type tree from the root node to the leaf node (maximum tree depth of the multi-type tree) can be signaled or determined at a higher level of the coding unit. For example, the higher level can be a sequence level, a picture level, a slice level, a tile group level, a tile level, etc. The information of the minimum size of the quad tree and / or the information of the maximum depth of the multi-type tree can be signaled or determined for each of the intra slice and the inter slice.

[0199] The difference information between the size of the CTU and the maximum size of the transform block can be signaled or determined at a higher level of the coding unit. The higher level can be, for example, a sequence level, a picture level, a slice level, a parallel block group level, a parallel block level, or the like. The information of the maximum size of the coding unit corresponding to each node of the binary tree (hereinafter, referred to as the maximum size of the binary tree) can be determined based on the size of the coding tree unit and the difference information. The maximum size of the coding unit corresponding to each node of the ternary tree (hereinafter, referred to as the maximum size of the ternary tree) can vary depending on the type of the slice. For example, for an intra slice, the maximum size of the ternary tree can be 32x32. For example, for an inter slice, the maximum size of the ternary tree can be 128x128. For example, the minimum size of the coding unit corresponding to each node of the binary tree (hereinafter, referred to as the minimum size of the binary tree) and / or the minimum size of the coding unit corresponding to each node of the ternary tree (hereinafter, referred to as the minimum size of the ternary tree) can be set to the minimum size of the coding block.

[0200] As another example, the maximum size of the binary tree and / or the maximum size of the ternary tree can be signaled or determined at a slice level. Alternatively, the minimum size of the binary tree and / or the minimum size of the ternary tree can be signaled or determined at a slice level.

[0201] According to the size and depth information of the various blocks described above, the quad-tree information, the multi-type tree partitioning indication information, the partition tree information, and / or the partition direction information can or can not be included in the bitstream.

[0202] For example, when the size of the coding unit is not greater than the minimum size of the quad-tree, the coding unit does not include the quad-tree information. The quad-tree information can be inferred to be the second value.

[0203] For example, when the size (horizontal size and vertical size) of the coding unit corresponding to the node of the multi-type tree is greater than the maximum size (horizontal size and vertical size) of the binary tree and / or the maximum size (horizontal size and vertical size) of the ternary tree, the coding unit can not be partitioned into two or three. Thus, the multi-type tree partitioning indication information can not be signaled, but can be inferred to be the second value.

[0204] Optionally, when the size (horizontal size and vertical size) of the coding unit corresponding to the node of the multi-type tree is the same as the maximum size (horizontal size and vertical size) of the binary tree and / or twice as large as the maximum size (horizontal size and vertical size) of the ternary tree, the coding unit can not be further bi-partitioned or tri-partitioned. Thus, the multi-type tree partitioning indication information can not be signaled, but can be inferred as the second value. This is because when the coding unit is partitioned according to the binary tree partitioning structure and / or the ternary tree partitioning structure, a coding unit smaller than the minimum size of the binary tree and / or the minimum size of the ternary tree is generated.

[0205] Optionally, the binary tree partitioning or the ternary tree partitioning can be limited based on the size of the virtual pipeline data unit (hereinafter, pipeline buffer size). For example, when a coding unit is divided into sub-coding units that do not fit the pipeline buffer size by the binary tree partitioning or the ternary tree partitioning, the corresponding binary tree partitioning or ternary tree partitioning can be limited. The pipeline buffer size can be the size of the maximum transform block (e.g., 64x64). For example, when the pipeline buffer size is 64x64, the following divisions can be limited.

[0206] - 128xN (N and / or M is 128) ternary tree partitioning for a coding unit

[0207] - 128xN (N <= 64) binary tree partitioning in a horizontal direction for a coding unit

[0208] - Nx128 (N <= 64) binary tree partitioning in a vertical direction for a coding unit

[0209] Optionally, when the depth of the coding unit corresponding to the node of the multi-type tree is equal to the maximum depth of the multi-type tree, the coding unit can not be further bi-partitioned and / or tri-partitioned. Thus, the multi-type tree partitioning indication information can not be signaled, but can be inferred as the second value.

[0210] Optionally, the multi-type tree partitioning indication information can be signaled only when at least one of the vertical direction binary tree partitioning, the horizontal direction binary tree partitioning, the vertical direction ternary tree partitioning, and the horizontal direction ternary tree partitioning is possible for the coding unit corresponding to the node of the multi-type tree. Otherwise, the coding unit can not be bi-partitioned and / or tri-partitioned. Thus, the multi-type tree partitioning indication information can not be signaled, but can be inferred as the second value.

[0211] Optionally, the partition direction information can be signaled only when both the vertical direction binary tree partition and the horizontal direction binary tree partition or both the vertical direction ternary tree partition and the horizontal direction ternary tree partition are possible for the coding tree corresponding to the node of the multi-type tree. Otherwise, the partition direction information can not be signaled, but the partition direction information can be inferred as a value indicating the possible partition direction.

[0212] Optionally, the partition tree information can be signaled only when both the vertical direction binary tree partition and the vertical direction ternary tree partition or both the horizontal direction binary tree partition and the horizontal direction ternary tree partition are possible for the coding tree corresponding to the node of the multi-type tree. Otherwise, the partition tree information can not be signaled, but the partition tree information can be inferred as a value indicating the possible partition tree structure.

[0213] FIG. 4 is a diagram illustrating an intra prediction process.

[0214] FIG. 4 The arrows from the center to the outside in the center can represent the prediction direction of the intra prediction mode.

[0215] Intra coding and / or decoding can be performed by using the reference samples of the neighboring block of the current block. The neighboring block can be a reconstructed neighboring block. For example, the intra coding and / or decoding can be performed by using the values or coding parameters of the reference samples included in the reconstructed neighboring block.

[0216] The prediction block can represent a block generated by performing the intra prediction. The prediction block can correspond to at least one of the CU, the PU, and the TU. The unit of the prediction block can have the size of one of the CU, the PU, and the TU. The prediction block can be a square block having a size of 2x2, 4x4, 16x16, 32x32, or 64x64, etc., or can be a rectangular block having a size of 2x8, 4x8, 2x16, 4x16, and 8x16, etc.

[0217] The intra prediction can be performed according to the intra prediction mode for the current block. The number of the intra prediction modes that the current block can have can be a fixed value, and can be a value determined differently according to the attribute of the prediction block. For example, the attribute of the prediction block can include the size of the prediction block, the shape of the prediction block, etc.

[0218] The number of intra prediction modes can be fixed to N regardless of the block size. Alternatively, the number of intra prediction modes can be 3, 5, 9, 17, 34, 35, 36, 65, or 67, etc. Optionally, the number of intra prediction modes can vary according to the block size or the color component type or both the block size and the color component type. For example, the number of intra prediction modes can vary according to whether the color component is a luma signal or a chroma signal. For example, the number of intra prediction modes can increase as the block size becomes larger. Optionally, the number of intra prediction modes for a luma component block can be greater than the number of intra prediction modes for a chroma component block.

[0219] The intra prediction mode can be a non-angular mode or an angular mode. The non-angular mode can be a DC mode or a planar mode, and the angular mode can be a prediction mode having a specific direction or angle. The intra prediction mode can be represented by at least one of a mode number, a mode value, a mode number, a mode angle, and a mode direction. The number of intra prediction modes can be M which is greater than 1, including the non-angular mode and the angular mode. In order to perform intra prediction on the current block, a step of determining whether the samples included in the reconstructed neighboring block can be used as reference samples for the current block can be performed. When there are samples that cannot be used as reference samples for the current block, a value obtained by copying or performing interpolation on at least one of the sample values included in the reconstructed neighboring block or both copying and interpolation can be used to replace the unavailable sample values of the samples, and thus the replaced sample values are used as reference samples for the current block.

[0220] FIG. 7 is a diagram illustrating reference samples that can be used for intra prediction.

[0221] As FIG. 7 indicated in FIG. 7 , the samples of the segment A and the segment F can be padded with the samples closest to the samples of the segment B and the segment E, respectively, instead of being retrieved from the reconstructed neighboring block. Index information indicating the reference sample line to be used for the intra prediction of the current block can be signaled. For example, in FIG. 7 , the reference sample line indicators 0, 1, and 2 can be signaled as index information indicating the reference sample line 0, the reference sample line 1, and the reference sample line 2. When the upper boundary of the current block is a boundary of a CTU, only the reference sample line 0 can be available. Thus, in this case, the index information can not be signaled. When a reference sample line other than the reference sample line 0 is used, the filtering for the prediction block that will be described later can not be performed.

[0222] When intra prediction is performed, a filter can be applied to at least one of the reference samples and the prediction samples based on the intra prediction mode and the current block size.

[0223] In the case of the planar mode, when generating the prediction block of the current block, depending on the position of the prediction target sample within the prediction block, the sample value of the prediction target sample can be generated by using the weighted sum of the above reference sample and the left reference sample of the current block and the top-right reference sample and the bottom-left reference sample of the current block. Further, in the case of the DC mode, when generating the prediction block of the current block, the average of the above reference sample and the left reference sample of the current block can be used. Further, in the case of the angular mode, the prediction block can be generated by using the above reference sample, the left reference sample, the top-right reference sample and / or the bottom-left reference sample of the current block. To generate the prediction sample value, interpolation of real units can be performed.

[0224] In the case of the inter-component intra prediction, the prediction block of the current block of the second color component can be generated based on the corresponding reconstructed block of the first color component. For example, the first color component can be a luma component and the second color component can be a chroma component. For the inter-component intra prediction, the parameters of the linear model between the first color component and the second color component can be derived based on a template. The template can include the above and / or left neighboring samples of the current block and the above and / or left neighboring samples of the reconstructed block of the first color component corresponding thereto. For example, the parameters of the linear model can be derived using the sample value of the first color component having the maximum value among the samples in the template and the sample value of the second color component corresponding thereto, and the sample value of the first color component having the minimum value among the samples in the template and the sample value of the second color component corresponding thereto. When the parameters of the linear model are derived, the corresponding reconstructed block can be applied to the linear model to generate the prediction block of the current block. Depending on the video format, the neighboring samples of the reconstructed block of the first color component and the corresponding reconstructed block can be sub-sampled. For example, when one sample of the second color component corresponds to four samples of the first color component, the four samples of the first color component can be sub-sampled to calculate one corresponding sample. In this case, the parameter derivation of the linear model and the inter-component intra prediction can be performed based on the corresponding sub-sampled samples. Whether the inter-component intra prediction is performed and / or the range of the template can be signaled as the intra prediction mode.

[0225] The current block can be partitioned into two sub-blocks or four sub-blocks in a horizontal direction or a vertical direction. The partitioned sub-blocks can be sequentially reconstructed. That is, intra prediction can be performed on the sub-blocks to generate sub-predicted blocks. Also, dequantization and / or inverse transform can be performed on the sub-blocks to generate sub-residual blocks. The reconstructed sub-blocks can be generated by adding the sub-predicted blocks and the sub-residual blocks. The reconstructed sub-blocks can be used as reference samples for intra prediction of subsequent sub-blocks. The sub-blocks can be blocks including a predetermined number (e.g., 16) or more samples. Thus, for example, when the current block is an 8x4 block or a 4x8 block, the current block can be partitioned into two sub-blocks. Also, when the current block is a 4x4 block, the current block can not be partitioned into sub-blocks. When the current block has other sizes, the current block can be partitioned into four sub-blocks. Information about whether to perform intra prediction based on the sub-blocks and / or the partition direction (horizontal or vertical) can be signaled. Sub-block based intra prediction can be limited to be performed only when reference sample line 0 is used. When sub-block based intra prediction is performed, filtering for a predicted block, which will be described later, can not be performed.

[0226] A final predicted block can be generated by performing filtering on the predicted block that is intra-predicted. The filtering can be performed by applying a predetermined weight to a filtering target sample, a left reference sample, an above reference sample, and / or a top-left reference sample. The weight used for filtering and / or the reference sample (range, position, etc.) can be determined based on at least one of a block size, an intra prediction mode, and a position of the filtering target sample in the predicted block. The filtering can be performed only in the case of a predetermined intra prediction mode (e.g., a DC, planar, vertical, horizontal, diagonal, and / or adjacent diagonal mode). The adjacent diagonal mode can be a mode that adds or subtracts k from the diagonal mode. For example, k can be a positive integer of 8 or less.

[0227] An intra prediction mode of a current block can be entropy encoded / decoded by predicting an intra prediction mode of a block that exists adjacent to the current block. When the intra prediction mode of the current block is the same as that of the neighboring block, information that the intra prediction mode of the current block is the same as that of the neighboring block can be signaled by using predetermined flag information. Also, indicator information of the intra prediction mode that is the same as the intra prediction mode of the current block among the intra prediction modes of the plurality of neighboring blocks can be signaled. When the intra prediction mode of the current block is not the same as that of the neighboring block, the intra prediction mode information of the current block can be entropy encoded / decoded by performing entropy encoding / decoding based on the intra prediction mode of the neighboring block.

[0228] FIG. 5 FIG. 1 is a diagram illustrating an embodiment of an inter prediction process.

[0229] In FIG. 5 , a rectangle can represent a picture. In FIG. 5In the middle, the arrow indicates the prediction direction. Depending on the coding type of the picture, the picture can be classified as an intra picture (I picture), a predicted picture (P picture), and a bi-predicted picture (B picture).

[0230] An I picture can be encoded by intra prediction without inter prediction. A P picture can be encoded by inter prediction using a reference picture existing in one direction (i.e., forward or backward) with respect to a current block. A B picture can be encoded by inter prediction using reference pictures existing in two directions (i.e., forward and backward) with respect to a current block. When inter prediction is used, an encoder can perform inter prediction or motion compensation, and a decoder can perform corresponding motion compensation.

[0231] Hereinafter, embodiments of inter prediction will be described in detail.

[0232] Inter prediction or motion compensation can be performed using a reference picture and motion information.

[0233] Motion information of a current block can be derived during inter prediction by each of the encoding apparatus 100 and the decoding apparatus 200. The motion information of the current block can be derived by using motion information of a reconstructed neighboring block, motion information of a collocated block (also referred to as a col block or a collocated block), and / or motion information of a block neighboring the collocated block. The collocated block can denote a block spatially collocated within a previously reconstructed collocated picture (also referred to as a col picture or a collocated picture) with respect to the current block. The collocated picture can be one picture among one or more reference pictures included in a reference picture list.

[0234] A method of deriving motion information can differ according to a prediction mode of a current block. For example, prediction modes applied to inter prediction include an AMVP mode, a merge mode, a skip mode, a merge mode with a motion vector difference, a sub-block merge mode, a geometric partition mode, a combined inter-intra prediction mode, an affine mode, etc. Here, the merge mode can be referred to as a motion merge mode.

[0235] For example, when the AMVP is used as the prediction mode, at least one of a motion vector of a reconstructed neighboring block, a motion vector of a collocated block, a motion vector of a block neighboring the collocated block, and a (0, 0) motion vector can be determined as a motion vector candidate for the current block, and a motion vector candidate list is generated by using the motion vector candidate. A motion vector candidate of the current block can be derived by using the generated motion vector candidate list. Motion information of the current block can be determined based on the derived motion vector candidate. The motion vector of the collocated block or the motion vector of the block neighboring the collocated block can be referred to as a temporal motion vector candidate, and the motion vector of the reconstructed neighboring block can be referred to as a spatial motion vector candidate.

[0236] The encoding apparatus 100 can calculate a motion vector difference (MVD) between a motion vector of the current block and a motion vector candidate, and can perform entropy encoding on the motion vector difference (MVD). In addition, the encoding apparatus 100 can perform entropy encoding on a motion vector candidate index and generate a bitstream. The motion vector candidate index can indicate a best motion vector candidate among motion vector candidates included in a motion vector candidate list. The decoding apparatus can perform entropy decoding on the motion vector candidate index included in the bitstream, and can select a motion vector candidate of a decoding target block from the motion vector candidates included in the motion vector candidate list by using the entropy-decoded motion vector candidate index. In addition, the decoding apparatus 200 can add the entropy-decoded MVD to the motion vector candidate extracted by entropy decoding, thereby deriving a motion vector of the decoding target block.

[0237] In addition, the encoding apparatus 100 can perform entropy encoding on resolution information of the calculated MVD. The decoding apparatus 200 can use the MVD resolution information to adjust the resolution of the entropy-decoded MVD.

[0238] In addition, the encoding apparatus 100 calculates a motion vector difference (MVD) between a motion vector in the current block and a motion vector candidate based on an affine model, and performs entropy encoding on the MVD. The decoding apparatus 200 derives a motion vector for each sub-block based on a sum of the entropy-decoded MVD and an affine control motion vector candidate by deriving an affine control motion vector of a decoding target block from the sum.

[0239] The bitstream can include a reference picture index indicating a reference picture. The reference picture index can be entropy-encoded by the encoding apparatus 100 and then signaled as the bitstream to the decoding apparatus 200. The decoding apparatus 200 can generate a prediction block of a decoding target block based on the derived motion vector and the reference picture index information.

[0240] Another example of a method of deriving motion information of a current block can be a merge mode. The merge mode can denote a method of merging motions of a plurality of blocks. The merge mode can denote a mode of deriving motion information of a current block from motion information of neighboring blocks. When the merge mode is applied, a merge candidate list can be generated using motion information of reconstructed neighboring blocks and / or motion information of co-located blocks. The motion information can include at least one of a motion vector, a reference picture index, and an inter prediction indicator. The prediction indicator can indicate a uni-prediction (L0 prediction or L1 prediction) or bi-prediction (L0 prediction and L1 prediction).

[0241] The merge candidate list can be a list of stored motion information. The motion information included in the merge candidate list can be at least one of motion information of a neighboring block adjacent to the current block (spatial merge candidate), motion information of a collocated block of the current block in a reference picture (temporal merge candidate), new motion information generated by a combination of motion information present in the merge candidate list, motion information of a block encoded / decoded before the current block (history-based merge candidate), and a zero merge candidate.

[0242] The encoding apparatus 100 can generate a bitstream by performing entropy encoding on at least one of the merge flag and the merge index, and can signal the bitstream to the decoding apparatus 200. The merge flag can be information indicating whether the merge mode is performed for each block, and the merge index can be information indicating which of the neighboring blocks of the current block is a merge target block. For example, the neighboring blocks of the current block can include a left neighboring block located at the left side of the current block, an above neighboring block arranged above the current block, and a temporal neighboring block adjacent in time to the current block.

[0243] In addition, the encoding apparatus 100 performs entropy encoding on correction information for correcting a motion vector in the motion information of the merge candidate and signals the same to the decoding apparatus 200. The decoding apparatus 200 can correct the motion vector of the merge candidate selected by the merge index based on the correction information. Here, the correction information can include at least one of information on whether correction is performed, correction direction information, and correction size information. As described above, the prediction mode in which the motion vector of the merge candidate is corrected based on the signaled correction information can be referred to as a merge mode with a motion vector difference.

[0244] The skip mode can be a mode in which the motion information of the neighboring block is applied to the current block as it is. When the skip mode is applied, the encoding apparatus 100 can perform entropy encoding on information of the fact that which block's motion information is to be used as the motion information of the current block to generate a bitstream, and can signal the bitstream to the decoding apparatus 200. The encoding apparatus 100 can not signal syntax elements on at least any one of motion vector difference information, a coding block flag, and transform coefficient level to the decoding apparatus 200.

[0245] The sub-block merge mode can denote a mode in which motion information is derived in units of sub-blocks of a coding unit (CU). When the sub-block merge mode is applied, a sub-block merge candidate list can be generated using motion information of a sub-block collocated with the current sub-block in a reference picture (sub-block-based temporal merge candidate) and / or an affine control point motion vector merge candidate.

[0246] The geometric partition mode can represent a mode in which motion information is derived by partitioning a current block in a predetermined direction, each of the derived motion information is used to derive each prediction sample, and a prediction sample of the current block is derived by weighting each of the derived prediction samples.

[0247] The inter-intra combined prediction mode can represent a mode in which a prediction sample of a current block is derived by weighting a prediction sample generated by inter prediction and a prediction sample generated by intra prediction.

[0248] The decoding device 200 can correct the derived motion information by itself. The decoding device 200 can search for a predetermined region based on a reference block indicated by the derived motion information, and derive motion information having a minimum SAD as the corrected motion information.

[0249] The decoding device 200 can use optical flow to compensate for a prediction sample derived via inter prediction.

[0250] FIG. 6 is a diagram illustrating a transform and quantization process.

[0251] As shown in FIG. 6 A transform process and / or a quantization process are performed on a residual signal to generate a quantized level signal, as shown in FIG. 1. The residual signal is a difference between an original block and a prediction block (i.e., an intra prediction block or an inter prediction block). The prediction block is a block generated by intra prediction or inter prediction. The transform can be a primary transform, a secondary transform, or both the primary transform and the secondary transform. The primary transform of the residual signal generates transform coefficients, and the secondary transform of the transform coefficients generates secondary transform coefficients.

[0252] At least one scheme selected from various pre-defined transform schemes is used to perform the primary transform. For example, examples of the pre-defined transform schemes include a discrete cosine transform (DCT), a discrete sine transform (DST), and a Karhunen-Loève transform (KLT). The transform coefficients generated by the primary transform can undergo the secondary transform. The transform scheme used for the primary transform and / or the secondary transform can be determined according to an encoding parameter of the current block and / or a neighboring block of the current block. Alternatively, transform information indicating the transform scheme can be signaled. The DCT-based transform can include, for example, DCT-2, DCT-8, etc. The DST-based transform can include, for example, DST-7.

[0253] Quantized level signals (quantized coefficients) can be generated by performing quantization on the residual signal or on the results of performing the primary transform and / or the secondary transform. The quantized level signals can be scanned according to at least one of diagonal up-right scanning, vertical scanning, and horizontal scanning, depending on the intra prediction mode or the block size / shape of the block. For example, when the coefficients are scanned in diagonal up-right scanning, the coefficients in the form of a block are changed into the form of a one-dimensional vector. In addition to diagonal up-right scanning, depending on the intra prediction mode and / or the size of the transform block, horizontal scanning that scans the coefficients in the form of a two-dimensional block horizontally or vertical scanning that scans the coefficients in the form of a two-dimensional block vertically can be used. The scanned quantized level coefficients can be entropy coded to be inserted into a bitstream.

[0254] A decoder entropy decodes the bitstream to obtain the quantized level coefficients. The quantized level coefficients can be arranged in the form of a two-dimensional block by inverse scanning. For the inverse scanning, at least one of diagonal up-right scanning, vertical scanning, and horizontal scanning can be used.

[0255] The quantized level coefficients can then be dequantized, then secondary inverse transformed as needed, and finally primary inverse transformed as needed, to generate a reconstructed residual signal.

[0256] Inverse mapping in a dynamic range can be performed for a luma component reconstructed by intra prediction or inter prediction before in-loop filtering. The dynamic range can be divided into 16 equal segments, and a mapping function for each segment can be signaled. The mapping function can be signaled at a slice level or a parallel group of blocks level. An inverse mapping function for performing the inverse mapping can be derived based on the mapping function. In-loop filtering, reference picture storage, and motion compensation are performed in the mapping region, and a prediction block generated by inter prediction is converted to the mapping region via mapping using the mapping function, and then used to generate a reconstructed block. However, since intra prediction is performed in the mapping region, a prediction block generated via intra prediction can be used to generate a reconstructed block without mapping / inverse mapping.

[0257] When the current block is a residual block of a chroma component, the residual block can be converted to an inverse mapping region by performing scaling on the chroma component of the mapping region. The availability of scaling can be signaled at a slice level or a parallel block group level. Scaling can be applied only when the mapping for the luma component is available and the partition of the luma component and the partition of the chroma component follow the same tree structure. The scaling can be performed based on an average value of sample values of a luma prediction block corresponding to the chroma block. In this case, when the current block uses inter prediction, the luma prediction block can represent a mapped luma prediction block. The values required for scaling can be derived by referring to a lookup table using an index of a segment to which the average value of the sample values of the luma prediction block belongs. Finally, by scaling the residual block using the derived values, the residual block can be converted to the inverse mapping region. Then, chroma component block restoration, intra prediction, inter prediction, in-loop filtering, and reference picture storage can be performed in the inverse mapping region.

[0258] Information indicating whether mapping / inverse mapping of a luma component and a chroma component is available can be signaled through a sequence parameter set.

[0259] A prediction block of a current block can be generated based on a block vector indicating a displacement between the current block in a current picture and a reference block. In this way, a prediction mode for generating a prediction block using a reference current picture is referred to as an intra block copy (IBC) mode. The IBC mode can be applied to an MxN (M<=64, N<=64) coding unit. The IBC mode can include a skip mode, a merge mode, an AMVP mode, etc. In the case of the skip mode or the merge mode, a merge candidate list is constructed, and a merge index is signaled so that one merge candidate can be designated. A block vector of the designated merge candidate can be used as a block vector of the current block. The merge candidate list can include at least one of a spatial candidate, a history-based candidate, a candidate based on an average value of two candidates, and a zero merge candidate. In the case of the AMVP mode, a difference block vector can be signaled. Also, a prediction block vector can be derived from left and above neighboring blocks of the current block. An index of the neighboring block to be used can be signaled. The prediction block in the IBC mode is included in the current CTU or a left CTU and is limited to a block in a region that has been reconstructed. For example, the value of the block vector can be limited so that the prediction block of the current block is located in a region of three 64x64 blocks before the 64x64 block to which the current block belongs in the encoding / decoding order. By limiting the value of the block vector in this way, memory consumption and device complexity according to the IBC mode implementation can be reduced.

[0260] In the following, a method for enhancing video compression efficiency by improving a transform method as one of video encoding processes will be described. More specifically, encoding in a conventional video encoding schematically includes an intra / inter prediction step of predicting an original block as a part of a current original image, a transform and quantization step for a residual block which is a difference between a predicted block predicted in the prediction step and the original block, and an entropy encoding step which is a lossless compression method based on a probability of a coefficient of the block on which the transform and quantization have been performed and compression information obtained in the previous step. Accordingly, a bitstream which is a compressed form of the original image is generated and transmitted to a decoder or stored in a recording medium. A shuffling discrete sine transform (hereinafter, referred to as "SDST") to be described in the present specification below aims at enhancing compression efficiency by improving transform efficiency.

[0261] The SDST method according to the present application uses a discrete sine transform type-7 (hereinafter, referred to as "DST-VII" or "DST-7") instead of a discrete cosine transform type-2 (hereinafter, referred to as "DCT-II" or "DCT-2") which is a transform kernel widely used in video encoding, thereby better reflecting a frequency characteristic common to images.

[0262] The transform method according to the present application can obtain a high objective video quality even at a relatively low bit rate compared to a conventional video encoding method.

[0263] The DST-7 can be applied to data of a residual block. Applying the DST-7 to the residual block can be performed based on a prediction mode corresponding to the residual block. For example, it can be applied to a residual block encoded in an inter mode. According to an embodiment of the present application, the DST-7 can be applied after rearranging or shuffling data of the residual block. Here, shuffling can mean rearranging of image data, and can be equivalent to residual signal rearranging or flipping. Here, the residual block can have the same meaning as residual, residual block, residual signal, residual data, or residual data. Further, the residual block can have the same meaning as reconstructed residual, reconstructed residual block, reconstructed residual signal, reconstructed residual data, or reconstructed residual data in the form of a reconstructed residual block in an encoder and a decoder.

[0264] According to embodiments of the present application, the SDST can use DST-7 as a transform kernel. Here, the transform kernel of the SDST is not limited to DST-7, and at least one of various types of DSTs and DCTs (such as Discrete Sine Transform Type-1 (DST-1), Discrete Sine Transform Type-2 (DST-2), Discrete Sine Transform Type-3 (DST-3),..., Discrete Sine Transform Type-n (DST-n), Discrete Cosine Transform Type-1 (DCT-1), Discrete Cosine Transform Type-2 (DCT-2), Discrete Cosine Transform Type-3 (DCT-3),..., Discrete Cosine Transform Type-n (DCT-n), etc.) can be used (here, n can be a positive integer 1 or a positive integer greater than 1).

[0265] Equation 1 below can represent a method of performing one-dimensional DCT-2 according to embodiments of the present application. Here, N can represent the size of a block, k can represent the position of a frequency component, and x n may represent the value of the nth coefficient in the spatial domain.

[0266] [Equation 1]

[0267]

[0268] DCT-2 in a two-dimensional domain can be implemented by performing horizontal and vertical transforms on a residual block using Equation 1 above.

[0269] The DCT-2 transform kernel can be defined as Equation 2 below. Here, X k may represent a basis vector according to the position in the frequency domain, and N can represent the size of the frequency domain.

[0270] [Equation 2]

[0271]

[0272] In addition, FIG. 7 is a diagram showing a basis vector in the frequency domain of DCT-2 according to the present application. FIG. 7 shows the frequency characteristics of DCT-2 in the frequency domain. Here, the value calculated by the X0 basis vector of DCT-2 can represent a DC component.

[0273] DCT-2 can be used in transform processing for residual blocks having sizes of 4x4, 8x8, 16x16, 32x32, etc.

[0274] In addition, the DCT-2 can be selectively used based on at least one of a size of the residual block, a color component (e.g., a luma component and a chroma component) of the residual block, and a prediction mode corresponding to the residual block. For example, when the residual block has a size of 4x4 and is encoded in an intra mode and the component of the residual block is the luma component, the DCT-2 is used. For example, when a horizontal length (width) of the residual block encoded in the intra mode is in a predetermined range (e.g., equal to or greater than four pixels and equal to or less than 16 pixels) and the horizontal length (width) is not longer than a vertical length (height), a first transform kernel can be used for horizontal transform. Otherwise, a second transform kernel can be used for the horizontal transform. For example, when the vertical length (height) of the residual block encoded in the intra mode is equal to or longer than four pixels and equal to or shorter than 16 pixels and the vertical length (height) is not longer than the horizontal length (width), the first transform kernel can be used for vertical transform. Otherwise, the second transform kernel can be used for the vertical transform. The first transform kernel can be different from the second transform kernel. That is, the horizontal transform method and the vertical transform method for the block encoded in the intra mode can be implicitly determined based on a shape of the block under a predetermined condition. For example, the first transform kernel can be DST-7, and the second transform kernel can be DCT-2. Here, the residual block is a transform target, and thus it can have the same meaning as the transform block. Here, the prediction mode can denote inter prediction or intra prediction. Further, in the case of the intra prediction, the prediction mode denotes an intra prediction mode or an intra prediction direction.

[0275] The transform through the DCT-2 transform kernel can achieve high compression efficiency for a block having a characteristic like a background of an image in which a change between neighboring pixels is as small as possible. However, it can not be suitable as a transform kernel for a region having a complex pattern such as a texture image. This is because when a block having a low correlation between neighboring pixels is transformed through the DCT-2, a large number of transform coefficients occur in a high frequency component in a frequency domain. When transform coefficients are frequently generated in the high frequency domain, the compression efficiency of the image can be reduced. In order to enhance the compression efficiency, coefficients having a large value need to occur near a low frequency component, and the values of the coefficients need to approach zero in a high frequency component.

[0276] Equation 3 below can represent a method of performing one-dimensional DST-7 according to an embodiment of the present application. Here, N can denote a size of a block, k can denote a position of a frequency component, and x n may denote a value of an nth coefficient in a spatial domain.

[0277] [Equation 3]

[0278]

[0279] The DST-7 in a two-dimensional domain can be achieved by performing horizontal transform and vertical transform on a residual block using Equation 3 above.

[0280] A DST-7 transform kernel can be defined as Equation 4 below. Here, X k may denote a k-th basis vector of DST-7, i can denote a position in a frequency domain, and N can denote a size of the frequency domain.

[0281] [Equation 4]

[0282]

[0283] The DST-7 can be used in a transform process for a residual block of at least one of sizes 2x2, 4x4, 8x8, 16x16, 32x32, 64x64, 128x128, etc.

[0284] In addition, the DST-7 can be applied to a rectangular block instead of a square block. For example, the DST-7 can be applied to at least one of a vertical transform and a horizontal transform of a rectangular block having different horizontal and vertical sizes, such as 8x4, 16x8, 32x4, 64x16, etc. When a plurality of transform methods can be selectively applied, the DCT-2 is applied to the horizontal transform and the vertical transform of the square block. When a plurality of transform methods cannot be selectively applied, the DST-7 is applied to the horizontal transform and the vertical transform of the square block.

[0285] Furthermore, DST-7 can be selectively used based on at least one of the size of the residual block, the color components of the residual block (e.g., luma and chroma components), the prediction mode corresponding to the residual block, the intra prediction mode (direction), and the shape of the residual block. For example, DST-7 is used when the residual block has a size of 4×4 and is encoded in intra mode, and the components of the residual block are luma components. Here, the prediction mode can indicate inter prediction or intra prediction. In the case of intra prediction, the prediction mode indicates the intra prediction mode or intra prediction direction. For example, for chroma components, the selection of a transform method based on block shape may not be available. For example, when the intra prediction mode is prediction between color components, the selection of a transform method based on block shape is not available. For example, the transform method for chroma components may be specified by information signaled via the bitstream. When the current block is partitioned into multiple subblocks and intra prediction is performed on each of the multiple subblocks, the transform method for the current block is determined based on the intra prediction mode and / or the block size (horizontal and / or vertical size). For example, when the intra prediction mode is non-directional (DC or planar) and the horizontal length (width) (or vertical length (height)) is within a predetermined range, the first transform kernel is used for horizontal transform (vertical transform). Otherwise, the second transform kernel is used. The first transform kernel may be different from the second transform kernel. For example, the first transform kernel may be DST-7 and the second transform kernel may be DCT-2. The predetermined range may range from 4 pixels to 16 pixels, for example. When the size of the block is not within the predetermined range, the same kernel (e.g., the second transform kernel) is used for horizontal transform and vertical transform. When the size of the block is within the predetermined range, different transform kernels are used for adjacent intra prediction modes. For example, when the second transform kernel and the first transform kernel are used for horizontal transform and vertical transform in mode 27, respectively, the first transform kernel and the second transform kernel are used for horizontal transform and vertical transform in modes 26 and 28, respectively, which are adjacent to mode 27.

[0286] Hereinafter, SDST will be described as one of the transform methods using DST-7 as a transform kernel.

[0287] Hereinafter, a block may mean one of CU, PU, ​​and TU.

[0288] The SDST according to the present invention can be performed in two steps. The first step is to perform shuffling on the residual signal within the PU of the CU predicted in inter mode or intra mode. The second step is to apply DST-7 to the residual signal within the block where shuffling has been performed.

[0289] A residual signal arranged in a current block (e.g., a CU, a PU, or a TU) can be scanned in a first direction and can be rearranged in a second direction. That is, a residual signal arranged in a current block can be scanned in a first direction and can be rearranged in a second direction to perform shuffle. Here, a residual signal can mean a signal indicating a difference signal between an original signal and a predicted signal. That is, a residual signal can mean a signal before at least one of a transform and quantization is performed. Alternatively, a residual signal can mean a signal form in which at least one of a transform and quantization is performed. Further, a residual signal can mean a reconstructed residual signal. That is, a residual signal can mean a signal in which at least one of an inverse transform and inverse quantization is performed. Further, a residual signal can mean a signal before at least one of an inverse transform and inverse quantization is performed.

[0290] In addition, the first direction (or scan direction) can be one of a raster scan order, an upper-right diagonal scan order, a horizontal scan order, and a vertical scan order. Further, the first direction can be defined as at least one of the following (1) to (10).

[0291] Scan from an upper row to a lower row, and scan from left to right in a row

[0292] Scan from an upper row to a lower row, and scan from right to left in a row

[0293] Scan from a lower row to an upper row, and scan from left to right in a row

[0294] Scan from a lower row to an upper row, and scan from right to left in a row

[0295] Scan from a left column to a right column, and scan from top to bottom in a column

[0296] Scan from a left column to a right column, and scan from bottom to top in a column

[0297] Scan from a right column to a left column, and scan from top to bottom in a column

[0298] Scan from a right column to a left column, and scan from bottom to top in a column

[0299] Scan in a spiral shape: scan from an inside (or outside) of a block to an outside (or inside) of the block, and scan in a clockwise / anticlockwise direction

[0300] Diagonal scan: start from one vertex in a block, and diagonally scan in a left-up, right-up, left-down, or right-down direction

[0301] In addition, with respect to the second direction (or rearrangement direction), at least one of the (1) to (10) scan directions can be selectively used. The first direction and the second direction can be the same, or can be different from each other.

[0302] The scanning and rearranging processes for the residual signal can be performed in units of the current block.

[0303] Here, the rearranging can mean that the residual signal scanned in the first direction within the block is arranged in a block of the same size in the second direction. Here, the size of the block for scanning in the first direction can be different from the size of the block for rearranging in the second direction.

[0304] Further, the scanning and rearranging are described as being performed separately according to the first direction and the second direction, but the scanning and rearranging can be performed as one process for the first direction. For example, for the residual signal within the block, the scanning can be performed from the upper row to the lower row and the scanning in a row can be performed from the right to the left to store (rearrange) in the block.

[0305] In addition, the scanning and rearranging processes for the residual signal can be performed in predetermined units of sub-blocks within the current block. Here, the sub-block can be a block having a size equal to or smaller than the current block. The sub-block can be a block obtained by partitioning the current block in a quad-tree, binary-tree form, or the like.

[0306] The sub-block unit can have a fixed size and / or shape (e.g., 4x4, 4x8, 8x8, …, NxM, where N and M are positive integers). Further, the size and / or shape of the sub-block unit can be variably derived. For example, the size and / or shape of the sub-block unit can be determined according to the size, shape, and / or prediction mode (inter and intra) of the current block.

[0307] The scanning direction and / or the rearranging direction can be adaptively determined according to the position of the sub-block. In this case, different scanning directions and / or rearranging directions can be used for the sub-blocks, or all or part of the sub-blocks of the current block can use the same scanning direction and / or the same rearranging direction.

[0308] For example, for a block that is inter-predicted, a residual block having the same size as the block can be decoded, or a sub-residual block corresponding to a portion of the block can be decoded. Information for this operation can be signaled for the block, and the information can be, for example, a flag. When the residual block having the same size as the block is decoded, information on a transform kernel is determined by decoding information included in a bitstream. When the sub-residual block corresponding to the portion of the block is decoded, a transform kernel for the sub-residual block is determined based on information for specifying a type of the sub-residual block and / or a position within the block. For example, the information on the type of the sub-residual block and / or the position within the block can be included in a bitstream for signaling. Here, when the block is larger than 32x32, the determination of the transform kernel based on the type of the sub-residual block and / or the position within the block is not performed. For example, for a block larger than 32x32, a predetermined transform kernel (e.g., DCT-2) can be applied, or information on the transform kernel can be explicitly signaled. Alternatively, when a width or a height of the block is larger than 32, the determination of the transform kernel based on the type of the sub-residual block and / or the position within the block is not performed. For example, for a 64x8 block, a predetermined transform kernel (e.g., DCT-2) can be applied, or information on the transform kernel can be explicitly signaled.

[0309] The information on the type of the sub-residual block can be partition information of the block. The partition information of the block can be, for example, partition direction information indicating one among a horizontal partition and a vertical partition. Alternatively, the partition information of the block can include partition ratio information. For example, the partition ratio can include 1:1, 1:3, and / or 3:1. The partition direction information and the partition ratio information can be signaled as separate syntax elements or as a single syntax element.

[0310] The information on the position of the sub-residual block can indicate a position within the block. For example, when a partition of the block is a vertical partition, the information on the position indicates one among a left side and a right side. Further, when the partition of the block is a horizontal partition, the information on the position indicates one among an upper side and a lower side.

[0311] The transform kernel of the sub residual block can be determined based on the type information and / or the position information. The transform kernel can be determined independently for the horizontal transform and the vertical transform. For example, the transform kernel can be determined based on the partition direction. For example, in the case of vertical partitioning, a first transform kernel can be applied to the vertical transform. In the case of horizontal partitioning, the first transform kernel can be applied to the horizontal transform. For example, the first transform kernel or the second transform kernel can be applied to the horizontal transform in the case of vertical partitioning and to the vertical transform in the case of horizontal partitioning. For example, in the case of vertical partitioning, the second transform kernel can be applied to the horizontal transform at a left side position, and the first transform kernel can be applied to the horizontal transform at a right side position. Also, in the case of horizontal partitioning, the second transform kernel can be applied to the vertical transform at an upper position, and the first transform kernel can be applied to the vertical transform at a lower position. For example, the first transform kernel and the second transform kernel can be DST-7 and DCT-8, respectively. For example, the first transform kernel and the second transform kernel can be DST-7 and DCT-2, respectively. However, not limited thereto, any two different transform kernels among the various transform kernels described in the present specification can be used as the first transform kernel and the second transform kernel. Here, the block can denote a CU or a TU. Also, the sub residual block can denote a sub-TU.

[0312] The transform mode information can be entropy encoded / entropy decoded in a bypass mode only in the case of a TU within a PU that is inter-predicted. Also, in the case of at least one of a transform skip mode, a residual difference PCM (RDPCM) mode, and a lossless mode, entropy encoding / entropy decoding of the transform mode information is omitted, and the transform mode information is not signaled.

[0313] Also, when a coded block flag of a block is zero, entropy encoding / entropy decoding of the transform mode information is omitted, and the transform mode information is not signaled. When the coded block flag is zero, inverse transform processing is omitted in the decoder. Thus, even when the transform mode information is not present in the decoder, reconstruction of the block can be performed.

[0314] However, the transform mode information is not limited to representing the transform mode by a flag, and can be implemented in the form of a pre-defined table and an index. Here, the pre-defined table can be a table defining available transform modes for each index.

[0315] Also, the transform of DCT-2 or SDST can be performed in the horizontal direction and the vertical direction, respectively. The same transform mode can be used for the horizontal direction and the vertical direction, or different transform modes can be used.

[0316] Further, transform mode information related to whether DCT-2 is used in the horizontal direction and the vertical direction, whether SDST is used, and whether DST-7 is used can be entropy encoded / decoded, respectively. The transform mode information can be signaled, for example, as an index. The transform kernel indicated by the same index can be the same for blocks that are intra-predicted and blocks that are inter-predicted.

[0317] Further, the transform mode information can be entropy encoded / decoded in units of at least one of a CU, a PU, a TU, and a block.

[0318] Further, the transform mode information can be signaled according to a luma component or a chroma component. In other words, the transform mode information can be signaled according to a Y component, a Cb component, or a Cr component. For example, when transform mode information related to whether DCT-2 is performed for a Y component or whether SDST is performed is signaled, the transform mode information signaled for the Y component can be used as a transform mode of a block without signaling any transform mode information for at least one of a Cb component and a Cr component.

[0319] Here, the transform mode information can be entropy encoded / decoded using an arithmetic encoding method using a context model. When the transform mode information is implemented in the form of a pre-defined table and an index, all or part of a plurality of bins are entropy encoded / decoded using the arithmetic encoding method using the context model.

[0320] Further, the transform mode information can be entropy encoded / decoded selectively according to a block size. For example, when a size of a current block is equal to or greater than 64x64, the transform mode information is not entropy encoded / decoded. When the size is equal to or smaller than 32x32, the transform mode information is entropy encoded / decoded.

[0321] Further, when there is a non-zero transform coefficient or L quantized levels within a current block, the transform mode information is not entropy encoded / decoded, and one of DCT-2, DST-7, and SDST methods is performed. Here, the transform mode information can not be entropy encoded / decoded regardless of a position of the non-zero transform coefficient or the quantized levels within the block. Further, the transform mode information can not be entropy encoded / decoded only when the non-zero transform coefficient or the quantized levels exist in a top-left position within the block. Here, L can be a positive integer including zero, and can be, for example, 1.

[0322] Further, when there is a non-zero transform coefficient or J or more quantized levels within a current block, the transform mode information is entropy encoded / decoded. Here, J is a positive integer.

[0323] Further, the transform mode information is a method of limiting the use of certain transform modes according to the transform mode of a collocated block or the transform mode of a collocated block is represented by several bits, the binarization method of the transform method can vary.

[0324] The above-described SDST can be used restrictively based on at least one of a prediction mode of a current block, an intra prediction mode, an inter prediction mode, a TU depth, a size, and a shape.

[0325] For example, the SDST is used when the current block is coded in an inter mode.

[0326] A minimum / maximum depth allowing the SDST can be defined. In this case, the SDST is used when the depth of the current block is equal to or greater than the minimum depth. Alternatively, the SDST is used when the depth of the current block is equal to or less than the maximum depth. Here, the minimum / maximum depth can be a fixed value or can be variably determined based on information indicating the minimum / maximum depth. The information indicating the minimum / maximum depth can be signaled from an encoder and can be derived from a decoder based on properties (e.g., size, depth, and / or shape) of the current block / collocated block.

[0327] A minimum / maximum size allowing the SDST can be defined. Similarly, the SDST is used when the size of the current block is equal to or greater than the minimum size. Alternatively, the SDST is used when the size of the current block is equal to or less than the maximum size. Here, the minimum / maximum size can be a fixed value or can be variably determined based on information indicating the minimum / maximum size. The information indicating the minimum / maximum size can be signaled from an encoder and can be derived from a decoder based on properties (e.g., size, depth, and / or shape) of the current block / collocated block. For example, when the current block is 4x4, DCT-2 is used as a transform method, and transform mode information about whether DCT-2 is used or the SDST is used is not entropy coded / entropy decoded.

[0328] A shape of a block allowing the SDST can be defined. In this case, the SDST is used when the shape of the current block is the defined shape of a block. Further, a shape of a block not allowing the SDST can be defined. In this case, the SDST is not used when the shape of the current block is the defined shape of a block. The shape of a block allowing or not allowing the SDST can be fixed, and information about this can be signaled from an encoder. Alternatively, the information can be derived from a decoder based on properties (e.g., size, depth, and / or shape) of the current block / collocated block. The shape of a block allowing or not allowing the SDST can represent, for example, M, N, and / or a ratio of M to N in a block of MxN.

[0329] Further, when the depth of the TU is zero, DCT-2 or DST-7 is used as a transform method, and transform mode information about which transform method is used is entropy-encoded / entropy-decoded. When DST-7 is used as a transform method, rearrangement processing of a residual signal is performed. Further, when the depth of the TU is 1 or more, DCT-2 or SDST is used as a transform method, and transform mode information about which transform method is used is entropy-encoded / entropy-decoded.

[0330] Further, a transform method can be selectively used according to a partition shape of a CU and a PU or a shape of a current block.

[0331] According to an embodiment, when the partition shape of the CU and the PU or the shape of the current block is 2N×2N, DCT-2 is used. As for the remaining partition shapes and block shapes, DCT-2 or SDST can be selectively used.

[0332] Further, when the partition shape of the CU and the PU or the shape of the current block is 2N×N or N×2N, DCT-2 is used. As for the remaining partition shapes and block shapes, DCT-2 or SDST can be selectively used.

[0333] Further, when the partition shape of the CU and the PU or the shape of the current block is nR×2N, nL×2N, 2N×nU, or 2N×nD, DCT-2 is used. As for the remaining partition shapes and block shapes, DCT-2 or SDST can be selectively used.

[0334] In addition, when SDST or DST-7 is performed in units of a block obtained from a partition of a current block, scanning and inverse scanning of transform coefficients (quantized levels) can be performed in units of the block obtained from the partition. Further, when SDST or DST-7 is performed in units of a block obtained from a partition of a current block, scanning and inverse scanning of transform coefficients (quantized levels) can be performed in units of the current block which is not partitioned.

[0335] Further, transform / inverse transform using SDST or DST-7 can be performed according to at least one of an intra prediction mode (direction) of a current block, a size of the current block, and a component (luma component or chroma component) of the current block.

[0336] Further, in the transform / inverse transform using SDST or DST-7, DST-1 can be used instead of DST-7. Further, in the transform / inverse transform using SDST or DST-7, DCT-4 can be used instead of DST-7.

[0337] Further, in the transform / inverse transform using DCT-2, a rearrangement method used for rearranging the residual signal of SDST or DST-7 can be applied. That is, even when DCT-2 is used, rearrangement of the residual signal or rotation of the residual signal using a predetermined angle is performed.

[0338] Hereinafter, various modifications and embodiments of the shuffling method and the signaling method will be described.

[0339] The SDST of the present application aims to enhance the image compression efficiency by changing the transform, shuffling, rearrangement, and / or flipping method. The performance of DST-7 by shuffling the residual signal effectively reflects the distribution characteristics of the residual signal within the PU, and thus high compression efficiency is achieved.

[0340] In the above description related to the shuffling step, the residual signal rearrangement method has been described. Hereinafter, in addition to the shuffling method for rearranging the residual signal, other implementation methods will be described.

[0341] The rearrangement methods described below can be applied to at least one of the embodiments related to the above-described SDST method.

[0342] In order to minimize the hardware complexity for implementing the rearrangement of the residual signal, the residual signal rearrangement process can be implemented by a horizontal flipping method and a vertical flipping method. The residual signal rearrangement method can be implemented by flipping as shown in (1) to (4) below. The rearrangement described below can mean flipping.

[0343] (1) r'(x, y) = r(x, y); no flipping

[0344] (2) r'(x, y) = r(w-1-x, y); horizontal flipping

[0345] (3) r'(x, y) = r(x, h-1-y); vertical flipping

[0346] (4) r'(x, y) = r(w-1-x, h-1-y); horizontal and vertical flipping

[0347] The expression r'(x, y) denotes the residual signal after rearrangement, and the expression r(x, y) denotes the residual signal before rearrangement. The width and height of the block are denoted by w and h, respectively. The position of the residual signal within the block is denoted by x and y. The inverse rearrangement method of the rearrangement method using flipping can be performed in the same process as the rearrangement method. That is, the residual signal rearranged using horizontal flipping can be reconstructed into the original residual signal arrangement by performing horizontal flipping again. The rearrangement method performed by the encoder and the inverse rearrangement method performed by the decoder can be the same flipping method.

[0348] For example, when a horizontal flip is performed on a residual block on which a horizontal flip has already been performed, a residual block before the flip is performed is obtained as follows.

[0349] r'(w-1-x,y) = r(x,y).

[0350] For example, when a vertical flip is performed on a residual block on which a vertical flip has already been performed, a residual block before the flip is performed is obtained as follows.

[0351] r'(x,h-1-y) = r(x,y).

[0352] For example, when a horizontal and vertical flip is performed on a residual block on which a horizontal and vertical flip has already been performed, a residual block before the flip is performed is obtained as follows.

[0353] r'(w-1-x,h-1-y) = r(x,y).

[0354] The flip-based residual signal reshuffling / rearranging method can be used without partitioning a current block. That is, in the SDST method, it is described that a current block (TU, etc.) is partitioned into sub-blocks and DST-7 is used for each sub-block. However, when the flip-based residual signal reshuffling / rearranging method is used, the current block is not partitioned into sub-blocks, and a flip is performed on all or part of the current block, and then a DST-7 transform is performed. Also, when the flip-based residual signal reshuffling / rearranging method is used, the current block is not partitioned into sub-blocks, and a flip is performed on all or part of the current block after a DST-7 inverse transform is performed.

[0355] A maximum size (MxN) and / or a minimum size (OxP) of a block capable of performing the flip-based residual signal reshuffling / rearranging can be defined. Here, the size can include at least one of a width as a horizontal size (M or O) and a height as a vertical size (N or P). M, N, O, and P can be positive integers. The maximum size of the block and / or the minimum size of the block can be a pre-defined value in an encoder / decoder, or can be information signaled from the encoder to the decoder.

[0356] For example, when a size of a current block is smaller than a minimum size capable of performing the flip method, a flip and a DST-7 transform are not performed, and only a DCT-2 transform is performed. Here, an SDST flag as transform mode information indicating whether a flip and a DST-7 are used as a transform mode can not be signaled.

[0357] For example, when the width of the block is less than the minimum width capable of performing the flipping method and the height of the block is greater than the minimum height capable of performing the flipping method, only DCT-2 is used to perform one-dimensional transformation in the horizontal direction. As for one-dimensional transformation in the vertical direction, one-dimensional vertical transformation is performed using DST-7 after vertical flipping, or one-dimensional vertical transformation is performed using DST-7 without flipping. Here, an SDST flag, which is transform mode information indicating whether flipping is used as a transform mode, can be signaled only for one-dimensional transformation in the vertical direction.

[0358] For example, when the height of the block is less than the minimum height capable of performing the flipping method and the width of the block is greater than the minimum width capable of performing the flipping method, as for one-dimensional transformation in the horizontal direction, one-dimensional horizontal transformation is performed using DST-7 after horizontal flipping, or one-dimensional horizontal transformation is performed using DST-7 without flipping. Only DCT-2 is used to perform one-dimensional transformation in the vertical direction. Here, an SDST flag, which is transform mode information indicating whether flipping is used as a transform mode, can be signaled only for one-dimensional transformation in the horizontal direction.

[0359] For example, when the size of the current block is greater than the maximum size capable of performing the flipping method, flipping and DST-7 transformation are not used, and only DCT-2 transformation is used. Here, an SDST flag, which is transform mode information indicating whether flipping and DST-7 transformation are used as a transform mode, can not be signaled.

[0360] For example, when the size of the current block is greater than the maximum size capable of performing the flipping method, only DCT-2 transformation or DST-7 transformation is used.

[0361] For example, when the maximum size capable of performing the flipping method is 32x32 and the minimum size is 4x4, flipping and DST-7 transformation are not used for a block having a size of 64x64, and only DCT-2 transformation is used. Here, for a block having a size of 64x64, an SDST flag, which is transform mode information indicating whether flipping and DST-7 are used as a transform mode, can not be signaled. In addition, for a block having a size of 4x4 to 32x32, an SDST flag, which is transform mode information indicating whether flipping and DST-7 are used as a transform mode, can be signaled. In this case, DST-7 transformation is not used for a block having a size of 64x64, and thus memory space for storing DST-7 transformation for a block having a size of 64x64 can be saved.

[0362] For example, when the maximum size capable of performing the flipping method is 32x32 and the minimum size is 4x4, not only the flipping method is used for a block having a size of 64x64, and DCT-2 or DST-7 transformation is used.

[0363] For example, a square block having a size of MxN can be partitioned into four sub-blocks by a quad-tree, and a flipping-based residual signal shuffle / rearrangement method can be performed on each of the sub-blocks using a flipping method, and then a DST-7 transform can be performed. Here, the flipping method can be explicitly signaled for each of the sub-blocks. The flipping method can be signaled as a fixed length code of two bits, and can be signaled as a truncated unary code. In addition, a binarization method based on the occurrence probability of each block's flipping method obtained from partitioning can be used. Here, M and N can be positive integers, for example, 64x64.

[0364] The information (sdst_flag or sdst flag) on the use of the flipping-based residual signal shuffle / rearrangement method can be entropy encoded / decoded using the transform mode information. That is, by signaling for the transform mode information, the same method performed in the encoder can be performed in the decoder. For example, when a flag bit indicating the transform mode information has a first value, the flipping and DST-7-based residual signal shuffle / rearrangement method is used as a transform / inverse transform method. When the flag bit has a second value, another transform / inverse transform method is used. Here, the transform mode information can be entropy encoded / decoded for each block. Here, the other transform / inverse transform method can be a DCT-2 transform / inverse transform method. In addition, in the case of one of a transform skip mode, a residual difference PCM (RDPCM) mode, and a lossless mode, entropy encoding / decoding of the transform mode information is omitted, and the transform mode information is not signaled.

[0365] The transform mode information can be entropy encoded / decoded using at least one of a depth of a current block, a size of the current block, a shape of the current block, transform mode information of a neighboring block, a coded block flag of the current block, and information on whether a transform skip mode is used for the current block. For example, when the coded block flag of the current block is zero, entropy encoding / decoding of the transform mode information is omitted, and the transform mode information is not signaled. In addition, the transform mode information can be predictively encoded / decoded during entropy encoding / decoding according to transform mode information of a reconstructed block neighboring the current block. In addition, the transform mode information can be signaled based on at least one of coding parameters of the current block and the neighboring block.

[0366] In addition, by using flipping method information, at least one of four flipping methods (no flipping, horizontal flipping, vertical flipping, and horizontal and vertical flipping) can be entropy encoded / decoded in the form of a flag or an index (flipping_idx). That is, by signaling the flipping method information, the same flipping method performed in the encoder can be performed in the decoder. The transform mode information can include the flipping method information.

[0367] Further, in a case that one of the transform skip mode, the residual difference PCM (RDPCM) mode, and the lossless mode is used, the entropy encoding / entropy decoding of the flipping method information is omitted, and the flipping method information is not signaled. The flipping method information can be entropy encoded / entropy decoded using at least one of a depth of the current block, a size of the current block, a shape of the current block, flipping method information of a neighboring block, a coded block flag of the current block, and information on whether the transform skip mode is used for the current block. For example, when the coded block flag of the current block is zero, the entropy encoding / entropy decoding of the flipping method information is omitted, and the transform mode information is not signaled. Further, the flipping method information can be predictively encoded / decoded during the entropy encoding / entropy decoding according to flipping method information of a reconstructed block neighboring the current block. Further, the flipping method information can be signaled based on at least one of coding parameters of the current block and the neighboring block.

[0368] In addition, a part of the above-described residual signal rearrangement method regarding the shuffling step can be determined by the encoder as the best rearrangement method, and information regarding the determined rearrangement method (flipping method information) can be signaled to the decoder. For example, when four kinds of rearrangement methods are used, the encoder signals up to two bits of information regarding the residual signal rearrangement method to the decoder.

[0369] Further, when the rearrangement methods used have different occurrence probabilities, the rearrangement methods having high occurrence probabilities are encoded using fewer bits, and the rearrangement methods having low occurrence probabilities are encoded using relatively more bits. For example, the four kinds of rearrangement methods are arranged in order of decreasing occurrence probability, and can be signaled as a truncated unary code (e.g., (0, 10, 110, 111) or (1, 01, 001, 000)).

[0370] Further, the occurrence probabilities of the rearrangement methods can vary according to coding parameters such as a prediction mode of the current CU, an intra prediction mode (direction) of a PU, a motion vector of a neighboring block, etc. Accordingly, the encoding method of the information regarding the rearrangement method (flipping method information) can be used differently according to the coding parameters. For example, the occurrence probabilities of the rearrangement methods can vary according to the prediction mode of the intra prediction. Accordingly, for each intra mode, fewer bits can be allocated to the rearrangement methods having high occurrence probabilities, and many bits can be allocated to the rearrangement methods having low occurrence probabilities. Alternatively, according to circumstances, the rearrangement methods having very low occurrence probabilities can not be used, and can not be allocated any bits.

[0371] A reordering set including at least one of the residual signal reordering methods may be constructed based on at least one of the following: a prediction mode (inter mode or intra mode), an intra prediction mode (including a directional mode and a non-directional mode), an inter prediction mode, a block size, a block shape (square or non-square), luma / chroma signals, transform mode information, and the like for the current block. The reordering may represent flipping. Furthermore, a reordering set including at least one of the residual signal reordering methods may be constructed based on at least one of the coding parameters of the current block and a neighboring block.

[0372] Furthermore, at least one of the following reordering sets may be selected based on at least one of a prediction mode, an intra-frame prediction mode, an inter-frame prediction mode, a block size, a block shape, a luminance / chrominance signal, transform mode information, etc. of a current block. Furthermore, at least one of the reordering sets may be selected based on at least one coding parameter of the current block and a neighboring block.

[0373] The rearrangement set may include at least one of “no flip,” “horizontal flip,” “vertical flip,” and “horizontal and vertical flip.” Examples of the rearrangement set are shown below.

[0374] 1. Do not flip

[0375] 2. Horizontal Flip

[0376] 3. Vertical Flip

[0377] 4. Horizontal and vertical flip

[0378] 5. No flip, and horizontal flip

[0379] 6. No flip, and vertical flip

[0380] 7. No flip, horizontal and vertical flip

[0381] 8. Horizontal flip and vertical flip

[0382] 9. Horizontal flip, and horizontal and vertical flip

[0383] 10. Vertical flip, horizontal and vertical flip

[0384] 11. No flip, horizontal flip, and vertical flip

[0385] 12. No flip, horizontal flip, and horizontal and vertical flip

[0386] 13. No flip, vertical flip, horizontal and vertical flip

[0387] 14. Flip horizontally, flip vertically, and flip horizontally and vertically

[0388] 15. no flipping, horizontal flipping, vertical flipping, and horizontal and vertical flipping

[0389] Based on the rearrangement set, at least one of the residual signal rearrangement methods can be used for rearrangement of the current block.

[0390] Further, based on at least one of the prediction mode of the current block, the intra prediction mode, the inter prediction mode, the block size, the block shape, the luma / chroma signal, the transform mode information, the flipping method information, and the like, at least one of the residual signal rearrangement methods can be selected in the rearrangement set. Further, based on at least one of the coding parameters of the current block and the neighboring block, at least one of the residual signal rearrangement methods can be selected in the rearrangement set.

[0391] Based on the prediction mode of the current block, at least one rearrangement set can be constructed. For example, when the prediction mode of the current block is the intra prediction, a plurality of rearrangement sets are constructed. When the prediction mode of the current block is the inter prediction, one rearrangement set is constructed.

[0392] Based on the luma / chroma signal of the current block, at least one rearrangement set can be constructed. For example, when the current block is the chroma signal, one rearrangement set is constructed. When the current block is the luma signal, a plurality of rearrangement sets are constructed.

[0393] Further, based on the rearrangement set, an index for the residual signal rearrangement method can be entropy encoded / entropy decoded. Here, the index can be entropy encoded / entropy decoded as a variable length code or a fixed length code.

[0394] Further, based on the rearrangement set, binarization and de-binarization of the index for the residual signal rearrangement method can be performed. Here, the index can be binarized and de-binarized as a variable length code or a fixed length code.

[0395] Further, the rearrangement set can be in the form of a table in the encoder and the decoder, and can be calculated by an equation.

[0396] Further, the rearrangement set can be constructed in a manner having symmetry. For example, a table for the rearrangement set can be constructed in a manner having symmetry. Here, the table can be constructed in a manner having symmetry for the intra prediction mode.

[0397] Further, the rearrangement set can be constructed according to at least one of whether the intra prediction mode is in a specific range, and whether the intra prediction mode is even or odd.

[0398] The following table shows an example of a method of encoding / decoding the residual signal rearrangement method according to the prediction mode and the intra prediction mode (direction) of the current block.

[0399] Further, in the following table, the flipping method information can be used to indicate the use of at least one of the residual signal rearrangement methods.

[0400] [Table 1]

[0401]

[0402] In Table 1, the columns (1) to (4) of the residual signal rearrangement method designate the residual signal rearrangement method, such as an index of a scan / rearrangement order for the above-described residual signal rearrangement, an index for a predetermined angle value, an index for a predetermined flipping method, etc. In Table 1, the marks * in the columns of the residual signal rearrangement method indicate that the corresponding rearrangement method is implicitly used without signaling, and the mark - indicates that the corresponding rearrangement method is not used in the corresponding case. The meaning of implicitly using the rearrangement method can be to use the rearrangement method with the transform mode information (sdst_flag or sdst flag) without entropy encoding / entropy decoding the index for the residual signal rearrangement method. The columns (1) to (4) of the residual signal rearrangement method can respectively designate (1) no flipping, (2) horizontal flipping, (3) vertical flipping, and (4) horizontal and vertical flipping. Further, the numbers 0, 1, 10, 11, 110, 111, etc. can be the result of binarization / debinarization for entropy encoding / entropy decoding the residual signal rearrangement method. As a binarization / debinarization method, a fixed length code, a truncated unary code, a unary code, etc. can be used. As shown in Table 1, when the current block corresponds to at least one of the prediction modes and the intra prediction modes (directions), at least one rearrangement method is used in the encoder and the decoder. Here, the diagonal direction of the 45-degree angle can mean a direction toward the upper left position in the current block or a direction from the upper left position in the current block toward the current block.

[0403] [Table 2]

[0404]

[0405] As another example, as shown in Table 2, when the current block corresponds to at least one of the prediction modes and at least one of the intra prediction modes (directions), at least one rearrangement method is used in the encoder and the decoder.

[0406] [Table 3]

[0407]

[0408] As another example, as shown in Table 3, when the current block corresponds to at least one of the prediction modes and at least one of the intra prediction modes (directions), at least one of the rearrangement methods is used in the encoder and the decoder. Here, the residual signal rearrangement method can denote a type of transform. For example, when the residual signal rearrangement method is (1), both the horizontal transform and the vertical transform denote the first transform kernel. As another example, when the residual signal rearrangement method is (2), the horizontal transform and the vertical transform denote the second transform kernel and the first transform kernel, respectively. As another example, when the residual signal rearrangement method is (3), the horizontal transform and the vertical transform denote the first transform kernel and the second transform kernel, respectively. As another example, when the residual signal rearrangement method is (4), the horizontal transform and the vertical transform denote the second transform kernel and the second transform kernel, respectively. For example, the first transform kernel can be DST-7, and the second transform kernel can be DCT-8. When the intra prediction mode is the planar mode or the DC mode, information about the four rearrangement methods (flipping method information) is entropy encoded / entropy decoded using a frequency-of-occurrence-based truncated unary code. In the case of inter prediction, the occurrence probabilities of the rearrangement methods (1) to (4) can be considered to be equal, and information about the rearrangement method can be entropy encoded / entropy decoded as a two-bit fixed-length code.

[0409] Arithmetic encoding / decoding can be used for the code. Furthermore, arithmetic encoding using a context model for the code can not be used, and entropy encoding / entropy decoding can be performed in a bypass mode.

[0410] Transform / inverse transform using DST-7 can be performed for a region or a CTU within a picture, the entire picture, or the current block within a group of pictures without flipping, or can be performed by selecting one of two methods of performing transform / inverse transform using DCT-2. In this case, 1-bit flag information (transform mode information) indicating whether to use DST-7 or DCT-2 in units of the current block can be entropy encoded / entropy decoded. This method can be used for a case in which the longer the distance from a reference sample, the greater the energy of a residual signal, or can be used to reduce the computational complexity in encoding and decoding. Information about a region using this method can be signaled in units of a CTU, a slice, a PPS, an SPS, or other specific regions, and a 1-bit flag can be signaled in an on / off form.

[0411] For a current block in a region or CTU within a picture, a whole picture, or a group of pictures, a transform / inverse transform can be performed by selecting one of the following five methods: DCT-2 transform / inverse transform, DST-7 transform / inverse transform without flipping, DST-7 transform / inverse transform after horizontal flipping, DST-7 transform / inverse transform after vertical flipping, and DST-7 transform / inverse transform after horizontal and vertical flipping. Information on which transform among the five methods will be selected can be implicitly selected using nearby information of the current block, and can be explicitly selected by signaling an index (transform mode information or flipping method information). The index can be signaled as a truncated unary code in the following manner: DCT-2 is 0, DST-7 without flipping is 10, DST-7 after horizontal flipping is 110, DST-7 after vertical flipping is 1110, and DST-7 after horizontal and vertical flipping is 1111. In addition, binarization of DCT-2 and DST-7 can be exchanged for signaling according to the size of the current block and nearby information. In addition, the first bin among the bins can be signaled in a CU unit, and the remaining bins can be signaled in a TU or PU unit. In addition, information can be signaled as a fixed length code by distinguishing the first bin, the second bin, and the third bin among the bins. For example, the transform mode information or the flipping method information can be signaled in the following manner: DCT-2 is 0, DST-7 without flipping is 000, DST-7 after horizontal flipping is 001, DST-7 after vertical flipping is 010, and DST-7 after horizontal and vertical flipping is 011. In addition, according to an intra prediction mode, only a part of the five methods can be used. For example, when the intra prediction mode is a prediction mode close to a horizontal direction prediction mode, only three transform methods are used: DCT-2, DST-7 without flipping, and DST-7 after vertical flipping. In this case, the transform mode information or the flipping method information can be signaled in the following manner: DCT-2 is 0, DST-7 without flipping is 10, and DST-7 after vertical flipping is 11.

[0412] FIG. 8 FIG. 1 is a diagram illustrating an embodiment of a decoding method using an SDST method according to the present application.

[0413] Referring to FIG. 8 First, in step 801, a transform mode of a current block can be determined, and in step 802, an inverse transform can be performed on residual data of the current block according to the transform mode of the current block.

[0414] Next, at step 803, rearrangement can be performed on the residual data of the current block on which inverse transform has been performed according to the transform mode of the current block.

[0415] Here, the transform mode can include at least one of mixed rearranged discrete sine transform (SDST), mixed rearranged discrete cosine transform (SDCT), discrete sine transform (DST), and discrete cosine transform (DCT).

[0416] The SDST mode can indicate a mode in which inverse transform is performed in the DST-7 transform mode and rearrangement is performed on the residual data on which inverse transform has been performed.

[0417] The SDCT mode can indicate a mode in which inverse transform is performed in the DCT-2 transform mode and rearrangement is performed on the residual data on which inverse transform has been performed.

[0418] The DST mode can indicate a mode in which inverse transform is performed in the DST-7 transform mode and rearrangement is not performed on the residual data on which inverse transform has been performed.

[0419] The DCT mode can indicate a mode in which inverse transform is performed in the DCT-2 transform mode and rearrangement is not performed on the residual data on which inverse transform has been performed.

[0420] Accordingly, rearrangement of the residual data is performed only when the transform mode of the current block is one of the SDST and the SDCT.

[0421] Although it is described that inverse transform is performed in the DST-7 transform mode for the SDST and the DST mode as described above, transform modes based on other DSTs such as DST-1, DST-2, etc. can be used.

[0422] In addition, the step of determining the transform mode of the current block at step 801 can include obtaining transform mode information of the current block from a bitstream, and determining the transform mode of the current block based on the transform mode information.

[0423] Further, when determining the transform mode of the current block at step 801, the transform mode of the current block can be determined based on at least one of a prediction mode of the current block, depth information of the current block, a size of the current block, and a shape of the current block.

[0424] Specifically, when the prediction mode of the current block is an inter prediction mode, one of the SDST and the SDCT is determined as the transform mode of the current block.

[0425] In addition, the rearranging of the residual data of the current block on which the inverse transform has been performed in step 803 can include: scanning the residual data arranged within the current block on which the inverse transform has been performed in a first direction order; and rearranging the residual data scanned in the first direction within the current block on which the inverse transform has been performed in a second direction order. Here, the first direction order can be one of a raster scan order, a top-right diagonal scan order, a horizontal scan order, and a vertical scan order. In addition, the first direction order can be defined as follows.

[0426] (1) Scanning from an upper row to a lower row, and scanning from left to right in a row

[0427] (2) Scanning from an upper row to a lower row, and scanning from right to left in a row

[0428] (3) Scanning from a lower row to an upper row, and scanning from left to right in a row

[0429] (4) Scanning from a lower row to an upper row, and scanning from right to left in a row

[0430] (5) Scanning from a left column to a right column, and scanning from top to bottom in a column

[0431] (6) Scanning from a left column to a right column, and scanning from bottom to top in a column

[0432] (7) Scanning from a right column to a left column, and scanning from top to bottom in a column

[0433] (8) Scanning from a right column to a left column, and scanning from bottom to top in a column

[0434] (9) Spiral scan: scanning from an inside (or outside) of the block to an outside (or inside) of the block, and scanning in a clockwise / counter-clockwise direction

[0435] In addition, for the second direction order, one of the above-described directions can be selectively used. The first direction and the second direction can be the same, or can be different from each other.

[0436] In addition, when rearranging the residual data of the current block on which the inverse transform has been performed in step 803, the rearranging can be performed in units of sub-blocks within the current block. In this case, the residual data can be rearranged based on positions of the sub-blocks within the current block.

[0437] In addition, when rearranging the residual data of the current block on which the inverse transform has been performed in step 803, the residual data arranged within the current block on which the inverse transform has been performed can be rotated by a predefined angle to be rearranged.

[0438] Further, in rearranging the residual data of the current block on which the inverse transform has been performed in step 803, flipping can be performed on the residual data arranged in the current block on which the inverse transform has been performed to rearrange, according to a flipping method. In this case, the step of determining the transform mode of the current block in step 801 can include obtaining flipping method information from the bitstream; and determining the flipping method for the current block based on the flipping method information.

[0439] FIG. 9 is a diagram illustrating an embodiment of an encoding method using an SDST method according to the present application.

[0440] Referring to FIG. 9 In step 901, the transform mode of the current block can be determined.

[0441] Next, in step 902, the residual data of the current block can be rearranged according to the transform mode of the current block.

[0442] Next, in step 903, the residual data of the current block rearranged according to the transform mode of the current block can be transformed.

[0443] Here, the transform mode can include at least one of a shuffled discrete sine transform (SDST), a shuffled discrete cosine transform (SDCT), a discrete sine transform (DST), and a discrete cosine transform (DCT). Since the SDST, the SDCT, the DST, and the DCT mode have been described with reference to FIG. 8 The repeated description will be omitted.

[0444] In addition, the rearranging of the residual data is performed only when the transform mode of the current block is one of the SDST and the SDCT.

[0445] Further, in determining the transform mode of the current block in step 901, the transform mode of the current block can be determined based on at least one of a prediction mode of the current block, depth information of the current block, a size of the current block, and a shape of the current block.

[0446] Here, when the prediction mode of the current block is an inter prediction mode, one of the SDST and the SDCT is determined as the transform mode of the current block.

[0447] In addition, the step of rearranging the residual data of the current block in step 902 can include scanning the residual data arranged in the current block in order of a first direction; and rearranging the residual data scanned in the first direction within the current block in order of a second direction.

[0448] Further, in rearranging the residual data of the current block in step 902, the rearranging is performed in units of sub-blocks within the current block.

[0449] In this case, when the residual data of the current block is rearranged at step 902, the residual data can be rearranged based on a position of the sub-block within the current block.

[0450] In addition, when the residual data of the current block is rearranged at step 902, the residual data arranged within the current block can be rotated at a predefined angle to be rearranged.

[0451] In addition, when the residual data of the current block is rearranged at step 902, the residual data arranged within the current block can be flipped according to a flipping method to be rearranged.

[0452] An image decoder using an SDST method according to the present application can include an inverse transform module, wherein the inverse transform module determines a transform mode of a current block, performs inverse transform on residual data of the current block according to the transform mode of the current block, and rearranges the residual data of the current block on which inverse transform has been performed according to the transform mode of the current block. Here, the transform mode can include at least one of a shuffle-discrete sine transform (SDST), a shuffle-discrete cosine transform (SDCT), a discrete sine transform (DST), and a discrete cosine transform (DCT).

[0453] An image decoder using an SDST method according to the present application can include an inverse transform module, wherein the inverse transform module determines a transform mode of a current block, performs inverse transform on residual data of the current block according to the transform mode of the current block, and rearranges the residual data of the current block on which inverse transform has been performed according to the transform mode of the current block. Here, the transform mode can include at least one of a shuffle-discrete sine transform (SDST), a shuffle-discrete cosine transform (SDCT), a discrete sine transform (DST), and a discrete cosine transform (DCT).

[0454] An image encoder using an SDST method according to the present application can include a transform module, wherein the transform module determines a transform mode of a current block, and rearranges residual data of the current block according to the transform mode of the current block, and transforms the residual data of the current block rearranged according to the transform mode of the current block. Here, the transform mode can include at least one of a shuffle-discrete sine transform (SDST), a shuffle-discrete cosine transform (SDCT), a discrete sine transform (DST), and a discrete cosine transform (DCT).

[0455] An image encoder using an SDST method according to the present application can include a transform module, wherein the transform module determines a transform mode of a current block, transforms residual data of the current block according to the transform mode of the current block, and rearranges the residual data of the current block transformed according to the transform mode of the current block. Here, the transform mode can include at least one of a mixed rearranged discrete sine transform (SDST), a mixed rearranged discrete cosine transform (SDCT), a discrete sine transform (DST), and a discrete cosine transform (DCT).

[0456] A bitstream generated by an encoding method using an SDST method according to the present application can be provided, wherein the encoding method includes determining a transform mode of a current block, rearranging residual data of the current block according to the transform mode of the current block, and transforming the residual data of the current block rearranged according to the transform mode of the current block, wherein the transform mode can include at least one of a mixed rearranged discrete sine transform (SDST), a mixed rearranged discrete cosine transform (SDCT), a discrete sine transform (DST), and a discrete cosine transform (DCT).

[0457] Further, a transform used in the present specification can be selected from a set of N predefined transform candidates for each block. Here, N can be a positive integer. Each of the transform candidates can specify a primary horizontal transform, a primary vertical transform, and a secondary transform (which can be identical to an identity transform). The list of transform candidates can vary according to the block size and the prediction mode. The selected transform can be signaled as follows. When the coding block flag is one, a flag indicating whether the first transform of the candidate list is used is signaled. When the flag indicating whether the first transform of the candidate list is used is zero, the following is applied: when the number of non-zero transform coefficient levels is greater than a threshold, a transform index indicating the used transform candidate is signaled; otherwise, the second transform of the list is used.

[0458] Further, NSST is used as a secondary transform only when DCT-2 as a primary transform is used as a default transform. Further, as for a horizontal transform or a vertical transform, DST-7 is selected without signaling when the width or the height is each equal to or smaller than 4.

[0459] As for a residual block, DST-7 instead of DCT-2 is used for a one-dimensional horizontal transform when the width of the block is equal to or smaller than K. DST-7 instead of DCT-2 is used for a one-dimensional vertical transform when the height of the block is equal to or smaller than L. Further, even when the width or the height of the block is equal to or smaller than K, DCT-2 is used when the intra prediction mode is a linear model (LM) chroma mode. Here, K and L can be positive integers, for example, 4. Further, K and L can be the same or can have different values. Further, the residual block can be a block encoded in an intra mode. Further, the residual block can be a chroma block.

[0460] As an alternative to the flipping method performed on the residual signal, a transform / inverse transform can be performed using a transform kernel or transform matrix that has already been flipped. Here, the transform / inverse transform kernel or transform / inverse transform matrix that has already been flipped can be a kernel or matrix that has undergone flipping and is predefined in the encoder / decoder. In this case, since the transform / inverse transform matrix that has already been flipped is used to perform the transform / inverse transform, the same effect as performing flipping on the residual signal can be obtained. Here, the flipping can be at least one of no flipping, horizontal flipping, vertical flipping, and horizontal and vertical flipping. In this case, information about whether the transform / inverse transform that has already been flipped is used can be signaled. Also, information about whether the transform / inverse transform that has already been flipped is used can be signaled for each of the transform / inverse transform in the horizontal direction and the transform / inverse transform in the vertical direction.

[0461] Also, as an alternative to the flipping method performed on the residual signal, flipping can be performed on a transform kernel or transform matrix to perform a transform / inverse transform in the encoding / decoding process. In this case, since flipping is performed on the transform / inverse transform matrix to perform the transform / inverse transform, the same effect as performing flipping on the residual signal can be obtained. Here, the flipping can be at least one of no flipping, horizontal flipping, vertical flipping, and horizontal and vertical flipping. In this case, information about whether flipping is performed on the transform / inverse transform matrix can be signaled. Also, information about whether flipping is performed on the transform / inverse transform matrix can be signaled for each of the transform / inverse transform in the horizontal direction and the transform / inverse transform in the vertical direction.

[0462] When the flipping method is determined based on the intra prediction mode and two or more intra prediction modes of the current block are used, flipping is performed before / after the transform / inverse transform of the current block as the flipping method for the non-directional mode.

[0463] Also, when the flipping method is determined based on the intra prediction mode and two or more intra prediction modes of the current block are used, flipping is performed before / after the transform / inverse transform of the current block as the flipping method for the primary directional mode. Here, the primary directional mode can be at least one of the vertical mode, the horizontal mode, and the diagonal mode.

[0464] When the size of the transform is equal to or greater than MxN, all transform coefficients existing in the region of M / 2 to M and N / 2 to N during the transform or after the transform are set to a value of 0. Here, M and N can be positive integers, for example, 64x64.

[0465] In order to reduce memory requirements, a right shift operation by K can be performed on the transform coefficients generated after performing the transform. Also, a right shift operation by K can be performed on the temporary transform coefficients generated after performing the horizontal transform. Also, a right shift operation by K can be performed on the temporary transform coefficients generated after performing the vertical transform. Here, K is a positive integer.

[0466] In order to reduce memory requirements, a right shift operation by K can be performed on the reconstructed residual signal generated after performing the inverse transform. Also, a right shift operation by K can be performed on the temporary transform coefficients generated after performing the horizontal inverse transform. Also, a right shift operation by K can be performed on the temporary transform coefficients generated after performing the vertical inverse transform. Here, K is a positive integer.

[0467] At least one of the signals generated before performing the transform / inverse transform in the horizontal direction, after performing the transform / inverse transform in the horizontal direction, before performing the transform / inverse transform in the vertical direction, and after performing the transform / inverse transform in the vertical direction can be subjected to at least one of the flipping methods. In this case, flipping method information used in the transform / inverse transform in the horizontal direction or the transform / inverse transform in the vertical direction can be signaled.

[0468] Also, DCT-4 can be used instead of DST-7. A 2N-1 size DCT-4 transform / inverse transform matrix is extracted from a 2N size DCT-2 transform / inverse transform matrix for use, so only the DCT-2 transform / inverse transform matrix, not the DCT-4 transform / inverse transform matrix, is stored in the encoder / decoder, thereby reducing the memory requirements of the encoder / decoder. Also, 2N-1 size DCT-4 transform / inverse transform logic is utilized from 2N size DCT-2 transform / inverse transform logic, so the chip area required to implement the encoder / decoder is reduced. Here, the above examples are applied not only to DCT-2 and DCT-4, and when there is a transform matrix or transform logic shared between at least one of the types of DST transform / inverse transform and at least one of the types of DCT transform / inverse transform. That is, another transform / inverse transform matrix or logic can be extracted from one transform / inverse transform matrix or logic for use. Also, another transform / inverse transform matrix or logic can be extracted from one transform / inverse transform matrix or logic for use in the case of a specific transform / inverse transform size. Also, another transform / inverse transform matrix can be extracted from one transform / inverse transform matrix in at least one of a matrix unit, a basis vector unit, and a matrix coefficient unit.

[0469] Further, when the current block is smaller than the size of MxN, another transform / inverse transform is used for the transform / inverse transform of the current block instead of the specific transform / inverse transform. Further, when the current block is larger than the size of MxN, another transform / inverse transform is used for the transform / inverse transform of the current block instead of the specific transform / inverse transform. Here, M and N are positive integers. The specific transform / inverse transform and the other transform / inverse transform can be transform / inverse transform that are predefined in the encoder / decoder.

[0470] Further, at least one of the transforms of DCT-4, DCT-8, DCT-2, DST-4, DST-1, DST-7, etc. used in the present specification can be replaced by at least one of the transforms calculated based on the transforms of DCT-4, DCT-8, DCT-2, DST-4, DST-1, DST-7, etc. Here, the calculated transform can be a transform calculated by modifying the coefficient values within the transform matrix of DCT-4, DCT-8, DCT-2, DST-4, DST-1, DST-7, etc. Further, the coefficient values within the transform matrix of DCT-4, DCT-8, DCT-2, DST-4, DST-1, DST-7, etc. can have integer values. That is, the transforms of DCT-4, DCT-8, DCT-2, DST-4, DST-1, DST-7, etc. can be integer transforms. Further, the coefficient values within the calculated transform matrix can have integer values. That is, the calculated transform can be an integer transform. Further, the calculated transform can be a result of performing a left shift operation by N on the coefficient values within the transform matrix of DCT-4, DCT-8, DCT-2, DST-4, DST-1, DST-7, etc. Here, N can be a positive integer.

[0471] The DCT-Q and DST-W transforms can denote including the DCT-Q and DST-W transforms and the DCT-Q and DST-W inverse transforms. Here, Q and W can have a positive integer 1 or a positive integer greater than or equal to 1, and for example, the numbers 1 to 9 can have the same meaning as the Roman numerals I to IX.

[0472] Further, the transforms of DCT-4, DCT-8, DCT-2, DST-4, DST-1, DST-7, etc. used in the present specification are not limited thereto, and at least one of the DCT-Q transform and the DST-W transform can be used by replacing the transforms of DCT-4, DCT-8, DCT-2, DST-4, DST-1, DST-7. Here, Q and W can have a positive integer 1 or a positive integer greater than or equal to 1, and for example, the numbers 1 to 9 can have the same meaning as the Roman numerals I to IX.

[0473] Further, in the case of a square block, the transform used in the present specification can be performed in a square transform form. In the case of a non-square block, the transform can be performed in a non-square transform form. In the case of a square shape region including at least one of a square block and a non-square block, the transform can be performed on the region in a square transform form. In the case of a non-square shape region including at least one of a square block and a non-square block, the transform can be performed on the region in a non-square transform form.

[0474] Further, in the present specification, the information on the rearrangement method can be flip method information.

[0475] Further, the transform used in the present specification can denote at least one of a transform and an inverse transform.

[0476] The encoder can perform a transform on the residual block to generate transform coefficients, quantize the transform coefficients to generate quantized coefficient levels, and entropy encode the quantized coefficient levels, in order to improve subjective / objective image quality of the image.

[0477] The decoder can entropy decode the quantized coefficient levels, dequantize the quantized coefficient levels to generate transform coefficients, and inverse transform the transform coefficients to generate a reconstructed residual block.

[0478] The transform type information on which transform is used as the transform and the inverse transform can be explicitly entropy encoded / entropy decoded. Further, the transform type information on which transform is used as the transform and the inverse transform can be implicitly determined based on at least one of the encoding parameters, without entropy encoding / entropy decoding the transform type information on which transform is used as the transform and the inverse transform.

[0479] Hereinafter, embodiments of an image encoding / decoding method and apparatus for performing at least one of a transform or an inverse transform, and a recording medium for storing a bitstream in the present application will be described.

[0480] Using at least one of the following embodiments, a block can be partitioned into N sub-blocks, and at least one of prediction, transform / inverse transform, quantization / dequantization, or entropy encoding / entropy decoding can be performed. Such a mode can be referred to as a first sub-block partitioning mode (e.g., an ISP mode or an intra-sub-partitioning mode).

[0481] A block can denote a coding block, a prediction block, or a transform block. For example, the block can be a transform block.

[0482] Further, the partitioned sub-block can denote at least one of a coding block, a prediction block, or a transform block. For example, the partitioned sub-block can be a transform block.

[0483] Also, the block or partitioned sub-blocks can be at least one of an intra block, an inter block, or an intra block copy block. For example, the block and sub-blocks can be intra blocks.

[0484] Also, the block or partitioned sub-blocks can be at least one of an intra prediction block, an inter prediction block, or an intra block copy prediction block. For example, the block and sub-blocks can be intra prediction blocks.

[0485] Also, the block or partitioned sub-blocks can be at least one of a luma signal block or a chroma signal block. For example, the block and sub-blocks can be luma signal blocks.

[0486] When the block is partitioned into N sub-blocks, the block before partitioning can be a coding block, and the partitioned sub-blocks can be at least one of a prediction block or a transform block. That is, prediction of transform coefficients, transform / inverse transform, quantization / dequantization, entropy encoding / entropy decoding can be performed with the size of the partitioned sub-blocks.

[0487] Also, when the block is partitioned into N sub-blocks, the block before partitioning can be at least one of a coding block or a prediction block, and the partitioned sub-blocks can be transform blocks. That is, prediction can be performed with the size of the block before partitioning, and transform / inverse transform, quantization / dequantization, entropy encoding / entropy decoding of transform coefficients can be performed with the size of the partitioned sub-blocks.

[0488] Whether the block is partitioned into a plurality of sub-blocks can be determined based on at least one of an area (a product of width and height, etc.), a size (width, height, or a combination of width and height), and a shape / form (rectangular (non-square), square, etc.) of the block.

[0489] For example, when the current block is a 64x64 block, the current block can be partitioned into a plurality of sub-blocks.

[0490] As another example, when the current block is a 32x32 block, the current block can be partitioned into a plurality of sub-blocks.

[0491] As another example, when the current block is a 32x16 block, the current block can be partitioned into a plurality of sub-blocks.

[0492] As another example, when the current block is a 16x32 block, the current block can be partitioned into a plurality of sub-blocks.

[0493] As another example, when the current block is a 4x4 block, the current block can not be partitioned into a plurality of sub-blocks.

[0494] As another example, when the current block is a 2x4 block, the current block can not be partitioned into a plurality of sub-blocks.

[0495] As another example, when an area of the current block is equal to or greater than 32, the current block can be partitioned into a plurality of sub-blocks.

[0496] As another example, when the area of the current block is less than 32, the current block can not be partitioned into a plurality of sub-blocks.

[0497] As another example, when the area of the current block is 256 and the shape of the current block is rectangular, the current block can be partitioned into a plurality of sub-blocks.

[0498] As another example, when the area of the current block is 16 and the shape of the current block is square, the current block can not be partitioned into a plurality of sub-blocks.

[0499] When the block is partitioned, the block can be partitioned into a plurality of sub-blocks in at least one partition direction of a vertical direction or a horizontal direction.

[0500] For example, the current block can be partitioned into two sub-blocks in the vertical direction.

[0501] As another example, the current block can be partitioned into two sub-blocks in the horizontal direction.

[0502] As another example, the current block can be partitioned into four sub-blocks in the horizontal direction.

[0503] As another example, the current block can be partitioned into four sub-blocks in the vertical direction.

[0504] When the block is partitioned into N sub-blocks, N can be a positive integer, and can be, for example, 2 or 4. In addition, N can be determined using at least one of the area, the size, the shape, or the partition direction of the block.

[0505] For example, when the current block is a 4×8 or 8×4 block, the current block can be partitioned into two sub-blocks in the horizontal direction or two sub-blocks in the vertical direction.

[0506] As another example, when the current block is a 16×8 or 16×16 block, the current block can be partitioned into four sub-blocks in the vertical direction or four sub-blocks in the horizontal direction.

[0507] As another example, when the current block is an 8×32 or 32×32 block, the current block can be partitioned into four sub-blocks in the horizontal direction or four sub-blocks in the vertical direction.

[0508] As another example, when the current block is a 16×4, 32×4, or 64×4 block, the current block can be partitioned into four sub-blocks in the vertical direction. In addition, when the current block is a 16×4, 32×4, or 64×4 block, the current block can be partitioned into two sub-blocks in the horizontal direction.

[0509] As another example, when the current block is a 4×16, 4×32, or 4×64 block, the current block can be partitioned into four sub-blocks in a horizontal direction. Also, when the current block is a 4×16, 4×32, or 4×64 block, the current block can be partitioned into two sub-blocks in a vertical direction.

[0510] As another example, when the current block is a J×4 block, the current block can be partitioned into two sub-blocks in a horizontal direction. Here, J can be a positive integer.

[0511] As another example, when the current block is a 4×K block, the current block can be partitioned into two sub-blocks in a vertical direction. Here, K can be a positive integer.

[0512] As another example, when the current block is a J×K (K>4) block, the current block can be partitioned into four sub-blocks in a horizontal direction. Here, J can be a positive integer.

[0513] As another example, when the current block is a J×K (J>4) block, the current block can be partitioned into four sub-blocks in a vertical direction. Here, J can be a positive integer.

[0514] As another example, when the current block is a J×K (K>4) block, the current block can be partitioned into four sub-blocks in a vertical direction. Here, J can be a positive integer.

[0515] As another example, when the current block has an area of 64, the current block can be partitioned into four sub-blocks in a horizontal direction or a vertical direction.

[0516] As another example, when the current block is a 16×4 block and a shape of the current block is a rectangle, the current block can be partitioned into four sub-blocks in a vertical direction.

[0517] As another example, when the current block has an area of 1024 and a shape of the current block is a square, the current block can be partitioned into four sub-blocks in a horizontal direction or a vertical direction.

[0518] Also, the sub-blocks can have at least one of a minimum area, a minimum width, or a minimum height.

[0519] For example, the sub-blocks can have S as the minimum area. Here, S can be a positive integer, and can be, for example, 16.

[0520] As another example, the sub-blocks can have J as the minimum width. Here, J can be a positive integer, and can be, for example, 4.

[0521] As another example, the sub-blocks can have K as the minimum height. Here, K can be a positive integer, and can be, for example, 4.

[0522] In each partitioned sub-block, a reconstructed block can be generated by adding a residual block (or a reconstructed residual block) and a prediction block. Here, at least one of the reconstructed samples in each reconstructed sub-block can be used as a reference sample in the intra prediction of the coded / decoded sub-block later.

[0523] The coding / decoding order of the sub-blocks partitioned from the block can be determined according to at least one of the partition directions.

[0524] For example, the coding / decoding order of the horizontally partitioned sub-blocks can be determined as an order from the top direction to the bottom direction.

[0525] As another example, the coding / decoding order of the vertically partitioned sub-blocks can be determined as an order from the left direction to the right direction.

[0526] For the partitioned sub-blocks, an intra prediction mode can be shared and used.

[0527] At this time, information about the intra prediction mode for each sub-block can be entropy coded / entropy decoded only once in the block before partitioning.

[0528] For the partitioned sub-blocks, an intra block copy mode can be shared and used.

[0529] At this time, information about the intra block copy mode for each sub-block can be entropy coded / entropy decoded only once in the block before partitioning.

[0530] To indicate a sub-block partitioning mode that partitions a block into N sub-blocks and performs at least one of prediction, transform / inverse transform, quantization / dequantization, or entropy coding / entropy decoding in units of sub-blocks, at least one of sub-block partitioning mode information or partition direction information can be entropy coded / entropy decoded.

[0531] Here, the sub-block partitioning mode information can be used to indicate the sub-block partitioning mode. When it is indicated that the sub-block partitioning mode is used (second value), the block can be partitioned into sub-blocks, and at least one of prediction, transform / inverse transform, quantization / dequantization, or entropy coding / entropy decoding can be performed. When it is indicated that the sub-block partitioning mode is not used (first value), the block can not be partitioned into sub-blocks, and at least one of prediction, transform / inverse transform, quantization / dequantization, or entropy coding / entropy decoding can be performed. Here, the first value can be 0, and the second value can be 1.

[0532] In addition, the partition direction information can be used to indicate whether the sub-block partitioning mode is vertical partitioning or horizontal partitioning. When the partition direction information has a first value, the block can be partitioned into sub-blocks in a horizontal direction, and the first value can be 0. In addition, when the partition direction information has a second value, the block can be partitioned into sub-blocks in a vertical direction, and the second value can be 1.

[0533] When the current block does not use the closest reference sample line (the first reference sample line) as the reference sample line, at least one of the sub-block partition mode information or the partition direction information can not be entropy encoded / entropy decoded. At this time, it can be inferred from the sub-block partition mode information that the current block is not partitioned into sub-blocks.

[0534] Here, the current block not using the closest reference sample line (the first reference sample line) as the reference sample line can mean that the second reference sample line or a larger reference sample line can be used as the reconstructed reference line around the current block.

[0535] That is, at least one of the sub-block partition mode information or the partition direction information can be entropy encoded / entropy decoded only when the current block uses the closest reference sample line as the reference sample line.

[0536] At least one of the area, size, shape, or partition direction of the coefficient group used during the entropy encoding / entropy decoding of the transform coefficient can be determined based on at least one of the area, size, shape, or partition direction of the sub-block.

[0537] For example, when the area of the sub-block is 16, the area of the coefficient group can be determined as 16.

[0538] As another example, when the area of the sub-block is 32, the area of the coefficient group can be determined as 16.

[0539] As another example, when the size of the sub-block is 1×16 or 16×1, the size of the coefficient group can be determined as 1×16 or 16×1.

[0540] As another example, when the size of the sub-block is 2×8 or 8×2, the size of the coefficient group can be determined as 2×8 or 8×2.

[0541] As another example, when the size of the sub-block is 4×4, the size of the coefficient group can be determined as 4×4.

[0542] As another example, when the width of the sub-block is 2, the width of the coefficient group can be determined as 2.

[0543] As another example, when the width of the sub-block is 4, the width of the coefficient group can be determined as 4.

[0544] As another example, when the height of the sub-block is 2, the height of the coefficient group can be determined as 2.

[0545] As another example, when the height of the sub-block is 4, the height of the coefficient group can be determined as 4.

[0546] As another example, when the shape of the sub-block is rectangular (non-square), the shape of the coefficient group can be determined as rectangular (non-square).

[0547] As another example, when the shape of the sub-block is a square, the shape of the coefficient group can be determined as a square.

[0548] As another example, when the size of the sub-block is 16x4 and the form thereof is a rectangle, the size of the coefficient group can be determined as at least one of 4x4 or 8x2.

[0549] As another example, when the size of the sub-block is 4x8 and the form thereof is a rectangle, the size of the coefficient group can be determined as at least one of 4x4 or 2x8.

[0550] As another example, when the size of the sub-block is 32x4 and the form thereof is a rectangle, the size of the coefficient group can be determined as at least one of 4x4 or 8x2.

[0551] As another example, when the size of the sub-block is 8x64 and the form thereof is a rectangle, the size of the coefficient group can be determined as at least one of 4x4 or 2x8.

[0552] As another example, when the size of the sub-block is 16x4 and the partition direction is a vertical direction, the size of the coefficient group can be determined as 4x4.

[0553] As another example, when the size of the sub-block is 4x8 and the partition direction is a horizontal direction, the size of the coefficient group can be determined as 4x4.

[0554] As another example, when the size of the sub-block is 32x4 and the partition direction is a horizontal direction, the size of the coefficient group can be determined as 8x2.

[0555] As another example, when the size of the sub-block is 8x64 and the partition direction is a vertical direction, the size of the coefficient group can be determined as 2x8.

[0556] For each partitioned sub-block, an encoded block flag indicating whether there is at least one transform coefficient having a non-zero value in the sub-block unit can be entropy encoded / decoded.

[0557] For example, the encoded block flag can indicate that there is at least one transform coefficient having a non-zero value in at least one sub-block in a sub-block unit.

[0558] As another example, when m denotes the total number of sub-blocks and the encoded block flags of the m-1 sub-blocks from the front of the sub-blocks indicate that there is no transform coefficient having a non-zero value, it can be inferred that the encoded block flag of the mth sub-block indicates that there is at least one transform coefficient having a non-zero value.

[0559] As another example, when the encoded block flag is entropy encoded / decoded in a sub-block unit, the encoded block flag can be entropy encoded / decoded in a block unit before partitioning.

[0560] As another example, when the coding block flag is entropy coded / entropy decoded in units of a block before partitioning, the coding block flag can not be entropy coded / entropy decoded in units of a sub-block.

[0561] In addition, when the current block is in the first sub-block partition mode and the size of the current block is a pre-defined size, the size of a sub-block for intra prediction and the size of a sub-block for transform can be different from each other. That is, the sub-block partition for intra prediction and the sub-block partition for transform can be different from each other. Here, the pre-defined size can be 4xN or 8xN (N>4). Here, the sub-block partition can mean vertical partitioning.

[0562] For example, when the current block is in the first sub-block partition mode and the size of the current block is 8xN (N>4), the current block can be vertically partitioned into sub-blocks of 4xN for intra prediction, and the current block can be vertically partitioned into sub-blocks of 1xN for transform. At this time, one-dimensional transform / inverse transform can be performed in order to perform transform of 1xN. That is, one-dimensional transform / inverse transform can be performed based on at least one of the partition mode of the current block or the size of the current block.

[0563] As another example, when the current block is in the first sub-block partition mode and the size of the current block is 8xN (N>4), the current block can be vertically partitioned into sub-blocks of 4xN for intra prediction, and the current block can be vertically partitioned into sub-blocks of 2xN for transform. At this time, two-dimensional transform / inverse transform can be performed in order to perform transform of 2xN. That is, two-dimensional transform / inverse transform can be performed based on at least one of the partition mode of the current block or the size of the current block.

[0564] Here, N can mean a positive integer, and can be a positive integer less than 64 or 128.

[0565] In addition, the size of the current block can mean at least one of the size of a coding block of the current block, the size of a prediction block, or the size of a transform block.

[0566] As in the example of FIG. 10 According to the embodiment of the first sub-block partition mode, the current block can be partitioned into two sub-blocks in a horizontal direction and can be partitioned into two sub-blocks in a vertical direction.

[0567] As in the example of FIG. 11 According to the embodiment of the first sub-block partition mode, the current block can be partitioned into two sub-blocks in a horizontal direction and can be partitioned into two sub-blocks in a vertical direction.

[0568] As in the example of FIG. 12In an example, according to an embodiment of the first sub-block partitioning mode, the current block can be partitioned into four sub-blocks in a horizontal direction and can be partitioned into four sub-blocks in a vertical direction.

[0569] Using at least one of the embodiments in the following embodiments, a block can be partitioned into N sub-blocks so that at least one of a transform / inverse transform, quantization / dequantization, or entropy encoding / entropy decoding is performed in units of sub-blocks. Such a mode can be referred to as a second sub-block partitioning mode (e.g., SBT mode or sub-block transform mode).

[0570] A block can represent at least one of a coding block, a prediction block, or a transform block. For example, a block can be a transform block.

[0571] Further, a partitioned sub-block can represent at least one of a coding block, a prediction block, or a transform block. For example, a partitioned sub-block can be a transform block.

[0572] Further, a block or a partitioned sub-block can be at least one of an intra block, an inter block, or an intra block copy block. For example, a block or a partitioned sub-block can be an inter block.

[0573] Further, a block or a partitioned sub-block can be at least one of an intra prediction block, an inter prediction block, or an intra block copy prediction block. For example, a block can be an inter prediction block.

[0574] Further, a block or a partitioned sub-block can be at least one of a luma signal block or a chroma signal block. For example, a block and a sub-block can be a luma signal block.

[0575] When a block is partitioned into N sub-blocks, the block before partitioning can be a coding block, and the partitioned sub-blocks can be at least one of a prediction block or a transform block. That is, a transform / inverse transform, quantization / dequantization, and entropy encoding / entropy decoding of transform coefficients can be performed with a size of the partitioned sub-blocks.

[0576] Further, when a block is partitioned into N sub-blocks, the block before partitioning can be at least one of a coding block or a prediction block, and the partitioned sub-blocks can be a transform block. That is, prediction is performed with a size of the block before partitioning, and a transform / inverse transform, quantization / dequantization, and entropy encoding / entropy decoding of transform coefficients can be performed with a size of the partitioned sub-blocks.

[0577] Whether a block is partitioned into a plurality of sub-blocks can be determined based on at least one of an area (a product of a width and a height), a size (a combination of a width or a height or a width and a height), or a shape / form (a rectangle, a square, etc.) of the block.

[0578] For example, when a current block is a 64x64 block, the current block can be partitioned into a plurality of sub-blocks.

[0579] As another example, when the current block is a 32x32 block, the current block can be partitioned into a plurality of sub-blocks.

[0580] As another example, when the current block is a 32x16 block, the current block can be partitioned into a plurality of sub-blocks.

[0581] As another example, when the current block is a 16x32 block, the current block can be partitioned into a plurality of sub-blocks.

[0582] As another example, when the current block is a 4x4 block, the current block can not be partitioned into a plurality of sub-blocks.

[0583] As another example, when the current block is a 2x4 block, the current block can not be partitioned into a plurality of sub-blocks.

[0584] As another example, when at least one of a width or a height of the current block is greater than a maximum size of a transform block, the current block can not be partitioned into a plurality of sub-blocks. That is, when both the width and the height of the current block are less than or equal to the maximum size of the transform block, the second sub-block partition mode can be applied to the current block.

[0585] As another example, when at least one of a width or a height of the current block is greater than a maximum size of a transform block, the current block can not be partitioned into a plurality of sub-blocks. That is, when both the width and the height of the current block are less than or equal to the maximum size of the transform block, the second sub-block partition mode can be applied to the current block.

[0586] Further, when at least one of a width or a height of the current block is less than or equal to a maximum size of a transform block, at least one of information indicating the second sub-block partition mode (sub-block partition mode information, partition direction information, sub-block position information, or sub-block size information) can be entropy encoded / entropy decoded. Here, the maximum size of the transform block can be determined based on transform block maximum size information signaled in a higher level unit. For example, the maximum size of the transform block can be determined to be any one of 64 or 32 based on the transform block maximum size information.

[0587] As another example, when an area of the current block is equal to or greater than 32, the current block can be partitioned into a plurality of sub-blocks.

[0588] As another example, when an area of the current block is less than 32, the current block can not be partitioned into a plurality of sub-blocks.

[0589] As another example, when an area of the current block is 256 and a shape of the current block is rectangular, the current block can be partitioned into a plurality of sub-blocks.

[0590] As another example, when an area of the current block is 16 and a shape of the current block is square, the current block can not be partitioned into a plurality of sub-blocks.

[0591] When at least one of a width or a height of the current block is greater than or equal to a pre-defined value, the current block can be partitioned into a plurality of sub-blocks.

[0592] For example, when at least one of a width or a height of the current block is equal to or greater than 8, the current block can be partitioned into a plurality of sub-blocks.

[0593] Conversely, when both the width and the height of the current block are less than a pre-defined value, the current block can not be partitioned into a plurality of sub-blocks.

[0594] When the current block is in a GPM (Geometric Partition Mode), a transform block of the current block can not be partitioned into a plurality of sub-blocks. Here, the GPM can be a prediction mode that partitions a prediction block of the current block into two sub-blocks to perform prediction. When the current block is in the GPM, the prediction block of the current block can be partitioned into two sub-blocks. At this time, information related to a partition direction for partitioning the prediction block of the current block into two sub-blocks can be entropy encoded / entropy decoded. Inter prediction can be performed with respect to the two sub-blocks, thereby generating prediction samples for the two sub-blocks. Further, the prediction samples for the generated two sub-blocks can be weighted-summed to derive prediction samples of the current block. That is, when the prediction block of the current block is partitioned into at least two sub-blocks, a transform block of the current block can not be partitioned into at least two sub-blocks. Similarly, when the prediction block of the current block is not partitioned into at least two sub-blocks, the transform block of the current block can be partitioned into at least two sub-blocks.

[0595] When a block is partitioned, the block can be partitioned into a plurality of sub-blocks in at least one of a vertical direction or a horizontal direction.

[0596] For example, the current block can be partitioned into two sub-blocks in a vertical direction.

[0597] As another example, the current block can be partitioned into two sub-blocks in a horizontal direction.

[0598] When a block is partitioned into N sub-blocks, N can be a positive integer, and can be, for example, 2. Further, N can be determined using at least one of an area, a size, a shape, or a partition direction of the block.

[0599] For example, when the current block is a 4x8 or 8x4 block, the current block can be partitioned into two sub-blocks in a horizontal direction or in a vertical direction.

[0600] As another example, when the current block is a 16x8 or 16x16 block, the current block can be partitioned into two sub-blocks in a vertical direction or in a horizontal direction.

[0601] As another example, when the current block is an 8x32 or 32x32 block, the current block can be partitioned into two sub-blocks in a horizontal direction or in a vertical direction.

[0602] As another example, when the current block is a Jx8 block, the current block can be partitioned into two sub-blocks in a horizontal direction. Here, J can be a positive integer.

[0603] As another example, when the current block is an 8xK block, the current block can be partitioned into two sub-blocks in a vertical direction. Here, K can be a positive integer.

[0604] As another example, when the current block is a JxK (K>8) block, the current block can be partitioned into two sub-blocks in a horizontal direction. Here, J can be a positive integer. At this time, the height of the partitioned sub-blocks can have a ratio of 1:3 or 3:1.

[0605] As another example, when the current block is a J(J>8)xK block, the current block can be partitioned into two sub-blocks in a vertical direction. Here, J can be a positive integer. At this time, the width of the partitioned sub-blocks can have a ratio of 1:3 or 3:1.

[0606] As another example, when the area of the current block is 64, the current block can be partitioned into two sub-blocks in a horizontal direction or in a vertical direction.

[0607] As another example, when the current block is a 16x4 block and the shape of the current block is rectangular, the current block can be partitioned into two sub-blocks in a vertical direction.

[0608] As another example, when the area of the current block is 1024 and the shape of the current block is square, the current block can be partitioned into two sub-blocks in a horizontal direction or in a vertical direction.

[0609] Further, the sub-blocks can have at least one of a minimum area, a minimum width, or a minimum height.

[0610] For example, the sub-blocks can have S as the minimum area. Here, S can be a positive integer, and can be, for example, 16.

[0611] As another example, the sub-blocks can have J as the minimum width. Here, J can be a positive integer, and can be, for example, 4.

[0612] As another example, the sub-blocks can have K as the minimum height. Here, K can be a positive integer, and can be, for example, 4.

[0613] To indicate a sub-block partition mode in which a block is partitioned into N sub-blocks to perform at least one of a transform / inverse transform, quantization / dequantization, or entropy encoding / entropy decoding, at least one of sub-block partition mode information, partition direction information, sub-block position information, or sub-block size information can be entropy encoded / entropy decoded.

[0614] Here, the sub-block partition mode information can be used to indicate the sub-block partition mode. When the sub-block partition mode information indicates that the sub-block partition mode is used (a second value), the block can be partitioned into sub-blocks, and at least one of a transform / inverse transform, quantization / dequantization, or entropy encoding / entropy decoding can be performed. When the sub-block partition mode information indicates that the sub-block partition mode is not used (a first value), the block can not be partitioned into sub-blocks, and at least one of a transform / inverse transform, quantization / dequantization, or entropy encoding / entropy decoding can be performed. Here, the first value can be 0, and the second value can be 1.

[0615] Further, the partition direction information can be used to indicate whether the sub-block partition mode is partitioned in a vertical direction or a horizontal direction. When the partition direction information has a first value, the sub-blocks can be partitioned in the vertical direction, and the first value can be 0. Further, when the partition direction information has a second value, the sub-blocks can be partitioned in the horizontal direction, and the second value can be 1.

[0616] Further, the sub-block position information can be used to indicate which of the partitioned sub-blocks a residual signal of the partitioned sub-block is encoded / decoded. When the sub-block position information has a first value, a residual signal of a first sub-block can be encoded / decoded, and the first value can be 0. Further, when the sub-block position information has a second value, a residual signal of a second sub-block can be encoded / decoded, and the second value can be 1. Further, when the sub-block position information has the first value, at least one of a coded block flag for a luma signal or a coded block flag for a chroma signal for the first sub-block can be entropy encoded / entropy decoded. Further, when the sub-block position information has the second value, at least one of a coded block flag for a luma signal or a coded block flag for a chroma signal for the second sub-block can be entropy encoded / entropy decoded.

[0617] Further, the sub-block size information can be used to indicate whether a width or a height of the partitioned sub-block is 1 / 2 or 1 / 4 of a width or a height of the block. When the sub-block size information has a first value, this can indicate that a width or a height of the sub-block for which a residual signal is encoded / decoded by the sub-block position information is 1 / 2 of a width or a height of the block, and the first value can be 0. Further, when the sub-block size information has a second value, this can indicate that a width or a height of the sub-block for which a residual signal is encoded / decoded by the sub-block position information is 1 / 4 of a width or a height of the block, and the second value can be 1. For example, when there is only a case in which a size of the partitioned sub-block is 1 / 2 of a width or a height of the block, the sub-block size information can not be entropy encoded / entropy decoded.

[0618] In each partitioned sub-block, a reconstructed block can be generated by adding the residual block (or the reconstructed residual block) to the prediction block.

[0619] An encoding / decoding order of the sub-blocks partitioned from the block can be determined according to at least one of the partition directions.

[0620] For example, the encoding / decoding order of the sub-blocks partitioned in the horizontal direction can be determined as an order from the top direction to the bottom direction.

[0621] As another example, the encoding / decoding order of the sub-blocks partitioned in the vertical direction can be determined as an order from the left direction to the right direction.

[0622] In the partitioned sub-blocks, an encoded block flag indicating whether there is at least one transform coefficient having a non-zero value can be entropy-encoded / entropy-decoded in a sub-block unit.

[0623] For example, the encoded block flag can indicate, in a sub-block unit, that there is at least one transform coefficient having a non-zero value in at least one sub-block.

[0624] As another example, when the encoded block flag is entropy-encoded / entropy-decoded in a sub-block unit, the encoded block flag can not be entropy-encoded / entropy-decoded in a block unit before partitioning.

[0625] As another example, when the encoded block flag is entropy-encoded / entropy-decoded in a block unit before partitioning, the encoded block flag can not be entropy-encoded / entropy-decoded in a sub-block unit.

[0626] The residual signal can be entropy-encoded / entropy-decoded only for the sub-blocks indicated by the sub-block position information.

[0627] At this time, since the residual signal can always exist in the sub-blocks indicated by the sub-block position information, it can be inferred that the encoded block flag indicates that there is at least one non-zero transform coefficient.

[0628] In addition, since the residual signal can not always exist in the sub-blocks not indicated by the sub-block position information, it can be inferred that the encoded block flag indicates that there is no at least one non-zero transform coefficient.

[0629] At least one of an area, a size, a shape, or a partition direction of a coefficient group used when the transform coefficient is entropy-encoded / entropy-decoded can be determined based on at least one of an area, a size, a shape, or a partition direction of the sub-block.

[0630] For example, when the area of the sub-block is 16, the area of the coefficient group can be determined as 16.

[0631] As another example, when the size of the sub-block is 32x32, the size of the coefficient group can be determined as 16x16.

[0632] As another example, when the size of the sub-block is 1x16 or 16x1, the size of the coefficient group can be determined as 1x16 or 16x1.

[0633] As another example, when the size of the sub-block is 2x8 or 8x2, the size of the coefficient group can be determined as 2x8 or 8x2.

[0634] As another example, when the size of the sub-block is 4x4, the size of the coefficient group can be determined as 4x4.

[0635] As another example, when the width of the sub-block is 2, the width of the coefficient group can be determined as 2.

[0636] As another example, when the width of the sub-block is 4, the width of the coefficient group can be determined as 4.

[0637] As another example, when the height of the sub-block is 2, the height of the coefficient group can be determined as 2.

[0638] As another example, when the height of the sub-block is 4, the height of the coefficient group can be determined as 4.

[0639] As another example, when the shape of the sub-block is rectangular (non-square), the shape of the coefficient group can be determined as rectangular (non-square).

[0640] As another example, when the shape of the sub-block is square, the shape of the coefficient group can be determined as square.

[0641] As another example, when the size of the sub-block is 16x4 and its form is rectangular, the size of the coefficient group can be determined as at least one of 4x4 or 8x2.

[0642] As another example, when the size of the sub-block is 4x8 and its form is rectangular, the size of the coefficient group can be determined as at least one of 4x4 or 2x8.

[0643] As another example, when the size of the sub-block is 32x4 and its form is rectangular, the size of the coefficient group can be determined as at least one of 4x4 or 8x2.

[0644] As another example, when the size of the sub-block is 8x64 and its form is rectangular, the size of the coefficient group can be determined as at least one of 4x4 or 2x8.

[0645] As another example, when the size of the sub-block is 16x4 and the partition direction is a vertical direction, the size of the coefficient group can be determined as 4x4.

[0646] As another example, when the size of the sub-block is 4x8 and the partition direction is a horizontal direction, the size of the coefficient group can be determined as 4x4.

[0647] As another example, when the size of the sub-block is 32x4 and the partition direction is a horizontal direction, the size of the coefficient group can be determined as 8x2.

[0648] As another example, when the size of the sub-block is 8x64 and the partition direction is a vertical direction, the size of the coefficient group can be determined as 2x8.

[0649] Further, the area of the coefficient group used when the transform coefficient is entropy encoded / entropy decoded can be determined as a pre-defined value. Here, the pre-defined value can be 4 or 16.

[0650] Further, the area or size of the transform coefficient group can be determined based on the size of the current block regardless of the color component of the current block. At this time, the size of the current block can include at least one of the width or height of the current block.

[0651] For example, when the width and height of the current block are 2, the size of the coefficient group can be determined as 2x2.

[0652] As another example, when the size of the current block is 2x4 or 4x2, the size of the coefficient group can be determined as 2x2.

[0653] As in the example of FIG. 10, FIG. 13 According to an embodiment of the second sub-block partition mode, the current block can be partitioned into two sub-blocks in a horizontal direction (1 / 2 or 1 / 4 of the height) and can be partitioned into two sub-blocks in a vertical direction (1 / 2 or 1 / 4 of the width). In FIG. 13 In the example of FIG. 10,

[0654] The sub-block partition mode usage information can be entropy encoded / entropy decoded in at least one of a parameter set or a header, wherein the sub-block partition mode usage information indicates whether a mode of partitioning a block into N sub-blocks and performing at least one of prediction, transform / inverse transform, quantization / de-quantization, or entropy encoding / entropy decoding is used.

[0655] Here, the sub-block partition mode usage information can indicate at least one of a first sub-block partition mode or a second sub-block partition mode.

[0656] At this time, the at least one of the parameter set or the header can be at least one of a video parameter set, a decoding parameter set, a sequence parameter set, an adaptation parameter set, a picture parameter set, a picture header, a slice header, a parallel block group header, or a parallel block header.

[0657] For example, to indicate whether sub-block partition mode is used within a video, sub-block partition mode usage information can be entropy coded / entropy decoded in a video parameter set.

[0658] As another example, to indicate whether sub-block partition mode is used within a decoding process, sub-block partition mode usage information can be entropy coded / entropy decoded in a sequence parameter set.

[0659] As another example, to indicate whether sub-block partition mode is used within a sequence, sub-block partition mode usage information can be entropy coded / entropy decoded in a sequence parameter set.

[0660] As another example, to indicate whether sub-block partition mode is used within a number of pictures, sub-block partition mode usage information can be entropy coded / entropy decoded in an adaptation parameter set or an adaptation header.

[0661] As another example, to indicate whether sub-block partition mode is used within a picture, sub-block partition mode usage information can be entropy coded / entropy decoded in a picture parameter set or a picture header.

[0662] As another example, to indicate whether sub-block partition mode is used within a slice, sub-block partition mode usage information can be entropy coded / entropy decoded in a slice header.

[0663] As another example, to indicate whether sub-block partition mode is used within a parallel block group, sub-block partition mode usage information can be entropy coded / entropy decoded in a parallel block group header.

[0664] As another example, to indicate whether sub-block partition mode is used within a parallel block, sub-block partition mode usage information can be entropy coded / entropy decoded in a parallel block header.

[0665] At least one of the following embodiments can be used to determine a transform / inverse transform type for each block or sub-block.

[0666] At least one of a one-dimensional transform type, a two-dimensional transform combination, or whether to use a transform for a block or sub-block can be determined based on at least one of a prediction mode, an intra prediction mode, a color component, a size, a shape (form), sub-block partition related information, secondary transform execution information, or matrix-based intra prediction execution information for the block or sub-block. Matrix-based intra prediction can indicate that intra prediction is performed based on a matrix.

[0667] For example, a one-dimensional transform type indicating at least one of a horizontal transform type or a vertical transform type can be determined based on at least one of a prediction mode, an intra prediction mode, a color component, a size, a shape (form), sub-block partition related information, secondary transform execution information, or matrix-based intra prediction execution information for a block or sub-block.

[0668] As another example, the information indicating whether to perform the transform can be determined based on at least one of an intra prediction mode, a prediction mode, a color component, a size, a shape, or subblock partition related information for the block or the subblock.

[0669] As another example, the information indicating whether to perform the transform can be determined based on at least one of an intra prediction mode, a prediction mode, a color component, a size, a shape, or subblock partition related information for the block or the subblock.

[0670] At this time, at least one of the one-dimensional transform type, the two-dimensional transform combination, or whether to use the transform can be different from each other according to at least one of an intra prediction mode, a prediction mode, a color component, a size, a shape, or subblock partition related information for the block or the subblock.

[0671] Further, when at least one of the one-dimensional transform type, the two-dimensional transform combination, or whether to use the transform for the block or the subblock is determined based on at least one of an intra prediction mode, a prediction mode, a color component, a size, a shape (form), subblock partition related information, secondary transform execution information, or matrix-based intra prediction execution information for the block or the subblock, information about the one-dimensional transform type, information about the two-dimensional transform combination, or information about whether to use the transform can not be entropy encoded / entropy decoded.

[0672] That is, at least one of the one-dimensional transform type, the two-dimensional transform combination, or whether to use the transform for the block or the subblock can be implicitly determined according to a predetermined rule in the encoder / decoder. The predetermined rule can be set based on an encoding parameter in the encoder / decoder.

[0673] Here, the matrix-based intra prediction can mean an intra prediction mode that performs at least one of a boundary averaging process, a matrix vector multiplication process, or a linear interpolation process to generate a prediction block.

[0674] Here, the transform can mean at least one of a transform or an inverse transform.

[0675] Further, the block can mean each subblock partitioned from the block.

[0676] The primary transform can mean at least one integer transform based on DCT-J or DST-K, such as DCT-2, DCT-8, DST-7, DCT-4, or DST-4 performed for a residual block to generate transform coefficients. Here, J and K can be positive integers.

[0677] The primary transform can be performed using a transform matrix extracted from a transform matrix of at least one of the integer transforms based on DCT-J or DST-K, such as DCT-2, DCT-8, DST-7, DCT-4, or DST-4. That is, the primary transform can be performed using the extracted transform matrix. Also, at least one of the coefficients in the extracted transform matrix can be equal to at least one of the coefficients in the transform matrix of at least one of the integer transforms based on DCT-J or DST-K, such as DCT-2, DCT-8, DST-7, DCT-4, or DST-4. Also, the extracted transform matrix can be included in the transform matrix to be extracted. Also, the extracted transform matrix can be obtained by performing at least one of a flip or a sign change for a specific coefficient in the transform matrix to be extracted.

[0678] For example, at least one of the integer transforms based on DCT-J or DST-K, such as DCT-8, DST-7, DCT-4, or DST-4, can be extracted from a transform matrix of DCT-2 and used for the primary transform.

[0679] Here, at least one of the integer transforms based on DCT-J or DST-K, such as DCT-2, DCT-8, DST-7, DCT-4, or DST-4, can have different coefficients in the transform matrix from at least one of the integer transforms based on DCT-J or DST-K, such as DCT-2, DCT-8, DST-7, DCT-4, or DST-4.

[0680] For example, an integer transform matrix based on DCT-8 can be derived by performing at least one of a horizontal flip for an integer transform matrix based on DST-7 or a sign change for at least one of the DST-7 transform matrix coefficients. At this time, a vertical flip can be used instead of the horizontal flip.

[0681] As another example, an integer transform matrix based on DST-7 can be derived by performing at least one of a horizontal flip for an integer transform matrix based on DCT-8 or a sign change for at least one of the DCT-8 transform matrix coefficients. At this time, a vertical flip can be used instead of the horizontal flip.

[0682] As another example, an integer transform matrix based on DCT-4 can be derived by performing at least one of a horizontal flip for an integer transform matrix based on DST-4 or a sign change for at least one of the DST-4 transform matrix coefficients. At this time, a vertical flip can be used instead of the horizontal flip.

[0683] As another example, the DST-4 based integer transform matrix can be derived by performing at least one of a horizontal flip with respect to the DCT-4 based integer transform matrix or a sign change with respect to at least one of the DCT-4 transform matrix coefficients. At this time, a vertical flip can be used instead of the horizontal flip.

[0684] The secondary transform can represent at least one of a transform for transforming at least one of the transform coefficients based on an angle. The secondary transform can be performed after the primary transform.

[0685] In the encoder, the secondary transform can be performed with respect to coefficients of a low frequency region of a top left side of the transform coefficients subjected to the primary transform. A size of the low frequency region to which the secondary transform is applied can be determined based on a size of the transform block.

[0686] In the decoder, the secondary inverse transform can be performed before the primary inverse transform is performed. In the following description, the secondary transform can include the secondary inverse transform.

[0687] The secondary transform can be referred to as a LFNST (Low Frequency Non-Separable Transform) because a non-separable transform kernel is used instead of a horizontal and vertical separable transform kernel (or type).

[0688] The secondary transform can be performed only with respect to intra prediction encoding / decoding, and a secondary transform kernel can be determined based on an intra prediction mode. Specifically, a transform set including a plurality of transform kernels can be determined based on the intra prediction mode. Further, a transform kernel to be applied to the secondary transform can be determined in the transform set determined based on index information. Here, the transform set can include four types of transform sets.

[0689] Further, when the intra prediction mode of the current block is the CCLM mode, a transform set for the chrominance block can be determined based on an intra prediction mode of a luma block corresponding to the chrominance block. Here, when the luma block corresponding to the chrominance block is in the matrix-based intra prediction mode, this can be regarded as a planar mode, and a transform set for the chrominance block can be determined. Further, when the luma block corresponding to the chrominance block is in the IBC mode, this can be regarded as a DC mode, and a transform set for the chrominance block can be determined.

[0690] As another example, when the luma block corresponding to the chrominance block is in the matrix-based intra prediction mode, the IBC mode, or the palette mode, this can be regarded as a planar mode and a transform set for the chrominance block can be determined.

[0691] As another example, when the luma block corresponding to the chrominance block is in the matrix-based intra prediction mode, the IBC mode, or the palette mode, this can be regarded as a DC mode and a transform set for the chrominance block can be determined.

[0692] In addition, the secondary transform index information can be used to determine a secondary transform core in the transform set. Here, the secondary transform core can indicate a secondary transform matrix.

[0693] Whether to use the transform can indicate whether at least one of the primary transform or the secondary transform is used in the residual block. Whether to use the transform can include at least one of whether to use the primary transform or whether to use the secondary transform. Whether to use the transform can indicate whether a transform skip mode is applied. In addition, transform_skip_flag can indicate a transform skip flag.

[0694] For example, when transform_skip_flag, which is information indicating whether at least one of the primary transform or the secondary transform is used, has a first value (e.g., 0), this can indicate that at least one of the primary transform or the secondary transform is used.

[0695] As another example, when transform_skip_flag, which is information indicating whether at least one of the primary transform or the secondary transform is used, has a second value (e.g., 1), this can indicate that at least one of the primary transform or the secondary transform is not used.

[0696] The one-dimensional transform type can represent a type of the primary transform, and represent a horizontal transform type trTypeHor or a vertical transform type trTypeVer for at least one of an integer transform type based on DCT-J or DST-K. Here, J and K can be positive integers.

[0697] As a type of the primary transform, a first transform to an Nth transform can be used. Here, N can be a positive integer 2 or a positive integer greater than 2.

[0698] For example, the first transform can represent an integer transform based on DCT-2.

[0699] As another example, when the first transform is used for the horizontal transform and the vertical transform, trTypeHor, which is a transform type for the horizontal transform, and trTypeVer, which is a transform type for the vertical transform, can have values Q and R, respectively. Here, Q and R can be at least one of a negative integer, 0, or a positive integer. For example, Q and R can be 0 and 0, respectively.

[0700] For example, when trTypeHor has a first value, this can represent an integer horizontal transform based on DCT-2.

[0701] As another example, when trTypeVer has a first value, this can represent an integer vertical transform based on DCT-2.

[0702] The first value can be 0.

[0703] For example, the second transform can represent at least one of integer transforms based on DCT-J or DST-K other than DCT-2, such as DCT-8, DST-7, DCT-4, or DST-4. Here, J and K can be positive integers. That is, the second transform can represent at least one of transforms other than the first transform.

[0704] As another example, when the second transform is used for at least one of a horizontal transform or a vertical transform, trTypeHor as a transform type for the horizontal transform and trTypeVer as a transform type for the vertical transform can have values T and U, respectively. Here, T and U can be at least one of a negative integer, 0, or a positive integer. For example, T and U can be a value equal to or greater than 1 and a value equal to or greater than 1, respectively. Also, T and U can be greater than Q and R, respectively.

[0705] For example, when trTypeHor has a second value, this can represent an integer horizontal transform based on DST-7.

[0706] As another example, when trTypeHor has a third value, this can represent an integer horizontal transform based on DCT-8.

[0707] As another example, when trTypeVer has a second value, this can represent an integer vertical transform based on DST-7.

[0708] As another example, when trTypeVer has a third value, this can represent an integer vertical transform based on DCT-8.

[0709] The second value can be 1. Also, the third value can be 2.

[0710] DST-4 can be used instead of DST-7. Also, DCT-4 can be used instead of DCT-8.

[0711] For example, the first transform can be an integer transform based on DCT-2. Also, the second transform can be an integer transform based on DST-7. Also, the third transform can be an integer transform based on DCT-8. Also, the second transform can represent at least one of the second transform or the third transform.

[0712] As another example, the first transform can be an integer transform based on DCT-2. Also, the second transform can be an integer transform based on DST-4. Also, the third transform can be an integer transform based on DCT-4. Also, the second transform can represent at least one of the second transform or the third transform.

[0713] That is, the first transform can be an integer transform based on DCT-2, and the second transform to the Nth transform can represent at least one of integer transforms based on DCT-J or DST-K (such as DCT-8, DST-7, DCT-4, or DST-4) other than DCT-2. Here, N can be a positive integer equal to or greater than 3.

[0714] For example, the first transform can be an integer transform based on DCT-2. Also, the second transform can be an integer transform based on DST-7 extracted from an integer transform matrix based on DCT-2. Also, the third transform can be an integer transform based on DCT-8 extracted from an integer transform matrix based on DCT-2. Also, the second transform can represent at least one of the second transform or the third transform.

[0715] As another example, the first transform can be an integer transform based on DCT-2. Also, the second transform can be an integer transform based on DST-4 extracted from an integer transform matrix based on DCT-2. Also, the third transform can be an integer transform based on DCT-4 extracted from an integer transform matrix based on DCT-2. Also, the second transform can represent at least one of the second transform or the third transform.

[0716] That is, the first transform can be an integer transform based on DCT-2, and the second transform to the Nth transform can represent at least one of integer transforms based on DCT-J or DST-K (such as DCT-8, DST-7, DCT-4, or DST-4) extracted from an integer transform matrix based on DCT-2. Here, N can be a positive integer equal to or greater than 3. Also, the second transform can represent at least one of the second transform to the Nth transform.

[0717] As an alternative to DCT-2, at least one of integer transforms based on DCT-J or DST-K (such as DCT-8, DST-7, DCT-4, or DST-4) can be used.

[0718] The two-dimensional transform combination can represent a combination of primary transforms, and can represent a combination of a horizontal transform type trTypeHor and a vertical transform type trTypeVer for at least one of integer transform types based on DCT-J or DST-K. Also, the two-dimensional transform combination can represent an mts_idx that is a multi-transform selection index.

[0719] For example, when the first transform is used for a horizontal transform and a vertical transform, the mts_idx that is a multi-transform selection index can have a value P. Here, P can be at least one of a negative integer, 0, or a positive integer. For example, P can be 0.

[0720] For example, when mts_idx is 0, trTypeHor and trTypeVer can have first values (e.g., 0), respectively. That is, when mts_idx is 0, this can indicate a DCT-2 based integer horizontal transform and a DCT-2 based integer vertical transform.

[0721] As another example, when the second transform is used for at least one of the horizontal transform or the vertical transform, mts_idx as the multiple transform selection index can have a value S or a larger value. Here, S can be at least one of a negative integer, 0, or a positive integer. For example, S can be 1. Also, S can be larger than P.

[0722] For example, when mts_idx is 1, trTypeHor and trTypeVer can have second values (e.g., 1), respectively.

[0723] As another example, when mts_idx is 2, trTypeHor and trTypeVer can have third values (e.g., 2) and second values (e.g., 1), respectively.

[0724] As another example, when mts_idx is 3, trTypeHor and trTypeVer can have second values (e.g., 1) and third values (e.g., 2), respectively.

[0725] As another example, when mts_idx is 4, trTypeHor and trTypeVer can have third values (e.g., 2), respectively.

[0726] For example, when trTypeHor has the second value, this can indicate a DST-7 based integer horizontal transform.

[0727] For another example, when trTypeHor has the third value, this can indicate a DCT-8 based integer horizontal transform.

[0728] For another example, when trTypeVer has the second value, this can indicate a DST-7 based integer vertical transform.

[0729] For another example, when trTypeVer has the third value, this can indicate a DCT-8 based integer vertical transform.

[0730] The second value can be 1. Also, the third value can be 2.

[0731] In the above embodiments, DST-4 can be used instead of DST-7. Also, DCT-4 can be used instead of DCT-8.

[0732] For example, in the first transform, the horizontal transform and the vertical transform can be DCT-2 based integer transforms, respectively. Also, in the second transform, the horizontal transform and the vertical transform can be DST-7 based integer transform and DST-7 based integer transform, respectively. Also, in the third transform, the horizontal transform and the vertical transform can be DCT-8 based integer transform and DST-7 based integer transform, respectively. Also, in the fourth transform, the horizontal transform and the vertical transform can be DST-7 based integer transform and DCT-8 based integer transform, respectively. Also, in the fifth transform, the horizontal transform and the vertical transform can be DCT-8 based integer transform and DCT-8 based integer transform, respectively. Also, the second transform can represent at least one of the second transform, the third transform, the fourth transform, or the fifth transform.

[0733] As another example, in the first transform, the horizontal transform and the vertical transform can be DCT-2 based integer transforms, respectively. Also, in the second transform, the horizontal transform and the vertical transform can be DST-4 based integer transform and DST-4 based integer transform, respectively. Also, in the third transform, the horizontal transform and the vertical transform can be DCT-4 based integer transform and DST-4 based integer transform, respectively. Also, in the fourth transform, the horizontal transform and the vertical transform can be DST-4 based integer transform and DCT-4 based integer transform, respectively. Also, in the fifth transform, the horizontal transform and the vertical transform can be DCT-4 based integer transform and DCT-4 based integer transform, respectively. Also, the second transform can represent at least one of the second transform, the third transform, the fourth transform, or the fifth transform.

[0734] That is, in the first transform, the horizontal transform and the vertical transform can be DCT-2 based integer transforms, respectively, and in the second transform to the Nth transform, the horizontal transform and the vertical transform can represent at least one of integer transforms based on DCT-J or DST-K other than DCT-2, such as DCT-8, DST-7, DCT-4, or DST-4. Here, N can be an integer equal to or greater than 3.

[0735] For example, in the first transform, the horizontal transform and the vertical transform can be DCT-2-based integer transforms, respectively. Also, in the second transform, the horizontal transform and the vertical transform can be DST-7-based integer transforms extracted from a DCT-2-based integer transform matrix and a DST-7-based integer transform, respectively. Also, in the third transform, the horizontal transform and the vertical transform can be a DCT-8-based integer transform extracted from a DCT-2-based integer transform matrix and a DST-7-based integer transform extracted from a DCT-2-based integer transform matrix, respectively. Also, in the fourth transform, the horizontal transform and the vertical transform can be a DST-7-based integer transform extracted from a DCT-2-based integer transform matrix and a DCT-8-based integer transform extracted from a DCT-2-based integer transform matrix, respectively. Also, in the fifth transform, the horizontal transform and the vertical transform can be a DCT-8-based integer transform extracted from a DCT-2-based integer transform matrix and a DCT-8-based integer transform, respectively. Also, the second transform can denote at least one of the second transform, the third transform, the fourth transform, or the fifth transform.

[0736] As another example, in the first transform, the horizontal transform and the vertical transform can be DCT-2-based integer transforms, respectively. Also, in the second transform, the horizontal transform and the vertical transform can be DST-4-based integer transforms extracted from a DCT-2-based integer transform matrix and a DST-4-based integer transform, respectively. Also, in the third transform, the horizontal transform and the vertical transform can be a DCT-4-based integer transform extracted from a DCT-2-based integer transform matrix and a DST-4-based integer transform extracted from a DCT-2-based integer transform matrix, respectively. Also, in the fourth transform, the horizontal transform and the vertical transform can be a DST-4-based integer transform extracted from a DCT-2-based integer transform matrix and a DCT-4-based integer transform extracted from a DCT-2-based integer transform matrix, respectively. Also, in the fifth transform, the horizontal transform and the vertical transform can be a DCT-4-based integer transform extracted from a DCT-2-based integer transform matrix and a DCT-4-based integer transform, respectively. Also, the second transform can denote at least one of the second transform, the third transform, the fourth transform, or the fifth transform.

[0737] That is, in the first transform, the horizontal transform and the vertical transform can be DCT-2-based integer transforms, respectively, and in the second transform to the Nth transform, the horizontal transform and the vertical transform can denote at least one of DCT-J or DST-K-based integer transforms extracted from a DCT-2-based integer transform matrix, such as DCT-8, DST-7, DCT-4, or DST-4. Here, N can be a positive integer equal to or greater than 3. In this case, the second transform can denote at least one of the second transform to the Nth transform.

[0738] As an alternative to the DCT-2 transform, at least one of integer transforms based on DCT-J or DST-K, such as DCT-8, DST-7, DCT-4, or DST-4, can be used.

[0739] The prediction mode can denote a prediction mode of the block, and can denote which of an intra prediction mode, an inter prediction mode, and an IBC (intra block copy) mode is used to perform encoding / decoding.

[0740] For example, when both intra prediction and inter prediction are performed in a certain mode to generate a prediction block, the certain mode can denote the inter prediction mode.

[0741] For example, when a current picture is used as a reference picture in a certain mode and a vector is used for prediction, the certain mode can denote an intra block copy prediction mode. The intra block copy prediction mode can be an IBC mode. Here, the IBC mode can denote a mode in which a reference region is set within a current picture / tile / parallel block / parallel block group / CTU, a position in the reference region is indicated by a block vector, and prediction is performed using the region indicated by the block vector.

[0742] The color component can denote a color component of the block and can denote a luma (Y) component or a chroma component.

[0743] For example, the chroma component can denote at least one of a Cb component or a Cr component. That is, the color component can denote a Y component, a Cb component, or a Cr component.

[0744] As another example, the color component can denote at least one of an R component, a G component, or a B component.

[0745] As another example, when an image is decomposed into a plurality of components and is encoded / decoded, the color component can denote a decomposed component.

[0746] The sub-block partition-related information can denote information indicating that the block is partitioned into a plurality of sub-blocks.

[0747] For example, the sub-block partition-related information can include at least one of sub-block partition mode information or partition direction information.

[0748] As another example, the sub-block partition-related information can include at least one of sub-block partition mode information, partition direction information, sub-block position information, or sub-block size information.

[0749] The size can denote at least one of a block size, a sub-block size, or a transform size. Here, the size can denote at least one of a width, a height, or a combination of the width and the height.

[0750] The transform size can indicate a transform size used in the corresponding block. The transform size can be smaller than or equal to the block size.

[0751] The size can be MxN, such as 2x2, 4x2, 2x4, 4x4, 8x4, 8x2, 2x8, 8x8, 16x8, 16x4, 16x2, 2x16, 4x16, 8x16, 16x16, 32x16, 32x8, 32x4, 32x2, 2x32, 4x32, 8x32, 16x32, 32x32, 64x32, 64x16, 64x8, 64x4, 64x2, 2x64, 4x64, 8x64, 16x64, 32x64, 64x64, 128x64, 128x32, 32x128, 64x128, or 128x128. Here, M and N can be positive integers, and can be the same or different. Also, M can be S*N. N can be S*M. Here, S can be a positive integer.

[0752] Here, M can indicate a width, and N can indicate a height.

[0753] For example, in the case of a block having a size of 64x64, a transform having a size of 32x32 can be performed in a top-left region of the block. At this time, a quantization matrix having a size of 32x32 can be used.

[0754] As another example, in the case of a block having a size of 64x32, a transform having a size of 32x32 can be performed in a top-left region of the block. At this time, a quantization matrix having a size of 32x32 can be used.

[0755] As another example, in the case of a block having a size of 32x64, a transform having a size of 16x32 can be performed in a top-left region of the block. At this time, a quantization matrix having a size of 16x32 can be used.

[0756] As another example, in the case of a block having a size of 32x32, a transform having a size of 32x32 can be performed in the block. At this time, a quantization matrix having a size of 32x32 can be used.

[0757] The form (or shape) can indicate at least one of a form of the block, a form of the sub-block, or a form of the transform.

[0758] The form can be a square form or a non-square form.

[0759] The square form can indicate a form of a square.

[0760] The non-square form can indicate a rectangular form.

[0761] The form of the transform can indicate a form of a transform used in the corresponding block. When the horizontal transform size and the vertical transform size are different from each other, the form of the transform can be non-square. Also, when the horizontal transform size and the vertical transform size are the same, the form of the transform can be square. The form of the transform can be equal to or different from the form of the corresponding block.

[0762] The form of the quantization matrix can indicate a form of a quantization matrix used in the corresponding block. When the horizontal transform size and the vertical transform size are different from each other, the form of the quantization matrix can be non-square. Also, when the horizontal transform size and the vertical transform size are the same, the form of the quantization matrix can be square. The form of the quantization matrix can be equal to or different from the form of the corresponding block. The form of the quantization matrix can be equal to or different from the form of the transform.

[0763] For example, in the case of a square block having a size of 64x64, a square transform having a size of 32x32 can be performed in a left upper region of the block. At this time, a square quantization matrix having a size of 32x32 can be used.

[0764] As another example, in the case of a square block having a size of 16x16, a square transform having a size of 16x16 can be performed in the block. At this time, a square quantization matrix having a size of 16x16 can be used.

[0765] As another example, in the case of a non-square block having a size of 16x4, a non-square transform having a size of 16x4 can be performed in the block. At this time, a quantization matrix having a size of 16x4 can be used.

[0766] As another example, in the case of a non-square block having a size of 2x8, a transform having a size of 2x8 can be performed in the block. At this time, a quantization matrix having a size of 2x8 can be used.

[0767] The following shows an embodiment of determining at least one of a one-dimensional transform type, a two-dimensional transform combination, or whether to use a transform for a block or a sub-block. Here, a one-dimensional transform type for at least one of a horizontal transform or a vertical transform for a block or a sub-block can be determined.

[0768] When a width W or a height H of the block or the sub-block is less than X, a horizontal transform type trTypeHor or a vertical transform type trTypeVer can be determined as a first transform indicating an integer transform based on DCT-2.

[0769] At this time, the first transform can mean that trTypeHor or trTypeVer has a first value. Here, the first value can be 0.

[0770] Here, X can be a positive integer, and can be, for example, 2 or 4.

[0771] When the width or height of the block or sub-block is greater than Y, the horizontal transform type trTypeHor or the vertical transform type trTypeVer can be determined as a first transform indicating a DCT-2-based integer transform.

[0772] Here, Y can be a positive integer, and can be, for example, 16, 32, or 64.

[0773] When the width or height of the block or sub-block is greater than or equal to X or less than or equal to Y, the horizontal transform type trTypeHor or the vertical transform type trTypeVer can be determined as a second transform indicating a DST-7-based integer transform.

[0774] At this time, the second transform can mean that trTypeHor or trTypeVer has a second value.

[0775] Here, the second value can be 1. Here, X can be a positive integer, and can be, for example, 2 or 4. Here, Y can be a positive integer, and can be, for example, 16, 32, or 64.

[0776] In addition, when the width or height of the block or sub-block is Z, the horizontal transform or the vertical transform can not be performed.

[0777] Here, Z can be a positive integer including 0, and can be, for example, 1.

[0778] Here, the same horizontal transform type or the same vertical transform type can be used to transform all sub-blocks partitioned from the block.

[0779] In addition, a one-dimensional transform type of at least one of the horizontal transform or the vertical transform for the block or sub-block can be determined regardless of the intra prediction mode. That is, a transform type of at least one of the horizontal transform or the vertical transform for the block or sub-block can be determined regardless of the intra prediction mode. The transform type can be selected from at least two transform types.

[0780] When the current block is in a sub-block partition mode, a transform type of at least one of the horizontal transform or the vertical transform can be determined based on the width or height of the current block regardless of the intra prediction mode. Here, the sub-block partition mode can be a first sub-block partition mode (ISP mode) or a second sub-block partition mode (SBT mode).

[0781] As in the example of Table 4, at least one of the horizontal transform type trTypeHor or the vertical transform type trTypeVer for the block or sub-block can be determined.

[0782]

Table 4

[0783] trTypeHor trTypeVer (W >= 4 && W <= 16)? 1 : 0 (H >= 4 && H <= 16)? 1 : 0

[0784] For example, when the current block is in the sub-block partition mode, the transform type for at least one of the horizontal transform or the vertical transform can be determined based on Table 4 regardless of the intra prediction mode.

[0785] In addition, in order to reduce the implementation complexity of the encoder / decoder, the one-dimensional transform type for the horizontal transform and the vertical transform can be determined on the same criteria according to the width of the block and the height of the block.

[0786] The conditions for determining the horizontal transform and the vertical transform can be the same regardless of the width of the block or the height of the block. That is, the condition for determining the horizontal transform and the condition for determining the vertical transform can be the same.

[0787] The above conditions can represent a comparison between the width or height of the current block and a certain positive integer.

[0788] Here, since the logic for the conditions for determining the horizontal transform and the vertical transform can be shared, the implementation complexity of the encoder / decoder can be reduced.

[0789] In addition, as shown in the example of Table 4, the transform type for at least one of the horizontal transform or the vertical transform used in the sub-block can be determined without performing a comparison between the width and the height of the current block in order to reduce the calculation complexity.

[0790] In Table 4, since the transform type for at least one of the horizontal transform or the vertical transform used in the sub-block can be determined without performing a comparison between the width and the height of the current block, the calculation complexity can be reduced compared to Tables 5 and 6 below.

[0791] The mts_idx, which is a multi-transform selection index, can be entropy-encoded / entropy-decoded to determine a two-dimensional transform combination of the block or the sub-block. The horizontal transform type trTypehor and the vertical transform type trTypever can be determined using a two-dimensional transform combination table predetermined in the encoder and the decoder. At this time, the two-dimensional transform combination can represent each entry in the two-dimensional transform combination table.

[0792] When the block is not partitioned into sub-blocks, the mts_idx, which is a multi-transform selection index, can be entropy-encoded / entropy-decoded.

[0793] The multi-transform selection index mts_idx can be determined based on the lfnst_idx, that is, the secondary transform execution information. In other words, the multi-transform selection index mts_idx can be entropy-encoded / entropy-decoded based on the lfnst_idx, that is, the secondary transform execution information.

[0794] When the multi-transform selection index mts_idx does not exist in the bitstream, the multi-transform selection index mts_idx can be inferred to be a first value (e.g., 0). In other words, when the multi-transform selection index mts_idx is not entropy encoded / decoded, the multi-transform selection index mts_idx can be inferred to be a first value (e.g., 0).

[0795] According to an embodiment, whether the multi-transform selection index mts_idx is signaled may be determined based on at least one of intra-prediction explicit multi-transform selection enable information (sps_explicit_mts_intra_enabled_flag) and inter-prediction explicit multi-transform selection enable information (sps_explicit_mts_inter_enabled_flag). For example, when the current block is intra-predicted and the intra-prediction explicit multi-transform selection enable information indicates that multi-transform is enabled for the intra-predicted block, the multi-transform selection index for the current block may be signaled. Conversely, when the intra-prediction explicit multi-transform selection enable information indicates that multi-transform is not enabled for the intra-predicted block, the multi-transform selection index for the current block may not be signaled.

[0796] Furthermore, when the current block is inter-predicted and the inter-prediction explicit multi-transform selection enabling information indicates that multi-transform is enabled for the inter-prediction block, a multi-transform selection index for the current block may be signaled. Conversely, when the inter-prediction explicit multi-transform selection enabling information indicates that multi-transform is not enabled for the inter-prediction block, the multi-transform selection index for the current block may not be signaled.

[0797] Furthermore, when the current block is predicted according to the IBC mode, whether a multi-transform selection index is signaled may be determined based on the intra-prediction explicit multi-transform selection enable information and / or the inter-prediction explicit multi-transform selection enable information. Furthermore, when the current block is predicted according to the IBC mode, regardless of the intra-prediction explicit multi-transform selection enable information and the inter-prediction explicit multi-transform selection enable information, the multi-transform selection index for the current block may not be signaled. Here, when the current block is predicted according to the IBC mode, a sub-transform / inverse transform may not be performed on the current block. Furthermore, when the current block is not in the IBC mode and / or inter-prediction mode but in the intra-prediction mode, a sub-transform / inverse transform may be performed on the current block.

[0798] As shown in Table 5, at least one of the horizontal transform type trTypeHor or the vertical transform type trTypeVer for a block or subblock may be determined. According to Table 5, a 2D transform combination table may be predetermined, and a 2D transform combination indicated by a multi-transform selection index may be determined.

[0799]

Table 5

[0800] mts_idx[x0][y0] 0 1 2 3 4 trTypeHor 0 1 2 1 2 trTypeVer 0 1 1 2 2

[0801] The following shows an embodiment of determining at least one of a one-dimensional transform type, a two-dimensional transform combination, or whether to use a transform for a block or a sub-block. Here, a one-dimensional transform type of at least one of a horizontal transform or a vertical transform for a block or a sub-block can be determined.

[0802] When a width W or a height H of a block or a sub-block is less than X, a horizontal transform type trTypeHor or a vertical transform type trTypeVer can be determined as a first transform indicating an integer transform based on DCT-2.

[0803] At this time, the first transform can mean that trTypeHor or trTypeVer has a first value. Here, the first value can be 0.

[0804] Here, X can be a positive integer, and can be, for example, 2 or 4.

[0805] When a width or a height of a block or a sub-block is greater than Y, a horizontal transform type or a vertical transform type can be determined as a first transform indicating an integer transform based on DCT-2.

[0806] Here, Y can be a positive integer, and can be, for example, 16, 32, or 64.

[0807] When a width or a height of a block or a sub-block is greater than or equal to X or less than or equal to Y, a horizontal transform type or a vertical transform type can be determined according to the following conditions.

[0808] When partition direction information has a first value (0) and sub-block position information has a first value (0), a horizontal transform type can be determined as a third transform indicating an integer transform based on DCT-8, and a vertical transform type can be determined as a second transform indicating an integer transform based on DST-7.

[0809] When partition direction information has a first value (0) and sub-block position information has a second value (1), a horizontal transform type can be determined as a second transform indicating an integer transform based on DST-7, and a vertical transform type can be determined as a second transform indicating an integer transform based on DST-7.

[0810] When partition direction information has a second value (1) and sub-block position information has a first value (0), a horizontal transform type can be determined as a second transform indicating an integer transform based on DST-7, and a vertical transform type can be determined as a third transform indicating an integer transform based on DCT-8.

[0811] When the partition direction information has the second value (1) and the sub-block position information has the second value (1), the horizontal transform type can be determined as a second transform indicating an integer transform based on DST-7, and the vertical transform type can be determined as a second transform indicating an integer transform based on DST-7.

[0812] At this time, the second transform can mean that trTypeHor or trTypeVer has a second value. Here, the second value can be 1.

[0813] At this time, the third transform can mean that trTypeHor or trTypeVer has a third value. Here, the third value can be 2.

[0814] Here, X can be a positive integer, and can be, for example, 2 or 4. Here, Y can be a positive integer, and can be, for example, 16, 32, or 64.

[0815] In addition, when the width or height of the block or sub-block is Z, the horizontal transform or the vertical transform can not be performed.

[0816] Here, Z can be a positive integer including 0, and can be, for example, 1.

[0817] As in the example of Table 6, at least one of the horizontal transform type trTypeHor or the vertical transform type trTypeVer for the block or sub-block can be determined.

[0818]

Table 6

[0819] partition direction information subblock position information trTypeHor trTypeVer 0 0 2 1 0 1 1 1 1 0 1 2 1 1 1 1

[0820] When the width W or the height H of the block or sub-block is less than X, the horizontal transform type trTypeHor or the vertical transform type trTypeVer can be determined as a first transform indicating an integer transform based on DCT-2.

[0821] At this time, the first transform can mean that trTypeHor or trTypeVer has a first value. Here, the first value can be 0.

[0822] Here, X can be a positive integer, and can be, for example, 2, 4, or 8.

[0823] When the width or height of the block or sub-block is greater than Y, the horizontal transform type or the vertical transform type can be determined as a first transform indicating an integer transform based on DCT-2.

[0824] Here, Y can be a positive integer, and can be, for example, 8, 16, 32, or 64.

[0825] When the width or height of the block or sub-block is greater than or equal to X or less than or equal to Y, the horizontal transform type or the vertical transform type can be determined as a second transform indicating an integer transform based on DST-7.

[0826] At this time, the second transform can mean that trTypeHor or trTypeVer has a second value. Here, the second value can be 1.

[0827] Here, X can be a positive integer and can be, for example, 2, 4, or 8. Here, Y can be a positive integer and can be, for example, 8, 16, 32, or 64.

[0828] In addition, when the width or height of the block or sub-block is Z, the horizontal transform or the vertical transform can not be performed.

[0829] Here, Z can be a positive integer including 0 and can be, for example, 1.

[0830] Here, the same horizontal transform type or the same vertical transform type can be used to transform all sub-blocks partitioned from the block. In addition, a one-dimensional transform type for at least one of the horizontal transform or the vertical transform of the block or sub-block can be determined regardless of the intra prediction mode.

[0831] As in the example of Table 7, at least one of the horizontal transform type trTypeHor or the vertical transform type trTypeVer for the block or sub-block can be determined.

[0832]

Table 7

[0833] trTypeHor trTypeVer (W >= 4 && W <= 8)? 1 : 0 (H >= 4 && H <= 8)? 1 : 0

[0834] The following shows an embodiment of determining at least one of a one-dimensional transform type, a two-dimensional transform combination, or whether to use a transform for a block or sub-block. Here, a one-dimensional transform type for at least one of the horizontal transform or the vertical transform of the block or sub-block can be determined.

[0835] When the width W or the height H of the block or sub-block is less than X, the horizontal transform type trTypeHor or the vertical transform type trTypeVer can be determined as a first transform indicating an integer transform based on DCT-2.

[0836] At this time, the first transform can mean that trTypeHor or trTypeVer has a first value. Here, the first value can be 0.

[0837] Here, X can be a positive integer and can be, for example, 2, 4, or 8.

[0838] When the width or height of the block or sub-block is greater than Y, the horizontal transform type or the vertical transform type can be determined as a first transform indicating an integer transform based on DCT-2.

[0839] Here, Y can be a positive integer, and can be, for example, 8, 16, 32, or 64.

[0840] When the width or height of the block or sub-block is greater than or equal to X or less than or equal to Y, the horizontal transform type or the vertical transform type can be determined as a second transform indicating an integer transform based on DST-7.

[0841] At this time, the second transform can mean that trTypeHor or trTypeVer has a second value. Here, the second value can be 1.

[0842] Here, X can be a positive integer, and can be, for example, 2, 4, or 8. Here, Y can be a positive integer, and can be, for example, 8, 16, 32, or 64.

[0843] In addition, when the width or height of the block or sub-block is Z, the horizontal transform or the vertical transform can not be performed.

[0844] Here, Z can be a positive integer including 0, and can be, for example, 1.

[0845] Here, the same horizontal transform type or the same vertical transform type can be used to transform all sub-blocks partitioned from the block. In addition, a one-dimensional transform type for at least one of the horizontal transform or the vertical transform of the block or sub-block can be determined regardless of the intra prediction mode.

[0846] As in the example of Table 8, at least one of the horizontal transform type trTypeHor or the vertical transform type trTypeVer for the block or sub-block can be determined.

[0847]

Table 8

[0848] trTypeHor trTypeVer (W >= 4 && W <= 32)? 1 : 0 (H >= 4 && H <= 32)? 1 : 0

[0849] The following shows an embodiment of determining at least one of a one-dimensional transform type, a two-dimensional transform combination, or whether to use a transform for a block or sub-block. Here, a one-dimensional transform type for at least one of the horizontal transform or the vertical transform of the block or sub-block can be determined.

[0850] When the prediction mode of the block or sub-block is an intra prediction mode or an intra block copy prediction mode, a one-dimensional transform type for at least one of the horizontal transform or the vertical transform of the block or sub-block can be determined based on at least one of the embodiments.

[0851] Various transform / inverse transform type determination methods for a block or sub-block can be performed, and at least one of the following scan methods can be performed after the transform or before the inverse transform.

[0852] At least one of the following scan methods can be performed with respect to a quantized coefficient level or a quantized level of a quantized coefficient, which is transformed or quantized at least once in an encoder / decoder.

[0853] Here, the quantized coefficient level can denote a result generated by performing a transform and quantization with respect to a residual block. Also, the quantized level can denote a result generated by performing quantization with respect to a residual block.

[0854] Also, the quantized coefficient level and the quantized level can have the same meaning, and can have the same meaning as a transform coefficient. That is, the quantized coefficient level, the quantized level, and the transform coefficient can denote an object when a residual block is entropy encoded / entropy decoded.

[0855] As shown in an example of FIG. FIG. 14 A diagonal scan can be used to arrange the quantized coefficient levels in a two-dimensional residual block as a one-dimensional coefficient level array. Also, the one-dimensional reconstructed coefficient level array can be arranged as the quantized coefficient levels in a two-dimensional residual block using the diagonal scan.

[0856] A scan direction from the lower left to the upper right can be referred to as an upper right diagonal scan. Also, a scan direction from the upper right to the lower left can be referred to as a lower left diagonal scan.

[0857] FIG. 14 An example of FIG.

[0858] As shown in an example of FIG. FIG. 15 A horizontal scan can be used to arrange the quantized coefficient levels in a two-dimensional residual block as a one-dimensional coefficient level array. Also, the one-dimensional reconstructed coefficient level array can be arranged as the quantized coefficient levels in a two-dimensional residual block using the horizontal scan.

[0859] At this time, the horizontal scan can be a method of preferentially scanning coefficients corresponding to a first row.

[0860] As shown in an example of FIG. FIG. 16 A vertical scan can be used to arrange the quantized coefficient levels in a two-dimensional residual block as a one-dimensional coefficient level array. Also, the one-dimensional reconstructed coefficient level array can be arranged as the quantized coefficient levels in a two-dimensional residual block using the vertical scan.

[0861] At this time, the vertical scan can be a method of preferentially scanning coefficients corresponding to a first column.

[0862] As shown in an example of FIG. FIG. 17 A block-based diagonal scan can be used to arrange the quantized coefficient levels in a two-dimensional residual block as a one-dimensional coefficient level array. Also, the one-dimensional reconstructed coefficient level array can be arranged as the quantized coefficient levels in a two-dimensional residual block using the block-based diagonal scan.

[0863] At this time, the block size can be MxN. Here, at least one of M or N can be a positive integer and can be 4. Also, the block size can be equal to the size of a coefficient group used in transform coefficient encoding / decoding.

[0864] FIG. 17 An example of the diagonal line scan based on a block shows a right-up scan based on a block.

[0865] At this time, the block can mean a sub-block partitioned from a block having a certain size. If a scan method based on a block is used, even a sub-block in a block having a certain size can be scanned using the same scan method as that in the block.

[0866] As in an example of FIG. 17 When a diagonal line scan based on a block is used, after a block having a size of 8x8 is partitioned into sub-blocks each having a size of 4x4, a diagonal line scan can be used to scan the sub-blocks each having a size of 4x4, and a diagonal line scan can be used to scan coefficients in the sub-blocks.

[0867] As in an example of FIG. 18 A block-based horizontal scan can be used to arrange quantized coefficient levels in a two-dimensional residual block into a one-dimensional coefficient level array. Also, a block-based horizontal scan can be used to arrange a one-dimensional reconstructed coefficient level array into quantized coefficient levels in a two-dimensional residual block. At this time, the block size can be 4x4, and a block corresponding to a first row can be preferentially scanned.

[0868] At this time, the block size can be MxN. Here, at least one of M or N can be a positive integer and can be 4. Also, the block size can be equal to the size of a coefficient group used in transform coefficient encoding / decoding.

[0869] At this time, the block-based horizontal scan can be a method of preferentially scanning coefficients corresponding to a first row.

[0870] As in an example of FIG. 19 A block-based vertical scan can be used to arrange quantized coefficient levels in a two-dimensional residual block into a one-dimensional coefficient level array. Also, a block-based vertical scan can be used to arrange a one-dimensional reconstructed coefficient level array into quantized coefficient levels in a two-dimensional residual block.

[0871] At this time, the block size can be MxN. Here, at least one of M or N can be a positive integer and can be 4. Also, the block size can be equal to the size of a coefficient group used in transform coefficient encoding / decoding.

[0872] At this time, the block-based vertical scan can be a method of preferentially scanning coefficients corresponding to a first column.

[0873] As in an example of FIG. 14 to FIG. 19In the example of FIG, the scan corresponding to (a) may be used for a residual block of size J×K for a J×K block, and the scan corresponding to (b) may be used for a residual block of size M×N or larger for a block of at least one of sizes 8×8 / 16×16 / 32×32 / 64×64, or for a residual block of size M×N. J, K, M, and N may be positive integers. Furthermore, J and K may be smaller than M and N, respectively. Furthermore, J×K may be 4×4, and M×N may be 8×8.

[0874] As in FIG. 14 to FIG. 19 In the example, although only the scanning method corresponding to the maximum size of 8×8 is shown, the scanning method corresponding to the size of 8×8 is applicable to the scanning method corresponding to the size larger than 8×8, and the above scanning is applicable not only to the residual block having a square form but also to the residual block having a non-square form.

[0875] In order to arrange the quantized coefficient levels in the two-dimensional residual block having a square / non-square form in the encoder, the quantized coefficient levels in the residual block may be scanned. In addition, in order to arrange the one-dimensionally reconstructed coefficient level array into the quantized coefficient levels in the two-dimensional residual block having a square / non-square form in the decoder, the coefficient levels may be scanned.

[0876] As in FIG. 20 In the example, at least one of the quantized coefficient levels may be scanned.

[0877] For example, as in FIG. 20 In the example of (a), the quantized coefficient levels in the two-dimensional residual block can be arranged into a one-dimensional coefficient level array using diagonal scanning. In addition, the one-dimensional reconstructed coefficient level array can be arranged into the quantized coefficient levels in the two-dimensional residual block using diagonal scanning.

[0878] At this time, if FIG. 20 In the example of (a), the diagonal scanning direction may be from the lower left side to the upper right side or from the upper right side to the lower left side.

[0879] The scanning direction from the lower left side to the upper right side may be referred to as an upper right diagonal scan. In addition, the scanning direction from the upper right side to the lower left side may be referred to as a lower left diagonal scan.

[0880] FIG. 20 The example of (a) shows an upper right scan in a diagonal scan.

[0881] As another example, in FIG. 20In an example of (b) of the present application, a vertical scan can be used to arrange the quantized coefficient levels in a two-dimensional residual block into a one-dimensional coefficient level array. Also, a vertic...

Claims

1. A video decoding method, the method comprising: decoding a transform skip mode flag from a bitstream indicating whether an inverse transform is skipped; Determine whether to decode the transform matrix index of the current block from the bitstream, Wherein, determining whether to skip the secondary inverse transform for the current block is determined according to the value of the transform matrix index, wherein the transform skip mode flag is decoded for each of the color components, the color components including a luminance component, a Cb component, and a Cr component, and Wherein, when the tree structure regarding the current block is a dual-tree type and the current block is a chroma component block, whether to decode a transform matrix index of the current block from a bitstream is determined based on a transform skip mode flag for a Cb component and a transform skip mode flag for a Cr component regardless of a transform skip mode flag for a luma component, wherein when both the transform skip mode flag for a Cb component and the transform skip mode flag for a Cr component indicate that inverse transform is not skipped, the transform matrix index is decoded.

2. The video decoding method according to claim 1, in, When the tree structure regarding the current block is a single tree type, it is determined whether to decode a transform matrix index of the current block from a bitstream based on all of a transform skip mode flag for a luma component, a transform skip mode flag for a Cb component, and a transform skip mode flag for a Cr component.

3. The video decoding method according to claim 1, in, When the tree structure regarding the current block is a dual-tree type and the current block is a luminance component block, it is determined whether to decode a transform matrix index of the current block from a bitstream based on a transform skip mode flag for the luminance component regardless of a transform skip mode flag for the Cb component and a transform skip mode flag for the Cr component.

4. The video decoding method according to claim 2, in, When the tree structure regarding the current block is a single tree type, the transform matrix index of the current block is decoded from the bitstream only when the transform skip mode flag for the luma component, the transform skip mode flag for the Cb component, and the transform skip mode flag for the Cr component all indicate that inverse transform is not skipped.

5. The video decoding method according to claim 1, in, When the value of the transform matrix index is greater than 0, a secondary inverse transform is applied to the current block, and a transform matrix for the secondary inverse transform is determined according to the value of the transform matrix index.

6. The video decoding method according to claim 1, further comprising: decoding information indicating whether an intra residual DPCM method is applied to the current block, wherein, when the information indicates that the intra residual DPCM method is not applied to the current block, decoding the transform matrix index of the current block from the bitstream, and When the information indicates that the intra residual DPCM method is applied to the current block, decoding a transform skip mode flag of the current block is omitted, and inverse transform is skipped for the current block.

7. The video decoding method according to claim 1, in, Further considering whether the current block is predicted by an intra prediction mode that is not a matrix-based intra prediction mode, it is determined whether to decode a transform matrix index of the current block from a bitstream.

8. A video encoding method, the method comprising: encoding a transform skip mode flag indicating whether a transform is skipped; Determine whether to encode the transformation matrix index of the current block, Wherein, when encoding the transformation matrix index, the value of the transformation matrix index is determined according to whether the secondary transformation is skipped for the current block, wherein the transform skip mode flag is encoded for each of the color components, the color components including a luminance component, a Cb component, and a Cr component, and Wherein, when the tree structure regarding the current block is a dual-tree type and the current block is a chroma component block, whether to encode a transform matrix index of the current block is determined based on a transform skip mode flag for the Cb component and a transform skip mode flag for the Cr component regardless of a transform skip flag for the luma component, wherein when both the transform skip mode flag for the Cb component and the transform skip mode flag for the Cr component are encoded to indicate that transform is not skipped, the transform matrix index is encoded.

9. The video encoding method according to claim 8, in, When the tree structure regarding the current block is a single tree type, it is determined whether to encode a transform matrix index of the current block based on all of a transform skip mode flag for a luma component, a transform skip mode flag for a Cb component, and a transform skip mode flag for a Cr component.

10. The video encoding method according to claim 9, in, When the tree structure regarding the current block is a single tree type, the transform matrix index of the current block is encoded only when the transform skip mode flag for the luma component, the transform skip mode flag for the Cb component, and the transform skip mode flag for the Cr component are all encoded to indicate that the transform is not skipped.

11. The video encoding method according to claim 8, in, When a secondary transform is applied to the current block, a value of the transform matrix index is greater than 0, and the value of the transform matrix index is set to indicate a secondary transform matrix used for the secondary transform.

12. The video encoding method according to claim 8, further comprising: encoding information indicating whether an intra residual DPCM method is applied to the current block, wherein, when the information is encoded to indicate that the intra residual DPCM method is not applied to the current block, a transform skip mode flag of the current block is encoded, and When the information is encoded to indicate that an intra residual DPCM method is applied to the current block, encoding of a transform skip mode flag of the current block is omitted, and transform is skipped for the current block.

13. The video encoding method according to claim 8, in, Further considering whether the current block is predicted by an intra prediction mode that is not a matrix-based intra prediction mode, it is determined whether to encode the transform matrix index of the current block.

14. An apparatus for transmitting compressed video data, comprising: a processor configured to obtain the compressed video data; as well as a sending unit, configured to send the compressed video data, Wherein, obtaining the compressed video data includes: encoding a transform skip mode flag indicating whether a transform is skipped; Determine whether to encode the transformation matrix index of the current block, Wherein, when encoding the transformation matrix index, the value of the transformation matrix index is determined according to whether the secondary transformation is skipped for the current block, wherein the transform skip mode flag is encoded for each of the color components, the color components including a luminance component, a Cb component, and a Cr component, and Wherein, when the tree structure regarding the current block is a dual-tree type and the current block is a chroma component block, whether to encode a transform matrix index of the current block is determined based on a transform skip mode flag for the Cb component and a transform skip mode flag for the Cr component regardless of a transform skip flag for the luma component, wherein when both the transform skip mode flag for the Cb component and the transform skip mode flag for the Cr component are encoded to indicate that transform is not skipped, the transform matrix index is encoded.