Image decoding method using residual information in image encoding system and apparatus therefor

By limiting the number of context compilation bins and bypassing syntax elements during image decoding, the image decoding process is optimized, solving the problem of low compression efficiency for high-resolution images and achieving more efficient image compression.

CN117939131BActive Publication Date: 2026-06-23GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
Filing Date
2020-01-13
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing technologies have low image compression efficiency in the transmission and storage of high-resolution, high-quality images, leading to increased transmission and storage costs.

Method used

The image decoding process is optimized by limiting the number of context compilation bins of the context syntax elements of the current sub-block in the image decoding method, and by bypassing the decoding of syntax elements when a certain number is reached.

Benefits of technology

It improves image compression efficiency, reduces image compilation complexity, and enhances overall compilation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117939131B_ABST
    Figure CN117939131B_ABST
Patent Text Reader

Abstract

The present invention relates to an image decoding method using residual information in an image encoding system and an apparatus thereof. According to the present document, an image decoding method performed by a decoding apparatus includes the steps of receiving a bitstream including residual information of a current block; deriving a particular number of context-coded bins for a context syntax element of a current sub-block of the current block; decoding the context syntax element of the current sub-block included in the residual information based on the particular number; deriving transform coefficients of the current sub-block based on the decoded context syntax element; deriving residual samples of the current block based on the transform coefficients; and generating a reconstructed picture based on the residual samples.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of patent application No. 202080013196.1 (PCT / KR2020 / 000621), filed with the China Patent Office on August 6, 2021, with an international application date of January 13, 2020, entitled "Image Decoding Method and Apparatus Using Residual Information in an Image Compilation System". Technical Field

[0002] This disclosure relates to image compilation technology, and more specifically, to an image decoding method and apparatus thereof for compiling residual information of syntax elements including transform coefficients of residuals in an image compilation system. Background Technology

[0003] Recently, the demand for high-resolution, high-quality images, such as HD (high-definition) and UHD (ultra-high-definition) images, has been growing across various fields. Because image data is high-resolution and high-quality, the amount of information or bits to be transmitted increases compared to traditional image data. Therefore, transmission and storage costs increase when using media such as traditional wired / wireless broadband lines to send image data or when using existing storage media to store image data.

[0004] Therefore, there is a need for efficient image compression technology to effectively transmit, store, and reproduce information from high-resolution, high-quality images. Summary of the Invention

[0005] Technical issues

[0006] This disclosure provides a method and apparatus for improving image compilation efficiency.

[0007] This disclosure also provides a method and apparatus for improving the efficiency of residual compilation.

[0008] This disclosure also provides a method and apparatus for determining and adjusting the sum of the number of context compilation bins of a context syntax element when adjusting the number of context compilation bins for the current sub-block while encoding residual information.

[0009] Technical solution

[0010] In one aspect, an image decoding method performed by a decoding device is provided. The method includes: receiving a bitstream including residual information of a current block; deriving a specific number of context compilation bins for context syntax elements of a current sub-block of the current block; decoding the context syntax elements for the current sub-block included in the residual information based on the specific number; deriving transform coefficients of the current sub-block based on the decoded context syntax elements; deriving residual samples of the current block based on the transform coefficients; and generating a reconstructed image based on the residual samples, wherein bypass syntax elements for specific transform coefficients included in the residual information are decoded when the number of context compilation bins for context syntax elements of transform coefficients derived before specific transform coefficients of the current sub-block reaches the specific number.

[0011] In another aspect, a decoding apparatus for performing image decoding is provided. The decoding apparatus includes: an entropy decoder configured to receive a bitstream including residual information of a current block, derive a specific number of context compilation bins of context syntax elements of a current sub-block of the current block, decode the context syntax elements of the current sub-block included in the residual information based on the specific number, and derive transform coefficients of the current sub-block based on the decoded context syntax elements; an inverse transformer configured to derive residual samples of the current block based on the transform coefficients; and an adder configured to generate a reconstructed image based on the residual samples of the current block, wherein bypass syntax elements of the specific transform coefficients included in the residual information are decoded when the number of context compilation bins of context syntax elements of the transform coefficients derived before the specific transform coefficients of the current sub-block reaches the specific number.

[0012] In another aspect, an image encoding method performed by an encoding device is provided. The method includes: deriving residual samples of a current block; deriving transform coefficients in a current sub-block of the current block based on the residual samples; deriving a specific number of context compilation bins for context syntax elements of the current sub-block; encoding the context syntax elements based on the specific number; and generating a bitstream including residual information of the current block, the residual information of the current block including encoded context syntax elements, wherein bypass syntax elements for specific transform coefficients included in the residual information are encoded when the number of context compilation bins for context syntax elements of transform coefficients derived before specific transform coefficients of the current sub-block reaches the specific number.

[0013] In another aspect, a video encoding apparatus is provided. The encoding apparatus includes: a subtractor configured to derive residual samples about a current block; a transformer configured to derive transform coefficients in a current sub-block of the current block based on the residual samples; and an entropy encoder configured to derive a specific number of context compilation bins of context syntax elements about the current sub-block, encode the context syntax elements based on the specific number, and generate a bitstream including residual information of the current block, the residual information of the current block including encoded context syntax elements, wherein, when the number of context compilation bins of context syntax elements of transform coefficients derived before a specific transform coefficient of the current sub-block reaches the specific number, bypass syntax elements of the specific transform coefficients included in the residual information are encoded.

[0014] Beneficial effects

[0015] According to this document, overall image / video compression efficiency can be improved.

[0016] According to this document, the efficiency of residual compilation can be improved.

[0017] According to the document, the amount of context-based compilation data can be reduced by limiting the sum of the number of context compilation bins containing context syntax elements about the transform coefficients in the current block included in the residual information to a predetermined maximum value or less.

[0018] According to the document, when adjusting the number of context compilation bins for the current sub-block, instead of determining the encoding for each context syntax element, the sum of the number of context compilation bins for each context syntax element is determined. This reduces residual compilation complexity and improves overall compilation efficiency. Attached Figure Description

[0019] Figure 1 Examples of video / image compilation apparatuses to which embodiments of this document can be applied are briefly illustrated.

[0020] Figure 2 This is a schematic diagram illustrating the configuration of a video / image encoding device to which embodiments of this document can be applied.

[0021] Figure 3 This is a schematic diagram illustrating the configuration of a video / image decoding device to which embodiments of this document can be applied.

[0022] Figure 4 An example is shown of context-adaptive binary arithmetic coding (CABAC) for encoding syntax elements.

[0023] Figure 5 This is a diagram showing exemplary transformation coefficients within a 4x4 block.

[0024] Figure 6 An example is illustrated of a decoding apparatus according to the present disclosure for performing a method for delivering a residual signal in a pixel domain.

[0025] Figure 7a and Figure 7b An embodiment for determining whether to parse the transform skip flag based on the number of samples in the current block and a decoding device for performing this embodiment are illustrated.

[0026] Figure 8 The residual coefficients of the current block to which a rearrangement method of rotating 180 degrees has been applied are shown as an example.

[0027] Figure 9 The residual coefficients of the current block to which the mirror rearrangement method has been applied are shown as an example.

[0028] Figure 10 The residual coefficients of the current block to which the flip rearrangement method has been applied are shown as an example.

[0029] Figure 11 An illustrative example is shown of the residual coefficients of the current block to which layers differentiated based on distance from a reference sample are derived and rearranged in position according to the inverse raster order.

[0030] Figure 12 An illustrative example is shown of the residual coefficients of the current block to which layers differentiated based on distance from a reference sample are derived and rearranged in position according to the diagonal scan order.

[0031] Figure 13 An exemplary example is shown of the residual coefficients of the current block to which layers differentiated based on distance from a particular reference sample are derived and rearranged in a location according to the diagonal scan order.

[0032] Figure 14a and Figure 14b An embodiment of determining whether to apply a rearrangement method based on the transform skip flag of the current block is shown, along with an encoding device and a decoding device that execute this embodiment.

[0033] Figure 15 An example of a method for determining the compilation of residual information based on a transform skip flag is shown.

[0034] Figure 16 An example of a method for determining the compilation of residual information based on integrated transformation type information is shown.

[0035] Figure 17 The image encoding method performed by the encoding device according to this document is illustrated schematically.

[0036] Figure 18 An encoding device for performing an image encoding method according to the document is illustrated schematically.

[0037] Figure 19 The image decoding method performed by the decoding device according to the document is illustrated schematically.

[0038] Figure 20 The document schematically illustrates a decoding device for performing an image decoding method.

[0039] Figure 21 A structural diagram of a content streaming system using this disclosure is illustrated. Detailed Implementation

[0040] This disclosure can be modified in various forms, and specific embodiments thereof will be described and illustrated in the accompanying drawings. However, the embodiments are not intended to limit this disclosure. The terminology used in the following description is for the purpose of describing specific embodiments only and is not intended to limit this disclosure. Singular expressions include plural expressions, provided that they are clearly understood in different ways. Terms such as “comprising” and “having” are intended to indicate the presence of the features, numbers, steps, operations, elements, components, or combinations thereof used in the following description, and therefore should be understood to mean that the possibility of having or adding one or more different features, numbers, steps, operations, elements, components, or combinations thereof is not excluded.

[0041] Furthermore, the elements in the accompanying drawings described in this disclosure are drawn independently for the convenience of explaining different specific functions and do not imply that these elements are embodied by independent hardware or independent software. For example, two or more elements may be combined to form a single element, or a single element may be divided into multiple elements. The implementation of combining and / or dividing elements is part of this disclosure and does not depart from its concept.

[0042] In the following, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings. Furthermore, throughout the drawings, similar reference numerals are used to indicate similar elements, and identical descriptions of similar elements will be omitted.

[0043] Figure 1 Examples of video / image compilation apparatuses to which embodiments of the present disclosure may be applied are briefly illustrated.

[0044] Reference Figure 1 A video / image encoding system may include a first device (source device) and a second device (receiving device). The source device may send encoded video / image information or data to the receiving device in the form of a file or stream via a digital storage medium or network.

[0045] The source device may include a video source, an encoding device, and a transmitter. The receiving device may include a receiver, a decoding device, and a renderer. The encoding device may be referred to as a video / image encoding device, and the decoding device may be referred to as a video / image decoding device. The transmitter may be included in the encoding device. The receiver may be included in the decoding device. The renderer may include a display, and the display may be configured as a separate device or an external component.

[0046] Video sources can acquire video / images through processes that capture, synthesize, or generate video / images. Video sources may include video / image capture devices and / or video / image generation devices. Video / image capture devices may include, for example, one or more cameras, video / image archives including previously captured video / images, etc. Video / image generation devices may include, for example, computers, tablets, and smartphones, and can generate video / images (electronically). For example, virtual video / images can be generated by computers, etc. In this case, the video / image capture process can be replaced by a process that generates related data.

[0047] Encoding devices can encode input video / images. They can perform a series of processes such as prediction, transformation, and quantization to achieve compression and compilation efficiency. The encoded data (encoded video / image information) can be output as a bitstream.

[0048] The transmitter can send encoded images / image information or data, output in bitstream form, to the receiver of the receiving device in the form of a file or stream via digital storage media or a network. Digital storage media can include various storage media such as USB, SD, CD, DVD, Blu-ray, HDD, SSD, etc. The transmitter can include elements for generating media files according to a predetermined file format and may include elements for transmission via a broadcast / communication network. The receiver can receive / extract the bitstream and send the received bitstream to a decoding device.

[0049] Decoding devices can decode video / images by performing a series of processes, such as dequantization, inverse transform, and prediction, that correspond to the operations of encoding devices.

[0050] The renderer can render decoded video / images. The rendered video / images can be displayed on a monitor.

[0051] This document relates to video / image compilation. For example, the methods / implementations disclosed in this document can be applied to methods disclosed in Multifunctional Video Coding (VVC), EVC (Essential Video Coding) standard, AOMedia Video 1 (AV1) standard, Audio Video Coding Standard 2 (AVS2), or next-generation video / image coding standards (e.g., H.267, or H.268, etc.).

[0052] This document presents various implementations of video / image compilation, and unless otherwise noted, these implementations can be combined with each other.

[0053] In this document, video can refer to a series of images over a period of time. An image typically refers to a unit representing an image within a specific time region, while a slice / tile is a unit that makes up a part of an image during compilation. A slice / tile can include one or more compilation tree units (CTUs). An image can include one or more slices / tiles. An image can include one or more tile groups. A tile group can include one or more tiles. A brick can represent a rectangular area of ​​CTU rows within a tile in an image. A tile can be partitioned into multiple bricks, each brick comprising one or more CTU rows within the tile. A tile that is not partitioned into multiple bricks can also be called a brick. A brick scan is a specific ordering of the CTUs in an image where the CTUs are consecutively ordered in the CTU raster scan of the brick; bricks within a tile are consecutively arranged in the raster scan of the tile's bricks, and tiles in an image are consecutively ordered in the raster scan of the image's tiles. A tile is a rectangular area of ​​CTUs within a specific tile column and a specific tile row in an image. A tile column is a rectangular area of ​​CTUs with a height equal to the height of the image and a width specified by a syntax element in the image parameter set. A tile row is a rectangular area of ​​CTUs with a height specified by a syntax element in the image parameter set and a width equal to the width of the image. A tile scan refers to a specific ordering of CTUs in an image where the CTUs are ordered consecutively in a tile's CTU raster scan, and tiles in an image are ordered consecutively in a tile's tile raster scan. A slice comprises an integer number of tiles of an image that can be uniquely contained within a single NAL unit. A slice can include multiple complete tiles or a consecutive sequence of complete tiles of a single tile. Tile groups and slices are used interchangeably in this document. For example, in this document, a tile group / tile group header may be referred to as a slice / slice header.

[0054] A pixel, or cell, can represent the smallest unit that makes up a picture (or image). Additionally, "sample" can be used as the term corresponding to a pixel. A sample can typically represent a pixel or pixel value, and can represent only the pixel / pixel value of the luminance component or only the pixel / pixel value of the chrominance component.

[0055] A unit can represent the basic unit of image processing. A unit may include a specific region of an image and at least one of the information associated with that region. A unit may include a luminance block and two chrominance (e.g., cb, cr) blocks. In some cases, the term "unit" may be used interchangeably with terms such as "block" or "region". In general, an M×N block may include a set (or array) of samples (or sample arrays) or transform coefficients in M ​​columns and N rows.

[0056] In this document, the terms " / " and "," should be interpreted as indicating "and / or". For example, the expression "A / B" can mean "A and / or B". Furthermore, "A, B" can mean "A and / or B". Additionally, "A / B / C" can mean "at least one of A, B, and / or C". Also, "A / B / C" can mean "at least one of A, B, and / or C".

[0057] Furthermore, in this document, the term "or" should be interpreted as indicating "and / or". For example, the expression "A or B" could include 1) only A, 2) only B, and / or 3) both A and B. In other words, the term "or" in this document should be interpreted as indicating "additionally or alternatively".

[0058] Figure 2 This is a schematic diagram illustrating the configuration of a video / image encoding apparatus to which the embodiments described in this document can be applied. In the following text, a video encoding apparatus may include an image encoding apparatus.

[0059] Reference Figure 2 The encoding device 200 includes an image partitioner 210, a predictor 220, a residual processor 230, an entropy encoder 240, an adder 250, a filter 260, and a memory 270. The predictor 220 may include an inter-frame predictor 221 and an intra-frame predictor 222. The residual processor 230 may include a transformer 232, a quantizer 233, a dequantizer 234, and an inverse transformer 235. The residual processor 230 may also include a subtractor 231. The adder 250 may be referred to as a reconstructor or a reconstruction block generator. According to embodiments, the image partitioner 210, predictor 220, residual processor 230, entropy encoder 240, adder 250, and filter 260 may be constituted by at least one hardware component (e.g., an encoder chipset or processor). Additionally, the memory 270 may include a decoded picture buffer (DPB) or may be constituted by a digital storage medium. The hardware component may also include the memory 270 as an internal / external component.

[0060] Image partitioner 210 can partition an input image (or picture or frame) input to encoding device 200 into one or more processors. For example, a processor can be referred to as a compilation unit (CU). In this case, the compilation unit can be recursively partitioned from a compilation tree unit (CTU) or a maximum compilation unit (LCU) according to a quadtree-binary-trinary tree (QTBTTT) structure. For example, a compilation unit can be partitioned into multiple deeper compilation units based on a quadtree structure, a binary tree structure, and / or a ternary structure. In this case, for example, a quadtree structure can be applied first, followed by a binary tree structure and / or a ternary structure. Alternatively, a binary tree structure can be applied first. The compilation process according to this document can be performed based on the final compilation unit that is no longer partitioned. In this case, the maximum compilation unit can be used as the final compilation unit based on compilation efficiency according to image characteristics, or, if necessary, the compilation unit can be recursively partitioned into deeper compilation units, and the compilation unit with the optimal size can be used as the final compilation unit. Here, the compilation process can include prediction, transformation, and reconstruction processes, which will be described later. As another example, the processor may also include a prediction unit (PU) or a transform unit (TU). In this case, the prediction unit and the transform unit can be separated or partitioned from the final compilation unit described above. The prediction unit may be a unit for predicting samples, and the transform unit may be a unit for deriving transform coefficients and / or a unit for deriving residual signals from the transform coefficients.

[0061] In some cases, a unit can be used interchangeably with terms such as block or region. Generally, an M×N block can represent a set of samples or transform coefficients consisting of M columns and N rows. A sample can typically represent a pixel or pixel value, and can represent only the pixel / pixel value of the luminance component, or only the pixel / pixel value of the chrominance component. A sample can be used as a term corresponding to a picture (or image) of pixels or cells.

[0062] In the encoding device 200, the predicted signal (prediction block, prediction sample array) output from the inter-frame predictor 221 or the intra-frame predictor 222 is subtracted from the input image signal (original block, original sample array) to generate a residual signal (residual block, residual sample array), and the generated residual signal is sent to the converter 232. In this case, as shown, the unit in the encoder 200 used to subtract the predicted signal (prediction block, prediction sample array) from the input image signal (original block, original sample array) can be called the subtractor 231. The predictor can perform prediction on the block to be processed (hereinafter referred to as the current block) and generate a prediction block that includes the prediction samples of the current block. The predictor can determine whether to apply intra-frame prediction or inter-frame prediction based on the current block or CU. As described later in the description of each prediction mode, the predictor can generate various information related to the prediction, such as prediction mode information, and send the generated information to the entropy encoder 240. The information about the prediction can be encoded in the entropy encoder 240 and output as a bitstream.

[0063] Intra-predictor 222 can predict the current block by referencing samples in the current image. Depending on the prediction mode, the referenced samples may be located near or far from the current block. In intra-prediction, the prediction mode can include multiple non-directional modes and multiple directional modes. Non-directional modes can include, for example, DC mode and planar mode. Depending on the level of detail in the prediction direction, the directional modes can include, for example, 33 or 65 directional prediction modes. However, this is just an example, and more or fewer directional prediction modes may be used depending on the settings. Intra-predictor 222 can determine the prediction mode to be applied to the current block by using the prediction modes applied to neighboring blocks.

[0064] Inter-frame predictor 221 can derive the predicted block of the current block based on a reference block (reference sample array) specified by motion vectors on a reference image. Here, to reduce the amount of motion information transmitted in inter-frame prediction mode, motion information can be predicted on a block, sub-block, or sample basis based on the correlation between motion information between neighboring blocks and the current block. Motion information may include motion vectors and reference image indices. Motion information may also include inter-frame prediction direction (L0 prediction, L1 prediction, Bi prediction, etc.) information. In the case of inter-frame prediction, neighboring blocks may include spatially adjacent blocks existing in the current image and temporally adjacent blocks existing in the reference image. The reference image including the reference block and the reference image including the temporally adjacent block may be the same or different. The temporally adjacent block may be called a juxtaposed reference block, a co-located CU (colCU), etc., and the reference image including the temporally adjacent block may be called a juxtaposed image (colPic). For example, inter-frame predictor 221 can configure a motion information candidate list based on neighboring blocks and generate information indicating which candidate to use to derive the motion vector and / or reference image index of the current block. Inter-frame prediction can be performed based on various prediction modes. For example, in skip mode and merge mode, the inter-frame predictor 221 can use motion information from neighboring blocks as motion information for the current block. In skip mode, unlike merge mode, residual signals may not be transmitted. In motion vector prediction (MVP) mode, motion vectors from neighboring blocks can be used as motion vector predictors, and the motion vector of the current block can be indicated by signaling the motion vector difference.

[0065] Predictor 220 can generate prediction signals based on various prediction methods described below. For example, the predictor can not only apply intra-frame prediction or inter-frame prediction to predict a block, but can also apply both intra-frame prediction and inter-frame prediction simultaneously. This can be called Inter-Frame Intra-Frame Combined Prediction (CIIP). Alternatively, the predictor can predict blocks based on Intra-Frame Block Copy (IBC) prediction mode or Palette mode. IBC prediction mode or Palette mode can be used for content image / video compilation such as games, for example, Screen Content Encoding (SCC). IBC essentially performs prediction in the current image, but can be performed similarly to inter-frame prediction because the reference block is derived from the current image. That is, IBC can use at least one of the inter-frame prediction techniques described in this document. Palette mode can be considered as an example of intra-frame compilation or intra-frame prediction. When applying Palette mode, sample values ​​within the image can be signaled based on information about the palette table and palette index.

[0066] The predicted signal generated by the predictor (including inter-frame predictor 221 and / or intra-frame predictor 222) can be used to generate a reconstructed signal or a residual signal. Transformer 232 can generate transform coefficients by applying transform techniques to the residual signal. For example, the transform technique can include at least one of Discrete Cosine Transform (DCT), Discrete Sine Transform (DST), Karhunen-Loève Transform (KLT), Graph-Based Transform (GBT), or Conditional Nonlinear Transform (CNT). Here, GBT refers to the transform obtained from a graph when the relationship information between pixels is represented by a graph. CNT refers to the transform generated based on the predicted signal generated using all previously reconstructed pixels. Furthermore, the transform processing can be applied to square pixel blocks of the same size, or it can be applied to blocks of variable size that are not square.

[0067] Quantizer 233 quantizes the transform coefficients and sends them to entropy encoder 240, which encodes the quantized signal (information about the quantized transform coefficients) and outputs a bitstream. This information about the quantized transform coefficients can be called residual information. Quantizer 233 can rearrange the block-type quantized transform coefficients into a one-dimensional vector form based on the coefficient scan order and generate information about the quantized transform coefficients based on this one-dimensional vector form. Entropy encoder 240 can perform various encoding methods, such as Golomb, Context Adaptive Variable Length Coding (CAVLC), and Context Adaptive Binary Arithmetic Coding (CABAC). Entropy encoder 240 can encode information required for video / image reconstruction other than the quantized transform coefficients (e.g., values ​​of syntax elements) together or separately. Encoded information (e.g., encoded video / image information) can be sent or stored in units of NAL (Network Abstraction Layer) in the form of a bitstream. The video / image information may also include information about various parameter sets such as Adaptive Parameter Set (APS), Picture Parameter Set (PPS), Sequence Parameter Set (Step, SPS), or Video Parameter Set (VPS). Additionally, the video / image information may include general constraint information. In this document, information and / or syntax elements that send / signal notifications from the encoding device to the decoding device may be included in the video / image information. The video / image information may be encoded by the encoding process described above and included in a bitstream. The bitstream may be transmitted over a network or stored in a digital storage medium. The network may include broadcast networks and / or communication networks, and the digital storage medium may include various storage media such as USB, SD, CD, DVD, Blu-ray, HDD, SSD, etc. A transmitter (not shown) that transmits the signal output from the entropy encoder 240 and / or a storage unit (not shown) that stores the signal may be included as internal / external components of the encoding device 200; alternatively, the transmitter may be included in the entropy encoder 240.

