Method for decoding or encoding video and apparatus for transmitting compressed video data

By selectively applying inverse transformation and quantization in the video signal encoding and decoding process, combined with the number of binary bits encoded by context information, the problem of increased cost of high-resolution image data transmission and storage is solved, and efficient video signal compression and transmission is achieved.

CN120455674APending Publication Date: 2025-08-08KT CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510801957.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2019-09-23
Filing Date
2020-09-23
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

With the increasing demand for high-resolution and high-quality images, the prior art faces the problem of increasing expenses caused by the increase in data volume when transmitting and storing image data, especially when transmitting high-resolution and ultra-high-resolution stereoscopic image content, and existing video compression technologies are difficult to effectively compress and transmit.

Method used

Inverse transformation and quantization are selectively applied during the video signal encoding and decoding process, combined with the number of binary bits encoded by context information, to determine whether to decode or encode the absolute value and symbol information of the residual coefficients, efficient encoding and decoding of the residual coefficients is achieved.

Benefits of technology

It improves the encoding and decoding efficiency of video signals, reduces the cost of data transmission and storage, and is suitable for the compression and transmission of high-resolution and ultra-high-resolution videos.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120455674A_ABST
    Figure CN120455674A_ABST
Patent Text Reader

Abstract

A method of decoding or encoding a video and an apparatus for transmitting compressed video data are provided. The method for decoding the video comprises the following steps: obtaining a prediction sample of a current block; decoding a transform skip flag indicating whether the inverse transform is skipped for the current block; obtaining a residual coefficient of the current block; performing inverse quantization on the current block; obtaining a residual sample of the current block based on the inverse quantized residual coefficient of the current block; and reconstructing the current block by summing the prediction sample and the residual sample, in which when the transform skip flag indicates that the inverse transform is skipped for the current block, the transform skip flag is summed on the basis of the number of binary bits of context coding decoded until now and a threshold value, and the transform skip flag is summed on the basis of the number of binary bits of context coding decoded until now. And determining whether to decode at least one context-coded syntax for obtaining the residual coefficient of the current block, and decoding the at least one context-coded syntax from the bitstream to obtain the residual coefficient when the number of binary bits of the context-coded decoded until now is less than a threshold value.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the Chinese patent application with an application date of September 23, 2020, international application number PCT / KR2020 / 012865, invention name “Method and device for processing video signals”, and application number 202080066694.2 after entering the Chinese national phase. Technical Field

[0002] The present disclosure relates to methods and apparatus for processing video signals. Background Art

[0003] Recently, demand for high-resolution and high-quality images, such as HD (High Definition) and UHD (Ultra High Definition), has increased in various application fields. As image data becomes higher in resolution and higher in quality, the amount of data increases relative to existing image data. Consequently, when image data is transmitted using media such as existing wired and wireless broadband circuits or stored using existing storage media, transmission and storage costs increase. These issues arising from the increase in resolution and quality of image data can be addressed using efficient image compression technology.

[0004] There are various technologies, such as inter-frame prediction technology that uses image compression technology to predict pixel values included in a current picture based on previous or subsequent pictures of the current picture, intra-frame prediction technology that predicts pixel values included in a current picture by using pixel information in the current picture, entropy coding technology that assigns short symbols to values with high occurrence frequency and long symbols to values with low occurrence frequency, etc., and image data can be effectively compressed and transmitted or stored by using these image compression technologies.

[0005] On the other hand, as the demand for high-resolution images increases, the demand for stereoscopic image content as a new image service also increases. Video compression technology for efficiently providing high-resolution and ultra-high-resolution stereoscopic image content has been discussed. Summary of the Invention

[0006] Technical Purpose

[0007] An object of the present disclosure is to provide a method and apparatus for efficiently encoding / decoding residual coefficients when encoding / decoding a video signal.

[0008] An object of the present disclosure is to provide a method and apparatus for additionally applying a second transform to a result of a first transform when encoding / decoding a video signal.

[0009] The technical effects of the present disclosure may not be limited to the above-mentioned technical effects, and ordinary technicians in the technical field to which the present disclosure belongs may clearly understand other unmentioned technical effects from the following description.

[0010] Technical Solutions

[0011] According to the present disclosure, a method for decoding a video signal may include: determining whether to skip inverse transform for a current block; decoding residual coefficients of the current block; and selectively applying inverse transform to the residual coefficients based on the determination. In this case, when decoding the residual coefficients, one of a first syntax indicating whether the residual coefficient is greater than 0 and a second syntax indicating the absolute value of the residual coefficient may be selectively decoded.

[0012] According to the present disclosure, a method for encoding a video signal may include: determining whether to skip transform for a current block; quantizing a result of applying the transform or a result of skipping the transform; and encoding a residual coefficient output as a result of the quantization. In this case, when encoding the residual coefficient, one of a first syntax indicating whether the residual coefficient is greater than 0 and a second syntax indicating the absolute value of the residual coefficient may be selectively encoded.

[0013] In the method of decoding a video signal according to the present disclosure, whether to decode the first syntax or the second syntax may be determined by comparing a threshold value with the number of bins decoded by using context information.

[0014] In a method for decoding a video signal according to the present disclosure, the number of binary bits decoded by using context information may be increased when at least one of the following is decoded: a first syntax, at least one gt_N_flag indicating whether an absolute value has a value greater than (2N-1), or a parity flag indicating whether an absolute value is an even number.

[0015] In the method of decoding a video signal according to the present disclosure, when the first syntax is decoded and the first syntax indicates that the residual coefficient has a non-zero value, gt_1_flag indicating whether the absolute value of the residual coefficient has a value greater than 1 may be additionally decoded.

[0016] In the method of decoding a video signal according to the present disclosure, when gt_1_flag indicates that the absolute value has a value greater than 1, a parity flag indicating whether the absolute value is an even number and gt_2_flag indicating whether the absolute value is greater than 3 may be additionally decoded.

[0017] In the method of decoding a video signal according to the present disclosure, the threshold value may be determined based on the size of the current block.

[0018] A method for decoding a video according to the present disclosure includes: obtaining prediction samples of a current block; decoding a transform skip flag indicating whether inverse transform is skipped for the current block; obtaining residual coefficients of the current block; performing inverse quantization on the current block; obtaining residual samples of the current block based on the inverse quantized residual coefficients of the current block; and reconstructing the current block by summing the prediction samples and the residual samples, wherein, when the transform skip flag indicates that inverse transform is skipped for the current block, determining whether to decode at least one context-coded syntax for obtaining the residual coefficients of the current block based on the number of context-coded bits decoded so far and a threshold value, wherein when the number of context-coded bits decoded so far is less than the threshold value, decoding the at least one context-coded syntax from a bitstream to obtain the residual coefficients of the current block, and wherein the at least one context-coded syntax includes at least one of the following: a valid flag indicating whether the residual coefficient is non-zero, a greater-than-1 flag indicating whether the absolute value of the residual coefficient is greater than 1, a sign flag indicating whether the residual coefficient has a positive value or a negative value, and a parity flag indicating whether the absolute value of the residual coefficient is an odd number or an even number.

[0019] A method for encoding a video according to the present disclosure includes: obtaining prediction samples of a current block; obtaining residual samples of the current block by subtracting the prediction samples from original samples; obtaining the residual samples of the current block; determining whether to skip transform for the current block; quantizing transform coefficients of the current block; and encoding the residual coefficients resulting from the quantization, wherein when it is determined that transform is skipped for the current block, the transform coefficients are the same as the residual samples, wherein when it is determined that transform is skipped for the current block, determining whether to encode at least one context-coded syntax for the residual coefficients of the current block based on the number of context-coded bits encoded so far and a threshold value, wherein when the remaining number of context-coded bits encoded so far is less than the threshold value, encoding the at least one context-coded syntax into a bitstream for the residual coefficients of the current block, and wherein the at least one context-coded syntax includes at least one of the following: a significant flag indicating whether the residual coefficient is non-zero, a greater-than-1 flag indicating whether the absolute value of the residual coefficient is greater than 1, a sign flag indicating whether the residual coefficient has a positive value or a negative value, and a parity flag indicating whether the absolute value of the residual coefficient is an odd number or an even number.

[0020] According to the present disclosure, an apparatus for transmitting compressed video data includes: a processor configured to obtain compressed video data, and a transmission unit configured to transmit the compressed video data, wherein obtaining the compressed video data includes: obtaining prediction samples of a current block; obtaining residual samples of the current block by subtracting the prediction samples from the original samples; obtaining the residual samples of the current block; determining whether to skip transform for the current block; quantizing transform coefficients of the current block; and encoding the residual coefficients generated from the quantization, wherein when it is determined that transform is skipped for the current block, the transform coefficients are the same as the residual samples, wherein when it is determined that transform is skipped for the current block, based on the residual samples generated so far The method comprises: determining whether to encode at least one context coding syntax for a residual coefficient of a current block based on the number of context coded bits encoded so far and a threshold value, wherein when the remaining number of context coded bits encoded so far is less than the threshold value, encoding the at least one context coding syntax into the bitstream for the residual coefficient of the current block, and wherein the at least one context coding syntax includes at least one of the following: a valid flag indicating whether the residual coefficient is non-zero, a greater than 1 flag indicating whether the absolute value of the residual coefficient is greater than 1, a sign flag indicating whether the residual coefficient has a positive value or a negative value, and a parity flag indicating whether the absolute value of the residual coefficient is an odd number or an even number.

[0021] The features briefly summarized above for the present disclosure are merely illustrative aspects of the detailed description of the disclosure that follows and do not limit the scope of the disclosure.

[0022] Technical Effects

[0023] According to the present disclosure, encoding / decoding efficiency can be improved by an encoding method of differently setting residual coefficients according to the number of bins encoded by using context information.

[0024] According to the present disclosure, encoding / decoding efficiency can be improved by additionally applying a second transform to the result of the first transform. The effects obtainable from the present disclosure may not be limited to the effects mentioned above, and those skilled in the art in the art to which the present disclosure pertains may clearly understand other unmentioned effects from the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 is a block diagram illustrating an image encoding apparatus according to an embodiment of the present disclosure.

[0026] Figure 2 is a block diagram illustrating an image decoding apparatus according to an embodiment of the present disclosure.

[0027] Figure 3is a flowchart illustrating an intra prediction method according to an embodiment of the present disclosure.

[0028] Figure 4 The type of intra prediction mode is shown.

[0029] Figure 5 is a diagram for describing an example of deriving prediction samples in planar mode.

[0030] Figure 6 Represents an example of generating prediction samples in horizontal mode and vertical mode.

[0031] Figure 7 and Figure 8 is a diagram showing an example of application of the second transformation.

[0032] Figure 9 and Figure 10 A second transformation based on a second transformation kernel having an asymmetric shape is shown.

[0033] Figure 11 This shows an example of determining whether to encode information indicating whether to apply the second transform based on the position of the last non-zero coefficient.

[0034] Figure 12 Limited region candidates for a 4x4 sized block are shown.

[0035] Figure 13 is a diagram showing an example of applying a second transform kernel of a predetermined size.

[0036] Figure 14 The scanning method is shown.

[0037] Figure 15 Flowchart showing the process of encoding residual coefficients in an encoder.

[0038] Figure 16 This is a flowchart showing the process of encoding the magnitude information of the residual coefficient.

[0039] Figure 17 Flowchart showing the process of decoding residual coefficients in a decoder.

[0040] Figure 18 This is a diagram showing a process of decoding the magnitude information of the residual coefficient.

[0041] Figure 19 and Figure 20 is a diagram showing an example of counting the number of binary bits of usage context information.

[0042] Figures 21 to 23 This section shows an example where the priorities between grammars are different by using context information encoding.

[0043] Figure 24 and Figure 25 Represents the surrounding reconstruction area that is referenced to determine contextual information.

[0044] Figure 26 The number of context information that can be referred to when encoding the flag sig_flag is shown.

[0045] Figure 27 Shows the number of context information that can be referenced when encoding gt_N_flag or par_flag. DETAILED DESCRIPTION

[0046] Since the present disclosure can be modified in various ways and has several embodiments, specific embodiments will be illustrated in the drawings and described in detail. However, it is not intended to limit the present disclosure to specific embodiments, and it should be understood that the present disclosure includes all changes, equivalents, or alternatives within the scope of the ideas and techniques of the present disclosure. When describing each of the drawings, similar reference numerals are used for similar parts.

[0047] Terms such as first, second, etc. may be used to describe various components, but components should not be limited by these terms. These terms are only used to distinguish one component from other components. For example, a first component may be referred to as a second component, and similarly, a second component may be referred to as a first component, without exceeding the scope of the rights of the present disclosure. The term "and / or" includes a combination of multiple relative input items or any items of multiple relative input items.

[0048] When a component is referred to as being "linked" or "connected" to another component, it should be understood that the component may be directly linked or connected to the other component, but other components may exist in between. On the other hand, when a component is referred to as being "directly linked" or "directly connected" to another component, it should be understood that no other components exist in between.

[0049] Because the terms used in this application are only used to describe specific embodiments, they are not intended to limit the present disclosure. Singular expressions include plural expressions unless they clearly have different meanings in the context. In this application, it should be understood that terms such as "including" or "having" refer to the presence of characteristics, numbers, stages, movements, components, parts or combinations thereof entered in the specification, but do not exclude the presence or possibility of adding in advance one or more other characteristics, numbers, stages, movements, components, parts or combinations thereof.

