Encoding and decoding methods, bitstreams, encoders, decoders, and computer storage media

TWI939511BActive Publication Date: 2026-09-21GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
TW111123498
Authority / Receiving Office
TW · TW
Patent Type
Patents
Current Assignee / Owner
Priority Date
2021-06-29
Filing Date
2022-06-23
Publication Date
2026-09-21
Estimated Expiration
2042-06-22

AI Technical Summary

Technical Problem

Existing image codecs with high bit width, high quality, and high bit rate (three-high images) face inefficiencies due to increased overhead and waste in the code stream, particularly when encoding and decoding larger coefficients, which are not effectively managed by current methods.

Method used

A method for encoding and decoding that analyzes the code stream to determine the last non-zero coefficient position, allowing for efficient encoding and decoding by flipping the coordinate information of this position based on the distribution of non-zero coefficients, reducing overhead and improving compression efficiency.

Benefits of technology

This approach reduces the number of codes in the code stream, enhancing compression efficiency by optimizing the encoding and decoding process for high-bit-width, high-bit-rate, and high-quality images, including lossless compression scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure TWG2TB001911628_001
    Figure TWG2TB001911628_001
  • Figure TWG2TB001911628_002
    Figure TWG2TB001911628_002
  • Figure TWG2TB001911628_003
    Figure TWG2TB001911628_003
Patent Text Reader

Abstract

This application discloses an encoding / decoding method, a bitstream, an encoder, a decoder, and a computer storage medium. The method includes: parsing the bitstream to determine the component identification information of the current slice and determining the coordinate information of the last non-zero coefficient of the current block corresponding to the component of the current slice; when the component identification information indicates that the component of the current slice is flipped using the position of the last non-zero coefficient, calculating the coordinate information of the last non-zero coefficient to obtain the position of the last non-zero coefficient of the current block; and decoding all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block. This improves compression efficiency in high-bit-width, high-bit-rate, high-quality, or lossless image encoding / decoding scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The embodiments of this application relate to the field of image encoding and decoding technology, and in particular to an encoding and decoding method, a bitstream, an encoder, a decoder and a computer storage medium. [Previous Technology]

[0002] With the increasing demands for image display quality, the field of computer vision has received more and more attention. In recent years, image processing technology has been successfully applied in various industries. Regarding the encoding and decoding process of images, at the encoding end, the image data to be encoded is compressed and encoded through an entropy coding unit after transformation and quantization. The bitstream generated after entropy coding is transmitted to the decoding end; then, the bitstream is parsed, and after inverse quantization and inverse transform processing, the original input image data can be recovered.

[0003] Currently, high-bit-width, high-quality, and high-bit-rate image encoding and decoding (referred to as "high-three-high images") typically require more and larger encoding and decoding coefficients compared to low-bit-width, low-quality, and low-bit-rate images (which can be called "conventional images"). Therefore, existing solutions for high-three-high images may incur greater overhead and waste in the bitstream. [Summary of the Invention]

[0004] This application provides an encoding / decoding method, a bitstream, an encoder, a decoder, and a computer storage medium, which can be applied to image encoding / decoding scenarios with high bit width, high bit rate, high quality, or lossless compression, and can improve compression efficiency.

[0005] The technical solution of the embodiments of this application can be implemented as follows:

[0006] In a first aspect, embodiments of this application provide a decoding method applied to a decoder, the method comprising:

[0007] Analyze the bitstream to determine the component identifier information of the current slice, and determine the coordinate information of the last non-zero coefficient of the current block corresponding to the component of the current slice;

[0008] When the component identification message indicates that the component of the current block is flipped using the last non-zero coefficient position, the coordinate message of the last non-zero coefficient is calculated to obtain the position of the last non-zero coefficient of the current block;

[0009] Decode all coefficients before the position of the last non-zero coefficient according to the preset scanning order to determine the coefficients of the current block.

[0010] In a second aspect, embodiments of this application provide an encoding method applied to an encoder, the method comprising:

[0011] Determine the component identification message of the current slice, and determine the position of the last non-zero coefficient of the current block corresponding to the component of the current slice;

[0012] Determine the coordinate information of the last non-zero coefficient of the current block based on the component identification information and the position of the last non-zero coefficient;

[0013] All coefficients before the position of the last non-zero coefficient are encoded according to the preset scanning order, and the bit information, component identification information and coordinate information of the last non-zero coefficient are written into the bit stream after encoding.

[0014] In a third aspect, embodiments of this application provide a bitstream generated by bit encoding a message to be encoded, the message to be encoded including at least one of the following: a first syntax element identifier message, a second syntax element identifier message, a third syntax element identifier message, a component identifier message, a last coefficient enable identifier message, and a sub-block preset encoding identifier message; wherein...

[0015] The first syntax element identifier message is used to indicate whether the current sequence is allowed to use the last non-zero coefficient position flip; the second syntax element identifier message is used to indicate whether the current sequence uses the standard extended version; the third syntax element identifier message is used to indicate whether the current sequence uses range extension; the component identifier message is used to indicate whether the components of the current slice use the last non-zero coefficient position flip; the last coefficient enable identifier message is used to indicate whether the current block uses the last coefficient position; the sub-block preset encoding identifier message is used to indicate whether the sub-block to be encoded in the current block is preset encoded; wherein, the current sequence includes the current slice, and the current slice includes the current block.

[0016] In a fourth aspect, embodiments of this application provide an encoder, which includes a first determining unit and an encoding unit; wherein,

[0017] The first determining unit is configured to determine the component identification message of the current slice and to determine the position of the last non-zero coefficient of the current block corresponding to the component of the current slice;

[0018] The first determining unit is further configured to determine the coordinate information of the last non-zero coefficient of the current block based on the component identification information and the position of the last non-zero coefficient;

[0019] The encoding unit is configured to encode all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and write the encoded bit information, component identification information and coordinate information of the last non-zero coefficient into the code stream.

[0020] In a fifth aspect, embodiments of this application provide an encoder, which includes a first memory and a first processor; wherein,

[0021] First memory, used to store computer programs that can run on the first processor;

[0022] A first processor is configured to execute the method described in the second aspect when running a computer program.

[0023] In a sixth aspect, embodiments of this application provide a decoder, which includes a parsing unit and a second determining unit; wherein...

[0024] The parsing unit is configured to parse the bitstream, determine the component identifier information of the current slice, and determine the coordinate information of the last non-zero coefficient of the current block corresponding to the component of the current slice;

[0025] The second determining unit is configured to calculate the coordinate information of the last non-zero coefficient when the component identification message indicates that the component of the current block is flipped using the position of the last non-zero coefficient, so as to obtain the position of the last non-zero coefficient of the current block.

[0026] The parsing unit is also configured to decode all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block.

[0027] In a seventh aspect, embodiments of this application provide a decoder, which includes a second memory and a second processor; wherein...

[0028] Second memory, used to store computer programs that can run on the second processor;

[0029] A second processor is configured to execute the method described in the first aspect when running a computer program.

[0030] In an eighth aspect, embodiments of this application provide a computer storage medium storing a computer program that, when executed, implements the method described in the first aspect or the method described in the second aspect.

[0031] This application provides an encoding / decoding method, a bitstream, an encoder, a decoder, and a computer storage medium. In the encoder, the component identification message of the current slice is determined, and the position of the last non-zero coefficient of the current block corresponding to the component of the current slice is determined. Based on the component identification message and the position of the last non-zero coefficient, the coordinate message of the last non-zero coefficient of the current block is determined. All coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the encoded bit information, component identification message, and coordinate message of the last non-zero coefficient are written into the bitstream. In the decoder, the bitstream is parsed to determine the component identification message of the current slice, and the coordinate message of the last non-zero coefficient of the current block corresponding to the component of the current slice. When the component identification message indicates that the component of the current slice is flipped using the position of the last non-zero coefficient, the coordinate message of the last non-zero coefficient is calculated to obtain the position of the last non-zero coefficient of the current block. All coefficients before the position of the last non-zero coefficient are decoded according to a preset scanning order to determine the coefficients of the current block. Thus, in high-bit-width, high-bit-rate, high-quality, or lossless image encoding and decoding scenarios, setting a reasonable output method for the last non-zero coefficient based on the distribution pattern of the non-zero coefficients can reduce the overhead of encoding in the bitstream and improve compression efficiency. In addition, since the distribution patterns of the non-zero coefficients of each image component are different, the output method of the last non-zero coefficient for each image component can be controlled separately using the component identification information. That is, each image component can be controlled separately to control whether to use the last non-zero coefficient position flipping technique, thereby further improving compression efficiency.

Implementation Method

[0049] In order to understand the features and technical content of the embodiments of this application in more detail, the implementation of the embodiments of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference only and are not intended to limit the embodiments of this application.

[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0051] In the following description, references are made to "some embodiments," which describe a subset of all possible embodiments. However, it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict. It should also be noted that the terms "first, second, third" used in the embodiments of this application are only used to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0052] In an image, a first image component, a second image component, and a third image component are generally used to represent a coding block (CB). These three image components are a luminance component, a blue chrominance component, and a red chrominance component, respectively. Specifically, the luminance component is usually represented by the symbol Y, the blue chrominance component is usually represented by the symbol Cb or U, and the red chrominance component is usually represented by the symbol Cr or V. Thus, the image can be represented in YCbCr format or YUV format.

[0053] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application shall be explained. The nouns and terms involved in the embodiments of this application shall be interpreted as follows:

[0054] Moving Picture Experts Group (MPEG)

[0055] Joint Video Experts Team (JVET)

[0056] Alliance for Open Media (AOM)

[0057] The next-generation video coding standard H.266 / Versatile Video Coding (VVC)

[0058] VVC Reference Software Testing Platform (VVC Test Model, VTM)

[0059] Audio Video Standard (AVS)

[0060] AVS High-Performance Model (HPM)

[0061] Context-based Adaptive Binary Arithmetic Coding (CABAC)

[0062] Raw Byte Sequence Payload (RBSP)

[0063] Regular Residual Coding (RRC)

[0064] Transform Skip Residual Coding (TSRC)

[0065] It is understood that currently common image coding and decoding standards (such as VVC) all adopt a block-based hybrid coding framework. Each frame in the image is divided into a maximum coding unit (LCU) of the same size (such as 128×128, 64×64, etc.). Each LCU can be further divided into rectangular coding units (CU) according to rules; and the coding units may be further divided into smaller prediction units (PU), transform units (TU), etc. Specifically, as shown in Figure 1, the hybrid coding framework may include modules such as prediction, transform, quantization, entropy coding, and in-loop filtering. Among them, the prediction module may include intra-prediction and inter-prediction. Inter-prediction may include motion estimation and motion compensation. Because there is a strong correlation between adjacent pixels within a frame of an image, intra-frame prediction can be used in image encoding and decoding technology to eliminate spatial redundancy between adjacent pixels. However, because there is also a strong similarity between adjacent frames in an image, inter-frame prediction can be used in image encoding and decoding technology to eliminate temporal redundancy between adjacent frames, thereby improving encoding and decoding efficiency.

[0066] The basic process of the image codec is as follows: In the encoder, a frame of image is divided into blocks. Intra-frame prediction or inter-frame prediction is used on the current block to generate a prediction block for the current block. The original block of the current block is subtracted from the prediction block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix. The quantization coefficient matrix is ​​entropy encoded and output to the bitstream. In the decoder, intra-frame prediction or inter-frame prediction is used on the current block to generate a prediction block for the current block. On the other hand, the bitstream is decoded to obtain a quantization coefficient matrix. The quantization coefficient matrix is ​​dequantized and inversely transformed to obtain a residual block. The prediction block and the residual block are added together to obtain a reconstructed block. The reconstructed blocks form a reconstructed image. Based on the image or based on the blocks, loop filtering is performed on the reconstructed image to obtain a decoded image. The encoder also needs similar operations to the decoder to obtain the decoded image. The decoded image can be used as a reference frame for inter-frame prediction in subsequent frames. The encoder determines block partitioning information, and mode information or parameter information such as prediction, transform, quantization, entropy coding, and loop filtering, which may be output to the bitstream if necessary. Then, the decoder analyzes and parses the existing information to determine the same block partitioning information, prediction, transform, quantization, entropy coding, and loop filtering mode information or parameter information as the encoder, thus ensuring that the decoded image obtained by the encoder and the decoder are identical. The decoded image obtained by the encoder is usually called the reconstructed image. During prediction, the current block can be divided into prediction units; during transform, the current block can be divided into transform units. The division of prediction units and transform units can be different. The above describes the basic flow of an image encoder and decoder under a block-based hybrid coding framework. With technological advancements, some modules or steps of this framework or process may be optimized. The embodiments in this application are applicable to the basic flow of an image codec under this block-based hybrid coding framework, but are not limited to this framework and process.

[0067] In this embodiment, the current block can be the current coding unit (CU), the current prediction unit (PU), or the current transform block (TU), etc. The block partitioning information, various modes and parameter information for prediction, transform, and quantization, and coefficients are written into the bitstream through entropy coding. Assuming that different elements have different probabilities, assigning shorter codewords to elements with higher probabilities and longer codewords to elements with lower probabilities achieves higher coding efficiency than fixed-length coding. However, if the probabilities of different elements are similar or essentially the same, the compression space of entropy coding is limited. CABAC is a commonly used entropy coding method; HEVC and VVC, among others, use CABAC for entropy coding. CABAC can improve compression efficiency by using a context model, but the use and updating of the context model also makes the operation more complex. CABAC has a bypass mode, in which the context model does not need to be used and updated, achieving higher throughput. In this embodiment, the mode in CABAC that requires the use and updating of the context model can be called the context mode.

[0068] Generally, the context model needs to be determined first according to the defined method. When calling the arithmetic decoding process of the defined binary symbols, the parameters of the context model can be used as input. The selection of the context model also has a dependency between adjacent coefficients. For example, Figure 2 shows a schematic diagram of the positional relationship between the current coefficient and adjacent coefficients provided by related technologies. In Figure 2, the black-filled block represents the current coefficient, and the grid-filled block represents adjacent coefficients; as shown in Figure 2, the selection of which context model for the current coefficient's sig_coeff_flag depends on the information of the five coefficients adjacent to its right, bottom, and bottom right. As can be further seen from Figure 2, the operation of the context mode is much more complex than that of the bypass mode, and there is also a dependency between adjacent coefficients.

[0069] For the CABAC arithmetic encoding engine, if context mode is required, the defined arithmetic decoding process for binary symbols needs to be called, which includes the state transition process, i.e., updating the context model. The renormalization process of the arithmetic decoding engine is called during the binary symbol arithmetic decoding process. When using bypass mode, the bypass decoding process needs to be called.

[0070] The following uses CABAC in VVC as an example for introduction:

[0071] For the CABAC arithmetic encoding engine, the inputs to the arithmetic decoding process are ctxTable, ctxIdx, bypassFlag, and the state variables ivlCurrRange and ivlOffset of the arithmetic decoding engine, and the output of the arithmetic decoding process is the value of bin.

[0072] Where ctxTable is the table used when selecting the context mode, and ctxIdx is the context model index.

[0073] Figure 3 shows a flowchart of an arithmetic decoding process for a bin provided by the related technology. As shown in Figure 3, in order to decode the value of bin, the context index table ctxTable, the context model index ctxIdx, and the bypass mode enable flag bypassFlag are transmitted as input to the arithmetic decoding process DecodeBin(ctxTable, ctxIdx, bypassFlag), as follows:

[0074] If the value of bypassFlag is 1, then the bypass decoding process DecodeBypass() is called;

[0075] Otherwise, if the value of bypassFlag is 0, the value of ctxTable is 0, and the value of ctxIdx is 0, then call DecodeTerminate() to end the decoding process;

[0076] Otherwise (the value of bypassFlag is 0 and the value of ctxTable is not 0), call the defined binary symbol arithmetic decoding procedure DecodeDecision(ctxTable, ctxIdx).

[0077] Further, for the arithmetic decoding process of the binary symbol, the input of the process is the variables ctxTable, ctxIdx, ivlCurrRange, and ivlOffset, and the output of the process is the decoded value binVal, the updated variables ivlCurrRange and ivlOffset.

[0078] Figure 4 shows a flowchart of an arithmetic decoding process for binary symbols provided by related technologies. As shown in Figure 4, the DecodeDecision(ctxTable, ctxIdx) can be used to input the context index table ctxTable and the context model index ctxIdx, as well as the state variables ivlCurrRange and ivlOffset of the arithmetic decoding engine. Among them, pStateIdx0 and pStateIdx1 are the two states of the current context model.

[0079] (1)The value of the variable ivlLpsRange is exported as follows:

[0080] Given the current value of ivlCurrRange, the variable qRangeIdx is exported as follows:

[0081] qRangeIdx=ivlCurrRange >>5

[0082] Given qRangeIdx, ctxTable and the corresponding pStateIdx0 and pStateIdx1 of ctxIdx, valMps and ivlLpsRange are exported as follows:

[0083] pState=pStateIdx1+16×pStateIdx0;

[0084] valMps=pState >>14;

[0085] ivlLpsRange=(qRangeIdx×((valMps? 32767-pState:pState)>>9)>>1)+4.

[0086] (2) Set the value of the variable ivlCurrRange to ivlCurrRange–ivlLpsRange, and perform the following operation:

[0087] If ivlOffset is greater than or equal to ivlCurrRange, then the value of variable binVal is 1 – valMps, and variables ivlOffset and ivlCurrRange are updated, where the value of ivlOffset is ivlOffset minus ivlCurrRange, and the value of ivlCurrRange is ivlLpsRange.

[0088] Otherwise (ivlOffset is less than ivlCurrRange), the value of variable binVal is valMps.

[0089] Given the value of binVal, execute the defined state transition. Based on the current value of ivlCurrRange, the defined renormalization can be performed.

[0090] Further, for the state transition process, the inputs are the current pStateIdx0 and pStateIdx1, and the solved value binVal; the outputs are the updated context variables pStateIdx0 and pStateIdx1 corresponding to ctxTable and ctxIdx. The variables shift0 and shift1 are exported by shiftIdx. The correspondence between shiftIdx and ctxTable and ctxIdx is defined here as follows:

[0091] shift0=(shiftIdx >>2)+2;

[0092] shift1=(shiftIdx& 3)+3+shift0.

[0093] Based on the solved value binVal, the updates to the two variables pStateIdx0 and pStateIdx1 corresponding to ctxTable and ctxIdx are as follows:

[0094] pStateIdx0=pStateIdx0-(pStateIdx0>>shift0)+(1023×binVal>>shift0);

[0095] pStateIdx1=pStateIdx1-(pStateIdx1>>shift1)+(16383×binVal>>shift1).

[0096] Further, the input to the renormalization process of the arithmetic decoding engine is the bits and variables ivlCurrRange and ivlOffset in the slice data, and the output is the updated variables ivlCurrRange and ivlOffset.

[0097] Figure 5 shows a flowchart of the renormalization process of an arithmetic decoding engine provided by the related technology. As shown in Figure 5, upon entering the ReNormD process, the current value of ivlCurrRange is first compared with 256, and the subsequent steps are as follows:

[0098] If ivlCurrRange is greater than or equal to 256, then no renormalization is needed, and the RenormD process ends;

[0099] Otherwise (ivlCurrRange is less than 256), enter the renormalization loop. In this loop, the value of ivlCurrRange is multiplied by 2, which is to shift left by one bit. The value of ivlOffset is multiplied by 2, which is to shift left by one bit. The bit obtained by read_bits(1) is shifted into ivlOffset, as follows:

[0100] ivlCurrRange=ivlCurrRange<<1;

[0101] ivlOffset=ivlOffset<<1;

[0102] ivlOffset=ivlOffset |read_bits(1).

[0103] Throughout the process, the data in the bitstream should not cause ivlOffset to be greater than or equal to ivlCurrRange.

[0104] Further, the input to the bypass decoding process of the binary symbol is the bits of the slice data and the variables ivlCurrRange and ivlOffset, and the output is the updated variable ivlOffset and the solved value binVal.

[0105] When bypassFlag is 1, the bypass decoding process is invoked. Figure 6 shows a flowchart of a bypass decoding process provided by related technologies. As shown in Figure 6, firstly, the variable ivlOffset is updated, that is, the value of ivlOffset is multiplied by 2, which is shifted left by one bit. The bit obtained by read_bits (1) is shifted into ivlOffset, as follows:

[0106] ivlOffset=ivlOffset<<1;

[0107] ivlOffset=ivlOffset |read_bits(1).

[0108] Then, the value of ivlOffset will be compared with the value of ivlCurrRange, and the subsequent steps are as follows:

[0109] If ivlOffset is greater than or equal to ivlCurrRange, then the value of binVal is set to 1, and ivlOffset is equal to ivlOffset minus ivlCurrRange;

[0110] Otherwise (ivlOffset is less than ivlCurrRange), the value of binVal is set to 0.

[0111] Throughout the process, the data in the bitstream should not cause ivlOffset to be greater than or equal to ivlCurrRange.

[0112] It should also be understood that current image encoding and decoding standards typically support one or more transforms and transform skips for residuals. Transforms include Discrete Cosine Transform (DCT), etc. Residual blocks using transforms usually exhibit certain characteristics after transformation (and quantization). For example, after some transforms (and quantization), the energy is mostly concentrated in the low-frequency region, resulting in larger coefficients in the upper left corner and smaller coefficients, or even many zero coefficients, in the lower right corner. Transform skips, as the name suggests, do not perform a transform. The distribution of coefficients after transform skipping is different from that after transforming, thus allowing the use of different coefficient encoding methods. For example, in VVC, RRC is used for coefficients after transform skipping, and TSRC is used for coefficients after transform skipping.

[0113] In general transformations, such as DCT transforms, the transformed blocks represent frequencies from low to high from left to right and from low to high from top to bottom. The upper left corner represents low frequencies, and the lower right corner represents high frequencies. The human eye is more sensitive to low-frequency information and less sensitive to high-frequency information. Utilizing this characteristic, some high-frequency information can be processed more or removed with less visual impact. Some techniques, such as zero-out, can force certain high-frequency information to be set to 0. For example, in a 64x64 block, coefficients at positions with an x-coordinate greater than or equal to 32 or a y-coordinate greater than or equal to 32 can be forced to be set to 0. The above is just a simple example; the range of zero-out may have more complex output methods, which will not be elaborated here. As shown in Figure 7, the upper left part may contain non-zero coefficients (i.e., the region that may contain non-zero coefficients), and the lower right part will be all set to zero (i.e., the region forced to be 0). Thus, for subsequent coefficient encoding, the coefficients in the region forced to be 0 by zero-out do not need to be encoded because they are definitely 0.

[0114] Furthermore, since the coefficient distribution after transforming (and quantizing) the residuals of a typical image exhibits the characteristic of larger coefficients in the upper left corner and many zero coefficients in the lower right corner, some methods are usually used during coefficient encoding to ensure that coefficients within a certain range in the upper left corner need to be encoded, while coefficients within a certain range in the lower right corner do not need to be encoded, that is, these coefficients are preset to be 0. One method is to first determine the position of the last non-zero coefficient of the block in the scan order when encoding the coefficients of a block. After determining this position, all coefficients after the position of the last non-zero coefficient in the scan order are considered to be 0, that is, they do not need to be encoded; only the position of the last non-zero coefficient and the coefficients before it need to be encoded. For example, in VVC, last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, and last_sig_coeff_y_suffix are used to determine the position of the last non-zero coefficient (LastSignificantCoeffX, LastSignificantCoeffY).

[0115] (a) last_sig_coeff_x_prefix determines the prefix of the horizontal (or column) coordinate of the last non-zero coefficient in the current block in scan order. The value of last_sig_coeff_x_prefix should be in the range of 0 to (log2ZoTbWidth << 1) - 1, including these two boundary values.

[0116] If last_sig_coeff_x_prefix does not exist, then the value of last_sig_coeff_x_prefix is ​​0.

[0117] (b)last_sig_coeff_y_prefix determines the prefix of the last non-zero coefficient in the vertical (or row) coordinates of the current block in scan order. The value of last_sig_coeff_y_prefix should be in the range of 0 to (log2ZoTbHeight<<1)-1, including these two boundary values.

[0118] If last_sig_coeff_y_prefix does not exist, then the value of last_sig_coeff_y_prefix is ​​0.

[0119] (c)last_sig_coeff_x_suffix determines the suffix of the last non-zero coefficient in the current block in scan order. The value of last_sig_coeff_x_suffix should be in the range of 0 to (1 << ( ( last_sig_coeff_x_prefix >> 1) - 1)) – 1, inclusive of these two boundary values.

[0120] The value of the horizontal (or column) coordinate of the last non-zero coefficient in the current transform block in scan order, LastSignificantCoeffX, is exported as follows:

[0121] If last_sig_coeff_x_suffix does not exist, then

[0122] LastSignificantCoeffX = last_sig_coeff_x_prefix;

[0123] Otherwise (last_sig_coeff_x_suffix exists),

[0124] LastSignificantCoeffX=(1<< ((last_sig_coeff_x_prefix>>1)-1))*(2+(last_sig_coeff_x_prefix&1)) + last_sig_coeff_x_suffix.

[0125] (d)last_sig_coeff_y_suffix determines the suffix of the vertical (or row) coordinate of the last non-zero coefficient in the current transform block in scan order. The value of last_sig_coeff_x_suffix should be in the range of 0 to (1 << ((last_sig_coeff_y_prefix>>1)-1))–1, inclusive of these two boundary values.

[0126] The value of the vertical (or row) coordinate of the last non-zero coefficient in the current transform block in scan order, LastSignificantCoeffY, is exported as follows:

[0127] If last_sig_coeff_y_suffix does not exist, then

[0128] LastSignificantCoeffY = last_sig_coeff_y_prefix;

[0129] Otherwise (last_sig_coeff_y_suffix exists),

[0130] LastSignificantCoeffY = (1<< ((last_sig_coeff_y_prefix>>1)-1))*(2+(last_sig_coeff_y_prefix&1)) + last_sig_coeff_y_suffix.

[0131] Furthermore, all coefficients up to and including the last non-zero coefficient must be encoded. However, in ordinary images, even among these coefficients, a certain proportion are still 0. VVC uses the flag sb_coded_flag indicating whether the current sub-block needs encoding to determine whether the coefficients in the current sub-block need to be encoded. If no encoding is required, then all coefficients in the current sub-block are considered to be 0. Here, the sub-block is usually an n×n sub-block, such as a 4×4 sub-block.

[0132] sb_coded_flag[xS][yS] determines the following message of the sub-block at position (xS, yS) in the current transform block, where the sub-block is an array of transform coefficient values:

[0133] If the value of sb_coded_flag[xS][yS] is 0, then the values ​​of all transform coefficients in the sub-block at position (xS, yS) in the current transform block are 0;

[0134] If sb_coded_flag[xS][yS] does not exist, then the value of sb_coded_flag[xS][yS] is 1.

[0135] Furthermore, when processing coefficient encoding, the characteristics of coefficients can be utilized to improve compression efficiency. For example, in typical images, a certain proportion of the coefficients to be encoded are 0. Therefore, a syntax element can be used to indicate whether the current coefficient is 0. This syntax element is usually a binary symbol. If the current coefficient is 0, it means that the encoding of the current coefficient has ended; otherwise, the encoding of the current coefficient needs to continue. As another example, in typical images, a certain proportion of the non-zero coefficients have an absolute value of 1. Therefore, a syntax element can be used to indicate whether the absolute value of the current coefficient is greater than 1. This syntax element is usually a binary symbol. If the absolute value of the current coefficient is not greater than 1, it means that the encoding of the current coefficient has ended; otherwise, the encoding of the current coefficient needs to continue. For example, the syntax elements involved in VVC are as follows...

[0136] sig_coeff_flag[xC][yC] is used to determine whether the transform coefficients at the transform coefficient positions (xC, yC) of the current transform block are non-zero coefficients:

[0137] If the value of sig_coeff_flag[xC][yC] is 0, then the value of the transformation coefficient at position (xC, yC) is set to 0;

[0138] Otherwise (sig_coeff_flag[xC][yC] is 1), the transformation coefficients at the (xC, yC) positions are non-zero coefficients.

[0139] If sig_coeff_flag[xC][yC] does not exist, then the following inference is made:

[0140] If the value of transform_skip_flag[x0][y0][cIdx] is 0 or the value of sh_ts_residual_coding_disabled_flag is 1:

[0141] If (xC, yC) is the position of the last non-zero coefficient in the scan order (LastSignificantCoeffX, LastSignificantCoeffY) or all of the following conditions are true, then the value of sig_coeff_flag[xC][yC] is inferred to be 1:

[0142] (xC&((1<<log2SbW)-1), yC&((1<<log2SbH)-1)) equals (0, 0);

[0143] The value of inferSbDcSigCoeffFlag is equal to 1;

[0144] The value of sb_coded_flag[xS][yS] is 1;

[0145] Otherwise, the value of sig_coeff_flag[xC][yC] is inferred to be 0;

[0146] Otherwise (the value of transform_skip_flag[x0][y0][cIdx] is 1 and the value of sh_ts_residual_coding_disabled_flag is 0):

[0147] If all of the following conditions are true, then the value of sig_coeff_flag[xC][yC] is inferred to be 1:

[0148] (xC&((1<<log2SbW)-1), yC&((1<<log2SbH)-1)) equals ((1<<log2SbW)-1, ( ...

[0149] log2SbH)-1); The value of

[0150] inferSbSigCoeffFlag is 1;

[0151] The value of sb_coded_flag[xS][yS] is 1;

[0152] Otherwise, the value of sig_coeff_flag[xC][yC] is inferred to be 0.

[0153] abs_level_gtx_flag[n][j] is used to determine whether the absolute value of the transformation coefficient (the nth one in the scan order) is greater than (j << 1) + 1. If abs_level_gtx_flag[n][j] does not exist, then the value of abs_level_gtx_flag[n][j] is 0.

[0154] Thus, if the current coefficient has not been fully encoded after processing the above flags (or syntax elements), then the remaining value of the coefficient's absolute value needs to be encoded. For example, abs_remainder in VVC.

[0155] abs_remainder[n] is used to determine the residual absolute value of the nth transform coefficient in the scan order, encoded in Golomb-Rice. If abs_remainder[n] does not exist, then the value of abs_remainder[n] is 0.

[0156] Furthermore, in VVC, syntax elements such as `sig_coeff_flag` and `abs_level_gtx_flag` use context mode encoding, while `abs_remainder` uses bypass mode encoding. As mentioned above, context mode encoding is more complex than bypass mode encoding; intuitively, it's slower to process. If there are many coefficients to be encoded, using too much context mode encoding will affect decoding speed. Therefore, the number of syntax elements using context mode encoding can be limited. For example, if the number of binary symbols using context mode encoding exceeds a threshold, subsequent coefficient encoding is forced to use bypass mode encoding. This is exemplified by `dec_abs_level` in VVC.

[0157] dec_abs_level[n] is an intermediate value encoded in Golomb-Rice at scan position n. Parsing dec_abs_level[n] can export ZeroPos[n]. The absolute value of the quantization coefficient at position (xC, yC), AbsLevel[xC][yC], is exported as follows:

[0158] If dec_abs_level[n] does not exist or the value of dec_abs_level[n] is equal to ZeroPos[n], then the value of AbsLevel[xC][yC] is 0;

[0159] Otherwise, if the value of dec_abs_level[n] is less than ZeroPos[n], then the value of AbsLevel[xC][yC] is dec_abs_level[n]+1;

[0160] Otherwise (the value of dec_abs_level[n] is greater than ZeroPos[n]), the value of AbsLevel[xC][yC] is dec_abs_level[n].

[0161] The above refers to the absolute values ​​of the coefficients. The sign of non-zero coefficients can be determined using the coefficient sign flag `coeff_sign_flag` or some sign output method. `coeff_sign_flag[n]` can determine the sign of the transform coefficients at scan position n as follows:

[0162] If the value of coeff_sign_flag[n] is 0, then the corresponding transformation coefficient is positive;

[0163] Otherwise (coeff_sign_flag[n] is 1), the corresponding transformation coefficient is negative.

[0164] If coeff_sign_flag[n] does not exist, then the value of coeff_sign_flag[n] is 0; at this time, the sign of the transformation coefficients on coordinates (xC, yC) is determined according to CoeffSignLevel[xC][yC]:

[0165] If the value of CoeffSignLevel[xC][yC] is 0, then the corresponding transformation coefficient is 0;

[0166] Otherwise, if the value of CoeffSignLevel[xC][yC] is 1, then the corresponding transformation coefficient is positive; otherwise (the value of CoeffSignLevel[xC][yC] is -1), the corresponding transformation coefficient is negative.

[0167] It should also be noted that CoeffSignLevel[xC][yC] can also be exported using other methods, which will not be elaborated here.

[0168] In addition, VVC also uses a parity flag for the value of a coefficient, par_level_flag. This flag indicates the parity of the current coefficient value and is used in determining the current coefficient value and in dependent quantization.

[0169] par_level_flag[n] determines the parity of the transformation coefficients at position n in the scan order. If par_level_flag[n] does not exist, then the value of par_level_flag[n] is 0.

[0170] In addition to determining the parity of the transformation coefficients, par_level_flag can also be used together with abs_level_gtx_flag, abs_remainder, etc. to determine the magnitude of the coefficients.

[0171] Here, since context mode encoding requires selecting, using, and updating the context mode, while bypass mode encoding does not, the common practice is to group context mode encoded syntax elements together and bypass mode encoded syntax elements together within a certain range. This is more hardware-friendly. For example, all context mode encoded syntax elements in a block can be processed first, and then bypass mode encoded syntax elements can be processed. All context mode encoded syntax elements in the current block may be divided into several groups, and all bypass mode encoded syntax elements in a block may be divided into several groups.

[0172] In a specific example, the specific syntax of RRC is shown in Table 1.

[0173] Table 1 residual_coding(x0,y0,log2TbWidth,log2TbHeight,cIdx){ Descriptor if (sps_mts_enabled_flag && cu_sbt_flag && cIdx==0 && log2TbWidth == 5 && log2TbHeight<6) log2ZoTbWidth=4 else log2ZoTbWidth=Min(log2TbWidth, 5) if (sps_mts_enabled_flag && cu_sbt_flag && cIdx==0 && log2TbWidth<6 && log2TbHeight == 5) log2ZoTbHeight=4 else log2ZoTbHeight=Min(log2TbHeight,5) if(log2TbWidth >0) last_sig_coeff_x_prefix ae(v) if(log2TbHeight >0) last_sig_coeff_y_prefix ae(v) if(last_sig_coeff_x_prefix> 3) last_sig_coeff_x_suffix ae(v) if(last_sig_coeff_y_prefix> 3) last_sig_coeff_y_suffix ae(v) log2TbWidth=log2ZoTbWidth log2TbHeight=log2ZoTbHeight remBinsPass1=((1<<(log2TbWidth+log2TbHeight))×7)>>2 log2SbW=(Min(log2TbWidth,log2TbHeight)< 2 ?1: 2) log2SbH=log2SbW if(log2TbWidth+log2TbHeight>3) if(log2TbWidth<2){ log2SbW=log2TbWidth log2SbH=4-log2SbW } elseif(log2TbHeight<2){ log2SbH=log2TbHeight log2SbW=4-log2SbH } numSbCoeff=1<<(log2SbW+log2SbH) lastScanPos=numSbCoeff lastSubBlock=(1<<(log2TbWidth+log2TbHeight-(log2SbW+log2SbH)))-1 do { if(lastScanPos ==0){ lastScanPos=numSbCoeff lastSubBlock-- } lastScanPos-- xS=DiagScanOrder[log2TbWidth-log2SbW][log2TbHeight-log2SbH] [lastSubBlock][0] yS=DiagScanOrder[log2TbWidth-log2SbW][log2TbHeight-log2SbH] [lastSubBlock][1] xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][lastScanPos][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][lastScanPos][1] } while((xC != LastSignificantCoeffX) | | (yC != LastSignificantCoeffY)) if(lastSubBlock ==0 && log2TbWidth>=2 && log2TbHeight>=2 && !transform_skip_flag[x0][y0][cIdx] && lastScanPos >0) LfnstDcOnly=0 if((lastSubBlock >0 && log2TbWidth>=2 && log2TbHeight>=2) | | (lastScanPos>7 && (log2TbWidth == 2 | | log2TbWidth == 3) && log2TbWidth == log2TbHeight)) LfnstZeroOutSigCoeffFlag=0 if((lastSubBlock >0 | | lastScanPos >0) && cIdx==0) MtsDcOnly=0 QState=0 for(i=lastSubBlock; i >=0; i--){ startQStateSb=QState xS=DiagScanOrder[log2TbWidth-log2SbW][log2TbHeight-log2SbH] [i][0] yS=DiagScanOrder[log2TbWidth-log2SbW][log2TbHeight-log2SbH] [i][1] inferSbDcSigCoeffFlag=0 if(i<lastSubBlock && I >0){ sb_coded_flag[xS][yS] ae(v) inferSbDcSigCoeffFlag=1 } if(sb_coded_flag[xS][yS] && (xS>3 | | yS>3) && cIdx==0) MtsZeroOutSigCoeffFlag=0 firstSigScanPosSb=numSbCoeff lastSigScanPosSb=-1 firstPosMode0=(i == lastSubBlock ? lastScanPos : numSbCoeff-1) firstPosMode1=firstPosMode0 for(n=firstPosMode0;n>=0 && remBinsPass1>=4; n--){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] if(sb_coded_flag[xS][yS] && (n >0 | | !inferSbDcSigCoeffFlag) && (xC != LastSignificantCoeffX | | yC != LastSignificantCoeffY)){ sig_coeff_flag[xC][yC] ae(v) remBinsPass1-- if(sig_coeff_flag[xC][yC]) inferSbDcSigCoeffFlag=0 } if(sig_coeff_flag[xC][yC]){ abs_level_gtx_flag[n][0] ae(v) remBinsPass1-- if(abs_level_gtx_flag[n][0]){ par_level_flag[n] ae(v) remBinsPass1-- abs_level_gtx_flag[n][1] ae(v) remBinsPass1-- } if(lastSigScanPosSb == -1) lastSigScanPosSb=n firstSigScanPosSb=n } AbsLevelPass1[xC][yC]=sig_coeff_flag[xC][yC]+par_level_flag[n]+ abs_level_gtx_flag[n][0]+2×abs_level_gtx_flag[n][1] if(sh_dep_quant_used_flag) QState=QStateTransTable[QState][AbsLevelPass1[xC][yC]&1] firstPosMode1=n-1 } for(n=firstPosMode0; n>firstPosMode1; n--){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] if(abs_level_gtx_flag[n][1]) abs_remainder[n] ae(v) AbsLevel[xC][yC]=AbsLevelPass1[xC][yC]+2×abs_remainder[n] } for(n=firstPosMode1;n>=0; n--){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] if(sb_coded_flag[xS][yS]) dec_abs_level[n] ae(v) if(AbsLevel[xC][yC]>0){ if(lastSigScanPosSb == -1) lastSigScanPosSb=n firstSigScanPosSb=n } if(sh_dep_quant_used_flag) QState=QStateTransTable[QState][AbsLevel[xC][yC]&1] } signHiddenFlag=sh_sign_data_hiding_used_flag && (lastSigScanPosSb-firstSigScanPosSb>3 ?1:0) for(n=numSbCoeff-1;n>=0; n--){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] if((AbsLevel[xC][yC]>0) && (!signHiddenFlag | | (n != firstSigScanPosSb))) coeff_sign_flag[n] ae(v) } if(sh_dep_quant_used_flag){ QState=startQStateSb for(n=numSbCoeff-1;n>=0; n--){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] if(AbsLevel[xC][yC]>0) TransCoeffLevel[x0][y0][cIdx][xC][yC]= (2×AbsLevel[xC][yC]-(QState>1?1:0))× (1-2×coeff_sign_flag[n]) QState=QStateTransTable[QState][AbsLevel[xC][yC]&1] } } else{ sumAbsLevel=0 for(n=numSbCoeff-1;n>=0; n--){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] if(AbsLevel[xC][yC]>0){ TransCoeffLevel[x0][y0][cIdx][xC][yC] = AbsLevel[xC][yC]×(1-2×coeff_sign_flag[n]) if(signHiddenFlag){ sumAbsLevel += AbsLevel[xC][yC] if (n == firstSigScanPosSb && sumAbsLevel % 2 ==1) TransCoeffLevel[x0][y0][cIdx][xC][yC] = -TransCoeffLevel[x0][y0][cIdx][xC][yC] } } } } } }

[0174] Where, the array AbsLevel[xC][yC] represents the array of absolute values ​​of the transform coefficients of the current transform block. The array AbsLevelPass1[xC][yC] represents the array of partially reconstructed absolute values ​​of the transform coefficients of the current transform block. The array indices xC and yC represent the (xC, yC) positions in the current transform block.

[0175] After entering the `residual_coding(x0, y0, log2TbWidth, log2TbHeight, cIdx)` function, some block size information needs to be determined, such as the logarithms of the block size after zero-out: `log2ZoTbWidth` and `log2ZoTbHeight`. Coefficients with the x-coordinate in the range [0, (1 << log2ZoTbWidth) – 1] and the y-coordinate in the range [0, (1 << log2ZoTbHeight) – 1] may be non-zero coefficients. Here, (1 << log2ZoTbWidth) represents the width of the transform block after zero-out, and (1 << log2ZoTbHeight) represents the height of the transform block after zero-out. Then, the position of the last non-zero coefficient is determined based on `last_sig_coeff_x_prefix`, `last_sig_coeff_y_prefix`, `last_sig_coeff_x_suffix`, and `last_sig_coeff_y_suffix`. The coefficients preceding the last non-zero coefficient in the scan order are likely to be non-zero. The value of `remBinsPass1` is then determined using the equation `remBinsPass1 = ((1 << (log2TbWidth + log2TbHeight)) × 7) >> 2`. `remBinsPass1` determines the number of context-mode encoded syntax elements in the current block. In this embodiment, `remBinsPass1` can be understood as "remaining binaries inpass1," meaning the number of remaining binary symbols in the first round. The coefficients preceding the last non-zero coefficient in the scan order need to be encoded. For the sub-blocks containing these coefficients, it is determined sequentially whether the current sub-block needs encoding. If encoding is required, the method places the context-mode encoded syntax elements in a sub-block in the first round, and the bypass-mode encoded syntax elements later. Each coefficient may require processing up to four context-mode encoded syntax elements: one `sig_coeff_flag`, two `abs_level_gtx_flag`s, and one `par_level_flag`. In the first round, `remBinsPass1` is decremented by 1 after each context-mode encoded syntax element is processed. If a coefficient is large enough, the remaining value, `abs_remainder`, needs to be processed after processing several context-mode encoded syntax elements in the first round. However, if `remBinsPass1` is already small enough (not satisfying `remBinsPass1 >= 4`), the first round ends, and the remaining coefficients are processed directly using the bypass mode, `dec_abs_level`.

[0176] In another specific example, the specific syntax of TSRC is shown in Table 2.

[0177] Table 2 residual_ts_coding(x0,y0,log2TbWidth,log2TbHeight,cIdx){ Descriptor log2SbW=(Min(log2TbWidth, log2TbHeight)<2?1:2) log2SbH=log2SbW if(log2TbWidth+log2TbHeight>3) if (log2TbWidth < 2) { log2SbW=log2TbWidth log2SbH = 4 - log2SbW } elseif(log2TbHeight<2){ log2SbH=log2TbHeight log2SbW = 4 - log2SbH } numSbCoeff=1<<(log2SbW+log2SbH) lastSubBlock=(1<<(log2TbWidth+log2TbHeight-(log2SbW+log2SbH)))-1 inferSbCbf=1 RemCcbs=((1<<(log2TbWidth+log2TbHeight))×7)>>2 for (i =0; i <= lastSubBlock; i++) { xS=DiagScanOrder[log2TbWidth-log2SbW][log2TbHeight-log2SbH][i][0] yS=DiagScanOrder[log2TbWidth-log2SbW][log2TbHeight-log2SbH][i][1] if(i != lastSubBlock | | !inferSbCbf) sb_coded_flag[xS][yS] ae(v) if(sb_coded_flag[xS][yS] && i<lastSubBlock) inferSbCbf=0 / ×Firstscanpass × / inferSbSigCoeffFlag=1 lastScanPosPass1=-1 for(n=0;n <= numSbCoeff-1 && RemCcbs>=4; n++){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] lastScanPosPass1=n if(sb_coded_flag[xS][yS] && (n != numSbCoeff-1 | | !inferSbSigCoeffFlag)){ sig_coeff_flag[xC][yC] ae(v) RemCcbs-- if(sig_coeff_flag[xC][yC]) inferSbSigCoeffFlag=0 } CoeffSignLevel[xC][yC]=0 if(sig_coeff_flag[xC][yC]){ coeff_sign_flag[n] ae(v) RemCcbs-- CoeffSignLevel[xC][yC]=(coeff_sign_flag[n]>0 ?-1:1) abs_level_gtx_flag[n][0] ae(v) RemCcbs-- if(abs_level_gtx_flag[n][0]){ par_level_flag[n] ae(v) RemCcbs-- } } AbsLevelPass1[xC][yC]= sig_coeff_flag[xC][yC]+par_level_flag[n]+abs_level_gtx_flag[n][0] } / ×Greater than Xscanpass(numGtXFlags=5)× / lastScanPosPass2=-1 for(n=0;n <= numSbCoeff-1 && RemCcbs>=4; n++){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] AbsLevelPass2[xC][yC]=AbsLevelPass1[xC][yC] for(j=1; j<5; j++){ if(abs_level_gtx_flag[n][j-1]){ abs_level_gtx_flag[n][j] ae(v) RemCcbs-- } AbsLevelPass2[xC][yC]+=2×abs_level_gtx_flag[n][j] } lastScanPosPass2=n } / ×remainderscanpass × / for(n=0;n <= numSbCoeff-1; n++){ xC=(xS<<log2SbW)+DiagScanOrder[log2SbW][log2SbH][n][0] yC=(yS<<log2SbH)+DiagScanOrder[log2SbW][log2SbH][n][1] if((n <= lastScanPosPass2 && AbsLevelPass2[xC][yC]>=10) | | (n>lastScanPosPass2 && n <= lastScanPosPass1 && AbsLevelPass1[xC][yC]>= 2) | | (n>lastScanPosPass1 && sb_coded_flag[xS][yS])) abs_remainder[n] ae(v) if (n <= lastScanPosPass2) AbsLevel[xC][yC]=AbsLevelPass2[xC][yC]+2×abs_remainder[n] elseif(n <= lastScanPosPass1) AbsLevel[xC][yC]=AbsLevelPass1[xC][yC]+2×abs_remainder[n] else{ / ×bypass × / AbsLevel[xC][yC]=abs_remainder[n] if(abs_remainder[n]) coeff_sign_flag[n] ae(v) } if(BdpcmFlag[x0][y0][cIdx] ==0 && n <= lastScanPosPass1){ absLeftCoeff=xC >0 ? AbsLevel[xC-1][yC]:0 absAboveCoeff =yC >0 ? AbsLevel[xC][yC-1]:0 predCoeff=Max(absLeftCoeff,absAboveCoeff) if(AbsLevel[xC][yC]==1 && predCoeff >0) AbsLevel[xC][yC]=predCoeff elseif(AbsLevel[xC][yC]>0 && AbsLevel[xC][yC] <= predCoeff) AbsLevel[xC][yC]-- } TransCoeffLevel[x0][y0][cIdx][xC][yC]=(1-2×coeff_sign_flag[n])× AbsLevel[xC][yC] } } }

[0178] After entering the `residual_ts_coding(x0, y0, log2TbWidth, log2TbHeight, cIdx)` function, some block size information needs to be determined. Then, the value of `RemCcbs` is determined, i.e., using the equation `RemCcbs = ((1 << (log2TbWidth + log2TbHeight)) × 7) >> 2`. `RemCcbs` determines the number of context-coded syntax elements used in the current block. In this embodiment, `RemCcbs` can be understood as remaining context-coded binaries, that is, the number of remaining context-coded binary symbols. For each sub-block, it is determined whether the current sub-block needs to be encoded. If encoding is required, unlike the above RRC, the TSRC method places the context-coded syntax elements in a sub-block in two rounds. Each coefficient processes a maximum of 4 context-coded syntax elements in the first and second rounds respectively. Bypass-mode encoded syntax elements are placed later. In the first and second rounds, `remBinsPass1` is decremented by 1 after each context-mode encoded syntax element is processed. If a coefficient is large enough, the remaining value, `abs_remainder`, needs to be processed after processing several context-mode encoded syntax elements in the first and second rounds. However, if `remBinsPass1` is already small enough (not satisfying `remBinsPass1 >= 4`), the first two rounds will end, and the remaining coefficients will be processed directly using the bypass mode, which is still `abs_remainder`.

[0179] In short, existing coefficient encoding methods in related technologies offer excellent compression efficiency for commonly used images, such as consumer images. Consumer images typically have a bit width of 8 or 10 bits per pixel, and their bit rate is usually not very high, typically a few megabits per second (MB / s) or lower. However, some applications require higher bit widths, such as 12, 14, or 16 bits or more per pixel. Higher bit widths usually result in larger coefficients and more non-zero coefficients, thus leading to a higher bit rate. Some applications require higher image quality, which also usually results in larger coefficients and more non-zero coefficients, leading to a higher bit rate. Higher bit rates place higher demands on the decoder's processing capabilities, such as throughput.

[0180] High-bit-width, high-quality, and high-bit-rate images (high-bit-width, high-quality, and high-bit-rate images) typically require more and larger coefficients for encoding and decoding than low-bit-width, low-quality, and low-bit-rate images (regular images). For example, a block in a high-bit-width, high-quality, and high-bit-rate image requires significantly more coefficients for encoding and decoding than a block of the same size in a regular image. This is because many coefficients in a block of a regular image become 0 after prediction, transformation, and quantization, while many coefficients in a block of a high-bit-width, high-quality, and high-bit-rate image remain non-zero after prediction, transformation, and quantization. Since a large proportion of the coefficients in a block of a regular image are 0 after prediction, transformation, and quantization, using the last non-zero coefficient position (LastSignificantCoeffX, LastSignificantCoeffY) to distinguish whether a coefficient region needs encoding is effective is crucial. Even before the last non-zero coefficient position, a large proportion of the coefficients are still 0, making the sub-block encoding flag (sb_coded_flag) highly effective for further distinguishing whether the current sub-block needs encoding. However, when there are a large number of non-zero coefficients in the current block, or even when the vast majority or all coefficients are non-zero, the aforementioned flag indicating the position of the last non-zero coefficient and whether the sub-block is encoded will not filter out too many non-zero coefficients. Moreover, encoding the position of non-zero coefficients and the flag indicating whether the sub-block is encoded in the bitstream will incur certain overhead and result in waste.

[0181] On the other hand, the last non-zero coefficient position and the flag indicating whether the sub-block is encoded are encoded using context mode. Context mode encoding is more complex than bypass mode, and processing these messages will also affect the speed and transmission volume of software and hardware encoding and decoding.

[0182] On the other hand, the current encoding method for the last non-zero coefficient position (LastSignificantCoeffX, LastSignificantCoeffY) is to encode the coordinates of the last non-zero coefficient position. In conventional images, since most non-zero coefficients are concentrated in the upper left corner while a large area in the lower right corner is 0, the values ​​of LastSignificantCoeffX and LastSignificantCoeffY are usually small. However, in high-altitude and high-temperature images, a large number of non-zero coefficients also appear in the lower right corner, which leads to the values ​​of LastSignificantCoeffX and LastSignificantCoeffY usually being larger, thus encoding larger values ​​in the bitstream will bring greater overhead. In addition, there is another possibility of using this method in lossless compression, because quantization cannot be used in lossless compression, and in this case, there are usually more and larger coefficients. In this case, using existing related schemes may bring greater overhead, resulting in waste and low compression efficiency.

[0183] This application provides a decoding method that, by parsing the bitstream, determines the component identification message of the current slice and the coordinate message of the last non-zero coefficient of the current block corresponding to the component of the current slice; when the component identification message indicates that the component of the current slice is flipped using the position of the last non-zero coefficient, the coordinate message of the last non-zero coefficient is calculated to obtain the position of the last non-zero coefficient of the current block; and all coefficients before the position of the last non-zero coefficient are decoded according to a preset scanning order to determine the coefficients of the current block.

[0184] This application embodiment provides another encoding method, which involves determining the component identification information of the current slice and determining the position of the last non-zero coefficient of the current block corresponding to the component of the current slice; determining the coordinate information of the last non-zero coefficient of the current block according to the component identification information and the position of the last non-zero coefficient; encoding all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and writing the encoded bit information, component identification information and coordinate information of the last non-zero coefficient into the bit stream.

[0185] Thus, in high-bit-width, high-bit-rate, high-quality or lossless image encoding and decoding scenarios, setting a reasonable output method for the last non-zero coefficient based on the distribution pattern of the non-zero coefficients can reduce the overhead caused by encoding in the bitstream and improve compression efficiency. In addition, since the distribution patterns of the non-zero coefficients of each image component are different, the output method of the last non-zero coefficient can be controlled separately for each image component using the component identification information, that is, whether each image component uses the last non-zero coefficient position flipping technique, thereby further improving compression efficiency.

[0186] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0187] Referring to Figure 8A, which shows an example of a system block diagram of an encoder provided in an embodiment of this application. As shown in Figure 8A, the encoder 100 may include: a segmentation unit 101, a prediction unit 102, a first adder 107, a transform unit 108, a quantization unit 109, an inverse quantization unit 110, an inverse transform unit 111, a second adder 112, a filtering unit 113, a Decoded Picture Buffer (DPB) unit 114, and an entropy coding unit 115. Here, the input of the encoder 100 may be an image composed of a series of images or a single static image, and the output of the encoder 100 may be a bitstream (also called a "bitstream") representing a compressed version of the input image.

[0188] The segmentation unit 101 segments the image in the input image into one or more Coding Tree Units (CTUs). The segmentation unit 101 divides the image into one or more tiles, and can further divide a tile into one or more bricks. Here, a tile or a brick may include one or more complete and / or partial CTUs. Additionally, the segmentation unit 101 can form one or more slices, where a slice may include one or more tiles arranged in raster order in the image, or one or more tiles covering a rectangular area in the image. The segmentation unit 101 can also form one or more sub-images, where a sub-image may include one or more slices, tiles, or bricks.

[0189] During the encoding process of encoder 100, segmentation unit 101 transmits the CTU to prediction unit 102. Typically, prediction unit 102 may consist of block segmentation unit 103, motion estimation (ME) unit 104, motion compensation (MC) unit 105, and intra prediction unit 106. Specifically, block segmentation unit 103 repeatedly uses quadtree segmentation, binary tree segmentation, and ternary tree segmentation to further divide the input CTU into smaller coding units (CUs). Prediction unit 102 can use ME unit 104 and MC unit 105 to obtain inter-frame prediction blocks of CUs. Intra-frame prediction unit 106 can use various intra-frame prediction modes, including MIP mode, to obtain intra-frame prediction blocks of CUs. In the example, the bit rate distortion optimized motion estimation method can be invoked by ME unit 104 and MC unit 105 to obtain inter-frame prediction blocks, and the bit rate distortion optimized mode determination method can be invoked by intra-frame prediction unit 106 to obtain intra-frame prediction blocks.

[0190] Prediction unit 102 outputs the prediction block of CU. First adder 107 calculates the difference between the CU in the output of segmentation unit 101 and the prediction block of CU, i.e., the residual CU. Transform unit 108 reads the residual CU and performs one or more transform operations on the residual CU to obtain coefficients. Quantization unit 109 quantizes the coefficients and outputs quantization coefficients (i.e., levels). Inverse quantization unit 110 performs scaling operations on the quantization coefficients to output reconstruction coefficients. Inverse transform unit 111 performs one or more inverse transforms corresponding to the transform in transform unit 108 and outputs the reconstruction residual. Second adder 112 calculates the reconstructed CU by adding the reconstruction residual to the prediction block of CU from prediction unit 102. Second adder 112 also sends its output to prediction unit 102 as an intra-frame prediction reference. After all CUs in the picture or sub-picture are reconstructed, filtering unit 113 performs loop filtering on the reconstructed picture or sub-picture. Here, the filtering unit 113 includes one or more filters, such as a deblocking filter, a Sample Adaptive Offset (SAO) filter, an Adaptive Loop Filter (ALF), a Luma Mapping with Chroma Scaling (LMCS) filter, and a neural network-based filter. Alternatively, when the filtering unit 113 determines that the CU is not used as a reference for encoding other CUs, the filtering unit 113 performs loop filtering on one or more target pixels in the CU.

[0191] The output of the filtering unit 113 is a decoded image or sub-image, which is cached to the DPB unit 114. The DPB unit 114 outputs the decoded image or sub-image according to the timing and control messages. Here, the image stored in the DPB unit 114 can also be used as a reference for the prediction unit 102 to perform inter-frame prediction or intra-frame prediction. Finally, the entropy coding unit 115 converts the parameters (such as control parameters and supplementary messages) necessary for decoding the image from the encoder 100 into binary form, and writes such binary form into the bitstream according to the syntax structure of each data unit, that is, the final output bitstream of the encoder 100.

[0192] Further, the encoder 100 may be a first memory having a first processor and a computer program. When the first processor reads and runs the computer program, the encoder 100 reads the input image and generates a corresponding code stream. Alternatively, the encoder 100 may also be a computing device having one or more chips. These units, implemented as integrated circuits on the chips, have connection and data exchange functions similar to the corresponding units in FIG8A.

[0193] Referring to Figure 8B, which shows an example of a system block diagram of a decoder provided in an embodiment of this application. As shown in Figure 8B, the decoder 200 may include: a parsing unit 201, a prediction unit 202, an inverse quantization unit 205, an inverse transform unit 206, an adder 207, a filtering unit 208, and a decoded image caching unit 209. Here, the input of the decoder 200 is a bitstream representing a compressed version of an image or a still image, and the output of the decoder 200 may be a decoded image composed of a series of images or a decoded still image.