[0068] The quantized transform coefficients output from quantizer 233 can be used to generate a prediction signal. For example, the residual signal (residual block or residual sample) can be reconstructed by applying dequantization and inverse transform to the quantized transform coefficients using dequantizer 234 and inverse transformer 235. Adder 250 adds the reconstructed residual signal to the prediction signal output from inter-frame predictor 221 or intra-frame predictor 222 to generate a reconstructed signal (reconstructed image, reconstructed block, reconstructed sample array). If the block to be processed has no residual (such as when a skip mode is applied), the prediction block can be used as a reconstructed block. Adder 250 can be referred to as a reconstructor or reconstructed block generator. The generated reconstructed signal can be used for intra-frame prediction of the next block to be processed in the current image, and can be used for inter-frame prediction of the next image by filtering as described below.

[0069] In addition, luminance mapping with chroma scaling (LMCS) can be applied during image encoding and / or reconstruction.

[0070] Filter 260 can improve subjective / objective image quality by applying filtering to the reconstructed signal. For example, filter 260 can generate a modified reconstructed image by applying various filtering methods to the reconstructed image and store the modified reconstructed image in memory 270 (specifically, the DPB of memory 270). Various filtering methods may include, for example, deblocking filtering, sample adaptive offsetting, adaptive loop filtering, bilateral filtering, etc. Filter 260 can generate various filtering-related information and send the generated information to entropy encoder 240, as described later in the description of the various filtering methods. The filtering-related information can be encoded by entropy encoder 240 and output as a bitstream.

[0071] The modified reconstructed image sent to memory 270 can be used as a reference image in inter-frame predictor 221. When inter-frame prediction is applied via the encoding device, prediction mismatch between the encoding device 200 and the decoding device can be avoided, and compilation efficiency can be improved.

[0072] The DPB of memory 270 can store a modified reconstructed image used as a reference image in inter-frame predictor 221. Memory 270 can store motion information of blocks from which motion information in the current image is derived (or encoded) and / or motion information of reconstructed blocks in the image. The stored motion information can be sent to inter-frame predictor 221 and used as motion information for spatially adjacent blocks or temporally adjacent blocks. Memory 270 can store reconstructed samples of reconstructed blocks in the current image and can transmit these reconstructed samples to intra-frame predictor 222.

[0073] Figure 3 This is a schematic diagram illustrating the configuration of a video / image decoding device to which the implementation methods described in this document can be applied.

[0074] Reference Figure 3 The decoding device 300 may include an entropy decoder 310, a residual processor 320, a predictor 330, an adder 340, a filter 350, and a memory 360. The predictor 330 may include an inter-frame predictor 332 and an intra-frame predictor 331. The residual processor 320 may include a dequantizer 321 and an inverse transformer 322. According to embodiments, the entropy decoder 310, residual processor 320, predictor 330, adder 340, and filter 350 may be constructed from hardware components (e.g., a decoder chipset or processor). Additionally, the memory 360 may include a decoded image buffer (DPB) or may be constructed from a digital storage medium. The hardware components may also include the memory 360 as an internal / external component.

[0075] When a bitstream including video / image information is input, the decoding device 300 can interact with... Figure 2 The processing of video / image information in the encoding device correspondingly reconstructs the image. For example, the decoding device 300 can derive units / blocks based on block partitioning information obtained from the bitstream. The decoding device 300 can use a processor applied in the encoding device to perform decoding. Therefore, the decoding processor can be, for example, a compilation unit, and the compilation unit can be partitioned from compilation tree units or the largest compilation unit according to a quadtree structure, binary tree structure, and / or ternary tree structure. One or more transformation units can be derived from the compilation unit. The reconstructed image signal decoded and output by the decoding device 300 can be reproduced by a reproduction device.

[0076] Decoding device 300 can receive data in bitstream form from... Figure 2The signal output by the encoding device can be decoded by the entropy decoder 310. For example, the entropy decoder 310 can parse the bitstream to derive information (e.g., video / image information) required for image reconstruction (or picture reconstruction). The video / image information may also include information about various parameter sets such as Adaptive Parameter Set (APS), Picture Parameter Set (PPS), Sequence Parameter Set (Step, SPS), or Video Parameter Set (VPS). Additionally, the video / image information may include general constraint information. The decoding device can also decode the picture based on the information about the parameter sets and / or general constraint information. The signaled / received information and / or syntax elements described later in this document can be decoded and obtained from the bitstream through the decoding process. For example, the entropy decoder 310 decodes the information in the bitstream based on a compilation method such as Exponential Golomb coding, CAVLC, or CABAC, and outputs the quantized values ​​of the syntax elements and transform coefficients of the residuals required for image reconstruction. More specifically, the CABAC entropy decoding method can receive a bin corresponding to each syntax element in the bitstream, determine the context model using information about the target syntax element, decoding information about the target block, or information about symbols / bins decoded in previous stages, and perform arithmetic decoding on the bin by predicting the occurrence probability of the bin based on the determined context model, generating symbols corresponding to the value of each syntax element. In this case, after determining the context model, the CABAC entropy decoding method can update the context model by using the information of the decoded symbols / bins for the context model of the next symbol / bin. The prediction-related information in the information decoded by the entropy decoder 310 can be provided to the predictors (inter-frame predictor 332 and intra-frame predictor 331), and the residual values ​​(i.e., quantization transform coefficients and related parameter information) from which entropy decoding has been performed in the entropy decoder 310 can be input to the residual processor 320. The residual processor 320 can derive residual signals (residual blocks, residual samples, residual sample arrays). Additionally, the filtering information in the information decoded by the entropy decoder 310 can be provided to the filter 350. Furthermore, a receiver (not shown) for receiving signals output from the encoding device may be further configured as an internal / external element of the decoding device 300, or the receiver may be a component of the entropy decoder 310. Additionally, the decoding device according to this document may be referred to as a video / image / picture decoding device, and the decoding device may be classified as an information decoder (video / image / picture information decoder) and a sample decoder (video / image / picture sample decoder). The information decoder may include the entropy decoder 310, and the sample decoder may include at least one of a dequantizer 321, an inverse transformer 322, an adder 340, a filter 350, a memory 360, an inter-frame predictor 332, and an intra-frame predictor 331.

[0077] Dequantizer 321 can dequantize the quantized transform coefficients and output the transform coefficients. Dequantizer 321 can rearrange the quantized transform coefficients in the form of two-dimensional blocks. In this case, the rearrangement can be performed based on the coefficient scan order performed in the encoding device. Dequantizer 321 can perform dequantization on the quantized transform coefficients using quantization parameters (e.g., quantization step size information) and obtain the transform coefficients.

[0078] The inverse transformer 322 performs an inverse transformation on the transformation coefficients to obtain the residual signal (residual block, residual sample array).

[0079] The predictor can perform prediction on the current block and generate a prediction block that includes the prediction samples of the current block. The predictor can determine whether to apply intra-frame prediction or inter-frame prediction to the current block based on the prediction information output from the entropy decoder 310, and can determine the specific intra-frame / inter-frame prediction mode.

[0080] Predictor 320 can generate prediction signals based on various prediction methods described below. For example, the predictor can not only apply intra-frame prediction or inter-frame prediction to predict a block, but can also apply intra-frame prediction and inter-frame prediction simultaneously. This can be referred to as combined intra-frame and inter-frame prediction (CIIP). Additionally, the predictor can predict blocks based on an intra-block copy (IBC) prediction mode or a palette mode. The IBC prediction mode or palette mode can be used for content image / video compilation, such as in games, for example, screen content encoding (SCC). IBC essentially performs prediction within the current image, but can be performed similarly to inter-frame prediction because a reference block is derived from the current image. That is, IBC can use at least one of the inter-frame prediction techniques described in this document. The palette mode can be considered an example of intra-frame compilation or intra-frame prediction. When applying a palette mode, sample values ​​within the image can be signaled based on information about the palette table and palette indexes.

[0081] Intra-predictor 331 can predict the current block by referencing samples in the current image. Depending on the prediction mode, the referenced samples may be located near or far from the current block. In intra-prediction, the prediction mode can include multiple non-directional modes and multiple directional modes. Intra-predictor 331 can determine the prediction mode applied to the current block by using prediction modes applied to neighboring blocks.

[0082] Inter-frame predictor 332 can derive the predicted block for the current block based on a reference block (reference sample array) specified by motion vectors on a reference image. In this case, to reduce the amount of motion information transmitted in the inter-frame prediction mode, motion information can be predicted on a block, sub-block, or sample basis based on the correlation between motion information between neighboring blocks and the current block. Motion information may include motion vectors and reference image indices. Motion information may also include inter-frame prediction direction (L0 prediction, L1 prediction, Bi prediction, etc.) information. In the case of inter-frame prediction, neighboring blocks may include spatially adjacent blocks existing in the current image and temporally adjacent blocks existing in the reference image. For example, inter-frame predictor 332 can configure a motion information candidate list based on neighboring blocks and derive the motion vector and / or reference image index for the current block based on received candidate selection information. Inter-frame prediction can be performed based on various prediction modes, and the information about the prediction may include information indicating the mode of inter-frame prediction for the current block.

[0083] Adder 340 can generate a reconstruction signal (reconstructed image, reconstruction block, reconstruction sample array) by adding the obtained residual signal to the prediction signal (prediction block, prediction sample array) output from the predictor (including inter-frame predictor 332 and / or intra-frame predictor 331). If the block to be processed has no residual (e.g., when a skip mode is applied), the prediction block can be used as the reconstruction block.

[0084] Adder 340 can be called a reconstructor or reconstruction block generator. The generated reconstructed signal can be used for intra-frame prediction of the next block to be processed in the current image, through filtering output as described below, or it can be used for inter-frame prediction of the next image.

[0085] Furthermore, Luminance Mapping with Chroma Scaling (LMCS) can be applied in image decoding processing.

[0086] Filter 350 can improve subjective / objective image quality by applying filtering to the reconstructed signal. For example, filter 350 can generate a modified reconstructed image by applying various filtering methods to the reconstructed image and store the modified reconstructed image in memory 360 (specifically, the DPB of memory 360). Various filtering methods may include, for example, deblocking filtering, adaptive sample shifting, adaptive loop filtering, bilateral filtering, etc.

[0087] The (modified) reconstructed image stored in the DPB of memory 360 can be used as a reference image in inter-frame predictor 332. Memory 360 can store motion information of blocks from which motion information in the current image is derived (or decoded) and / or motion information of reconstructed blocks in the image. The stored motion information can be sent to inter-frame predictor 260 to be used as motion information of spatially adjacent blocks or temporally adjacent blocks. Memory 360 can store reconstructed samples of reconstructed blocks in the current image and can transmit the reconstructed samples to intra-frame predictor 331.

[0088] In this disclosure, the embodiments described in the filter 260, inter-frame predictor 221, and intra-frame predictor 222 of the encoding device 200 can be the same as, or applied to, the filter 350, inter-frame predictor 332, and intra-frame predictor 331 of the decoding device 300, respectively. The same content can also be applied to the inter-frame predictor 332 and intra-frame predictor 331.

[0089] As described above, the encoding device can perform various encoding methods, such as Exponential Golomb coding, Context Adaptive Variable Length Coding (CAVLC), and Context Adaptive Binary Arithmetic Coding (CABAC). Furthermore, the decoding device can decode information in the bitstream based on encoding methods such as Exponential Golomb coding, CAVLC, or CABAC, and output the values ​​of the syntax elements required for image reconstruction and the quantized values ​​of the transform coefficients related to the residuals.

[0090] For example, the above compilation method can be performed as follows.

[0091] Figure 4 An illustrative example is shown of Context Adaptive Binary Arithmetic Coding (CABAC) for encoding syntax elements. For instance, during CABAC encoding, when the input signal is a syntax element rather than a binary value, the encoding device can convert the input signal into a binary value by binarizing the value of the input signal. Alternatively, when the input signal is already a binary value (i.e., when the value of the input signal is binary), binarization may not be performed and can be bypassed. Here, each binary digit 0 or 1 that constitutes the binary value can be called a bin. For example, if the binary string after binarization is 110, then each of 1, 1, and 0 is called a bin. The bin of a syntax element can indicate the value of the syntax element.

[0092] Subsequently, the binarized bins of the syntax elements can be input into either the regular compilation engine or the bypass compilation engine. The regular compilation engine of the encoding device can assign a context model reflecting probability values ​​to the corresponding bin and encode the corresponding bin based on the assigned context model. The regular compilation engine of the encoding device can update the context model of each bin after encoding each bin. The bin encoded as described above can be called a context-compiled bin.

[0093] Simultaneously, when the binarized bins of syntax elements are input to the bypass compilation engine, they can be compiled as follows. For example, the bypass compilation engine of the encoding device omits the process of estimating the probability of the input bin and updating the probability model applied to the bin after encoding. When bypass encoding is applied, the encoding device can improve the encoding speed by encoding the input bin by applying a uniform probability distribution instead of assigning a context model. The bin encoded as described above can be called a bypass bin.

[0094] Entropy decoding can represent a process that is performed in reverse order of the entropy encoding described above.

[0095] For example, when decoding a syntax element based on a context model, the decoding device can receive the bin corresponding to the syntax element via a bitstream. Using this syntax element and decoding information from the target block or neighboring blocks, or information from symbols / bins decoded in previous stages, it determines the context model. Based on the determined context model, it predicts the probability of the received bin occurring and performs arithmetic decoding on the bin to derive the value of the syntax element. Subsequently, the determined context model can be used to update the context model of the next bin to be decoded.

[0096] Alternatively, for example, when a syntax element is bypassed and decoded, the decoding device can receive the bin corresponding to the syntax element via a bitstream and decode the input bin by applying a uniform probability distribution. In this case, the process of deriving the context model of the syntax element and updating the context model applied to the bin after decoding can be omitted.

[0097] As described above, residual samples can be derived into quantized transform coefficients through a transformation and quantization process. These quantized transform coefficients can also be referred to as transform coefficients. In this case, the transform coefficients in the block can be signaled in the form of residual information. The residual information can include residual compilation syntax. That is, the encoding device can configure the residual compilation syntax with the residual information, encode it, and output it as a bitstream, while the decoding device can decode the residual compilation syntax from the bitstream and derive the residual (quantized) transform coefficients. The residual compilation syntax can include syntax elements indicating whether a transform was applied to the corresponding block, the position of the last valid transform coefficient in the block, whether valid transform coefficients exist in sub-blocks, the size / sign of the valid transform coefficients, etc., as will be described later.

[0098] For example, (quantized) transform coefficients (i.e., residual information) can be encoded and / or decoded based on syntax elements such as: transform_skip_flag, last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_suffix, coded_sub_block_flag, sig_coeff_flag, par_level_flag, abs_level_gt1_flag, abs_level_gt3_flag, abs_remainder, coeff_sign_flag, dec_abs_level, and mts_idx. Syntax elements related to residual data encoding / decoding can be represented as shown in the table below.

[0099] [Table 1]

[0100]

[0101]

[0102]

[0103]

[0104] `transform_skip_flag` indicates whether to skip a transformation in the relevant block. `transform_skip_flag` can be a syntax element of the transformation skip flag. The relevant block can be a compile block (CB) or a transform block (TB). CB and TB can be used interchangeably regarding transformation (and quantization) and residual compilation processes. For example, as mentioned above, a residual sample can be derived from a CB, and transform coefficients can be derived (quantized) through transformation and quantization of the residual sample and through residual compilation processes. Information (e.g., syntax elements) can be generated and signaled to effectively indicate the position, magnitude, sign, etc., of the (quantized) transform coefficients. Quantized transform coefficients can be simply referred to as transform coefficients. Typically, when CB is not greater than the maximum TB, the size of CB can be the same as the size of TB, and in this case, the target block to be transformed (and quantized) and residual compiled can be called either CB or TB. Conversely, when CB is greater than the maximum TB, the target block to be transformed (and quantized) and residual compiled can be called TB. In the following, the signaling of syntax elements related to residual compilation on a transform block (TB) basis will be described, but this is just an example, and TB can be used interchangeably with compile blocks (CB as described above).

[0105] In an embodiment, the encoding device can encode the (x,y) position information of the last non-zero transform coefficient in the transform block based on the syntax elements last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, and last_sig_coeff_y_suffix. More specifically, last_sig_coeff_x_prefix represents the prefix of the column position of the last valid coefficient in the scan order within the transform block, last_sig_coeff_y_prefix represents the prefix of the row position of the last valid coefficient in the scan order within the transform block, last_sig_coeff_x_suffix represents the suffix of the column position of the last valid coefficient in the scan order within the transform block, and last_sig_coeff_y_suffix represents the suffix of the row position of the last valid coefficient in the scan order within the transform block. Here, a valid coefficient can represent a non-zero coefficient. Additionally, the scan order can be a right diagonal scan order. Alternatively, the scan order can be a horizontal scan order or a vertical scan order. The scan order can be determined based on whether intra / inter-frame prediction is applied to the target block (CB or CB including TB) and / or a specific intra / inter-frame prediction mode.

[0106] The encoding device can then divide the transform block into 4x4 sub-blocks, and for each 4x4 sub-block, use a 1-bit syntax element coded_sub_block_flag to indicate whether there are non-zero coefficients in the current sub-block.

[0107] If the value of `coded_sub_block_flag` is 0, no more information needs to be sent, and therefore the encoding device can terminate the encoding process for the current sub-block. Conversely, if the value of `coded_sub_block_flag` is 1, the encoding device can continue the encoding process for `sig_coeff_flag`. Since sub-blocks that include the last non-zero coefficient do not need to encode `coded_sub_block_flag` and sub-blocks that include the DC information of the transform block have a high probability of including non-zero coefficients, `coded_sub_block_flag` can be left uncompiled and its value can be assumed to be 1.

[0108] If the value of `coded_sub_block_flag` is 1, and therefore it is determined that there is a non-zero coefficient in the current subblock, the encoding device can encode the `sig_coeff_flag` with binary values ​​according to the reverse scan order. The encoding device can encode the 1-bit syntax element `sig_coeff_flag` for each transform coefficient according to the scan order. If the value of the transform coefficient at the current scan position is not 0, the value of `sig_coeff_flag` can be 1. Here, if the subblock includes the last non-zero coefficient, it is not necessary to encode `sig_coeff_flag` for the last non-zero coefficient, so the compilation process for that subblock can be omitted. Level information compilation can only be performed when `sig_coeff_flag` is 1, and four syntax elements can be used in the level information encoding process. More specifically, each `sig_coeff_flag[xC][yC]` can indicate whether the level (value) of the corresponding transform coefficient at each transform coefficient position (xC, yC) in the current TB is non-zero. In an embodiment, sig_coeff_flag may correspond to an example of a syntax element that indicates whether the quantized transform coefficients are non-zero valid coefficients.

[0109] The level value remaining after encoding sig_coeff_flag can be derived as shown in the following equation. That is, the syntax element remAbsLevel, which indicates the level value to be encoded, can be derived from the following equation.

[0110] [Equation 1]

[0111] remAbsLevel = coeff - 1

[0112] In this paper, coeff refers to the actual transformation coefficient value.

[0113] Additionally, `abs_level_gt1_flag` can indicate whether `remAbsLevel'` at the corresponding scan position (n) is greater than 1. For example, when the value of `abs_level_gt1_flag` is 0, the absolute value of the transform coefficient at the corresponding position can be 1. Furthermore, when the value of `abs_level_gt1_flag` is 1, `remAbsLevel`, indicating the level value to be encoded later, can be derived as shown in the following equation.

[0114] [Equation 2]

[0115] remAbsLeveremAbsLevel-1

[0116] Alternatively, the least effective coefficient (LSB) value of remAbsLevel described in Equation 2 above can be encoded using par_level_flag, as in Equation 3 below.

[0117] [Equation 3]

[0118] par_level_flag=remAbsLevel&1

[0119] In this paper, par_level_flag[n] can indicate the parity of the transformation coefficient level (value) at scan position n.

[0120] The transform coefficient level value remAbsLevel, which is to be encoded after par_level_flag encoding, can be updated as shown in the following equation.

[0121] [Equation 4]

[0122] remAbsLevel′=remAbsLevel>>1

[0123] The `abs_level_gt3_flag` indicates whether the `remAbsLevel` at the corresponding scan position (n) is greater than 3. Encoding of `abs_remainder` can be performed only if `rem_abs_gt3_flag` equals 1. The relationship between the actual transform coefficient values ​​`coeff` and each syntax element can be shown in the following equation.

[0124] [Equation 5]

[0125] |coeff|=sig_coeff_flag+abs_level_gt1_flag+par_level_flag+2*(abs_level_gt3_flag+abs_remainder)

[0126] Additionally, the table below indicates examples relating to Equation 5 above.

[0127] [Table 2]

[0128]

[0129] In this paper, |coeff| indicates the transform coefficient level (value) and can also be indicated as the AbsLevel of the transform coefficient. Additionally, the sign of each coefficient can be encoded using the coeff_sign_flag as a 1-bit sign.

[0130] Additionally, dec_abs_level can represent the intermediate value compiled using Golomb-Rice code at the corresponding scan position (n). dec_abs_level can be signaled for scan positions satisfying the conditions disclosed in Table 2 above. In this case, the absolute value of the corresponding transform coefficient, AbsLevel (i.e., |coeff|), is derived as one of 0, dec_abs_level+1, or dec_abs+level, depending on the conditions.

[0131] Additionally, `coeff_sign_flag` can indicate the sign of the transform coefficients at the corresponding scan position (n). In other words, `coeff_sign_flag` can indicate the sign of the transform coefficients at the corresponding scan position (n).

[0132] Additionally, mts_idx can indicate the transform kernel applied to the residual samples in the current transform block in both the horizontal and vertical directions.

[0133] Figure 5 An example of the transformation coefficients within a 4x4 block is shown.

[0134] Figure 5 The 4x4 block illustrates an example of quantization coefficients. Figure 5 The block shown can be a 4x4 transform block or a 4x4 sub-block of an 8x8, 16x16, 32x32, or 64x64 transform block. Figure 5 A 4x4 block can represent a luminance block or a chrominance block.

[0135] For example, the following shows Figure 5 The example shows the encoding result of the coefficients scanned diagonally.

[0136] [Table 3]

[0137] scan_pos 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 coefficients 0 0 0 0 1 -1 0 2 0 3 -2 -3 4 6 -7 10 sig_coeff_flag 0 0 0 0 1 1 0 1 0 1 1 1 1 1 abs_level_gt1_flag 0 0 1 1 1 1 1 1 parlevel_flag 0 1 0 1 0 0 abs_level_gt3_flag 1 1 abs_remainder 0 1 dec_abs_level 7 10 coeff_sign_flag 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0

[0138] In Table 3, scan_pos represents the position of the coefficients scanned along the anti-diagonal line. scan_pos 15 can represent the transform coefficient scanned first in the 4x4 block, i.e., the transform coefficient at the bottom right corner, while scan_pos 0 can be the transform coefficient scanned last, i.e., the transform coefficient at the top left corner. In one embodiment, scan_pos can also be referred to as the scan position. For example, scan_pos 0 can be referred to as scan position 0.

[0139] At the same time, CABAC offers high performance but suffers from poor throughput. This characteristic stems from CABAC's regular compilation engine, where regular compilation (i.e., encoding via CABAC's regular compilation engine) uses probabilistic states and ranges updated through encoding of previous bins, resulting in high data dependencies and spending considerable time reading probability intervals and determining the current state. CABAC's throughput problem can be addressed by limiting the number of context compilation bins. For example, as shown in Table 1, the sum of bins used to express sig_coeff_flag, abs_level_gt1_flag, and par_level_flag may be limited by the number of bins depending on the size of the corresponding block. In one example, when the corresponding block is 4x4, the sum of bins for sig_coeff_flag, abs_level_gt1_flag, and par_level_flag can be limited to 28. On the other hand, when the corresponding block is 2x2, the sum of bins for sig_coeff_flag, abs_level_gt1_flag, and par_level_flag can be limited to 6. `remBinsPass1` can represent a finite number of bins. Additionally, the number of bins for the context compilation of `abs_level_gt3_flag` can be limited by the size of the corresponding block. For example, in the case of a 4x4 block, the number of bins for `abs_level_gt3_flag` can be limited to 4, while in the case of a 2x2 block, the number of bins for `abs_level_gt3_flag` can be limited to 2. `remBinsPass2` can represent a finite number of bins for `abs_level_gt3_flag`. In this case, when the encoding device compiles the context elements using all the finite number of context compilation bins, the remaining coefficients can be binarized without using CABAC to perform bypass coding using the coefficient binarization method described later.