[0050] Hereinafter, with reference to the accompanying drawings, a desired embodiment of the present disclosure will be described in more detail. Hereinafter, the same reference numerals are used for the same components in the drawings, and repeated description of the same components is omitted.

[0051] Figure 1 is a block diagram illustrating an image encoding apparatus according to an embodiment of the present disclosure.

[0052] Reference Figure 1 The image encoding device 100 may include: a picture segmentation unit 110, a prediction unit 120 and a prediction unit 125, a transformation unit 130, a quantization unit 135, a rearrangement unit 160, an entropy encoding unit 165, a dequantization unit 140, an inverse transformation unit 145, a filter unit 150 and a memory 155.

[0053] because Figure 1 Each of the structural units in the image encoding apparatus is shown independently to illustrate different characteristic functions, but this does not mean that each structural unit is composed of separate hardware or a single software unit. That is, since each structural unit is included for the convenience of description, at least two structural units in each structural unit may be combined to form a single structural unit, or a single structural unit may be divided into multiple structural units to perform functions. Even integrated implementations and separate implementations of each structural unit are included within the scope of the present disclosure as long as they do not depart from the essence of the present disclosure.

[0054] In addition, some components may be optional components for improving performance only, rather than essential components for performing the basic functions of the present disclosure. The present disclosure may be implemented by including only the structural units necessary to achieve the essence of the present disclosure and excluding components that are only used to improve performance, and a structure that includes only the essential components and excludes optional components that are only used to improve performance is also included in the scope of the rights of the present disclosure.

[0055] The picture segmentation unit 110 may segment an input picture into at least one processing unit. In this regard, a processing unit may be a prediction unit (PU), a transform unit (TU), or a coding unit (CU). In the picture segmentation unit 110, a picture may be segmented into a combination of a plurality of coding units, prediction units, and transform units, and the picture may be encoded by selecting a combination of a coding unit, a prediction unit, and a transform unit according to a predetermined criterion (e.g., a cost function).

[0056] For example, a picture can be divided into multiple coding units. In order to divide the coding units in the picture, a recursive tree structure such as a quadtree structure can be used, and the coding unit divided into other coding units by using an image or a maximum coding unit as a path can be divided with as many child nodes as the number of divided coding units. Coding units that are no longer divided according to specific restrictions become leaf nodes. In other words, when it is assumed that only square division is possible for one coding unit, one coding unit can be divided into up to four other coding units.

[0057] Hereinafter, in an embodiment of the present disclosure, a coding unit may be used as a unit for encoding or may be used as a unit for decoding.

[0058] The prediction units may be partitioned in at least one square or rectangular shape, etc., with the same size in one coding unit, or may be partitioned such that any one of the prediction units partitioned in one coding unit may have a different shape and / or size from another prediction unit.

[0059] When generating a prediction unit for performing intra prediction based on a coding block, when the prediction unit is not a minimum coding unit, intra prediction may be performed without performing partitioning into a plurality of prediction units N×N.

[0060] The prediction units 120 and 125 may include an inter-frame prediction unit 120 that performs inter-frame prediction and an intra-frame prediction unit 125 that performs intra-frame prediction. Whether inter-frame prediction or intra-frame prediction is performed for a prediction unit may be determined, and detailed information based on each prediction method (e.g., intra-frame prediction mode, motion vector, reference picture, etc.) may be determined. In this regard, the processing unit that performs prediction may be different from the processing unit that determines the prediction method and details. For example, the prediction method, prediction mode, etc. may be determined in the prediction unit, and prediction may be performed in the transform unit. The residual value (residual block) between the generated prediction block and the original block may be input to the transform unit 130. In addition, prediction mode information, motion vector information, etc. used for prediction may be encoded using the residual value in the entropy coding unit 165 and transmitted to the decoding device. When a specific coding mode is used, the original block may be encoded as is and transmitted to the decoding unit without generating a prediction block through the prediction unit 120 or 125.

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

[0062] The reference picture interpolation unit can receive reference picture information from the memory 155 and generate pixel information equal to or smaller than an integer pixel in the reference picture. For luma pixels, an 8-tap DCT-based interpolation filter with different filter coefficients can be used to generate pixel information equal to or smaller than an integer pixel in units of 1 / 4 pixels. For chroma signals, a 4-tap DCT-based interpolation filter with different filter coefficients can be used to generate pixel information equal to or smaller than an integer pixel in units of 1 / 8 pixels.

[0063] The motion prediction unit may perform motion prediction based on the reference picture interpolated by the reference picture interpolation unit. As a method for calculating a motion vector, various methods such as FBMA (full search based block matching algorithm), TSS (three-step search), NTS (new three-step search algorithm), etc. may be used. The motion vector may have a motion vector value in units of 1 / 2 or 1 / 4 pixels based on the interpolated pixel. The motion prediction unit may predict the current prediction unit by changing the motion prediction method. Various methods such as a skip method, a merge method, an advanced motion vector prediction (AMVP) method, an intra-block copy method, etc. may be used as the motion prediction method.

[0064] The intra-frame prediction unit 125 can generate a prediction unit based on reference pixel information around the current block, which is pixel information in the current picture. When the neighboring block in the current prediction unit is a block for which inter-frame prediction is performed, and therefore the reference pixel is a pixel for which inter-frame prediction is performed, the reference pixel included in the block for which inter-frame prediction is performed can be used by replacing it with the reference pixel information of the surrounding block for which intra-frame prediction is performed. In other words, when a reference pixel is unavailable, the unavailable reference pixel information can be used by replacing it with at least one reference pixel from among the available reference pixels.

[0065] The prediction mode for intra-frame prediction can include a directional prediction mode that uses reference pixel information according to the prediction direction when performing prediction, and a non-directional mode that does not use directional information. The mode for predicting luma information can be different from the mode for predicting chroma information, and chroma information can be predicted using the intra-frame prediction mode information used to predict luma information or the predicted luma signal information.

[0066] When the size of the prediction unit is the same as the size of the transform unit when performing intra prediction, intra prediction of the prediction unit can be performed based on the pixel at the left position, the pixel at the upper left position, and the pixel at the top position of the prediction unit. However, when the size of the prediction unit is different from the size of the transform unit when performing intra prediction, intra prediction can be performed by using reference pixels based on the transform unit. In addition, intra prediction using N×N partitioning can be used only for the smallest coding unit.

[0067] In the intra prediction method, a prediction block may be generated after applying an adaptive intra smoothing (AIS) filter to reference pixels according to a prediction mode. The type of the AIS filter applied to the reference pixels may be different. In order to perform the intra prediction method, the intra prediction mode in the current prediction unit may be predicted based on the intra prediction modes in the prediction units surrounding the current prediction unit. When the prediction mode in the current prediction unit is predicted by using mode information predicted based on the surrounding prediction units, if the intra prediction mode in the current prediction unit is the same as the intra prediction mode in the surrounding prediction units, information that the prediction mode in the current prediction unit is the same as the prediction mode in the surrounding prediction units may be transmitted by using predetermined flag information, and if the prediction mode in the current prediction unit is different from the prediction mode in the surrounding prediction units, the prediction mode information of the current block may be encoded by performing entropy coding.

[0068] Furthermore, a residual block including information on a residual value, which is a difference value between a prediction unit predicted based on the prediction units generated in the prediction units 120 and 125 and an original block in the prediction unit, may be generated. The generated residual block may be input to the transform unit 130.

[0069] The transform unit 130 may transform the original block and the residual block including residual value information in the prediction unit generated by the prediction units 120 and 125 by using a transform method such as DCT (Discrete Cosine Transform), DST (Discrete Sine Transform), or KLT. Whether DCT, DST, or KLT is applied to transform the residual block may be determined based on intra prediction mode information in the prediction unit used to generate the residual block.

[0070] The quantization unit 135 may quantize the value transformed into the frequency domain in the transform unit 130. The quantization coefficient may be changed according to the importance or block of the image. The value calculated in the quantization unit 135 may be provided to the dequantization unit 140 and the rearrangement unit 160.

[0071] The rearrangement unit 160 may perform rearrangement on coefficient values of the quantized residual value.

[0072] The rearrangement unit 160 can change the coefficients in the shape of a two-dimensional block into the shape of a one-dimensional vector using a coefficient scanning method. For example, the rearrangement unit 160 can scan from the DC coefficient to the coefficients in the high frequency domain using a zigzag scanning method and change them into the shape of a one-dimensional vector. Depending on the size of the transform unit and the intra-frame prediction mode, instead of the zigzag scanning, vertical scanning that scans the coefficients in the shape of a two-dimensional block in the column direction or horizontal scanning that scans the coefficients in the shape of a two-dimensional block in the row direction can be used. In other words, which scanning method to use among zigzag scanning, vertical directional scanning, and horizontal directional scanning can be determined according to the size of the transform unit and the intra-frame prediction mode.

[0073] The entropy encoding unit 165 may perform entropy encoding based on the value calculated by the rearrangement unit 160. The entropy encoding may use various encoding methods such as Exponential Golomb, CAVLC (Context-Adaptive Variable Length Coding), and CABAC (Context-Adaptive Binary Arithmetic Coding).

[0074] The entropy coding unit 165 can encode various information from the rearrangement unit 160 and the prediction unit 120 and the prediction unit 125, such as residual value coefficient information and block type information in the coding unit, prediction mode information, partition unit information, prediction unit information and transmission unit information, motion vector information, reference frame information, block interpolation information, filtering information, etc.

[0075] The entropy encoding unit 165 may perform entropy encoding on the coefficient values in the coding unit input from the rearrangement unit 160 .

[0076] The dequantization unit 140 and the inverse transform unit 145 perform dequantization on the value quantized in the quantization unit 135 and perform inverse transform on the value transformed in the transform unit 130. The residual value generated by the dequantization unit 140 and the inverse transform unit 145 may be combined with the prediction unit predicted by the motion prediction unit, the motion compensation unit, and the intra prediction unit included in the prediction units 120 and 125 to generate a reconstructed block.

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

[0078] A deblocking filter can remove block distortion generated by boundaries between blocks in a reconstructed image. To determine whether to perform deblocking, a determination can be made based on the pixels included in a number of rows or columns included in the block whether to apply a deblocking filter to the current block. When applying a deblocking filter to a block, a strong filter or a weak filter can be applied depending on the desired deblocking filter strength. In addition, when applying a deblocking filter, when performing horizontal filtering and vertical filtering, horizontal directional filtering and vertical directional filtering can be set to be processed in parallel.

[0079] The offset correction unit can correct the offset of the deblocked image from the original image in units of pixels. To perform offset correction on a specific image, the pixels included in the image can be divided into a certain number of regions to determine the region where the offset is to be performed, and a method of applying the offset to the corresponding region or a method of applying the offset by considering edge information of each pixel can be used.

[0080] Adaptive loop filtering (ALF) can be performed based on a value obtained by comparing a filtered reconstructed image with an original image. After the pixels included in the image are divided into predetermined groups, filtering can be performed on each group separately by determining a filter to be applied to the corresponding group. Information on whether ALF will be applied can be transmitted per coding unit (CU) for the luminance signal, and the shape and filter coefficients of the ALF filter to be applied can be different for each block. In addition, an ALF filter of the same shape (fixed shape) can be applied regardless of the characteristics of the block to which it is applied.

[0081] The memory 155 may store the reconstructed block or picture calculated by the filter unit 150 and may provide the stored reconstructed block or picture to the prediction units 120 and 125 when inter prediction is performed.

[0082] Figure 2 is a block diagram illustrating an image decoding apparatus according to an embodiment of the present disclosure.

[0083] Reference Figure 2 , the image decoding device 200 may include: an entropy decoding unit 210, a rearrangement unit 215, a dequantization unit 220, an inverse transformation unit 225, a prediction unit 230 and a prediction unit 235, a filter unit 240 and a memory 245.

[0084] When an image bit stream is input from the image encoding apparatus, the input bit stream may be decoded according to a reverse process of the image encoding apparatus.

[0085] The entropy decoding unit 210 may perform entropy decoding according to a process opposite to the process of performing entropy encoding in the entropy encoding unit of the image encoding device. For example, various methods such as Exponential Golomb, CAVLC (Context Adaptive Variable Length Coding), and CABAC (Context Adaptive Binary Arithmetic Coding) may be applied depending on the method performed in the image encoding device.

[0086] The entropy decoding unit 210 may decode information related to intra prediction and inter prediction performed in the encoding apparatus.

[0087] The rearrangement unit 215 may perform rearrangement based on a method of rearranging the bitstream entropy-decoded by the entropy decoding unit 210 in the coding unit. The coefficients represented in the one-dimensional vector form may be rearranged by reconfiguring the coefficients into a two-dimensional block form. The rearrangement unit 215 may receive information related to coefficient scanning performed in the coding unit and perform rearrangement by a method in which scanning is performed inversely based on the scanning order performed in the corresponding coding unit.

[0088] The dequantization unit 220 may perform dequantization based on the quantization parameter provided from the encoding device and the coefficient value of the rearranged block.

[0089] The inverse transform unit 225 can perform the transform performed in the transform unit, that is, the inverse transform for DCT, DST, and KLT, that is, the inverse DCT, inverse DST, and inverse KLT for the quantization result performed in the image encoding device. The inverse transform can be performed based on the transmission unit determined in the image encoding device. In the inverse transform unit 225 of the image decoding device, the transform technology (e.g., DCT, DST, KLT) can be selectively performed based on various information such as the prediction method, the size of the current block, the prediction direction, etc.

[0090] The prediction units 230 and 235 may generate a prediction block based on information related to generation of the prediction block provided from the entropy decoding unit 210 and pre-decoded block or picture information provided from the memory 245 .