[0194] The input bitstream of the decoder 200 may be the bitstream generated by the encoder 100. The parsing unit 201 parses the input bitstream and obtains the values ​​of the syntax elements from the input bitstream. The parsing unit 201 converts the binary representation of the syntax elements into digital values ​​and sends the digital values ​​to the units in the decoder 200 to obtain one or more decoded images. The parsing unit 201 may also parse one or more syntax elements from the input bitstream to display the decoded images.

[0195] During the decoding process of the decoder 200, the parsing unit 201 sends the value of the syntax element and one or more variables set or determined according to the value of the syntax element for obtaining one or more decoded images to the unit in the decoder 200.

[0196] The prediction unit 202 determines the prediction block of the current decoding block (e.g., CU). Here, the prediction unit 202 may include a motion compensation unit 203 and an intra-frame prediction unit 204. Specifically, when an inter-frame decoding mode is indicated for decoding the current decoding block, the prediction unit 202 transmits relevant parameters from the parsing unit 201 to the motion compensation unit 203 to obtain the inter-frame prediction block; when an intra-frame prediction mode (including a MIP mode indicated by a MIP mode index value) is indicated for decoding the current decoding block, the prediction unit 202 transmits relevant parameters from the parsing unit 201 to the intra-frame prediction unit 204 to obtain the intra-frame prediction block.

[0197] The dequantization unit 205 has the same function as the dequantization unit 110 in the encoder 100. The dequantization unit 205 performs a scaling operation on the quantization coefficients (i.e., levels) from the parsing unit 201 to obtain the reconstruction coefficients.

[0198] The inverse transformation unit 206 has the same function as the inverse transformation unit 111 in the encoder 100. The inverse transformation unit 206 performs one or more transformation operations (i.e., the inverse operation of one or more transformation operations performed by the inverse transformation unit 111 in the encoder 100) to obtain the reconstructed residual.

[0199] Adder 207 performs an addition operation on its inputs (the prediction block from prediction unit 202 and the reconstruction residual from inverse transform unit 206) to obtain the reconstruction block of the current decoded block. The reconstruction block is also sent to prediction unit 202 as a reference for other blocks encoded in intra-frame prediction mode.

[0200] After all CUs in an image or sub-image are reconstructed, the filtering unit 208 performs loop filtering on the reconstructed image or sub-image. The filtering unit 208 includes one or more filters, such as deblocking filters, sampling adaptive compensation filters, adaptive loop filters, luminance mapping and chroma scaling filters, and neural network-based filters. Alternatively, when the filtering unit 208 determines that a reconstructed block is not used as a reference for decoding other blocks, the filtering unit 208 performs loop filtering on one or more target pixels in the reconstructed block. Here, the output of the filtering unit 208 is a decoded image or sub-image, which is cached to the DPB unit 209. The DPB unit 209 outputs the decoded image or sub-image according to timing and control messages. The image stored in the DPB unit 209 can also be used as a reference for performing inter-frame prediction or intra-frame prediction through the prediction unit 202.

[0201] Further, the decoder 200 may be a second memory having a second processor and a computer program. When the first processor reads and runs the computer program, the decoder 200 reads the input bitstream and generates the corresponding decoded image. Alternatively, the decoder 200 may also be a computing device having one or more chips. These units, implemented as integrated circuits on the chips, have connection and data exchange functions similar to the corresponding units in FIG8B.

[0202] It should also be noted that when the embodiments of this application are applied to the encoder 100, the "current block" specifically refers to the block to be encoded in the image (which can also be simply referred to as the "encoding block"); when the embodiments of this application are applied to the decoder 200, the "current block" specifically refers to the block to be decoded in the image (which can also be simply referred to as the "decoding block").

[0203] In one embodiment of this application, referring to FIG9, a flowchart of a decoding method provided by an embodiment of this application is shown. As shown in FIG9, the method may include:

[0204] S901: parse the bitstream, determine the last non-zero coefficient position flip flag message of the current slice, and determine the coordinate message of the last non-zero coefficient of the current block corresponding to the current block in the current slice.

[0205] It should be noted that the decoding method in this application embodiment specifically refers to a coefficient decoding method, which is applied to a decoder. Based on the composition structure of the decoder 200 shown in Figure 8B, this decoding method is mainly applied to the "parse unit 201" part of the decoder 200. For the parse unit 201, an adaptive binary arithmetic coding mode or a bypass mode based on a context model can be used for decoding to obtain the values ​​of relevant identification messages (or syntax elements), thereby determining the coefficients of the current block.

[0206] It should also be noted that the encoding commonly referred to in image standards can include both encoding and decoding. Therefore, image encoding can include encoding methods on the encoder side and decoding methods on the decoder side. This application describes the decoding method on the decoder side.

[0207] In general, for example, for conventional images, the decoding method for coefficients is the same as the existing methods in related technologies; however, for certain situations, such as high bit width, high quality, high bit rate, or lossless compression image encoding and decoding scenarios, the embodiments of this application provide an output method that can modify the position of the last non-zero coefficient.

[0208] In this embodiment of the application, the component identification message of the current slice is a slice-level flag. This component identification message is used to indicate whether the component of the current slice is flipped using the last non-zero coefficient position. Wherein, if the component of the current slice is flipped using the last non-zero coefficient position, it means that the current block corresponding to the component of the current slice is flipped using the last non-zero coefficient position; if the component of the current slice is not flipped using the last non-zero coefficient position, it means that the current block corresponding to the component of the current slice is also not flipped using the last non-zero coefficient position.

[0209] Understandably, the current sequence may include the current slice, and the current slice may include the current block. In some embodiments, before parsing the bitstream and determining the component identification information of the current slice, the method may further include:

[0210] Analyze the code stream to determine the first syntax element identifier message;

[0211] When the first syntax element identification message indicates that the current sequence is allowed to be flipped using the last non-zero coefficient position, the step of parsing the bitstream and determining the component identification message of the current slice is performed.

[0212] In this embodiment of the application, the method may further include: if the value of the first syntax element identification message is a first value, then determine that the first syntax element identification message indicates that the current sequence is allowed to be flipped using the last non-zero coefficient position; or, if the value of the first syntax element identification message is a second value, then determine that the first syntax element identification message indicates that the current sequence is not allowed to be flipped using the last non-zero coefficient position.

[0213] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numerical form. Specifically, the first syntax element identification message can be a parameter written in the profile or a value of a flag. This application embodiment does not limit this in any way.

[0214] Taking the first syntax element identifying the message as a flag as an example, for the first and second values, the first value can be set to 1 and the second value can be set to 0; or, the first value can also be set to true and the second value can also be set to false; or, the first value can also be set to 0 and the second value can also be set to 1; or, the first value can also be set to false and the second value can also be set to true. For example, for a flag, generally, the first value can be 1 and the second value can be 0, but there are no restrictions.

[0215] It should also be noted that the first syntax element identifier message is a sequence-level flag, represented by `sps_reverse_last_sig_coeff_flag`, which can be used to indicate whether the current sequence is allowed to use the last non-zero coefficient position for flipping. Thus, when decoding reveals that the current sequence is allowed to use the last non-zero coefficient position for flipping, the slice-level component identifier message can be further decoded to determine whether the components of the current slice use the last non-zero coefficient position for flipping.

[0216] Further, before decoding to obtain the first syntax element identification message, in one possible embodiment, the method may further include:

[0217] Analyze the code stream to determine the second syntax element identifier message;

[0218] When the second syntax element identification message indicates that the current sequence uses the standard extended version, the step of parsing the code stream and determining the first syntax element identification message is performed.

[0219] Before decoding to obtain the first syntax element identification message, in another possible embodiment, the method may further include:

[0220] Analyze the code stream to determine the third syntax element identifier message;

[0221] When the third syntax element identification message indicates that the current sequence uses an expanded range, the step of parsing the code stream and determining the first syntax element identification message is performed.

[0222] In another possible embodiment, before decoding to obtain the first syntax element identifier message, the method may further include:

[0223] Analyze the code stream to determine the second syntax element identifier message;

[0224] When the second syntax element identification message indicates that the current sequence uses the standard extended version, the code stream is parsed to determine the third syntax element identification message;

[0225] When the third syntax element identification message indicates that the current sequence uses an expanded range, the step of parsing the code stream and determining the first syntax element identification message is performed.

[0226] It should be noted that both the second and third syntax element identification messages are sequence-level flags. The second syntax element identification message is represented by sps_extension_flag, which can be used to indicate whether the current sequence uses the standard extended version; the third syntax element identification message is represented by sps_range_extension_flag, which can be used to indicate whether the current sequence uses range extension.

[0227] That is to say, before decoding to obtain the first syntax element identifier message (sps_reverse_last_sig_coeff_flag), it can be after parsing the bitstream to obtain sps_extension_flag. If sps_extension_flag indicates that the current sequence uses the standard extended version, then decode to obtain sps_reverse_last_sig_coeff_flag; or it can be after parsing the bitstream to obtain sps_range_extension_flag. If sps_range_extension_flag indicates that the current sequence uses range extension, then decode to obtain sps_reverse_last_sig_flag. _coeff_flag; or, even after obtaining sps_extension_flag by parsing the bitstream, if sps_extension_flag indicates that the current sequence uses the standard extended version, then obtain sps_range_extension_flag by parsing the bitstream; if sps_range_extension_flag indicates that the current sequence uses range extension, then obtain sps_reverse_last_sig_coeff_flag by decoding; however, this application embodiment does not impose any limitations.

[0228] Further, in some embodiments, the method may further include: if the value of the second syntax element identification message is a first value, then determining that the second syntax element identification message indicates that the current sequence uses the standard extended version; or, if the value of the second syntax element identification message is a second value, then determining that the second syntax element identification message indicates that the current sequence does not use the standard extended version.

[0229] Further, in some embodiments, the method may further include: if the value of the third syntax element identification message is a first value, then determining that the third syntax element identification message indicates that the current sequence uses range extension; or, if the value of the third syntax element identification message is a second value, then determining that the third syntax element identification message indicates that the current sequence does not use range extension.

[0230] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numeric form. In a specific example, the first value can be set to 1 and the second value can be set to 0, but there are no restrictions.

[0231] It should also be noted that the second syntax element identification message is represented by sps_extension_flag, and the third syntax element identification message is represented by sps_range_extension_flag. Thus, at the sequence level, if the value of sps_extension_flag is 1, that is, the current sequence uses the standard extended version, then sps_range_extension_flag needs to be decoded; if the value of sps_range_extension_flag is 1, that is, the current sequence uses range extension, then sps_reverse_last_sig_coeff_flag needs to be decoded; if the value of sps_reverse_last_sig_coeff_flag is 1, that is, the current sequence allows flipping using the last non-zero coefficient position, then further decoding of the slice-level component identification message is needed to determine whether the components of the current slice use flipping using the last non-zero coefficient position.

[0232] In some embodiments, the scope of the current sequence is extended, which may include: the current sequence satisfies at least one of the following: high bit width, high quality, high bit rate, high frame rate and lossless compression.

[0233] In other words, compared with conventional images, the images described in the embodiments of this application have characteristics such as high bit width, high quality, high bit rate, high frame rate and lossless compression.

[0234] Furthermore, the first syntax element identifier message, the second syntax element identifier message, and the third syntax element identifier message can be sequence-level identifiers, or even higher-level identifiers, such as Video Usability Information (VUI) and Supplemental Enhancement Information (SEI).

[0235] In a specific example, for the current sequence of an image, for the second syntax element identifier message (sps_extension_flag), it is determined whether the current sequence uses the standard extended version; in other words, it is determined whether the current sequence can be opened in the standard extended version, such as the extended version specified in VVC for high bit width, high bit rate, etc. When the value of sps_extension_flag is 1, the first syntax element identifier message (sps_reverse_last_sig_coeff_flag) needs to be decoded; otherwise, the first syntax element identifier message (sps_reverse_last_sig_coeff_flag) does not need to be decoded.

[0236] In another specific example, for the current sequence of the image, when the value of sps_extension_flag is 1, it is also necessary to decode the third syntax element identifier message (sps_range_extension_flag) to determine whether the current sequence uses range extension, such as flags for high bit width, high bit rate, high frame rate, and lossless compression. The following will describe four cases as examples.

[0237] In one possible implementation, when the third syntax element identification message is a high-width identification message, the method may further include: if the high-width identification message indicates that the current sequence satisfies the high-width, then determine that the current sequence uses an extended range.

[0238] In another possible implementation, when the third syntax element identification message is a high bit rate identification message, the method may further include: if the high bit rate identification message indicates that the current sequence meets the high bit rate, then determine that the current sequence usage range is extended.

[0239] In another possible implementation, when the third syntax element identification message is a high quality identification message, the method may further include: if the high quality identification message indicates that the current sequence meets the high quality, then determine that the scope of use of the current sequence is extended.

[0240] In another possible implementation, when the third syntax element identification message is a lossless compression identification message, the method may further include: if the lossless compression identification message indicates that the current sequence satisfies lossless compression, then determine that the current sequence usage range is extended.

[0241] For example, taking the sequence level as an example, the third syntax element identification message can also be a high bit width identification message (represented by sps_high_bit_depth_flag), used to indicate whether the current sequence is a high bit width sequence; or it can be replaced by a high bit rate identification message (represented by sps_high_bit_rate_flag), used to indicate whether the current sequence is a high bit rate sequence; or it can be replaced by other identification messages that indicate high bit width, high bit rate, high quality or lossless compression. The embodiments of this application do not make specific limitations.

[0242] Further, in some embodiments, for S901, the parsing of the code stream to determine the coordinate information of the last non-zero coefficient of the current block corresponding to the current intra-block may include:

[0243] Parse the code stream and obtain the first code information of the horizontal coordinate of the last non-zero coefficient, the first code information of the vertical coordinate of the last non-zero coefficient, the last code information of the horizontal coordinate of the last non-zero coefficient, and the last code information of the vertical coordinate of the last non-zero coefficient of the current block.

[0244] Determine the horizontal coordinate of the last non-zero coefficient based on the first code information of the horizontal coordinate of the last non-zero coefficient and the last code information of the horizontal coordinate of the last non-zero coefficient;

[0245] Determine the vertical coordinate of the last non-zero coefficient based on the first code information of the vertical coordinate of the last non-zero coefficient and the last code information of the vertical coordinate of the last non-zero coefficient;

[0246] Determine the coordinate information of the last non-zero coefficient of the current block based on the horizontal coordinate and the vertical coordinate of the last non-zero coefficient.

[0247] It should be noted that the first code message of the horizontal coordinate of the last non-zero coefficient is represented by last_sig_coeff_x_prefix, which determines the first code of the horizontal (or column) coordinate of the last non-zero coefficient of the current block according to the preset scanning order; the first code message of the vertical coordinate of the last non-zero coefficient is represented by last_sig_coeff_y_prefix, which determines the first code of the vertical (or row) coordinate of the last non-zero coefficient of the current block according to the preset scanning order; the last code message of the horizontal coordinate of the last non-zero coefficient is represented by last_sig_coeff_x_suffix, which determines the last code of the horizontal (or column) coordinate of the last non-zero coefficient of the current block according to the preset scanning order; the last code message of the vertical coordinate of the last non-zero coefficient is represented by last_sig_coeff_y_suffix, which determines the last code of the vertical (or row) coordinate of the last non-zero coefficient of the current block according to the preset scanning order. In other words, the coordinate information of the last non-zero coefficient can be determined by last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix.

[0248] It should also be noted that last_sig_coeff_x_prefix and last_sig_coeff_x_suffix determine the horizontal coordinate of the last non-zero coefficient, while last_sig_coeff_y_prefix and last_sig_coeff_y_suffix determine the vertical coordinate of the last non-zero coefficient, thus obtaining the coordinate information of the last non-zero coefficient.

[0249] In this embodiment of the application, the last non-zero coefficient position flip flag message can be represented by reverse_last_sig_coeff_flag. The last non-zero coefficient position flip flag message can be at least one of the following flag messages: sequence level, picture level, slice level, and block level; it can even be a higher-level flag message (such as VUI, SEI, etc.), without any limitation here.

[0250] In other words, reverse_last_sig_coeff_flag may be a sequence-level or higher-level flag, or it may be an image-level flag, a slice-level flag, a block-level flag, or a flag at other levels. In addition, block-level flags may include maximum coding unit (LCU) level flags, coding tree unit (CTU) level flags, coding unit (CU) level flags, or other block-level flags, and the embodiments of this application do not impose any limitations.

[0251] In this embodiment of the application, the last non-zero coefficient position flip flag message at the sequence level can be represented by sps_reverse_last_sig_coeff_flag, and the last non-zero coefficient position flip flag message at the slice level can be represented by sh_reverse_last_sig_coeff_flag.

[0252] It should also be noted that the last non-zero coefficient position flip identifier message at the slice level can also be referred to as the component identifier message of the current slice. In some embodiments, the method may further include:

[0253] If the component identification message takes the first value, then it is determined that the component identification message indicates that the current slice's component is flipped using the last non-zero coefficient position; or,

[0254] If the component identification message takes the second value, then it is determined that the component identification message indicates that the current slice's component does not use the last non-zero coefficient position for flipping.

[0255] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numeric form. In a specific example, the first value can be set to 1 and the second value can be set to 0, but there are no restrictions.

[0256] Taking the first value as 1 and the second value as 0 as an example, if the value of the component identification message obtained by decoding is 1, then it can be determined that the component identification message indicates that the component of the current slice uses the last non-zero coefficient position to flip; if the value of the component identification message obtained by decoding is 0, then it can be determined that the component identification message indicates that the component of the current slice does not use the last non-zero coefficient position to flip.

[0257] S902: When the last non-zero coefficient position flip flag message indicates that the current intra-block uses the last non-zero coefficient position flip, the coordinate message of the last non-zero coefficient is calculated to obtain the position of the last non-zero coefficient of the current block.

[0258] S903: Decode all coefficients before the position of the last non-zero coefficient according to the preset scanning order to determine the coefficients of the current block.

[0259] It should be noted that, in the embodiments of this application, when the component identification message indicates that the component of the current slice is flipped using the last non-zero coefficient position, it means that the current block corresponding to the component of the current slice is also flipped using the last non-zero coefficient position. At this time, the coordinate message of the last non-zero coefficient of the current block can be determined as the horizontal distance and vertical distance between the position of the last non-zero coefficient and the lower right corner position of the current block.

[0260] In some embodiments, calculating the coordinate information of the last non-zero coefficient to obtain the position of the last non-zero coefficient of the current block may include:

[0261] Determine the width and height of the current block;

[0262] The horizontal coordinates of the last non-zero coefficient are obtained by subtracting the horizontal distance between the width of the current block and the position of the last non-zero coefficient relative to the lower right corner of the current block; and

[0263] Calculate the vertical coordinates of the last non-zero coefficient by subtracting the vertical distance between the height of the current block and the position of the last non-zero coefficient relative to the lower right corner of the current block;

[0264] Determine the position of the last non-zero coefficient of the current block based on the horizontal coordinate and the vertical coordinate of the last non-zero coefficient.

[0265] It should be noted that the coordinate information of the last non-zero coefficient is usually the horizontal and vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block. For regular images, most non-zero coefficients are concentrated in the upper left corner, while a large area in the lower right corner is 0; however, for high bit width, high quality, and high bit rate image encoding and decoding, a large number of non-zero coefficients will also appear in the lower right corner, making the value of the coordinate information of the last non-zero coefficient usually large. In this case, in order to save costs, coordinate transformation is required during coefficient encoding (specifically, coordinate flipping calculation, that is, after coordinate flipping, the coordinate information of the last non-zero coefficient is the horizontal and vertical distance between the position of the last non-zero coefficient and the lower right corner of the current block). Therefore, coordinate flipping calculation is also required during coefficient decoding. After flipping again, the coordinate information of the last non-zero coefficient can be recovered as the horizontal and vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block, thereby determining the position of the last non-zero coefficient so that all coefficients before the position of the last non-zero coefficient in the current block can be encoded according to the preset scanning order.

[0266] It should also be noted that the current block corresponding to the component of the current slice can be a block without zero-out transformation or a block after zero-out transformation. Taking a block after zero-out transformation as an example, the width of the current block is 1 << log2ZoTbWidth, and the height of the current block is 1 << log2ZoTbHeight; then, if the component identification message indicates that the component of the current slice is flipped using the last non-zero coefficient position,

[0267] LastSignificantCoeffX= (1<<log2ZoTbWidth)-1-LastSignificantCoeffX;

[0268] LastSignificantCoeffY= (1<<log2ZoTbHeight)-1-LastSignificantCoeffY.

[0269] In this equation, (LastSignificantCoeffX, LastSignificantCoeffY) on the right side represents the coordinate information of the last non-zero coefficient obtained through decoding, and (LastSignificantCoeffX, LastSignificantCoeffY) on the left side represents the position of the last non-zero coefficient (which can also be regarded as the target coordinate information of the last non-zero coefficient).

[0270] In addition, in some embodiments, the method may further include:

[0271] When the component identification message indicates that the component of the current slice does not use the last non-zero coefficient position to flip, the coordinate message of the last non-zero coefficient of the current block is determined as the horizontal distance and vertical distance between the position of the last non-zero coefficient and the upper left corner position of the current block.

[0272] The position of the last non-zero coefficient of the current block is determined based on the horizontal and vertical distances between the position of the last non-zero coefficient and the position of the upper left corner of the current block.

[0273] It should be noted that if the component identification message indicates that the component of the current slice does not use the last non-zero coefficient position flip, it means that the current block corresponding to the component of the current slice also does not use the last non-zero coefficient position flip. Therefore, the coordinate message of the last non-zero coefficient obtained through decoding can be regarded as the target coordinate message of the last non-zero coefficient. In the embodiments of this application, the target coordinate message of the last non-zero coefficient is the horizontal distance and vertical distance between the position of the last non-zero coefficient and the upper left corner position of the current block.

[0274] Further, in some embodiments, the method may also include:

[0275] When the component identification message indicates that the component of the current block does not use the last non-zero coefficient position to flip, the position of the last non-zero coefficient of the current block is directly determined according to the coordinate message of the last non-zero coefficient.

[0276] Decode all coefficients before the position of the last non-zero coefficient according to the preset scanning order to determine the coefficients of the current block.

[0277] It should be noted that the preset scanning order can be diagonal, zigzag, horizontal, vertical, 4×4 sub-block scanning or any other scanning order, and the embodiments of this application do not limit it in any way.

[0278] It should also be noted that after obtaining the component identification information of the current slice, if the value of the component identification information of the current slice is 1, that is, the component of the current slice needs to be flipped using the last non-zero coefficient position, then for the current block corresponding to the component of the current slice, after decoding to obtain the coordinate information of the last non-zero coefficient, it is necessary to calculate the coordinate information of the last non-zero coefficient to determine the position of the last non-zero coefficient of the current block; then, according to the preset scanning order, all coefficients before the position of the last non-zero coefficient are decoded to obtain the coefficients of the current block. If the value of the component identification information of the current slice is 1, that is, the component of the current slice does not need to be flipped using the last non-zero coefficient position, then for the current block corresponding to the component of the current slice, after decoding to obtain the coordinate information of the last non-zero coefficient, the position of the last non-zero coefficient of the current block can be directly determined according to the coordinate information of the last non-zero coefficient; then, according to the preset scanning order, all coefficients before the position of the last non-zero coefficient are decoded to obtain the coefficients of the current block.

[0279] Thus, in certain situations, during coefficient encoding, embodiments of this application provide a method for modifying the position of the last non-zero coefficient during output. That is, normally, the coefficient encoding / decoding method is the same as existing methods in related technologies. In certain situations, this could refer to the encoding / decoding of high-bit-width, high-quality, or high-bit-rate images, or lossless compressed images. Normally,

[0280] last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the horizontal coordinate of the last non-zero coefficient position, which is the horizontal distance relative to the top left corner of the current block;

[0281] last_sig_coeff_y_prefix and last_sig_coeff_y_suffix encode the ordinate of the last non-zero coefficient position, which is the vertical distance relative to the top-left corner of the current block, as shown in Figure 10A. However, in the case of high-bit-width, high-quality, high-bit-rate, or lossless compression image encoding and decoding, the position of the last non-zero coefficient is generally close to the bottom-right corner of all potentially non-zero coefficient regions in the current block. In this case, last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the horizontal distance of the last non-zero coefficient position relative to the bottom-right corner of all potentially non-zero coefficient regions in the current block; last_sig_coeff_y_prefix and last_sig_coeff_y_suffix encode the vertical distance of the last non-zero coefficient position relative to the bottom-right corner of all potentially non-zero coefficient regions in the current block, as shown in Figure 10B. For example, if all regions in the current block that could have non-zero coefficients are rectangular regions from (0, 0) to ((1 << log2ZoTbWidth) - 1, (1 << log2ZoTbHeight) - 1), then last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the horizontal distance of the last non-zero coefficient position relative to the current block ((1 << log2ZoTbWidth) - 1, (1 << log2ZoTbHeight) - 1). last_sig_coeff_y_prefix and last_sig_coeff_y_suffix encode the vertical distance of the last non-zero coefficient position relative to the current block ((1 << log2ZoTbWidth) - 1, (1 << log2ZoTbHeight) - 1).

[0282] The semantic modifications are as follows:

[0283] The value of the horizontal (or column) coordinate of the last non-zero coefficient in the current block according to the preset scan order, LastSignificantCoeffX, is exported as follows:

[0284] If last_sig_coeff_x_suffix does not exist, then,

[0285] LastSignificantCoeffX= last_sig_coeff_x_prefix;

[0286] Otherwise (last_sig_coeff_x_suffix exists),

[0287] LastSignificantCoeffX= (1<<((last_sig_coeff_x_prefix>>1)-1)) * (2+(last_sig_coeff_x_prefix&1)) + last_sig_coeff_x_suffix;

[0288] If the value of reverse_last_sig_coeff_flag is 1, then LastSignificantCoeffX = (1 << log2ZoTbWidth) - 1 - LastSignificantCoeffX;

[0289] The value of the vertical (or row) coordinate of the last non-zero coefficient in the current block according to the scan order.

[0290] LastSignificantCoeffY should be exported as follows:

[0291] If last_sig_coeff_y_suffix does not exist, then,

[0292] LastSignificantCoeffY= last_sig_coeff_y_prefix;

[0293] Otherwise (last_sig_coeff_y_suffix exists):

[0294] LastSignificantCoeffY= (1<<((last_sig_coeff_y_prefix>>1)-1)) * (2+(last_sig_coeff_y_prefix&1)) + last_sig_coeff_y_suffix;

[0295] If the value of reverse_last_sig_coeff_flag is 1, then

[0296] LastSignificantCoeffY= (1<<log2ZoTbHeight)-1-LastSignificantCoeffY.

[0297] Wherein, reverse_last_sig_coeff_flag is a flag indicating whether the position of the last non-zero coefficient needs to be flipped. If the value of reverse_last_sig_coeff_flag is 1, it means that the position of the last non-zero coefficient needs to be flipped; otherwise, it means that the position of the last non-zero coefficient does not need to be flipped.

[0298] It should also be noted that `reverse_last_sig_coeff_flag` may be a sequence-level or higher-level flag, or it may be a picture-level flag, a slice-level flag, a block-level flag, or a flag at other levels. Block-level flags include maximum coding unit (LCU) level flags, coding tree unit (CTU) level flags, coding unit (CU) level flags, or other block-level flags. For example, a sequence-level `reverse_last_sig_coeff_flag` can be represented by `sps_reverse_last_sig_coeff_flag`, and a slice-level `reverse_last_sig_coeff_flag` can be represented by `sh_reverse_last_sig_coeff_flag`.

[0299] In addition, `reverse_last_sig_coeff_flag` may depend on some other flags, such as high bit width flags, high bit rate flags, or second syntax element flags (SPS extension flag, `sps_extension_flag`). The SPS extension flag can be enabled in standard extension versions, such as the VVC extension version designed for high bit width, high bit rate encoding. That is, when the value of the high bit width flag or high bit rate flag is 1, the `reverse_last_sig_coeff_flag` flag needs to be decoded; otherwise, it does not need to be decoded.

[0300] In a specific example, assume there are sequence-level identification messages sps_extension_flag, sps_range_extension_flag, and sps_reverse_last_sig_coeff_flag. At the sequence level, if sps_extension_flag is 1, then sps_range_extension_flag needs to be decoded. If sps_range_extension_flag is 1, then sps_reverse_last_sig_coeff_flag needs to be decoded. Here, sps_reverse_last_sig_coeff_flag represents a flag indicating that the last non-zero coefficient position of the current sequence is flipped. If sps_reverse_last_sig_coeff_flag is 1, then it is determined that the block in the current sequence uses the last non-zero coefficient position for flipping; otherwise (i.e., sps_reverse_last_sig_coeff_flag is 0), it is determined that the block in the current sequence does not use the last non-zero coefficient position for flipping. The reverse_last_sig_coeff_flag in the existing syntax table has been changed to sps_reverse_last_sig_coeff_flag.

[0301] Understandably, sps_extension_flag indicates whether the current sequence uses a standard extended version. sps_range_extension_flag indicates whether the current sequence uses range extensions, such as high bit width, high bit rate, etc.