[0140] Furthermore, as mentioned above, when the input signal is received in the form of syntax elements rather than binary values, the encoding device can convert the input signal into binary values ​​through binarization. Additionally, the decoding device can decode the syntax elements to derive their binarized values ​​(i.e., binarized binaries) and perform inverse binarization on these binarized values ​​to derive the values ​​of the syntax elements. The binarization process can be performed using truncated Rice (TR) binarization, k-order Exp-Golomb (EGk) binarization, or fixed-length (FL) binarization. Furthermore, inverse binarization can refer to the process of deriving the values ​​of the syntax elements by performing TR, EGk, or FL binarization.

[0141] For example, the TR binarization process can be performed as follows.

[0142] The input to the TR binarization process can be a request for TR binarization, along with the cMax and cRiceParam values ​​of the syntax elements. Additionally, the output of the TR binarization process can be the TR binarization of the value symbolVal corresponding to the bin string.

[0143] Specifically, as an example, when a suffix bin string exists for a syntax element, the TR bin string of the syntax element can be a concatenation of the prefix bin string and the suffix bin string; when no suffix bin string exists, the TR bin string of the syntax element can be the prefix bin string. For example, the prefix bin string can be derived as follows.

[0144] The prefix value of symbolVal of a syntax element can be derived to satisfy the following equation.

[0145] [Equation 6]

[0146] prefixVal=symbolVal>>cRiceParam

[0147] In Equation 6, prefixVal represents the prefix value of symbolVal. The prefixes (i.e., prefix bins) of the TR bin strings of the syntax elements can be derived as follows.

[0148] For example, when prefixVal is less than cMax >> cRiceParam, the prefix bin string can be a bit string of length prefixVal+1, indexed by binIdx. In other words, when prefixVal is less than cMax >> cRiceParam, the prefix bin string can be a bit string with prefixVal+1 bits indicated by binIdx. The bin corresponding to a binIdx less than prefixVal can be equal to 1. Conversely, the bin corresponding to a binIdx with the same value as prefixVal can be equal to 0.

[0149] For example, the bin string derived by unary binarization of prefixVal can be given as follows.

[0150] [Table 4]

[0151]

[0152] Meanwhile, when prefixVal is not less than cMax >> cRiceParam, the prefix bin string can be a bit string with length cMax >> cRiceParam and all its bins are 1.

[0153] Additionally, when cMax is greater than symbolVal and cRiceParam is greater than 0, a suffix bin string of a TR bin string can exist. For example, the suffix bin string can be derived as described later.

[0154] The suffix value of the symbolVal of a syntax element can be derived using the following equation.

[0155] [Equation 7]

[0156] suffixVal=symbolVal((prefixVal)<<cRiceParam)

[0157] Here, suffixVal can represent the suffix value of symbolVal.

[0158] The suffix of the TR bin string (i.e., the suffix bin string) can be derived based on the FL binarization process of suffixVal, where the value of cMax is (1 << cRiceParam) - 1.

[0159] Meanwhile, if the value of the input parameter cRiceParam is 0, TR binarization can be a precisely truncated unary binarization, and can use a cMax value equal to the maximum possible value of the syntax element that is always decoded.

[0160] Alternatively, for example, the EGk binarization process can be performed as follows. Syntax elements compiled via ue(v) can be syntax elements compiled via Exp-Golumb.

[0161] In one example, the 0th-order Exp-Golomb (EG0) binarization process can be performed as follows.

[0162] The parsing process of a syntax element can begin by reading bits (including the first non-zero bit) starting from the current position in the bit stream and counting the number of leading bits such as 0. The following table describes the process.

[0163] [Table 5]

[0164]

[0165] Additionally, the variable codeNum can be derived using the following equation.

[0166] [Equation 8]

[0167] codeNum=2 leadingZeroBits -1 + read_bits(leadingZeroBits)

[0168] Here, the value returned by read_bits(leadingZeroBits), that is, the value represented by read_bits(leadingZeroBits), can be interpreted as the binary representation of the unsigned integer of the most significant bit first recorded.

[0169] The following diagram illustrates the structure of the Exp-Golomb code, where the bit string is divided into "prefix" bits and "suffix" bits.

[0170] [Table 6]

[0171] bit string form The scope of codeNum 1 0 <![CDATA[0 1 x0]]> 1..2 <![CDATA[0 0 1 x1 x0]]> 3..6 <![CDATA[0 0 0 1 x2 x1 x0]]> 7..14 <![CDATA[0 0 0 0 1 x3 x2 x1 x0]]> 15..30 <![CDATA[0 0 0 0 0 1 x4 x3 x2 x1 x0]]> 31..62 ... ...

[0172] The "prefix" bits can be the bits parsed as described above to calculate leadingZeroBits and can be represented by 0s or 1s in the bit strings in Table 6. In other words, the bit strings in Table 6 that begin with 0 or 1 can represent the prefix bit strings. The "suffix" bits can be the bits parsed from the calculation of codeNum and can be represented by x in Table 6. i In other words, in Table 6 above, x represents... i The starting bit string can represent the suffix bit string. Here, i can be a value ranging from 0 to LeadZeroBits-1. Additionally, each x... i It can correspond to 0 or 1.

[0173] The following table shows the bit string assigned to codeNum.

[0174] [Table 7]

[0175] Bit string codeNum 1 0 0 1 0 1 0 1 1 2 0 0 1 0 0 3 0 0 1 0 1 4 0 0 1 1 0 5 0 0 1 1 1 6 0 0 0 1 0 0 0 7 0 0 0 1 0 0 1 8 0 0 0 1 0 1 0 9 ... ...

[0176] When the descriptor of a syntax element is ue(v), that is, when a syntax element is compiled by ue(v), the value of the syntax element can be the same as codeNum.

[0177] Alternatively, for example, the EGk binarization process can be performed as follows.

[0178] The input to the EGk binarization process can be a request for EGk binarization. Furthermore, the output of the EGk binarization process can be the EGk binarization of the simbolVal corresponding to the bin string.

[0179] The bit string of the EGk binarization process for symbolVal can be exported as follows.

[0180] [Table 8]

[0181]

[0182] Referring to Table 8 above, the binary value X can be appended to the end of the bin string with each call to put(X). Here, X can be 0 or 1.

[0183] Alternatively, for example, the FL binarization process can be performed as follows.

[0184] The input to the FL binarization process can be a request for FL binarization and the cMax of the syntax element. Additionally, the output of the FL binarization process can be the FL binarization of the symbolVal corresponding to the bin string.

[0185] FL binarization can be performed using a bit string with a fixed length corresponding to the symbol value symbolVal. Here, the fixed-length bits can be an unsigned integer bit string. That is, the bit string of the symbol value symbolVal can be derived by FL binarization, and the bit length (i.e., the number of bits) of the bit string can be fixed.

[0186] For example, a fixed length can be derived using the following equation.

[0187] [Equation 9]

[0188] fixedLength=Ceil(Log2(cMax+1))

[0189] The index of the bin used for FL binarization can be a value that increases sequentially from the most significant bit to the least significant bit. For example, the bin index associated with the most significant bit could be binIdx = 0.

[0190] At the same time, the binarization process for the syntax element abs_remainder in the residual information can be performed as follows.

[0191] The inputs to the binarization processes of `abs_remainder` and `dec_abs_level` are requests for binarization of the syntax element `abs_remainder[n]` or `dec_abs_level[n]`, the color component `cIdx`, the luminance position (x0, y0), the current coefficient scan position (xC, yC), `log2TbWidth` (the binary logarithm of the transform block width), and `log2TbHeight` (the binary logarithm of the transform block height). The luminance position (x0, y0) can indicate the top-left sample of the current luminance transform block based on the top-left luminance sample of the image.