[0091] As described above, when intra prediction is performed in the same manner as in the operation of the image encoding device, if the size of the prediction unit is the same as the size of the transform unit, intra prediction of the prediction unit can be performed based on the pixel at the left position, the pixel at the upper left position, and the pixel at the top position of the prediction unit. However, when the size of the prediction unit is different from the size of the transform unit when performing intra prediction, intra prediction can be performed by using reference pixels based on the transform unit. In addition, intra prediction using N×N partitioning can be used only for the minimum coding unit.

[0092] Prediction units 230 and 235 may include a prediction unit determination unit, an inter-frame prediction unit, and an intra-frame prediction unit. The prediction unit determination unit may receive various information input from the entropy decoding unit 210, such as prediction unit information, prediction mode information for the intra-frame prediction method, and motion prediction-related information for the inter-frame prediction method, to divide the prediction unit in the current coding unit and determine whether the prediction unit performs inter-frame prediction or intra-frame prediction. The inter-frame prediction unit 230 may perform inter-frame prediction on the current prediction unit based on information included in at least one picture preceding or following the current picture including the current prediction unit, using information required for inter-frame prediction in the current prediction unit provided by the image encoding device. Alternatively, inter-frame prediction may be performed based on information regarding pre-reconstructed regions in the current picture including the current prediction unit.

[0093] In order to perform inter prediction, whether a motion prediction method in a prediction unit included in a corresponding coding unit is a skip mode, a merge mode, an AMVP mode, or an intra block copy mode may be determined based on the coding unit.

[0094] The intra-frame prediction unit 235 can generate a prediction block based on pixel information in the current picture. When the prediction unit is a prediction unit that performs intra-frame prediction, intra-frame prediction can be performed based on the intra-frame prediction mode information in the prediction unit provided by the image encoding device. The intra-frame prediction unit 235 may include an adaptive intra-frame smoothing (AIS) filter, a reference pixel interpolation unit, and a DC filter. As part of performing filtering on the reference pixels of the current block, the AIS filter can be applied by determining whether to apply the filter based on the prediction mode in the current prediction unit. By using the prediction mode and AIS filter information in the prediction unit provided by the image encoding device, AIS filtering can be performed on the reference pixels of the current block. When the prediction mode of the current block is a mode in which AIS filtering is not performed, the AIS filter may not be applied.

[0095] When the prediction mode in the prediction unit is a prediction unit that performs intra-frame prediction based on pixel values interpolated from reference pixels, the reference pixel interpolation unit may interpolate the reference pixels to generate reference pixels in units of pixels equal to or less than an integer value. When the prediction mode of the current prediction unit is a prediction mode that generates a prediction block without interpolating the reference pixels, the reference pixels may not be interpolated. When the prediction mode of the current block is a DC mode, a DC filter may generate a prediction block through filtering.

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

[0097] Information on whether a deblocking filter is applied to a corresponding block or picture and information on whether a strong filter or a weak filter is applied when the deblocking filter is applied may be provided from the image encoding device. Information related to the deblocking filter provided from the image encoding device may be provided in the deblocking filter of the image decoding device, and deblocking filtering of the corresponding block may be performed in the image decoding device.

[0098] The offset correction unit may perform offset correction on the reconstructed image based on the offset value information, a type of offset correction applied to the image when encoding is performed.

[0099] ALF may be applied to a coding unit based on information on whether ALF is applied, ALF coefficient information, etc. provided from the encoding device. Such ALF information may be provided by including it in a specific parameter set.

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

[0101] As described above, hereinafter, in the embodiments of the present disclosure, for convenience of description, a coding unit is used as a term of a coding unit, but may be a unit that performs decoding as well as encoding.

[0102] In addition, since the current block represents a block to be encoded / decoded, it can represent a coding tree block (or coding tree unit), a coding block (or coding unit), a transform block (or transform unit), or a prediction block (or prediction unit), etc., depending on the encoding / decoding step. In this specification, a "unit" can represent a basic unit for performing a specific encoding / decoding process, and a "block" can represent a pixel array of a predetermined size. Unless otherwise classified, "block" and "unit" can be used interchangeably. For example, in the embodiments described later, it can be understood that a coding block (coding block) and a coding unit (coding unit) can be used interchangeably.

[0103] The image can be encoded / decoded in units of blocks. The coding blocks can be recursively partitioned based on a tree structure. In an example, the coding blocks can be partitioned by at least one of quadtree partitioning, binary tree partitioning, or ternary tree partitioning.

[0104] In addition, a coding block may be partitioned into multiple prediction blocks or multiple transform blocks.

[0105] Figure 3 is a flowchart illustrating an intra prediction method according to an embodiment of the present disclosure.

[0106] Reference Figure 3, an index of a reference sample row of the current block may be determined S301. The index may specify one of a plurality of reference sample row candidates. The plurality of reference sample row candidates may include adjacent reference sample rows adjacent to the current block and at least one non-adjacent reference sample row not adjacent to the current block.

[0107] In an example, neighboring reference sample rows including a neighboring row whose y-axis coordinate is 1 less than the uppermost row of the current block and a neighboring column whose x-axis coordinate is 1 less than the leftmost column of the current block may be used as reference sample row candidates.

[0108] A first non-adjacent reference sample row including a non-adjacent row whose y-axis coordinate is 2 less than the uppermost row of the current block and a non-adjacent column whose x-axis coordinate is 2 less than the leftmost column of the current block may be used as a reference sample row candidate.

[0109] A second non-adjacent reference sample row including a non-adjacent row whose y-axis coordinate is 3 less than the uppermost row of the current block and a non-adjacent column whose x-axis coordinate is 3 less than the leftmost column of the current block may be used as a reference sample row candidate.

[0110] The index may indicate one of an adjacent reference sample row, a first non-adjacent reference sample row, or a second non-adjacent reference sample row. In an example, when the index is 0, it means that the adjacent reference sample row is selected, when the index is 1, it means that the first non-adjacent reference sample row is selected, and when the index is 2, it means that the second non-adjacent reference sample row is selected.

[0111] An index specifying one of a plurality of reference sample row candidates may be signaled in the bitstream.

[0112] Alternatively, the index may be signaled for the luma component block and omitted for the chroma component block. When the index is omitted, the index may be inferred to be 0. In other words, for the chroma component block, intra prediction may be performed using adjacent reference sample rows.

[0113] The reconstructed samples included by the selected reference sample row may be derived as reference samples.

[0114] Next, the intra prediction mode of the current block may be determined S302.

[0115] Figure 4 Shows the type of intra prediction mode. Figure 4 In the example shown, the intra prediction modes include non-directional prediction modes (DC and planar) and directional prediction modes. Figure 4 It is shown that 65 directional prediction modes are defined.

[0116] A flag indicating whether the intra prediction mode of the current block is the same as the MPM (Most Probable Mode) can be signaled in the bitstream. In this example, when the value of the MPM flag is 1, it indicates that there is an MPM that is the same as the intra prediction mode of the current block. On the other hand, when the value of the MPM flag is 0, it indicates that there is no MPM that is the same as the intra prediction mode of the current block.

[0117] When the value of the MPM flag is 1, a flag indicating whether the intra prediction mode of the current block is the same as the default intra prediction mode may be signaled. The default intra prediction mode may be at least one of DC, planar, vertically oriented prediction mode, or horizontally oriented prediction mode. In the example, intra_not_planar_flag, a flag indicating whether the intra prediction mode of the current block is a planar mode, may be signaled. When the value of the flag intra_not_planar_flag is 0, this indicates that the intra prediction mode of the current block is planar. On the other hand, when the value of the flag intra_not_planar_flag is 1, this indicates that the intra prediction mode of the current block is not planar. When the value of the flag intra_not_planar_flag is 1, an index specifying one of the MPM candidates may be signaled. The intra prediction mode of the current block may be set to be the same as the MPM indicated by the MPM index.

[0118] Based on the intra prediction mode and the reference samples belonging to the reference sample row, a prediction sample may be derived S303.

[0119] When the intra prediction mode of the current block is a directional prediction mode, a prediction sample may be derived by using a reference sample positioned on a line following an angle of the directional prediction mode.

[0120] When the intra prediction mode of the current block is the planar mode, the prediction sample may be derived by using a reference sample in a vertical direction of the sample to be predicted and a reference sample in a horizontal direction of the sample to be predicted.

[0121] Figure 5 is a diagram for describing an example of deriving prediction samples in planar mode.

[0122] exist Figure 5 In , T represents the reference sample adjacent to the upper right corner of the current block, and L represents the reference sample adjacent to the lower left corner of the current block.

[0123] In the planar mode, for the sample to be predicted, a horizontally oriented prediction sample P1 and a vertically oriented prediction sample P2 can be obtained.

[0124] The horizontally oriented prediction sample P1 may be generated by performing linear interpolation on an upper right reference sample T and a reference sample H positioned on the same horizontal line as the sample to be predicted.

[0125] The vertically oriented prediction sample P2 may be generated by performing linear interpolation on a lower left reference sample L and a reference sample V positioned on the same vertical line as the sample to be predicted.

[0126] Then, based on the weighted sum operation of the horizontally oriented prediction sample P1 and the vertically oriented prediction sample P2, the prediction sample can be obtained. Equation 1 represents an example of obtaining the prediction sample P by the weighted sum operation of the horizontally oriented prediction sample P1 and the vertically oriented prediction sample P2.

[0127] [Equation 1]

[0128] P = (α × P1 + β × P2) / (α + β)

[0129] In Equation 1, α represents a weight applied to the horizontally oriented prediction sample P1, and β represents a weight applied to the vertically oriented prediction sample P2.

[0130] The weights α and β may be determined based on the size or shape of the current block. Specifically, the weights α and β may be determined by considering at least one of the width or height of the current block. In the example, when the width and height of the current block are the same, the weights α and β may be set to the same value. When the weights α and β are the same, the prediction sample may be derived as the average of the horizontally oriented prediction sample P1 and the vertically oriented prediction sample P2. On the other hand, when the width and height of the current block are different, the weights α and β may be set differently. In the example, when the width of the current block is greater than the height, the weight β may be set to a value greater than the weight α, and when the height of the current block is greater than the width, the weight α may be set to a value greater than the weight β. Alternatively, conversely, when the width of the current block is greater than the height, the weight α may be set to a value greater than the weight β, and when the height of the current block is greater than the width, the weight β may be set to a value greater than the weight α.

[0131] In another example, weights α and β can be derived from one of a plurality of weight set candidates. In the example, when weight candidate sets (1, 1), (3, 1), and (1, 3) representing combinations of weights α and β are predefined, weights α and β can be selected to be the same as one of the weight candidate sets.

[0132] An index indicating one of the plurality of weight set candidates may be signaled in the bitstream. The index may be signaled at the block level. In an example, the index may be signaled per coding block or transform block.

[0133] Alternatively, the index can be signaled at the level of a coding tree unit, slice, picture, or sequence. The blocks included in the index transmission unit can determine the weights α and β by referring to the index signaled at a higher level. In other words, the weights α and β can be set to be the same for the blocks included in the index transmission unit.

[0134] exist Figure 5 In the example of , it is shown that the top right reference sample T is used to derive the horizontally oriented prediction sample P1 , and the bottom left reference sample L is used to derive the vertically oriented prediction sample P2 .

[0135] The horizontally oriented prediction sample P1 may be derived by using a reference sample other than the upper right reference sample, or the vertically oriented prediction sample P2 may be derived by using a reference sample other than the lower left reference sample. In this example, reference sample set candidates for deriving a first reference sample for deriving the horizontally oriented prediction sample P1 and a second reference sample for deriving the vertically oriented prediction sample P2 may be configured, and the horizontally oriented prediction sample P1 and the vertically oriented prediction sample P2 may be derived by using one candidate selected from a plurality of reference sample set candidates.

[0136] An index identifying one of a plurality of reference sample set candidates may be signaled in a bitstream. The index may be signaled in units of blocks, sub-blocks, or samples.

[0137] Alternatively, the reference sample set candidates may be selected based on the positions of the samples to be predicted.

[0138] In directional prediction mode, prediction samples can be generated by using reconstructed pixels around the current block.

[0139] Figure 6 Represents an example of generating prediction samples in horizontal mode and vertical mode.

[0140] like Figure 6 In the example shown, in the horizontal mode, prediction samples may be generated by using reconstructed samples in the horizontal direction of the sample to be predicted.

[0141] In the vertical mode, a prediction sample may be generated by using reconstructed samples in the vertical direction of the sample to be predicted.

[0142] After performing intra prediction based on the intra prediction mode, a residual block may be obtained by subtracting the predicted block from the original block.

[0143] In this case, a prediction method using one of the 0th to 66th modes can be used, or a limited prediction method can also be used. In the limited prediction method, only the intra-frame prediction mode in the horizontal direction (18th) or the intra-frame prediction mode in the vertical direction (50th) can be used. In this case, the intra-frame prediction mode can be specified by 1 bit of information. Alternatively, diagonal directional prediction modes other than the vertical and horizontal directions, such as the lower left diagonal direction (2nd) and the upper right diagonal direction (66th), can be added as available candidates. In this case, the intra-frame prediction mode can be specified by 2 bits of information. Alternatively, 2 of the 3 diagonal direction modes, such as the lower left diagonal direction (2nd), the upper left diagonal direction (34th), and the upper right diagonal direction (66th), can be added as available candidates.