[0302] In one implementation, the syntax element table is modified as follows (Sequence parameter set RBSP syntax), see Table 3.

[0303] Table 3 ... Descriptor sps_extension_flag u(1) ... if( sps_extension_flag ) { sps_range_extension_flag u(1) ... if(sps_range_extension_flag) sps_range_extension() } ...

[0304] In another implementation, the syntax element table is modified as follows (Sequence parameter set range extension syntax), see Table 4.

[0305] Table 4 sps_range_extension() { Descriptor ... sps_reverse_last_sig_coeff_flag u(1) ... }

[0306] Based on the syntax elements in Tables 3 and 4, the value of sps_extension_flag is equal to 1, indicating that the syntax elements sps_range_extension_flag and sps_extension_7bits will appear in the SPS RBSP syntax structure; the value of sps_extension_flag is equal to 0, indicating that these syntax elements will not appear.

[0307] The value of sps_range_extension_flag is equal to 1, which means that the sps_range_extension() syntax structure will appear in the SPS RBSP syntax structure; if sps_range_extension_flag does not appear, then the value of sps_range_extension_flag is equal to 0.

[0308] The value of sps_reverse_last_sig_coeff_flag is equal to 1, which means that the block in the current sequence is flipped using the last non-zero coefficient position; otherwise (i.e., the value of sps_reverse_last_sig_coeff_flag is equal to 0), it means that the block in the current sequence is not flipped using the last non-zero coefficient position.

[0309] In another specific example, assume there are sequence-level identification messages sps_extension_flag, sps_range_extension_flag, and sps_reverse_last_sig_coeff_enabled_flag. At the sequence level, if sps_extension_flag is 1, then sps_range_extension_flag needs to be decoded. If sps_range_extension_flag is 1, then sps_reverse_last_sig_coeff_enabled_flag needs to be decoded. Here, sps_reverse_last_sig_coeff_enabled_flag is a flag indicating that the last non-zero coefficient position flip technique is allowed in the current sequence. If sps_reverse_last_sig_coeff_enabled_flag is 1, it means that the block in the current sequence is allowed to use the last non-zero coefficient position flip; otherwise (i.e., sps_reverse_last_sig_coeff_enabled_flag is 0), it means that the block in the current sequence is not allowed to use the last non-zero coefficient position flip. If `sps_reverse_last_sig_coeff_enabled_flag` does not appear, then its value is 0. At the slice level, if `sps_reverse_last_sig_coeff_enabled_flag` is 1, then `sh_reverse_last_sig_coeff_flag` needs to be decoded. `sh_reverse_last_sig_coeff_flag` is a flag indicating whether the last non-zero coefficient position of the current slice is flipped. If `sh_reverse_last_sig_coeff_flag` is 1, it means that blocks in the current slice use the last non-zero coefficient position for flipping; otherwise (i.e., `sh_reverse_last_sig_coeff_flag` is 0), it means that blocks in the current slice do not use the last non-zero coefficient position for flipping. If `sh_reverse_last_sig_coeff_flag` does not appear, then its value is 0.The existing syntax table has changed reverse_last_sig_coeff_flag to sh_reverse_last_sig_coeff_flag.

[0310] It should be noted that for the flag that flips the last non-zero coefficient position, at the sequence level, its semantics is "whether it is allowed to be used"; at the slice level, its semantics is "whether it is determined to be used".

[0311] In another implementation, the syntax element table is modified as follows (Slice header syntax), see Table 5.

[0312] Table 5 … Descriptor if(sps_reverse_last_sig_coeff_enabled_flag) sh_reverse_last_sig_coeff_flag u(1) …

[0313] Based on the syntax elements in Table 5, the value of sps_reverse_last_sig_coeff_enabled_flag is equal to 1, which means that the block in the current sequence is allowed to be flipped using the last non-zero coefficient position; otherwise (i.e., the value of sps_reverse_last_sig_coeff_enabled_flag is equal to 0), it means that the block in the current sequence is not allowed to be flipped using the last non-zero coefficient position.

[0314] The value of sh_reverse_last_sig_coeff_flag is equal to 1, indicating that the block in the current slice is flipped using the last non-zero coefficient position; otherwise (i.e., the value of sh_reverse_last_sig_coeff_flag is equal to 0), indicating that the block in the current slice is not flipped using the last non-zero coefficient position. If sh_reverse_last_sig_coeff_flag does not appear, then it is determined that the value of sh_reverse_last_sig_coeff_flag is equal to 0.

[0315] Understandably, for sh_reverse_last_sig_coeff_flag, that is, the component identification information of the current slice, it can be reflected that each image component in the current slice can be individually controlled to flip using the last non-zero coefficient position.

[0316] In this embodiment of the application, the components may include a first image component, a second image component and a third image component.

[0317] In a specific example, the first image component is a luminance component, the second image component is a first chromaticity component, and the third image component is a second chromaticity component. The luminance component is represented by the Y component, the first chromaticity component by the U (Cb) component, and the second chromaticity component by the V (Cr) component.

[0318] In another specific example, the first image component is the red component, the second image component is the green component, and the third image component is the blue component. The red component is represented by the R component, the green component by the G component, and the blue component by the B component.

[0319] Further, in some embodiments, when the components include a first image component, a second image component, and a third image component, the method may further include:

[0320] Based on the attribute relationship between the first image component, the second image component and the third image component, determine whether there is a shared component identification message among the first image component, the second image component and the third image component in the current chip;

[0321] Based on the judgment result, determine the number of component identification messages of the current slice; wherein the number of component identification messages is 1, 2 or 3.

[0322] Specifically, determining the number of component identification messages may include:

[0323] If the first image component, the second image component, and the third image component of the current slice all share a single component identifier message, then the number of component identifier messages in the current slice is determined to be 1; or,

[0324] If two of the first, second, and third image components of the current slice share a single component identification message, then the number of component identification messages for the current slice is determined to be two; or,

[0325] If the first image component, the second image component, and the third image component of the current slice each use a component identification message, then the number of component identification messages of the current slice is determined to be 3.

[0326] In this embodiment of the application, on the one hand, since the attributes of each image component are different, the image components are such as R, G, B of RGB format images or Y, U, V (Y, Cb, Cr) of YUV format, and other possible formats. For YUV format, there can be formats such as YUV444, YUV422, YUV420, etc. For the human eye, changes in brightness are more sensitive than changes in chrominance. Therefore, sometimes formats such as YUV422 and YUV420 are used to downsample the chrominance. Moreover, the quantization step size of chrominance is usually larger than that of brightness, which has the effect of reducing the bit rate.

[0327] On the other hand, some cross-component coding techniques utilize the correlation between components to improve coding efficiency. For example, the Cross-Component Linear Model (CCLM) prediction technique uses the reconstructed values ​​of the luminance component and a linear model to predict the chrominance component. CCLM can improve the prediction accuracy of the chrominance component, thereby reducing the residual of the chrominance component. In addition, some techniques further utilize information from one luminance component and one chrominance component to predict another component, thereby further improving compression efficiency. The Cross-Component Adaptive Loop Filter (CCALF) technique supplements the chrominance component with some details of the luminance component during loop filtering to improve compression efficiency. Since the details of the chrominance component can be supplemented by the luminance component, this also allows for greater distortion when coding residuals.

[0328] Thus, due to the different properties of each image component and the use of some cross-component techniques, the residual distribution patterns of each image component are not always consistent. For example, in high-bitrate, high-quality image encoding and decoding, the distribution of non-zero coefficients of different components is similar; for example, the non-zero coefficients are all close to the lower right corner of the region where they might be non-zero coefficients. However, in some low-bitrate, low-quality image encoding and decoding, the distribution of non-zero coefficients of different components may be different. For example, the non-zero coefficients of the Y component are all close to the lower right corner of the region where they might be non-zero coefficients, while the non-zero coefficients of the U / V components are only distributed in the upper left corner; or the non-zero coefficients of the U component are also close to the lower right corner, while the non-zero coefficients of the V component are only distributed in the upper left corner.

[0329] Therefore, embodiments of this application can use one or more component identification messages to control the use of different image components in embodiments of this application. For example, one component identification message can be used to control whether three image components use the method of embodiments of this application, such as one component identification message controlling whether three image components use the method of embodiments of this application. Alternatively, two component identification messages can be used to control whether three image components use the method of embodiments of this application, such as one component identification message controlling the luminance component and another component identification message controlling the two chrominance components. Alternatively, three component identification messages can be used to control whether each of the three image components uses the method of embodiments of this application, such as the three image components being R, G, B in RGB, or Y, U, V in YUV, or Y, Cb, Cr. In one possible implementation, when the number of component identification messages is one, parsing the bitstream and determining the component identification message of the current slice includes: parsing the bitstream and determining the first component identification message of the current slice;

[0330] Accordingly, the method may further include: if the value of the first component identification message is a first value, then it is determined that the first image component, the second image component, and the third image component of the current slice are all flipped using the last non-zero coefficient position; or, if the value of the first component identification message is a second value, then it is determined that the first image component, the second image component, and the third image component of the current slice are not flipped using the last non-zero coefficient position.

[0331] In another possible implementation, when the number of component identification messages is 2, the bitstream is parsed to determine the component identification messages of the current slice, including: parsing the bitstream to determine the second component identification message and the third component identification message of the current slice;

[0332] Accordingly, the method may further include: if the value of the second component identification message is a first value, then determining that two of the first image component, the second image component, and the third image component of the current slice are flipped using the last non-zero coefficient position; or, if the value of the second component identification message is a second value, then determining that two of the first image component, the second image component, and the third image component of the current slice are not flipped using the last non-zero coefficient position; and

[0333] If the value of the third component identification message is the first value, then it is determined that the remaining image components of the current slice, excluding two of them, are flipped using the last non-zero coefficient position; or, if the value of the third component identification message is the second value, then it is determined that the remaining image components of the current slice, excluding two of them, are not flipped using the last non-zero coefficient position.

[0334] In another possible implementation, when the number of component identification messages is 3, the bitstream is parsed to determine the component identification messages of the current slice, including: parsing the bitstream to determine the fourth component identification message, the fifth component identification message and the sixth component identification message of the current slice.

[0335] Accordingly, the method may further include: if the value of the fourth component identification message is a first value, then determining that the first image component of the current slice is flipped using the last non-zero coefficient position; or, if the value of the fourth component identification message is a second value, then determining that the first image component of the current slice is not flipped using the last non-zero coefficient position; and

[0336] If the value of the fifth component identifier message is the first value, then it is determined that the second image component of the current slice is flipped using the last non-zero coefficient position; or, if the value of the fifth component identifier message is the second value, then it is determined that the second image component of the current slice is not flipped using the last non-zero coefficient position; and

[0337] If the value of the sixth component identification message is the first value, then it is determined that the third image component of the current slice is flipped using the last non-zero coefficient position; or, if the value of the sixth component identification message is the second value, then it is determined that the third image component of the current slice is not flipped using the last non-zero coefficient position.

[0338] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numeric form. In a specific example, the first value can be set to 1 and the second value can be set to 0, but there are no restrictions.

[0339] It should also be noted that the component identification message here is a slice-level flag, which can be represented by sh_reverse_last_sig_coeff_flag[cIdx], where the value of cIdx is 0, 1, or 2. Specifically, when using 3 component identification messages to control 3 image components respectively, these 3 component identification messages can include: sh_reverse_last_sig_coeff_flag[0], sh_reverse_last_sig_coeff_flag[1], and sh_reverse_last_sig_coeff_flag[2]. The fourth component identifier message is represented by sh_reverse_last_sig_coeff_flag[0], which is used to indicate whether the current block corresponding to the first image component of the current slice is flipped using the last non-zero coefficient position; the fifth component identifier message is represented by sh_reverse_last_sig_coeff_flag[1], which is used to indicate whether the current block corresponding to the second image component of the current slice is flipped using the last non-zero coefficient position; the sixth component identifier message is represented by sh_reverse_last_sig_coeff_flag[2], which is used to indicate whether the current block corresponding to the third image component of the current slice is flipped using the last non-zero coefficient position.

[0340] In a specific example, each of the three image components (YUV) is individually identified and controlled using a component identifier message. Assume there are sequence-level identifier messages: `sps_extension_flag`, `sps_range_extension_flag`, and `sps_reverse_last_sig_coeff_enabled_flag`. At the sequence level, `sps_extension_flag` is decoded. If its value is 1, then `sps_range_extension_flag` needs to be decoded; otherwise, `sps_reverse_last_sig_coeff_enabled_flag` needs to be decoded. Here, `sps_reverse_last_sig_coeff_enabled_flag` is a flag indicating that the flipping technique is allowed at the last non-zero coefficient position of the current sequence. If the value of sps_reverse_last_sig_coeff_enabled_flag is 1, it means that the block in the current sequence is allowed to be flipped using the last non-zero coefficient position; otherwise (i.e., the value of sps_reverse_last_sig_coeff_enabled_flag is 0), it means that the block in the current sequence is not allowed to be flipped using the last non-zero coefficient position. If sps_reverse_last_sig_coeff_enabled_flag does not appear, then the value of sps_reverse_last_sig_coeff_enabled_flag is 0. At the slice level, if the value of sps_reverse_last_sig_coeff_enabled_flag is 1, then further decoding is required to obtain the component identification information (sh_reverse_last_sig_coeff_flag[0], sh_reverse_last_sig_coeff_flag[1], sh_reverse_last_sig_coeff_flag[2]). Wherein, sh_reverse_last_sig_coeff_flag[cIdx], where cIdx takes the values ​​0, 1, and 2, represents the flip flag of the last non-zero coefficient position of the cIdx component of the current slice.If sh_reverse_last_sig_coeff_flag[cIdx] is 1, it means that the block of the cIdx-th component in the current slice is flipped using the last non-zero coefficient position; otherwise (i.e., sh_reverse_last_sig_coeff_flag[cIdx] is 0), it means that the block of the cIdx-th component in the current slice is not flipped using the last non-zero coefficient position. If sh_reverse_last_sig_coeff_flag[cIdx] does not appear, then sh_reverse_last_sig_coeff_flag[cIdx] is 0.

[0341] In one possible implementation, for the YUV format, the 0th component corresponds to the Y component, the 1st component corresponds to the U (Cb) component, and the 2nd component corresponds to the V (Cr) component.

[0342] In another possible implementation, for the RGB format, the 0th component corresponds to the R component, the 1st component corresponds to the G component, and the 2nd component corresponds to the B component.

[0343] For example, taking the YUV format as an example, if the value of sh_reverse_last_sig_coeff_flag[0] is 1, then it is determined that the first image component (e.g., the Y component) of the current slice is flipped using the last non-zero coefficient position; if the value of sh_reverse_last_sig_coeff_flag[1] is 1, then it is determined that the second image component (e.g., the U component) of the current slice is flipped using the last non-zero coefficient position; if the value of sh_reverse_last_sig_coeff_flag[2] is 1, then it is determined that the third image component (e.g., the V component) of the current slice is flipped using the last non-zero coefficient position.

[0344] In one implementation, the syntax element table is modified as follows (Sequence parameter set RBSP syntax), see Table 6.

[0345] Table 6 ... Descriptor sps_extension_flag u(1) ... if( sps_extension_flag ) { sps_range_extension_flag u(1) ... if(sps_range_extension_flag) sps_range_extension() } ...

[0346] In another implementation, the syntax element table is modified as follows (Sequence parameter set range extension syntax), see Table 7.

[0347] Table 7 sps_range_extension() { Descriptor ... sps_reverse_last_sig_coeff_enabled_flag u(1) ... }

[0348] In another implementation, the syntax element table is modified as follows (Slice header syntax), see Table 8.

[0349] Table 8 … Descriptor if(sps_reverse_last_sig_coeff_enabled_flag) sh_reverse_last_sig_coeff_flag[0] u(1) sh_reverse_last_sig_coeff_flag[1] u(1) sh_reverse_last_sig_coeff_flag[2] u(1) …

[0350] In another implementation, there is another modified form of the Slice header syntax, and the modification of its syntax element table is as follows (Slice header syntax), see Table 9.

[0351] Table 9 … Descriptor if(sps_reverse_last_sig_coeff_enabled_flag) for( cIdx = startComp; cIdx < ( startComp + numComps ); cIdx++ ) sh_reverse_last_sig_coeff_flag[cIdx] u(1) …

[0352] Here, one possible scenario is that startComp equals 0 and numComps equals 3.

[0353] The semantic modifications are as follows:

[0354] The value of the horizontal (or column) coordinate of the last non-zero coefficient in the current block according to the preset scan order, LastSignificantCoeffX, is exported as follows:

[0355] If last_sig_coeff_x_suffix does not exist, then,

[0356] LastSignificantCoeffX= last_sig_coeff_x_prefix;

[0357] Otherwise (last_sig_coeff_x_suffix exists),

[0358] LastSignificantCoeffX= (1<<((last_sig_coeff_x_prefix>>1)-1)) * (2+(last_sig_coeff_x_prefix&1)) + last_sig_coeff_x_suffix;

[0359] If the value of sh_reverse_last_sig_coeff_flag[cIdx] is 1, then

[0360] LastSignificantCoeffX = (1<<log2ZoTbWidth)-1-LastSignificantCoeffX;

[0361] The value of the vertical (or row) coordinate of the last non-zero coefficient in the current block in scan order, LastSignificantCoeffY, is exported as follows:

[0362] If last_sig_coeff_y_suffix does not exist, then,

[0363] LastSignificantCoeffY= last_sig_coeff_y_prefix;

[0364] Otherwise (last_sig_coeff_y_suffix exists):

[0365] LastSignificantCoeffY= (1<<((last_sig_coeff_y_prefix>>1)-1)) * (2+(last_sig_coeff_y_prefix&1)) + last_sig_coeff_y_suffix;

[0366] If the value of sh_reverse_last_sig_coeff_flag[cIdx] is 1, then

[0367] LastSignificantCoeffY= (1<<log2ZoTbHeight)-1-LastSignificantCoeffY.

[0368] Here, sh_reverse_last_sig_coeff_flag[cIdx] represents the flip flag of the last non-zero coefficient position of the cIdx component of the current slice, and the value of cIdx is 0, 1, or 2.

[0369] It can also be understood that when the third syntax element identification message indicates that the current sequence uses an expanded range, it is also possible to preset that all coefficients that may need to be encoded need to be encoded. That is, the position of the last non-zero coefficient is no longer used, but all possible non-zero coefficients of the current block are scanned according to the preset scanning order. Therefore, the embodiments of this application can also introduce the last coefficient enable flag message to determine whether the current block uses the last coefficient position.

[0370] In some embodiments, when the third syntax element identification message indicates that the current sequence usage scope has been expanded, the method may further include:

[0371] Analyze the bitstream to determine the last coefficient enable flag message of the current block;

[0372] When the last coefficient enable flag message indicates that the current block uses the last coefficient position, all coefficients before the last coefficient position are decoded according to the preset scanning order to determine the coefficients of the current block.

[0373] It should be noted that the last coefficient enable flag message can be represented by default_last_coeff_enabled_flag. In the embodiments of this application, the last coefficient enable flag message can be at least one of the following flag messages: sequence level, image level, slice level, and block level; it can even be a higher level flag message (such as VUI, SEI, etc.), without any limitation here.

[0374] That is to say, default_last_coeff_enabled_flag may be a sequence-level or higher-level flag, or it may be an image-level flag, a slice-level flag, a block-level flag, or a flag at other levels. In addition, block-level flags may include maximum coding unit (LCU) level flags, coding tree unit (CTU) level flags, coding unit (CU) level flags, or other block-level flags, and this application embodiment does not impose any limitations.

[0375] In some embodiments, the method may further include:

[0376] If the value of the last coefficient enable flag message is the first value, then it is determined that the last coefficient enable flag message indicates that the current block uses the position of the last coefficient; or,

[0377] If the value of the last coefficient enable flag message is the second value, then it is determined that the last coefficient enable flag message indicates that the current block does not use the last coefficient position.

[0378] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numeric form. In a specific example, the first value can be set to 1 and the second value can be set to 0, but there are no restrictions.

[0379] In this way, taking the first value as 1 and the second value as 0 as an example, if the value of default_last_coeff_enabled_flag is 1, then it can be determined that default_last_coeff_enabled_flag indicates that the current block uses the last coefficient position; or, if the value of default_last_coeff_enabled_flag is 0, then it can be determined that default_last_coeff_enabled_flag indicates that the current block does not use the last coefficient position.

[0380] When the last coefficient position is used in the current block, all coefficients before the last coefficient position can be decoded according to the preset scanning order to determine the coefficients of the current block.

[0381] Further, when the last coefficient position is not used in the current block, that is, when the value of the last coefficient enable flag message is 0, in some embodiments, the method may further include:

[0382] Parse the code stream and obtain the first code information of the horizontal coordinate of the last non-zero coefficient, the first code information of the vertical coordinate of the last non-zero coefficient, the last code information of the horizontal coordinate of the last non-zero coefficient, and the last code information of the vertical coordinate of the last non-zero coefficient of the current block.

[0383] Determine the position of the last non-zero coefficient based on the first code information of the horizontal coordinate of the last non-zero coefficient, the first code information of the vertical coordinate of the last non-zero coefficient, the last code information of the horizontal coordinate of the last non-zero coefficient, and the last code information of the vertical coordinate of the last non-zero coefficient.

[0384] Decode all coefficients before the last non-zero coefficient according to the preset scanning order to determine the coefficients of the current block.

[0385] It should be noted that if the current block does not use the position of the last coefficient, then it is necessary to decode to obtain the position of the last non-zero coefficient. Specifically, by parsing the bitstream, obtain last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix; then, based on last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix, determine the position of the last non-zero coefficient. Otherwise, if the current block uses the position of the last coefficient, then it is no longer necessary to determine the position of the last non-zero coefficient, and therefore it is no longer necessary to decode to obtain last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix.

[0386] It should also be noted that if the current block uses the last coefficient position, then all coefficients before the last coefficient position can be decoded according to the preset scanning order; if the current block does not use the last coefficient position, then all coefficients before the last non-zero coefficient position can be decoded according to the preset scanning order. Here, the preset scanning order can be diagonal, zigzag, horizontal, vertical, 4×4 sub-block scanning, or any other scanning order, and this application embodiment does not impose any limitations.

[0387] Further, for the last coefficient position, in some embodiments, the last coefficient position is the lower right corner of the matrix composed of all possible non-zero coefficients in the current block; or, the last coefficient position is the last position of the current block after scanning all possible non-zero coefficients according to a preset scanning sequence.

[0388] It should be noted that the position of the last coefficient in the embodiments of this application does not represent the position of the last non-zero coefficient. This is because the coefficient at the last coefficient position may be 0, while the coefficient at the last non-zero coefficient position is definitely not 0.

[0389] In a particular example, the method may further include setting the position of the last non-zero coefficient at the last coefficient position.

[0390] That is to say, the position of the last non-zero coefficient can still be used in the embodiments of this application. In this case, the position of the last non-zero coefficient needs to be placed at the last position of all possible non-zero coefficients in the current block according to the preset scanning order.

[0391] Further, the position of the last coefficient can be represented by (LastCoeffX, LastCoeffY), that is, the last position of all coefficients that may be non-zero in the current block according to a preset scan order. In some embodiments, the method may further include:

[0392] Determine the width and height of the transformed block obtained by the current block after the preset operation;

[0393] Calculate the coordinates based on the width and height of the transform block to obtain the coordinate information of the lower right corner of the transform block;

[0394] Determine the position of the last coefficient based on the coordinate information of the lower right corner of the transform block.

[0395] Here, the default operation includes at least: forced zero-out operation.

[0396] It should be noted that (LastCoeffX, LastCoeffY) represents the coordinate information of the lower right corner of the transform block after zero-out; the export method of (LastCoeffX, LastCoeffY) is as follows:

[0397] LastCoeffX= (1<<log2ZoTbWidth)-1;

[0398] LastCoeffY= (1<<log2ZoTbHeight)-1.

[0399] In this way, if the value of default_last_coeff_enabled_flag is 1, then the position of the last coefficient can be determined according to (LastCoeffX, LastCoeffY).

[0400] In a particular example, the position of the last non-zero coefficient is still used. In this case, the position of the last non-zero coefficient can be placed at the end of all coefficients that may be 0 in the current block according to a preset scan order. In some embodiments, the method may further include:

[0401] When the position of the last non-zero coefficient is set to the last coefficient position, the position of the last non-zero coefficient is determined according to the coordinate information of the lower right corner of the transform block.

[0402] That is to say, the position of the last non-zero coefficient can be represented by (LastSignificantCoeffX, LastSignificantCoeffY), and the export method of (LastSignificantCoeffX, LastSignificantCoeffY) is as follows:

[0403] LastSignificantCoeffX= (1 <<log2ZoTbWidth)-1;

[0404] LastSignificantCoeffY= (1 <<log2ZoTbHeight)-1.

[0405] Where (LastSignificantCoeffX, LastSignificantCoeffY) represents the coordinate information of the lower right corner of the transform block after zero-out. If the value of default_last_coeff_enabled_flag is 1, then the position of the last non-zero coefficient can be determined according to (LastSignificantCoeffX, LastSignificantCoeffY).

[0406] Thus, in certain situations, during coefficient encoding, it is pre-set that all coefficients that may need to be encoded need to be encoded. That is to say, under normal circumstances, the coefficient encoding and decoding method is still the same as existing methods in related technologies. Such situations may refer to the encoding and decoding of high-bit-width, high-quality, or high-bit-rate images, or lossless compressed images. Pre-setting that all coefficients that may need to be encoded means that the position of the last non-zero coefficient is no longer used; instead, all possible non-zero coefficients in the current block are scanned according to a pre-set scanning order; or, the position of the last coefficient to be encoded is placed at the end of all possible non-zero coefficients in the current block according to the pre-set scanning order. This position usually refers to the lower right corner of the matrix formed by all possible non-zero coefficients in the current block. Here, the position of the last coefficient to be encoded is used instead of the position of the last non-zero coefficient. This is because the coefficient at the position of the last coefficient to be encoded may be 0, while the coefficient at the position of the last non-zero coefficient is definitely not 0.

[0407] A special case is to still use the position of the last non-zero coefficient. In this case, the position of the last non-zero coefficient is placed at the end of all possible non-zero coefficients in the current block according to the preset scan order.

[0408] Additionally, all coefficients in the current block that may be non-zero in the preset scan order are because there are other techniques besides the last non-zero coefficient that make some coefficients in a block default to 0. For example, it could be the zero-out mentioned above.

[0409] The semantic modifications are shown in Table 10.

[0410] Table 10 … Descriptor if(!default_last_coeff_enabled_flag){ if (log2TbWidth > 0) last_sig_coeff_x_prefix ae(v) if ( log2TbHeight > 0 ) last_sig_coeff_y_prefix ae(v) if(last_sig_coeff_x_prefix > 3) last_sig_coeff_x_suffix ae(v) if(last_sig_coeff_y_prefix > 3) last_sig_coeff_y_suffix ae(v) } …

[0411] In this embodiment of the application, a condition can be added before decoding the message required for the last non-zero coefficient. That is, if default_last_coeff_enabled_flag is not true (i.e., the value of default_last_coeff_enabled_flag is equal to 0), then it is necessary to decode the syntax elements such as last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, and last_sig_coeff_y_suffix. If default_last_coeff_enabled_flag is true (i.e., the value of default_last_coeff_enabled_flag is equal to 1), then it is not necessary to decode the syntax elements such as last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, and last_sig_coeff_y_suffix.

[0412] Here, default_last_coeff_enabled_flag is the default last coefficient enable flag, used to indicate whether to use the default last coefficient. If the value of default_last_coeff_enabled_flag is 1, it means that the default last coefficient position is used, that is, the last coefficient position to be encoded is placed at the last position of all possible non-zero coefficients in the current block according to the preset scan order; otherwise, it means that the default last coefficient position is not used.

[0413] If the value of default_last_coeff_enabled_flag is 1, then by default, the last coefficient position (LastCoeffX, LastCoeffY) is the last position of all coefficients that may not be 0 in the current block according to the preset scan order. Coefficients before (LastCoeffX, LastCoeffY) in the preset scan order need to be scanned. In this embodiment, the export method for (LastCoeffX, LastCoeffY) is as follows:

[0414] LastCoeffX= (1<<log2ZoTbWidth)-1;

[0415] LastCoeffY= (1<<log2ZoTbHeight)-1.

[0416] Where (LastCoeffX, LastCoeffY) is the coordinate information of the lower right corner of the transform block after zero-out.

[0417] A special case is to still use the position of the last non-zero coefficient, placing it at the end of all possible non-zero coefficients in the current block according to a preset scan order. In this embodiment, the method for exporting the position of the last non-zero coefficient (LastSignificantCoeffX, LastSignificantCoeffY) is as follows:

[0418] LastSignificantCoeffX= (1<<log2ZoTbWidth)-1;

[0419] LastSignificantCoeffY= (1<<log2ZoTbHeight)-1.

[0420] Where (LastSignificantCoeffX, LastSignificantCoeffY) is the coordinate information of the lower right corner of the transform block after zero-out.