[0192] The output of the binarization process for abs_remainder (or dec_abs_level) can be the binarization of abs_remainder (or dec_abs_level) (i.e., the binarized bin string of abs_remainder (or dec_abs_level). A usable bin string of abs_remainder (or dec_abs_level) can be derived from the binarization process.

[0193] The Rice parameter cRiceParam of abs_remainder (or dec_abs_level) can be derived through a Rice parameter derivation process performed with the color component cIdx, the luminance position (x0, y0), the current coefficient scan position (xC, yC), and the binary logarithm log2TbHeight as the height of the transform block as input. A detailed description of the Rice parameter derivation process will be provided later.

[0194] Alternatively, for example, cMax of abs_remainder (or dec_abs_level) can be derived based on the Rice parameter cRiceParam. cMax can be derived using the following equation.

[0195] [Equation 10]

[0196] cMax=(cRiceParam==1?6:7)<<cRiceParam

[0197] Referring to Equation 10, if the value of cRiceParam is 1, then cMax can be derived as 6 << cRiceParam, while if the value of cRiceParam is not 1, then cMax can be derived as 7 << cRiceParam.

[0198] On the other hand, when a suffix bin string exists, the binarization of abs_remainder (or dec_abs_level), i.e., the bin string of abs_remainder (or dec_abs_level), can be a concatenation of the prefix bin string and the suffix bin string. Conversely, when a suffix bin string does not exist, the bin string of abs_remainder (or dec_abs_level) can be the prefix bin string.

[0199] For example, the prefix bin string can be exported as described later.

[0200] The prefix value of abs_remainder, prefixVal, can be derived using the following equation.

[0201] [Equation 11]

[0202] prefixVal=Min(cMax, abs_remainder[n])

[0203] The prefix of the bin string of abs_remainder (i.e., the prefix bin string) can be derived by the TR binarization process of prefixVal with cMax and cRiceParam as input.

[0204] If the prefix bin string is the same as all bit strings with 1 bit and a length of 4, then the suffix bin string of the bin string of abs_remainder can exist and can be derived as described below.

[0205] The suffix value suffixVal of abs_remainder can be derived using the following equation.

[0206] [Equation 12]

[0207] suffixVal=abs_remainder[n]-cMax

[0208] The suffix bin string of abs_remainder can be derived through the EGk binarization process for suffixVal, where k is set to cRiceParam+1.

[0209] Meanwhile, the process of deriving the Rice parameters described above can be as follows.

[0210] The inputs to the Rice parameter derivation process are the color component index cIdx, the luminance position (x0, y0), the current coefficient scan position (xC, yC), log2TbWidth (the binary logarithm of the transform block width), and log2TbHeight (the binary logarithm of the transform block height). The luminance position (x0, y0) can indicate the top-left sample of the current luminance transform block based on the top-left luminance sample of the image. Furthermore, the output of the Rice parameter derivation process can be the Rice parameter cRiceParam.

[0211] For example, the variable locSumAbs can be derived from the pseudocode shown in the table below, based on the given syntax element sig_coeff_flag[x][y], component index cIdx, and the array AbsLevel[x][C] of the transform block at the top-left luminance position (x0, y0).

[0212] [Table 9]

[0213]

[0214] The Rice parameter cRiceParam can be exported as follows.

[0215] For example, when locSumAbs is less than 12, cRiceParam can be set to 0. Alternatively, when the above condition is not met and locSumAbs is less than 25 (i.e., when locSumAbs is greater than or equal to 12 and less than 25), cRiceParam can be set to 1. Or, when the above condition is not met (i.e., when locSumAbs is greater than or equal to 25), cRiceParam can be set to 2.

[0216] In addition, unlike the embodiment that sends the above-mentioned syntax elements, a method of notifying tu_mts_idx by signaling can be proposed.

[0217] Specifically, the method of signaling tu_mts_idx in the existing VVC draft 3 can be compared with the proposed method of signaling tu_mts_idx as follows.

[0218] [Table 10]

[0219]

[0220] As shown in Table 10, according to the existing scheme, the MTS flag of the current block is first parsed, then the transform skip flag is parsed, and then the MTS index compilation can be performed. Here, compilation for the MTS index can be performed by fixed-length binarization, and the fixed bit length of the MTS index can be 2.

[0221] Alternatively, according to the proposed scheme, the MTS index can be compiled without separately resolving the transform skip flag and the MTS flag, and truncated unary binarization can be used to compile the MTS index. Here, the MTS index can indicate whether a transform is applied to the residual information of the current block, and can also indicate whether MTS is applied. That is, in the proposed scheme, a scheme can be proposed to signal the transform skip flag, the MTS flag, and the MTS index as a single syntax element. In the proposed scheme, the first bin of the MTS index can indicate whether a transform is applied to the residual information of the current block, and the second bin of the MTS index can indicate whether MTS is applied and the applied transform kernel.

[0222] The meanings indicated by the values ​​of the MTS index and the binarized values ​​in the proposed method can be shown in the table below.

[0223] [Table 11]

[0224]

[0225] For example, when the MTS index value is 0, the MTS index indicates that a transform is applied to the current block, but no MTS is applied, and the horizontal and vertical transform kernel types are DCT-2. Alternatively, when the MTS index value is 1, the MTS index indicates that no transform is applied to the current block (i.e., no MTS is applied and no transform kernel type is indicated). Furthermore, when the MTS index value is 2, the MTS index indicates that a transform and MTS are applied to the current block, and the horizontal and vertical transform kernel types are DST-7. Additionally, when the MTS index value is 3, the MTS index indicates that a transform and MTS are applied to the current block, the horizontal transform kernel type is DCT-8, and the vertical transform kernel type is DST-7. Finally, when the MTS index value is 4, the MTS index indicates that a transform and MTS are applied to the current block, the horizontal transform kernel type is DST-7, and the vertical transform kernel type is DCT-8. Additionally, when the MTS index value is 5, the MTS index can indicate the application of transform and MTS to the current block, and the horizontal transform kernel type and vertical transform kernel type are DCT-8.

[0226] Alternatively, another example of the meaning indicated by the value of the MTS index and the binarized value can be shown in the table below.

[0227] [Table 12]

[0228]

[0229] For example, when the MTS index value is 0, the MTS index indicates that no transformation is applied to the current block (i.e., no MTS is applied and no transformation kernel type is indicated). Alternatively, when the MTS index value is 1, the MTS index indicates that a transformation is applied to the current block, no MTS is applied, and the horizontal and vertical transformation kernel types are DCT-2. Alternatively, when the MTS index value is 2, the MTS index indicates that a transformation and MTS are applied to the current block, and the horizontal and vertical transformation kernel types are DST-7. Alternatively, when the MTS index value is 3, the MTS index indicates that a transformation and MTS are applied to the current block, the horizontal transformation kernel type is DCT-8, and the vertical transformation kernel type is DST-7. Alternatively, when the MTS index value is 4, the MTS index indicates that a transformation and MTS are applied to the current block, the horizontal transformation kernel type is DST-7, and the vertical transformation kernel type is DCT-8. Additionally, when the MTS index value is 5, the MTS index can indicate the application of transform and MTS to the current block, and the horizontal transform kernel type and vertical transform kernel type are DCT-8.

[0230] Meanwhile, the method to specify the context index increment ctxInc for each bin of tu_mts_idx without changing the number of context models can be shown in the table below.

[0231] [Table 13]

[0232]

[0233] In addition, this document proposes a method to modify existing residual compilation methods (described later) to apply statistical and signal properties to residual compilation that represent the transformation skip level of the quantized prediction residual (i.e., the residual in the spatial domain).

[0234] Locations without the last non-zero transform coefficients: Since the residual signal (i.e., the residual sample) reflects the spatial residual and does not perform energy compression via transform after prediction without a transform skip, the high probability of zeros at the end or invalid levels at the lower right of the transform block may no longer occur. Therefore, in this case, signaling information about the scan position of the last non-zero transform coefficients can be omitted. Instead, the first sub-block to be compiled first can be the lower right sub-block in the transform block. Meanwhile, the non-zero transform coefficients can be referred to as valid coefficients.

[0235] Sub-block CBF: In the absence of signaling information about the scan position of the last non-zero transform coefficients, transform skip is applied, and the CBF signaling for sub-blocks with coded_sub_block_flag should be modified as follows.

[0236] Due to quantization, the aforementioned non-critical level sequences may still occur locally within the transform block. Therefore, information regarding the scan position of the last non-zero transform coefficients can be removed as described above, and the coded_sub_block_flag can be compiled for all sub-blocks.

[0237] Additionally, the `coded_sub_block_flag` for the sub-block at the DC frequency position (top-left sub-block) can indicate special cases. For example, in VVC draft 3, the `coded_sub_block_flag` of the top-left sub-block is not signaled and can always be derived to be equal to 1. When the scan position of the last non-zero transform coefficient is located in a sub-block that is not the top-left sub-block, it can indicate that at least one valid level exists outside the DC sub-block (i.e., the top-left sub-block). As a result, the `coded_sub_block_flag` for the DC sub-block is derived to be 1, but can include only 0 / invalid levels. As mentioned above, if transform skipping is applied to the current block and there is no information about the scan position of the last non-zero transform coefficient, the `coded_sub_block_flag` of each sub-block can be signaled. Here, the `coded_sub_block_flag` of the DC sub-block can be included, except when the `coded_sub_block_flag` of all sub-blocks except the DC sub-block is already 0. In this case, the `coded_sub_block_flag` of the DC sub-block can be derived to be equal to 1 (inferDcSbCbf = 1). Therefore, since the DC subblock should have at least one valid level, if all sig_coeff_flags except for the sig_coeff_flag at the first position (0,0) in the DC subblock are 0, then the sig_coeff_flag at the first position (0,0) is not signaled and can be derived to be equal to 1 (inferSbDcSigCoeffFlag = 1).

[0238] Additionally, the context modeling of coded_sub_block_flag can be modified. For example, the context model index can be calculated by summing the coded_sub_block_flag of the right sub-block of the current sub-block and the coded_sub_block_flag of the next sub-block of the current sub-block, as well as by logically separating coded_sub_block_flag.

[0239] sig_coeff_flag context modeling: The local template for sig_coeff_flag context modeling can be modified to include only the right position NB0 and the lower position NB1 of the current scan position. The context model offset can be derived as the number of valid outer positions: sig_coeff_flag[NB0] + sig_coeff_flag[NB1]. Therefore, the selection of different context sets based on the diagonal d of the current transform block can be eliminated. As a result, three context models and a single context model can be set to compile sig_coeff_flag.

[0240] abs_level_gt1_flag and par_level_flag context modeling: A single context model can be used for both abs_level_gt1_flag and par_level_flag.

[0241] Compiling abs_remainder: The empirical distribution of the residual absolute level, after the transformation skips it, still conforms to a Laplace or geometric distribution, but instabilities greater than the absolute level of the transform coefficients may exist. In particular, the covariance of the residual absolute level may be higher within a continuously realized window. Therefore, the binarization and context modeling of abs_remainder can be modified as follows.

[0242] For example, a higher cutoff value can be used for binarization of `abs_remainder`. This allows for higher compression efficiency in the transition points from compilation using `sig_coeff_flag`, `abs_level_gt1_flag`, `par_level_flag`, and `abs_level_gt3_flag` to the Rice code for `abs_remainder`, as well as in the dedicated context model for each bin location. Increasing the cutoff value may result in more flags "greater than X" (e.g., `abs_level_gt5_flag`, `abs_level_gt7_flag`, etc.) until the cutoff value is reached. The cutoff value can be fixed at 5 (`numGtFlags = 5`).

[0243] Additionally, the template used for exporting the Rice parameters can be modified. That is, only the right and lower outer edges of the current scan position can be considered as local templates for modeling the sig_coeff_flag context.

[0244] coeff_sign_flag Context Modeling: Due to instabilities within the symbol sequence and the frequent bias in prediction residuals, a context model can be used to compile symbol-related information even when the global empirical distribution is nearly uniform. A single dedicated context model can be used for compiling symbol-related information and can be used to parse symbol-related information after sig_coeff_flag and maintained along with all context compilation bins.

[0245] Reduction of the context compilation bin: The transmission of syntax elements (i.e., sig_coeff_flag, abs_level_gt1_flag, and par_level_flag) in the first scan may not change. However, the constraint on the maximum value of the context compilation bin (CCB) per sample can be removed and can be adjusted differently. In the case of CCB > k, the CCB reduction can be derived by specifying an invalid mode. Here, k can be a positive integer. For example, in the case of normal level compilation mode, k can be 2 (k = 2). The constraints mentioned above can correspond to a reduction in the quantization space.

[0246] Syntax elements related to residual data compiled by applying the above modifications can be represented as shown in the table below.

[0247] [Table 14]

[0248]

[0249] Furthermore, as shown in Table 1 above, according to the VVC standard, before encoding / decoding the residual signal (i.e., residual information), it is possible to first send whether to apply the transform to the corresponding block. In other words, before parsing the residual information of the current block, the transform skip flag (i.e., transform_skip_flag) indicating whether to apply the transform can be parsed first. The transform skip flag can be called the transform or non-transform flag or the transform application flag.

[0250] Data is compressed (data compression) and delivered to the decoding device by expressing the correlation between residual signals in the transform domain. However, if the correlation between residual signals is insufficient, data compression may not occur adequately. In this case, the transformation process, which involves complex calculations, can be omitted, and the residual signals in the pixel domain (spatial domain) can be sent to the decoding device. Since the residual signals in the pixel domain without transformation have different characteristics than those in the general transform domain (e.g., the distribution of residual signals, the absolute level of each residual signal, etc.), a residual signal encoding / decoding method for efficiently delivering signals to the decoding device has been proposed.

[0251] Figure 6An exemplary decoding device is shown for performing the proposed method of transmitting residual signals of the pixel domain.

[0252] Transform skip flags can be sent on a transform block basis. Referring to Table 1 above, the transform skip flag can be resolved by restricting it to a specific block size. That is, referring to Table 1, the transform skip flag can be resolved only for transform blocks whose block size is equal to or smaller than a specific size. For example, the transform skip flag for the current transform block can be resolved when the current transform block size is less than or equal to 4x4.

[0253] In this regard, as an example, the document proposes an embodiment in which the size of the block used to determine whether to parse the transform skip flag is configured differently. Specifically, the sizes of Log2TbWidth and log2TbHeight can be determined by variables wN and hN, and according to existing schemes, wN and hN can be selected from one of the following.

[0254] -wN={2,3,4,5,6}

[0255] -hN={2,3,4,5,6}

[0256] In other words, wN can be selected from one of 2, 3, 4, 5, and 6, and hN can be selected from one of 2, 3, 4, 5, and 6.

[0257] The method for parsing the transformation skip flag according to this embodiment can be represented as shown in the table below.

[0258] [Table 15]

[0259]

[0260] According to the embodiment disclosed in Table 15, the transform skip flag of the current block can be parsed when log2TbWidth, indicating the width of the current block (i.e., the current transform block), is equal to or less than wN, and log2TbHeight, indicating the height of the current block, is equal to or less than hN. The method for decoding the residual signal of the current block can be determined based on the transform skip flag. Through the proposed embodiment, the complexity of the entropy decoding process can be reduced and coding efficiency can be improved by efficiently processing signals with different statistical characteristics.

[0261] Alternatively, referring to Table 1 above, an embodiment can be proposed to resolve the transform skip flag by restricting it to a specific block size, but the condition used to determine whether to resolve the transform skip flag is defined as the number of samples in the block rather than the width and height information of the corresponding block. That is, for example, a method can be proposed to use the product of log2TbWidth and log2TbHeight as the condition for determining whether to resolve the transform_skip_flag syntax element.

[0262] log2TbWidth and log2TbHeight can be selected from one of the following.

[0263] -log2TbWidth={1,2,3,4,5,6}

[0264] -log2TbHeight={1,2,3,4,5,6}

[0265] In other words, log2TbWidth can be selected from one of 1, 2, 3, 4, 5 and 6, and log2TbHeight can be selected from one of 1, 2, 3, 4, 5 and 6.

[0266] Figure 7a and Figure 7b An exemplary embodiment is shown that determines whether to parse the transform skip flag based on the number of samples in the current block, and a decoding device for performing this embodiment is illustrated.

[0267] Reference Figure 7a The decoding device can determine whether it is permissible to skip the transformation of the current block in the high-level syntax (S700). When it is permissible to skip the transformation of the current block in the high-level syntax, the decoding device can determine whether the value of the syntax element cu_mts_flag is 0 (S710).

[0268] When the value of cu_mts_flag is 0, the decoding device can determine whether the product of log2TbWidth and log2TbHeight of the current block is equal to or less than the threshold (S720). In other words, the decoding device can determine whether the number of samples in the current block is equal to or less than the threshold.

[0269] When the product of log2TbWidth and log2TbHeight is equal to or less than the threshold, the decoding device can resolve the value of the syntax element transform_skip_flag of the transform skip flag to 1 (S730).

[0270] Meanwhile, when the conditions of steps S700 to S720 are not met, the decoding device can export the value of the syntax element transform_skip_flag of the transform skip flag as 0 (S740).

[0271] Figure 7b An exemplary decoding apparatus is shown for performing an embodiment of determining whether to transform a block based on the number of samples in the block. (Refer to...) Figure 7b The decoding device can determine whether to use the transform skip flag for block parsing based on whether transform skipping is allowed in the high-level grammar, block size information, and whether MTS is applied.

[0272] When determining whether to transform based on the number of samples in a block, blocks of various shapes can be included in the transform exclusion block compared to controlling transformation by the width and height of the block. For example, if log2TbWidth and log2TbHeight are both defined as 2 in the embodiment described above that controls whether to transform based on the width and height of the block, then blocks of only size 2x4, blocks of size 4x2, and blocks of size 4x4 can be included in the transform exclusion block. However, if transformation is controlled by the number of samples, blocks of size 2x8 and blocks of size 8x2 can also be included as transform exclusion blocks.

[0273] The method for decoding the residual signal can be determined based on the transform skip flag. Furthermore, by efficiently processing signals with different statistical properties via the proposed embodiment, the complexity of the entropy decoding process can be reduced and compilation efficiency can be improved.

[0274] For example, the following embodiments can be proposed to encode and decode residual signals taking into account statistical properties without applying transformations to the residual signals of the current block.

[0275] Typically, in the case of a transform block that has undergone transformation and quantization (i.e., transform coefficients that have undergone transformation and quantization), the energy is concentrated near the upper left of the transform block by the transformation, and the energy level decreases towards the lower right (high-frequency region) by quantization. Considering the aforementioned characteristics, as Figure 5 As shown, a diagonal scan technique has been introduced for efficient residual coding. However, in the case of transform skip blocks (i.e., transform blocks that include residual coefficients without applying the transform), energy can be evenly distributed throughout the block, rather than concentrated in the top left corner, and the level size is also random. Therefore, using a diagonal scan technique for coding may be inefficient. Therefore, this embodiment proposes a residual scan scheme suitable for the characteristics of transform skip blocks. Here, residual coefficients can refer to transform coefficients.

[0276] Furthermore, as another characteristic of transform skip blocks, when the prediction mode applied to the transform skip block to be compiled is intra-frame prediction mode, the size of the residual samples increases in the direction of the larger distance between the predicted sample and the reference sample, towards the lower right. Considering these characteristics, this embodiment proposes a method in which the residual signals are rearranged and encoded such that they can be scanned from the upper left of the transform block, and the decoding device parses the residual signals and rearranges them back to their original positions. That is, this embodiment proposes a method in which the residual signals are rearranged and encoded such that residual signals with large sizes can be scanned from the upper left of the transform block, and the decoding device parses the residual signals and rearranges them back to their original positions. As a similar effect, a method of defining a new scanning method in the residual signal encoding and decoding steps can be considered. However, when rearranging the residual signals as in the method proposed in this embodiment, existing residual coding modules can be used without modification.

[0277] One point to consider when rearranging residuals while maintaining existing residual compilation modules is that the scan order should be defined from the top left region to the bottom right region.

[0278] As an example of a rearrangement method, a method can be defined to rotate the current block by 180 degrees.

[0279] Figure 8 The residual coefficients of the current block after a 180-degree rotation rearrangement method are shown as an example.

[0280] Figure 8 The numbers in the current block shown indicate the pixel positions within the block according to the raster scan order. (See reference...) Figure 8 The residual coefficients in the upper left position can be rearranged to the lower right position, which is a 180-degree rotation. (See reference...) Figure 8 The residual coefficients can be rearranged to a position symmetrical about the center of the transform block by a 180-degree rotation. After the rearrangement, the general residual coefficient scan order can be applied, and due to the rearrangement, the residual coefficients located in the lower right can be considered first, and the residual coefficients located in the upper left can be scanned later.

[0281] Alternatively, as another example of a rearrangement method, a method for mirroring the current block can be defined. Furthermore, this method can be divided into anti-diagonal mirroring and main diagonal mirroring based on the direction of the mirror.

[0282] Figure 9 The residual coefficients of the current block for which the mirror rearrangement method has been applied are shown as an example. Figure 9 (a) illustrates an example of rearranging the residual coefficients of the current block by anti-diagonal mirroring, and Figure 9 Example (b) illustrates an example of rearranging the residual coefficients of the current block by mirroring the main diagonal.

[0283] Reference Figure 9 (a) The residual coefficients can be rearranged to positions symmetrical to the upper right diagonal of the current block using a reverse diagonal mirroring process. Here, the upper right diagonal can refer to the diagonal in the upper right direction passing through the center of the current block. For example, the residual coefficient at the upper left position can be rearranged to the lower right position, which is a reverse diagonal mirror. Alternatively, for example, the #1 residual coefficient (i.e., the residual coefficient adjacent to the right of the residual coefficient at the upper left position) can be rearranged to the position adjacent to the lower right position, which is a reverse diagonal mirror. That is, when the width and height of the current block are 4 and the x and y components at the upper left sample position of the current block are 0, the residual coefficient at position (1,0) can be rearranged to position (3,3), which is a reverse diagonal mirror.

[0284] Additionally, refer to Figure 9 (b) The residual coefficients can be rearranged to positions symmetrical to the upper left diagonal of the current block using a diagonal mirroring process. Here, the upper left diagonal can refer to the upper left diagonal that passes through the center of the current block. For example, the residual coefficient at the upper right position can be rearranged to the lower left position, which is a diagonal mirror. Alternatively, for example, the #1 residual coefficient (i.e., the residual coefficient adjacent to the right of the residual coefficient in the upper left position) can be rearranged to the lower side of the upper left position, which is a diagonal mirror. That is, when the width and height of the current block are 4 and the x and y components of the upper left sample position of the current block are 0, the residual coefficient at position (1,0) can be rearranged to position (0,1), which is a diagonal mirror.

[0285] Alternatively, as another example of a rearrangement method, a method can be defined to flip the current block. Furthermore, vertical and horizontal flips can be defined separately based on the axis used as the flip reference.

[0286] Figure 10 The residual coefficients of the current block when the flip rearrangement method is applied are shown as an example. Figure 10 (a) illustrates an example of rearranging the residual coefficients of the current block by vertical flipping, and Figure 9 (b) illustrates an example of rearranging the residual coefficients of the current block by horizontal flipping.

[0287] Reference Figure 10(a) The residual coefficients can be rearranged to positions symmetrical about the vertical axis of the current block using a vertical flip rearrangement process. Here, the vertical axis can represent a vertical line passing through the center of the current block. For example, the residual coefficient in the upper left position can be rearranged to the upper right position, which is a vertically flipped position. Alternatively, for example, the #1 residual coefficient (i.e., the residual coefficient adjacent to the right of the residual coefficient in the upper left position) can be rearranged to the left adjacent to the residual coefficient in the upper right position, which is a vertically flipped position. That is, when the width and height of the current block are 4 and the x and y components of the upper left sample position of the current block are 0, the residual coefficient at position (1,0) can be rearranged to position (2,0), which is a vertically flipped position.

[0288] Additionally, refer to Figure 10 (b) The residual coefficients can be rearranged to positions symmetrical about the horizontal axis of the transformed block by a horizontal flipping rearrangement process. Here, the horizontal axis can represent a horizontal line passing through the center of the current block. For example, the residual coefficient in the upper right position can be rearranged to the lower right position, which is a horizontally flipped position. Alternatively, for example, the #1 residual coefficient (i.e., the residual coefficient adjacent to the right of the residual coefficient in the upper left position) can be rearranged to the right adjacent to the lower left position, which is a horizontally flipped position. That is, when the width and height of the current block are 4 and the x and y components of the upper left sample position of the current block are 0, the residual coefficient at position (1,0) can be rearranged to position (1,3), which is a horizontally flipped position.

[0289] Alternatively, as another example of a rearrangement method, a method can be proposed to rearrange the residual coefficients of the current block based on the distance from the intra-frame predicted reference sample. For example, layers can be defined in the TU based on the distance between the reference sample and the predicted block, and the encoding device can determine whether to scan the residual coefficients in each layer with lateral priority or longitudinal priority, and rearrange the residual coefficients in reverse raster order (from right to left, bottom to top) according to the scan order. That is, the layers of the current block can be defined based on the distance from the reference sample, and the encoding / decoding device can determine the scan order of the residual coefficients in each layer as lateral priority or longitudinal priority, and rearrange the residual coefficients in reverse raster order (from right to left, bottom to top) according to the scan order. Meanwhile, the decoding device can derive the existing residual coefficients by performing the above rearrangement process in reverse order.

[0290] Figure 11 An example is shown of the residual coefficients of the current block to which the above embodiments are applied, wherein layers are derived based on the distance from the reference sample and rearranged at each location according to the reverse grating order. Figure 11(a) illustrates an example of rearranging the residual coefficients in each layer at positions according to the reverse raster order, in a lateral priority scan order, and Figure 11 (b) illustrates an example of rearranging the residual coefficients in each layer at each position according to the reverse raster order, with the longitudinal priority scanning order.

[0291] Reference Figure 11 The current block comprises a first layer adjacent to at least one reference sample, a second layer at a distance of 1 from the nearest reference sample, a third layer at a distance of 2 from the nearest reference sample, and a fourth layer at a distance of 3 from the nearest reference sample. That is, the first layer may include residual coefficients adjacent to at least one reference sample (e.g., Figure 11 The example shows the residual coefficients #0 to #4, #8, and #12 of the current block before rearrangement (in other words, the first layer may include residual coefficients at a distance of 1 from the nearest reference sample), and the second layer may include residual coefficients at a distance of 2 from the nearest reference sample (e.g., Figure 11 The example shown in the image illustrates the residual coefficients #5 to #7, #9, and #13 of the current block before rearrangement. The third layer may include residual coefficients at a distance of 3 from the nearest reference sample (e.g., Figure 11 The example shows the #10 and #11 residual coefficients and the #14 residual coefficient of the current block before the rearrangement, and the fourth layer can include residual coefficients at a distance of 4 from the nearest reference sample (e.g., Figure 11 The example shown is the #15 residual factor of the current block before rearrangement.

[0292] When the layer of the current block is defined as described above, the encoding device may determine one of the horizontal priority scan and the vertical priority scan as the scanning method for the layer of the current block.

[0293] For example, when lateral priority scanning is determined as the scanning method for the layer of the current block, it can be as follows: Figure 11 The residual coefficients are rearranged as shown in (a).

[0294] Specifically, the encoding device can scan sequentially from the first layer to the fourth layer, scan from the residual coefficient at the upper left position in the corresponding layer to the vertical side, scan all residual coefficients on the horizontal side, and scan the remaining residual coefficients on the vertical side from top to bottom.

[0295] For example, the horizontal residual coefficients in the first layer may include residual coefficients #0 to #3, while the vertical residual coefficients in the first layer may include residual coefficients #4, #8, and #12. The encoding / decoding device can scan the horizontal residual coefficients in the first layer sequentially from left to right (scanning in the order of residual coefficients #1, #2, and #3), and then scan the vertical residual coefficients in the first layer sequentially from top to bottom (scanning in the order of residual coefficients #4, #8, and #12). Next, the second layer can be scanned. The horizontal residual coefficients in the second layer may include residual coefficients #5 to #7, and the vertical residual coefficients in the second layer may include residual coefficients #9 and #13. The encoding device can scan the horizontal residual coefficients in the second layer from left to right (scanning in the order of residual coefficients #5, #6, and #7), and then scan the horizontal residual coefficients in the second layer from top to bottom (scanning in the order of residual coefficients #9 and #13). Next, the third layer can be scanned. The horizontal residual coefficients in the third layer can include residual coefficients #10 and #11, while the vertical residual coefficients in the third layer can include residual coefficient #14. The encoding device can scan the horizontal residual coefficients in the third layer sequentially from left to right (scanning in the order of residual coefficients #10 and #11), and then scan the vertical residual coefficients in the third layer from top to bottom (scanning in the order of residual coefficient #14). Next, the fourth layer can be scanned. The horizontal residual coefficients in the fourth layer can include residual coefficient #15. The encoding device can scan the horizontal residual coefficients in the fourth layer sequentially from left to right (scanning residual coefficient #15).

[0296] Subsequently, refer to Figure 11 (a) The encoding device can rearrange the residual coefficients in the scan order according to the reverse raster sequence (from right to left, from bottom to top). The scan order of the residual coefficients can be the order of residual coefficients #0, #1, #2, #3, #4, #8, #12, #5, #6, #7, #9, #13, #10, #11, #14, and #15. The residual coefficients can be rearranged in the current block according to the position in the reverse raster sequence. For example, residual coefficient #0 can be rearranged in the bottom right position; residual coefficients #1, #2, and #3 can be rearranged to the left of the bottom right position; residual coefficients #4, #8, #12, and #5 can be rearranged from right to left in the top row of the bottom right position (i.e., the third row of the current block); residual coefficients #6, #7, #9, and #13 can be rearranged from right to left in the second row of the current block; and residual coefficients #10, #11, #14, and #15 can be rearranged from right to left in the first row of the current block.

[0297] Additionally, for example, when a vertical priority scan is determined as the scanning method for the layer of the current block, such as Figure 11Perform the rearrangement of residual coefficients as shown in (b).

[0298] Specifically, the encoding device can scan sequentially from the first layer to the fourth layer, and can scan from the residual coefficient at the upper left position in the corresponding layer to the vertical side, can scan all the residual coefficients on the vertical side, and can scan the remaining residual coefficients on the vertical side from top to bottom.

[0299] For example, the vertical residual coefficients in the first layer may include residual coefficients #0, #4, #8, and #12, while the horizontal residual coefficients in the first layer may include residual coefficients #1 to #3. The encoding device can scan the vertical residual coefficients in the first layer sequentially from top to bottom (scanning in the order of residual coefficients #0, #4, #8, and #12), and then scan the horizontal residual coefficients in the first layer from left to right (scanning in the order of residual coefficients #1, #2, and #3). Next, the second layer can be scanned. The vertical residual coefficients in the second layer may include residual coefficients #5, #9, and #13, while the horizontal residual coefficients in the second layer may include residual coefficients #6 and #7. The encoding device can scan the vertical residual coefficients in the second layer sequentially from top to bottom (scanning in the order of residual coefficients #5, #9, and #13), and then scan the horizontal residual coefficients in the second layer from left to right (scanning in the order of residual coefficients #6 and #7). Next, the third layer can be scanned. The vertical residual coefficients in the third layer can include residual coefficients #10 and #14, while the horizontal residual coefficients in the third layer can include residual coefficient #11. The encoding device can scan the vertical residual coefficients in the third layer from top to bottom (scanning in the order of residual coefficients #10 and #14), and then scan the horizontal residual coefficients in the third layer from left to right (scanning in the order of residual coefficient #11). Next, the fourth layer can be scanned. The vertical residual coefficients in the fourth layer can include residual coefficient #15. The encoding device can scan the vertical residual coefficients in the fourth layer from top to bottom in the order of residual coefficient #15.

[0300] Subsequently, refer to Figure 11(b) The encoding device can rearrange the residual coefficients in the scan order according to the reverse raster sequence (from right to left, from bottom to top). The scan order of the residual coefficients can be the order of residual coefficients #0, #4, #8, #12, #1, #2, #3, #5, #9, #13, #6, #7, #10, #14, #11, and #15. The residual coefficients can be rearranged in the current block according to the position in the reverse raster sequence. For example, residual coefficient #0 can be rearranged to the bottom right position, and residual coefficients #4, #8, and #12 can be rearranged to the left of the bottom right position. Residual coefficients #1, #2, #3, and #5 can be rearranged from right to left in the upper row of the bottom right position (the third row of the current block). Residual coefficients #9, #13, #6, and #7 can be rearranged from right to left in the second row of the current block. Residual coefficients #10, #14, #11, and #15 can be rearranged from right to left in the first row of the current block.

[0301] Alternatively, another embodiment can be proposed that rearranges the residual coefficients of the current block based on the distance from the intra-frame predicted reference sample. For example, layers can be defined in the TU based on the distance between the reference sample and the predicted block, and the encoding device can determine whether to scan the residual coefficients in each layer with lateral priority or longitudinal priority, and rearrange the residual coefficients in a diagonal scan order according to the scan order. That is, the layers of the current block can be defined based on the distance from the reference sample, and the encoding device can determine the scan order of the residual coefficients in each layer as lateral priority or longitudinal priority, and rearrange the residual coefficients in positions in a diagonal scan order according to the scan order. Meanwhile, the decoding device can derive the existing residual coefficients by performing the above rearrangement process in reverse order.

[0302] Figure 12 An exemplary illustration shows the residual coefficients of the current block applying the above embodiments, wherein layers are derived based on the distance from the reference sample and rearranged at each location according to the diagonal scan order. Figure 12 (a) illustrates an example of rearranging the residual coefficients in each layer at positions according to the diagonal scan order, with the transverse scan order as the priority. Figure 12 (b) illustrates an example of rearranging the residual coefficients in each layer at each position according to the diagonal scan order, with the longitudinal priority scan order.

[0303] Reference Figure 12The current block comprises a first layer adjacent to at least one reference sample, a second layer at a distance of 1 from the nearest reference sample, a third layer at a distance of 2 from the nearest reference sample, and a fourth layer at a distance of 3 from the nearest reference sample. That is, the first layer may include residual coefficients adjacent to at least one reference sample (e.g., Figure 12 The example shows the residual coefficients #0 to #4, #8, and #12 of the current block before rearrangement (in other words, the first layer may include residual coefficients at a distance of 1 from the nearest reference sample), and the second layer may include residual coefficients at a distance of 2 from the nearest reference sample (e.g., Figure 12 The example shown in the image illustrates the residual coefficients #5 to #7, #9, and #13 of the current block before rearrangement. The third layer may include residual coefficients at a distance of 3 from the nearest reference sample (e.g., Figure 12 The example shows the #10 and #11 residual coefficients and the #14 residual coefficient of the current block before the rearrangement, and the fourth layer can include residual coefficients at a distance of 4 from the nearest reference sample (e.g., Figure 12 The example shown is the #15 residual factor of the current block before rearrangement.

[0304] When the layer of the current block is defined as described above, the encoding device may determine one of the horizontal priority scan and the vertical priority scan as the scanning method for the layer of the current block.

[0305] For example, when lateral priority scanning is determined as the scanning method for the layer of the current block, it can be as follows: Figure 12 The residual coefficients are rearranged as shown in (a).

[0306] Specifically, the encoding device can scan sequentially from the first layer to the fourth layer, scan from the residual coefficient at the upper left position in the corresponding layer to the vertical side, scan all residual coefficients on the horizontal side, and scan the remaining residual coefficients on the vertical side from top to bottom.

[0307] For example, the horizontal residual coefficients in the first layer may include residual coefficients #0 to #3, while the vertical residual coefficients in the first layer may include residual coefficients #4, #8, and #12. The encoding device can scan the horizontal residual coefficients in the first layer sequentially from left to right (scanning in the order of residual coefficients #1, #2, and #3), and then the encoding / decoding device can scan the vertical residual coefficients in the first layer sequentially from top to bottom (scanning in the order of residual coefficients #4, #8, and #12). Next, the second layer can be scanned. The horizontal residual coefficients in the second layer may include residual coefficients #5 to #7, while the vertical residual coefficients in the second layer may include residual coefficients #9 and #13. The encoding device can scan the horizontal residual coefficients in the second layer from left to right (scanning in the order of residual coefficients #5, #6, and #7), and then scan the horizontal residual coefficients in the second layer from top to bottom (scanning in the order of residual coefficients #9 and #13). Next, the third layer can be scanned. The horizontal residual coefficients in the third layer can include residual coefficients #10 and #11, while the vertical residual coefficients in the third layer can include residual coefficient #14. The encoding device can scan the horizontal residual coefficients in the third layer sequentially from left to right (scanning in the order of residual coefficients #10 and #11), and then scan the vertical residual coefficients in the third layer from top to bottom (scanning in the order of residual coefficient #14). Next, the fourth layer can be scanned. The horizontal residual coefficients in the fourth layer can include residual coefficient #15. The encoding device can scan the horizontal residual coefficients in the fourth layer sequentially from left to right (scanning residual coefficient #15).

[0308] Subsequently, refer to Figure 12(a) The encoding device can rearrange the residual coefficients according to the scan order (from top right to bottom left, or from bottom right to top left). The scan order of the residual coefficients can be the order of residual coefficients #0, #1, #2, #3, #4, #8, #12, #5, #6, #7, #9, #13, #10, #11, #14, and #15. The residual coefficients can be rearranged in the current block according to the scan order and their positions based on the diagonal scan order. For example, residual coefficient #0 can be rearranged to the lower right position on the first upper right diagonal; residual coefficients #1 and #2 can be rearranged sequentially from the upper right to the upper left in the second upper right diagonal of the current block (i.e., from the upper left to the upper right diagonal of the first upper right diagonal); residual coefficients #3, #4, and #8 can be rearranged sequentially from the upper right to the upper left in the third upper right diagonal (i.e., from the upper left to the upper right diagonal of the second upper right diagonal); and residual coefficients #12, #5, #6, and #7 can be rearranged sequentially in the fourth upper right diagonal (i.e., from the upper left to the upper right diagonal of the third diagonal). In the upper right diagonal (from the upper left to the upper right diagonal), residual coefficients #9, #13, and #10 can be rearranged sequentially from the upper right to the upper left in the fifth upper right diagonal (i.e., from the upper left to the upper right diagonal of the fourth upper right diagonal). Residual coefficients #11 and #14 can be rearranged sequentially from the upper right to the upper left in the sixth upper right diagonal (i.e., from the upper left to the upper right diagonal of the fifth upper left diagonal). Residual coefficient #15 can be rearranged in the upper left position of the seventh upper right diagonal (i.e., from the upper left to the upper right diagonal of the sixth upper right diagonal).

[0309] Additionally, for example, when a vertical priority scan is determined as the scanning method for the layer of the current block, such as Figure 12 Perform the rearrangement of residual coefficients as shown in (b).

[0310] Specifically, the encoding device can scan sequentially from the first layer to the fourth layer, and can scan from the residual coefficient at the upper left position in the corresponding layer to the vertical side, can scan all the residual coefficients on the vertical side, and can scan the remaining residual coefficients on the vertical side from top to bottom.

[0311] For example, the vertical residual coefficients in the first layer may include residual coefficients #0, #4, #8, and #12, while the horizontal residual coefficients in the first layer may include residual coefficients #1 to #3. The encoding device can scan the vertical residual coefficients in the first layer sequentially from top to bottom (scanning in the order of residual coefficients #0, #4, #8, and #12), and then scan the horizontal residual coefficients in the first layer from left to right (scanning in the order of residual coefficients #1, #2, and #3). Next, the second layer can be scanned. The vertical residual coefficients in the second layer may include residual coefficients #5, #9, and #13, while the horizontal residual coefficients in the second layer may include residual coefficients #6 and #7. The encoding device can scan the vertical residual coefficients in the second layer sequentially from top to bottom (scanning in the order of residual coefficients #5, #9, and #13), and then scan the horizontal residual coefficients in the second layer from left to right (scanning in the order of residual coefficients #6 and #7). Next, the third layer can be scanned. The vertical residual coefficients in the third layer can include residual coefficients #10 and #14, while the horizontal residual coefficients in the third layer can include residual coefficient #11. The encoding device can scan the vertical residual coefficients in the third layer from top to bottom (scanning in the order of residual coefficients #10 and #14), and then scan the horizontal residual coefficients in the third layer from left to right (scanning in the order of residual coefficient #11). Next, the fourth layer can be scanned. The vertical residual coefficients in the fourth layer can include residual coefficient #15. The encoding device can scan the vertical residual coefficients in the fourth layer from top to bottom in the order of residual coefficient #15.

[0312] Subsequently, refer to Figure 12(b) The encoding device can rearrange the residual coefficients in the scanning order according to the diagonal scan sequence (from top right to bottom left, or from bottom right to top left). The scanning order of the residual coefficients can be the order of residual coefficients #0, #4, #8, #12, #1, #2, #3, #5, #9, #13, #6, #7, #10, #14, #11, and #15. The residual coefficients can be rearranged in the current block according to the diagonal scan position. For example, residual coefficient #0 can be rearranged to the lower right position on the first upper right diagonal; residual coefficients #4 and #8 can be rearranged sequentially from the upper right to the upper left on the second upper right diagonal of the current block (i.e., from the upper left to the upper right diagonal of the first upper right diagonal); residual coefficients #12, #1, and #2 can be rearranged sequentially from the upper right to the upper left on the third upper right diagonal (i.e., from the upper left to the upper right diagonal of the second upper right diagonal); and residual coefficients #3, #5, #9, and #13 can be rearranged sequentially from the upper right to the upper left on the fourth upper right diagonal. That is, in the upper left side of the third upper right diagonal (towards the upper right diagonal), the residual coefficients #6, #7, and #10 can be rearranged sequentially from the upper right side to the upper left side in the fifth upper right diagonal (that is, from the upper left corner of the fourth upper right diagonal to the upper right diagonal). The residual coefficients #14 and #11 can be rearranged sequentially from the upper right side to the upper left side in the sixth upper right diagonal (that is, from the upper left corner of the fifth upper left diagonal to the upper right diagonal). The residual coefficient #15 can be rearranged in the upper left position of the seventh upper right diagonal (that is, from the upper left corner of the sixth upper right diagonal to the upper right diagonal).

[0313] Alternatively, another embodiment can be proposed to rearrange the residual coefficients of the current block based on the distance from the intra-frame predicted reference sample. For example, a method can be proposed that a reference sample (left or top) is set as a reference, the layer of the current block is defined based on the distance from the set reference sample, the residual coefficients are scanned, and then the residual coefficients are rearranged in scan order at positions according to the diagonal scan order. Here, the residual coefficients in the layer defined based on the distance from the left reference sample can be scanned using a longitudinal priority scan, and the residual coefficients in the layer defined based on the distance from the top reference sample can be scanned using a transverse priority scan.

[0314] Figure 13 An example is shown of the residual coefficients of a current block to which the above embodiments are applied, wherein layers are derived based on the distance from a particular reference sample and rearranged at each location according to the diagonal scan order. Figure 13 (a) illustrates an example of rearranging the residual coefficients in a layer, set based on the distance from the upper reference sample, at various positions according to the diagonal scan order, in a lateral-first scan order, and Figure 13 Example (b) illustrates an example of rearranging the residual coefficients in a layer, set based on the distance from the upper reference sample, at positions according to the diagonal scan order, with a longitudinal priority scan order. Meanwhile, the decoding device can derive the existing residual coefficients by performing the above rearrangement process in reverse order.

[0315] Reference Figure 13 (a) The current block comprises a first layer adjacent to at least one upper reference sample, a second layer at a distance of 1 from the nearest upper reference sample, a third layer at a distance of 2 from the nearest upper reference sample, and a fourth layer at a distance of 3 from the nearest upper reference sample. That is, the first layer may include residual coefficients (e.g., adjacent to at least one upper reference sample) Figure 13 The residual coefficients of the current block before rearrangement, as illustrated in (a) (in other words, the first layer may include residual coefficients at a distance of 1 from the nearest upper reference sample), and the second layer may include residual coefficients at a distance of 2 from the nearest upper reference sample (e.g., Figure 13 The third layer may include residuals #4 to #7 of the current block before rearrangement, as illustrated in (a). Figure 13 The residual coefficients of the current block before rearrangement, as illustrated in (a), and the fourth layer may include residual coefficients at a distance of 4 from the nearest upper reference sample (e.g., Figure 13 (The #15 residual coefficient of the current block before rearrangement is illustrated in (a)). In other words, the first layer can be derived as the first row of the current block, the second layer as the second row of the current block, the third layer as the third row of the current block, and the fourth layer as the fourth row of the current block.

[0316] When the layer of the current block is defined as described above, the encoding device can determine the scanning method for the layer of the current block as a lateral priority scan. Thereafter, as... Figure 13 As shown in (a), the rearrangement of residual coefficients can be performed.

[0317] Specifically, the encoding device can scan sequentially from the first layer to the fourth layer, and can scan the residual coefficients from the left position to the right position in the corresponding layer.

[0318] As an example, the encoding device can scan the residual coefficients in the first layer sequentially from left to right (scanning in the order of residual coefficients #0, #1, #2, and #3). Next, the second layer can be scanned. The encoding device can scan the residual coefficients in the second layer sequentially from left to right (scanning in the order of residual coefficients #4, #5, #6, and #7). Next, the third layer can be scanned. The encoding device can scan the residual coefficients in the third layer sequentially from left to right (scanning in the order of residual coefficients #8, #9, #10, and #11). Next, the fourth layer can be scanned. The encoding device can scan the residual coefficients in the fourth layer sequentially from left to right (scanning residual coefficients #13, #14, and #15).

[0319] Subsequently, refer to Figure 13 (a) The encoding device can rearrange the residual coefficients at each position according to the scan order, based on the diagonal scan sequence (from top right to bottom left, or from bottom right to top left). The scan order of the residual coefficients can be the order of residual coefficients #0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14, and #15. The residual coefficients can be rearranged in the current block according to the diagonal scan order. For example, residual coefficient #0 can be rearranged to the lower right position on the first upper right diagonal; residual coefficients #1 and #2 can be rearranged sequentially from the upper right to the upper left in the second upper right diagonal of the current block (i.e., from the upper left to the upper right diagonal of the first upper right diagonal); residual coefficients #3, #4, and #5 can be rearranged sequentially from the upper right to the upper left in the third upper right diagonal (i.e., from the upper left to the upper right diagonal of the second upper right diagonal); and residual coefficients #6, #7, #8, and #9 can be rearranged sequentially from the upper right to the upper left in the fourth upper right diagonal (i.e., from the upper left to the upper right diagonal of the second upper right diagonal). In the upper right diagonal (from the upper left to the upper right diagonal), residual coefficients #10, #11, and #12 can be rearranged sequentially from the upper right to the upper left in the fifth upper right diagonal (i.e., from the upper left to the upper right diagonal of the fourth upper right diagonal). Residual coefficients #13 and #14 can be rearranged sequentially from the upper right to the upper left in the sixth upper right diagonal (i.e., from the upper left to the upper right diagonal of the fifth upper right diagonal). Residual coefficient #15 can be rearranged in the upper left position of the seventh upper right diagonal (i.e., from the upper left to the upper right diagonal of the sixth upper right diagonal).

[0320] Additionally, refer to Figure 13(b) The current block comprises a first layer adjacent to at least one left reference sample, a second layer at a distance of 1 from the nearest left reference sample, a third layer at a distance of 2 from the nearest left reference sample, and a fourth layer at a distance of 3 from the nearest left reference sample. That is, the first layer may include residual coefficients adjacent to at least one left reference sample (e.g., Figure 13 The residual coefficients of the current block before rearrangement, illustrated in (b) (in other words, the first layer may include residual coefficients at a distance of 1 from the nearest left reference sample), and the second layer may include residual coefficients at a distance of 2 from the nearest left reference sample (e.g., Figure 13 The residual coefficients of the current block before rearrangement, as illustrated in (b), may include residual coefficients at a distance of 3 from the nearest left reference sample (e.g., ...). Figure 13 The residual coefficients of the current block before rearrangement, as illustrated in (b), are #2, #6, #10, and #14, and the fourth layer may include residual coefficients at a distance of 4 from the nearest left reference sample (e.g., Figure 13 (The residual coefficients of #3, #7, #11, and #15 of the current block before rearrangement are illustrated in (b). In other words, the first layer can be derived as the first column of the current block, the second layer as the second column of the current block, the third layer as the third column of the current block, and the fourth layer as the fourth column of the current block.

[0321] When the layer of the current block is defined as described above, the encoding device can determine the scanning method for the layer of the current block as a vertical priority scan. Thereafter, as... Figure 13 As shown in (b), a rearrangement of the residual coefficients can be performed.

[0322] Specifically, the encoding device can scan sequentially from the first layer to the fourth layer, and can scan downwards from the residual coefficients at the upper position in the corresponding layer.

[0323] As an example, the encoding device can scan the residual coefficients in the first layer sequentially from top to bottom (scanning in the order of residual coefficients #0, #4, #8, and #12). Next, the second layer can be scanned. The encoding device can scan the residual coefficients in the second layer sequentially from top to bottom (scanning in the order of residual coefficients #1, #5, #9, and #13). Next, the third layer can be scanned. The encoding device can scan the residual coefficients in the third layer sequentially from top to bottom (scanning in the order of residual coefficients #2, #6, #10, and #14). Next, the fourth layer can be scanned. The encoding device can scan the residual coefficients in the fourth layer sequentially from top to bottom (scanning residual coefficients #3, #7, #11, and #15).

[0324] Subsequently, refer to Figure 13 (b) The encoding device can rearrange the residual coefficients at each position according to the scan order, based on the diagonal scan sequence (from top right to bottom left, or from bottom right to top left). The scan order of the residual coefficients can be the order of residual coefficients #0, #4, #8, #12, #1, #5, #9, #13, #2, #6, #10, #14, #3, #7, #11, and #15. The residual coefficients can be rearranged in the current block according to the diagonal scan order. For example, residual coefficient #0 can be rearranged to the lower right position on the first upper right diagonal; residual coefficients #4 and #8 can be rearranged sequentially from the upper right to the upper left in the second upper right diagonal of the current block (i.e., from the upper left to the upper right diagonal of the first upper right diagonal); residual coefficients #12, #1, and #5 can be rearranged sequentially from the upper right to the upper left in the third upper right diagonal (i.e., from the upper left to the upper right diagonal of the second upper right diagonal); and residual coefficients #9, #13, #2, and #6 can be rearranged sequentially from the upper right to the upper left in the fourth upper right diagonal. (That is, from the upper left side of the third upper right diagonal to the upper right diagonal), the residual coefficients #10, #14 and #3 can be rearranged sequentially from the upper right side to the upper left side in the fifth upper right diagonal (that is, from the upper left side of the fourth upper right diagonal to the upper right diagonal). The residual coefficients #7 and #11 can be rearranged sequentially from the upper right side to the upper left side in the sixth upper right diagonal (that is, from the upper left side of the fifth upper right diagonal to the upper right diagonal). The residual coefficient #15 can be rearranged in the upper left position of the seventh upper right diagonal (that is, from the upper left side of the sixth upper right diagonal to the upper right diagonal).

[0325] Furthermore, for example, the aforementioned rearrangement method can be performed without applying a transformation to the residual coefficients of the current block. That is, the application of the rearrangement method can be determined based on whether a transformation of the residual coefficients is applied. In other words, the application of the rearrangement method can be determined based on the transformation skip flag of the current block.

[0326] Figure 14a and Figure 14b An embodiment of determining whether to apply a rearrangement method based on the transform skip flag of the current block is shown, along with an encoding device and a decoding device that execute this embodiment.

[0327] Reference Figure 14aThe encoding and decoding devices can determine whether the transform skip flag for the current block is 1 (S1400). When the transform skip flag is 1, the encoding and decoding devices can perform a rearrangement method on the residual coefficients of the current block (S1410). Conversely, when the transform skip flag is not 1 (i.e., when the transform skip flag is 0), the encoding and decoding devices can choose not to perform a rearrangement method on the residual coefficients of the current block. The transform skip flag indicates whether a transform is applied to the residual coefficients of the current block. In other words, the transform skip flag indicates whether a transform is applied to the residual coefficients. The syntax element representing the transform skip flag can be the aforementioned `transform_skip_flag`.

[0328] Additionally, refer to Figure 14b An encoding device and a decoding device can be exemplarily illustrated, which determine whether to apply a rearrangement method and perform the corresponding operation based on the transform skip flag of the current block. The residual rearrangement unit of the encoding device can determine whether to rearrange the residual coefficients based on the transform skip flag of the current block, and can rearrange the residual coefficients when the transform skip flag is 1. The quantization unit and entropy encoder of the encoding device can quantize and entropy encode the rearranged residual coefficients to generate residual information, and output the encoded residual information as a bitstream. Additionally, the entropy decoder of the decoding device can receive a bitstream including the residual information of the current block and decode the residual information to derive the quantized residual coefficients. Subsequently, the dequantizer of the decoding device can dequantize (i.e., scale) the quantized residual coefficients to derive the residual coefficients. The residual rearrangement unit of the decoding device can determine whether to rearrange the residual coefficients based on the transform skip flag of the current block, and can rearrange the residual coefficients when the transform skip flag is 1.

[0329] As another example, a method can be proposed to combine the above-described rearrangement methods under various conditions.

[0330] As an example, the rearrangement method or whether to rearrange can be determined based on the size of the current block. Here, the size of the current block can indicate the number of samples in the current block or the width and height of the current block. For example, when the number of samples in the current block is less than 64, a rearrangement method that rotates the residual coefficients of the current block by 180 degrees can be applied, while when the number of samples in the current block is 64 or more, the aforementioned rearrangement method that mirrors the residual coefficients of the current block can be applied. Alternatively, as another example, when the number of samples in the current block is less than 64, one of the aforementioned rearrangement methods can be applied to the residual coefficients of the current block, while when the number of samples in the current block is 64 or more, a rearrangement method may not be applied. Furthermore, for example, the aforementioned process of determining the rearrangement method or whether to rearrange based on conditions can only be performed when the value of the transformation skip flag of the current block is 1. In other words, when the value of the transformation skip flag of the current block is 1, the rearrangement method or whether to rearrange can be determined based on the size of the current block (number of samples or width and height).

[0331] Alternatively, as another example, the rearrangement method or whether to rearrange can be determined based on the shape of the current block. For example, when the current block is a square block (i.e., when the width and height of the current block are the same), a rearrangement method that mirrors the residual coefficients of the current block can be applied. When the current block is not a square block (i.e., when the width and height values ​​of the current block are different), the above-described 180-degree rotation rearrangement method can be applied to the residual coefficients of the current block. Furthermore, for example, the above-described process of determining the rearrangement method or whether to rearrange based on conditions can only be performed if the transformation skip flag of the current block is 1. In other words, when the transformation skip flag of the current block is 1, the rearrangement method or whether to rearrange can be determined based on the shape of the current block.

[0332] Alternatively, as another example, the rearrangement method or whether to rearrange can be determined based on the width-to-height ratio of the current block. For example, when the width-to-height ratio of the current block is greater than 2 or less than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is greater than 2 or less than 1 / 2), the mirror rearrangement method can be applied to the residual coefficient of the current block, while when the width-to-height ratio of the current block is less than 2 but greater than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is less than 2 but greater than 1 / 2), the above-described rearrangement method of rotating 180 degrees relative to the residual coefficient of the current block can be applied. Alternatively, for example, when the width-to-height ratio of the current block is greater than 2 or less than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is greater than 2 or less than 1 / 2), the above-described mirror rearrangement method can be applied to the residual coefficients of the current block. Conversely, when the width-to-height ratio of the current block is less than 2 but greater than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is less than 2 and less than 1 / 2), the above-described rearrangement method may not be applied to the residual coefficients of the current block. Furthermore, the above-described process of determining the rearrangement method or whether to rearrange based on conditions can only be performed when the transform skip flag of the current block is 1. In other words, when the transform skip flag of the current block is 1, the rearrangement method or whether to rearrange can be determined based on the width-to-height ratio of the current block.

[0333] Alternatively, as another example, when applying intra-prediction to the current block, the rearrangement method or whether to rearrange can be determined based on the intra-prediction mode of the current block. For example, when the prediction direction of the intra-prediction mode of the current block is close to the horizontal or vertical direction, the left or top reference sample is mainly used for prediction, causing the prediction error to be concentrated in the direction of one reference sample. Therefore, an embodiment that takes this characteristic into account can be proposed to determine the rearrangement method. For example, when the prediction direction of the intra-prediction mode of the current block is horizontal or when the intra-prediction mode of the current block mainly uses the left reference sample for prediction, the above-described vertical flip rearrangement method can be applied. When the prediction direction of the intra-prediction mode of the current block is vertical or when the intra-prediction mode of the current block mainly uses the top reference sample for prediction, the above-described horizontal flip rearrangement method can be applied. Furthermore, for example, the above-described process of determining the rearrangement method or whether to rearrange based on conditions can only be performed when the value of the transform skip flag of the current block is 1. In other words, when the transform skip flag of the current block is 1, the rearrangement method or whether to rearrange can be determined based on the intra-prediction mode of the current block.

[0334] Alternatively, as another example, the rearrangement method or whether to rearrange can be determined based on the high-level syntax in the bitstream sent from the encoding device. For example, a flag indicating whether to rearrange can be sent via a high-level syntax such as a Sequence Parameter Set (SPS) or Picture Parameter Set (PPS), and the rearrangement method and whether to rearrange within a lower-level syntax referencing the high-level syntax can be determined based on this flag. Meanwhile, for example, the above-described conditional process of determining the rearrangement method or whether to rearrange can be performed only when the transform skip flag of the current block is 1. In other words, when the transform skip flag of the current block is 1, a flag indicating whether to rearrange can be sent via a high-level syntax such as SPS or PPS, and the rearrangement method or whether to rearrange can be determined based on this flag.

[0335] Alternatively, as another example, the rearrangement method or whether to rearrange can be determined based on the prediction mode of the current block. For example, an embodiment could be proposed in which the residual rearrangement method is not used for inter-frame prediction modes that generate relatively few residual signals, and the rearrangement method is only used for the residual signals of blocks predicted by intra-frame prediction modes. In other words, when inter-frame prediction is applied to the current block, the rearrangement method for the residual coefficients of the current block may not be applied, while when intra-frame prediction is applied to the current block, the rearrangement method for the residual coefficients of the current block may be applied. Meanwhile, for example, the above-described process of determining the rearrangement method or whether to rearrange can be performed only when the transform skip flag of the current block is 1. In other words, when the transform skip flag of the current block is 1, the rearrangement method or whether to rearrange can be determined based on the prediction mode of the current block.

[0336] Alternatively, as another example, the rearrangement method or whether to rearrange can be determined based on whether quantization is performed. For example, in lossless compilation without quantization, the residual rearrangement method described above may not be performed, while in lossy compilation with quantization, the residual rearrangement method described above may be performed. In other words, when quantization is not applied to the residual coefficients of the current block, the rearrangement method may not be applied to the residual coefficients of the current block, while when quantization is applied to the residual coefficients of the current block, the rearrangement method may be applied to the residual coefficients of the current block. Furthermore, for example, the process of determining the rearrangement method or whether to rearrange based on conditions may only be performed if the transform skip flag of the current block is 1. In other words, when the transform skip flag of the current block is 1, the rearrangement method or whether to rearrange can be determined based on whether quantization is applied.

[0337] Meanwhile, as mentioned above, blocks for which no transform coding is performed, i.e., transform blocks including residual coefficients for which no transform is applied, have different residual information characteristics than blocks for which general transform coding is performed. Therefore, efficient residual data coding methods are needed for blocks for which no transform coding is performed.

[0338] Therefore, this document proposes an embodiment for encoding / decoding residual information regarding transform skip blocks. Here, a transform skip flag indicating whether a transform is applied can be sent on a transform block basis, and the size of the transform block is not limited in the embodiments of this document. For example, when the value of the transform skip flag is 1, the method for encoding / decoding residual information proposed in this document can be performed. When the value of the transform skip flag is 0, a method for encoding / decoding existing residual information (such as the syntax elements of residual information disclosed in Table 1 above) can be performed.

[0339] Figure 15 An example of a method for determining the compilation of residual information based on a transform skip flag is shown.

[0340] Reference Figure 15 The encoding device can determine whether the value of the transform skip flag for the current block is 1 (S1500).

[0341] When the transform skip flag is set to 1, the encoding device can rearrange the residual coefficients of the current block (S1510). Here, at least one of the methods described in the above embodiments can be used as a method for rearranging the residual coefficients. Alternatively, for example, whether to rearrange the residual coefficients can be determined based on whether the prediction mode of the current block is an inter-frame prediction mode or an intra-frame prediction mode. Alternatively, for example, when performing intra-frame prediction on the current block, the method for rearranging the residual coefficients or whether to rearrange them can be selected based on the intra-frame prediction mode applied to the current block or the distance between the reference sample used in the intra-frame prediction mode and the current block. Alternatively, for example, the method for rearranging the residual coefficients or whether to rearrange them can be selected based on the size of the current block (e.g., the number of samples in the current block or the width and height of the current block), the shape of the current block (e.g., whether the current block is a square block or a non-square block), the ratio of the horizontal length to the vertical length of the current block, and / or whether quantization is applied to the current block.

[0342] Subsequently, the encoding device can encode information indicating the position of the last non-zero residual coefficient in the current block (S1520). The syntax element indicating the position of the last non-zero residual coefficient can be last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, and last_sig_coeff_y_suffix.

[0343] Subsequently, the encoding device can encode the residual information under the coded_sub_block_flag of the current block, that is, the residual information encoded after coded_sub_block_flag (S1530). For example, the residual information can be encoded together with the syntax elements shown in Table 14 above.

[0344] Meanwhile, when the value of the transform skip flag is 0, the encoding device can encode the residual information of the current block as in the related art method (S1540). For example, the residual information encoded as in the related art scheme can be the same as the syntax elements disclosed in Table 1 above.

[0345] Simultaneously, the unified transform type information proposed in Table 10 can be communicated using signals. The syntax element of the transform type information can be tu_mts_idx. In this case, the method for compiling the residual information can be determined based on tu_mts_idx. Through the proposed embodiment, the complexity of the residual information encoding process can be reduced and the encoding efficiency of the residual information can be improved for blocks for which transform encoding is not performed.

[0346] Figure 16 An example is shown of a method for determining the compilation of residual information based on unified transformation type information.

[0347] Reference Figure 16 The encoding device can determine whether the value of the uniform transformation type information for the current block is 1 (S1600). The syntax element of the uniform transformation type information can be tu_mts_idx.

[0348] When the value of the unified transform type information is 1, the encoding device can rearrange the residual coefficients of the current block (S1610). Here, at least one of the methods described in the above embodiments can be used as a method for rearranging the residual coefficients. Alternatively, for example, whether to rearrange the residual coefficients can be determined based on whether the prediction mode of the current block is an inter-frame prediction mode or an intra-frame prediction mode. Alternatively, for example, when performing intra-frame prediction on the current block, the method for rearranging the residual coefficients can be selected based on the distance between the intra-frame prediction mode applied to the current block or the reference sample used for the intra-frame prediction mode and the current block, or whether to rearrange the residual coefficients. Alternatively, for example, the method for rearranging the residual coefficients can be selected based on the size of the current block (e.g., the number of samples in the current block or the width and height of the current block), the shape of the current block (e.g., whether the current block is a square block or a non-square block), the ratio of the horizontal length to the vertical length of the current block, and / or whether quantization of the current block is applied, or whether to rearrange the residual coefficients.

[0349] Subsequently, the encoding device can encode information indicating the position of the last non-zero residual coefficient in the current block (S1620). The syntax element indicating the position of the last non-zero residual coefficient can be last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, and last_sig_coeff_y_suffix.

[0350] Subsequently, the encoding device can encode the residual information under the coded_sub_block_flag of the current block, that is, the residual information encoded after coded_sub_block_flag (S1630). For example, the residual information can be encoded as shown in the syntax elements in Table 14 above.

[0351] Simultaneously, when the value of the unified transformation type information is 0, the encoding device can encode the residual information of the current block as in the related art method (S1640). For example, the residual information encoded as in the related art method can be the same as the syntax elements disclosed in Table 1 above. Additionally, as disclosed in Table 10 above, the syntax elements transform_skip_flag and / or mts_idx can be omitted. Through the proposed embodiment, the complexity of the process of encoding residual information for blocks for which transformation encoding is not performed can be reduced, and the encoding efficiency of residual information can be improved.

[0352] Simultaneously, the decoding device can derive the residual coefficients of the current block based on the residual information as described above, and determine whether to apply residual rearrangement (residual coefficient rearrangement) to the current block. For example, based on... Figure 15 or Figure 16 The values ​​of the transform skip flag (i.e., transform_skip_flag) or the uniform transform type information (i.e., tu_mts_idx) shown can determine whether residual rearrangement is applied. When residual rearrangement is applied to the current block, the decoding device can rearrange the residual coefficients based on the residual rearrangement method determined according to the above criteria, and derive residual samples for the current block based on the rearranged residual coefficients. The rearranged residual coefficients can be derived as residual samples, or dequantization can be applied to the rearranged residual coefficients as necessary to derive residual samples. Subsequently, as described above, reconstructed samples for the current block can be generated based on the residual samples and prediction samples of the current block.

[0353] Furthermore, as mentioned above, in residual compilation for the current block, the primary syntax elements in the 4x4 or 2x2 sub-block units of the current block can be sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, par_level_flag, abs_level_gtX_flag, and abs_remainder. The bins for sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, par_level_flag, and abs_level_gtX_flag can be context-compiled bins based on a regular compilation engine, while the bin for abs_remainder can be a bypass bin compiled based on a bypass coding engine.

[0354] Context-compiled bins exhibit high data dependency because they are compiled using updated probability states and ranges while processing previous bins. That is, in the case of context-compiled bins, parallel processing can be challenging because the encoding / decoding of the next bin can be performed after all encoding / decoding of the current bin has been completed. Furthermore, the process of deriving probability intervals and determining the current state can be time-consuming. Therefore, this document proposes an implementation to improve CABAC processing efficiency by reducing the number of context-compiled bins and increasing the number of bypass bins.

[0355] The examples in this document demonstrate how the compilation process for syntax elements compiled as context-compiled bins can be quickly switched to the compilation process for syntax elements abs_remainder compiled using a bypass compilation engine (i.e., compiled as a bypass bin), and the number of context-compiled bins can be reduced.

[0356] As an example, this document proposes a method to limit the number of residual coefficients compiled with sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, and par_level_flag in the current sub-block. That is, this embodiment proposes a method to limit the number of bins allocated to sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, and par_level_flag to a maximum of N. According to this embodiment, residual compilation can be performed on the residual coefficients in the current sub-block according to the scan order, and when the number of bins compiled with sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, and par_level_flag—that is, the number of context compilation bins—reaches N, if abs_level_gt1_flag is not compiled in subsequent residual encoding, then abs_level_gtX_flag is also not compiled, and it can be switched to compilation for abs_remainder. N can be represented as the maximum number of context compilation bins.

[0357] For example, when the current sub-block is 4x4, N can be derived as one of 0 to 64, while when the current sub-block is 2x2, N can be derived as one of 0 to 16. N can be selected by the encoding device. Alternatively, N can be adaptively determined based on the size of the current block and / or the position of the current sub-block within the current block. Alternatively, when the current sub-block is 4x4, N can be set to any value from 0 to 64. When the current sub-block is 2x2, N can be set to any value from 0 to 16.

[0358] Additionally, as an example, this document proposes a method to limit the number of residual coefficients compiled with `abs_level_gtX_flag` in the current sub-block. Referring to Table 14 above, a maximum of four `abs_level_gtX_flag`s can be derived for a single residual coefficient during residual compilation. That is, when the current sub-block is a 4x4 sub-block, a maximum of 64 `abs_level_gtX_flag`s can be compiled for the current sub-block. When the current sub-block is a 2x2 sub-block, a maximum of 16 `abs_level_gtX_flag`s can be compiled for the current sub-block.

[0359] Therefore, this embodiment proposes a method to perform residual compilation on the residual coefficients in the current sub-block to reduce the number of context compilation bins and to compile `abs_level_gtX_flag` to a maximum of N. That is, this embodiment proposes a method to limit the number of bins allocated for `abs_level_gtX_flag` to a maximum of N. N can be represented as the maximum number of syntax elements `abs_level_gtX_flag`. For example, N can be selected by the encoding device. Alternatively, N can be adaptively determined based on the size of the current block and / or the position of the current sub-block within the current block. Alternatively, when the current sub-block is a 4x4 sub-block, N can be set to any value from 0 to 64. When the current sub-block is a 2x2 sub-block, N can be set to any value from 0 to 16. According to this embodiment, residual compilation can be performed on the residual coefficients in the current sub-block according to the scan order, and when the number of syntax elements `abs_level_gtX_flag` reaches N, residual compilation can subsequently be switched to compilation for `abs_remainder`. In other words, residual compilation can be performed on the residual coefficients in the current sub-block according to the scan order, and when the number of bins compiled with the syntax element abs_level_gtX_flag, i.e., the compilation context bins, reaches N, residual compilation can be switched to compilation for abs_remainder.

[0360] Additionally, as an example, this document proposes a method that combines the above-described embodiment of limiting the sum of the numbers of sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, and par_level_flag with an embodiment of limiting the number of abs_level_gtX_flag. According to this embodiment, the sum of the numbers of sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, and par_level_flag for the current sub-block can be limited to M, and the number of abs_level_gtX_flag can be limited to N. That is, this embodiment proposes a method that limits the sum of the bins allocated to sig_coeff_flag, coeff_sign_flag, abs_level_gt1_flag, and par_level_flag to a maximum of M and limits the number of bins allocated to abs_level_gtX_flag to a maximum of N. Here, when the current sub-block is a 4x4 sub-block, M and N can each be derived as one from 0 to 64. When the current sub-block is a 2x2 sub-block, M and N can each be derived as one of 0 to 16.

[0361] Figure 17The image encoding method performed by the encoding device according to this document is illustrated schematically. Figure 17 The method disclosed in the article can be derived from Figure 2 The encoding device disclosed in the document executes the commands. Specifically, for example, Figure 17 S1700 can be executed by the subtractor of the encoding device, S1710 can be executed by the converter and quantizer of the encoding device, and S1720 to S1740 can be executed by the entropy encoder of the encoding device. Additionally, although not shown, the process of deriving the prediction samples can be executed by the predictor of the encoding device, the process of deriving the reconstructed samples of the current block based on the residual samples and prediction samples of the current block can be executed by the adder of the encoding device, and the process of encoding the prediction information about the current block can be executed by the entropy encoder of the encoding device.

[0362] The encoding device derives residual samples for the current block (S1700). The encoding device can determine whether to perform inter-frame prediction or intra-frame prediction for the current block, and can determine a specific inter-frame prediction mode or a specific intra-frame prediction mode based on the RD cost. According to the determined mode, the encoding device can derive prediction samples for the current block and can derive residual samples by subtracting the prediction samples from the original samples of the current block.

[0363] The encoding device derives the transform coefficients in the current sub-block of the current block based on the residual samples (S1710). The encoding device can derive the transform coefficients based on the residual samples in the current sub-block of the current block.

[0364] For example, the encoding device can determine whether to apply a transformation to the residual samples. When no transformation is applied to the residual samples, the encoding device can derive the transformed coefficients from the derived residual samples. Alternatively, when a transformation is applied to the residual samples, the encoding device can derive the transformed coefficients by performing the transformation on the derived residual samples. The transformed coefficients can be included in the current sub-block of the current block. The current sub-block can be called the current coefficient group (CG). Furthermore, the size of the current sub-block of the current block can be either 4x4 or 2x2. That is, the current sub-block of the current block can include up to 16 non-zero transformed coefficients or up to 4 non-zero transformed coefficients.

[0365] Simultaneously, the encoding device can generate and encode a transform skip flag indicating whether a transform is applied to the transform coefficients of the current block. The bitstream can include the transform skip flag for the current block. The transform skip flag indicates whether a transform is applied to the transform coefficients of the current block. That is, the transform skip flag indicates whether a transform is applied to the transform coefficients. The syntax element representing the transform skip flag can be the transform_skip_flag mentioned above.

[0366] Simultaneously, when the transform skip flag of the current block is set to 1, the encoding device can rearrange the transform coefficients. In this case, the encoding device can generate residual information about the rearranged transform coefficients and encode it. For example, the encoding device can rearrange the transform coefficients using various rearrangement methods. That is, the encoding device can move the transform coefficients from their derived positions to other positions using various rearrangement methods.

[0367] As an example, the encoding device can rearrange the transform coefficients by rotating them 180 degrees. Specifically, for example, the encoding device can rearrange the transform coefficients of the current block to a position symmetrical about the center of the current block.

[0368] Alternatively, as an example, the encoding device can rearrange the transform coefficients using a reverse diagonal mirroring method. Specifically, for example, the encoding device can rearrange the transform coefficients to positions symmetrical about the right-upper diagonal of the current block. Here, the right-upper diagonal can refer to the right-upper diagonal that passes through the center of the current block.

[0369] Alternatively, as an example, the encoding device can rearrange the transform coefficients using a diagonal mirroring method. Specifically, for example, the encoding device can rearrange the transform coefficients to positions symmetrical about the upper-left diagonal of the current block. Here, the upper-left diagonal can refer to the upper-left diagonal that passes through the center of the current block.

[0370] Alternatively, as an example, the encoding device can rearrange the transform coefficients using a vertical flipping rearrangement method. Specifically, for example, the encoding device can rearrange the transform coefficients of the current block to a position symmetrical with respect to the vertical axis of the current block. Here, the vertical axis can be a vertical line passing through the center of the current block.

[0371] Alternatively, as an example, the encoding device can rearrange the transform coefficients using a horizontal flipping rearrangement method. The encoding device can rearrange the transform coefficients of the current block to a position symmetrical about the horizontal axis of the current block. Here, the horizontal axis can be a horizontal line passing through the center of the current block.

[0372] Alternatively, as an example, the encoding device can rearrange the transform coefficients by deriving layers distinguished based on their distance from a reference sample of the current block and rearranging the layers according to the reverse raster order.

[0373] For example, the encoding device can set layers for the current block based on the distance to a reference sample of the current block. Here, the reference sample can include the top reference sample and the left reference sample of the current block. For example, when the size of the current block is NxN and the x and y components of the top-left sample position of the current block are 0, the left reference sample can be p[-1][0] to p[-1][2N-1] and the top reference sample can be p[0][-1] to p[2N-1][-1]. When the size of the current block is NxN, the layers can include the first layer to the Nth layer. The Nth layer can be the last layer, and N can be equal to the width or height of the current block. For example, the first layer can include positions at a distance of 1 from the nearest reference sample, the second layer can include positions at a distance of 2 from the nearest reference sample, and the Nth layer can include positions at a distance of N from the nearest reference sample.

[0374] Subsequently, the encoding device can scan the transform coefficients in reverse raster order. In other words, the encoding device can scan the transform coefficients of the current block from right to left and from bottom to top. Next, the encoding device can rearrange the transform coefficients in the layers according to the scan order. Here, the rearrangement of transform coefficients can be performed in the order of layers one through N. Furthermore, the transform coefficients can be rearranged in the rearranged layers based on either a lateral-priority scan or a vertical-priority scan.

[0375] For example, the transformation coefficients can be preferentially rearranged from right to left at the lateral position of the upper left of the rearranged layer, and if a vertical position of the upper left of the rearranged layer exists, the transformation coefficients can be rearranged from top to bottom at the vertical position of the upper left of the rearranged layer after being rearranged at the lateral position. Alternatively, for example, the transformation coefficients can be preferentially rearranged from top to bottom at the vertical position of the upper left of the rearranged layer, and if a lateral position of the upper left of the rearranged layer exists, the transformation coefficients can be rearranged from left to right at the lateral position of the upper left of the rearranged layer after being rearranged at the vertical position.

[0376] Alternatively, as an example, the encoding device can rearrange the transform coefficients by deriving layers differentiated based on their distance from a reference sample of the current block and rearranging the layers according to the diagonal scan order.

[0377] For example, the encoding device can set layers for the current block based on the distance to a reference sample of the current block. Here, the reference sample can include the top reference sample and the left reference sample of the current block. For example, when the size of the current block is NxN and the x and y components of the top-left sample position of the current block are 0, the left reference sample can be p[-1][0] to p[-1][2N-1] and the top reference sample can be p[0][-1] to p[2N-1][-1]. When the size of the current block is NxN, the layers can include the first layer to the Nth layer. The Nth layer can be the last layer, and N can be equal to the width or height of the current block. For example, the first layer can include positions at a distance of 1 from the nearest reference sample, the second layer can include positions at a distance of 2 from the nearest reference sample, and the Nth layer can include positions at a distance of N from the nearest reference sample.

[0378] Subsequently, the encoding device can scan the transform coefficients in a diagonal scan order. In other words, the encoding device can scan the transform coefficients of the current block from top right to bottom left and from bottom right to top left. Next, the encoding device can rearrange the transform coefficients in the layers according to the scan order. Here, the rearrangement of transform coefficients can be performed in the order of layers one through N. Furthermore, the transform coefficients can be rearranged in the rearranged layers based on either a horizontal priority scan or a vertical priority scan.

[0379] For example, the transformation coefficients can be preferentially rearranged from right to left at the lateral position of the upper left of the rearranged layer, and if a vertical position of the upper left of the rearranged layer exists, the transformation coefficients can be rearranged from top to bottom at the vertical position of the upper left of the rearranged layer after being rearranged at the lateral position. Alternatively, for example, the transformation coefficients can be preferentially rearranged from top to bottom at the vertical position of the upper left of the rearranged layer, and if a lateral position of the upper left of the rearranged layer exists, the transformation coefficients can be rearranged from left to right at the lateral position of the upper left of the rearranged layer after being rearranged at the vertical position.

[0380] Alternatively, for example, the encoding device may set layers for the current block based on the distance to the upper reference sample of the current block. For example, when the size of the current block is NxN and the x and y components of the upper left sample position of the current block are 0, the upper reference sample may be p[0][-1] to p[2N-1][-1]. When the size of the current block is NxN, the layers may include the first layer to the Nth layer. The Nth layer may be the last layer, and N may be equal to the width or height of the current block. For example, the first layer may include positions at a distance of 1 from the nearest reference sample, the second layer may include positions at a distance of 2 from the nearest reference sample, and the Nth layer may include positions at a distance of N from the nearest reference sample. In other words, the first layer may be the first row of the current block, the second layer may be the second row of the current block, and the Nth layer may be the Nth row of the current block.

[0381] Afterward, the encoding device can scan the transform coefficients in a diagonal scan order. In other words, the encoding device can scan the transform coefficients of the current block from top right to bottom left and from bottom right to top left. Next, the encoding device can rearrange the transform coefficients in the layers in scan order. Here, the rearrangement of transform coefficients can be performed sequentially from layer 1 to layer N. The rearrangement of transform coefficients can be performed from layer 1 to layer N, and the transform coefficients can be rearranged from right to left at the positions of the rearranged layers.

[0382] Alternatively, for example, the encoding device may set layers for the current block based on the distance to the left reference sample of the current block. For example, when the size of the current block is NxN and the x and y components of the top-left sample position of the current block are 0, the left reference sample may be p[-1][0] to p[-1][2N-1]. When the size of the current block is NxN, the layers may include a first layer to an Nth layer. The Nth layer may be the last layer, and N may be equal to the width or height of the current block. For example, the first layer may include positions at a distance of 1 from the nearest left reference sample, the second layer may include positions at a distance of 2 from the nearest left reference sample, and the Nth layer may include positions at a distance of N from the nearest reference sample. In other words, the first layer may be the first column of the current block, the second layer may be the second column of the current block, and the Nth layer may be the Nth column of the current block.

[0383] Afterward, the encoding device can scan the transform coefficients in a diagonal scan order. In other words, the encoding device can scan the transform coefficients of the current block from top right to bottom left and from bottom right to top left. Next, the encoding device can rearrange the transform coefficients in the layers according to the scan order. Here, the rearrangement of transform coefficients can be performed in the order of layers 1 to N. The rearrangement of transform coefficients can be performed sequentially from layers 1 to N, and the transform coefficients can be rearranged from top to bottom at the positions of the rearranged layers.

[0384] Simultaneously, the encoding device can determine whether to rearrange the transform coefficients based on various conditions. Alternatively, the encoding device can derive a rearrangement method for the transform coefficients based on various conditions.

[0385] As an example, the encoding device can determine whether to rearrange the transform coefficients based on the transform skip flag of the current block. The transform skip flag indicates whether a transform should be applied to the transform coefficients. For example, when the transform skip flag is 1, it can be determined that the transform coefficients should be rearranged. In other words, when the transform skip flag is 1, the encoding device can rearrange the transform coefficients. When the transform skip flag is 0, it can be determined that the transform coefficients should not be rearranged. In other words, when the transform skip flag is 0, the encoding device can generate residual information about the current block based on the transform coefficients and encode it without rearranging the transform coefficients.

[0386] Alternatively, as another example, the decision to rearrange the transform coefficients can be based on the number of samples in the current block. For example, if the number of samples in the current block is less than a certain value, it can be determined that the transform coefficients should be rearranged. In other words, the encoding device can rearrange the transform coefficients when the number of samples in the current block is less than a certain value. If the number of samples in the current block is greater than or equal to a certain value, it can be determined that the transform coefficients should not be rearranged. In other words, if the number of samples in the current block is equal to or greater than a certain value, the encoding device can generate residual information about the current block based on the transform coefficients and encode it without rearranging the transform coefficients. This specific value can be 64.

[0387] Alternatively, for example, when the number of samples in the current block is less than 64, the encoding device may rearrange the transform coefficients by rotating them 180 degrees. When the number of samples in the current block is 64 or more, the encoding device may not rearrange the transform coefficients.

[0388] Alternatively, as another example, the method for rearranging the transformation coefficients can be determined based on the number of samples in the current block.

[0389] For example, when the number of samples in the current block is less than 64, the encoding device can rearrange the transform coefficients by rotating them 180 degrees. When the number of samples in the current block is 64 or more, the encoding device can rearrange the transform coefficients by mirroring them. Alternatively, as another example, when the number of samples in the current block is less than 64, the encoding device can rearrange the transform coefficients using one of the above rearrangement methods. When the number of samples in the current block is 64 or more, the encoding device may not rearrange the transform coefficients.

[0390] Alternatively, as another example, the decision to rearrange the residual coefficients can be based on the shape of the current block. For instance, if the current block is a square block, it can be determined that the transform coefficients should be rearranged. In other words, if the current block is a square block, the encoding device can rearrange the transform coefficients. If the current block is a non-square block, it can be determined that the transform coefficients should not be rearranged. In other words, if the current block is a non-square block, the encoding device can generate residual information about the current block based on the transform coefficients and encode it without rearranging the transform coefficients.

[0391] Alternatively, as another example, the method for rearranging the transform coefficients can be determined based on the shape of the current block. For instance, when the current block is a square block, the encoding device can rearrange the transform coefficients using a mirroring method, while when the current block is a non-square block, the encoding device can rearrange the transform coefficients using a method that rotates them by 180 degrees.

[0392] Alternatively, as another example, the decision to rearrange the transform coefficients can be based on the width-to-height ratio of the current block. For instance, when the width-to-height ratio of the current block is greater than 2 or less than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is greater than 2 or less than 1 / 2), the encoding device can rearrange the transform coefficients using a mirroring rearrangement method. Conversely, when the width-to-height ratio of the current block is less than 2 but greater than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is less than 2 but greater than 1 / 2), the encoding device can generate and encode the residual information of the current block based on the transform coefficients without rearranging them.

[0393] Alternatively, as another example, the method for rearranging the transform coefficients can be determined based on the width-to-height ratio of the current block. For instance, when the width-to-height ratio of the current block is greater than 2 or less than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is greater than 2 or less than 1 / 2), the encoding device can rearrange the transform coefficients using a mirroring method. Conversely, when the width-to-height ratio of the current block is less than 2 but greater than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is less than 2 but greater than 1 / 2), the encoding device can rearrange the transform coefficients using a 180-degree rotation method.