[0144] The number of available intra prediction modes can be encoded and sent to the decoder. Alternatively, the number of intra prediction modes that can be used in the encoder and decoder can be fixed. Alternatively, the number of available intra prediction modes can be determined based on the size or shape of the current block.

[0145] After performing the prediction, a residual block may be obtained by subtracting the original block from the predicted block. When the residual block is obtained, a residual coefficient may be obtained by performing at least one of transformation or quantization on the residual block.

[0146] Information indicating whether a transform is applied to the current block may be encoded and signaled. In an example, a transform_skip_flag may be encoded and signaled. When transform_skip_flag is 1, this indicates that a transform is not applied to the current block. Here, the transform may include a second transform, which will be described later, as well as the first transform. When transform_skip_flag is 0, this indicates that a transform is applied to the current block. When transform_skip_flag is 0, the first transform must be applied to the current block, while the second transform may be applied optionally.

[0147] The transform may be performed based on at least one of a DCT-based transform kernel or a DST-based transform kernel. Here, the DCT-based transform kernel may include at least one of DCT-2 or DCT-8, and the DST-based transform kernel may include DST-7. An additional transform may be applied to the result of transforming the residual samples. Hereinafter, for ease of description, the transform performed by the DCT-based or DST-based transform kernel is referred to as a first transform, and the transform additionally applied to the result of the first transform is referred to as a second transform. Furthermore, the transform coefficients generated by the result of the first transform are referred to as first transform coefficients, and the transform coefficients generated by the result of the second transform are referred to as second transform coefficients.

[0148] The second transform may be applied to at least a portion of the first transform coefficients. In an example, the second transform may be applied to 16, 48, or 64 first transform coefficients, depending on the size of the second transform kernel. The shape of the region including the first transform coefficients to which the second transform is applied may be square, non-square, or polygonal.

[0149] Equation 2 represents the application aspects of the second transform.

[0150] [Equation 2]

[0151] B R×1 =T R×N ·A N×1

[0152] In Equation 2, B_R×1 represents a second transform coefficient consisting of R rows and 1 column. T_R×N represents a second transform kernel consisting of R rows and N columns. A_N×1 represents a first transform coefficient consisting of N rows and 1 column.

[0153] Figure 7 and Figure 8 is a diagram showing an example of application of the second transformation.

[0154] Figure 7 This shows an example where the second transform kernel has a size of 64×64. The first transform coefficients generated by the result of the first transform in the 8×8 block can be arranged in one dimension. In this case, the one-dimensional array can be generated by scanning the first transform coefficients using a predetermined scanning method. The predetermined scanning method may include at least one of diagonal scanning, horizontal scanning, vertical scanning, or raster scanning.

[0155] When a 64×1 sized input matrix is generated through rearrangement, the second transform coefficients may be obtained through matrix product between a 64×64 sized second transform kernel and the 64×1 sized input matrix.

[0156] As a result of performing the second transform, 64 second transform coefficients may be generated and the second transform coefficients in the 8x8 block may be rearranged.After quantizing the 8x8 block in which the second transform coefficients are rearranged, the quantized transform block may be encoded.

[0157] Figure 8 This example shows a second transform kernel having a size of 48×48. Of the first transform coefficients generated by the first transform in an 8×8 block, the 48 first transform coefficients can be rearranged in one dimension. In this case, the 48 first transform coefficients can be included in a polygonal area excluding the lower right sub-block of the 4×4 size in the 8×8 block.

[0158] When a 48×1 input matrix is generated by rearranging 48 first transform coefficients in one dimension, second transform coefficients may be obtained through matrix product between a 48×48 second transform kernel and the 48×1 input matrix.

[0159] As a result of performing the second transform, 48 second transform coefficients may be generated and the second transform coefficients in the 8×8 block may be rearranged. In an example, the 48 second transform coefficients may be rearranged in a polygonal region excluding a lower right sub-block of 4×4 size in the 8×8 block.

[0160] In the region not used for arranging the second transform coefficient, the first transform coefficient may remain as it is.After quantization is applied to the block including the second transform coefficient and the first transform coefficient, the quantized transform block may be encoded.

[0161] Alternatively, the transform coefficients in the region where the second transform coefficients are not arranged may be set to 0. In other words, quantization and encoding may be performed after setting the values of the transform coefficients in the region where the second transform is not applied to 0.

[0162] The size of the second transform kernel may be determined based on the size of the current block. In an example, when at least one of the width or height of the current block is 4, the second transform may be applied to 16 first transform coefficients. On the other hand, when the width and height of the current block are equal to or greater than 8, the second transform may be applied to 48 or 64 first transform coefficients.

[0163] Alternatively, information indicating the size and type of the second transform kernel may be encoded and signaled. An index may be signaled at the block level. In an example, information specifying at least one of the number of columns or the number of rows of the transform size may be encoded. Alternatively, after assigning a different index to each combination of the number of rows and the number of columns, an index specifying one of the combinations may be encoded. Alternatively, after assigning a different index to each of a plurality of second transform kernel candidates, an index specifying one of the second transform kernel candidates may be encoded. Here, at least one of the size or the coefficient may be different for each of the plurality of second transform kernel candidates.

[0164] Alternatively, after determining the size of the second transform kernel based on the size of the current block, an index specifying one of a plurality of second transform kernel candidates having the determined size may be encoded.

[0165] Figure 7 and Figure 8 The example shown in shows a second transform kernel using the same number of rows and columns. In order to simplify the second transform, the number of rows and columns can be set differently.

[0166] Figure 9 and Figure 10 A second transformation based on a second transformation kernel having an asymmetric shape is shown.

[0167] The number of rows R of the second transform kernel may be set to a value smaller than the number of columns N. For example, the number of rows R may be set to 8, and the number of columns N may be set to 48.

[0168] When the number of rows of the second transform kernel decreases, the number of second transform coefficients output as a result of the second transform also decreases. For example, when a matrix product is performed between an 8×48 sized second transform kernel and a 48×1 sized input matrix, an 8×1 sized second transform coefficient is generated.

[0169] The eight second transform coefficients may be rearranged in an 8×8 block. In this case, the values of the transform coefficients in the region to which the second transform is applied (i.e., the region including the first transform coefficients to which the second transform is applied) to which the second transform coefficients are not allocated may be set to 0. For example, when a polygonal region including 48 samples is the region to which the second transform is applied, the values of the transform coefficients in the remaining regions of the polygonal region excluding the region to which the eight second transform coefficients are allocated may be set to 0.

[0170] In regions where the second transform is not applied, the first transform coefficients may remain as they are.

[0171] Alternatively, at least a portion of the first transform coefficients in a region to which the second transform is not applied may be converted to 0 and encoded. Figure 10 , an example of converting at least a portion of a region to which the second transform is not applied to 0 is shown.

[0172] like Figure 10 In the example shown in (a), in the area where the second transform is not performed, the value of the first transform coefficient corresponding to the high frequency domain can be converted to 0. In this example, the value of the first transform coefficient whose sum of the x-axis and y-axis coordinates is equal to or greater than the threshold value can be converted to 0.

[0173] Alternatively, depending on the shape, the first transform coefficient converted to 0 may be selected. In the example, Figure 10 In the example shown in (b) of FIG, the first transform coefficients included in the n bottom rows in the region where the second transform is not performed may be converted to 0. Alternatively, as Figure 10 In the example shown in (c) of FIG. 1 , the first transform coefficients included in the n right columns in the region where the second transform is not performed may be converted to 0.

[0174] Alternatively, if Figure 10 In the example shown in (d), all first transform coefficients in the region where the second transform is not performed may be converted to 0.

[0175] The shape of the region including the first transform coefficient converted to 0 may be determined based on at least one of the size or shape of the current block, the intra prediction mode, or the transform kernel. Alternatively, an index specifying one candidate shape corresponding to the region from among a plurality of candidate shapes may be encoded and signaled.

[0176] Whether the second transform is allowed may be determined based on at least one of a coding mode of the current block or a first transform kernel. Here, the coding mode indicates intra-frame prediction or inter-frame prediction. In this example, although the second transform is allowed when the current block is encoded using intra-frame prediction, the second transform may not be allowed when the current block is encoded using inter-frame prediction.

[0177] Information indicating whether the second transform has been applied can be encoded and signaled. This information can be a 1-bit flag. Whether the flag is true or false can be used to determine whether the second transform has been applied to the current block. Alternatively, this information can be index information. When the value of the index is 0, this indicates that the second transform has not been applied to the current block. On the other hand, when the value of the index is greater than 0, this indicates that the second transform has been applied to the current block. When the value of the index is greater than 0, the second transform kernel can be specified by the index.

[0178] The information indicating whether the second transform is performed on the current block can be encoded separately by color component. In an example, for each of the luminance component (Y), the first chrominance component (Cb), and the second chrominance component (Cr), the information indicating whether the second transform is performed can be encoded.

[0179] Alternatively, for the chroma components, information indicating whether the second transform has been performed can be jointly encoded. In this example, for each chroma component (Cb, Cr), whether the second transform is applied can be jointly determined. In other words, the first chroma component (Cb) and the second chroma component (Cr) can share information indicating whether the second transform has been performed.

[0180] Alternatively, whether information is encoded per color component may be determined based on the tree structure. In this example, when the luma component and the chroma components have the same tree structure, the three color components (i.e., Y, Cb, Cr) may share information indicating whether the second transform is performed. On the other hand, when the luma component and the chroma components have different tree structures, information indicating whether the second transform is performed may be signaled for each of the luma component and the chroma component.

[0181] The plurality of second transform kernel candidates may be grouped into at least a plurality of groups. One of the plurality of groups may be specified based on at least one of the size or shape of the current block or the intra-prediction mode thereof. When specifying a group, at least one of the plurality of second transform kernel candidates included in the specified group may be specified using index information.

[0182] Whether to encode information indicating whether to apply the second transform may be determined based on the position of the last non-zero coefficient in the current block.

[0183] Figure 11 This shows an example of determining whether to encode information indicating whether to apply the second transform based on the position of the last non-zero coefficient.

[0184] For convenience of description, it is assumed that when the second transform is performed, the values of the transform coefficients are set to 0 in the remaining regions excluding the region where the second transform coefficients are rearranged.

[0185] As a result of performing the second transform, as many second transform coefficients as the number of rows R of the second transform kernel are generated. As in the above example, since all values of the remaining transform coefficients excluding the second transform coefficients are set to 0, there are no non-zero coefficients in the remaining region excluding the region where the R second transform coefficients are rearranged. Based on this principle, the region where the R second transform coefficients are rearranged can be set to a limited region.

[0186] exist Figure 11 In (a) to (c), it is shown that the upper left block of 4×4 size in the 8×8 size block is set as the limited area.

[0187] When a non-zero coefficient exists outside the limited region, this indicates that the second transform is not applied to the current block. Therefore, when the last non-zero coefficient exists outside the limited region, encoding of information indicating whether the second transform is applied to the current block can be omitted. In the example, Figure 11 In the example shown in (a) of FIG. , when the last non-zero coefficient exists outside the limited region, encoding of the information indicating whether the second transform is applied can be omitted.

[0188] When the last non-zero coefficient exists outside the limited area, the decoder may determine that the second inverse transform is not applied to the current block without decoding the information.

[0189] like Figure 11 In the example shown in (b) of FIG, when the second transform is applied to the current block, the non-zero transform coefficients may exist only in a limited area. Figure 11 In the example shown in (c) of FIG, although the second transform is not applied to the current block, a non-zero transform coefficient may exist only in a limited area. Therefore, when the last non-zero coefficient exists in a limited area, information indicating whether the second transform is applied can be encoded.

[0190] The decoder may determine whether to apply a second inverse transform to the current block based on this information.

[0191] Alternatively, when the last non-zero coefficient exists within a limited region, encoding of the information may be omitted and the second transform may be applied by default.

[0192] The size of the limited area can be determined based on the size of the second transform kernel. In an example, when the second transform kernel is a matrix of size R×N, a rectangular area with a width and height of Log2R can be set as the limited area.

[0193] Alternatively, the area to which the second transform is applied may be set to a limited area.

[0194] Alternatively, information indicating at least one of the size or shape of the limited area may be encoded and signaled. This information may be signaled at a higher level such as a sequence, picture header, or slice header.

[0195] Alternatively, at least one of the size or shape of the limited region may be predefined in the encoder and decoder. In an example, between the encoder and decoder, it may be pre-agreed that the upper left block of 4×4 size in the current block is set as the limited region.

[0196] Alternatively, at least one of the size or shape of the limited area may be adaptively determined based on at least one of the size or shape of the current block, the first transform kernel, or the intra prediction mode.

[0197] Alternatively, after defining a plurality of limited area candidates, an index specifying one of the plurality of limited area candidates may be encoded and signaled.

[0198] Figure 12 Limited region candidates for a 4x4 sized block are shown.

[0199] When the current block has a size of 4×4, you can specify Figure 12 The index information of one of the plurality of limited region candidates is encoded.

[0200] You can Figure 12 At least one of the limited area candidates shown in is applied to a block having a size greater than 4×4 as well as a block of 4×4 size. In the example, it is also possible to Figure 12 At least one of the shown limited area candidates applies to a block having at least one of a width or a height of 4 and the other being greater than 4.

[0201] Alternatively, the size or number of limited region candidates may be set differently according to the size of the current block.

[0202] Instead of encoding an index specifying one of the limited area candidates, one of the limited area candidates may be specified based on the size or shape of the current block.