[0421] It should also be noted that default_last_coeff_enabled_flag may be a sequence-level or higher-level flag, or it may be a picture-level flag, a slice-level flag, a block-level flag, or a flag at other levels. Block-level flags include flags at the maximum coding unit (LCU) level, or flags at the coding tree unit (CTU) level, or flags at the coding unit (CU) level, or other block-level flags.

[0422] In addition, default_last_coeff_enabled_flag may depend on some other flags, such as high bit width flags or high bit rate flags. That is, when the value of the high bit width flag or the high bit rate flag is 1, the default_last_coeff_enabled_flag flag needs to be decoded; otherwise, the default_last_coeff_enabled_flag flag does not need to be decoded.

[0423] In a specific example, taking the sequence level as an example, assume there is a sequence-level flag `sps_high_bit_depth_flag` indicating whether the current image sequence is a high-bit-width sequence. If the value of `sps_high_bit_depth_flag` is 1, then it means that the current image sequence is a high-bit-width sequence; otherwise, it means that the current image sequence is not a high-bit-width sequence. At the sequence level, if the value of `sps_high_bit_depth_flag` is 1, then `sps_default_last_coeff_enabled_flag` needs to be decoded. Here, `sps_default_last_coeff_enabled_flag` is the default last coefficient enable flag for the current sequence. If the value of `sps_default_last_coeff_enabled_flag` is 1, then it means that the block in the current sequence uses the default last coefficient; otherwise (i.e., the value of `sps_default_last_coeff_enabled_flag` is 0), it means that the block in the current sequence does not use the default last coefficient. In the syntax table above, default_last_coeff_enabled_flag is changed to sps_default_last_coeff_enabled_flag.

[0424] In the implementation, the syntax element table is modified as follows (Sequence parameter set RBSP syntax), see Table 11.

[0425] Table 11 … Descriptor sps_high_bit_depth_flag u(1) if( sps_high_bit_depth_flag ) sps_default_last_coeff_enabled_flag u(1) …

[0426] In another specific example, taking the slice level as an example, assume there is a sequence-level flag `sps_high_bit_depth_flag` indicating whether the current image sequence is a high-bit-width sequence. If the value of `sps_high_bit_depth_flag` is 1, then it means that the current image sequence is a high-bit-width sequence; otherwise, it means that the current image sequence is not a high-bit-width sequence. At the slice level, if the value of `sps_high_bit_depth_flag` is 1, then `sh_default_last_coeff_enabled_flag` needs to be decoded. Here, `sh_default_last_coeff_enabled_flag` is the default last coefficient enable flag for the current slice. If the value of `sh_default_last_coeff_enabled_flag` is 1, then it means that the blocks in the current slice use the default last coefficient; otherwise (i.e., the value of `sh_default_last_coeff_enabled_flag` is 0), it means that the blocks in the current slice do not use the default last coefficient. In the syntax table above, default_last_coeff_enabled_flag is changed to sh_default_last_coeff_enabled_flag.

[0427] In the implementation, the syntax element table is modified as follows (Slice header syntax), see Table 12.

[0428] Table 12 … Descriptor if( sps_high_bit_depth_flag ) sh_default_last_coeff_enabled_flag u(1) …

[0429] In this embodiment of the application, the default last coefficient enable flag for sh_default_last_coeff_enabled_flag, that is, the default last coefficient enable flag for the current slice, can also be reflected in the fact that each image component in the current slice can be individually controlled to control whether to use the default last coefficient.

[0430] Specifically, the default last coefficient enable flag message of the current slice can also be represented by sh_default_last_coeff_enabled_flag[cIdx], where cIdx takes the value of 0, 1, or 2. Specifically, when using 3 component flag messages to control 3 image components respectively, these 3 component flag messages can include: sh_default_last_coeff_enabled_flag[0], sh_default_last_coeff_enabled_flag[1], and sh_default_last_coeff_enabled_flag[2]. Among them, sh_default_last_coeff_enabled_flag[0] is used to indicate whether the current block corresponding to the first image component of the current slice uses the default last coefficient; sh_default_last_coeff_enabled_flag[1] is used to indicate whether the current block corresponding to the second image component of the current slice uses the default last coefficient; sh_default_last_coeff_enabled_flag[2] is used to indicate whether the current block corresponding to the third image component of the current slice uses the default last coefficient.

[0431] Here, one or more component identification messages can also be used in this embodiment to control the use of different image components in this embodiment. For example, one component identification message can be used to control whether three image components use the method of this embodiment, such as one component identification message controlling whether three image components use the method of this embodiment. Alternatively, two component identification messages can be used to control whether three image components use the method of this embodiment, such as one component identification message controlling the luminance component and another component identification message controlling the two chrominance components. Alternatively, three component identification messages can be used to control whether each of the three image components uses the method of this embodiment, such as the three image components being R, G, B in RGB, or Y, U, V in YUV, or Y, Cb, Cr.

[0432] For example, taking the YUV format as an example, three component identification messages are used to control whether each of the three image components uses the method of the embodiment of this application. Wherein, if the value of sh_default_last_coeff_enabled_flag[0] is 1, then it is determined that the block corresponding to the first image component (e.g., the Y component) of the current slice uses the default last coefficient; if the value of sh_default_last_coeff_enabled_flag[1] is 1, then it is determined that the block corresponding to the second image component (e.g., the U component) of the current slice uses the default last coefficient; if the value of sh_default_last_coeff_enabled_flag[2] is 1, then it is determined that the block corresponding to the third image component (e.g., the V component) of the current slice uses the default last coefficient.

[0433] It can also be understood that when the third syntax element identifier message indicates that the current sequence uses an expanded range, all sub-blocks that can be scanned are pre-encoded. In this case, it is not necessary to transmit sb_coded_flag in the bitstream, that is, neither the encoder nor the decoder needs to process this flag, so as to speed up the encoding and decoding speed. Therefore, embodiments of this application can also introduce a sub-block pre-encoding identifier message to determine whether the sub-block to be decoded in the current block is pre-encoded.

[0434] In some embodiments, when the third syntax element identification message indicates that the current sequence usage range has been expanded, the method may further include:

[0435] Analyze the bitstream to determine the preset encoding identifier information of the sub-blocks of the current block;

[0436] When the sub-block preset encoding identifier message indicates the preset encoding of the sub-block to be decoded in the current block, all coefficients in the sub-block to be decoded are decoded.

[0437] It should be noted that if the sub-block preset encoding identifier message indicates the preset encoding of the sub-block to be decoded in the current block, then it can be determined that the value of the sub-block encoding identifier message is the first value. At this time, all coefficients in the sub-block to be decoded need to be decoded.

[0438] It should also be noted that the sub-block preset identification message can be represented by default_sb_coded_flag. In the embodiments of this application, the sub-block preset coding identification message is at least one of the following identification messages: sequence level, image level, slice level, and block level; it can even be a higher level (such as VUI, SEI, etc.) identification message, which is not limited here.

[0439] That is to say, default_sb_coded_flag may be a sequence-level or higher-level flag, or it may be an image-level flag, a slice-level flag, a block-level flag, or a flag of other levels. In addition, block-level flags may include maximum coding unit (LCU) level flags, coding tree unit (CTU) level flags, coding unit (CU) level flags, or other block-level flags. The embodiments of this application do not impose any limitations.

[0440] In some embodiments, the method may further include: if the value of the sub-block preset encoding identifier message is a first value, then determine that the sub-block preset encoding identifier message indicates that the sub-block to be decoded in the current block is preset encoded; or, if the value of the sub-block preset encoding identifier message is a second value, then determine that the sub-block preset encoding identifier message indicates that the sub-block to be decoded in the current block is not preset encoded.

[0441] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numerical form. Specifically, the first syntax element identification message can be a parameter written in the profile or a value of a flag. This application embodiment does not limit this in any way.

[0442] Taking the first syntax element identifier message as a flag as an example, for the first value and the second value, the first value can be set to 1 and the second value can be set to 0; or, the first value can also be set to true and the second value can also be set to false; or, the first value can also be set to 0 and the second value can also be set to 1; or, the first value can also be set to false and the second value can also be set to true; no restrictions are made here.

[0443] In this way, taking the first value as 1 and the second value as 0 as an example, if the value of default_sb_coded_flag is 1, then it can be determined that default_sb_coded_flag indicates that the sub-block to be decoded needs to be encoded by default; or, if the value of default_sb_coded_flag is 0, then it can be determined that default_sb_coded_flag indicates that the sub-block to be decoded does not need to be encoded by default.

[0444] If the sub-block to be decoded is required to be encoded by default, the value of default_sb_coded_flag is 1, which means that the value of sb_coded_flag is 1, that is, sb_coded_flag no longer needs to be decoded. At this time, it is assumed that all coefficients in the sub-block to be decoded need to be decoded.

[0445] Further, in cases where the sub-block to be decoded does not pre-define the need for encoding, i.e., the value of default_sb_coded_flag is 0, in some embodiments, the method may further include:

[0446] Analyze the bitstream to determine the sub-block encoding identifier information of the sub-block to be decoded;

[0447] When the sub-block encoding identifier message takes the first value, all coefficients in the sub-block to be decoded are decoded.

[0448] It should be noted that if the sub-block to be decoded does not require encoding by default, then it is necessary to decode to obtain the sub-block encoding identifier information; and then determine whether to decode all coefficients in the sub-block to be decoded based on the sub-block encoding identifier information.

[0449] Further, for the sub-block encoding identifier message, the method may also include: if the value of the sub-block encoding identifier message is a first value, then it is determined that all coefficients in the sub-block to be decoded are decoded; or, if the value of the sub-block encoding identifier message is a second value, then it is determined that all coefficients in the sub-block to be decoded are zero.

[0450] In this embodiment of the application, the sub-block encoding identifier message can be represented by sb_coded_flag. Taking a first value of 1 and a second value of 0 as an example, if the value of sb_coded_flag is 1, then it can be determined that all coefficients in the sub-block to be decoded need to be decoded; or, if the value of sb_coded_flag is 0, then it can be determined that all coefficients in the sub-block to be decoded do not need to be decoded, and in this case, all coefficients in the sub-block to be decoded are zero.

[0451] Thus, in certain situations, during coefficient encoding, all scanned sub-blocks are pre-programmed to require encoding, or in other words, all scanned sub-blocks contain non-zero coefficients by default. That is, under normal circumstances, the coefficient encoding and decoding method is the same as existing methods in related technologies. In certain situations, this might refer to the encoding and decoding of high-bit-width, high-quality, or high-bit-rate images, or lossless compressed images. In this case, there are many non-zero coefficients, and almost all scanned sub-blocks need to be encoded; or in other words, almost all scanned sub-blocks contain non-zero coefficients. This eliminates the need to transmit the `sb_coded_flag` in the bitstream, and the encoder / decoder does not need to process this flag, thereby speeding up encoding and decoding. Removing a flag that is almost non-existent also brings a slight improvement in compression performance.

[0452] The semantic modifications are shown in Table 13.

[0453] Table 13 … Descriptor if( i<lastSubBlock && i>0 ) { if(!default_sb_coded_flag) { sb_coded_flag[xS][yS] ae(v) } inferSbDcSigCoeffFlag = 1 } …

[0454] wherein, default_sb_coded_flag is a flag indicating that a sub-block needs to be encoded. If the value of default_sb_coded_flag is 1, then it can be determined that the value of sb_coded_flag[xS][yS] is 1, and there is no need to decode from the bitstream; otherwise (if the value of default_sb_coded_flag is 0), it is still necessary to decode sb_coded_flag[xS][yS] from the bitstream.

[0455] It should also be noted that default_sb_coded_flag may be a sequence-level or higher-level flag, or it may be a picture-level flag, a slice-level flag, a block-level flag, or a flag at other levels. Block-level flags include maximum coding unit (LCU) level flags, coding tree unit (CTU) level flags, coding unit (CU) level flags, or other block-level flags.

[0456] In addition, default_sb_coded_flag may depend on some other flags, such as high bit width flags or high bit rate flags. That is, when the value of the high bit width flag or the high bit rate flag is 1, the default_sb_coded_flag flag needs to be decoded; otherwise, the default_sb_coded_flag flag does not need to be decoded.

[0457] In a specific example, taking the sequence level as an example, assume there is a sequence-level flag `sps_high_bit_depth_flag` indicating whether the current image sequence is a high-bit-width sequence. If the value of `sps_high_bit_depth_flag` is 1, then it indicates that the current image sequence is a high-bit-width sequence; otherwise, it indicates that the current image sequence is not a high-bit-width sequence. At the sequence level, if the value of `sps_high_bit_depth_flag` is 1, then `sps_default_sb_coded_flag` needs to be decoded. Here, `sps_default_sb_coded_flag` is a flag indicating that the default sub-blocks of the current sequence need to be encoded. If the value of `sps_default_sb_coded_flag` is 1, then it indicates that the blocks in the current sequence have default sub-blocks that need to be encoded; otherwise (i.e., the value of `sps_default_sb_coded_flag` is 0), it indicates that the blocks in the current sequence do not have default sub-blocks that need to be encoded. The `default_sb_coded_flag` in the above syntax table is changed to `sps_default_sb_coded_flag`.

[0458] In the implementation, the syntax element table is modified as follows (Sequence parameter set RBSP syntax), see Table 14.

[0459] Table 14 … Descriptor sps_high_bit_depth_flag u(1) if( sps_high_bit_depth_flag ) sps_default_sb_coded_flag u(1) …

[0460] In another specific example, taking the slice level as an example, assume there is a sequence-level flag `sps_high_bit_depth_flag` indicating whether the current image sequence is a high-bit-width sequence. If the value of `sps_high_bit_depth_flag` is 1, it indicates that the current image sequence is a high-bit-width sequence; otherwise, it indicates that the current image sequence is not a high-bit-width sequence. At the slice level, if the value of `sps_high_bit_depth_flag` is 1, then `sh_default_sb_coded_flag` needs to be decoded. Here, `sh_default_sb_coded_flag` is a flag indicating that the default sub-blocks of the current slice need to be encoded. If the value of `sh_default_sb_coded_flag` is 1, it indicates that the default sub-blocks of the blocks within the current slice need to be encoded; otherwise (i.e., the value of `sh_default_sb_coded_flag` is 0), it indicates that the default sub-blocks of the blocks within the current slice do not need to be encoded. The `default_sb_coded_flag` in the above syntax table is changed to `sh_default_sb_coded_flag`.

[0461] In the implementation, the syntax element table is modified as follows (Slice header syntax), see Table 15.

[0462] Table 15 … Descriptor if( sps_high_bit_depth_flag ) sh_default_sb_coded_flag u(1) …

[0463] It should be noted that the sequence-level flag sps_high_bit_depth_flag indicates whether the current sequence is a high bit width sequence, and can also be replaced by sps_high_bit_rate_flag indicating whether the current sequence is a high bit rate sequence; it can even be replaced by other flags indicating high bit width, high bit rate, high quality or lossless encoding, etc., without any restrictions here.

[0464] In this embodiment of the application, regarding sh_default_sb_coded_flag, that is, the preset sub-blocks of the current slice need to be encoded identification information, it can also be reflected in the fact that each image component in the current slice can be individually controlled to use the preset sub-blocks need to be encoded.

[0465] Specifically, the preset sub-block of the current slice needs to be encoded with an identifier message, which can also be represented by sh_default_sb_coded_flag[cIdx], where cIdx takes the value of 0, 1, or 2. Specifically, when three component identifier messages are used to control three image components respectively, these three component identifier messages can include: sh_default_sb_coded_flag[0], sh_default_sb_coded_flag[1], and sh_default_sb_coded_flag[2]. Among them, sh_default_sb_coded_flag[0] is used to indicate whether the current block corresponding to the first image component of the current slice needs to be encoded using a preset sub-block; sh_default_sb_coded_flag[1] is used to indicate whether the current block corresponding to the second image component of the current slice needs to be encoded using a preset sub-block; sh_default_sb_coded_flag[2] is used to indicate whether the current block corresponding to the third image component of the current slice needs to be encoded using a preset sub-block.

[0466] Here, one or more component identification messages can also be used in this embodiment to control the use of different image components in this embodiment. For example, one component identification message can be used to control whether three image components use the method of this embodiment, such as one component identification message controlling whether three image components use the method of this embodiment. Alternatively, two component identification messages can be used to control whether three image components use the method of this embodiment, such as one component identification message controlling the luminance component and another component identification message controlling the two chrominance components. Alternatively, three component identification messages can be used to control whether each of the three image components uses the method of this embodiment, for example, the three image components can be R, G, B in RGB, or Y, U, V in YUV, or Y, Cb, Cr.

[0467] For example, taking the YUV format as an example, three component identification messages are used to control whether each of the three image components uses the method of the embodiment of this application. Wherein, if the value of sh_default_sb_coded_flag[0] is 1, then it is determined that the block corresponding to the first image component (e.g., the Y component) of the current slice needs to be encoded using a preset sub-block; if the value of sh_default_sb_coded_flag[1] is 1, then it is determined that the block corresponding to the second image component (e.g., the U component) of the current slice needs to be encoded using a preset sub-block; if the value of sh_default_sb_coded_flag[2] is 1, then it is determined that the block corresponding to the third image component (e.g., the V component) of the current slice needs to be encoded using a preset sub-block.

[0468] In short, for all image components in an image, besides using a unified identification message to control the use of the embodiments of this application, it is also possible to use different identification messages to individually control the use of each image component in the embodiments of this application, or to use two identification messages to control the use of all image components in the embodiments of this application. That is, more than one identification message can be used to control the use of different image components in the embodiments of this application. Here, all image components can refer to, for example, R, G, B in RGB format images, or Y, U, V (Y, Cb, Cr) in YUV format, etc.

[0469] This embodiment provides a decoding method applied to a decoder. By parsing the bitstream, the component identification message of the current slice is determined, as well as the coordinate message of the last non-zero coefficient of the current block corresponding to the component of the current slice. When the component identification message indicates that the component of the current slice uses the last non-zero coefficient position flip, the coordinate message of the last non-zero coefficient is calculated to obtain the position of the last non-zero coefficient of the current block. All coefficients before the position of the last non-zero coefficient are decoded according to a preset scanning order to determine the coefficients of the current block. In this way, in high bit width, high bit rate, high quality or lossless image encoding and decoding scenarios, setting a reasonable output method of the last non-zero coefficient according to the distribution law of non-zero coefficients can reduce the overhead caused by encoding in the bitstream and improve compression efficiency. In addition, since the distribution law of non-zero coefficients of each image component is different, the output method of the last non-zero coefficient of each image component can be controlled more finely, that is, whether each image component uses the last non-zero coefficient position flip technology, thereby further improving compression efficiency.

[0470] In another embodiment of this application, referring to FIG11, a flowchart of an encoding method provided by an embodiment of this application is shown. As shown in FIG11, the method may include:

[0471] S1101: Determine the position flip flag message of the last non-zero coefficient of the current slice, and determine the position of the last non-zero coefficient of the current block corresponding to the current block in the current slice.

[0472] S1102: Determine the coordinate information of the last non-zero coefficient of the current block based on the flip flag message of the last non-zero coefficient position and the position of the last non-zero coefficient.

[0473] S1103: Encode all coefficients before the position of the last non-zero coefficient according to the preset scanning order, and write the encoded bit information, the last non-zero coefficient position flip flag information, and the coordinate information of the last non-zero coefficient into the bit stream.

[0474] It should be noted that the encoding method in this application embodiment specifically refers to a coefficient encoding method, which is applied to an encoder. Based on the composition structure of the encoder 100 shown in FIG8A, the encoding method is mainly applied to the "entropy encoding unit 115" part in the encoder 100. For the entropy encoding unit 115, an adaptive binary arithmetic encoding mode or a bypass mode based on the context model can be used to entropy encode the relevant identification information (or syntax elements) and then write it into the bitstream.

[0475] It should also be noted that the encoding commonly referred to in image standards can include both encoding and decoding. Therefore, image encoding includes the encoding method on the encoder side and the decoding method on the decoder side. The embodiments of this application describe the encoding method on the encoder side.

[0476] Normally, for example, for conventional images, the encoding method for coefficients is the same as the existing methods in related technologies; however, for certain situations, such as high bit width, high quality, high bit rate, or lossless compression image encoding and decoding, the embodiments of this application provide an output method that can modify the position of the last non-zero coefficient. In this case, the embodiments of this application need to introduce component identification information in order to determine whether the components of the current slice are flipped using the position of the last non-zero coefficient.

[0477] In this embodiment of the application, the component identification message is a slice-level flag. This component identification message is used to indicate whether the component of the current slice is flipped using the last non-zero coefficient position. Wherein, if the component of the current slice is flipped using the last non-zero coefficient position, it means that the current block corresponding to the component of the current slice is flipped using the last non-zero coefficient position; if the component of the current slice is not flipped using the last non-zero coefficient position, it means that the current block corresponding to the component of the current slice is also not flipped using the last non-zero coefficient position.

[0478] Understandably, the current sequence includes the current slice, and the current slice may include the current block. In some embodiments, before determining the component identification information of the current slice, the method may further include:

[0479] Determine the first syntax element identifier message;

[0480] When the first syntax element identification message indicates that the current sequence is allowed to be flipped using the last non-zero coefficient position, the step of determining the component identification message of the current slice is performed.

[0481] In this embodiment of the application, determining the first syntax element identification message may include: if the current sequence allows flipping using the last non-zero coefficient position, then determining the value of the first syntax element identification message to be a first value; or, if the current sequence does not allow flipping using the last non-zero coefficient position, then determining the value of the first syntax element identification message to be a second value.

[0482] Further, the method may also include: writing the first syntax element identification message into the code stream.

[0483] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numerical form. Specifically, the first syntax element identification message can be a parameter written in the profile or a value of a flag, and this application embodiment does not limit it in any way.

[0484] Taking the first syntax element identifying the message as a flag as an example, for the first and second values, the first value can be set to 1 and the second value can be set to 0; or, the first value can also be set to true and the second value can also be set to false; or, the first value can also be set to 0 and the second value can also be set to 1; or, the first value can also be set to false and the second value can also be set to true. For example, for a flag, generally, the first value can be 1 and the second value can be 0, but there are no restrictions.

[0485] It should also be noted that the first syntax element identifier message is a sequence-level flag, represented by `sps_reverse_last_sig_coeff_flag`, which can be used to indicate whether the current sequence is allowed to use the last non-zero coefficient position for flipping. Thus, when it is determined that the current sequence is allowed to use the last non-zero coefficient position for flipping, the slice-level component identifier message can be further determined in order to determine whether the components of the current slice use the last non-zero coefficient position for flipping.

[0486] Further, before decoding to obtain the first syntax element identification message, in one possible embodiment, the method may further include:

[0487] Analyze the code stream to determine the second syntax element identifier message;

[0488] When the second syntax element identification message indicates that the current sequence uses the standard extended version, the step of parsing the code stream and determining the first syntax element identification message is performed.

[0489] Before decoding to obtain the first syntax element identification message, in another possible embodiment, the method may further include:

[0490] Analyze the code stream to determine the third syntax element identifier message;

[0491] When the third syntax element identification message indicates that the current sequence uses an expanded range, the step of parsing the code stream and determining the first syntax element identification message is performed.

[0492] In another possible embodiment, before decoding to obtain the first syntax element identifier message, the method may further include:

[0493] Analyze the code stream to determine the second syntax element identifier message;

[0494] When the second syntax element identification message indicates that the current sequence uses the standard extended version, parse the code stream and determine the third syntax element identification message;

[0495] When the third syntax element identification message indicates that the current sequence uses an expanded range, the step of parsing the code stream and determining the first syntax element identification message is performed.

[0496] It should be noted that both the second and third syntax element identification messages are sequence-level flags. The second syntax element identification message is represented by sps_extension_flag, which can be used to indicate whether the current sequence uses the standard extended version; the third syntax element identification message is represented by sps_range_extension_flag, which can be used to indicate whether the current sequence uses range extension.

[0497] That is to say, after decoding, the first syntax element identifier message (sps_reverse_last_sig) is obtained. Before obtaining `sps_extension_flag`, the code can be executed after parsing the bitstream to obtain `sps_extension_flag`. If `sps_extension_flag` indicates that the current sequence uses the standard extended version, then `sps_reverse_last_sig_coeff_flag` is decoded. Alternatively, it can be executed after obtaining `sps_range_extension_flag` from the bitstream. If `sps_range_extension_flag` indicates that the current sequence uses range extension, then `sps_reverse_last_sig_coeff_flag` is decoded. Or, it can even be executed after obtaining `sps_extension_flag` from the bitstream. If `sps_extension_flag` indicates that the current sequence uses the standard extended version, then `sps_range_extension_flag` is parsed; if `sps_range_extension_flag` indicates that the current sequence uses range extension, then `sps_reverse_last_sig_coeff_flag` is decoded. However, this embodiment does not impose any limitations.

[0498] In this embodiment of the application, determining the second syntax element identification message may include: if the current sequence uses the standard extended version, then determining the value of the second syntax element identification message to be a first value; or, if the current sequence does not use the standard extended version, then determining the value of the second syntax element identification message to be a second value.

[0499] Further, the method may also include: writing the second syntax element identification message into the code stream.

[0500] In this embodiment of the application, determining the third syntax element identification message may include: if the current sequence uses range expansion, then determining the value of the third syntax element identification message to be a first value; or, if the current sequence does not use range expansion, then determining the value of the third syntax element identification message to be a second value.

[0501] Further, the method may also include: writing the third syntax element identification message into the code stream.

[0502] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numeric form. In a specific example, the first value can be set to 1 and the second value can be set to 0, but there are no restrictions.

[0503] It should also be noted that the second syntax element identification message is represented by `sps_extension_flag`, and the third syntax element identification message is represented by `sps_range_extension_flag`. Thus, at the sequence level, if the value of `sps_extension_flag` is 1, meaning the current sequence uses the standard extended version, then `sps_range_extension_flag` needs to be determined; if the value of `sps_range_extension_flag` is 1, meaning the current sequence uses range extension, then `sps_reverse_last_sig_coeff_flag` needs to be determined; if the value of `sps_reverse_last_sig_coeff_flag` is 1, meaning the current sequence allows flipping using the last non-zero coefficient position, then it is necessary to further determine the slice-level component identification message in order to determine whether the components of the current slice use flipping using the last non-zero coefficient position.

[0504] In some embodiments, the scope of the current sequence is extended, which may include: the current sequence satisfying at least one of the following: high bit width, high quality, high bit rate, high frame rate, and lossless compression. The following will describe four cases as examples.

[0505] In one possible implementation, when the third syntax element identification message is a high-width identification message, the method may further include: if the high-width identification message indicates that the current sequence satisfies the high-width, then determine that the current sequence uses an extended range.

[0506] In another possible implementation, when the third syntax element identification message is a high bit rate identification message, the method may further include: if the high bit rate identification message indicates that the current sequence meets the high bit rate, then determine that the current sequence usage range is extended.

[0507] In another possible implementation, when the third syntax element identification message is a high quality identification message, the method may further include: if the high quality identification message indicates that the current sequence meets the high quality, then determine that the scope of use of the current sequence is extended.

[0508] In another possible implementation, when the third syntax element identification message is a lossless compression identification message, the method may further include: if the lossless compression identification message indicates that the current sequence satisfies lossless compression, then determine that the current sequence usage range is extended.

[0509] For example, taking the sequence level as an example, the third syntax element identification message can also be a high bit width identification message (represented by sps_high_bit_depth_flag), used to indicate whether the current sequence is a high bit width sequence; or it can be replaced by a high bit rate identification message (represented by sps_high_bit_rate_flag), used to indicate whether the current sequence is a high bit rate sequence; or it can be replaced by other identification messages that indicate high bit width, high bit rate, high quality or lossless compression. The embodiments of this application do not make specific limitations.

[0510] In the embodiments of this application, the first syntax element identification message, the second syntax element identification message and the third syntax element identification message can be sequence-level flags, or even higher-level flags, such as video usability information (VUI) and supplemental enhancement information (SEI).

[0511] Further, the last non-zero coefficient position flip flag message can be represented by reverse_last_sig_coeff_flag. The last non-zero coefficient position flip flag message can be at least one of the following flag messages: sequence level, picture level, slice level, and block level; it can even be a higher level flag message (such as VUI, SEI, etc.), without any limitation here.

[0512] That is to say, reverse_last_sig_coeff_flag may be a sequence-level or higher-level flag, or it may be an image-level flag, a slice-level flag, a block-level flag, or a flag of other levels. In addition, block-level flags may include maximum coding unit (LCU) level flags, coding tree unit (CTU) level flags, coding unit (CU) level flags, or other block-level flags. The embodiments of this application do not impose any limitations.

[0513] In this embodiment of the application, the last non-zero coefficient position flip flag message at the sequence level can be represented by sps_reverse_last_sig_coeff_flag, and the last non-zero coefficient position flip flag message at the slice level can be represented by sh_reverse_last_sig_coeff_flag.

[0514] It should also be noted that the last non-zero coefficient position flipping identifier message at the slice level can also be referred to as the component identifier message of the current slice. In some embodiments, determining the component identifier message of the current slice may include:

[0515] If the component of the current slice is flipped using the last non-zero coefficient position, then the component identifier message is determined to be the first value; or,