[0394] Alternatively, as another example, the decision to rearrange the transform coefficients can be based on the intra-prediction mode of the current block. For instance, if the prediction direction of the intra-prediction mode of the current block is horizontal, or if the intra-prediction mode of the current block primarily uses the left reference sample for prediction, the coding device can rearrange the transform coefficients using a vertical flip rearrangement method. In other cases, the coding device can generate and encode the residual information of the current block based on the transform coefficients without rearranging the transform coefficients. Alternatively, for example, if the prediction direction of the intra-prediction mode of the current block is vertical, or if the intra-prediction mode of the current block primarily uses the top reference sample for prediction, the coding device can rearrange the transform coefficients using a vertical flip rearrangement method. In other cases, the coding device can generate and encode the residual information of the current block based on the transform coefficients without rearranging the transform coefficients.

[0395] Alternatively, as another example, the method for rearranging the transform coefficients can be determined based on the intra-prediction mode of the current block. For instance, when the prediction direction of the intra-prediction mode of the current block is horizontal, or when the intra-prediction mode of the current block primarily uses the left reference sample for prediction, the coding device can rearrange the transform coefficients using a vertical flip rearrangement method. Conversely, when the prediction direction of the intra-prediction mode of the current block is vertical, or when the intra-prediction mode of the current block primarily uses the top reference sample for prediction, the coding device can also rearrange the transform coefficients using a vertical flip rearrangement method.