[0203] In the above examples, it is described that the size of the second transform kernel can be adaptively selected. In other examples, a second transform kernel of a predefined size can be applied to all blocks. In this example, a second transform kernel of 16×48 size can be used for all blocks. In this case, the second transform can be applied to the 48 first transform coefficients.

[0204] Figure 13 is a diagram showing an example of applying a second transform kernel of a predetermined size.

[0205] When using the second transform kernel of size 16×48, such as Figure 13 In the example shown in (a), the second transform can be applied to the area of the 8×8 block excluding the lower right sub-block of 4×4 size. In the example, the second transform can be applied to the area included in Figure 13 The first transform coefficient in the polygonal area shown in (a).

[0206] In this case, when at least one of the width or the height of the current block is less than 8, the second transform may not be applied to the current block.

[0207] Alternatively, when at least one of the width or the height of the current block is less than 8, the second transform may be performed after transforming the region to which the second transform is applied into a rectangular shape such as 4×12 or 12×4.

[0208] Alternatively, when at least one of the width or height of the current block is less than 8, after matching the upper left position of the current block with the upper left area of the area to which the second transform is applied, the second transform may be applied only to the overlapping area between the current block and the area to which the second transform is applied.

[0209] Figure 13 (b) shows an example in which the second transformation is performed only on the overlapping area.

[0210] After the first transform coefficients included in the overlapping region are arranged in one dimension, the first transform coefficients may be set as an input matrix for the second transform.

[0211] When the first transform and the second transform are applied to the current block, the decoder may obtain residual samples by performing the inverse transform (first inverse transform) of the first transform on a result of performing the second inverse transform after performing the inverse transform (second inverse transform).

[0212] The second inverse transform may be performed based on the transposed matrix of the second transform kernel. In an example, when the second transform kernel has a size of 8×48, the second inverse transform may be performed by a transform kernel of a size of 48×8.

[0213] The second transform coefficients generated by the second transform can be set as the input matrix of the second inverse transform. In an example, when the second transform is performed by a second transform kernel of 8×48 size, an input matrix of 8×1 size consisting of 8 coefficients can be used when performing the second inverse transform. Subsequently, the transform coefficients subjected to the second inverse transform can be output by matrix product between the input matrix and the transposed matrix of the second transform kernel. In an example, 48 transform coefficients can be output by matrix product between a transform kernel of 48×8 size and an input matrix of 8×1 size.

[0214] After rearranging transform coefficients in the current block, a first inverse transform may be applied to the rearranged block.

[0215] After quantizing the transform coefficients generated by transforming the residual samples, the quantized transform coefficients may be encoded. Alternatively, quantization may be omitted and the transform coefficients may be encoded.

[0216] When transform is not applied to the current block, the residual samples may be quantized and the quantized residual samples may be encoded.

[0217] When skipping transform, quantization information may be additionally encoded per block. In an example, quantization information for transform skipping may be additionally signaled by applying DPCM (Differential Pulse Code Modulation) to quantization information transmitted through a sequence, a picture header, or a slice header.

[0218] After quantization is performed, run-length encoding can be applied. In other words, the quantized coefficients generated by the quantization result can be encoded using the run-length method. Here, a run refers to the continuity of the same data, and a run length refers to the length of the continuous data. In the example, when there is a string of aaaaaabbccccccc, a appears 6 times in a row, b appears 2 times in a row, and c appears 7 times in a row, so it can be expressed as 6a2b7c or a6b2c7 and encoded.

[0219] The encoding method may be defined as a run-length encoding method.

[0220] For efficient run-length encoding, the best scanning method can be determined.

[0221] Figure 14 The scanning method is shown.

[0222] according to Figure 14 The scanning method shown in , scans the coefficients according to a specific direction. Figure 14 In the scanning method shown, when the same value is arranged continuously, it can be determined as the optimal scanning method.

[0223] When transform skip is applied to a current block, information specifying a scanning method for the current block may be encoded and signaled. The information may be an index specifying one of a plurality of scanning methods.

[0224] The number or type of available scanning method candidates may be set differently based on at least one of the size, shape, or intra prediction mode of the current block. In an example, when the intra prediction mode of the current block is in the horizontal direction or in the vertical direction, only Figure 4 On the other hand, when the intra prediction mode of the current block is in a diagonal direction (eg, 2, 34, or 66), the two scanning methods shown in FIG. Figure 14 All four scanning methods shown are set as candidates. Therefore, the bit length assigned to the index used to specify the scanning method may be different depending on the intra prediction mode of the current block. In this example, when the intra prediction mode of the current block is in the horizontal direction or in the vertical direction, the index may have a length of 1 bit. On the other hand, when the intra prediction mode of the current block is in the diagonal direction, the index may have a length of 2 bits.

[0225] Alternatively, the scanning method may be determined based on at least one of the size, shape, or intra prediction mode of the current block. In an example, when the intra prediction mode is in the horizontal direction, the scanning method may be applied. Figure 14 The horizontal directional scanning method or the vertical directional scanning method shown in (a).

[0226] Instead of encoding the quantized coefficients using the run-length method, an encoding method that applies additional prediction to the quantized coefficients may be applied. In an example, when a residual block is generated by intra-frame prediction in a current block, quantization may be performed by skipping transform on the residual block. When the quantized coefficients are output, DPCM may be applied to the output values.

[0227] One of a plurality of direction candidates may be used for DPCM. In an example, horizontal direction DPCM or vertical direction DPCM may be applied to the quantized coefficients.

[0228] The encoder may encode and signal information for specifying a DPCM direction applied to the quantized residual coefficient. Alternatively, the prediction direction for generating the prediction block may be set to a DPCM direction.

[0229] The DPCM direction can be used when predicting the intra-frame prediction mode. In an example, when horizontal DPCM is applied to a neighboring block when deriving an MPM candidate for the current block, the MPM can be derived by considering the intra-frame prediction mode of the neighboring block as horizontal. Alternatively, when vertical DPCM is applied to a neighboring block when deriving an MPM candidate for the current block, the MPM can be derived by considering the intra-frame prediction mode of the neighboring block as vertical. Alternatively, when diagonal DPCM is applied to a neighboring block, the MPM can be derived by considering the intra-frame prediction mode of the neighboring block as diagonal (e.g., 2, 34, or 66) or non-directional (e.g., planar or DC).

[0230] In this case, the MPM derived directly from the DPCM direction may have the highest or lowest priority among the MPM candidates. Here, the highest priority may mean that the lowest index among the MPM candidates is assigned (i.e., set as the first MPM), and the lowest priority may mean that the highest index among the MPM candidates is assigned (i.e., set as the last MPM).

[0231] For ease of description, residual signal related data encoded in the encoder is referred to as residual coefficients. For example, depending on whether transformation or quantization is applied, the residual coefficients may mean at least one of quantized transform coefficients, transform coefficients, or quantized residual samples.

[0232] A flag indicating whether there is a non-zero residual coefficient in the current block may be encoded and signaled. When there is a non-zero residual coefficient in the current block, the position of the last non-zero residual coefficient in the scanning order may be encoded.

[0233] In addition, a subblock flag indicating whether a non-zero residual coefficient exists in a subblock may be encoded in units of subblocks in the current block. When a non-zero residual coefficient exists in a subblock, information about each residual coefficient may be additionally encoded in a scanning order.

[0234] In this case, for the sub-blocks scanned before the sub-block including the last non-zero residual coefficient, the encoding of the sub-block flag can be omitted. Since no non-zero residual coefficient is included in the sub-block, the value of the sub-block flag can be inferred to be 0.

[0235] In addition, for a sub-block including the last non-zero residual coefficient, the encoding of the sub-block flag can be omitted. Since a sub-block necessarily includes a non-zero residual coefficient, the value of the sub-block flag can be inferred to be 1.

[0236] In another example, encoding of the position information of the last non-zero residual coefficient may be omitted. When encoding of the position information of the last non-zero residual coefficient is omitted, subblock flags may be encoded for all subblocks in the current block.

[0237] In this case, when it is determined that the remaining sub-blocks excluding the sub-block with the last scanning order do not include a non-zero residual coefficient, it can be understood that a non-zero residual coefficient should be included in the last sub-block. Therefore, for the last sub-block, encoding of the sub-block flag can be omitted, and the value can be inferred to be 1.

[0238] Information indicating whether the position information of the last non-zero coefficient is encoded may be additionally encoded. When the position information of the last non-zero coefficient is encoded, the value of this information may be set to 1. In this case, the subblock flag may be encoded from the subblock in which the last non-zero coefficient exists. On the other hand, when the position information of the last non-zero coefficient is not encoded, the value of this information may be set to 0. In this case, the subblock flag may be encoded from the subblock that is scanned first.

[0239] When there is a non-zero residual coefficient in the current block, it can be assumed that the first sub-block in the current block must include a non-zero residual coefficient. Therefore, for the first sub-block, encoding of a sub-block flag indicating whether there is a non-zero residual coefficient can be omitted.

[0240] The information about each residual coefficient may include at least one of a flag indicating whether the residual coefficient has a non-zero value, information indicating a size of the residual coefficient, and information indicating a sign of the residual coefficient.

[0241] The residual coefficients may be encoded in a predetermined scanning order. In this case, the encoding order of the residual coefficients may be different based on whether the transform is skipped in the current block. In the example, when the transform is not skipped in the current block, the residual coefficient at the lower right position in the sub-block may be encoded first, and the residual coefficient at the upper left position may be encoded last. In other words, the scanning order between the residual coefficients may be determined according to inverse diagonal scanning, inverse horizontal scanning, or inverse vertical scanning. On the other hand, when the transform is skipped in the current block, the residual coefficient at the upper left position in the sub-block may be encoded first, and the residual coefficient at the lower right position may be encoded last. In other words, the scanning order between the residual coefficients may be determined according to diagonal scanning, horizontal scanning, or vertical scanning.

[0242] Alternatively, when transformation is skipped in the current block, the scanning order between residual coefficients may be determined according to inverse diagonal scanning, inverse horizontal scanning, or inverse vertical scanning.

[0243] The scanning order of the residual coefficients may be predefined in the encoder and decoder. Alternatively, information indicating the scanning order of the residual coefficients may be encoded and signaled. Alternatively, the scanning order may be determined based on at least one of the following: the size or shape of the current block, the intra prediction mode, whether to skip a transform, or whether to perform a second transform.

[0244] Figure 15 Flowchart showing the process of encoding residual coefficients in an encoder.

[0245] First, a flag significant_flag indicating whether the residual coefficient has a non-zero value may be encoded ( S1510 ). When the value of the residual coefficient is 0, the value of the flag sig_flag may be set to 0 and encoded. On the other hand, when the value of the residual coefficient is not 0, the value of the flag sig_flag may be set to 1 and encoded. When the value of the residual coefficient is not 0, information on the magnitude of the residual coefficient may also be encoded ( S1520 ).

[0246] Figure 16 This is a flowchart showing the process of encoding the magnitude information of the residual coefficient.

[0247] The absolute value of the residual coefficient can be encoded by using at least one or more gt_N_flags. In this case, N can be a natural number equal to or greater than 1. The flag gt_N_flag can indicate whether the absolute value of the residual coefficient has a value greater than 2(N-1). The number of gt_N_flags used to encode the absolute value of the residual coefficient can be determined based on whether the transform is skipped in the current block. In an example, when the transform is not skipped in the current block, two gt_N_flags (N is from 1 to 2) can be used. On the other hand, when the transform is skipped in the current block, three or more gt_N_flags (for example, 3, 4, or 5) can be used. In this embodiment, it is assumed that two gt_N_flags are used.

[0248] A flag gt1_flag indicating whether the absolute value of the residual coefficient is greater than 1 may be encoded S1610. When the absolute value of the residual coefficient is 1, the value of the flag gt1_flag may be encoded with 0. On the other hand, when the absolute value of the residual coefficient is greater than 1, the value of the flag gt1_flag may be encoded with 1.

[0249] When the absolute value of the residual coefficient is greater than 1, a flag par_flag indicating whether the absolute value of the residual coefficient is even or odd may be encoded (S1620). When the absolute value of the residual coefficient is even, the flag par_flag may be set to 0 and encoded. On the other hand, when the absolute value of the residual coefficient is odd, the flag par_flag may be set to 1 and encoded. Alternatively, conversely, when the absolute value of the residual coefficient is even, the flag par_flag may be set to 1, and when the absolute value of the residual coefficient is odd, the flag par_flag may be set to 0.

[0250] Next, a flag gt_2_flag indicating whether the absolute value of the residual coefficient is greater than 3 may be encoded S1630. When the absolute value of the residual coefficient is equal to or less than 3, the value of the flag gt_2_flag may be set to 0. On the other hand, when the absolute value of the residual coefficient is greater than 0, the value of the flag gt_2_flag may be set to 1.

[0251] When the absolute value of the residual coefficient is greater than 3, rem_level indicating the residual size may be encoded S 1640. The syntax rem_level may be obtained by right-shifting a value obtained by subtracting 4 from the absolute value of the residual coefficient by 1.

[0252] Apart from Figure 16 In addition to the flags gt_1_flag and gt_2_flag shown, gt_N_flag such as gt_3_flag, gt_4_flag, or gt_5_flag may be additionally encoded. In this case, when the value of gt_(N-1)_flag is 1, gt_N_flag may be additionally encoded.

[0253] gt_N_flag may indicate whether the absolute value of the residual coefficient has a value greater than (2N-1). When gt_N_flag is additionally used, rem_level may be obtained by right-shifting a value obtained by subtracting 2N from the absolute value of the residual coefficient by 1.