[0516] If the component of the current slice does not use the last non-zero coefficient position to flip, then the component identifier message is determined to be the second value.

[0517] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numeric form. In a specific example, the first value can be set to 1 and the second value can be set to 0, but there are no restrictions.

[0518] Taking the first value as 1 and the second value as 0 as an example, if the component of the current slice is flipped using the last non-zero coefficient position, that is, the current block corresponding to the component of the current slice is flipped using the last non-zero coefficient position, then it can be determined that the component identification message is 1; if the component of the current slice is not flipped using the last non-zero coefficient position, that is, the current block corresponding to the component of the current slice is not flipped using the last non-zero coefficient position, then it can be determined that the component identification message is 0.

[0519] Further, for the current block corresponding to the component of the current slice, the position of the last non-zero coefficient may include the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient. When the initial horizontal coordinate and the initial vertical coordinate are the horizontal distance and the vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block, the step of determining the coordinate information of the last non-zero coefficient of the current block based on the component identification information and the position of the last non-zero coefficient may include:

[0520] If the component identifier message takes the first value, then the coordinate message of the last non-zero coefficient is determined by calculating based on the initial horizontal and initial vertical coordinates of the last non-zero coefficient; or,

[0521] If the value of the component identification message is the second value, then the coordinate message of the last non-zero coefficient is directly determined based on the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient.

[0522] In other words, in some embodiments, the method may further include:

[0523] If the component identifier message takes the first value, then the coordinate message of the last non-zero coefficient is determined as the horizontal and vertical distances between the position of the last non-zero coefficient and the lower right corner of the current block; or,

[0524] If the value of the component identifier message is the second value, then the coordinate message of the last non-zero coefficient is the horizontal and vertical distance between the position of the last non-zero coefficient and the position of the upper left corner of the current block.

[0525] In other words, the coordinate information of the last non-zero coefficient is usually the horizontal and vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block. For regular images, since most non-zero coefficients are concentrated in the upper left corner, while a large area in the lower right corner is 0; however, for high bit width, high quality, and high bit rate image encoding and decoding, a large number of non-zero coefficients will also appear in the lower right corner, making the value of the coordinate information of the last non-zero coefficient usually large. In this case, in order to save costs, coordinate transformation is required during coefficient encoding (specifically, coordinate flipping calculation, that is, after coordinate flipping, the coordinate information of the last non-zero coefficient is the horizontal and vertical distance between the position of the last non-zero coefficient and the lower right corner of the current block). Then, in the decoder, coordinate flipping calculation is also required during coefficient decoding. After flipping again, the coordinate information of the last non-zero coefficient can be recovered as the horizontal and vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block, thereby determining the position of the last non-zero coefficient.

[0526] Further, in some embodiments, the step of calculating and determining the coordinate information of the last non-zero coefficient based on the initial horizontal and initial vertical coordinates of the last non-zero coefficient may include:

[0527] Determine the width and height of the current block;

[0528] The horizontal coordinate of the last non-zero coefficient is obtained by subtracting the width of the current block from the initial horizontal coordinate of the last non-zero coefficient; and

[0529] Calculate the vertical coordinate of the last non-zero coefficient by subtracting the height of the current block from the initial vertical coordinate of the last non-zero coefficient;

[0530] Determine the coordinate information of the last non-zero coefficient based on the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.

[0531] It should be noted that the current block corresponding to the component of the current slice can be a block without zero-out transformation or a block after zero-out transformation. Taking a block after zero-out transformation as an example, the width of the current block is 1 << log2ZoTbWidth, and the height of the current block is 1 << log2ZoTbHeight; then, if the component identification message indicates that the last non-zero coefficient position is used for flipping,

[0532] LastSignificantCoeffX= (1<<log2ZoTbWidth)-1-LastSignificantCoeffX;

[0533] LastSignificantCoeffY= (1<<log2ZoTbHeight)-1-LastSignificantCoeffY.

[0534] Where, (LastSignificantCoeffX, LastSignificantCoeffY) on the right side of the equation represents the coordinate information of the last non-zero coefficient that is directly determined (i.e., the initial horizontal and initial vertical coordinates of the last non-zero coefficient), and (LastSignificantCoeffX, LastSignificantCoeffY) on the left side of the equation represents the coordinate information of the last non-zero coefficient obtained after coordinate flipping (i.e., the coordinate information of the last non-zero coefficient written to the bitstream when the position of the last non-zero coefficient is flipped in the current block).

[0535] In some embodiments, writing the coordinate information of the last non-zero coefficient into the code stream may include:

[0536] Based on the coordinate information of the last non-zero coefficient, determine the first code information of the horizontal coordinate of the last non-zero coefficient, the first code information of the vertical coordinate of the last non-zero coefficient, the last code information of the horizontal coordinate of the last non-zero coefficient, and the last code information of the vertical coordinate of the last non-zero coefficient of the current block.

[0537] Write the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient into the code stream.

[0538] It should be noted that the first code message of the horizontal coordinate of the last non-zero coefficient is represented by last_sig_coeff_x_prefix, the first code message of the vertical coordinate of the last non-zero coefficient is represented by last_sig_coeff_y_prefix, the last code message of the horizontal coordinate of the last non-zero coefficient is represented by last_sig_coeff_x_suffix, and the last code message of the vertical coordinate of the last non-zero coefficient is represented by last_sig_coeff_y_suffix; then last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix are written into the bitstream so that the decoder can determine the coordinate message of the last non-zero coefficient by parsing the bitstream.

[0539] In the embodiments of this application, the preset scanning order can be diagonal, zigzag, horizontal, vertical, 4×4 sub-block scanning or any other scanning order, without any limitation.

[0540] Thus, this application embodiment provides a method for modifying the output position of the last non-zero coefficient. That is, under normal circumstances, the encoding and decoding method of the coefficients is still the same as the existing methods of related technologies. In some cases, this may refer to the encoding and decoding of high-bit-width, high-quality, or high-bit-rate images or lossless compressed images. Under normal circumstances, last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the horizontal coordinate of the position of the last non-zero coefficient, that is, the horizontal distance relative to the upper left corner of the current block; last_sig_coeff_y_prefix and last_sig_coeff_y_suffix encode the vertical coordinate of the position of the last non-zero coefficient, that is, the vertical distance relative to the upper left corner of the current block, as shown in Figure 10A. However, in the case of encoding and decoding of high-bit-width, high-quality, or high-bit-rate images or lossless compressed images, the position of the last non-zero coefficient is generally close to the lower right corner of all regions of the current block that may have non-zero coefficients. In this case, last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the horizontal distance of the last non-zero coefficient position relative to the bottom right corner of all regions in the current block that may have non-zero coefficients; last_sig_coeff_y_prefix and last_sig_coeff_y_suffix encode the vertical distance of the last non-zero coefficient position relative to the bottom right corner of all regions in the current block that may have non-zero coefficients, as shown in Figure 10B. Therefore, this embodiment of the application can solve the problem of greater overhead caused by encoding larger values ​​in the bitstream by introducing reverse_last_sig_coeff_flag.

[0541] Furthermore, for the slice-level reverse_last_sig_coeff_flag (i.e., the component identification message of the current slice, sh_reverse_last_sig_coeff_flag), it can be reflected that each image component in the current slice can be individually controlled to flip using the last non-zero coefficient position.

[0542] In this embodiment of the application, the components may include a first image component, a second image component and a third image component.

[0543] In a specific example, the first image component is a luminance component, the second image component is a first chromaticity component, and the third image component is a second chromaticity component. The luminance component is represented by the Y component, the first chromaticity component by the U (Cb) component, and the second chromaticity component by the V (Cr) component.

[0544] In another specific example, the first image component is the red component, the second image component is the green component, and the third image component is the blue component. The red component is represented by the R component, the green component by the G component, and the blue component by the B component.

[0545] Further, in some embodiments, when the components include a first image component, a second image component, and a third image component, the method may further include:

[0546] Based on the attribute relationship between the first image component, the second image component and the third image component, determine whether there is a shared component identification message among the first image component, the second image component and the third image component in the current chip;

[0547] Based on the judgment result, determine the number of component identification messages of the current slice; wherein the number of component identification messages is 1, 2 or 3.

[0548] Specifically, determining the number of component identification messages may include:

[0549] If the first image component, the second image component, and the third image component of the current slice all share a single component identifier message, then the number of component identifier messages in the current slice is determined to be 1; or,

[0550] If two of the first, second, and third image components of the current slice share a single component identifier message, then the number of component identifier messages for the current slice is determined to be 2; or,

[0551] If the first image component, the second image component, and the third image component of the current slice each use a component identification message, then the number of component identification messages of the current slice is determined to be 3.

[0552] In this embodiment, due to the different properties of each image component and the use of some cross-component techniques, the residual distribution patterns of each image component are not always consistent. For example, in high-bitrate, high-quality image encoding and decoding, the distribution of non-zero coefficients of different components is similar; for example, the non-zero coefficients are all close to the lower right corner of the region where they might be non-zero coefficients. However, in some low-bitrate, low-quality image encoding and decoding, the distribution of non-zero coefficients of different components may be different. For example, the non-zero coefficients of the Y component are all close to the lower right corner of the region where they might be non-zero coefficients, while the non-zero coefficients of the U / V components are only distributed in the upper left corner; or the non-zero coefficients of the U component are also close to the lower right corner, while the non-zero coefficients of the V component are only distributed in the upper left corner.

[0553] Therefore, embodiments of this application can use one or more component identification messages to control the use of different image components in embodiments of this application. For example, one component identification message can be used to control whether three image components use the method of embodiments of this application, such as one component identification message controlling whether three image components use the method of embodiments of this application. Alternatively, two component identification messages can be used to control whether three image components use the method of embodiments of this application, such as one component identification message controlling the luminance component and another component identification message controlling the two chrominance components. Alternatively, three component identification messages can be used to control whether each of the three image components uses the method of embodiments of this application, for example, the three image components can be R, G, B in RGB, or Y, U, V in YUV, or Y, Cb, Cr.

[0554] In one possible implementation, when the number of component identification messages is 1, determining the component identification message of the current slice may include: determining the first component identification message of the current slice;

[0555] Accordingly, the method may further include: if the value of the first component identification message is a first value, then it is determined that the first image component, the second image component, and the third image component of the current slice are all flipped using the last non-zero coefficient position; or, if the value of the first component identification message is a second value, then it is determined that the first image component, the second image component, and the third image component of the current slice are not flipped using the last non-zero coefficient position.

[0556] In another possible implementation, when the number of component identification messages is 2, determining the component identification messages of the current slice may include: determining the second component identification message and the third component identification message of the current slice;

[0557] Accordingly, the method may further include: if the value of the second component identification message is a first value, then determining that two image components of the current slice are flipped using the last non-zero coefficient position; or, if the value of the second component identification message is a second value, determining that two image components of the current slice are not flipped using the last non-zero coefficient position; and

[0558] If the value of the third component identification message is the first value, then it is determined that the remaining image components of the current slice, excluding two of them, are flipped using the last non-zero coefficient position; or, if the value of the third component identification message is the second value, then it is determined that the remaining image components of the current slice, excluding two of them, are not flipped using the last non-zero coefficient position.

[0559] In another possible implementation, when the number of component identification messages is 3, determining the component identification messages of the current slice may include: determining the fourth component identification message, the fifth component identification message and the sixth component identification message of the current slice.

[0560] Accordingly, the method may further include: if the value of the fourth component identification message is a first value, then determining that the first image component of the current slice is flipped using the last non-zero coefficient position; or, if the value of the fourth component identification message is a second value, then determining that the first image component of the current slice is not flipped using the last non-zero coefficient position; and

[0561] If the value of the fifth component identifier message is the first value, then it is determined that the second image component of the current slice is flipped using the last non-zero coefficient position; or, if the value of the fifth component identifier message is the second value, then it is determined that the second image component of the current slice is not flipped using the last non-zero coefficient position; and

[0562] If the value of the sixth component identification message is the first value, then it is determined that the third image component of the current slice is flipped using the last non-zero coefficient position; or, if the value of the sixth component identification message is the second value, then it is determined that the third image component of the current slice is not flipped using the last non-zero coefficient position.

[0563] It should be noted that the first value and the second value are different, and the first value and the second value can be in parameter form or in numeric form. In a specific example, the first value can be set to 1 and the second value can be set to 0, but there are no restrictions.

[0564] It should also be noted that the component identification message here is a slice-level flag, which can be represented by sh_reverse_last_sig_coeff_flag[cIdx], where the value of cIdx is 0, 1, or 2. Specifically, when using 3 component identification messages to control 3 image components respectively, these 3 component identification messages can include: sh_reverse_last_sig_coeff_flag[0], sh_reverse_last_sig_coeff_flag[1], and sh_reverse_last_sig_coeff_flag[2]. The fourth component identifier message is represented by sh_reverse_last_sig_coeff_flag[0], which is used to indicate whether the current block corresponding to the first image component of the current slice is flipped using the last non-zero coefficient position; the fifth component identifier message is represented by sh_reverse_last_sig_coeff_flag[1], which is used to indicate whether the current block corresponding to the second image component of the current slice is flipped using the last non-zero coefficient position; the sixth component identifier message is represented by sh_reverse_last_sig_coeff_flag[2], which is used to indicate whether the current block corresponding to the third image component of the current slice is flipped using the last non-zero coefficient position.

[0565] For example, taking the YUV format as an example, three component identification messages are used to control whether each of the three image components uses the method of the embodiment of this application. Wherein, if the value of sh_reverse_last_sig_coeff_flag[0] is 1, then it is determined that the block corresponding to the first image component (e.g., the Y component) of the current slice is flipped using the last non-zero coefficient position; if the value of sh_reverse_last_sig_coeff_flag[1] is 1, then it is determined that the block corresponding to the second image component (e.g., the U component) of the current slice is flipped using the last non-zero coefficient position; if the value of sh_reverse_last_sig_coeff_flag[2] is 1, then it is determined that the block corresponding to the third image component (e.g., the V component) of the current slice is flipped using the last non-zero coefficient position.

[0566] It can also be understood that when the third syntax element identification message indicates that the current sequence uses an expanded range, it is also possible to preset that all coefficients that may need to be encoded need to be encoded. That is, the position of the last non-zero coefficient is no longer used, but all possible non-zero coefficients of the current block are scanned according to the preset scanning order. Therefore, the embodiments of this application can also introduce the last coefficient enable flag message to determine whether the current block uses the last coefficient position.

[0567] In some embodiments, when the third syntax element identification message indicates that the current sequence usage scope has been expanded, the method may further include:

[0568] Determine the last coefficient enable flag message for the current block;

[0569] When the last coefficient enable flag message indicates that the current block uses the last coefficient position, all coefficients before the last coefficient position are encoded according to the preset scanning order, and the encoded bit information, image flag message and last coefficient enable flag message are written into the bit stream.

[0570] It should be noted that the last coefficient enable flag message can be represented by default_last_coeff_enabled_flag. In the embodiments of this application, the last coefficient enable flag message can be at least one of the following flag messages: sequence level, image level, slice level, and block level; it can even be a higher level flag message (such as VUI, SEI, etc.), without any limitation here.

[0571] It should also be noted that, for the last coefficient enable flag message, in some embodiments, determining the last coefficient enable flag message of the current block may include:

[0572] If the current block uses the position of the last coefficient, then the value of the last coefficient enable flag message is determined to be the first value; or,

[0573] If the current block does not use the last coefficient position, then the value of the last coefficient enable flag message is determined to be the second value.

[0574] That is to say, taking the first value as 1 and the second value as 0 as an example, if it is determined that the current block uses the last coefficient position, then the value of default_last_coeff_enabled_flag is 1; or, if it is determined that the current block does not use the last coefficient position, then the value of default_last_coeff_enabled_flag is 0.

[0575] Further, for the last coefficient position, in some embodiments, the last coefficient position is the lower right corner of the matrix composed of all possible non-zero coefficients in the current block; or, the last coefficient position is the last position of the current block after scanning all possible non-zero coefficients according to a preset scanning sequence.

[0576] It should be noted that the position of the last coefficient in the embodiments of this application does not represent the position of the last non-zero coefficient. This is because the coefficient at the last coefficient position may be 0, while the coefficient at the last non-zero coefficient position is definitely not 0.

[0577] In a particular example, the method may further include setting the position of the last non-zero coefficient at the last coefficient position.

[0578] That is to say, the position of the last non-zero coefficient can still be used in the embodiments of this application. In this case, the position of the last non-zero coefficient needs to be placed at the last position of all possible non-zero coefficients in the current block according to the preset scanning order.

[0579] Further, the position of the last coefficient can be represented by (LastCoeffX, LastCoeffY), that is, the last position of all coefficients that may be non-zero in the current block according to a preset scan order. In some embodiments, the method may further include:

[0580] Determine the width and height of the transformed block obtained by the current block after a preset operation;

[0581] Calculate the coordinates based on the width and height of the transformation block to obtain the coordinate information of the lower right corner of the transformation block;

[0582] Determine the position of the last coefficient based on the coordinate information of the lower right corner of the transformation block.

[0583] Here, the default operation includes at least: forced zero-out operation.

[0584] It should be noted that (LastCoeffX, LastCoeffY) represents the coordinate information of the lower right corner of the transform block after zero-out; the export method of (LastCoeffX, LastCoeffY) is as follows:

[0585] LastCoeffX= (1<<log2ZoTbWidth)-1;

[0586] LastCoeffY= (1<<log2ZoTbHeight)-1.

[0587] In this way, if the value of default_last_coeff_enabled_flag is 1, then the position of the last coefficient can be determined according to (LastCoeffX, LastCoeffY).

[0588] In a particular example, the position of the last non-zero coefficient is still used. In this case, the position of the last non-zero coefficient can be placed at the end of all coefficients that may be 0 in the current block according to a preset scan order. In some embodiments, the method may further include:

[0589] When the position of the last non-zero coefficient is set at the last coefficient position, the position of the last non-zero coefficient is determined according to the coordinate information of the lower right corner of the transformation block.

[0590] That is to say, the position of the last non-zero coefficient can be represented by (LastSignificantCoeffX, LastSignificantCoeffY), and the export method of (LastSignificantCoeffX, LastSignificantCoeffY) is as follows:

[0591] LastSignificantCoeffX= (1<<log2ZoTbWidth)-1;

[0592] LastSignificantCoeffY= (1<<log2ZoTbHeight)-1.

[0593] Where (LastSignificantCoeffX, LastSignificantCoeffY) represents the coordinate information of the lower right corner of the transform block after zero-out. If the value of default_last_coeff_enabled_flag is 1, then the position of the last non-zero coefficient can be determined according to (LastSignificantCoeffX, LastSignificantCoeffY).

[0594] Further, in cases where the last coefficient enable flag message indicates that the current block does not use the last coefficient position, i.e., the value of the last coefficient enable flag message is 0, in some embodiments, the method may further include:

[0595] Determine the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient in the current block.

[0596] The position of the last non-zero coefficient is determined based on the first code information of the horizontal coordinate of the last non-zero coefficient, the first code information of the vertical coordinate of the last non-zero coefficient, the last code information of the horizontal coordinate of the last non-zero coefficient, and the last code information of the vertical coordinate of the last non-zero coefficient.

[0597] Encode all coefficients before the position of the last non-zero coefficient according to the preset scanning order, and write the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient into the code stream.

[0598] It should be noted that if the current block does not use the position of the last coefficient, then the position of the last non-zero coefficient needs to be determined. Specifically, it is necessary to determine last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix; and then write last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix into the bitstream.

[0599] Thus, during coefficient encoding, it is assumed that all coefficients that may need to be encoded need to be encoded. That is, under normal circumstances, the coefficient encoding / decoding method is the same as existing methods in related technologies. In certain cases, such as encoding / decoding high-bit-width, high-quality, or high-bit-rate images or lossless compressed images, it is assumed that all coefficients that may need to be encoded need to be encoded. That is, the position of the last non-zero coefficient is no longer used; instead, all possible non-zero coefficients in the current block are scanned according to a preset scanning order. Alternatively, the position of the last coefficient to be encoded is placed at the end of all possible non-zero coefficients in the current block according to the preset scanning order. This position usually refers to the lower right corner of the matrix formed by all possible non-zero coefficients in the current block. Therefore, this application embodiment can reduce or even eliminate the syntax elements related to the position of the last non-zero coefficient by introducing the default_last_coeff_enabled_flag, thus saving overhead and avoiding waste.

[0600] Furthermore, regarding sh_default_last_coeff_enabled_flag, which is the default last coefficient enable flag for the current slice, it can also be reflected that each image component in the current slice can be individually controlled to control whether to use the default last coefficient.

[0601] Specifically, the default last coefficient enable flag message of the current slice can also be represented by sh_default_last_coeff_enabled_flag[cIdx], where cIdx takes the value of 0, 1, or 2. Specifically, when using 3 component flag messages to control 3 image components respectively, these 3 component flag messages can include: sh_default_last_coeff_enabled_flag[0], sh_default_last_coeff_enabled_flag[1], and sh_default_last_coeff_enabled_flag[2]. Among them, sh_default_last_coeff_enabled_flag[0] is used to indicate whether the current block corresponding to the first image component of the current slice uses the default last coefficient; sh_default_last_coeff_enabled_flag[1] is used to indicate whether the current block corresponding to the second image component of the current slice uses the default last coefficient; sh_default_last_coeff_enabled_flag[2] is used to indicate whether the current block corresponding to the third image component of the current slice uses the default last coefficient.

[0602] Here, one or more component identification messages can also be used in this application embodiment to control the use of different image components in this application embodiment. For example, one component identification message can be used to control whether three image components use the method of this application embodiment; or two component identification messages can be used to control whether three image components use the method of this application embodiment; or three component identification messages can be used to control whether each of the three image components uses the method of this application embodiment.

[0603] For example, taking the YUV format as an example, three component identification messages are used to control whether each of the three image components uses the method of the embodiment of this application. Wherein, if the value of sh_default_last_coeff_enabled_flag[0] is 1, then it is determined that the block corresponding to the first image component (e.g., the Y component) of the current slice uses the default last coefficient; if the value of sh_default_last_coeff_enabled_flag[1] is 1, then it is determined that the block corresponding to the second image component (e.g., the U component) of the current slice uses the default last coefficient; if the value of sh_default_last_coeff_enabled_flag[2] is 1, then it is determined that the block corresponding to the third image component (e.g., the V component) of the current slice uses the default last coefficient.

[0604] It can also be understood that when the third syntax element identifier message indicates that the current sequence uses an expanded range, all sub-blocks that can be scanned are pre-encoded. In this case, it is not necessary to transmit sb_coded_flag in the bitstream, that is, neither the encoder nor the decoder needs to process this flag, so as to speed up the encoding and decoding speed. Therefore, embodiments of this application can also introduce a sub-block pre-encoding identifier message to determine whether the sub-block to be decoded in the current block is pre-encoded.

[0605] In some embodiments, when the third syntax element identification message indicates that the current sequence usage scope has been expanded, the method may further include:

[0606] Determine the preset encoding identifier information of the sub-block to be encoded within the current block;

[0607] When the sub-block preset encoding identifier message indicates that the sub-block to be encoded has a preset encoding, all coefficients in the sub-block to be encoded are encoded, and the bit information obtained after encoding and the sub-block preset encoding identifier message are written into the code stream.

[0608] It should be noted that the sub-block preset identification message can be represented by default_sb_coded_flag. In the embodiments of this application, the sub-block preset coding identification message is at least one of the following identification messages: sequence level, image level, slice level, and block level; it can even be a higher level (such as VUI, SEI, etc.) identification message, which is not limited here.

[0609] It should also be noted that, for the sub-block preset identification message, in some embodiments, determining the sub-block preset encoding identification message of the sub-block to be encoded may include: if the sub-block to be encoded has a preset encoding, then determining the value of the sub-block preset encoding identification message to be a first value; or, if the sub-block to be encoded does not have a preset encoding, then determining the value of the sub-block preset encoding identification message to be a second value.

[0610] In this way, taking the first value as 1 and the second value as 0 as an example, if it is determined that the sub-block to be encoded needs to be encoded by default, then the value of default_sb_coded_flag is 1; or, if it is determined that the sub-block to be encoded does not need to be encoded by default, then the value of default_sb_coded_flag is 0.

[0611] When the sub-block to be encoded is preset to require encoding, the value of default_sb_coded_flag is 1, meaning that the value of sb_coded_flag is 1, i.e., sb_coded_flag no longer needs to be encoded. However, when the sub-block to be encoded is not preset to require encoding, i.e., when the sub-block preset encoding flag message indicates that the sub-block to be encoded is not preset to be encoded, in some embodiments, the method may further include: determining the sub-block encoding flag message of the sub-block to be encoded, and writing the sub-block encoding flag message into the bitstream.

[0612] Further, in some embodiments, determining the sub-block encoding identifier message of the sub-block to be encoded may include: if encoding is required in the sub-block, then determining the value of the sub-block encoding identifier message to be a first value; or, if all coefficients in the sub-block are zero, then determining the value of the sub-block encoding identifier message to be a second value.

[0613] In this embodiment of the application, the sub-block encoding identifier message can be represented by sb_coded_flag. Taking a first value of 1 and a second value of 0 as an example, if it is determined that the sub-block to be encoded needs to be encoded, it means that the sub-block to be encoded contains non-zero coefficients to be encoded, then the value of sb_coded_flag is 1; or, if it is determined that the sub-block to be encoded does not need to be encoded, it means that all coefficients in the sub-block to be encoded are zero, then the value of sb_coded_flag is 0.

[0614] Thus, during coefficient encoding, all scanned sub-blocks are pre-programmed to require encoding, or in other words, all scanned sub-blocks contain non-zero coefficients by default. That is to say, under normal circumstances, the coefficient encoding method is the same as existing methods in related technologies. In certain cases, such as encoding and decoding high-bit-width, high-quality, or high-bit-rate images or lossless compressed images, there are many non-zero coefficients, and almost all scanned sub-blocks require encoding; or in other words, almost all scanned sub-blocks contain non-zero coefficients. This eliminates the need to transmit the `sb_coded_flag` in the bitstream, and the encoder does not need to process this flag, thereby speeding up encoding and decoding. Removing a flag that is almost non-existent also brings a slight improvement in compression performance.

[0615] Furthermore, regarding sh_default_sb_coded_flag, which is the preset sub-block encoding identifier message of the current slice, it can also be reflected in the fact that each image component in the current slice can be individually controlled to use the preset sub-block encoding.

[0616] Specifically, the preset sub-block of the current slice needs to be encoded with an identifier message, which can also be represented by sh_default_sb_coded_flag[cIdx], where cIdx takes the value of 0, 1, or 2. Specifically, when using three component identifier messages to control three image components respectively, these three component identifier messages can include: sh_default_sb_coded_flag[0], sh_default_sb_coded_flag[1], and sh_default_sb_coded_flag[2]. Among them, sh_default_sb_coded_flag[0] is used to indicate whether the current block corresponding to the first image component of the current slice needs to be encoded using a preset sub-block; sh_default_sb_coded_flag[1] is used to indicate whether the current block corresponding to the second image component of the current slice needs to be encoded using a preset sub-block; sh_default_sb_coded_flag[2] is used to indicate whether the current block corresponding to the third image component of the current slice needs to be encoded using a preset sub-block.

[0617] Here, one or more component identification messages can also be used in this application embodiment to control the use of different image components in this application embodiment. For example, one component identification message can be used to control whether three image components use the method of this application embodiment; or two component identification messages can be used to control whether three image components use the method of this application embodiment; or three component identification messages can be used to control whether each of the three image components uses the method of this application embodiment.

[0618] In a specific example, taking the YUV format as an example, three component identification messages are used to control whether each of the three image components uses the method of the embodiment of this application. Wherein, if the value of sh_default_sb_coded_flag[0] is 1, then it is determined that the block corresponding to the first image component (e.g., the Y component) of the current slice needs to be encoded using a preset sub-block; if the value of sh_default_sb_coded_flag[1] is 1, then it is determined that the block corresponding to the second image component (e.g., the U component) of the current slice needs to be encoded using a preset sub-block; if the value of sh_default_sb_coded_flag[2] is 1, then it is determined that the block corresponding to the third image component (e.g., the V component) of the current slice needs to be encoded using a preset sub-block.

[0619] In short, for all image components in an image, besides using a unified identification message to control the use of the embodiments of this application, it is also possible to use different identification messages to individually control the use of each image component in the embodiments of this application, or to use two identification messages to control the use of all image components in the embodiments of this application. That is, more than one identification message can be used to control the use of different image components in the embodiments of this application. Here, all image components can refer to, for example, R, G, B in RGB format images, or Y, U, V (Y, Cb, Cr) in YUV format, etc.