[0396] Alternatively, as another example, the decision to rearrange the transform coefficients can be based on a flag indicating whether to rearrange them, signaled via a high-level syntax. For instance, the encoding device can use a sequence parameter set (SPS) or picture parameter set (PPS) to signal the flag indicating whether to rearrange the transform coefficients, and determine whether to rearrange them based on that flag.

[0397] Alternatively, as another example, the rearrangement method of the transform coefficients can be determined based on information indicating the rearrangement method of the transform coefficients via signals communicated through a high-level syntax. For example, the encoding device can use a sequence parameter set (SPS) or a picture parameter set (PPS) to signal information indicating the rearrangement method of the transform coefficients, and determine whether to rearrange the transform coefficients based on that information.

[0398] Alternatively, as another example, the decision to rearrange the transform coefficients can be determined based on the prediction mode of the current block. For instance, if the prediction mode of the current block is intra-frame prediction, it can be determined that the transform coefficients should be rearranged. In other words, when the prediction mode of the current block is intra-frame prediction, the coding device can rearrange the transform coefficients. Conversely, if the prediction mode of the current block is inter-frame prediction, it can be determined that the transform coefficients should not be rearranged. In other words, when the prediction mode of the current block is inter-frame prediction, the coding device can generate residual information about the current block based on the transform coefficients and encode it without rearranging the transform coefficients.

[0399] Alternatively, as another example, the decision to rearrange the transform coefficients can be determined based on whether or not they have been quantized. For instance, when quantization is applied to the transform coefficients, it can be determined that they need to be rearranged. In other words, when quantization is applied to the transform coefficients, the encoding device can rearrange them. Conversely, when quantization is not applied to the transform coefficients, it can be determined that they do not need to be rearranged. In other words, when quantization is not applied to the transform coefficients, the encoding device may not need to rearrange them.