[0254] In the above example, the absolute value of the residual coefficient is encoded by using sig_flag, gt_1_flag, par_flag, gt_2_flag, and rem_level. In another example, the absolute value of the residual coefficient can be encoded as it is. In this example, the syntax abs_level representing the absolute value of the residual coefficient can be encoded. The following describes a method for selecting a method for encoding the absolute value of the residual coefficient.

[0255] After encoding the magnitude information of the residual coefficient, a flag sign_flag indicating the sign of the residual coefficient may be encoded ( S1030 ). When the value of the flag sign_flag is 0, it indicates that the residual coefficient is a positive number. On the other hand, when the value of the flag sign_flag is 1, it indicates that the residual coefficient is a negative number.

[0256] Table 1 shows the value assigned to each syntax when the value of the residual coefficient is -21 and 2 gt_N_flags are used.

[0257] [Table 1]

[0258] Division formula value Residual coefficient (Coeff) coeff -21 sig_flag coeff! = 0 1 gt_1_flag ! ! (|coeff|-1) 1 par_flag (|coeff|-2)&1 1 gt_2_flag (|coeff|-2)>>1 1 rem_level (|coeff|-4)>>1 8 sign_flag 1

[0259] In Table 1, coeff represents the value of the residual coefficient, and "formula" represents the formula for deriving the value of each syntax.

[0260] Table 2 shows the value assigned to each syntax when the value of the residual coefficient is -21 and 5 gt_N_flags are used.

[0261] [Table 2]

[0262] Division formula value Residual coefficient (Coeff) coeff -21 sig_flag coeff! = 0 1 gt_1_flag ! ! (|coeff|-1) 1 par_flag (|coeff|-2)&1 1 gt_2_flag |coeff|>=4 1 gt_3_flag |coeff|>=6 1 gt_4_flag |coeff|>=8 1 gt_5_flag |coeff|>=10 1 rem_level (|coeff|-10)>>1 5 sign_flag 1

[0263] Figure 17 Flowchart showing the process of decoding residual coefficients in a decoder.

[0264] When it is determined that a non-zero residual coefficient is included in the subblock, the residual coefficient may be reconstructed based on a predetermined scanning order.

[0265] First, a flag sig_flag indicating whether the residual coefficient has a non-zero value may be decoded (step S1710). When the value of the flag sig_flag is 0, it indicates that the value of the residual coefficient is 0. On the other hand, when the value of the flag sig_flag is 1, it indicates that the value of the residual coefficient is not 0. When the value of the flag sig_flag is 1, size information of the residual coefficient may also be decoded (step S1720).

[0266] Figure 18 This is a diagram showing a process of decoding the magnitude information of the residual coefficient.

[0267] For convenience of description, it is assumed that the residual coefficient is encoded by using up to 2 gt_N_flags.

[0268] The flag gt1_flag indicating whether the absolute value of the residual coefficient is greater than 1 may be decoded S1810. When the value of the flag gt_1_flag is 0, it indicates that the absolute value of the residual coefficient is 1. On the other hand, when the value of the flag gt_1_flag is 1, it indicates that the absolute value of the residual coefficient is greater than 1.

[0269] When the value of the flag gt_1_flag is 1, the flag par_flag indicating whether the absolute value of the residual coefficient is even or odd may be decoded S1820. When the value of the flag par_flag is 0, it indicates that the absolute value of the residual coefficient is even, and when the value of the flag par_flag is 1, it indicates that the absolute value of the residual coefficient is odd.

[0270] Next, the flag gt_2_flag indicating whether the absolute value of the residual coefficient is greater than 3 may be decoded S1830. When the value of the flag gt_2_flag is 0, it indicates that the absolute value of the residual coefficient is less than 3. When the value of the flag gt_2_flag is 0, the absolute value of the residual coefficient may be determined to be 2 or 3 according to the value of the flag par_flag.

[0271] When the value of the flag gt_2_flag is 1, it indicates that the absolute value of the residual coefficient is greater than 3.

[0272] When the value of the flag gt_2_flag is 1, rem_level indicating the size of the residual may be decoded S1840. The absolute value of the residual coefficient may be obtained by adding 3 or 4 to a value obtained by shifting the value indicating the syntax rem_level left by 1.

[0273] Apart from Figure 18 In addition to the flags gt_1_flag and gt_2_flag shown, gt_N_flag such as gt_3_flag, gt_4_flag, or gt_5_flag can be additionally decoded. In this case, when the value of gt_(N-1)_flag is 1, gt_N_flag can be additionally decoded.

[0274] gt_N_flag may indicate whether the absolute value of the residual coefficient has a value greater than (2N-1). When gt_N_flag is additionally used, rem_level may be set to a value obtained by right-shifting by 1 a value obtained by subtracting 2N from the absolute value of the residual coefficient.

[0275] In the above example, the absolute value of the residual coefficient is decoded by using sig_flag, gt_1_flag, par_flag, gt_2_flag, and rem_level. In another example, the absolute value of the residual coefficient can be decoded as it is. In this example, the syntax abs_level representing the absolute value of the residual coefficient can be decoded. The following describes a method for selecting a method for decoding the absolute value of the residual coefficient.

[0276] After decoding the magnitude information of the residual coefficient, the flag sign_flag indicating the sign of the residual coefficient may be decoded S1230. When the value of the flag sign_flag is 0, it indicates that the residual coefficient is a positive number. On the other hand, when the value of the flag sign_flag is 1, it indicates that the residual coefficient is a negative number.

[0277] Table 3 shows an example of decoding a residual coefficient whose value is -21 by using 2 gt_N_flags.

[0278] [Table 3]

[0279] Division value formula sig_flag 1 - gt_1_flag 1 - par_flag 1 - gt_2_flag 1 - tmp_coeff 5 1+gt_1_flag+par_flag+(gt_2_flag<<1) rem_level 8 sign_flag 1 sign=(sign_flag==1?-1:1) Residual coefficient (coeff) -21 tmp_coeff+(rem_level<<1)*sign

[0280] In Table 3, the variable tmp_coeff represents a temporary reconstruction coefficient. When the value of gt_2_flag is 0, the temporary reconstruction coefficient tmp_coeff can be set to the absolute value of the residual coefficient. On the other hand, when the value of gt_2_flag is 1, the absolute value of the residual coefficient can be obtained by updating the temporary reconstruction coefficient tmp_coeff based on the syntax rem_level.

[0281] Table 4 shows an example of decoding a residual coefficient whose value is -21 by using 5 gt_N_flags.

[0282] [Table 4]

[0283]

[0284]

[0285] In Table 3, the variable tmp_coeff represents a temporary reconstruction coefficient. When gt_N_flag is 0, the temporary reconstruction coefficient tmp_coeff can be set to the absolute value of the residual coefficient. On the other hand, when gt_N_flag is 1, the temporary reconstruction coefficient can be updated (e.g., tmp_coeff += sig_N_flag << 1), and the next syntax can be parsed.

[0286] As described, the residual coefficients may be encoded by at least one syntax. The residual coefficients may be changed into a plurality of binary bits during binarization of the syntax(ies), and the changed binary bits may be encoded by entropy coding.

[0287] Entropy coding can be divided into coding using context information and coding without context information. Context represents the probability of a binary bit being 0 or 1.

[0288] A threshold may be set to limit the number of bins encoded using context information. For bins among the generated bins whose count value is less than the threshold, encoding using context information is performed. When the count value is equal to or greater than the threshold, encoding using context information may no longer be performed.

[0289] The threshold value may be determined based on the number of non-zero residual coefficients in the current block. In an example, the number of non-zero residual coefficients in the current block multiplied by a real number or a value plus or minus an offset may be set as the threshold value.

[0290] Alternatively, the threshold value may be determined based on the number of pixels included in the current block. In an example, the number of pixels in the current block multiplied by a real number or a value plus or minus an offset may be set as the threshold value.

[0291] Alternatively, information representing the threshold value can be signaled in the bitstream. This information can be encoded by a higher header such as a sequence, picture header, or slice header.

[0292] Alternatively, the threshold may be determined based on at least one of the size or shape of the current block.

[0293] Alternatively, the threshold may be determined based on at least one of: whether transform skipping is applied, a transform kernel applied to the current block, or a quantization parameter.

[0294] When counting the number of binary bits encoded using context information, the counter may be set to not operate when encoding information indicating the position of the last non-zero residual coefficient. In other words, this information may be excluded from the count.

[0295] Alternatively, when encoding a flag indicating whether each subblock in the current block has a non-zero residual coefficient, the counter may be set to not operate. In other words, the flag may be excluded from the count.

[0296] According to an embodiment of the present disclosure, in order to limit the number of bins encoded using context information, when the number of bins encoded using context information is equal to or greater than a threshold, the absolute value of the residual coefficient may be encoded as is, rather than sequentially encoding the residual coefficient using such a gt_N_flag or the like. In an example, when the number of bins encoded using context information is less than the threshold, the absolute value of the residual coefficient may be encoded using at least one of sig_flag, sign_flag, gt_1_flag, par_flag, gt_2_flag, gt_3_flag, gt_4_flag, gt_5_flag, or rem_level shown in Tables 1 to 4. On the other hand, when the number of bins encoded using context information is equal to or greater than the threshold, the syntax abs_level indicating the absolute value of the residual coefficient may be encoded.

[0297] Whenever a binary bit encoded using context information is decoded, the decoder may also operate a counter. When the value of the counter is less than a threshold, the absolute value of the residual coefficient may be reconstructed using at least one of sig_flag, sign_flag, gt_1_flag, par_flag, gt_2_flag, gt_3_flag, gt_4_flag, gt_5_flag, or rem_level. On the other hand, when the value of the counter is equal to or greater than the threshold, the absolute value of the residual coefficient may be reconstructed using the syntax abs_level.

[0298] Figure 19 is a diagram showing an example of counting the number of binary bits of usage context information.

[0299] For ease of description, it is assumed that there are 16 residual coefficients in the subblock, and each of the coefficients is assumed to be C0 to C15. Here, C15 means the residual coefficient at the lower right position in the subblock, and C0 means the residual coefficient at the upper left position in the subblock.

[0300] In addition, the residual coefficient is generated by transformation, and therefore, it is assumed that the scanning order is determined in the order of C15 to C0.

[0301] In addition, it is assumed that the maximum number of bins encoded by using context information is 36, and it is assumed that a flag indicating whether a non-zero residual coefficient exists in a subblock and information indicating the position of the last non-zero residual coefficient are excluded from the count.

[0302] exist Figure 19In

[15] , 1 pass represents a syntax encoded by using context information. 2-1 pass, 2-2 pass, and 3 pass except 1 pass represent syntax encoded without using context information.

[0303] A pass represents the order of encoding and decoding. In this example, in the decoder, the syntax belonging to pass 2-1 can be decoded after all the syntax belonging to pass 1 is decoded. Alternatively, the syntax belonging to pass 3 can be decoded after all the syntax belonging to pass 2-1 is decoded.

[0304] In the example shown, 2-2 rounds represents alternating paths of 1 round, 2-1 round, and 3 rounds.

[0305] When the coefficient of the binary bit encoded by using the context information is less than the threshold, the absolute value of the residual coefficient can be encoded by 1 round and 2-1 round. On the other hand, when the coefficient of the binary bit encoded by using the context information is equal to or greater than the threshold, the absolute value of the residual coefficient can be encoded by 2-2 round.

[0306] In the example shown in Table 2, when the first residual coefficient C15 is -21, the flags sig_flag, gt_1_flag, par_flag, gt_2_flag, and rem_level may be encoded. When the syntax (i.e., sig_flag, gt_1_flag, par_flag, gt_2_flag) encoded using context information is encoded using a total of 4 bits when encoding the first residual coefficient C15, the counter is incremented to 4.

[0307] Since the counter value is less than the threshold value 36 after encoding the first residual coefficient C15, the syntax encoded by using the context information can also be used for the second residual coefficient C14. When it is assumed that four syntaxes encoded by using the context information are used for each of C15 to C7, after encoding the absolute value of the residual coefficient C7, the counter value is set to be equal to the threshold value 36.

[0308] Therefore, when encoding the next residual coefficient C6, the absolute value of the residual coefficient C6 can be encoded as it is by using the syntax abs_level without using the syntax encoded by using the context information. In other words, for the residual coefficients C6 to C0, the absolute value of the residual coefficient can be encoded by using the syntax abs_level belonging to the 2-2 round instead of the four syntaxes belonging to the 1 round (i.e., sig_flag, gt_1_flag, par_flag, gt_2_flag) and the syntax rem_level belonging to the 2-1 round.

[0309] In this case, even if the number of bins encoded using context information is less than the threshold, when the difference between the number and the threshold is less than the maximum number of syntax encoded using context information, abs_level can be set to not be encoded using context information. For example, when sig_flag, gt_1_flag, par_flag, and gt_2_flag are set to be encoded using context information, syntax can be encoded only when the difference between the number and the threshold is greater than 4. On the other hand, when the difference is less than 4, abs_level can be encoded.

[0310] In the example shown, only four syntax elements belonging to round 1 are encoded using context information. Unlike the example, at least one of rem_level (syntax elements belonging to round 2-1) or sign_flag (syntax elements belonging to round 3) may be encoded using context information. In the example, when rem_level is encoded using context information, a counter may be incremented by as many bits as the number of bits allocated to the syntax element rem_level.

[0311] exist Figure 19 In the example shown, the flag par_flag may be set to not be encoded by using context information. Figure 20 Indicates an example thereof.