[0620] This embodiment also provides an encoding method applied to an encoder. By determining the component identification information of the current slice and the position of the last non-zero coefficient of the current block corresponding to the component of the current slice; based on the component identification information and the position of the last non-zero coefficient, the coordinate information of the last non-zero coefficient of the current block is determined; all coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the encoded bit information, component identification information, and coordinate information of the last non-zero coefficient are written into the bitstream. Thus, in high-bit-width, high-bit-rate, high-quality, or lossless image encoding and decoding scenarios, setting a reasonable output method for the last non-zero coefficient based on the distribution pattern of the non-zero coefficients can reduce the overhead caused by encoding in the bitstream and improve compression efficiency; furthermore, since the distribution patterns of the non-zero coefficients of each image component are different, the output method of the last non-zero coefficient can be controlled more finely for each image component, that is, whether each image component uses the last non-zero coefficient position flipping technique, thereby further improving compression efficiency.

[0621] In another embodiment of this application, a bitstream is provided, which may be generated by bit encoding based on a message to be encoded. The message to be encoded includes at least one of the following: a first syntax element identifier message, a second syntax element identifier message, a third syntax element identifier message, a component identifier message, a last coefficient enable identifier message, and a sub-block preset encoding identifier message; wherein...

[0622] The first syntax element identifier message is used to indicate whether the current sequence is allowed to use the last non-zero coefficient position flip; the second syntax element identifier message is used to indicate whether the current sequence uses the standard extended version; the third syntax element identifier message is used to indicate whether the current sequence uses range extension; the component identifier message is used to indicate whether the components of the current slice use the last non-zero coefficient position flip; the last coefficient enable identifier message is used to indicate whether the current block uses the last coefficient position; the sub-block preset encoding identifier message is used to indicate whether the sub-block to be encoded in the current block is preset encoded; wherein, the current sequence includes the current slice, and the current slice includes the current block.

[0623] In this embodiment of the application, an encoding and decoding system is also provided, which may include an encoder and a decoder. The encoder, after generating a bitstream, transmits the bitstream to the decoder so that the decoder can obtain relevant decoding information by parsing the bitstream, such as first syntax element identifier information, second syntax element identifier information, third syntax element identifier information, component identifier information, last coefficient enable identifier information, sub-block preset encoding identifier information, and coordinate information of the last non-zero coefficient of the current block, etc.

[0624] In another embodiment of this application, based on the same inventive concept as the foregoing embodiments, referring to FIG12, a schematic diagram of the composition structure of an encoder 120 provided in an embodiment of this application is shown. As shown in FIG12, the encoder 120 may include: a first determining unit 1201 and an encoding unit 1202; wherein,

[0625] The first determining unit 1201 is configured to determine the component identification message of the current slice and to determine the position of the last non-zero coefficient of the current block corresponding to the component of the current slice;

[0626] The first determining unit 1201 is further configured to determine the coordinate information of the last non-zero coefficient of the current block based on the component identification information and the position of the last non-zero coefficient;

[0627] The encoding unit 1202 is configured to encode all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and write the bit information, component identification information and coordinate information of the last non-zero coefficient obtained after encoding into the code stream.

[0628] In some embodiments, the first determining unit 1201 is further configured to determine a first syntax element identification message; and when the first syntax element identification message indicates that the current sequence allows flipping using the last non-zero coefficient position, to perform the step of determining the component identification message of the current slice; wherein the current sequence includes the current slice.

[0629] In some embodiments, the first determining unit 1201 is further configured to determine a second syntax element identification message; and when the second syntax element identification message indicates that the current sequence uses a standard extended version, determine a third syntax element identification message; and when the third syntax element identification message indicates that the current sequence uses a scope extension, perform the step of determining the first syntax element identification message.

[0630] In some embodiments, the first determining unit 1201 is further configured to determine the value of the second syntax element identification message as a first value if the current sequence uses the standard extended version; or, if the current sequence does not use the standard extended version, determine the value of the second syntax element identification message as a second value.

[0631] In some embodiments, the encoding unit 1202 is further configured to write the second syntax element identification message into the code stream.

[0632] In some embodiments, the first determining unit 1201 is further configured to determine the value of the third syntax element identification message as a first value if the current sequence uses range expansion; or, if the current sequence does not use range expansion, determine the value of the third syntax element identification message as a second value.

[0633] In some embodiments, the encoding unit 1202 is further configured to write the third syntax element identification message into the code stream.

[0634] In some embodiments, the scope of the current sequence is extended to include: the current sequence satisfies at least one of the following: high bit width, high quality, high bit rate, high frame rate and lossless compression.

[0635] In some embodiments, the first determining unit 1201 is further configured to determine the value of the first syntax element identification message as a first value if the current sequence allows flipping using the last non-zero coefficient position; or, if the current sequence does not allow flipping using the last non-zero coefficient position, determine the value of the first syntax element identification message as a second value.

[0636] In some embodiments, the encoding unit 1202 is further configured to write the first syntax element identification message into the code stream.

[0637] In some embodiments, the first determining unit 1201 is further configured to determine the value of the component identification message as a first value if the component of the current slice is flipped using the last non-zero coefficient position; or, if the component of the current slice is not flipped using the last non-zero coefficient position, determine the value of the component identification message as a second value.

[0638] In some embodiments, the component includes at least one of the following: a first image component, a second image component, and a third image component; wherein,

[0639] The first image component is a luminance component, the second image component is a first chrominance component, and the second image component is a second chrominance component; or...

[0640] The first image component is the red component, the second image component is the green component, and the third image component is the blue component.

[0641] In some embodiments, the first determining unit 1201 is further configured to, when the component includes a first image component, a second image component and a third image component, determine that the number of component identification messages in the current slice is 1 if all the first image component, the second image component and the third image component of the current slice share a component identification message; or, determine that the number of component identification messages in the current slice is 2 if two of the first image component, the second image component and the third image component of the current slice share a component identification message; or, determine that the number of component identification messages in the current slice is 3 if each of the first image component, the second image component and the third image component of the current slice uses a component identification message.

[0642] In some embodiments, the first determining unit 1201 is further configured to determine the first component identification message of the current slice;

[0643] Accordingly, the first determining unit 1201 is further configured to determine the value of the first component identification message as the first value if the first image component, the second image component and the third image component of the current slice are all flipped using the last non-zero coefficient position.

[0644] In some embodiments, the first determining unit 1201 is further configured to determine the second component identification message and the third component identification message of the current slice;

[0645] Accordingly, the first determining unit 1201 is further configured to determine the value of the second component identification message as a first value if two of the first, second, and third image components of the current slice are flipped using the last non-zero coefficient position; and to determine the value of the third component identification message as a first value if the remaining image components of the current slice, excluding two of the image components, are flipped using the last non-zero coefficient position.

[0646] In some embodiments, the first determining unit 1201 is further configured to determine the fourth component identification message, the fifth component identification message and the sixth component identification message of the current slice;

[0647] Accordingly, the first determining unit 1201 is further configured to determine the value of the fourth component identification message as a first value if the first image component of the current slice is flipped using the last non-zero coefficient position; and to determine the value of the fifth component identification message as a first value if the second image component of the current slice is flipped using the last non-zero coefficient position; and to determine the value of the sixth component identification message as a first value if the third image component of the current slice is flipped using the last non-zero coefficient position.

[0648] In some embodiments, the position of the last non-zero coefficient includes the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient, which are the horizontal and vertical distances between the position of the last non-zero coefficient and the position of the upper left corner of the current block.

[0649] Accordingly, the first determining unit 1201 is further configured to, if the value of the component identification message is a first value, calculate and determine the coordinate message of the last non-zero coefficient based on the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient; or, if the value of the component identification message is a second value, directly determine the coordinate message of the last non-zero coefficient based on the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient.

[0650] In some embodiments, the first determining unit 1201 is further configured to determine the width and height of the current block; and to perform a subtraction calculation based on the width of the current block and the initial horizontal coordinate of the last non-zero coefficient to obtain the horizontal coordinate of the last non-zero coefficient; and to perform a subtraction calculation based on the height of the current block and the initial vertical coordinate of the last non-zero coefficient to obtain the vertical coordinate of the last non-zero coefficient; and to determine the coordinate information of the last non-zero coefficient based on the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.

[0651] In some embodiments, the first determining unit 1201 is further configured to determine the coordinate information of the last non-zero coefficient as the horizontal and vertical distance between the position of the last non-zero coefficient and the lower right corner of the current block if the value of the component identification message is a first value; or, if the value of the component identification message is a second value, the coordinate information of the last non-zero coefficient as the horizontal and vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block.

[0652] In some embodiments, the first determining unit 1201 is further configured to determine the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient of the current block based on the coordinate message of the last non-zero coefficient.

[0653] The encoding unit 1202 is further configured to write the first code message of the last non-zero coefficient horizontal coordinate, the first code message of the last non-zero coefficient vertical coordinate, the last code message of the last non-zero coefficient horizontal coordinate and the last code message of the last non-zero coefficient vertical coordinate into the code stream.

[0654] In some embodiments, the first determining unit 1201 is further configured to determine the last coefficient enable flag of the current block when the third syntax element flag indicates that the current sequence uses an expanded range;

[0655] The encoding unit 1202 is further configured to encode all coefficients before the last coefficient position according to a preset scanning order when the last coefficient enable flag message indicates that the current block uses the last coefficient position, and write the encoded bit message and the last coefficient enable flag message into the bit stream.

[0656] In some embodiments, the first determining unit 1201 is further configured to determine the value of the last coefficient enable flag message as a first value if the current block uses the last coefficient position; or, if the current block does not use the last coefficient position, determine the value of the last coefficient enable flag message as a second value.

[0657] In some embodiments, the last coefficient position is the lower right corner of the matrix formed by all possible non-zero coefficients in the current block; or, the last coefficient position is the last position of the current block after scanning all possible non-zero coefficients according to a preset scanning sequence.

[0658] In some embodiments, the first determining unit 1201 is further configured to set the position of the last non-zero coefficient at the last coefficient position.

[0659] In some embodiments, the first determining unit 1201 is further configured to determine the width and height of the transform block obtained by the current block after a preset operation; and to perform coordinate calculation based on the width and height of the transform block to obtain the lower right corner coordinate information of the transform block; and to determine the position of the last coefficient based on the lower right corner coordinate information of the transform block.

[0660] In some embodiments, the preset operation includes at least: a forced zero-out operation.

[0661] In some embodiments, the first determining unit 1201 is further configured to determine the position of the last non-zero coefficient according to the coordinate information of the lower right corner of the transform block when the position of the last non-zero coefficient is set at the last coefficient position.

[0662] In some embodiments, the first determining unit 1201 is further configured to determine the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient when the last coefficient enable flag message indicates that the current block does not use the last coefficient position; and to determine the position of the last non-zero coefficient based on the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient.

[0663] The encoding unit 1202 is further configured to encode all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and write the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient into the code stream.

[0664] In some embodiments, the first determining unit 1201 is further configured to determine the sub-block preset encoding identifier message of the sub-block to be encoded in the current block when the third syntax element identifier message indicates that the scope of use of the current sequence is expanded;

[0665] The encoding unit 1202 is further configured to encode all coefficients in the sub-block to be encoded when the sub-block preset encoding identifier message indicates that the sub-block to be encoded has a preset encoding, and to write the bit information obtained after encoding and the sub-block preset encoding identifier message into the code stream.

[0666] In some embodiments, the first determining unit 1201 is further configured to determine the sub-block encoding identifier message of the sub-block to be encoded when the sub-block preset encoding identifier message indicates that the sub-block to be encoded does not have a preset encoding;

[0667] The encoding unit 1202 is also configured to write the sub-block encoding identifier message into the code stream.

[0668] In some embodiments, the first determining unit 1201 is further configured to determine the value of the sub-block preset encoding identifier message as a first value if the sub-block to be encoded has a preset encoding; or, if the sub-block to be encoded does not have a preset encoding, determine the value of the sub-block preset encoding identifier message as a second value.

[0669] In some embodiments, the first determining unit 1201 is further configured to determine the value of the sub-block encoding identifier message as a first value if encoding is required within the sub-block; or, if all coefficients within the sub-block are zero, determine the value of the sub-block encoding identifier message as a second value.

[0670] In some embodiments, the first value is 1 and the second value is 0.

[0671] It is understood that in the embodiments of this application, a "unit" can be a part of a circuit, a part of a processor, a part of a program or software, etc., and of course, it can also be a module or a non-modular one. Moreover, the components in this embodiment can be integrated into one processing unit, or each unit can exist as a separate entity, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in the form of hardware or in the form of a software functional module.

[0672] If the integrated unit is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, and other media capable of storing program code.

[0673] Therefore, this application provides a computer storage medium applied to an encoder 120, the computer storage medium storing a computer program, which, when executed by a first processor, implements the method described in any of the foregoing embodiments.

[0674] Based on the composition of the encoder 120 described above and the computer storage medium, refer to FIG13, which shows a schematic diagram of the specific hardware structure of the encoder 120 provided in this application embodiment. As shown in FIG13, it may include: a first communication interface 1301, a first memory 1302, and a first processor 1303; each component is coupled together through a first bus system 1304. It is understood that the first bus system 1304 is used to realize the connection and communication between these components. In addition to data buses, the first bus system 1304 also includes power buses, control buses, and status signal buses. However, for clarity, all buses are labeled as the first bus system 1304 in FIG13.

[0675] The first communication interface 1301 is used for receiving and sending signals during the process of sending and receiving messages with other external network components;

[0676] First memory 1302 is used to store computer programs that can run on the first processor 1303;

[0677] The first processor 1303 is used to execute the following when running the computer program:

[0678] Determine the component identification message of the current slice, and determine the position of the last non-zero coefficient of the current block corresponding to the component of the current slice;

[0679] Based on the component identification message and the position of the last non-zero coefficient, determine the coordinate message of the last non-zero coefficient of the current block;

[0680] Encode all coefficients before the position of the last non-zero coefficient according to the preset scanning order, and write the encoded bit information, component identification information and coordinate information of the last non-zero coefficient into the bit stream.

[0681] It is understood that the first memory 1302 in the embodiments of this application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which is used as external cache memory. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The first memory 1302 of the system and method described in this application is intended to include, but is not limited to, these and any other suitable types of memory.

[0682] The first processor 1303 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed through the hardware integrated logic circuit or software instructions in the first processor 1303. The first processor 1303 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically readable and writable programmable memory, or registers. This storage medium is located in the first memory 1302. The first processor 1303 reads the information in the first memory 1302 and, in conjunction with its hardware, completes the steps of the above method.

[0683] It is understood that the embodiments described in this application can be implemented using hardware, software, firmware, intermediate software, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSP devices, DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application, or combinations thereof. For software implementation, the technology described in this application can be implemented through modules (e.g., procedures, functions, etc.) that perform the functions described in this application. Software code can be stored in memory and executed by a processor. Memory can be implemented in the processor or externally.

[0684] Optionally, as another embodiment, the first processor 1303 is further configured to execute the method described in any of the foregoing embodiments when running the computer program.

[0685] This embodiment provides an encoder, which may include a first determining unit and an encoding unit. Thus, in high-bit-width, high-bit-rate, high-quality, or lossless image encoding and decoding scenarios, setting a reasonable output method for the last non-zero coefficient based on the distribution pattern of the non-zero coefficients can reduce the overhead of encoding in the bitstream and improve compression efficiency. Furthermore, since the distribution patterns of the non-zero coefficients of each image component are different, more refined control of the output method of the last non-zero coefficient for each image component can be used, i.e., controlling whether each image component uses the last non-zero coefficient position flipping technique, thereby further improving compression efficiency.

[0686] In another embodiment of this application, based on the same inventive concept as the foregoing embodiments, referring to FIG14, a schematic diagram of the composition structure of a decoder 140 provided in an embodiment of this application is shown. As shown in FIG14, the decoder 140 may include: a parsing unit 1401 and a second determining unit 1402; wherein,

[0687] The parsing unit 1401 is configured to parse the bitstream, determine the component identifier information of the current slice, and determine the coordinate information of the last non-zero coefficient of the current block corresponding to the component of the current slice;

[0688] The second determining unit 1402 is configured to calculate the coordinate information of the last non-zero coefficient when the component identification message indicates that the component of the current block is flipped using the position of the last non-zero coefficient, so as to obtain the position of the last non-zero coefficient of the current block.

[0689] The parsing unit 1401 is also configured to decode all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block.

[0690] In some embodiments, the parsing unit 1401 is further configured to parse the code stream and determine the first syntax element identification message;

[0691] The second determining unit 1402 is further configured to perform the step of parsing the code stream and determining the component identification message of the current segment when the first syntax element identification message indicates that the current sequence allows the flipping of the last non-zero coefficient position; wherein the current sequence includes the current segment.

[0692] In some embodiments, the parsing unit 1401 is further configured to parse the code stream to determine the second syntax element identification message; and when the second syntax element identification message indicates that the current sequence uses the standard extended version, parse the code stream to determine the third syntax element identification message; and when the third syntax element identification message indicates that the current sequence uses the range extension, perform the step of parsing the code stream to determine the first syntax element identification message.

[0693] In some embodiments, the second determining unit 1402 is further configured to determine that if the value of the second syntax element identification message is a first value, the second syntax element identification message indicates that the current sequence uses the standard extended version; or, if the value of the second syntax element identification message is a second value, the second syntax element identification message indicates that the current sequence does not use the standard extended version.

[0694] In some embodiments, the second determining unit 1402 is further configured to determine that if the value of the third syntax element identification message is a first value, the third syntax element identification message indicates that the current sequence uses range extension; or, if the value of the third syntax element identification message is a second value, the third syntax element identification message indicates that the current sequence does not use range extension.

[0695] In some embodiments, the scope of the current sequence is extended to include: the current sequence satisfies at least one of the following: high bit width, high quality, high bit rate, high frame rate and lossless compression.

[0696] In some embodiments, the second determining unit 1402 is further configured to determine that if the value of the first syntax element identification message is a first value, the first syntax element identification message indicates that the current sequence is allowed to be flipped using the last non-zero coefficient position; or, if the value of the first syntax element identification message is a second value, the first syntax element identification message indicates that the current sequence is not allowed to be flipped using the last non-zero coefficient position.

[0697] In some embodiments, the second determining unit 1402 is further configured to determine that if the value of the component identification message is a first value, the component identification message indicates that the component of the current slice is flipped using the last non-zero coefficient position; or, if the value of the component identification message is a second value, the component identification message indicates that the component of the current slice is not flipped using the last non-zero coefficient position.

[0698] In some embodiments, the second determining unit 1402 is further configured to directly determine the position of the last non-zero coefficient of the current block based on the coordinate information of the last non-zero coefficient when the component identification message indicates that the component of the current block does not use the last non-zero coefficient position flip.

[0699] The parsing unit 1401 is also configured to decode all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block.

[0700] In some embodiments, the component includes at least one of the following: a first image component, a second image component, and a third image component; wherein,

[0701] The first image component is a luminance component, the second image component is a first chrominance component, and the second image component is a second chrominance component; or...

[0702] The first image component is the red component, the second image component is the green component, and the third image component is the blue component.

[0703] In some embodiments, the second determining unit 1402 is further configured to, when the component includes a first image component, a second image component, and a third image component, determine that the number of component identification messages in the current slice is 1 if all the first image component, the second image component, and the third image component of the current slice share a component identification message; or, determine that the number of component identification messages in the current slice is 2 if two of the first image component, the second image component, and the third image component of the current slice share a component identification message; or, determine that the number of component identification messages in the current slice is 3 if each of the first image component, the second image component, and the third image component of the current slice uses a component identification message.

[0704] In some embodiments, the parsing unit 1401 is further configured to parse the bitstream and determine the first component identification message of the current slice;

[0705] Accordingly, the second determining unit 1402 is further configured to determine that if the value of the first component identification message is the first value, the first image component, the second image component and the third image component of the current slice are all flipped using the last non-zero coefficient position.

[0706] In some embodiments, the parsing unit 1401 is further configured to parse the bitstream and determine the second component identification message and the third component identification message of the current slice;

[0707] Accordingly, the second determining unit 1402 is further configured to determine that if the value of the second component identification message is a first value, then two of the first image component, the second image component, and the third image component of the current slice are flipped using the last non-zero coefficient position; and if the value of the third component identification message is a first value, then the remaining image components of the current slice, excluding the two image components, are flipped using the last non-zero coefficient position.

[0708] In some embodiments, the parsing unit 1401 is further configured to parse the bitstream and determine the fourth component identification message, the fifth component identification message and the sixth component identification message of the current slice;

[0709] Accordingly, the second determining unit 1402 is further configured to determine that if the value of the fourth component identification message is a first value, the first image component of the current slice is flipped using the last non-zero coefficient position; and if the value of the fifth component identification message is a first value, the second image component of the current slice is flipped using the last non-zero coefficient position; and if the value of the sixth component identification message is a first value, the third image component of the current slice is flipped using the last non-zero coefficient position.

[0710] In some embodiments, the parsing unit 1401 is further configured to parse the code stream and obtain the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient of the current block.

[0711] The second determining unit 1402 is further configured to determine the horizontal coordinate of the last non-zero coefficient based on the first code message of the horizontal coordinate of the last non-zero coefficient and the last code message of the horizontal coordinate of the last non-zero coefficient; and to determine the vertical coordinate of the last non-zero coefficient based on the first code message of the vertical coordinate of the last non-zero coefficient and the last code message of the vertical coordinate of the last non-zero coefficient; and to determine the coordinate message of the last non-zero coefficient of the current block based on the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.

[0712] In some embodiments, the second determining unit 1402 is further configured to determine the coordinate information of the last non-zero coefficient of the current block as the horizontal and vertical distance between the position of the last non-zero coefficient and the lower right corner position of the current block when the component identification message indicates that the component of the current block is flipped using the position of the last non-zero coefficient.

[0713] Accordingly, the second determining unit 1402 is further configured to determine the width and height of the current block; and to calculate the horizontal coordinate of the last non-zero coefficient by subtracting the horizontal distance between the width of the current block and the position of the last non-zero coefficient relative to the lower right corner of the current block; and to calculate the vertical coordinate of the last non-zero coefficient by subtracting the vertical distance between the height of the current block and the position of the last non-zero coefficient relative to the lower right corner of the current block; and to determine the position of the last non-zero coefficient of the current block based on the horizontal coordinate and the vertical coordinate of the last non-zero coefficient.

[0714] In some embodiments, the second determining unit 1402 is further configured to determine the coordinate information of the last non-zero coefficient of the current block as the horizontal and vertical distances between the position of the last non-zero coefficient and the upper left corner position of the current block when the component identification message indicates that the component of the current block does not use the last non-zero coefficient position flip. And to determine the position of the last non-zero coefficient of the current block based on the horizontal and vertical distances between the position of the last non-zero coefficient and the upper left corner position of the current block.

[0715] In some embodiments, the parsing unit 1401 is further configured to parse the code stream and determine the last coefficient enable flag message of the current block when the third syntax element identifier message indicates that the current sequence uses an expanded range; and to decode all coefficients before the last coefficient position according to a preset scanning order and determine the coefficients of the current block when the last coefficient enable flag message indicates that the current block uses the last coefficient position.

[0716] In some embodiments, the second determining unit 1402 is further configured to determine that if the value of the last coefficient enable flag message is a first value, the last coefficient enable flag message indicates that the current block uses the last coefficient position; or, if the value of the last coefficient enable flag message is a second value, the last coefficient enable flag message indicates that the current block does not use the last coefficient position.

[0717] In some embodiments, the parsing unit 1401 is further configured to parse the code stream when the value of the last coefficient enable flag message is a second value, and obtain the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient of the current block.

[0718] The second determining unit 1402 is further configured to determine the position of the last non-zero coefficient based on the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient.

[0719] The parsing unit 1401 is also configured to decode all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block.

[0720] In some embodiments, the last coefficient position is the lower right corner of the matrix formed by all possible non-zero coefficients in the current block; or, the last coefficient position is the last position of the current block after scanning all possible non-zero coefficients according to a preset scanning sequence.

[0721] In some embodiments, the second determining unit 1402 is further configured to set the position of the last non-zero coefficient at the last coefficient position.

[0722] In some embodiments, the second determining unit 1402 is further configured to determine the width and height of the transform block obtained by the current block after a preset operation; and to perform coordinate calculation based on the width and height of the transform block to obtain the lower right corner coordinate information of the transform block; and to determine the position of the last coefficient based on the lower right corner coordinate information of the transform block.

[0723] In some embodiments, the preset operation includes at least: a forced zero-out operation.

[0724] In some embodiments, the second determining unit 1402 is further configured to determine the position of the last non-zero coefficient according to the coordinate information of the lower right corner of the transform block when the position of the last non-zero coefficient is set at the last coefficient position.

[0725] In some embodiments, the parsing unit 1401 is further configured to parse the bitstream and determine the sub-block preset encoding identifier message of the current block when the third syntax element identifier message indicates that the current sequence uses an expanded range; and to decode all coefficients in the sub-block to be decoded when the sub-block preset encoding identifier message indicates the preset encoding of the sub-block to be decoded in the current block.

[0726] In some embodiments, the parsing unit 1401 is further configured to parse the bitstream and determine the sub-block encoding identifier message of the sub-block to be decoded when the sub-block preset encoding identifier message indicates that the sub-block to be decoded in the current block does not have a preset encoding; and to decode all coefficients in the sub-block to be decoded when the sub-block encoding identifier message takes the first value.

[0727] In some embodiments, the second determining unit 1402 is further configured to determine that if the value of the sub-block preset encoding identifier message is a first value, the sub-block preset encoding identifier message indicates that the sub-block to be decoded in the current block is preset encoded; or, if the value of the sub-block preset encoding identifier message is a second value, the sub-block preset encoding identifier message indicates that the sub-block to be decoded in the current block is not preset encoded.

[0728] In some embodiments, the second determining unit 1402 is further configured to determine that all coefficients in the sub-block to be decoded are decoded if the value of the sub-block encoding identifier message is a first value; or, if the value of the sub-block encoding identifier message is a second value, determine that all coefficients in the sub-block to be decoded are zero.

[0729] In some embodiments, the first value is 1 and the second value is 0.

[0730] Understandably, in this embodiment, a "unit" can be a part of a circuit, a part of a processor, a part of a program or software, etc., and of course, it can also be a module or a non-modular component. Moreover, in this embodiment, the various components can be integrated into one processing unit, or each unit can exist as a separate entity, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware form or in the form of a software functional module.

[0731] If the integrated unit is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, this embodiment provides a computer storage medium applied to the decoder 140. The computer storage medium stores a computer program, which, when executed by a second processor, implements the method described in any of the foregoing embodiments.

[0732] Based on the composition of the decoder 140 described above and the computer storage medium, refer to FIG15, which shows a schematic diagram of the specific hardware structure of the decoder 140 provided in this embodiment of the application. As shown in FIG15, it may include: a second communication interface 1501, a second memory 1502, and a second processor 1503; the various components are coupled together through a second bus system 1504. It is understood that the second bus system 1504 is used to realize the connection and communication between these components. In addition to data buses, the second bus system 1504 also includes power buses, control buses, and status signal buses. However, for clarity, all buses are labeled as the second bus system 1504 in FIG15.

[0733] ​​The second communication interface 1501 is used for receiving and sending signals during the process of sending and receiving messages with other external network components;

[0734] Second memory 1502 is used to store computer programs that can run on the second processor 1503;

[0735] The second processor 1503 is used to execute the following when running the computer program:

[0736] Analyze the bitstream to determine the component identifier information of the current slice, and determine the coordinate information of the last non-zero coefficient of the current block corresponding to the component of the current slice;

[0737] When the component identification message indicates that the component of the current block is flipped using the last non-zero coefficient position, the coordinate information of the last non-zero coefficient is calculated to obtain the position of the last non-zero coefficient of the current block;

[0738] Decode all coefficients before the last non-zero coefficient according to the preset scanning order to determine the coefficients of the current block.

[0739] Optionally, as another embodiment, the second processor 1503 is also configured to perform the method described in any of the foregoing embodiments when running the computer program.

[0740] It is understood that the hardware functions of the second memory 1502 are similar to those of the first memory 1302, and the hardware functions of the second processor 1503 are similar to those of the first processor 1303; details will not be elaborated here.

[0741] This embodiment provides a decoder, which may include a parsing unit and a second determining unit. Thus, in high-bit-width, high-bit-rate, high-quality, or lossless image encoding and decoding scenarios, setting a reasonable output method for the last non-zero coefficient based on the distribution pattern of the non-zero coefficients can reduce the overhead of encoding in the bitstream and improve compression efficiency. Furthermore, since the distribution patterns of the non-zero coefficients of each image component are different, more refined control of the output method of the last non-zero coefficient for each image component can be used, i.e., controlling whether each image component uses the last non-zero coefficient position flipping technique, thereby further improving compression efficiency.

[0742] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0743] The sequence numbers of the above embodiments of this application are for description only and do not represent the superiority or inferiority of the embodiments.

[0744] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0745] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0746] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.

[0747] The above description is merely a specific embodiment of this application, but the protection scope of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the aforementioned claim.