[0400] The encoding device derives a specific number of context compilation bins for the context syntax elements of the current sub-block (S1720). Here, the specific number may represent the maximum value mentioned above, and the maximum value may be the maximum sum of the number of context compilation bins for the context syntax elements of the current sub-block related to the transformation coefficients of the current block.

[0401] As an example, the maximum value can be derived in units of transform blocks.

[0402] For example, the maximum value can be set to any value. When the current sub-block size is 4x4, the maximum value can be derived from one of 0 to 64. When the current sub-block size is 2x2, the maximum value can be derived from one of 0 to 16. For example, the maximum value can be set to 4.

[0403] Alternatively, for example, the maximum value can be derived based on the size of the current block (or the current child block within the current block). When the size of the current block (or the current child block within the current block) is 4x4, the derived maximum value can be derived as one of 0 to 64, while when the size of the current block (or the current child block within the current block) is 2x2, the derived maximum value can be derived as one of 0 to 16.

[0404] Alternatively, for example, the maximum value can be derived based on the size of the current block and the position of the current child block.

[0405] Additionally, for example, the maximum value can be derived based on positional information indicating the location of the last non-zero transform coefficient in the current block. For instance, the location of the last non-zero transform coefficient can be derived based on the positional information, and the length from the position of the first transform coefficient in the scan order of the current block to the position of the last non-zero transform coefficient can be derived. The maximum value can be derived based on this length. For example, the maximum value can be derived as the value obtained by multiplying the length by 1.75. Here, the length can correspond to the number of samples in the current block. That is, the length can be the number of samples in the current block. For example, when transform coefficients with a value of 0 are not included in the arrangement of transform coefficients in the current block, the length can be the number of samples in the current block. In other words, the maximum value can be derived based on the number of samples in the current block. For example, the maximum value can be derived as the value obtained by multiplying the number of samples in the current block by 1.75.

[0406] The encoding device encodes the context syntax elements based on a specific number (S1730). The encoding device may encode the context syntax elements based on a maximum value.

[0407] For example, the encoding device can encode the context syntax elements of the transform coefficients of the current sub-block of the current block based on the context. The context syntax elements may include a valid coefficient flag indicating whether the transform coefficient is a non-zero transform coefficient, a parity level flag indicating the parity of the transform coefficient level, a first transform coefficient level flag indicating whether the transform coefficient is greater than a first threshold, and a second transform coefficient level flag indicating whether the transform coefficient level is greater than a second threshold. Here, the valid coefficient flag may be `sig_coeff_flag`, the parity level flag may be `par_level_flag`, the first transform coefficient level flag may be `abs_level_gt1_flag`, and the second transform coefficient level flag may be `abs_level_gt3_flag` or `abs_level_gtx_flag`.

[0408] Alternatively, for example, the context syntax elements may include a valid coefficient flag indicating whether the transform coefficients are non-zero, a sign flag indicating the sign of the transform coefficients, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a parity level flag regarding the parity of the transform coefficient levels. Here, the valid coefficient flag may be sig_coeff_flag, the sign flag may be coeff_sign_flag, the first transform coefficient level flag may be abs_level_gt1_flag, and the parity level flag may be par_level_flag.

[0409] Specifically, when the sum of the number of context compilation bins of the context syntax elements of the transform coefficients in the scan order of the transform coefficients in the current sub-block reaches a maximum value (i.e., greater than or equal to the maximum value), the signaling and encoding of the context syntax elements of the transform coefficients can be omitted (i.e., the context syntax elements of the transform coefficients can be notified without signaling), and the bypass syntax elements compiled based on the bypass of the transform coefficients can be encoded. The values ​​of the transform coefficients can be derived based on the bypass syntax elements compiled based on the bypass.

[0410] For example, when the number of context compilation bins for context syntax elements of transform coefficients derived before a specific transform coefficient in the current sub-block reaches a certain number, the bypass syntax elements for the specific transform coefficients included in the residual information can be encoded. Signaling and encoding of the context syntax elements for the specific transform coefficients can be omitted. The value of the specific transform coefficient can be derived based on the bypass syntax elements.

[0411] For example, when the sum of the number of context compilation bins of the context syntax elements of the current sub-block from #0 to #n transform coefficients reaches the maximum value, the signaling and encoding of the context syntax elements of the current sub-block's #n+1 transform coefficients can be omitted, and the bypass syntax elements of the #n+1 transform coefficients included in the residual information can be encoded.

[0412] In other words, for example, when the sum of the number of context compilation bins for the valid coefficient flags, first transform coefficient level flags, parity level flags, and second transform coefficient level flags of the transform coefficients from #0 to #n determined by the scan order in the current sub-block reaches the maximum value (i.e., greater than or equal to the maximum value), the valid coefficient flags, first transform coefficient level flags, parity level flags, and second transform coefficient level flags of the transform coefficients of #n+1 determined by the scan order can be omitted, and the bypass syntax elements based on bypass compilation of the #n+1 quantized transform coefficients can be encoded.

[0413] Alternatively, for example, when the sum of the context compilation bins of the valid coefficient flag, sign flag, first transform coefficient level flag, and parity level flag of the transform coefficients from #0 to #n, determined by the scan order in the transform coefficients of the current sub-block, reaches the maximum value (i.e., greater than or equal to the maximum value), the signaling and encoding of the valid coefficient flag, sign flag, first transform coefficient level flag, and parity level flag of the transform coefficient #n+1, determined by the scan order, can be omitted, and the bypass syntax elements of the bypass compilation based on the #n+1 quantized transform coefficients can be encoded.

[0414] The encoding device generates a bitstream that includes residual information about the current block, including the encoding context syntax elements (S1740). For example, the encoding device can output image information including residual information as a bitstream.

[0415] For example, residual information may include syntax elements such as: transform_skip_flag, last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_suffix, coded_sub_block_flag, sig_coeff_flag, par_level_flag, abs_level_gt1_flag, abs_level_gtX_flag, abs_remainder, coeff_sign_flag, dec_abs_level, and / or mts_idx.

[0416] Specifically, for example, residual information may include a transform skip flag for the current block. The transform skip flag indicates whether a transform should be applied to the transform coefficients of the current block. In other words, the transform skip flag indicates whether a transform should be applied to the transform coefficients. The syntax element representing the transform skip flag can be the `transform_skip_flag` described above.

[0417] Additionally, for example, residual information may include positional information indicating the location of the last non-zero transform coefficient in the transform coefficient array of the current block. That is, residual information may include positional information indicating the location of the last non-zero transform coefficient in the scan order of the current block. Positional information may include prefix information indicating the column position of the last non-zero coefficient, prefix information indicating the row position of the last non-zero coefficient, suffix information indicating the column position of the last non-zero coefficient, and suffix information indicating the row position of the last non-zero coefficient. The syntax elements for positional information can be `last_sig_coeff_x_prefix`, `last_sig_coeff_y_prefix`, `last_sig_coeff_x_suffix`, and `last_sig_coeff_y_suffix`. Furthermore, non-zero transform coefficients can be referred to as effective coefficients.

[0418] Additionally, for example, residual information may include context syntax elements for transform coefficients in the current sub-block of the current block. These context syntax elements may include a valid coefficient flag indicating whether a transform coefficient is a non-zero transform coefficient, a parity level flag indicating the parity of the transform coefficient level, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a second transform coefficient level flag indicating whether the transform coefficient level is greater than a second threshold. Here, the valid coefficient flag may be `sig_coeff_flag`, the parity level flag may be `par_level_flag`, the first transform coefficient level flag may be `abs_level_gt1_flag`, and the second transform coefficient level flag may be `abs_level_gt3_flag` or `abs_level_gtx_flag`.

[0419] Alternatively, for example, the context syntax elements may include a valid coefficient flag indicating whether the transform coefficients are non-zero transform coefficients, a sign flag indicating the sign of the transform coefficients, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a parity level flag regarding the parity of the transform coefficient levels. Here, the valid coefficient flag may be sig_coeff_flag, the sign flag may be coeff_sign_flag, the first transform coefficient level flag may be abs_level_gt1_flag, and the parity level flag may be par_level_flag.

[0420] Additionally, for example, residual information may include bypass syntax elements compiled based on bypasses of the transform coefficients in the current sub-block of the current block. The bypass syntax elements may include coefficient value-related information about the values ​​of the transform coefficients. This coefficient value-related information may be `abs_remainder` and / or `dec_abs_level`.

[0421] Additionally, the bitstream may include prediction information for the current block. This prediction information may include information about the inter-frame prediction mode or intra-frame prediction mode performed on the current block. The encoding device can generate and encode the prediction information for the current block.

[0422] Simultaneously, the bitstream can be sent to the decoding device via a network or (digital) storage medium. Here, the network can include broadcast networks and / or communication networks, and the digital storage medium can include various storage media such as USB, SD, CD, DVD, Blu-ray, HDD, and SSD.

[0423] Figure 18 An encoding device for performing an image encoding method according to the document is illustrated schematically. Figure 17 The method disclosed in the article can be derived from Figure 18 The encoding device disclosed in the document executes the commands. Specifically, for example, Figure 18 The subtractor of the encoding device can perform Figure 17 The S1700, Figure 18 The converters and quantizers of the encoding device can perform Figure 17 The S1710, Figure 18 The entropy encoder of the encoding device can perform Figure 17 S1720 to S1740. In addition, although not shown, the process of deriving the prediction sample can be performed by the predictor of the encoding device, the process of deriving the reconstruction sample of the current block based on the residual sample and the prediction sample of the current block can be performed by the adder of the encoding device, and the process of encoding the prediction information of the current block can be performed by the entropy encoder of the encoding device.

[0424] Figure 19 The image decoding method performed by the decoding device according to the document is illustrated schematically. Figure 19 The method disclosed in the article can be derived from Figure 3 The decoding device disclosed in the document performs the operation. Specifically, for example, Figure 19 S1900 to S1930 can be executed by the entropy decoder of the decoding device, S1940 can be executed by the dequantizer and inverse transformer of the decoding device, and S1950 can be executed by the adder of the decoding device. Additionally, although not shown, the process of deriving the predicted sample can be executed by the predictor of the decoding device.

[0425] The decoding device receives a bitstream including residual information of the current block (S1900). The decoding device can receive image information including residual information about the current block via the bitstream. Here, the current block can be a compile block (CB) or a transform block (TB). The residual information can include syntax elements of the current sub-block within the current block. Here, syntax elements can include context syntax elements and bypass elements. That is, the residual information can include context syntax elements and bypass syntax elements of the current sub-block. Context syntax elements can indicate syntax elements compiled based on context, and bypass syntax elements can indicate syntax elements compiled by bypass (i.e., syntax elements compiled based on a uniform probability distribution).

[0426] For example, residual information may include syntax elements such as: transform_skip_flag, last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_suffix, coded_sub_block_flag, sig_coeff_flag, par_level_flag, abs_level_gt1_flag, abs_level_gtX_flag, abs_remainder, coeff_sign_flag, dec_abs_level, and / or mts_idx.

[0427] Specifically, for example, residual information may include a transform skip flag for the current block. The transform skip flag indicates whether a transform should be applied to the transform coefficients of the current block. In other words, the transform skip flag indicates whether a transform should be applied to the transform coefficients. The syntax element representing the transform skip flag can be the `transform_skip_flag` described above.

[0428] Additionally, for example, residual information may include positional information indicating the location of the last non-zero transform coefficient in the transform coefficient array of the current block. That is, residual information may include positional information indicating the location of the last non-zero transform coefficient in the scan order of the current block. Positional information may include prefix information indicating the column position of the last non-zero coefficient, prefix information indicating the row position of the last non-zero coefficient, suffix information indicating the column position of the last non-zero coefficient, and suffix information indicating the row position of the last non-zero coefficient. The syntax elements for positional information can be last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, and last_sig_coeff_y_suffix. Furthermore, non-zero transform coefficients can be referred to as effective coefficients.

[0429] Additionally, for example, residual information may include context syntax elements for transform coefficients in the current sub-block of the current block. These context syntax elements may include a valid coefficient flag indicating whether a transform coefficient is a non-zero transform coefficient, a parity level flag indicating the parity of the transform coefficient level, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a second transform coefficient level flag indicating whether the transform coefficient level is greater than a second threshold. Here, the valid coefficient flag may be `sig_coeff_flag`, the parity level flag may be `par_level_flag`, the first transform coefficient level flag may be `abs_level_gt1_flag`, and the second transform coefficient level flag may be `abs_level_gt3_flag` or `abs_level_gtx_flag`.

[0430] Alternatively, for example, the context syntax elements may include a valid coefficient flag indicating whether the transform coefficients are non-zero transform coefficients, a sign flag indicating the sign of the transform coefficients, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a parity level flag regarding the parity of the transform coefficient levels. Here, the valid coefficient flag may be sig_coeff_flag, the sign flag may be coeff_sign_flag, the first transform coefficient level flag may be abs_level_gt1_flag, and the parity level flag may be par_level_flag.

[0431] Additionally, for example, residual information may include bypass syntax elements compiled based on bypasses of the transform coefficients in the current sub-block of the current block. The bypass syntax elements may include coefficient value-related information about the values ​​of the transform coefficients. This coefficient value-related information may be `abs_remainder` and / or `dec_abs_level`.

[0432] Simultaneously, the bitstream may include prediction information for the current block. This prediction information may include information about the inter-frame prediction mode or intra-frame prediction mode performed on the current block. The decoding device can perform inter-frame or intra-frame prediction on the current block based on the prediction information received through the bitstream, and can derive prediction samples for the current block.

[0433] The decoding device derives a specific number of context compilation bins for the context syntax elements of the current sub-block of the current block (S1910). Here, the specific number can represent the maximum value mentioned above. That is, the maximum value can be the maximum sum of the numbers of context compilation bins for the context syntax elements of the current block's current sub-block.

[0434] As an example, the maximum value can be derived in units of transform blocks.

[0435] For example, the maximum value can be set to any value. When the current sub-block size is 4x4, the maximum value can be derived from one of 0 to 64. When the current sub-block size is 2x2, the maximum value can be derived from at least one of 0 to 16. For example, the maximum value can be set to 4.

[0436] Alternatively, for example, the maximum value can be derived based on the size of the current block (or the current child block within the current block). When the size of the current block (or the current child block within the current block) is 4x4, the derived maximum value can be derived as one of 0 to 64, while when the size of the current block (or the current child block within the current block) is 2x2, the derived maximum value can be derived as one of 0 to 16.

[0437] Alternatively, for example, the maximum value can be derived based on the size of the current block and the position of the current child block.

[0438] Additionally, for example, the maximum value can be derived based on positional information indicating the location of the last non-zero transform coefficient in the current block. For instance, the location of the last non-zero transform coefficient can be derived based on the positional information, and the length from the position of the first transform coefficient in the scan order of the current block to the position of the last non-zero transform coefficient can be derived. The maximum value can be derived based on this length. For example, the maximum value can be derived as the value obtained by multiplying the length by 1.75. Here, the length can correspond to the number of samples in the current block. That is, the length can be the number of samples in the current block. For example, when transform coefficients with a value of 0 are not included in the arrangement of transform coefficients in the current block, the length can be the number of samples in the current block. In other words, the maximum value can be derived based on the number of samples in the current block. For example, the maximum value can be derived as the value obtained by multiplying the number of samples in the current block by 1.75.

[0439] The decoding device decodes the context syntax elements of the current sub-block included in the residual information based on a specific number (S1920). The decoding device may decode the context syntax elements based on the maximum value.

[0440] For example, the decoding device can decode the context syntax elements of the transform coefficients of the current sub-block of the current block based on the context. The context syntax elements may include a valid coefficient flag indicating whether the transform coefficient is a non-zero transform coefficient, a parity level flag indicating the parity of the transform coefficient level, a first transform coefficient level flag indicating whether the transform coefficient is greater than a first threshold, and a second transform coefficient level flag indicating whether the transform coefficient level is greater than a second threshold. Here, the valid coefficient flag may be `sig_coeff_flag`, the parity level flag may be `par_level_flag`, the first transform coefficient level flag may be `abs_level_gt1_flag`, and the second transform coefficient level flag may be `abs_level_gt3_flag` or `abs_level_gtx_flag`.

[0441] Alternatively, for example, the context syntax elements may include a valid coefficient flag indicating whether the transform coefficients are non-zero, a sign flag indicating the sign of the transform coefficients, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a parity level flag regarding the parity of the transform coefficient levels. Here, the valid coefficient flag may be sig_coeff_flag, the sign flag may be coeff_sign_flag, the first transform coefficient level flag may be abs_level_gt1_flag, and the parity level flag may be par_level_flag.

[0442] Specifically, when the sum of the number of context compilation bins of the context syntax elements of the transform coefficients in the scan order of the transform coefficients in the current sub-block reaches the maximum value (i.e., greater than or equal to the maximum value), the signaling and decoding of the context syntax elements of the transform coefficients can be omitted (i.e., the context syntax elements of the transform coefficients can be notified without signaling), and the bypass syntax elements compiled based on the bypass of the transform coefficients can be decoded, and the value of the transform coefficients can be derived based on the decoded bypass syntax elements.

[0443] For example, when the number of context compilation bins for context syntax elements of transform coefficients derived before a specific transform coefficient in the current sub-block reaches a certain number, the bypass syntax elements for the specific transform coefficients included in the residual information can be decoded. Signaling and decoding of the context syntax elements for the specific transform coefficients can be omitted. The value of the specific transform coefficient can be derived based on the bypass syntax elements.

[0444] For example, when the sum of the number of context compilation bins of the context syntax elements of the current sub-block from #0 to #n transform coefficients reaches the maximum value, the signaling and decoding of the context syntax elements of the current sub-block's #n+1 transform coefficients can be omitted, and the bypass syntax elements of the #n+1 transform coefficients included in the residual information can be decoded.

[0445] In other words, for example, when the sum of the number of context compilation bins for the valid coefficient flags, first transform coefficient level flags, parity level flags, and second transform coefficient level flags of the transform coefficients from #0 to #n determined by the scan order in the current sub-block reaches the maximum value (i.e., greater than or equal to the maximum value), the valid coefficient flags, first transform coefficient level flags, parity level flags, and second transform coefficient level flags of the transform coefficients of #n+1 determined by the scan order can be omitted, and the bypass syntax element based on bypass compilation of the #n+1 quantized transform coefficient can be decoded, and the value of the #n+1 quantized transform coefficient can be derived based on the value of the bypass syntax element.

[0446] Alternatively, for example, when the sum of the context compilation bins of the valid coefficient flag, sign flag, first transform coefficient level flag, and parity level flag of the transform coefficients from #0 to #n, determined by the scan order in the transform coefficients of the current sub-block, reaches the maximum value (i.e., greater than or equal to the maximum value), the signaling and decoding of the valid coefficient flag, sign flag, first transform coefficient level flag, and parity level flag of the transform coefficients of #n+1, determined by the scan order, can be omitted. The bypass syntax element of the bypass compilation of the #n+1 quantized transform coefficient can be decoded, and the value of the #n+1 quantized transform coefficient can be derived based on the value of the element.

[0447] The decoding device derives the transform coefficients of the current sub-block based on the context syntax elements of the decoding (S1930).

[0448] The decoding device can derive the values ​​of the transform coefficients based on the values ​​of the context syntax elements of the entropy-decoded transform coefficients. Additionally, residual information can include a sign flag indicating the sign of the transform coefficients. The decoding device can derive the sign of the transform coefficients based on the sign flag. The syntax element representing the sign flag can be `coeff_sign_flag`. For example, the decoding device can derive the transform coefficients based on both their values ​​and signs.

[0449] The decoding device derives the residual sample of the current block based on the transform coefficients (S1940). For example, the decoding device can derive the residual sample of the current block based on the transform coefficients. That is, the decoding device can derive the residual sample of the current sub-block in the current block based on the transform coefficients.

[0450] For example, when the transform skip flag for the current block is set to 1, the decoding device can derive the residual sample of the current block based on the transform coefficients. Alternatively, when the transform skip flag for the current block is set to 1, the decoding device can dequantize the transform coefficients to derive the residual sample of the current block.

[0451] Alternatively, for example, when the transform skip flag for the current block is set to 1, the decoding device can rearrange the transform coefficients and derive the rearranged transform coefficients as residual samples for the current block. For example, the decoding device can rearrange the transform coefficients using various rearrangement methods. That is, the decoding device can move the transform coefficients from their derived positions to other positions using various rearrangement methods.

[0452] As an example, the decoding device can rearrange the transform coefficients by rotating them 180 degrees. Specifically, for example, the decoding device can rearrange the transform coefficients of the current block to a position symmetrical about the center of the current block.

[0453] Alternatively, as an example, the decoding device can rearrange the transform coefficients using an anti-diagonal mirroring rearrangement method. Specifically, for example, the decoding device can rearrange the transform coefficients to positions symmetrical about the right-upper diagonal of the current block. Here, the right-upper diagonal can refer to the right-upper diagonal passing through the center of the current block.

[0454] Alternatively, as an example, the decoding device can rearrange the transform coefficients using a diagonal mirroring method. Specifically, for example, the decoding device can rearrange the transform coefficients to positions symmetrical about the upper-left diagonal of the current block. Here, the upper-left diagonal can refer to the upper-left diagonal that passes through the center of the current block.

[0455] Alternatively, as an example, the decoding device can rearrange the transform coefficients using a vertical flipping rearrangement method. Specifically, for example, the decoding device can rearrange the transform coefficients of the current block to a position symmetrical with respect to the vertical axis of the current block. Here, the vertical axis can be a vertical line passing through the center of the current block.

[0456] Alternatively, as an example, the decoding device can rearrange the transform coefficients using a horizontal flipping rearrangement method. The decoding device can rearrange the transform coefficients of the current block to a position symmetrical about the horizontal axis of the current block. Here, the horizontal axis can be a horizontal line passing through the center of the current block.

[0457] Alternatively, as an example, the decoding device can rearrange the transform coefficients by deriving layers distinguished based on their distance from a reference sample of the current block and rearranging the layers according to the reverse raster order.

[0458] For example, the decoding device can set layers for the current block based on the distance to a reference sample of the current block. Here, the reference sample can include the top reference sample and the left reference sample of the current block. For example, when the size of the current block is NxN and the x and y components of the top-left sample position of the current block are 0, the left reference sample can be p[-1][0] to p[-1][2N-1] and the top reference sample can be p[0][-1] to p[2N-1][-1]. When the size of the current block is NxN, the layers can include the first layer to the Nth layer. The Nth layer can be the last layer, and N can be equal to the width or height of the current block. For example, the first layer can include a position 1 distance from the nearest reference sample, the second layer can include a position 2 distance from the nearest reference sample, and the Nth layer can include a position N distance from the nearest reference sample.

[0459] Subsequently, the decoding device can scan the transform coefficients in reverse raster order. In other words, the decoding device can scan the transform coefficients of the current block from right to left and from bottom to top. Next, the decoding device can rearrange the transform coefficients in the layers according to the scan order. Here, the rearrangement of transform coefficients can be performed in the order of layers 1 to N. Alternatively, the transform coefficients can be rearranged in the rearranged layers based on either lateral priority scanning or vertical priority scanning.

[0460] For example, the transformation coefficients can be preferentially rearranged from right to left at the lateral position of the upper left of the rearranged layer, and if a vertical position of the upper left of the rearranged layer exists, the transformation coefficients can be rearranged from top to bottom at the vertical position of the upper left of the rearranged layer after being rearranged at the lateral position. Alternatively, for example, the transformation coefficients can be preferentially rearranged from top to bottom at the vertical position of the upper left of the rearranged layer, and if a lateral position of the upper left of the rearranged layer exists, the transformation coefficients can be rearranged from left to right at the lateral position of the upper left of the rearranged layer after being rearranged at the vertical position.

[0461] Alternatively, as an example, the decoding device can rearrange the transform coefficients by deriving layers differentiated based on their distance from a reference sample of the current block and rearranging the layers according to the diagonal scan order.