[0312] exist Figure 20 In the example, 1 round represents the syntax encoded by using context information. 2 rounds, 3-1 rounds, 3-2 rounds, and 4 rounds other than 1 round represent the syntax encoded without using context information. When the coefficient of the binary bit encoded by using context information is less than a threshold value, the absolute value of the residual coefficient can be encoded by 1 round, 2 rounds, and 3-1 rounds. On the other hand, when the coefficient of the binary bit encoded by using context information is equal to or greater than the threshold value, the absolute value of the residual coefficient can be encoded by 3-2 rounds.

[0313] When the flag par_flag is set to be encoded without using context information, the counter may be set not to increase for the number of binary bits (ie, 1s) allocated to the flag par_flag.

[0314] Therefore, for each residual coefficient, the counter is incremented only for the bins allocated to the three syntax bits sig_flag, gt_1_flag and gt_2_flag.

[0315] When it is assumed that the syntax sig_flag, gt_1_flag, and gt_2_flag are encoded for each of the residual coefficients C15 to C4, after the syntax is encoded for the residual coefficient C4, the counter is set to 36 which is equal to the threshold value.

[0316] Therefore, when encoding the residual coefficient C3, the absolute value of the residual coefficient C3 can be encoded as is using the syntax abs_level included in the 3-2 round. In other words, for the residual coefficients C3 to C0, the absolute value of the residual coefficient can be encoded using the syntax abs_level belonging to the 3-2 round instead of the syntax belonging to the 1 round and the 2-1 round.

[0317] Priority can be set between grammars encoded by using context information. In this case, after counting the number of binary bits allocated to grammars with high priority, the number of binary bits allocated to grammars with low priority can be counted.

[0318] Figure 21 An example showing the difference in priority between grammars encoded using context information.

[0319] Transformation is skipped in the current block, and therefore, it is assumed that the scanning order is determined in the order of C0 to C15.

[0320] exist Figure 21 In the example of , grammars belonging to round 1 and round 2 may be encoded by using context information. In this case, when the grammar belonging to round 1 has a higher priority than the grammar belonging to round 2, when counting the number of bins encoded by using context information, the number of bins allocated to the grammar belonging to round 2 may be counted after counting the number of bins allocated to the grammar belonging to round 1.

[0321] In this example, when it is assumed that 16 residual coefficients are encoded and the threshold is 96, after encoding the syntax belonging to one pass for all 16 residual coefficients, the value of the counter is set to 64. Since the value of the counter is less than the threshold, the syntax belonging to two passes can also be encoded by using context information.

[0322] In the example shown, after the syntax belonging to the 2nd pass is encoded for the residual coefficient C7, the value of the counter is set to 96. Therefore, the syntax belonging to the 2nd pass can be encoded for the next residual coefficient C8 without using context information.

[0323] exist Figure 21 In the example shown, the flag par_flag may be set to not be encoded by using context information. Figure 22Indicates an example thereof.

[0324] exist Figure 22 In

[15] , rounds 1 and 3 represent grammars encoded by using context information. Rounds 2 and 4 represent grammars encoded without using context information.

[0325] The flag par_flag can be encoded without using context information. Therefore, when encoding the flag par_flag, the counter can be set to not increment. After encoding the syntax belonging to the third pass for the residual coefficient C11, the value of the counter is set to 96, which is equal to the threshold value. Therefore, starting from the next residual coefficient C12, context information can be not used when encoding the syntax belonging to the third pass.

[0326] exist Figure 21 and Figure 22 In the example, the gt_N_flag is distributed in different rounds. Figure 21 In the example shown, it is shown that when gt_1_flag belongs to round 1, gt_2_flag belongs to round 2.

[0327] You can also set the distribution of the grammar to be different from Figure 21 and Figure 22 In an example, all gt_N_flags may be assigned to a single round or gt_1_pass and gt_2_pass may be assigned to a single round.

[0328] Instead of setting the flag par_flag to a separate round, par_flag may be set to the same round as gt_1_flag or gt_2_flag, but may be set so that context information is not used when encoding the flag par_flag. Figure 23 Indicates an example. Figure 23 In the illustrated example, it is shown that the flag par_flag is assigned to the same round as gt_2_flag, gt_3_flag, gt_4_flag, and gt_5_flag.

[0329] The flag par_flag can be assigned to rounds lower than gt_N_flag. In the example, Figure 22 In the example shown, 2 rounds including par_flag may be changed to 3 rounds, and the existing 3 rounds may be changed to 2 rounds. In this case, after first encoding the syntax using context information, the syntax not using context information may be encoded.

[0330] It is possible to combine par_flag and rem_level into 3 rounds and encode them.

[0331] As in the above example, the absolute value of the residual coefficient can be encoded by using at least one of sig_flag, par_flag, gt_N_flag, or rem_level. In this case, the residual syntax other than rem_level can be encoded by referring to various context information according to the characteristics of the surrounding coefficients. In the example, the flag sig_flag indicating whether the residual coefficient is 0 can be encoded by referring to various context information according to the characteristics of the surrounding residual coefficients. In this case, the amount of referenceable context information can be determined according to the position of the pixel.

[0332] Figure 24 and Figure 25 represents the surrounding reconstruction region that is referenced to determine contextual information.

[0333] Figure 24 This is an example of a case where the residual coefficients are encoded in a scanning order from the lower right residual coefficient to the upper left residual coefficient. In the example, Figure 24 Can be applied when the transform is not skipped in the current block.

[0334] Figure 25 is an example of a case where residual coefficients are encoded in a scanning order from the upper left residual coefficient to the lower right residual coefficient. In the example, Figure 25 Can be applied to the case where a transform is skipped in the current block.

[0335] Reference Figure 24 and Figure 25 In the example in, up to 2 or up to 5 reconstruction coefficients may be referred to. In the example, when the position of the residual coefficient is (x, y), an area including reconstruction coefficients having an absolute value of the sum of the x-coordinate difference and the y-coordinate difference of the residual coefficients equal to or less than 1 or an area including reconstruction coefficients having an absolute value equal to or less than 2 may be set as the surrounding reconstruction area.

[0336] Alternatively, when there are reconstruction coefficients that have not been reconstructed in scanning order or are outside a block boundary among the reconstruction coefficients in the reconstruction region having the residual coefficients, the unavailable reconstruction coefficients may be excluded from reference.

[0337] Alternatively, for unavailable reconstruction coefficients, context information can be selected by considering the information at the corresponding position as a default value. Figure 25 In the example shown in (a) of , when the reconstruction area is set and the residual coefficient currently to be encoded is included in the leftmost column in the current block, the sig_flag value of the left reconstructed coefficient of the current residual coefficient may be inferred to be 0 or 1.

[0338] Alternatively, when a reconstruction coefficient outside a block boundary is included in a subblock different from the current residual coefficient but included in the same coding block, the corresponding reconstruction coefficient may be set to be available.

[0339] The context information may be determined by referring to more or fewer reconstruction coefficients than in the example shown. Figure 24 Although not shown in FIG, context information may be determined using only the reconstruction coefficients at the right position and the reconstruction coefficients at the lower position of the residual coefficient.

[0340] Alternatively, after assigning an index to each of the multiple reconstruction region candidates, the index specifying one of them can be encoded and transmitted to the decoder. Alternatively, the reconstruction region can be adaptively determined based on the size or shape of the current block. Alternatively, the reconstruction region can be determined based on quantization state information QState. In this example, when the variable QState is 0 or 1, a reconstruction region including up to 2 reconstruction coefficients can be used. Alternatively, when QState is 2 or 3, a reconstruction region including up to 5 reconstruction coefficients can be used.

[0341] Alternatively, it can be set to reference one of N fixed context information instead of setting a surrounding reconstruction area. In this example, N can be 1. Alternatively, the value of N can be determined based on the position of the residual coefficient. In this example, when the sum of x and y is less than a threshold, N can be set to 1, and when the sum of x and y is equal to or greater than the threshold, N can be set to 2. The threshold can be sent to the encoder via the upper header. Alternatively, the threshold can be pre-agreed between the encoder and decoder.

[0342] When sig_flag is encoded / decoded, the values of sig_flag of the reconstructed coefficients included in the reconstructed region around the residual coefficient may be summed.

[0343] Alternatively, the absolute value of the reconstruction coefficient or partial reconstruction coefficient included in the reconstruction area around the residual coefficient may be calculated. Here, the absolute value of the partial reconstruction coefficient may mean a temporary reconstruction coefficient derived based on the syntax included in 1 round, such as (sig_flag+gt_1_flag+par_flag+(gt_2_flag<<1)).

[0344] One of multiple context information can be specified by using the derived value.

[0345] Figure 26 The number of context information that can be referred to when encoding the flag sig_flag is shown.

[0346] Figure 26 (a) is an example of a luminance component, and Figure 26 (b) is an example of chrominance components.

[0347] The current block may be divided into a plurality of regions, and the type of referenceable context information may be set differently for each region. In an example, the type of referenceable context information may be different for each of a first region having a sum of an x-coordinate and a y-coordinate less than 2, a second region having a sum of an x-coordinate and a y-coordinate equal to or greater than 2 and less than 5, and a third region having a sum of an x-coordinate and a y-coordinate equal to or greater than 5.

[0348] In addition, the number of referenceable context information in each region may be different. In an example, the number of referenceable context information in each region may be fixed.

[0349] Alternatively, the amount of referenceable context information in each region may be different. In this example, the amount of referenceable context information may be different in each of a first region where the sum of the x-coordinate and the y-coordinate is less than 2, a second region where the sum of the x-coordinate and the y-coordinate is equal to or greater than 2 and less than 5, and a third region where the sum of the x-coordinate and the y-coordinate is equal to or greater than 5.

[0350] In another example, the type of referenceable context information may be set differently depending on the quantization state information. The variable QState representing the quantization state information may have values 0 to 3. In this example, when the variable QState is 0 or 1, type 1 context information may be referenced, when QState is 2, type 2 context information may be referenced, and when QState is 3, type 3 context information may be referenced.

[0351] exist Figure 26 In the example shown in (a), it is shown that the luminance block is divided into 3 areas, and the number of referenceable context information for each area is 4. When it is assumed that 3 types of context information are available according to the quantization state information, a total of 36 (3×4×3) pieces of context information can be set to be referenced in the luminance block.

[0352] exist Figure 26 In the example shown in (b), the chroma block is divided into 2 regions, and the number of referenceable context information for each region is 4. When it is assumed that 3 types of context information are available according to the quantization state information, a total of 24 (2×4×3) pieces of context information can be set to be referenced in the chroma block.

[0353] The number of referable context information may be set differently according to the size of the reconstruction region (ie, the number of reconstruction coefficients included in the reconstruction region).

[0354] Alternatively, the number of referenceable context information may differ depending on whether transform skipping is applied to the current block. In an example, 3 or 5 context information may be referenced when transform skipping is applied to the current block, while 4 context information may be referenced when transform is applied to the current block.

[0355] When the sum of the values of sig_flag of the surrounding reconstruction coefficients is used, the resulting sum can be compared with a threshold. Here, the threshold can be set to be the same as the number of referenceable context information. Depending on the number of reconstruction coefficients included in the reconstruction area, the sum can be in the range of 0 to 2 or 0 to 5. When the sum is greater than the threshold, the sum can be converted to the threshold. In the example, when the sum is 5 and the threshold is 4, the sum can be changed to 4. Subsequently, one of multiple context information can be specified based on the sum. In other words, the sum can be used as an index to specify one of multiple context information.

[0356] When the sum of the absolute values of the surrounding reconstruction coefficients is used, after calculating the sum of the absolute values of the reconstruction coefficients in the surrounding reconstruction region, the resulting value may be divided by a predetermined value. For example, the predetermined value may be a natural number such as 2, 3, 4, or 5. Alternatively, the sum of the absolute values may be divided by the number of reconstruction coefficients in the surrounding reconstruction region.

[0357] The result value obtained by the division operation can be compared with a threshold value. In this case, when the result value is greater than the threshold value, the obtained value can be converted to the threshold value. In the example, when the threshold value is 3 and the result value is greater than 3, the result value can be converted to 3. Therefore, the result value can be set to a value from 0 to 3.

[0358] Based on the result value, the context information that should be referenced when encoding / decoding the corresponding residual coefficient can be specified. In other words, the result value can be used as an index to specify one of multiple context information. Therefore, the threshold value can be determined based on the number of referenceable context information in the region including the residual coefficient.

[0359] The residual coefficient can be encoded / decoded by using simplified context information. In an example, when the variable QState is 0 or 1, the number of referenceable context information can be 4. On the other hand, when the variable QState is 2 or 3, the number of referenceable context information can be 2.

[0360] Alternatively, the number of references may be set differently for each region. In this example, when the variable QState is 2 or 3, the number of referenceable context information is set to 4 in the third region, and to 2 in the first and second regions.

[0361] When the number of referable context information in encoding / decoding the residual coefficient is 2, the threshold value may be set to 1. In this case, the result value has a value of 0 or 1, and thus one of the 2 context information may be specified by the result value.

[0362] Alternatively, when the number of referable context information is 2, context information may be specified based on whether a value obtained by a modulo operation with 2 and the sum of the absolute values of reconstruction coefficients in the surrounding reconstruction area is 0.

[0363] Even when gt_N_flag or par_flag is encoded / decoded, context information can be determined by referring to the surrounding reconstructed area.

[0364] Figure 27 Shows the number of context information that can be referenced when encoding gt_N_flag or par_flag.

[0365] Figure 27 (a) shows a luminance block, and Figure 27 (b) shows the chrominance block.