[0748] In this embodiment of the application, the encoder determines the component identification message of the current slice and the position of the last non-zero coefficient of the current block corresponding to the component of the current slice; based on the component identification message and the position of the last non-zero coefficient, the coordinate message of the last non-zero coefficient of the current block is determined; all coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the encoded bit message, component identification message, and coordinate message of the last non-zero coefficient are written into the bitstream. In the decoder, the bitstream is parsed to determine the component identification message of the current slice and the coordinate message of the last non-zero coefficient of the current block corresponding to the component of the current slice; when the component identification message indicates that the component of the current slice is flipped using the position of the last non-zero coefficient, the coordinate message of the last non-zero coefficient is calculated to obtain the position of the last non-zero coefficient of the current block; all coefficients before the position of the last non-zero coefficient are decoded according to a preset scanning order to determine the coefficients of the current block. In this way, in high-bit-width, high-bit-rate, high-quality or lossless image encoding and decoding scenarios, setting a reasonable output method for the last non-zero coefficient based on the distribution pattern of the non-zero coefficients can reduce the overhead of encoding in the bitstream and improve compression efficiency. In addition, since the distribution patterns of the non-zero coefficients of each image component are different, the component identification information can be used to control whether the last non-zero coefficient position flipping technique is used for each image component, thereby further improving compression efficiency. [Simplified Explanation of the Diagram]

[0032] Figure 1 is a schematic diagram of the application of a coding framework provided by related technologies;

[0033] Figure 2 is a schematic diagram of the positional relationship between the current coefficient and adjacent coefficients provided by related technologies;

[0034] Figure 3 is a schematic flowchart of an arithmetic decoding process for a bin provided by related technologies;

[0035] Figure 4 is a flowchart illustrating an arithmetic decoding process for binary symbols provided by related technologies;

[0036] Figure 5 is a schematic diagram of the normalization process of an arithmetic decoding engine provided by related technologies;

[0037] Figure 6 is a schematic flowchart of a bypass decoding process provided by related technologies;

[0038] Figure 7 is a schematic diagram of the positional relationship between a region that may have non-zero coefficients and a region that is forced to be 0, provided by related technologies;

[0039] Figure 8A is a schematic diagram of the system composition of an encoder provided in an embodiment of this application;

[0040] Figure 8B is a schematic diagram of the system composition of a decoder provided in an embodiment of this application;

[0041] Figure 9 is a flowchart illustrating a decoding method provided in an embodiment of this application;

[0042] Figure 10A is a schematic diagram showing the position of the last non-zero coefficient relative to the upper left corner of the current block according to an embodiment of this application;

[0043] Figure 10B is a schematic diagram showing the position of the last non-zero coefficient relative to the lower right corner of the current block according to an embodiment of this application;

[0044] Figure 11 is a flowchart illustrating an encoding method provided in an embodiment of this application;

[0045] Figure 12 is a schematic diagram of the composition structure of an encoder provided in an embodiment of this application;

[0046] Figure 13 is a schematic diagram of the specific hardware structure of an encoder provided in an embodiment of this application;

[0047] Figure 14 is a schematic diagram of the composition structure of a decoder provided in an embodiment of this application;

[0048] Figure 15 is a schematic diagram of the specific hardware structure of a decoder provided in an embodiment of this application.

Claims

1. A decoding method applied to a decoder, the method comprising: The code stream is parsed to determine the last non-zero coefficient position flip flag message of the current slice, and to determine the coordinate message of the last non-zero coefficient of the current block corresponding to the current slice block; when the last non-zero coefficient position flip flag message indicates that the current slice block uses the last non-zero coefficient position flip, the coordinate message of the last non-zero coefficient is calculated to obtain the position of the last non-zero coefficient of the current block. The method further includes: decoding all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block; parsing the bitstream to determine a first syntax element identification message; when the first syntax element identification message indicates that the current sequence allows the use of the last non-zero coefficient position flip, performing the step of parsing the bitstream to determine the last non-zero coefficient position flip identification message of the current slice; wherein the current sequence includes the current slice; and parsing the bitstream to determine a second syntax element identification message; when the second syntax element identification message indicates that the current sequence uses a standard extended version, parsing the bitstream to determine a third syntax element identification message; and when the third syntax element identification message indicates that the current sequence uses a range extension, performing the step of parsing the bitstream to determine the first syntax element identification message.

2. The method according to request item 1, wherein, The method further includes: if the value of the second syntax element identification message is a first value, then determining that the second syntax element identification message indicates that the current sequence uses the standard extended version; or, if the value of the second syntax element identification message is a second value, then determining that the second syntax element identification message indicates that the current sequence does not use the standard extended version.

3. The method according to request item 1, wherein, The method further includes: if the value of the third syntax element identification message is a first value, then determining that the third syntax element identification message indicates that the current sequence uses range extension; or, if the value of the third syntax element identification message is a second value, then determining that the third syntax element identification message indicates that the current sequence does not use range extension.

4. The method according to request item 3, wherein, The current sequence usage range extension includes: the current sequence satisfies at least one of the following: high bit width, high quality, high bit rate, high frame rate, and lossless compression.

5. The method according to request item 1, wherein, The method further includes: if the value of the first syntax element identification message is a first value, then determining that the first syntax element identification message indicates that the current sequence is allowed to be flipped using the last non-zero coefficient position; or, if the value of the first syntax element identification message is a second value, then determining that the first syntax element identification message indicates that the current sequence is not allowed to be flipped using the last non-zero coefficient position.

6. The method according to request item 1, wherein, The method further includes: if the value of the last non-zero coefficient position flip flag message is a first value, then the last non-zero coefficient position flip flag message indicates that the current intra-chip block uses the last non-zero coefficient position flip; or, if the value of the last non-zero coefficient position flip flag message is a second value, then the last non-zero coefficient position flip flag message indicates that the current intra-chip block does not use the last non-zero coefficient position flip.

7. The method according to request item 6, wherein, The method further includes: when the last non-zero coefficient position flip flag message indicates that the current intra-block does not use the last non-zero coefficient position flip, directly determining the position of the last non-zero coefficient of the current block according to the coordinate message of the last non-zero coefficient; decoding all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block.

8. The method according to request item 1, wherein, The components include at least one of the following: a first image component, a second image component, and a third image component; wherein the first image component is a luminance component, the second image component is a first chrominance component, and the second image component is a second chrominance component; or, the first image component is a red component, the second image component is a green component, and the third image component is a blue component.

9. The method according to claim 7, wherein, When the components include a first image component, a second image component, and a third image component, the method further includes: if the first image component, the second image component, and the third image component of the current slice all share a single last non-zero coefficient position flip flag message, then the number of last non-zero coefficient position flip flag messages in the current slice is 1; or, if two of the first image component, the second image component, and the third image component of the current slice share a single last non-zero coefficient position flip flag message, then the number of last non-zero coefficient position flip flag messages in the current slice is 2; or, if the first image component, the second image component, and the third image component of the current slice each use a single last non-zero coefficient position flip flag message, then the number of last non-zero coefficient position flip flag messages in the current slice is 3.

10. The method according to claim 8, wherein, The method of parsing the bitstream to determine the last non-zero coefficient position flip flag message of the current slice includes: parsing the bitstream to determine the first last non-zero coefficient position flip flag message of the current slice; correspondingly, the method further includes: if the value of the first last non-zero coefficient position flip flag message is a first value, then it is determined that the first image component, the second image component and the third image component of the current slice are all flipped using the last non-zero coefficient position.

11. The method according to claim 8, wherein, The method of parsing the bitstream to determine the last non-zero coefficient position flip flag message of the current slice includes: parsing the bitstream to determine the second and third last non-zero coefficient position flip flag messages of the current slice; correspondingly, the method further includes: if the value of the second last non-zero coefficient position flip flag message is a first value, then it is determined that two of the first, second, and third image components of the current slice are flipped using the last non-zero coefficient position; if the value of the third last non-zero coefficient position flip flag message is a first value, then it is determined that the remaining image components of the current slice, excluding the two image components, are flipped using the last non-zero coefficient position.

12. The method according to claim 9, wherein, The method of parsing the bitstream to determine the last non-zero coefficient position flip flag message of the current slice includes: parsing the bitstream to determine the fourth, fifth, and sixth last non-zero coefficient position flip flag messages of the current slice; correspondingly, the method further includes: if the value of the fourth last non-zero coefficient position flip flag message is a first value, then it is determined that the first image component of the current slice uses the last non-zero coefficient position flip; if the value of the fifth last non-zero coefficient position flip flag message is a first value, then it is determined that the second image component of the current slice uses the last non-zero coefficient position flip; if the value of the sixth last non-zero coefficient position flip flag message is a first value, then it is determined that the third image component of the current slice uses the last non-zero coefficient position flip.

13. The method according to claim 1, wherein, The process of parsing the bitstream to determine the coordinate information of the last non-zero coefficient of the current block corresponding to the current intra-block includes: parsing the bitstream to obtain the first code information of the horizontal coordinate of the last non-zero coefficient, the first code information of the vertical coordinate of the last non-zero coefficient, the last code information of the horizontal coordinate of the last non-zero coefficient, and the last code information of the vertical coordinate of the last non-zero coefficient; determining the horizontal coordinate of the last non-zero coefficient based on the first code information of the horizontal coordinate of the last non-zero coefficient and the last code information of the horizontal coordinate of the last non-zero coefficient; determining the vertical coordinate of the last non-zero coefficient based on the first code information of the vertical coordinate of the last non-zero coefficient and the last code information of the vertical coordinate of the last non-zero coefficient; and determining the coordinate information of the last non-zero coefficient of the current block based on the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.

14. The method according to claim 1, wherein, The method further includes: when the last non-zero coefficient position flip flag message indicates that the current intra-block uses the last non-zero coefficient position for flipping, determining the coordinate information of the last non-zero coefficient of the current block as the horizontal and vertical distances between the position of the last non-zero coefficient and the lower right corner position of the current block; correspondingly, the step of calculating the coordinate information of the last non-zero coefficient to obtain the position of the last non-zero coefficient of the current block includes: determining the width and height of the current block; calculating the horizontal coordinate of the last non-zero coefficient by subtracting the horizontal distance between the width of the current block and the position of the last non-zero coefficient relative to the lower right corner position of the current block; and calculating the vertical coordinate of the last non-zero coefficient by subtracting the vertical distance between the height of the current block and the position of the last non-zero coefficient relative to the lower right corner position of the current block; and determining the position of the last non-zero coefficient of the current block based on the horizontal and vertical coordinates of the last non-zero coefficient.

15. The method according to request item 1, wherein, The method further includes: when the last non-zero coefficient position flip flag message indicates that the current intra-block does not use the last non-zero coefficient position flip, determining the coordinate message of the last non-zero coefficient of the current block as the horizontal and vertical distances between the position of the last non-zero coefficient and the upper left corner position of the current block; and determining the position of the last non-zero coefficient of the current block based on the horizontal and vertical distances between the position of the last non-zero coefficient and the upper left corner position of the current block.

16. The method according to claim 1, wherein, When the third syntax element identification message indicates that the current sequence uses an expanded range, the method further includes: parsing the bitstream to determine the last coefficient enable identifier message of the current block; when the last coefficient enable identifier message indicates that the current block uses the last coefficient position, decoding all coefficients before the last coefficient position according to a preset scanning order to determine the coefficients of the current block.

17. The method according to claim 16, wherein, The method further includes: if the value of the last coefficient enable flag message is a first value, then determining that the last coefficient enable flag message indicates that the current block uses the last coefficient position; or, if the value of the last coefficient enable flag message is a second value, then determining that the last coefficient enable flag message indicates that the current block does not use the last coefficient position.

18. The method according to claim 17, wherein, When the value of the last coefficient enable flag message is the second value, the method further includes: parsing the bitstream to obtain the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient; determining the position of the last non-zero coefficient based on the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient; and decoding all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block.

19. The method according to claim 16, wherein, The last coefficient position is the bottom right corner of the matrix formed by all possible non-zero coefficients in the current block; or, the last coefficient position is the last position of the current block when it scans all possible non-zero coefficients according to a preset scanning sequence.

20. The method according to claim 16, wherein, The method further includes setting the position of the last non-zero coefficient at the last coefficient position.

21. The method according to claim 16, wherein, The method further includes: determining the width and height of the current block after a preset operation; calculating coordinates based on the width and height of the transformation block to obtain the lower right corner coordinate information of the transformation block; and determining the position of the last coefficient based on the lower right corner coordinate information of the transformation block.

22. The method according to request item 21, wherein, The preset operations include at least the following: forced zero-out operation.

23. The method according to request item 21, wherein, The method further includes: when the position of the last non-zero coefficient is set at the last coefficient position, determining the position of the last non-zero coefficient according to the coordinate information of the lower right corner of the transform block.

24. The method according to request item 1, wherein, When the third syntax element identification message indicates that the current sequence uses an expanded range, the method further includes: parsing the bitstream to determine the sub-block preset encoding identification message of the current block; when the sub-block preset encoding identification message indicates the preset encoding of the sub-block to be decoded in the current block, decoding all coefficients in the sub-block to be decoded.

25. The method according to request item 24, wherein, When the sub-block preset encoding identifier message indicates that the sub-block to be decoded in the current block does not have a preset encoding, the method further includes: parsing the bitstream to determine the sub-block encoding identifier message of the sub-block to be decoded; when the value of the sub-block encoding identifier message is a first value, decoding all coefficients in the sub-block to be decoded.

26. The method according to claim 24, wherein, The method further includes: if the value of the sub-block preset encoding identifier message is a first value, then the sub-block preset encoding identifier message indicates that the sub-block to be decoded in the current block is preset encoded; or, if the value of the sub-block preset encoding identifier message is a second value, then the sub-block preset encoding identifier message indicates that the sub-block to be decoded in the current block is not preset encoded.

27. The method according to claim 25, wherein, The method further includes: if the value of the sub-block encoding identifier message is a first value, then it is determined that all coefficients in the sub-block to be decoded will be decoded; or, if the value of the sub-block encoding identifier message is a second value, then it is determined that all coefficients in the sub-block to be decoded are zero.

28. The method according to any one of claims 2, 3, 5, 6, 17, 26 and 27, wherein, The first value is 1, and the second value is 0.

29. An encoding method applied to an encoder, the method comprising: Determine the position flip flag message of the last non-zero coefficient of the current slice, and determine the position of the last non-zero coefficient of the current block corresponding to the current block within the current slice; Based on the last non-zero coefficient position flip flag message and the position of the last non-zero coefficient, determine the coordinate information of the last non-zero coefficient of the current block; encode all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and write the encoded bit information, the last non-zero coefficient position flip flag message, and the coordinate information of the last non-zero coefficient into the bitstream, wherein, before determining the last non-zero coefficient position flip flag message of the current slice, the method further includes: determining a first syntax element identifier message; when the first syntax element identifier message indicates that the current sequence allows the use of the last non-zero coefficient position flip, perform the step of determining the last non-zero coefficient position flip flag message of the current slice; wherein, the current sequence includes the current slice; and before determining the first syntax element identifier message, the method further includes: determining a second syntax element identifier message; when the second syntax element identifier message indicates that the current sequence uses the standard extended version, determine a third syntax element identifier message; when the third syntax element identifier message indicates that the current sequence uses the range extension, perform the step of determining the first syntax element identifier message.

30. The method according to claim 29, wherein, The determination of the second syntax element identification message includes: if the current sequence uses the standard extended version, then the value of the second syntax element identification message is determined to be a first value; or, if the current sequence does not use the standard extended version, then the value of the second syntax element identification message is determined to be a second value.

31. The method according to claim 30, wherein, The method further includes: writing the second syntax element identification message into the code stream.

32. The method according to claim 29, wherein, The determination of the third syntax element identifier message includes: if the current sequence uses range expansion, then determining that the value of the third syntax element identifier message is a first value; or, if the current sequence does not use range expansion, then determining that the value of the third syntax element identifier message is a second value.

33. The method according to claim 32, wherein, The method further includes: writing the third syntax element identification message into the code stream.

34. The method according to claim 32, wherein, The current sequence usage range extension includes: the current sequence satisfies at least one of the following: high bit width, high quality, high bit rate, high frame rate, and lossless compression.

35. The method according to claim 29, wherein, The determination of the first syntax element identifier message includes: if the current sequence allows flipping using the last non-zero coefficient position, then the value of the first syntax element identifier message is determined to be a first value; or, if the current sequence does not allow flipping using the last non-zero coefficient position, then the value of the first syntax element identifier message is determined to be a second value.

36. The method according to request item 35, wherein, The method further includes: writing the first syntax element identification message into the code stream.

37. The method according to claim 29, wherein, The step of determining the last non-zero coefficient position flip flag message of the current slice includes: if the current slice block uses the last non-zero coefficient position flip, then the value of the last non-zero coefficient position flip flag message is determined to be a first value; or, if the current slice block does not use the last non-zero coefficient position flip, then the value of the last non-zero coefficient position flip flag message is determined to be a second value.

38. The method according to claim 29, wherein, The components include at least one of the following: a first image component, a second image component, and a third image component; wherein the first image component is a luminance component, the second image component is a first chrominance component, and the second image component is a second chrominance component; or, the first image component is a red component, the second image component is a green component, and the third image component is a blue component.

39. The method according to request item 38, wherein, When the components include a first image component, a second image component, and a third image component, the method further includes: if the first image component, the second image component, and the third image component of the current slice all share a single last non-zero coefficient position flip flag message, then the number of last non-zero coefficient position flip flag messages in the current slice is 1; or, if two of the first image component, the second image component, and the third image component of the current slice share a single last non-zero coefficient position flip flag message, then the number of last non-zero coefficient position flip flag messages in the current slice is 2; or, if the first image component, the second image component, and the third image component of the current slice each use a single last non-zero coefficient position flip flag message, then the number of last non-zero coefficient position flip flag messages in the current slice is 3.

40. The method according to request item 38, wherein, The step of determining the last non-zero coefficient position flip flag message of the current slice includes: determining the first last non-zero coefficient position flip flag message of the current slice; correspondingly, the method further includes: if the first image component, the second image component and the third image component of the current slice are all flipped using the last non-zero coefficient position, then the value of the first last non-zero coefficient position flip flag message is determined to be a first value.

41. The method according to request item 38, wherein, The step of determining the last non-zero coefficient position flip flag message of the current slice includes: determining a second last non-zero coefficient position flip flag message and a third last non-zero coefficient position flip flag message of the current slice; correspondingly, the method further includes: if two of the first image component, the second image component, and the third image component of the current slice are flipped using the last non-zero coefficient position, then the value of the second last non-zero coefficient position flip flag message is determined to be a first value; if the remaining image components of the current slice other than the two image components are flipped using the last non-zero coefficient position, then the value of the third last non-zero coefficient position flip flag message is determined to be a first value.

42. The method according to request item 38, wherein, The step of determining the last non-zero coefficient position flip flag message of the current slice includes: determining the fourth, fifth, and sixth last non-zero coefficient position flip flag messages of the current slice; correspondingly, the method further includes: if the first image component of the current slice uses the last non-zero coefficient position flip, then determining the value of the fourth last non-zero coefficient position flip flag message to be a first value; if the second image component of the current slice uses the last non-zero coefficient position flip, then determining the value of the fifth last non-zero coefficient position flip flag message to be a first value; if the third image component of the current slice uses the last non-zero coefficient position flip, then determining the value of the sixth last non-zero coefficient position flip flag message to be a first value.

43. The method according to request item 37, wherein, The position of the last non-zero coefficient includes the initial horizontal and initial vertical coordinates of the last non-zero coefficient, which are the horizontal and vertical distances between the position of the last non-zero coefficient and the upper left corner of the current block. Correspondingly, determining the coordinate information of the last non-zero coefficient of the current block based on the position flip flag message and the position of the last non-zero coefficient includes: if the value of the position flip flag message is a first value, then the coordinate information of the last non-zero coefficient is determined by calculation based on the initial horizontal and initial vertical coordinates of the last non-zero coefficient; or, if the value of the position flip flag message is a second value, then the coordinate information of the last non-zero coefficient is directly determined based on the initial horizontal and initial vertical coordinates of the last non-zero coefficient.

44. The method according to claim 43, wherein, The step of calculating and determining the coordinate information of the last non-zero coefficient based on the initial horizontal and initial vertical coordinates of the last non-zero coefficient includes: determining the width and height of the current block; subtracting the width of the current block from the initial horizontal coordinate of the last non-zero coefficient to obtain the horizontal coordinate of the last non-zero coefficient; subtracting the height of the current block from the initial vertical coordinate of the last non-zero coefficient to obtain the vertical coordinate of the last non-zero coefficient; and determining the coordinate information of the last non-zero coefficient based on the horizontal and vertical coordinates of the last non-zero coefficient.

45. The method according to claim 43, wherein, The method further includes: if the value of the last non-zero coefficient position flip flag message is a first value, then the coordinate message of the last non-zero coefficient is determined to be the horizontal and vertical distance between the position of the last non-zero coefficient and the lower right corner of the current block; or, if the value of the last non-zero coefficient position flip flag message is a second value, then the coordinate message of the last non-zero coefficient is the horizontal and vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block.

46. ​​The method according to claim 29, wherein, Writing the coordinate information of the last non-zero coefficient into the bitstream includes: determining the first code information of the horizontal coordinate of the last non-zero coefficient, the first code information of the vertical coordinate of the last non-zero coefficient, the last code information of the horizontal coordinate of the last non-zero coefficient, and the last code information of the vertical coordinate of the last non-zero coefficient in the current block based on the coordinate information of the last non-zero coefficient; and writing the first code information of the horizontal coordinate of the last non-zero coefficient, the first code information of the vertical coordinate of the last non-zero coefficient, the last code information of the horizontal coordinate of the last non-zero coefficient, and the last code information of the vertical coordinate of the last non-zero coefficient into the bitstream.

47. The method according to claim 29, wherein, When the third syntax element identification message indicates that the current sequence uses an expanded range, the method further includes: determining the last coefficient enable identifier message of the current block; when the last coefficient enable identifier message indicates that the current block uses the last coefficient position, encoding all coefficients before the last coefficient position according to a preset scanning order, and writing the encoded bit information and the last coefficient enable identifier message into the bit stream.

48. The method according to request item 47, wherein, The step of determining the last coefficient enable flag message of the current block includes: if the current block uses the last coefficient position, then determining the value of the last coefficient enable flag message to be a first value; or, if the current block does not use the last coefficient position, then determining the value of the last coefficient enable flag message to be a second value.

49. The method according to claim 47, wherein, The last coefficient position is the bottom right corner of the matrix formed by all possible non-zero coefficients in the current block; or, the last coefficient position is the last position of the current block when it scans all possible non-zero coefficients according to a preset scanning sequence.

50. The method according to claim 47, wherein, The method further includes setting the position of the last non-zero coefficient at the last coefficient position.

51. The method according to request item 47, wherein, The method further includes: determining the width and height of the current block after a preset operation; calculating coordinates based on the width and height of the transformation block to obtain the lower right corner coordinate information of the transformation block; and determining the position of the last coefficient based on the lower right corner coordinate information of the transformation block.

52. The method according to request item 51, wherein, The preset operations include at least the following: forced zero-out operation.

53. The method according to request item 51, wherein, The method further includes: when the position of the last non-zero coefficient is set at the last coefficient position, determining the position of the last non-zero coefficient according to the coordinate information of the lower right corner of the transform block.

54. The method according to request item 47, wherein, When the last coefficient enable flag message indicates that the current block does not use the position of the last coefficient, the method further includes: determining the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient; determining the position of the last non-zero coefficient based on the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient; encoding all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and writing the first code message of the horizontal coordinate of the last non-zero coefficient, the first code message of the vertical coordinate of the last non-zero coefficient, the last code message of the horizontal coordinate of the last non-zero coefficient, and the last code message of the vertical coordinate of the last non-zero coefficient into the code stream.

55. The method according to request item 29, wherein, When the third syntax element identification message indicates that the current sequence uses an expanded range, the method further includes: determining the sub-block preset encoding identification message of the sub-block to be encoded within the current block; when the sub-block preset encoding identification message indicates that the sub-block to be encoded has a preset encoding, encoding all coefficients within the sub-block to be encoded, and writing the encoded bit information and the sub-block preset encoding identification message into the bitstream.

56. The method according to request item 55, wherein, The method further includes: when the sub-block preset encoding identifier message indicates that the sub-block to be encoded does not have a preset encoding, determining the sub-block encoding identifier message of the sub-block to be encoded, and writing the sub-block encoding identifier message into the bitstream.

57. The method according to request item 55, wherein, The step of determining the preset encoding identifier message of the sub-block to be encoded includes: if the sub-block to be encoded has a preset encoding, then the value of the preset encoding identifier message is determined to be a first value; or, if the sub-block to be encoded does not have a preset encoding, then the value of the preset encoding identifier message is determined to be a second value.

58. The method according to request item 56, wherein, The step of determining the sub-block encoding identifier message of the sub-block to be encoded includes: if encoding is required in the sub-block, then the value of the sub-block encoding identifier message is determined to be a first value; or, if all coefficients in the sub-block are zero, then the value of the sub-block encoding identifier message is determined to be a second value.

59. The method according to any one of claims 30, 32, 35, 37, 48, 57 and 58, wherein, The first value is 1, and the second value is 0.

60. A bitstream, wherein, The bitstream is generated by bit encoding based on the message to be encoded, which includes at least one of the following: a first syntax element identifier message, a second syntax element identifier message, a third syntax element identifier message, a last non-zero coefficient position flip identifier message, a last coefficient enable identifier message, and a sub-block preset encoding identifier message; wherein, the first syntax element identifier message is used to indicate whether the current sequence allows the use of the last non-zero coefficient position flip, the second syntax element identifier message is used to indicate whether the current sequence uses the standard extended version, the third syntax element identifier message is used to indicate whether the current sequence uses range extension, the last non-zero coefficient position flip identifier message is used to indicate whether the current block uses the last non-zero coefficient position flip, the last coefficient enable identifier message is used to indicate whether the current block uses the last coefficient position, and the sub-block preset encoding identifier message is used to indicate whether the sub-block to be encoded within the current block is preset encoded; wherein, the current sequence includes the current slice, and the current slice includes the current block.

61. An encoder, the encoder comprising a first determining unit and an encoding unit; wherein, The first determining unit is configured to determine the last non-zero coefficient position flip flag message of the current slice, and to determine the position of the last non-zero coefficient of the current block corresponding to the block within the current slice; the first determining unit is further configured to determine the coordinate information of the last non-zero coefficient of the current block based on the last non-zero coefficient position flip flag message and the position of the last non-zero coefficient; the encoding unit is configured to encode all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and write the encoded bit information, the last non-zero coefficient position flip flag message, and the coordinate information of the last non-zero coefficient into the bitstream, wherein, The first determining unit is further configured to determine a first syntax element identification message; and when the first syntax element identification message indicates that the current sequence allows the use of the last non-zero coefficient position flip, perform the step of determining the last non-zero coefficient position flip identification message of the current slice; wherein the current sequence includes the current slice; and the first determining unit is further configured to determine a second syntax element identification message; and when the second syntax element identification message indicates that the current sequence uses the standard extended version, determine a third syntax element identification message; and when the third syntax element identification message indicates that the current sequence uses the range extension, perform the step of determining the first syntax element identification message.

62. An encoder, the encoder comprising a first memory and a first processor; wherein, The first memory is used to store a computer program that can run on the first processor; the first processor is used to execute the method described in any one of claims 29 to 59 when running the computer program.

63. A decoder, the decoder comprising a parsing unit and a determining unit; wherein, The parsing unit is configured to parse the bitstream, determine the last non-zero coefficient position flip flag message of the current slice, and determine the coordinate message of the last non-zero coefficient of the current block corresponding to the current intra-slice block; the second determining unit is configured to perform calculations on the coordinate message of the last non-zero coefficient when the last non-zero coefficient position flip flag message indicates that the current intra-slice block uses the last non-zero coefficient position flip to obtain the position of the last non-zero coefficient of the current block; the parsing unit is further configured to decode all coefficients before the position of the last non-zero coefficient according to a preset scanning order to determine the coefficients of the current block, wherein the method further includes: the parsing unit is further configured to parse the bitstream to determine the first syntax element identification message; The second determining unit is further configured to, when the first syntax element identification message indicates that the current sequence allows the use of the last non-zero coefficient position flip, execute the parsing bitstream to determine the last non-zero coefficient position flip identification message of the current slice; wherein the current sequence includes the current slice; and the parsing unit is further configured to, parse the bitstream to determine the second syntax element identification message; and when the second syntax element identification message indicates that the current sequence uses the standard extended version, parse the bitstream to determine the third syntax element identification message; and when the third syntax element identification message indicates that the current sequence uses the range extension, execute the parsing bitstream to determine the first syntax element identification message.

64. A decoder, the decoder comprising a second memory and a second processor; wherein, The second memory is used to store a computer program that can run on the second processor; the second processor is used to execute the method described in any one of claims 1 to 28 when running the computer program.

65. A computer storage medium, wherein, The computer storage medium stores a computer program that, when executed, implements the method described in any one of claims 1 to 28, or the method described in any one of claims 29 to 59.

66. A computer storage medium, wherein, The computer storage medium stores a computer program and a bitstream, and when the computer program is executed by a processor, it implements the steps of the encoding method as described in any one of requests 29 to 59 to generate the bitstream.

Citation Information

Patent Citations

  • Coding position data for the last non-zero transform coefficient in a coefficient group

    CN104469378A

  • Encoding device, decoding device, and encoding and decoding method thereof

    CN108353179A