[0462] For example, the decoding device can set layers for the current block based on the distance to a reference sample of the current block. Here, the reference sample can include the top reference sample and the left reference sample of the current block. For example, when the size of the current block is NxN and the x and y components of the top-left sample position of the current block are 0, the left reference sample can be p[-1][0] to p[-1][2N-1] and the top reference sample can be p[0][-1] to p[2N-1][-1]. When the size of the current block is NxN, the layers can include the first layer to the Nth layer. The Nth layer can be the last layer, and N can be equal to the width or height of the current block. For example, the first layer can include a position 1 distance from the nearest reference sample, the second layer can include a position 2 distance from the nearest reference sample, and the Nth layer can include a position N distance from the nearest reference sample.

[0463] Afterward, the decoding device can scan the transform coefficients in a diagonal scan order. In other words, the decoding device can scan the transform coefficients of the current block from top right to bottom left and from bottom right to top left. Next, the decoding device can rearrange the transform coefficients in the layers according to the scan order. Here, the rearrangement of transform coefficients can be performed in the order of layers 1 to N. Alternatively, the transform coefficients can be rearranged in the rearranged layers based on either a horizontal priority scan or a vertical priority scan.

[0464] For example, the transformation coefficients can be preferentially rearranged from right to left at the lateral position of the upper left of the rearranged layer, and if a vertical position of the upper left of the rearranged layer exists, the transformation coefficients can be rearranged from top to bottom at the vertical position of the upper left of the rearranged layer after being rearranged at the lateral position. Alternatively, for example, the transformation coefficients can be preferentially rearranged from top to bottom at the vertical position of the upper left of the rearranged layer, and if a lateral position of the upper left of the rearranged layer exists, the transformation coefficients can be rearranged from left to right at the lateral position of the upper left of the rearranged layer after being rearranged at the vertical position.

[0465] Alternatively, for example, the decoding device may set layers for the current block based on the distance to the upper reference sample of the current block. For example, when the size of the current block is NxN and the x and y components of the upper left sample position of the current block are 0, the upper reference sample may be p[0][-1] to p[2N-1][-1]. When the size of the current block is NxN, the layers may include the first layer to the Nth layer. The Nth layer may be the last layer, and N may be equal to the width or height of the current block. For example, the first layer may include positions at a distance of 1 from the nearest reference sample, the second layer may include positions at a distance of 2 from the nearest reference sample, and the Nth layer may include positions at a distance of N from the nearest reference sample. In other words, the first layer may be the first row of the current block, the second layer may be the second row of the current block, and the Nth layer may be the Nth row of the current block.

[0466] Afterward, the decoding device can scan the transform coefficients in a diagonal scan order. In other words, the decoding device can scan the transform coefficients of the current block from top right to bottom left and from bottom right to top left. Next, the decoding device can rearrange the transform coefficients in the layers according to the scan order. Here, the rearrangement of transform coefficients can be performed in the order of layers 1 to N. The rearrangement of transform coefficients can be performed sequentially from layers 1 to N, and the transform coefficients can be rearranged from right to left at the positions of the rearranged layers.

[0467] Alternatively, for example, the decoding device may set layers for the current block based on the distance to the left reference sample of the current block. For example, when the size of the current block is NxN and the x and y components of the top-left sample position of the current block are 0, the left reference sample may be p[-1][0] to p[-1][2N-1]. When the size of the current block is NxN, the layers may include a first layer to an Nth layer. The Nth layer may be the last layer, and N may be equal to the width or height of the current block. For example, the first layer may include a position at a distance of 1 from the nearest left reference sample, the second layer may include a position at a distance of 2 from the nearest left reference sample, and the Nth layer may include a position at a distance of N from the nearest reference sample. In other words, the first layer may be the first column of the current block, the second layer may be the second column of the current block, and the Nth layer may be the Nth column of the current block.

[0468] Afterward, the decoding device can scan the transform coefficients in a diagonal scanning order. In other words, the decoding device can scan the transform coefficients of the current block from top right to bottom left and from bottom right to top left. Next, the decoding device can rearrange the transform coefficients in the layers according to the scanning order. Here, the rearrangement of transform coefficients can be performed in the order of layers 1 to N. The rearrangement of transform coefficients can be performed sequentially from layer 1 to layer N, and the transform coefficients can be rearranged from top to bottom at the positions of the rearranged layers.

[0469] Simultaneously, the decoding device can determine whether to rearrange the transform coefficients based on various conditions. Alternatively, the decoding device can derive a rearrangement method applicable to the transform coefficients based on various conditions.

[0470] As an example, the decoding device can receive the transform skip flag for the current block and determine whether to rearrange the transform coefficients based on this flag. The transform skip flag indicates whether a transform should be applied to the transform coefficients. For example, when the transform skip flag is 1, it can be determined that the transform coefficients should be rearranged. In other words, when the transform skip flag is 1, the decoding device can rearrange the transform coefficients. When the transform skip flag is 0, it can be determined that the transform coefficients should not be rearranged. In other words, when the transform skip flag is 0, the decoding device can derive the residual samples of the current block based on the transform coefficients without rearranging the transform coefficients.

[0471] Alternatively, as another example, the decision to rearrange the transform coefficients can be based on the number of samples in the current block. For example, if the number of samples in the current block is less than a certain value, it can be determined that the transform coefficients should be rearranged. In other words, the decoding device can rearrange the transform coefficients when the number of samples in the current block is less than a certain value. If the number of samples in the current block is greater than or equal to a certain value, it can be determined that the transform coefficients should not be rearranged. In other words, if the number of samples in the current block is equal to or greater than a certain value, the decoding device can generate residual information about the current block based on the transform coefficients and encode it without rearranging the transform coefficients. This specific value can be 64.

[0472] Alternatively, for example, when the number of samples in the current block is less than 64, the decoding device can rearrange the transform coefficients by rotating them 180 degrees. When the number of samples in the current block is 64 or more, the decoding device may not rearrange the transform coefficients.

[0473] Alternatively, as another example, the method for rearranging the transformation coefficients can be determined based on the number of samples in the current block.

[0474] For example, when the number of samples in the current block is less than 64, the decoding device can rearrange the transform coefficients by rotating them by 180 degrees. When the number of samples in the current block is 64 or more, the decoding device can rearrange the transform coefficients by mirroring them. Alternatively, as another example, when the number of samples in the current block is less than 64, the decoding device can rearrange the transform coefficients using one of the above rearrangement methods, while when the number of samples in the current block is 64 or more, the decoding device may not rearrange the transform coefficients.

[0475] Alternatively, as another example, the decision to rearrange the residual coefficients can be based on the shape of the current block. For instance, if the current block is a square block, it can be determined that the transform coefficients should be rearranged. In other words, if the current block is a square block, the decoding device can rearrange the transform coefficients. If the current block is a non-square block, it can be determined that the transform coefficients should not be rearranged. In other words, if the current block is a non-square block, the decoding device can derive the residual samples of the current block based on the transform coefficients without rearranging the transform coefficients.

[0476] Alternatively, as another example, the method for rearranging the transform coefficients can be determined based on the shape of the current block. For instance, when the current block is a square block, the decoding device can rearrange the transform coefficients using a mirroring method, while when the current block is a non-square block, the decoding device can rearrange the transform coefficients using a method that rotates them by 180 degrees.

[0477] Alternatively, as another example, the decision to rearrange the transform coefficients can be based on the width-to-height ratio of the current block. For instance, when the width-to-height ratio of the current block is greater than 2 or less than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is greater than 2 or less than 1 / 2), the decoding device can rearrange the transform coefficients using a mirroring rearrangement method. Conversely, when the width-to-height ratio of the current block is less than 2 but greater than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is less than 2 but greater than 1 / 2), the decoding device can derive the residual sample of the current block based on the transform coefficients without rearranging them.

[0478] Alternatively, as another example, the method for rearranging the transform coefficients can be determined based on the ratio of the width to the height of the current block. For instance, when the ratio of the width to the height of the current block is greater than 2 or less than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is greater than 2 or less than 1 / 2), the decoding device can rearrange the transform coefficients using a mirroring method. Conversely, when the ratio of the width to the height of the current block is less than 2 but greater than 1 / 2 (i.e., when the value obtained by dividing the width of the current block by its height is less than 2 but greater than 1 / 2), the decoding device can rearrange the transform coefficients using a 180-degree rotation method.

[0479] Alternatively, as another example, the decision to rearrange the transform coefficients can be based on the intra-prediction mode of the current block. For instance, if the prediction direction of the intra-prediction mode for the current block is horizontal, or if the intra-prediction mode primarily uses the left reference sample for prediction, the decoding device can rearrange the transform coefficients using a vertical flip rearrangement method. In other cases, the decoding device can derive the residual samples of the current block based on the transform coefficients without rearranging them. Alternatively, for example, if the prediction direction of the intra-prediction mode for the current block is vertical, or if the intra-prediction mode primarily uses the top reference sample for prediction, the decoding device can rearrange the transform coefficients using a vertical flip rearrangement method. In other cases, the decoding device can derive the residual samples of the current block based on the transform coefficients without rearranging them.

[0480] Alternatively, as another example, the method for rearranging the transform coefficients can be determined based on the intra-prediction mode of the current block. For instance, when the prediction direction of the intra-prediction mode of the current block is horizontal, or when the intra-prediction mode of the current block primarily uses the left reference sample for prediction, the decoding device can rearrange the transform coefficients using a vertical flip method. Conversely, when the prediction direction of the intra-prediction mode of the current block is vertical, or when the intra-prediction mode of the current block primarily uses the top reference sample for prediction, the decoding device can also rearrange the transform coefficients using a vertical flip method.

[0481] Alternatively, as another example, the decision to rearrange the transform coefficients can be based on a flag received via a high-level syntax indicating whether to rearrange them. For example, the decoding device can receive the flag indicating whether to rearrange the transform coefficients via a sequence parameter set (SPS) or a picture parameter set (PPS) and determine whether to rearrange the transform coefficients based on that flag.

[0482] Alternatively, as another example, the rearrangement method of the transform coefficients can be determined based on information indicating the rearrangement method of the transform coefficients received via a high-level syntax. For example, the decoding device can use a sequence parameter set (SPS) or a picture parameter set (PPS) to signal information indicating the rearrangement method of the transform coefficients, and determine whether to rearrange the transform coefficients based on that information.

[0483] Alternatively, as another example, the decision to rearrange the transform coefficients can be determined based on the prediction mode of the current block. For instance, if the prediction mode of the current block is intra-frame prediction, it can be determined that the transform coefficients should be rearranged. In other words, when the prediction mode of the current block is intra-frame prediction, the decoding device can rearrange the transform coefficients. Conversely, if the prediction mode of the current block is inter-frame prediction, it can be determined that the transform coefficients should not be rearranged. In other words, when the prediction mode of the current block is inter-frame prediction, the decoding device can derive the residual samples of the current block based on the transform coefficients without rearranging them.

[0484] Alternatively, as another example, the decision to rearrange the transform coefficients can be determined based on whether or not they have been quantized. For instance, when quantization is applied to the transform coefficients, it can be determined that they need to be rearranged. In other words, when quantization is applied to the transform coefficients, the decoding device can rearrange them. Conversely, when quantization is not applied to the transform coefficients, it can be determined that they should not be rearranged. In other words, when quantization is not applied to the transform coefficients, the decoding device can derive the residual samples of the current block based on the transform coefficients without rearranging them.

[0485] Alternatively, for example, when the transform skip flag of the current block is 0, the decoding device may perform an inverse transform on the transform coefficients to derive the residual samples of the current block. Or, for example, when the transform skip flag of the current block is 0, the decoding device may dequantize the transform coefficients and perform an inverse transform on the dequantized coefficients to derive the residual samples of the current block.

[0486] The decoding device generates a reconstructed image based on residual samples (S1950). For example, the decoding device can derive prediction samples by performing an inter-frame prediction mode or an intra-frame prediction mode on the current block based on prediction information received via the bitstream, and can generate a reconstructed image by adding prediction samples and residual samples. For example, the prediction information may include information indicating the intra-frame prediction mode of the current block. Alternatively, the prediction information may include motion-related information of the current block.

[0487] Subsequently, if necessary, in-loop filtering processes such as deblocking, SAO, and / or ALF can be applied to the reconstructed image to improve the subjective / objective image quality as described above.

[0488] Figure 20 The document schematically illustrates a decoding device for performing an image decoding method. Figure 19 The method disclosed in the article can be derived from Figure 20 The decoding device disclosed in the document performs the operation. Specifically, for example, Figure 20 The entropy decoder of the decoding device can perform Figure 19 S1900 to S1930, and Figure 20The dequantizer and inverse converter of the decoding device can perform Figure 19 S1940, Figure 20 The adder of the decoding device can perform Figure 19 S1950. Additionally, although not shown, the process of obtaining prediction information for the current block via a bitstream can be achieved by... Figure 20 The process of executing the entropy decoder of the decoding device and deriving the predicted samples of the current block based on the prediction information can be performed by... Figure 20 The predictor of the decoding device is executed.

[0489] According to the aforementioned document, the efficiency of residual compilation can be improved.

[0490] Additionally, according to the document, the amount of context-based compilation data can be reduced by limiting the sum of the number of context compilation bins of the context syntax elements of the transform coefficients in the current block included in the residual information to a predetermined maximum value or less.

[0491] In addition, according to the document, when adjusting the number of context compilation bins for the current sub-block, it is determined by the sum of the number of context compilation bins for each context syntax element, rather than by compiling for each context syntax element. This reduces residual compilation complexity and improves overall compilation efficiency.

[0492] In the above embodiments, the method is described based on a flowchart having a series of steps or blocks. This disclosure is not limited to the order of the above steps or blocks. Some steps or blocks may be performed in a different order than the other steps or blocks described above, or may be performed simultaneously. Furthermore, those skilled in the art will understand that the steps shown in the flowchart are not exclusive, and may include other steps, or one or more steps in the flowchart may be deleted without affecting the scope of this disclosure.

[0493] The embodiments described in this specification can be executed by being implemented on a processor, microprocessor, controller, or chip. For example, the functional unit shown in each figure can be executed by being implemented on a computer, processor, microprocessor, controller, or chip. In this case, the information for implementation (e.g., information about instructions) or algorithm can be stored in a digital storage medium.

[0494] Furthermore, the decoding and encoding devices using this disclosure can be included in the following devices: multimedia broadcasting transmitting / receiving devices, mobile communication terminals, home theater video devices, digital cinema video devices, surveillance cameras, video chat devices, real-time communication devices such as video communication, mobile streaming devices, storage media, portable cameras, VoD service providing devices, over-the-top (OTT) video devices, internet streaming service providing devices, three-dimensional (3D) video devices, teleconferencing video devices, transportation user equipment (e.g., vehicle user equipment, aircraft user equipment, and ship user equipment), and medical video devices; and the decoding and encoding devices using this disclosure can be used to process video signals or data signals. For example, over-the-top (OTT) video devices can include game consoles, Blu-ray players, internet-access televisions, home theater systems, smartphones, tablet computers, digital video recorders (DVRs), etc.

[0495] Furthermore, the processing methods of this disclosure can be generated in the form of a computer-executable program and can be stored in a computer-readable recording medium. Multimedia data with data structures according to this disclosure can also be stored in a computer-readable recording medium. A computer-readable recording medium includes all types of storage devices in which computer-readable data is stored. Computer-readable recording media can include, for example, BD, Universal Serial Bus (USB), ROM, PROM, EPROM, EEPROM, RAM, CD-ROM, magnetic tape, floppy disk, and optical data storage devices. Additionally, computer-readable recording media include media implemented in the form of a carrier wave (e.g., transmission via the Internet). Furthermore, bitstreams generated by encoding methods can be stored in a computer-readable recording medium or transmitted via wired / wireless communication networks.

[0496] Furthermore, embodiments of this disclosure can be implemented using computer program products based on program code, and the program code can be executed on a computer using embodiments of this disclosure. The program code can be stored on a computer-readable medium.

[0497] Figure 21 A structural diagram of a content streaming system using this disclosure is illustrated.

[0498] The content streaming system using the implementation methods described in this document may primarily include an encoding server, a streaming server, a network server, a media storage device, a user device, and a multimedia input device.

[0499] An encoding server compresses content input from multimedia input devices such as smartphones, cameras, or camcorders into digital data to generate a bitstream, which is then sent to a streaming server. As another example, when multimedia input devices such as smartphones, cameras, or camcorders generate bitstreams directly, the encoding server can be omitted.

[0500] Bitstreams can be generated using the encoding methods or bitstream generation methods described in this document, and the streaming server can temporarily store the bitstreams during the sending or receiving of the bitstreams.

[0501] The streaming server sends multimedia data to the user's device via a web server based on user requests, and the web server acts as a medium for notifying the user of services. When a user requests a desired service from the web server, the web server delivers the request to the streaming server, and the streaming server sends multimedia data to the user. In this scenario, the content streaming system may include a separate control server. In this case, the control server is used to control the commands / responses between devices within the content streaming system.

[0502] A streaming server can receive content from media storage and / or encoding servers. For example, when receiving content from an encoding server, the content can be received in real time. In this case, to provide a smooth streaming service, the streaming server can store the bitstream for a predetermined period of time.

[0503] Examples of user devices may include mobile phones, smartphones, laptops, digital broadcast terminals, personal digital assistants (PDAs), portable multimedia players (PMPs), navigators, touchscreen PCs, tablet PCs, ultrabooks, wearable devices (e.g., smartwatches, smart glasses, and head-mounted displays), digital TVs, desktop computers, and digital signage. Each server within the content streaming system can operate as a distributed server, in which case data received from each server can be distributed.

Claims

1. An image decoding method performed by a decoding device, comprising: Obtain the transform skip flag for the current block from the bitstream; The residual information of the current block is obtained from the bit stream based on the transformation skip flag; Export a specific number of bins of the current sub-blocks of the current block using the context model for decoding, wherein the specific number is exported on a transform block basis; Decode the context syntax elements of the current sub-block included in the residual information based on the specific number; The transform coefficients of the current sub-block are derived based on the context syntax elements of the decoded code. The residual samples of the current block are derived based on the transformation coefficients; and The reconstructed image is generated based on the residual samples. Specifically, when the number of bins decoded using the context model for the transform coefficients derived before the specific transform coefficients of the current sub-block reaches the specific number, the bypass syntax elements of the specific transform coefficients included in the residual information are decoded, and The specific number is set based on the size of the current block.

2. The image decoding method according to claim 1, in, The context syntax elements of the specific transform coefficient include: a valid coefficient flag indicating whether the specific transform coefficient is a non-zero transform coefficient; a sign flag indicating the sign of the specific transform coefficient; a first transform coefficient level flag indicating whether the transform coefficient level of the specific transform coefficient is greater than a first threshold; a parity level flag indicating the parity of the transform coefficient level; and a second transform coefficient level flag indicating whether the transform coefficient level is greater than a second threshold. In this context, the decoding of the context syntax elements for the specific transform coefficients is omitted, and In this context, the bypass syntax element of the specific transform coefficient is decoded regardless of the second transform coefficient level flag.

3. The image decoding method according to claim 1, wherein, The context syntax elements include: a valid coefficient flag indicating whether the transform coefficient is a non-zero transform coefficient, a parity level flag indicating the parity of the transform coefficient level, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a second transform coefficient level flag indicating whether the transform coefficient level is greater than a second threshold.

4. The image decoding method according to claim 1, wherein, The context syntax elements include: a valid coefficient flag indicating whether the transform coefficient is a non-zero transform coefficient, a sign flag indicating the sign of the transform coefficient, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a parity level flag indicating the parity of the transform coefficient level.

5. The image decoding method according to claim 1, wherein, The values ​​of the specific transform coefficients are derived based on the values ​​of the decoded bypass syntax elements.

6. The image decoding method according to claim 1, wherein... Deriving the residual sample of the current block based on the transformation coefficients includes: When the value of the transformation skip flag is 1, the transformation coefficients are rearranged; as well as The residual samples are derived based on the rearranged transformation coefficients.

7. The image decoding method according to claim 6, wherein, The rearrangement of the transformation coefficients includes: The transformation coefficients of the current block are rearranged to positions that are symmetric about the vertical axis of the current block.

8. The image decoding method according to claim 6, wherein, The rearrangement of the transformation coefficients includes: The transformation coefficients of the current block are rearranged to positions that are symmetric to the horizontal axis of the current block.

9. The image decoding method according to claim 6, wherein, The rearrangement of the transformation coefficients includes: The layer of the current block is set based on the distance from the reference sample of the current block; The transformation coefficients are scanned in diagonal scan order; and The transformation coefficients are rearranged in the layer according to the scan order. The reference samples include the upper reference sample and the left reference sample of the current block.

10. An image encoding method performed by an encoding device, comprising: Export the residual samples of the current block; Export the transform skip flag to determine whether to apply a transform to the current block; The transformation coefficients of the current sub-block of the current block are derived based on the residual samples and the transformation skip flag. A specific number of bins encoded using the context model are derived from the current sub-block of the current block, wherein the specific number is derived on a transform block basis; Encoding context syntax elements based on the specified number; and Generate a bitstream including the transform skip flag and residual information of the current block, including encoded context syntax elements. Specifically, when the number of bins encoded using the context model for transform coefficients derived before a specific transform coefficient in the current sub-block reaches the specific number, the bypass syntax elements for the specific transform coefficient included in the residual information are encoded, and The specific number is set based on the size of the current block.

11. The image encoding method according to claim 10, wherein, The context syntax elements include: a valid coefficient flag indicating whether the transform coefficient is a non-zero transform coefficient, a parity level flag indicating the parity of the transform coefficient level, a first transform coefficient level flag indicating whether the transform coefficient level is greater than a first threshold, and a second transform coefficient level flag indicating whether the transform coefficient level is greater than a second threshold.

12. The image encoding method according to claim 10, in, The context syntax elements of the specific transform coefficient include: a valid coefficient flag indicating whether the specific transform coefficient is a non-zero transform coefficient; a sign flag indicating the sign of the specific transform coefficient; a first transform coefficient level flag indicating whether the transform coefficient level of the specific transform coefficient is greater than a first threshold; a parity level flag indicating the parity of the transform coefficient level; and a second transform coefficient level flag indicating whether the transform coefficient level is greater than a second threshold. In this context, the encoding of the context syntax elements for the specific transform coefficients is omitted, and The bypass syntax element of the specific transform coefficient is encoded, regardless of the second transform coefficient level flag.

13. A non-transitory computer-readable storage medium storing a computer program and a bit stream, wherein when the computer program is executed by a computer, the computer performs an encoding method to generate the bit stream: Export the residual samples of the current block; Export the transform skip flag to determine whether to apply a transform to the current block; The transformation coefficients of the current sub-block of the current block are derived based on the residual samples and the transformation skip flag. A specific number of bins encoded using the context model are derived from the current sub-block of the current block, wherein the specific number is derived on a transform block basis; Encoding context syntax elements based on the specified number; and Generate a bitstream including the transform skip flag and residual information of the current block, including encoded context syntax elements. Specifically, when the number of bins encoded using the context model for transform coefficients derived before a specific transform coefficient in the current sub-block reaches the specific number, the bypass syntax elements for the specific transform coefficient included in the residual information are encoded, and The specific number is set based on the size of the current block.

14. A method of sending, comprising: The following operations are performed to generate a bitstream of residual information for the current block, including a transform skip flag and encoded context syntax elements: deriving residual samples of the current block; deriving the transform skip flag indicating whether a transform is applied to the current block; deriving transform coefficients of the current sub-blocks of the current block based on the residual samples and the transform skip flag; deriving a specific number of bins encoded using the context model for the current sub-blocks of the current block; encoding the context syntax elements based on the specific number of bins; and generating the bitstream, wherein... The specific number is derived in units of transform blocks; as well as Send the bit stream, Specifically, when the number of bins encoded using the context model for transform coefficients derived before a specific transform coefficient in the current sub-block reaches the specific number, the bypass syntax elements for the specific transform coefficient included in the residual information are encoded, and The specific number is set based on the size of the current block.