[0366] For luminance blocks, the blocks can be divided into multiple regions. Figure 27 In the example shown in (a), it is shown that the luminance block is divided into: a first region, where the luminance block includes a residual coefficient at the (0,0) position; a second region, where the sum of the x-axis coordinate and the y-axis coordinate is equal to or greater than 1 and less than 3; a third region, where the sum of the x-axis coordinate and the y-axis coordinate is equal to or greater than 3 and less than 10; and a fourth region other than the first to third regions.

[0367] In this case, the last non-zero residual coefficient may be set as the fifth region. Since the last non-zero residual coefficient is encoded / decoded first in the scanning order, only one context information may be set as reference for the last non-zero residual coefficient.

[0368] Chroma blocks can have fewer partitions than luma blocks. Figure 27 (b) shows that the chrominance block is divided into a first region including the residual coefficient (0, 0) and a second region other than the first region.

[0369] In this case, it can be set to the third region including the last non-zero residual coefficient.

[0370] exist Figure 27In the example shown, the number of reference context information in each region except the region including the last non-zero residual coefficient is shown to be 5. In this case, the type of reference context information in each region can be different. Therefore, the total number of reference context information in the luma block can be 21 (4×5+1), and the total number of reference context information in the chroma block can be 11 (2×5+1).

[0371] As described above, the number and / or type of referable context information may be set differently according to region or quantitative state information.

[0372] When encoding / decoding gt_N_flag or par_flag, at least one of the sum of the absolute values of the residual coefficients included in the surrounding reconstructed region and the sum of sig_flag can be obtained. Subsequently, the result value obtained by subtracting the sum of sig_flag from the sum of the absolute values can be compared with a threshold. In this case, when the result value is greater than the threshold, the result value can be converted to the threshold. In this example, when the threshold is 4, the result value greater than 4 can be converted to 4. Therefore, the result value is set to a value between 0 and 4. Based on the result value, one of five context information can be specified. In other words, the result value can be used as an index to specify one of multiple context information.

[0373] The context information that should be referenced can be determined using a simplified method. In one example, when encoding the residual coefficients in each region, only one predefined context information can be referenced, and the process of deriving the sum of the absolute values of the reconstruction coefficients in the surrounding reconstruction region can be omitted. The simplified method for determining context information can be applied to both the luma block and the chroma block, or to only one of the luma block and the chroma block.

[0374] In an example, although a method of specifying one of a plurality of context information may be used based on a result value in a luma block, a method of using predefined context information may be used in a chroma block.

[0375] The region partitioning method and the number of regions are not limited to the example shown. In this example, at least one of the partitioning method and the number of regions may be determined by considering at least one of the size or shape of the current block, whether transform skipping is applied, or the position of the last non-zero residual coefficient. Alternatively, information specifying at least one of the region partitioning method and the number of regions in the current block may be signaled by encoding via a higher header.

[0376] The number of referable context information may be set differently according to the size of the reconstruction region (ie, the number of reconstruction coefficients).

[0377] In this example, when context information is determined using five reconstruction coefficients, up to one of the five context information can be specified when encoding gt_N_flag or par_flag. On the other hand, when context information is determined using two reconstruction coefficients, up to one of three context information can be specified. As the number of referenceable context information decreases, the threshold value can also be decreased.

[0378] In addition, the size of the reconstruction region may be set differently for each region, or the size of the reconstruction region may be set differently for each color component.

[0379] Alternatively, the context information can be derived by comparing the information of each reconstruction coefficient instead of summing the information of each reconstruction coefficient in the surrounding reconstruction area. In the example, when encoding / decoding par_flag, it is assumed that Figure 27 In this case, for the left and upper reconstruction coefficients of the residual coefficient, context information that should be referred to when encoding / decoding par_flag for the current residual coefficient can be determined by referring to par_flag of each reconstruction coefficient.

[0380] In this example, for the left reconstruction coefficient and the upper reconstruction coefficient, the case where all par_flags are not encoded (i.e., for each of the left reconstruction coefficient and the upper reconstruction coefficient, at least one of sig_flag or gt_1_flag is 0) or the case where the values of par_flag of the two reconstruction coefficients are different can be defined as the first case. The case where all the values of par_flag of the two reconstruction coefficients are 1 can be defined as the second case, and the case where all the values of par_flag of the two reconstruction coefficients are 0 can be defined as the third case. When encoding the par_flag of the current residual coefficient, it can be set to refer to different context information for each case. In other words, after assigning an index (from 0 to 2) to each case, one context information can be specified based on the index.

[0381] This disclosure also provides the following configurations:

[0382] 1. A video decoding method, comprising:

[0383] determining whether to skip inverse transform for the current block;

[0384] Decoding the residual coefficients of the current block; and

[0385] selectively applying an inverse transform to the residual coefficients based on the determination,

[0386] When decoding the residual coefficient, one of a first syntax indicating whether the residual coefficient is greater than 0 and a second syntax indicating the absolute value of the residual coefficient is selectively decoded.

[0387] 2. The method according to claim 1, wherein whether to decode the first grammar or the second grammar is determined by comparing a threshold with the number of binary digits decoded by using context information.

[0388] 3. A method according to scheme 2, wherein the number of binary bits decoded by using the context information increases when at least one of the following is decoded: the first syntax, at least one gt_N_flag indicating whether the absolute value has a value greater than (2N-1), or a parity flag indicating whether the absolute value is an even number.

[0389] 4. The method according to scheme 1, wherein, when the first syntax is decoded and the first syntax indicates that the residual coefficient has a non-zero value, gt_1_flag indicating whether the absolute value of the residual coefficient has a value greater than 1 is additionally decoded.

[0390] 5. The method according to solution 4, wherein, when the gt_1_flag indicates that the absolute value has a value greater than 1, a parity flag indicating whether the absolute value is an even number and a gt_2_flag indicating whether the absolute value is greater than 3 are additionally decoded.

[0391] 6. The method according to scheme 2, wherein the threshold is determined based on the size of the current block.

[0392] 7. A video encoding method, comprising:

[0393] determining whether to skip transform for the current block;

[0394] quantizing the result of applying the transform or skipping the transform; and

[0395] encoding the residual coefficients output as a result of the quantization,

[0396] When encoding the residual coefficient, one of a first syntax indicating whether the residual coefficient is greater than 0 and a second syntax indicating the absolute value of the residual coefficient is selectively encoded.

[0397] 8. The method according to scheme 8, wherein whether to encode the first grammar or the second grammar is determined by comparing a threshold value with the number of binary bits encoded by using context information.

[0398] 9. A method according to scheme 8, wherein the number of binary bits encoded by using the context information increases when at least one of the following is encoded: the first syntax, at least one gt_N_flag indicating whether the absolute value has a value greater than (2N-1), or a parity flag indicating whether the absolute value is an even number.

[0399] 10. The method according to scheme 7, wherein, when the first syntax is encoded and the first syntax indicates that the residual coefficient has a non-zero value, gt_1_flag indicating whether the absolute value of the residual coefficient has a value greater than 1 is additionally encoded.

[0400] 11. The method according to embodiment 10, wherein, when the gt_1_flag indicates that the absolute value has a value greater than 1, a parity flag indicating whether the absolute value is an even number and a gt_2_flag indicating whether the absolute value is greater than 3 are additionally encoded.

[0401] 12. The method according to claim 8, wherein the threshold is determined based on the size of the current block.

[0402] 13. A computer-readable recording medium storing a bit stream encoded by a video encoding method, the video encoding method comprising:

[0403] determining whether to skip transform for the current block;

[0404] quantizing the result of applying the transform or skipping the transform; and

[0405] encoding the residual coefficients output as a result of the quantization,

[0406] When encoding the residual coefficient, one of a first syntax indicating whether the residual coefficient is greater than 0 and a second syntax indicating the absolute value of the residual coefficient is selectively encoded.

[0407] The syntax used in the above embodiments is named only for the convenience of description.

[0408] When the embodiments described based on the decoding process or encoding process are applied to the encoding process or decoding process, they are included in the scope of the present disclosure. When the embodiments described in the predetermined order are changed in an order different from the description, they are also included in the scope of the present disclosure.

[0409] The above-mentioned embodiment is described based on a series of stages or flow charts, but it does not limit the chronological order of the present disclosure, and if necessary, it can be performed simultaneously or in different orders. In addition, each component (e.g., unit, module, etc.) of the block diagram in the above-mentioned embodiment can be implemented as a hardware device or software, and a plurality of components can be combined and implemented as a hardware device or software. The above-mentioned embodiment can be recorded in a computer-readable recording medium implemented in the form of a program instruction that can be executed by various computer components. The computer-readable recording medium can include program instructions, data files, data structures, etc., individually or in combination. Hardware devices that are particularly configured to store and execute magnetic media such as hard disks, floppy disks and tapes, optical recording media such as CD-ROMs, DVDs, magneto-optical media such as optical floppy disks, and program instructions such as ROMs, RAMs, flash memories, etc. are included in the computer-readable recording medium. The hardware device can be configured to operate as one or more software modules to perform processing according to the present disclosure, and the software device can be configured to operate as one or more hardware modules to perform processing according to the present disclosure.

[0410] Industrial Applicability

[0411] The present disclosure may be applied to electronic devices that can encode / decode images.

Claims

1. A method for decoding a video, comprising: Get the predicted sample of the current block; decoding a transform skip flag indicating whether to skip inverse transform for a current block; Obtaining a residual coefficient of the current block; performing inverse quantization on the current block; Obtaining residual samples of the current block based on inverse quantized residual coefficients of the current block; as well as reconstructing the current block by summing the prediction samples and the residual samples, wherein, when the transform skip flag indicates that inverse transform is skipped for the current block, determining whether to decode at least one context-coded syntax for obtaining a residual coefficient of the current block based on the number of context-coded binary bits decoded so far and a threshold value, wherein, when the number of context-coded bits decoded so far is less than the threshold, decoding the at least one context-coded syntax from the bitstream to obtain the residual coefficient of the current block, and The syntax of the at least one context encoding includes at least one of the following: a valid flag indicating whether the residual coefficient is not zero, a greater than 1 flag indicating whether the absolute value of the residual coefficient is greater than 1, a sign flag indicating whether the residual coefficient has a positive value or a negative value, and a parity flag indicating whether the absolute value of the residual coefficient is an odd number or an even number.

2. The method according to claim 1, wherein When the number of context-coded binary bits decoded so far is equal to or greater than the threshold, the residual coefficient of the current block is obtained by decoding the remaining level information representing the absolute value of the residual coefficient from the bitstream without decoding the syntax of the at least one context code.

3. The method according to claim 1, wherein The greater than 1 flag is decoded from the bitstream only when the valid flag indicates that the residual coefficient is not zero.

4. The method according to claim 1, wherein The threshold is determined based on the size of the current block.

5. A method for encoding a video, comprising: Get the predicted sample of the current block; Obtaining residual samples of the current block by subtracting the predicted samples from the original samples; determining whether to skip transform for the current block; quantizing the transform coefficients of the current block; as well as Encode the residual coefficients resulting from quantization, wherein, when it is determined that the transformation is skipped for the current block, the transformation coefficient is the same as the residual sample, wherein, when it is determined to skip transform for the current block, determining whether to encode at least one context-coded syntax for the residual coefficient of the current block based on the number of context-coded bins encoded so far and a threshold value, wherein, when the remaining number of context-coded bins encoded so far is less than the threshold, encoding the at least one context-coded syntax into the bitstream for the residual coefficients of the current block, and The syntax of the at least one context encoding includes at least one of the following: a valid flag indicating whether the residual coefficient is not zero, a greater than 1 flag indicating whether the absolute value of the residual coefficient is greater than 1, a sign flag indicating whether the residual coefficient has a positive value or a negative value, and a parity flag indicating whether the absolute value of the residual coefficient is an odd number or an even number.

6. The method according to claim 5, wherein: When the number of context-coded bins encoded so far is equal to or greater than the threshold, remaining level information representing an absolute value of the residual coefficient is encoded for the residual coefficient of the current block instead of the at least one context-coded syntax.

7. The method according to claim 5, wherein: The greater than 1 flag is encoded into the bitstream only when the valid flag is encoded with a value indicating that the residual coefficient is not zero.

8. The method according to claim 5, wherein The threshold is determined based on the size of the current block.

9. An apparatus for transmitting compressed video data, comprising: a processor configured to acquire the compressed video data, and a transmission unit configured to transmit the compressed video data, Wherein, obtaining the compressed video data includes: Get the predicted sample of the current block; Obtaining residual samples of the current block by subtracting the predicted samples from the original samples; determining whether to skip transform for the current block; quantizing the transform coefficients of the current block; and Encode the residual coefficients resulting from quantization, wherein, when it is determined that the transformation is skipped for the current block, the transformation coefficient is the same as the residual sample, wherein, when it is determined to skip transform for the current block, determining whether to encode at least one context-coded syntax for the residual coefficient of the current block based on the number of context-coded bins encoded so far and a threshold value, wherein, when the remaining number of context-coded bins encoded so far is less than the threshold, encoding the at least one context-coded syntax into the bitstream for the residual coefficients of the current block, and The syntax of the at least one context encoding includes at least one of the following: a valid flag indicating whether the residual coefficient is not zero, a greater than 1 flag indicating whether the absolute value of the residual coefficient is greater than 1, a sign flag indicating whether the residual coefficient has a positive value or a negative value, and a parity flag indicating whether the absolute value of the residual coefficient is an odd number or an even number.