Coefficient encoding / decoding method, encoder, decoder, and computer storage medium
Patent Information
- Authority / Receiving Office
- RS · RS
- Patent Type
- Patents
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2021-04-12
- Publication Date
- 2026-05-29
Abstract
Description
Coefficient encoding and decoding method, encoder, decoder and computer storage medium Technical Field
[0001] The embodiments of the present application relate to the field of video coding and decoding technology, and in particular to a coefficient coding and decoding method, an encoder, a decoder, and a computer storage medium. Background Art
[0002] As demand for video display quality increases, computer vision and related fields are gaining increasing attention. In recent years, image processing technology has been successfully applied across various industries. In the video encoding and decoding process, at the encoder, the image data to be encoded undergoes transformation and quantization, followed by compression encoding via an entropy coding unit. The resulting bitstream is then transmitted to the decoder. The bitstream is then parsed, and after dequantization and inverse transformation, the original input image data can be restored.
[0003] Currently, high-bitwidth, high-quality, and high-bitrate video codecs (referred to as "three-high video") typically require more and larger coefficients than lower-bitwidth, lower-quality, and lower-bitrate video codecs (referred to as "conventional video"). Consequently, existing solutions for these high-bitrate video may incur greater overhead, generate waste, and even affect codec speed and throughput.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide a coefficient encoding and decoding method, an encoder, a decoder, and a computer storage medium, which can improve the coefficient encoding throughput and encoding and decoding speed in high-bitwidth, high-bitrate, high-quality or lossless video encoding and decoding scenarios, while also improving compression efficiency.
[0006] The technical solution of the embodiment of the present application can be implemented as follows:
[0007] In a first aspect, an embodiment of the present application provides a coefficient decoding method, applied to a decoder, the method comprising:
[0008] Parse the code stream and obtain video identification information;
[0009] When the video identification information indicates that the video meets the preset condition, the code stream is parsed to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient;
[0010] When the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, the coordinate information of the last non-zero coefficient is calculated to determine the position of the last non-zero coefficient;
[0011] All coefficients before the position of the last non-zero coefficient are decoded in a preset scanning order to determine the coefficients of the current block.
[0012] In a second aspect, an embodiment of the present application provides a coefficient encoding method, applied to an encoder, the method comprising:
[0013] Determine the video identification information and the position of the last non-zero coefficient;
[0014] When the video identification information indicates that the video meets a preset condition, determining the last non-zero coefficient position flip identification information;
[0015] Determine the coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information;
[0016] All coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the bit information, video identification information and coordinate information of the last non-zero coefficient obtained after encoding are written into the bit stream.
[0017] In a third aspect, an embodiment of the present application provides an encoder, which includes a first determining unit and an encoding unit; wherein,
[0018] A first determining unit is configured to determine video identification information and a position of the last non-zero coefficient; and when the video identification information indicates that the video meets a preset condition, determine the last non-zero coefficient position flip identification information;
[0019] The first determining unit is further configured to determine the coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information;
[0020] The encoding unit is configured to encode all coefficients before the position of the last non-zero coefficient in a preset scanning order, and write the encoded bit information, video identification information and coordinate information of the last non-zero coefficient into the bit stream.
[0021] In a fourth aspect, an embodiment of the present application provides an encoder, comprising a first memory and a first processor; wherein,
[0022] a first memory for storing a computer program capable of running on the first processor;
[0023] The first processor is configured to execute the method according to the second aspect when running a computer program.
[0024] In a fifth aspect, an embodiment of the present application provides a decoder, the decoder comprising a parsing unit and a second determining unit; wherein,
[0025] A parsing unit is configured to parse the code stream to obtain video identification information; and when the video identification information indicates that the video meets a preset condition, parse the code stream to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient;
[0026] a second determining unit configured to calculate the coordinate information of the last non-zero coefficient to determine the position of the last non-zero coefficient when the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip;
[0027] The parsing unit is further configured to decode all coefficients before the position of the last non-zero coefficient in a preset scanning order to determine the coefficients of the current block.
[0028] In a sixth aspect, an embodiment of the present application provides a decoder, the decoder comprising a second memory and a second processor; wherein,
[0029] a second memory for storing a computer program capable of running on the second processor;
[0030] The second processor is configured to execute the method according to the first aspect when running a computer program.
[0031] In a seventh aspect, an embodiment of the present application provides a computer storage medium storing a computer program, which, when executed, implements the method described in the first aspect or the method described in the second aspect.
[0032] The present invention provides a coefficient encoding and decoding method, an encoder, a decoder, and a computer storage medium. In the encoder, video identification information and the position of the last non-zero coefficient are determined. When the video identification information indicates that the video meets a preset condition, the last non-zero coefficient position flip identification information is determined. The coordinate information of the last non-zero coefficient is determined based on the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information. All coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the encoded bit information, video identification information, and the coordinate information of the last non-zero coefficient are written into a bitstream. In the decoder, the bitstream is parsed to obtain the video identification information. When the video identification information indicates that the video meets the preset condition, the bitstream is parsed to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient. When the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, the coordinate information of the last non-zero coefficient is calculated to determine the position of the last non-zero coefficient. All coefficients before the position of the last non-zero coefficient are decoded according to a preset scanning order to determine the coefficient of the current block. In this way, in high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding scenarios, since the coefficient distribution pattern is different from that of conventional video scenarios, the number of grammatical elements encoded in the context mode can be reduced or even eliminated in the coefficient encoding, such as the grammatical elements about the last non-zero coefficient position, sub-block coding identifier, etc., and even the coordinate transformation can be performed when the value of the coordinate information of the last non-zero coefficient is too large, thereby reducing the encoding overhead in the bitstream and improving the coefficient encoding throughput and encoding and decoding speed; in addition, since the reduced or eliminated grammatical elements have little impact on high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding, the compression efficiency can also be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] FIG1 is a schematic diagram of an application of a coding framework provided by related art;
[0034] FIG2 is a schematic diagram of the positional relationship between a current coefficient and adjacent coefficients provided by the related art;
[0035] FIG3 is a flow chart of a bin arithmetic decoding process provided by the related art;
[0036] FIG4 is a flow chart of an arithmetic decoding process of a binary symbol provided by the related art;
[0037] FIG5 is a schematic diagram of a renormalization process of an arithmetic decoding engine provided by the related art;
[0038] FIG6 is a schematic diagram of a flow chart of a bypass decoding process provided by the related art;
[0039] FIG7 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 zero, provided by the related art;
[0040] FIG8A is a schematic diagram of the system composition of an encoder provided in an embodiment of the present application;
[0041] FIG8B is a schematic diagram of the system composition of a decoder provided in an embodiment of the present application;
[0042] FIG9 is a schematic flow chart of a coefficient decoding method provided in an embodiment of the present application;
[0043] FIG10A 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 the present application;
[0044] FIG10B 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 the present application;
[0045] FIG11 is a schematic diagram of a flow chart of a coefficient encoding method provided in an embodiment of the present application;
[0046] FIG12 is a schematic diagram of the structure of an encoder provided in an embodiment of the present application;
[0047] FIG13 is a schematic diagram of a specific hardware structure of an encoder provided in an embodiment of the present application;
[0048] FIG14 is a schematic diagram of the structure of a decoder provided in an embodiment of the present application;
[0049] FIG15 is a schematic diagram of a specific hardware structure of a decoder provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below with reference to the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.
[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0052] In the following description, reference is 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, and third" in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understood that "first, second, and third" may be interchanged in a specific order or sequential order where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0053] In a video image, a first image component, a second image component, and a third image component are generally used to represent a coding block (CB); wherein the 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 video image can be represented in either the YCbCr format or the YUV format.
[0054] Before further explaining the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained first. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations:
[0055] Moving Picture Experts Group (MPEG)
[0056] International Standardization Organization (ISO)
[0057] International Electrotechnical Commission (IEC)
[0058] Joint Video Experts Team (JVET)
[0059] Alliance for Open Media (AOM)
[0060] Next-generation video coding standard H.266 / Versatile Video Coding (VVC)
[0061] VVC Test Model (VTM)
[0062] Audio Video Standard (AVS)
[0063] AVS High-Performance Model (HPM)
[0064] Context-based Adaptive Binary Arithmetic Coding (CABAC)
[0065] Regular Residual Coding (RRC)
[0066] Transform Skip Residual Coding (TSRC)
[0067] It is understandable that currently common video codec standards (such as VVC) all adopt a block-based hybrid coding framework. Each frame in a video image is divided into square Largest Coding Units (LCUs) of the same size (such as 128×128, 64×64, etc.). Each Largest Coding Unit can also be divided into rectangular Coding Units (CUs) according to rules; and Coding Units may also be divided into smaller Prediction Units (PUs) and Transform Units (TUs). 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 can include intra prediction and inter prediction, and inter prediction can include motion estimation and motion compensation. Since there is a strong correlation between adjacent pixels in a frame of a video image, the use of intra-frame prediction in video coding and decoding technology can eliminate the spatial redundancy between adjacent pixels; however, since there is also a strong similarity between adjacent frames in a video image, the use of inter-frame prediction in video coding and decoding technology can eliminate the temporal redundancy between adjacent frames, thereby improving coding and decoding efficiency.
[0068] The basic process of a video codec is as follows: In the encoder, a frame 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 prediction block is subtracted from the original block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix. This 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. The bitstream is decoded to obtain a quantization coefficient matrix. This 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, which is then subjected to image-based or block-based loop filtering to obtain the decoded image. The encoder also performs similar operations as the decoder to obtain the decoded image. The decoded image can serve as a reference frame for inter-frame prediction in subsequent frames. The block division information, prediction, transformation, quantization, entropy coding, loop filtering and other mode information or parameter information determined by the encoder need to be output to the bitstream if necessary; then the decoder determines the same block division information, prediction, transformation, quantization, entropy coding, loop filtering and other mode information or parameter information as the encoder through parsing and analysis based on the existing information, thereby ensuring that the decoded image obtained by the encoder and the decoded image obtained by the decoder are the same. The decoded image obtained by the encoder is usually also called a reconstructed image. During prediction, the current block can be divided into prediction units, and during transformation, the current block can be divided into transformation units. The division of prediction units and transformation units can be different. The above is the basic process of the video encoder and decoder under the block-based hybrid coding framework. With the development of technology, some modules or steps of the framework or process may be optimized. The embodiment of the present application is applicable to the basic process of the video codec under the block-based hybrid coding framework, but is not limited to the framework and process.
[0069] The current block (Current Block) may be a current coding unit (CU), a current prediction unit (PU), or a current transform block (TU), etc.
[0070] Among them, block division information, various modes and parameter information of prediction, transformation, and quantization, coefficients, etc. are written into the code stream through entropy coding. Assuming that the probabilities of different elements are different, shorter codewords are assigned to elements with a higher probability of occurrence, and longer codewords are assigned to elements with a lower probability of occurrence, which can achieve higher coding efficiency than fixed-length coding. However, if the probabilities of different elements are similar or basically the same, the compression space of entropy coding is limited. CABAC is a commonly used entropy coding method. HEVC and VVC both use CABAC for entropy coding. CABAC can use context models to improve compression efficiency, but the use and update of context models also make the operation more complicated. There is a bypass mode in CABAC. In bypass mode, the context model does not need to be used and updated, and a higher throughput can be achieved. In an embodiment of the present application, the mode in CABAC that requires the use and update of the context model can be called a context mode.
[0071] In general, it is necessary to first determine the context model according to the defined method, and when calling the arithmetic decoding process of the defined binary symbol, the parameters of the context model can be used as input. The selection of the context model also has dependencies between adjacent coefficients. For example, Figure 2 shows a schematic diagram of the positional relationship between a current coefficient and an adjacent coefficient provided by the relevant technology. In Figure 2, the black-filled block represents the current coefficient, and the grid-line-filled block represents the adjacent coefficient; as shown in Figure 2, which context model is selected for the sig_coeff_flag of the current coefficient needs to be determined based on the information of the 5 coefficients adjacent to its right, bottom, and lower right. It can be further seen from Figure 2 that the operation of the context mode is much more complicated than that of the bypass mode, and there is also a dependency between adjacent coefficients.
[0072] For the CABAC arithmetic coding engine, if context mode is used, the defined binary symbol arithmetic decoding process must be invoked, including state transitions, which are context model updates. The binary symbol arithmetic decoding process also invokes the arithmetic decoding engine's renormalization process. Using bypass mode also requires invoking the bypass decoding process.
[0073] The following is an example of using CABAC in VVC:
[0074] For the CABAC arithmetic coding engine, the input of the arithmetic decoding process is ctxTable, ctxIdx, bypassFlag, and the state variables ivlCurrRange and ivlOffset of the arithmetic decoding engine. The output of the arithmetic decoding process is the value of the bin.
[0075] Among them, ctxTable is the table used when selecting the context mode, and ctxIdx is the context model index.
[0076] Figure 3 shows a flowchart of a bin arithmetic decoding process provided by the related art. As shown in Figure 3, in order to decode the value of a bin, the context index table ctxTable, ctxIdx, bypassFlag are transmitted as input to the arithmetic decoding process DecodeBin(ctxTable, ctxIdx, bypassFlag), as follows:
[0077] If the value of bypassFlag is 1, the bypass decoding process DecodeBypass() is called;
[0078] Otherwise, if the value of bypassFlag is 0, the value of ctxTable is 0, and the value of ctxIdx is 0, call DecodeTerminate();
[0079] Otherwise (the value of bypassFlag is 0 and the value of ctxTable is not 0), the arithmetic decoding process of the defined binary symbol DecodeDecision(ctxTable, ctxIdx) is called.
[0080] Further, for the arithmetic decoding process of binary symbols, 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.
[0081] Figure 4 shows a schematic flow chart of an arithmetic decoding process of a binary symbol provided by the related art. As shown in Figure 4 , pStateIdx0 and pStateIdx1 are two states of the current context model.
[0082] (1) The value of the variable ivlLpsRange is derived as follows:
[0083] Given the current value of ivlCurrRange, the variable qRangeIdx is derived as follows:
[0084] qRangeIdx=ivlCurrRange>>5
[0085] Given qRangeIdx, ctxTable and pStateIdx0 and pStateIdx1 corresponding to ctxIdx, valMps and ivlLpsRange are derived as follows:
[0086] pState=pStateIdx1+16×pStateIdx0;
[0087] valMps = pState>>14;
[0088] ivlLpsRange=(qRangeIdx×((valMps?32767–pState:pState)>>9)>>1)+4.
[0089] (2) Set the value of the variable ivlCurrRange to ivlCurrRange – ivlLpsRange and perform the following operations:
[0090] If ivlOffset is greater than or equal to ivlCurrRange, then the value of the variable binVal is 1–valMps, the value of ivlOffset is ivlOffset minus ivlCurrRange, and the value of ivlCurrRange is ivlLpsRange;
[0091] Otherwise (ivlOffset is less than ivlCurrRange), the value of the variable binVal is valMps.
[0092] Given the value of binVal, the defined state transition is performed. Based on the current value of ivlCurrRange, the defined renormalization can be performed.
[0093] Furthermore, for the state transition process, the input is the current pStateIdx0 and pStateIdx1, and the solved value binVal; the output is the updated ctxTable and context variables pStateIdx0 and pStateIdx1 corresponding to ctxIdx. Among them, the variables shift0 and shift1 are derived from shiftIdx. Here, the corresponding relationship between shiftIdx, ctxTable, and ctxIdx is defined as follows:
[0094] shift0=(shiftIdx>>2)+2;
[0095] shift1=(shiftIdx&3)+3+shift0.
[0096] Based on the solved value binVal, the two variables pStateIdx0 and pStateIdx1 corresponding to ctxTable and ctxIdx are updated as follows:
[0097] pStateIdx0=pStateIdx0-(pStateIdx0>>shift0)+(1023×binVal>>shift0);
[0098] pStateIdx1=pStateIdx1-(pStateIdx1>>shift1)+(16383×binVal>>shift1).
[0099] Furthermore, the input of the renormalization process of the arithmetic decoding engine is the bits in the slice data and the variables ivlCurrRange and ivlOffset, and the output is the updated variables ivlCurrRange and ivlOffset.
[0100] FIG5 shows a schematic diagram of a renormalization process of an arithmetic decoding engine provided by the related art. As shown in FIG5 , the current value of ivlCurrRange is first compared with 256, and the subsequent steps are as follows:
[0101] If ivlCurrRange is greater than or equal to 256, no renormalization is required and the RenormD process ends;
[0102] Otherwise (ivlCurrRange is less than 256), enter the renormalization loop. In this loop, the value of ivlCurrRange is multiplied by 2, that is, it is shifted left by one bit. The value of ivlOffset is multiplied by 2, that is, it is shifted left by one bit. The bit obtained by read_bits(1) is transferred to ivlOffset.
[0103] During this process, the data in the codestream should not cause ivlOffset to be greater than or equal to ivlCurrRange.
[0104] Furthermore, the input of 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 decoded value binVal.
[0105] When bypassFlag is 1, the bypass decoding process is called. FIG6 shows a flowchart of a bypass decoding process provided by the related art. As shown in FIG6, the value of ivlOffset is first multiplied by 2, that is, it is shifted left by one bit. The bit obtained by read_bits(1) is shifted into ivlOffset. The value of ivlOffset is then compared with the value of ivlCurrRange. The subsequent steps are as follows:
[0106] If ivlOffset is greater than or equal to ivlCurrRange, then the value of binVal is set to 1 and ivlOffset is equal to ivlOffsetivl minus CurrRange;
[0107] Otherwise (ivlOffset is less than ivlCurrRange), the value of binVal is set to 0.
[0108] During this process, the data in the codestream should not cause ivlOffset to be greater than or equal to ivlCurrRange.
[0109] It should also be understood that in the current video coding standards, one or more transforms and transform skips are usually supported for the residual. Transforms include Discrete Cosine Transform (DCT), etc. The residual block using the transform usually exhibits certain characteristics after transformation (and quantization). For example, after certain transformations (and quantization), the energy is mostly concentrated in the low-frequency area, resulting in larger coefficients in the upper left corner and smaller coefficients in the lower right corner, or even many zero coefficients. Transform skipping, as the name implies, does not perform transformation. The distribution pattern of the coefficients after the transform skip is different from that after the transform, so different coefficient encoding methods can be used. For example, in VVC, RRC is used for the coefficients after the transform skip, and TSRC is used for the coefficients after the transform skip.
[0110] In a typical transform, such as the DCT, the frequencies of the transformed block are ranked 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. Taking advantage of this characteristic, some high-frequency information can be processed more extensively or removed with less visual impact. Techniques, such as zero-out, can force certain high-frequency information to zero. For example, for a 64x64 block, coefficients with a horizontal coordinate greater than or equal to 32 or a vertical coordinate greater than or equal to 32 are forced to zero. This is just a simple example; the zero-out range can be derived in more complex ways, which will not be detailed here. As shown in Figure 7, the upper left corner may contain non-zero coefficients (i.e., a possible non-zero coefficient area), while the lower right corner is set to all zeros (i.e., a forced zero area). Therefore, for subsequent coefficient coding, the coefficients in the zero-out area are guaranteed to be zero and do not need to be encoded.
[0111] Furthermore, because the coefficient distribution of typical video residuals after transformation (and quantization) exhibits a characteristic of larger coefficients in the upper left corner and many zero coefficients in the lower right corner, coefficient encoding often employs methods to ensure that coefficients within a certain range in the upper left corner are encoded, while coefficients within a certain range in the lower right corner are not encoded, that is, these coefficients are defaulted to 0. One method is to first determine the position of the last non-zero coefficient in the block in scan order when encoding the coefficients of the block. After determining this position, all coefficients following the last non-zero coefficient in scan order are assumed to be 0 and do not need to be encoded; only the coefficients before and after the last non-zero coefficient need to be encoded. For example, in VVC, the 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).
[0112] (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.
[0113] If last_sig_coeff_x_prefix does not exist, then the value of last_sig_coeff_x_prefix is 0.
[0114] (b) last_sig_coeff_y_prefix determines the prefix of the vertical (or row) coordinate of the last non-zero coefficient in 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.
[0115] If last_sig_coeff_y_prefix does not exist, then the value of last_sig_coeff_y_prefix is 0.
[0116] (c) last_sig_coeff_x_suffix determines the suffix of the horizontal (or column) coordinate of the last non-zero coefficient in the current block in scanning 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, including these two boundary values.
[0117] The value LastSignificantCoeffX of the horizontal (or column) coordinate of the last non-zero coefficient in the scan order in the current transform block is derived as follows:
[0118] If last_sig_coeff_x_suffix does not exist, then
[0119] LastSignificantCoeffX=last_sig_coeff_x_prefix;
[0120] Otherwise (last_sig_coeff_x_suffix exists),
[0121] LastSignificantCoeffX=(1<<((last_sig_coeff_x_prefix>>1)-1))*(2+(last_sig_coeff_x_prefix&1))+
[0122] last_sig_coeff_x_suffix.
[0123] (d) last_sig_coeff_y_suffix determines the suffix of the vertical (or row) coordinate of the last non-zero coefficient in the scan order in the current transform block. 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, including these two boundary values.
[0124] The value LastSignificantCoeffY of the vertical (or row) coordinate of the last non-zero coefficient in the scan order in the current transform block is derived as follows:
[0125] If last_sig_coeff_y_suffix does not exist, then
[0126] LastSignificantCoeffY=last_sig_coeff_y_prefix;
[0127] Otherwise (last_sig_coeff_y_suffix exists),
[0128] LastSignificantCoeffY=(1<<((last_sig_coeff_y_prefix>>1)-1))*(2+(last_sig_coeff_y_prefix&1))+last_sig_coeff_y_suffix.
[0129] Furthermore, the last non-zero coefficient and all coefficients before it must be encoded. However, in normal video, even a certain proportion of these coefficients are still zero. VVC uses the flag sb_coded_flag to determine whether the coefficients in the current sub-block need to be encoded. If encoding is not required, the coefficients in the current sub-block are considered to be all zero. Here, the sub-block is usually an n×n sub-block, such as a 4×4 sub-block.
[0130] sb_coded_flag[xS][yS] determines the following information for the subblock at position (xS, yS) in the current transform block, where a subblock is an array of transform coefficient values:
[0131] 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;
[0132] If sb_coded_flag[xS][yS] does not exist, then the value of sb_coded_flag[xS][yS] is 1.
[0133] Furthermore, when processing coefficient encoding, the compression efficiency can be improved by utilizing the characteristics of the coefficients. For example, for ordinary videos, among the coefficients that need to be encoded, a certain proportion of the coefficients are 0, so a syntax element can be used to indicate whether the current coefficient is 0, and 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 current coefficient needs to be continued to be encoded. For another example, for ordinary videos, among the non-zero coefficients, a certain proportion of the coefficients have an absolute value of 1, so a syntax element can be used to indicate whether the absolute value of the current coefficient is greater than 1, and 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 current coefficient needs to be continued to be encoded. For example, the syntax elements involved in VVC are as follows,
[0134] sig_coeff_flag[xC][yC] is used to determine whether the corresponding transform coefficient at the transform coefficient position (xC, yC) of the current transform block is a non-zero coefficient:
[0135] If the value of sig_coeff_flag[xC][yC] is 0, then the value of the transform coefficient at the position (xC, yC) is set to 0;
[0136] Otherwise (the value of sig_coeff_flag[xC][yC] is 1), the transform coefficient at the position (xC, yC) is a non-zero coefficient.
[0137] If sig_coeff_flag[xC][yC] does not exist, then make the following inferences:
[0138] If the value of transform_skip_flag[x0][y0][cIdx] is 0 or the value of sh_ts_residual_coding_disabled_flag is 1: <>
[0139] If (xC, yC) is the position of the last non-zero coefficient (LastSignificantCoeffX, LastSignificantCoeffY) in scan order or all of the following conditions are true, then the value of sig_coeff_flag[xC][yC] is inferred to be 1:
[0140] (xC & ((1 << log2SbW) - 1), yC & (({1 << log2SbH}) + 1)) is equal to (0, 0);
[0141] The value of inferSbDcSigCoeffFlag is equal to 1;
[0142] The value of sb_coded_flag[xS][yS] is 1;
[0143] Otherwise, the value of sig_coeff_flag[xC][yC] is inferred to be 0; I
[0144] Otherwise (the value of transform_skip_flag[x0][y0][cIdx] is 1 and the value of sh_ts_residual_coding_disabled_flag is 0):
[0145] [[ID=]]33If all of the following conditions are true, then the value of sig_coeff_flag[xC][yC] is inferred to be 1:
[0146] It should be noted that there seems to be an error in the expression in line . It should be "yC & ((1 << log2SbH) - 1)" instead of "yC & (({1 << log2SbH}) + 1)". The above translation is based on the corrected understanding. If there are other specific requirements or corrections, please let me know.(xC & ((1 << log2SbW) - 1), yC & ((1 << log2SbH) - 1)) is equal to ((1 <<
[0147] log2SbW) - 1, (1 << log2SbH) - 1);
[0148] The value of inferSbSigCoeffFlag is 1;
[0149] The value of sb_coded_flag[xS][yS] is 1;
[0150] Otherwise, the value of sig_coeff_flag[xC][yC] is inferred to be 0.
[0151] abs_level_gtx_flag[n][j] is used to determine whether the absolute value of the transform coefficient (the n-th 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.
[0152] In this way, if the current coefficient has not been encoded completely after processing the above flags (or called syntax elements), then the remaining value of the absolute value of the coefficient needs to be encoded. Such as abs_remainder in VVC.
[0153] abs_remainder[n] is used to determine the remaining absolute value of the n-th transform coefficient in the scan order encoded by Golomb - Rice. If abs_remainder[n] does not exist, then the value of abs_remainder[n] is 0.
[0154] Furthermore, in VVC, syntax elements such as sig_coeff_flag and abs_level_gtx_flag are encoded using the context mode, while abs_remainder is encoded using the bypass mode. As mentioned above, the context mode encoding is more complex than the bypass mode encoding, and intuitively it is slower to process. If there are many coefficients to be encoded, using too many context mode encodings will affect the decoding speed. Therefore, the number of syntax elements encoded using the context mode can be restricted. For example, when the number of binary symbols encoded using the context mode exceeds a threshold, the subsequent coefficient encoding is forced to use the bypass mode encoding. Such as dec_abs_level in VVC.
[0155] dec_abs_level[n] is an intermediate value encoded with Golomb-Rice at scan position n. When parsing dec_abs_level[n], ZeroPos[n] can be derived. The absolute value of the quantized coefficient at position (xC, yC), AbsLevel[xC][yC], is derived as follows:
[0156] 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;
[0157] 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;
[0158] Otherwise (the value of dec_abs_level[n] is greater than ZeroPos[n]), the value of AbsLevel[xC][yC] is dec_abs_level[n].
[0159] The above mentioned values are all absolute values of coefficients. The sign of non-zero coefficients can be determined using the coefficient sign flag coeff_sign_flag or some other sign derivation method. coeff_sign_flag[n] can determine the sign of the transform coefficient at scan position n as follows:
[0160] If the value of coeff_sign_flag[n] is 0, the corresponding transform coefficient is positive;
[0161] Otherwise (the value of coeff_sign_flag[n] is 1), the corresponding transform coefficient is a negative value.
[0162] 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 transform coefficient at the coordinate (xC, yC) is determined according to CoeffSignLevel[xC][yC]:
[0163] If the value of CoeffSignLevel[xC][yC] is 0, then the corresponding transform coefficient is 0;
[0164] Otherwise, if the value of CoeffSignLevel[xC][yC] is 1, the corresponding transform coefficient is positive; otherwise (the value of CoeffSignLevel[xC][yC] is -1), the corresponding transform coefficient is negative.
[0165] It should also be noted that CoeffSignLevel[xC][yC] can also be derived using other methods, which will not be repeated here.
[0166] In addition, VVC also uses a coefficient parity flag par_level_flag. This flag can be used to determine the parity of the current coefficient value and is used in determining the current coefficient value and dependent quantization.
[0167] par_level_flag[n] determines the parity of the transform coefficient at position n in scan order. If par_level_flag[n] does not exist, then the value of par_level_flag[n] is 0.
[0168] In addition to determining the parity of the transform coefficient, par_level_flag can also be used together with abs_level_gtx_flag, abs_remainder, etc. to determine the size of the coefficient.
[0169] Since context mode coding requires selecting, using, and updating a context mode, while bypass mode coding does not, a common practice is to group context mode coded syntax elements together with bypass mode coded syntax elements within a certain range. This is more user-friendly for hardware design. For example, all context mode coded syntax elements in a block are processed first, followed by bypass mode coded syntax elements. All context mode coded syntax elements in the current block may be further divided into several groups, and all bypass mode coded syntax elements in a block may be further divided into several groups.
[0170] In a specific example, the specific syntax of RRC is shown in Table 1.
[0171] Table 1
[0172]
[0173]
[0174]
[0175]
[0176]
[0177] 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 indices xC and yC of the arrays represent the (xC, yC) position in the current transform block.
[0178] After entering the residual_coding(x0, y0, log2TbWidth, log2TbHeight, cIdx) function, it is necessary to determine some information about the block size, such as determining the logarithms log2ZoTbWidth and log2ZoTbHeight of the block size after zero-out. The coefficients with the abscissa in the range [0, (1<<log2ZoTbWidth)–1] and the ordinate 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, determine the position of the last non-zero coefficient according to last_sig_coeff_x_prefix, last_sig_coeff_y_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_suffix, etc. The coefficients before the last non-zero coefficient in the scan order may be non-zero coefficients. Then, determine the value of remBinsPass1, that is, use the equation remBinsPass1 = ((1<<(log2TbWidth+log2TbHeight))×7)>>2 to determine. remBinsPass1 determines the number of syntax elements encoded using the context mode in the current block. In the embodiments of this application, remBinsPass1 can be understood as the meaning of remaining binaries inpass1, that is, the number of remaining binary symbols in the first round. The coefficients before the last non-zero coefficient in the scan order need to be encoded. For the sub-blocks where these coefficients are located, it is determined in turn whether the current sub-block needs to be encoded. If it needs to be encoded, in this method, the syntax elements encoded using the context mode in a sub-block are placed in the first round, and the syntax elements encoded using the bypass mode are placed later. Each coefficient may need to process up to 4 syntax elements encoded using the context mode: 1 sig_coeff_flag, 2 abs_level_gtx_flag, and 1 par_level_flag. In the first round, each time a syntax element encoded using the context mode is processed, remBinsPass1 will be decremented by 1. If a coefficient is large enough, after processing several syntax elements encoded using the context mode in the first round, the remaining value, that is, abs_remainder, needs to be processed. And if remBinsPass1 is small enough (not satisfying remBinsPass1 >= 4), the first round will end, and the remaining coefficients will be directly processed using the bypass mode, that is, dec_abs_level.
[0179] In another specific example, the specific syntax of TSRC is shown in Table 2.
[0180] Table 2
[0181]
[0182]
[0183]
[0184] After entering the residual_ts_coding(x0, y0, log2TbWidth, log2TbHeight, cIdx) function, it is necessary to determine some block size information. Then determine the value of RemCcbs, that is, use the equation RemCcbs = ((1<<(log2TbWidth+log2TbHeight))×7)>>2 to determine. RemCcbs determines the number of grammatical elements using context mode coding in the current block. The embodiment of the present application can understand RemCcbs as the meaning of remaining context coded binaries, that is, the number of remaining context mode coded binary symbols. For each sub-block, determine whether the current sub-block needs to be encoded. If encoding is required, unlike the above-mentioned RRC, the TSRC method puts the context mode coded grammatical elements in a sub-block in two rounds, and each coefficient processes up to 4 context mode coded grammatical elements in the first and second rounds respectively. The grammatical elements coded in bypass mode are placed at the end. In the first and second rounds, remBinsPass1 is decremented after each context mode coded syntax element is processed. If a coefficient is large enough, the remaining value (abs_remainder) needs to be processed after the first and second rounds have processed several context mode coded syntax elements. If remBinsPass1 is small enough (not satisfying remBinsPass1 >= 4), the first two rounds are terminated, and the remaining coefficients are processed directly in bypass mode, again using abs_remainder.
[0185] In short, in the relevant technology, the existing coefficient coding method has good compression efficiency for currently commonly used videos, such as consumer videos. Consumer videos usually have a bit width of 8 or 10 bits per pixel, and the bit rate of consumer videos is usually not too high, usually a few megabits per second (MB / s) or lower. However, the pixels of videos for some applications require a higher bit width, such as a bit width of 12 bits, 14 bits, or 16 bits or more per pixel. A higher bit width usually results in larger coefficients and more non-zero coefficients, which in turn results in a higher bit rate. Some applications require higher quality videos, and higher quality usually also results in larger coefficients and more non-zero coefficients, which in turn results in a higher bit rate. A higher bit rate places higher demands on the processing capabilities of the decoder, such as throughput.
[0186] Videos with high bit width, high quality, and high bit rate ("three-high" video) typically require more and larger coefficients to be encoded and decoded than videos with low bit width, low quality, and low bit rate ("conventional" video). For example, the number of coefficients required for encoding and decoding in a block of "three-high" video is significantly greater than that required for encoding and decoding in a block of the same size in conventional video. This is because many coefficients in conventional video blocks become zero after prediction, transformation, and quantization, while many coefficients in "three-high" video blocks remain non-zero after prediction, transformation, and quantization. A large proportion of the coefficients required for encoding in conventional video blocks after prediction, transformation, and quantization are zero. Therefore, using the last non-zero coefficient position (LastSignificantCoeffX, LastSignificantCoeffY) is very effective in distinguishing coefficient regions that need to be encoded. Even coefficients before the last non-zero coefficient position still have a large proportion of zeros, making the use of the sub-block encoding flag (sb_coded_flag) very effective in further distinguishing whether the current sub-block needs to be encoded. However, when there are a large number of non-zero coefficients in the current block, or even when most or all coefficients are non-zero coefficients, the last non-zero coefficient position and the flag of whether the sub-block is encoded will not filter out too many non-zero coefficients. Moreover, encoding the non-zero coefficient position and the flag of whether the sub-block is encoded in the bitstream itself will take up a certain amount of overhead, which will result in waste.
[0187] On the other hand, the position of the last non-zero coefficient and the flag indicating whether the sub-block is encoded are all encoded using the context mode. Context mode encoding is more complex than bypass mode, and processing this information will also affect the speed and throughput of software and hardware encoding and decoding.
[0188] On the other hand, the current encoding method of the last non-zero coefficient position (LastSignificantCoeffX, LastSignificantCoeffY) is to encode the coordinates of the last non-zero coefficient position. In conventional videos, since the non-zero coefficients are mostly concentrated in the upper left corner and the large area in the lower right corner is 0, the values of LastSignificantCoeffX and LastSignificantCoeffY are usually small. In the three-high video, a large number of non-zero coefficients will also appear in the lower right corner, which leads to the values of LastSignificantCoeffX and LastSignificantCoeffY being usually large, so encoding larger values in the bitstream will bring greater overhead. In addition, there is also the possibility of using this method in lossless compression, because quantization cannot be used in lossless compression, and at this time the coefficients are usually more and larger. At this time, using existing related solutions may bring greater overhead, generate waste, and even affect the speed and throughput of encoding and decoding.
[0189] The present application provides a coefficient decoding method, which is applied to a decoder. The method includes parsing a bitstream to obtain video identification information; when the video identification information indicates that the video meets a preset condition, parsing the bitstream to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient; when the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, calculating the coordinate information of the last non-zero coefficient to determine the position of the last non-zero coefficient; and decoding all coefficients before the position of the last non-zero coefficient in a preset scanning order to determine the coefficients of the current block.
[0190] The present application also provides a coefficient encoding method, which is applied to an encoder. The method includes determining video identification information and the position of the last non-zero coefficient; when the video identification information indicates that the video meets a preset condition, determining the last non-zero coefficient position flip identification information; determining the coordinate information of the last non-zero coefficient based on the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information; encoding all coefficients before the position of the last non-zero coefficient in a preset scanning order, and writing the encoded bit information, video identification information, and the coordinate information of the last non-zero coefficient into a bitstream.
[0191] In this way, in high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding scenarios, since the coefficient distribution pattern is different from that of conventional video scenarios, the number of grammatical elements encoded in the context mode can be reduced or even eliminated in the coefficient encoding, such as the grammatical elements about the last non-zero coefficient position, sub-block coding identifier, etc., and even the coordinate transformation can be performed when the value of the coordinate information of the last non-zero coefficient is too large, thereby reducing the encoding overhead in the bitstream and improving the coefficient encoding throughput and encoding and decoding speed; in addition, since the reduced or eliminated grammatical elements have little impact on high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding, the compression efficiency can also be improved.
[0192] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0193] Refer to Figure 8A, which shows an example of a system composition block diagram of an encoder provided in an embodiment of the present 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 can be a video consisting of a series of pictures or a static picture, and the output of the encoder 100 can be a bitstream (also referred to as a "codestream") for representing a compressed version of the input video.
[0194] Among them, the segmentation unit 101 segments the picture in the input video into one or more Coding Tree Units (CTUs). The segmentation unit 101 divides the picture into multiple tiles (or 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. In addition, the segmentation unit 101 can form one or more slices, where a slice can include one or more tiles arranged in a grid order in the picture, or one or more tiles covering a rectangular area in the picture. The segmentation unit 101 can also form one or more sub-pictures, where a sub-picture can include one or more slices, tiles or bricks.
[0195] During the encoding process of encoder 100, segmentation unit 101 transmits the CTU to prediction unit 102. Generally, prediction unit 102 may be composed 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 iteratively uses quadtree segmentation, binary tree segmentation, and ternary tree segmentation to further divide the input CTU into smaller coding units (CUs). Prediction unit 102 may use ME unit 104 and MC unit 105 to obtain inter-frame prediction blocks for the CU. Intra-frame prediction unit 106 may use various intra-frame prediction modes, including MIP mode, to obtain intra-frame prediction blocks for the CU. In an example, a rate-distortion optimized motion estimation method may be used by ME unit 104 and MC unit 105 to obtain inter-frame prediction blocks, and a rate-distortion optimized mode determination method may be used by intra-frame prediction unit 106 to obtain intra-frame prediction blocks.
[0196] The prediction unit 102 outputs the prediction block of the CU, and the first adder 107 calculates the difference between the CU in the output of the segmentation unit 101 and the prediction block of the CU, i.e., the residual CU. The transform unit 108 reads the residual CU and performs one or more transform operations on the residual CU to obtain coefficients. The quantization unit 109 quantizes the coefficients and outputs the quantized coefficients (i.e., levels). The inverse quantization unit 110 performs a scaling operation on the quantized coefficients to output reconstructed coefficients. The inverse transform unit 111 performs one or more inverse transforms corresponding to the transform in the transform unit 108 and outputs the reconstructed residual. The second adder 112 calculates the reconstructed CU by adding the reconstructed residual and the prediction block of the CU from the prediction unit 102. The second adder 112 also sends its output to the prediction unit 102 for use as an intra-frame prediction reference. After all CUs in the picture or sub-picture are reconstructed, the 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 and chroma scaling (LMCS) filter, and a neural network-based filter. Alternatively, when the filtering unit 113 determines that a 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.
[0197] The output of the filtering unit 113 is a decoded picture or sub-picture, which is cached to the DPB unit 114. The DPB unit 114 outputs the decoded picture or sub-picture based on the timing and control information. Here, the picture 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 required for decoding the picture from the encoder 100 (such as control parameters and supplementary information, etc.) into binary form and writes this binary form into the code stream according to the syntax structure of each data unit. That is, the encoder 100 finally outputs the code stream.
[0198] Furthermore, encoder 100 can be a device having a first processor and a first memory storing a computer program. When the first processor reads and executes the computer program, encoder 100 reads the input video and generates a corresponding bitstream. Alternatively, encoder 100 can be a computing device having one or more chips. These units implemented as integrated circuits on the chip have similar connection and data exchange functions as the corresponding units in FIG8A .
[0199] Referring to Figure 8B , an example block diagram of a system composition of a decoder provided in an embodiment of the present application is shown. 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 picture buffer unit 209. Here, the input of the decoder 200 is a bitstream representing a compressed version of a video or a still picture, and the output of the decoder 200 may be a decoded video consisting of a series of pictures or a decoded still picture.
[0200] The input codestream to decoder 200 may be the codestream generated by encoder 100. Parsing unit 201 parses the input codestream and obtains syntax element values from the input codestream. Parsing unit 201 converts the binary representation of the syntax elements into digital values and sends the digital values to units within decoder 200 to obtain one or more decoded pictures. Parsing unit 201 may also parse one or more syntax elements from the input codestream to display decoded pictures.
[0201] During the decoding process of the decoder 200 , the parsing unit 201 sends the values of the syntax elements and one or more variables set or determined according to the values of the syntax elements and used to obtain one or more decoded pictures to the units in the decoder 200 .
[0202] The prediction unit 202 determines a prediction block for 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 the inter-frame decoding mode is indicated for decoding the current decoding block, the prediction unit 202 passes the relevant parameters from the parsing unit 201 to the motion compensation unit 203 to obtain an inter-frame prediction block; when the intra-frame prediction mode (including the MIP mode indicated based on the MIP mode index value) is indicated for decoding the current decoding block, the prediction unit 202 passes the relevant parameters from the parsing unit 201 to the intra-frame prediction unit 204 to obtain an intra-frame prediction block.
[0203] The inverse quantization unit 205 has the same function as the inverse quantization unit 110 in the encoder 100. The inverse quantization unit 205 performs a scaling operation on the quantization coefficients (ie, levels) from the parsing unit 201 to obtain reconstructed coefficients.
[0204] The inverse transform unit 206 has the same function as the inverse transform unit 111 in the encoder 100. The inverse transform unit 206 performs one or more transform operations (ie, inverse operations of one or more transform operations performed by the inverse transform unit 111 in the encoder 100) to obtain a reconstructed residual.
[0205] The adder 207 performs an addition operation on its input (the prediction block from the prediction unit 202 and the reconstructed residual from the inverse transform unit 206) to obtain a reconstructed block of the current decoded block. The reconstructed block is also sent to the prediction unit 202 to be used as a reference for other blocks encoded in the intra prediction mode.
[0206] After all CUs in the picture or sub-picture are reconstructed, the filtering unit 208 performs loop filtering on the reconstructed picture or sub-picture. The filtering unit 208 includes one or more filters, such as a deblocking filter, a sample adaptive offset filter, an adaptive loop filter, a luminance mapping and chroma scaling filter, and a neural network-based filter. Alternatively, when the filtering unit 208 determines that the 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 picture or sub-picture, which is cached to the DPB unit 209. The DPB unit 209 outputs the decoded picture or sub-picture based on timing and control information. The picture stored in the DPB unit 209 can also be used as a reference for performing inter-frame prediction or intra-frame prediction by the prediction unit 202.
[0207] Furthermore, the decoder 200 can 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 code stream and generates a corresponding decoded video. In addition, the decoder 200 can also be a computing device having one or more chips. These units implemented as integrated circuits on the chip have similar connection and data exchange functions as the corresponding units in Figure 8B.
[0208] It should also be noted that when the embodiment of the present application is applied to the encoder 100, the "current block" specifically refers to the current block to be encoded in the video image (which can also be simply referred to as the "encoding block"); when the embodiment of the present application is applied to the decoder 200, the "current block" specifically refers to the current block to be decoded in the video image (which can also be simply referred to as the "decoding block").
[0209] In one embodiment of the present application, referring to FIG9 , a flow chart of a coefficient decoding method provided by an embodiment of the present application is shown. As shown in FIG9 , the method may include:
[0210] S901: Parse the code stream and obtain video identification information.
[0211] It should be noted that the coefficient decoding method of the embodiment of the present application is applied to the decoder. Specifically, based on the structure of decoder 200 shown in Figure 8B, the coefficient decoding method of the embodiment of the present application is mainly applied to the "parsing unit 201" part of decoder 200. For parsing unit 201, adaptive binary arithmetic coding mode based on a context model or bypass mode can be used for decoding to obtain the value of relevant identification information (or syntax elements), and then determine the coefficients of the current block.
[0212] It should also be noted that the coefficient coding commonly referred to in video standards can include two parts: encoding and decoding. Therefore, coefficient coding includes the coefficient encoding method on the encoder side and the coefficient decoding method on the decoder side. The embodiments of this application describe the coefficient decoding method on the decoder side.
[0213] Under normal circumstances, such as for conventional videos, the coefficient decoding method is the same as the existing method in the related art; however, for certain situations, such as high-bit-width or high-quality or high-bit-rate or lossless compressed video encoding and decoding scenarios, the embodiment of the present application can modify the position derivation method of the last non-zero coefficient.
[0214] In the embodiment of the present application, it is first necessary to determine whether the current video meets the preset conditions, which can be represented by video identification information. In some embodiments, the parsing of the code stream to obtain the video identification information may include:
[0215] If the value of the video identification information is the first value, it is determined that the video identification information indicates that the video meets the preset condition; or,
[0216] If the value of the video identification information is the second value, it is determined that the video identification information indicates that the video does not meet the preset condition.
[0217] Here, the first value is 1 and the second value is 0.
[0218] It should be noted that, in another specific example, the first value can be set to true, and the second value can be set to false. In yet another specific example, the first value can be set to 0, and the second value can be set to 1; or, the first value can be set to false, and the second value can be set to true. This is not limited in any way.
[0219] It should also be noted that the preset conditions include at least one of the following: high bit width, high quality, high bit rate, high frame rate and lossless compression.
[0220] That is to say, compared with conventional videos, the videos described in the embodiments of the present application have the characteristics of high bit width, high quality, high bit rate, high frame rate and lossless compression.
[0221] Furthermore, the video identification information can be a sequence-level flag, or even a higher-level flag, such as Video Usability Information (VUI) and Supplemental Enhancement Information (SEI). Whether a video meets the preset conditions can be determined by determining whether the video meets the requirements of high bit width, high bit rate, high quality, or lossless compression. The following describes these four cases as examples.
[0222] In some embodiments, when the video identification information is high-bitwidth identification information, the method may further include:
[0223] If the high bit width identification information indicates that the video meets the high bit width, it is determined that the video meets the preset condition.
[0224] In some embodiments, when the video identification information is high bit rate identification information, the method may further include:
[0225] If the high bit rate identification information indicates that the video meets the high bit rate, it is determined that the video meets the preset condition.
[0226] In some embodiments, when the video identification information is high-quality identification information, the method may further include:
[0227] If the high-quality identification information indicates that the video meets high quality, it is determined that the video meets the preset condition.
[0228] In some embodiments, when the video identification information is lossless compression identification information, the method may further include:
[0229] If the lossless compression identification information indicates that the video satisfies lossless compression, it is determined that the video satisfies a preset condition.
[0230] Exemplarily, taking the sequence level as an example, the video identification information can be high-bit-width identification information (represented by sps_high_bit_depth_flag), which is used to indicate whether the current video sequence is a high-bit-width sequence; or it can be replaced by high-bit-rate identification information (represented by sps_high_bit_rate_flag), which is used to indicate whether the current video sequence is a high-bit-rate sequence; or it can be replaced by other identification information indicating high bit-width, high bit-rate, high quality or lossless compression, which is not specifically limited in the embodiments of the present application.
[0231] S902: When the video identification information indicates that the video meets a preset condition, parse the code stream to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient.
[0232] It should be noted that when the video identification information indicates that the video meets the preset conditions, the code stream can be further parsed to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient.
[0233] The coordinate information of the last non-zero coefficient may be determined by last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix. Therefore, in some embodiments, parsing the bitstream to obtain the coordinate information of the last non-zero coefficient may include:
[0234] Parse the bitstream to obtain the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient;
[0235] Determine the horizontal coordinate of the last non-zero coefficient according to the prefix information of the horizontal coordinate of the last non-zero coefficient and the suffix information of the horizontal coordinate of the last non-zero coefficient;
[0236] Determining the vertical coordinate of the last non-zero coefficient according to the prefix information of the vertical coordinate of the last non-zero coefficient and the suffix information of the vertical coordinate of the last non-zero coefficient;
[0237] Coordinate information of the last non-zero coefficient is determined according to the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.
[0238] It should be noted that the prefix information of the horizontal coordinate of the last non-zero coefficient is represented by last_sig_coeff_x_prefix, which determines the prefix of the horizontal (or column) coordinate of the last non-zero coefficient of the current block in the preset scanning order; the prefix information of the vertical coordinate of the last non-zero coefficient is represented by last_sig_coeff_y_prefix, which determines the prefix of the vertical (or row) coordinate of the last non-zero coefficient of the current block in the preset scanning order; the suffix information of the horizontal coordinate of the last non-zero coefficient is represented by last_sig_coeff_x_suffix, which determines the suffix of the horizontal (or column) coordinate of the last non-zero coefficient of the current block in the preset scanning order; the suffix information of the vertical coordinate of the last non-zero coefficient is represented by last_sig_coeff_y_suffix, which determines the suffix of the vertical (or row) coordinate of the last non-zero coefficient of the current block in the preset scanning order.
[0239] It should also be noted that last_sig_coeff_x_prefix and last_sig_coeff_x_suffix determine the abscissa (i.e. horizontal coordinate) of the last non-zero coefficient, and last_sig_coeff_y_prefix and last_sig_coeff_y_suffix determine the ordinate (i.e. vertical coordinate) of the last non-zero coefficient, thus obtaining the coordinate information of the last non-zero coefficient.
[0240] The last non-zero coefficient position flip flag information can be represented by reverse_last_sig_coeff_flag. In the embodiment of the present application, the last non-zero coefficient position flip flag information can be at least one of the following: sequence level, picture level, slice level, and block level; or even higher-level (such as VUI, SEI, etc.) flag information, which is not limited here.
[0241] That is, reverse_last_sig_coeff_flag may be a sequence-level or higher-level flag, or may be a picture-level flag, a slice-level flag, a block-level flag, or a flag at another level. In addition, the block-level flag may include a maximum coding unit (LCU)-level flag, a coding unit (CU)-level flag, or another block-level flag, which is not limited in any way in the embodiments of the present application.
[0242] In some embodiments, the method may further include:
[0243] If the value of the last non-zero coefficient position flipping identification information is the first value, it is determined that the last non-zero coefficient position flipping identification information indicates that the current block uses the last non-zero coefficient position flipping; or
[0244] If the value of the last non-zero coefficient position flipping identification information is the second value, it is determined that the last non-zero coefficient position flipping identification information indicates that the current block does not use the last non-zero coefficient position flipping.
[0245] That is to say, taking the first value being 1 and the second value being 0 as an example, if the value of reverse_last_sig_coeff_flag is 1, then it can be determined that reverse_last_sig_coeff_flag indicates that the current block uses the last non-zero coefficient position flip; or, if the value of reverse_last_sig_coeff_flag is 0, then it can be determined that reverse_last_sig_coeff_flag indicates that the current block does not use the last non-zero coefficient position flip.
[0246] S903: When the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, the coordinate information of the last non-zero coefficient is calculated to determine the position of the last non-zero coefficient.
[0247] S904: 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.
[0248] It should be noted that, in an embodiment of the present application, when the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, the coordinate information of the last non-zero coefficient 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.
[0249] At this time, in some embodiments, calculating the coordinate information of the last non-zero coefficient to determine the position of the last non-zero coefficient may include:
[0250] Determine the width and height of the current block;
[0251] Perform a subtraction calculation based on 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 to obtain the horizontal coordinate of the last non-zero coefficient; and
[0252] Perform a subtraction calculation based on 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 to obtain the vertical coordinate of the last non-zero coefficient;
[0253] Determine the position of the last non-zero coefficient based on the horizontal coordinate and the vertical coordinate of the last non-zero coefficient.
[0254] It should be noted that the coordinate information of the last non-zero coefficient is usually the horizontal distance and the vertical distance between the position of the last non-zero coefficient and the upper left corner position of the current block. For conventional videos, since most non-zero coefficients are concentrated in the upper left corner and a large area in the lower right corner is 0; however, for high-bitwidth, high-quality, and high-bitrate video coding and decoding, a large number of non-zero coefficients also appear in the lower right corner, making the values of the coordinate information of the last non-zero coefficient usually large. At this time, in order to save overhead, coordinate transformation needs to be performed during coefficient coding (specifically, it can be coordinate flipping calculation, that is, after coordinate flipping, the coordinate information of the last non-zero coefficient is the horizontal distance and the vertical distance between the position of the last non-zero coefficient and the lower right corner position of the current block). Then, coordinate flipping calculation also needs to be performed during coefficient decoding. After flipping again, the coordinate information of the last non-zero coefficient can be restored to be the horizontal distance and the vertical distance between the position of the last non-zero coefficient and the upper left corner position of the current block, so as to determine the position of the last non-zero coefficient and decode all the coefficients before the position of the last non-zero coefficient in the current block according to the preset scanning order.
[0255] It should also be noted that the current block here can be a block without zero-out transformation or a block after zero-out transformation. Taking the block after zero-out transformation as an example, at this time, the width of the current block is 1<<log2ZoTbWidth, and the height of the current block is 1<<log2ZoTbHeight; then in the case where reverse_last_sig_coeff_flag indicates that the current block uses the position flipping of the last non-zero coefficient (that is, the value of reverse_last_sig_coeff_flag is 1),
[0256] LastSignificantCoeffX=(1< <log2ZoTbWidth)-1-LastSignificantCoeffX;
[0257] LastSignificantCoeffY=(1< <log2ZoTbHeight)-1-LastSignificantCoeffY。
[0258] Among them, (LastSignificantCoeffX, LastSignificantCoeffY) on the right side of the equation represents the coordinate information of the last non-zero coefficient obtained by decoding, and (LastSignificantCoeffX, LastSignificantCoeffY) on the left side of the equation 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).
[0259] In the embodiment of the present application, when the value of reverse_last_sig_coeff_flag is 0, in some embodiments, the method may further include:
[0260] When the last non-zero coefficient position flip identification information indicates that the current block does not use the last non-zero coefficient position flip, determining the coordinate information of the last non-zero coefficient as the horizontal distance and the vertical distance between the position of the last non-zero coefficient and the upper left corner position of the current block;
[0261] The position of the last non-zero coefficient is determined according to a horizontal distance and a vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block.
[0262] It should be noted that if reverse_last_sig_coeff_flag indicates that the current block does not use the last non-zero coefficient position flip, then the coordinate information of the last non-zero coefficient obtained by decoding can be regarded as the target coordinate information of the last non-zero coefficient. In this embodiment of the present application, the target coordinate information 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.
[0263] Furthermore, in some embodiments, the method may further include:
[0264] When the last non-zero coefficient position flip identification information indicates that the current block does not use the last non-zero coefficient position flip, directly determining the position of the last non-zero coefficient according to the coordinate information of the last non-zero coefficient;
[0265] All coefficients before the position of the last non-zero coefficient are decoded in a preset scanning order to determine the coefficients of the current block.
[0266] It should be noted that the preset scanning order may be diagonal, zigzag, horizontal, vertical, 4×4 sub-block scanning or any other scanning order, and the embodiment of the present application does not impose any limitation thereto.
[0267] It should also be noted that after obtaining reverse_last_sig_coeff_flag, if the value of reverse_last_sig_coeff_flag is 1, that is, the last non-zero coefficient position flip needs to be used, then after decoding to obtain the coordinate information of the last non-zero coefficient, the coordinate information of the last non-zero coefficient needs to be calculated to determine the position of the last non-zero coefficient; then all coefficients before the position of the last non-zero coefficient are decoded according to the preset scanning order. If the value of reverse_last_sig_coeff_flag is 0, that is, the last non-zero coefficient position flip does not need to be used, then after decoding to obtain the coordinate information of the last non-zero coefficient, the position of the last non-zero coefficient can be directly determined based on the coordinate information of the last non-zero coefficient; then all coefficients before the position of the last non-zero coefficient are decoded according to the preset scanning order.
[0268] Thus, for a certain situation, when encoding coefficients, the embodiments of the present application provide a method for deriving the position of modifying the last non-zero coefficient. That is to say, generally, the coefficient encoding and decoding method is still the same as the existing method in the related art. A certain situation, for example, can refer to video encoding and decoding with high bitwidth or high quality or high bitrate or lossless compression. Generally, last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the abscissa 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 ordinate 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 FIG. 10A. In the case of video encoding and decoding with high bitwidth or high quality or high bitrate or lossless compression, the position of the last non-zero coefficient generally approaches the lower right corner of the area where all possible non-zero coefficients of the current block are located. In this case, last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the horizontal distance of the position of the last non-zero coefficient relative to the lower right corner of the area where all possible non-zero coefficients of the current block are located; last_sig_coeff_y_prefix and last_sig_coeff_y_suffix encode the vertical distance of the position of the last non-zero coefficient relative to the lower right corner of the area where all possible non-zero coefficients of the current block are located, as shown in FIG. 10B. For example, if the area where all possible non-zero coefficients of the current block is a rectangular area 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 position of the last non-zero coefficient 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 position of the last non-zero coefficient relative to the current block ((1 << log2ZoTbWidth) - 1, (1 << log2ZoTbHeight) - 1).
[0269] The modifications to the semantics are as follows:
[0270] The value of the horizontal (or column) coordinate of the last non-zero coefficient in the current block in the preset scanning order, LastSignificantCoeffX, is derived as follows:
[0271] If last_sig_coeff_x_suffix does not exist, then,
[0272] LastSignificantCoeffX=last_sig_coeff_x_prefix;
[0273] Otherwise (last_sig_coeff_x_suffix exists),
[0274] LastSignificantCoeffX=(1<<((last_sig_coeff_x_prefix>>1)-1))*(2+(last_sig_coeff_x_prefix&1))+last_sig_coeff_x_suffix;
[0275] If the value of reverse_last_sig_coeff_flag is 1, then
[0276] LastSignificantCoeffX=(1< <log2ZoTbWidth)-1-LastSignificantCoeffX;
[0277] The value LastSignificantCoeffY of the vertical (or row) coordinate of the last non-zero coefficient in the current block in scan order is derived as follows:
[0278] If last_sig_coeff_y_suffix does not exist, then,
[0279] LastSignificantCoeffY=last_sig_coeff_y_prefix;
[0280] Otherwise (last_sig_coeff_y_suffix exists):
[0281] LastSignificantCoeffY=(1<<((last_sig_coeff_y_prefix>>1)-1))*(2+(last_sig_coeff_y_prefix&1))+last_sig_coeff_y_suffix;
[0282] If the value of reverse_last_sig_coeff_flag is 1, then
[0283] LastSignificantCoeffY=(1< <log2ZoTbHeight)-1-LastSignificantCoeffY。
[0284] Among them, reverse_last_sig_coeff_flag is the last non-zero coefficient position flip 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.
[0285] It should also be noted that reverse_last_sig_coeff_flag may be a sequence-level or higher-level flag, or a picture-level flag, a slice-level flag, a block-level flag, or a flag at another level. The block-level flag includes a maximum coding unit (LCU)-level flag, a coding unit (CU)-level flag, or another block-level flag.
[0286] In addition, reverse_last_sig_coeff_flag may depend on some other flags, such as high bit width flag information or high bit rate flag information, etc. That is, when the value of the high bit width flag information or the high bit rate flag information is 1, the reverse_last_sig_coeff_flag flag needs to be decoded; otherwise, the reverse_last_sig_coeff_flag flag does not need to be decoded.
[0287] In a specific example, taking the sequence level as an example, it is assumed that there is a sequence-level flag sps_high_bit_depth_flag indicating whether the current video sequence is a high-bit-width sequence. If the value of sps_high_bit_depth_flag is 1, it means that the current video sequence is a high-bit-width sequence; otherwise, it means that the current video sequence is not a high-bit-width sequence. At the sequence level, if the value of sps_high_bit_depth_flag is 1, then it is necessary to decode sps_reverse_last_sig_coeff_flag. Here, sps_reverse_last_sig_coeff_flag is the last non-zero coefficient position flip flag of the current sequence. If the value of sps_reverse_last_sig_coeff_flag is 1, it means that the block in the current sequence uses the last non-zero coefficient position flip; otherwise (that is, the value of sps_reverse_last_sig_coeff_flag is 0), it means that the block in the current sequence does not use the last non-zero coefficient position flip. The reverse_last_sig_coeff_flag in the above syntax table is changed to sps_reverse_last_sig_coeff_flag.
[0288] Its syntax elements are as follows (Sequence parameter set RBSP syntax), see Table 3.
[0289] Table 3
[0290]
[0291] In another specific example, taking the slice level as an example, it is assumed that there is a sequence-level flag sps_high_bit_depth_flag indicating whether the current video sequence is a high-bit-width sequence. If the value of sps_high_bit_depth_flag is 1, it means that the current video sequence is a high-bit-width sequence; otherwise, it means that the current video sequence is not a high-bit-width sequence. At the slice level, if the value of sps_high_bit_depth_flag is 1, then it is necessary to decode sh_reverse_last_sig_coeff_flag. Here, sh_reverse_last_sig_coeff_flag is the last non-zero coefficient position flip flag of the current slice. If the value of sh_reverse_last_sig_coeff_flag is 1, it means that the block in the current slice uses the last non-zero coefficient position flip; otherwise (that is, the value of sh_reverse_last_sig_coeff_flag is 0), it means that the block in the current slice does not use the last non-zero coefficient position flip. The reverse_last_sig_coeff_flag in the above syntax table is changed to sh_reverse_last_sig_coeff_flag.
[0292] Its syntax elements are as follows (Slice header syntax), see Table 4.
[0293] Table 4
[0294]
[0295] It can also be understood that when the video identification information indicates that the video meets the preset conditions, it is also possible to encode all the coefficients that may need to be encoded by default, that is, the position of the last non-zero coefficient is no longer used, but all the coefficients of the current block that may not be 0 are scanned according to the preset scanning order; therefore, the embodiment of the present application can also introduce the last coefficient enable identification information to determine whether the current block uses the last coefficient position.
[0296] In some embodiments, when the video identification information indicates that the video meets a preset condition, the method may further include:
[0297] Parse the code stream and obtain the last coefficient enable identification information;
[0298] When the last coefficient enable identification information indicates that the current block uses the last coefficient position, all coefficients before the last coefficient position are decoded according to a preset scanning order to determine the coefficients of the current block.
[0299] It should be noted that the last coefficient enable flag information can be represented by default_last_coeff_enabled_flag. In the embodiment of the present application, the last coefficient enable flag information can be at least one of the following flags: sequence level, picture level, slice level, and block level; or even higher-level flag information (such as VUI, SEI, etc.), without any limitation here.
[0300] That is, default_last_coeff_enabled_flag may be a sequence-level or higher-level flag, or a picture-level flag, a slice-level flag, a block-level flag, or a flag at another level. In addition, the block-level flag may include a maximum coding unit (LCU)-level flag, a coding unit (CU)-level flag, or another block-level flag, which is not limited in this embodiment of the present application.
[0301] In some embodiments, the method may further include:
[0302] If the value of the last coefficient enable identification information is the first value, it is determined that the last coefficient enable identification information indicates that the current block uses the last coefficient position; or
[0303] If the value of the last coefficient enable flag information is the second value, it is determined that the last coefficient enable flag information indicates that the current block does not use the last coefficient position.
[0304] Here, the first value is 1 and the second value is 0.
[0305] It should be noted that, in another specific example, the first value can be set to true, and the second value can be set to false. In yet another specific example, the first value can be set to 0, and the second value can be set to 1; or, the first value can be set to false, and the second value can be set to true. This is not limited in any way.
[0306] 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.
[0307] In the case where the current block uses the last coefficient position, all coefficients before the last coefficient position may be decoded according to a preset scanning order to determine the coefficients of the current block.
[0308] Furthermore, in the case where the last coefficient position is not used in the current block, that is, the value of the last coefficient enable identification information is 0, in some embodiments, the method may further include:
[0309] Parse the bitstream to obtain the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient;
[0310] Determining a position of the last non-zero coefficient according to prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient;
[0311] All coefficients before the position of the last non-zero coefficient are decoded in a preset scanning order to determine the coefficients of the current block.
[0312] It should be noted that if the current block does not use the last coefficient position, then it is necessary to decode and 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, the position of the last non-zero coefficient is determined. Otherwise, if the current block uses the last coefficient position, it is no longer necessary to determine the position of the last non-zero coefficient, and it is no longer necessary to decode and obtain last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix.
[0313] 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 position of the last non-zero coefficient 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 the embodiments of the present application do not impose any limitation.
[0314] Further, for the last coefficient position, in some embodiments, the last coefficient position is the lower right corner position of the matrix composed of all coefficients that may not be zero in the current block; or, the last coefficient position is the last position of the current block after scanning all coefficients that may not be zero according to a preset scanning order.
[0315] It should be noted that the last coefficient position in the embodiment of the present application does not represent the position of the last non-zero coefficient, 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.
[0316] In a specific example, the method may further include: setting the position of the last non-zero coefficient to the last coefficient position.
[0317] That is to say, the embodiment of the present application can still use the position of the last non-zero coefficient. At this time, the position of the last non-zero coefficient needs to be placed at the last position of all coefficients of the current block that may not be 0 according to the preset scanning order.
[0318] Furthermore, the last coefficient position can be represented by (LastCoeffX, LastCoeffY), that is, the last position of all coefficients of the current block that may not be 0 according to the preset scanning order. In some embodiments, the method may further include:
[0319] Determine the width and height of the transformed block of the current block after the preset operation;
[0320] Calculate the coordinates of the lower right corner of the transformation block based on the width and height of the transformation block;
[0321] The last coefficient position is determined according to the coordinate information of the lower right corner of the transform block.
[0322] Here, the preset operation at least includes: a forced zero-out operation.
[0323] It should be noted that (LastCoeffX, LastCoeffY) represents the coordinate information of the lower right corner of the transform block after zero-out; wherein, the derivation method of (LastCoeffX, LastCoeffY) is as follows:
[0324] LastCoeffX=(1< <log2ZoTbWidth)-1;LastCoeffY=(1<<log2ZoTbHeight)-1。
[0325] In this way, if the value of default_last_coeff_enabled_flag is 1, the last coefficient position can be determined according to (LastCoeffX, LastCoeffY).
[0326] In a specific 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 last position of all coefficients of the current block that may be 0 according to the preset scanning order. In some embodiments, the method may further include:
[0327] 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 lower right corner coordinate information of the transform block.
[0328] That is, the position of the last non-zero coefficient can be expressed as (LastSignificantCoeffX, LastSignificantCoeffY), and the derivation method of (LastSignificantCoeffX, LastSignificantCoeffY) is as follows:
[0329] LastSignificantCoeffX=(1< <log2ZoTbWidth)-1;LastSignificantCoeffY=(1<<log2ZoTbHeight)-1。
[0330] 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 based on (LastSignificantCoeffX, LastSignificantCoeffY).
[0331] Therefore, in certain situations, when encoding coefficients, the default is to encode all possible coefficients. This means that, generally speaking, the coefficient encoding and decoding methods remain the same as those already known in the art. This can be the case for high-bitwidth, high-quality, high-bitrate video, or lossless video encoding and decoding. By default, all possible coefficients that may need to be encoded are encoded. This 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 in the preset scan order. Alternatively, the last coefficient to be encoded is placed at the end of all possible non-zero coefficients in the current block in the preset scan order. This position is typically the bottom-right corner of the matrix of all possible non-zero coefficients in the current block. The last coefficient position to be encoded is used here, rather than the last non-zero coefficient position. This is because the coefficient at the last coefficient position to be encoded may be zero, while the coefficient at the last non-zero coefficient position is definitely non-zero.
[0332] A special case is that the position of the last non-zero coefficient is still used. In this case, the position of the last non-zero coefficient is placed at the last position of all coefficients of the current block that may not be zero in a preset scanning order.
[0333] In addition, all the coefficients of the current block in the preset scanning order may not be zero because, except for the last non-zero coefficient, there are some other technologies that make some coefficients in a block default to 0. For example, it may be the zero-out mentioned above.
[0334] The semantic modifications are shown in Table 5.
[0335] Table 5
[0336]
[0337] In an embodiment of the present application, a condition may be added before decoding the information required for the last non-zero coefficient, that is, if default_last_coeff_enabled_flag is not established (i.e., the value of default_last_coeff_enabled_flag is equal to 0), then it is necessary to decode 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 established (i.e., the value of default_last_coeff_enabled_flag is equal to 1), then it is not necessary to decode 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.
[0338] Here, default_last_coeff_enabled_flag is the default last coefficient enable flag, which is 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 of the current block in the preset scanning order; otherwise, it means that the default last coefficient position is not used.
[0339] If the value of default_last_coeff_enabled_flag is 1, then the default 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 scanning order. The coefficients before the preset scanning order (LastCoeffX, LastCoeffY) need to be scanned. In this embodiment of the application, the method for deriving (LastCoeffX, LastCoeffY) is as follows:
[0340] LastCoeffX=(1< <log2ZoTbWidth)-1;LastCoeffY=(1<<log2ZoTbHeight)-1。
[0341] Among them, (LastCoeffX, LastCoeffY) is the coordinate information of the lower right corner position of the transformation block after zero-out.
[0342] A special case is to still use the position of the last non-zero coefficient and place it at the last position of all coefficients that may not be zero in the current block according to the preset scanning order. In this embodiment of the application, the method for deriving the position of the last non-zero coefficient (LastSignificantCoeffX, LastSignificantCoeffY) is as follows:
[0343] LastSignificantCoeffX=(1< <log2ZoTbWidth)-1;LastSignificantCoeffY=(1<<log2ZoTbHeight)-1。
[0344] Among them, (LastSignificantCoeffX, LastSignificantCoeffY) is the coordinate information of the lower right corner position of the transformation block after zero-out.
[0345] It should also be noted that default_last_coeff_enabled_flag may be a sequence-level or higher-level flag, or a picture-level flag, a slice-level flag, a block-level flag, or a flag at another level. Block-level flags include maximum coding unit (LCU)-level flags, coding unit (CU)-level flags, or other block-level flags.
[0346] In addition, the default_last_coeff_enabled_flag may depend on some other flags, such as high bit width flag information or high bit rate flag information, etc. That is, when the value of the high bit width flag information or the high bit rate flag information 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.
[0347] In a specific example, taking the sequence level as an example, assume that there is a sequence-level flag sps_high_bit_depth_flag that indicates whether the current video sequence is a high-bit-width sequence. If the value of sps_high_bit_depth_flag is 1, it means that the current video sequence is a high-bit-width sequence; otherwise, it means that the current video sequence is not a high-bit-width sequence. At the sequence level, if the value of sps_high_bit_depth_flag is 1, then it is necessary to decode sps_default_last_coeff_enabled_flag. 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, it means that the block in the current sequence uses the default last coefficient; otherwise (that is, 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. The default_last_coeff_enabled_flag in the above syntax table is changed to sps_default_last_coeff_enabled_flag.
[0348] Its syntax elements are as follows (Sequence parameter set RBSP syntax), see Table 6.
[0349] Table 6
[0350]
[0351] In another specific example, taking the slice level as an example, assume that there is a sequence-level flag, sps_high_bit_depth_flag, that indicates whether the current video sequence is a high-bit-width sequence. If the value of sps_high_bit_depth_flag is 1, it indicates that the current video sequence is a high-bit-width sequence; otherwise, it indicates that the current video sequence is not a high-bit-width sequence. At the slice level, if the value of sps_high_bit_depth_flag is 1, then it is necessary to decode the sh_default_last_coeff_enabled_flag. 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, it indicates that the blocks in the current slice use the default last coefficient; otherwise (that is, the value of sh_default_last_coeff_enabled_flag is 0), it indicates that the blocks in the current slice do not use the default last coefficient. The default_last_coeff_enabled_flag in the above syntax table is changed to sh_default_last_coeff_enabled_flag.
[0352] Its syntax elements are as follows (Slice header syntax), see Table 7.
[0353] Table 7
[0354]
[0355] It is also understood that when the video identification information indicates that the video meets the preset conditions, all scanned sub-blocks are encoded by default. In this case, there is no need to transmit the sb_coded_flag in the bitstream, that is, the encoder / decoder does not need to process this flag, thereby speeding up encoding and decoding. Therefore, embodiments of the present application can also introduce sub-block default encoding identification information to determine whether the sub-block to be decoded in the current block is encoded by default.
[0356] In some embodiments, when the video identification information indicates that the video meets a preset condition, the method may further include:
[0357] Parse the code stream and obtain the sub-block default encoding identification information;
[0358] When the sub-block default coding identification information indicates the default coding of the sub-block to be decoded in the current block, the value of the sub-block coding identification information is determined to be the first value, and all coefficients in the sub-block to be decoded are decoded.
[0359] It should be noted that the sub-block default identification information can be represented by default_sb_coded_flag. In the embodiment of the present application, the sub-block default coding identification information is at least one of the following identification information: sequence level, picture level, slice level, and block level; it can even be identification information at a higher level (such as VUI, SEI, etc.), without any limitation here.
[0360] That is, default_sb_coded_flag may be a sequence-level or higher-level flag, or a picture-level flag, a slice-level flag, a block-level flag, or a flag at another level. In addition, the block-level flag may include a maximum coding unit (LCU)-level flag, a coding unit (CU)-level flag, or another block-level flag, which is not limited in any way in the embodiments of the present application.
[0361] In some embodiments, the method may further include:
[0362] If the value of the sub-block default coding identification information is the first value, it is determined that the sub-block default coding identification information indicates the default coding of the sub-block to be decoded; or,
[0363] If the value of the sub-block default encoding identification information is the second value, it is determined that the sub-block default encoding identification information indicates that the sub-block to be decoded is not encoded by default.
[0364] Here, the first value is 1 and the second value is 0.
[0365] It should be noted that, in another specific example, the first value can be set to true, and the second value can be set to false. In yet another specific example, the first value can be set to 0, and the second value can be set to 1; or, the first value can be set to false, and the second value can be set to true. This is not limited in any way.
[0366] 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.
[0367] When the sub-block to be decoded needs 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, it is no longer necessary to decode sb_coded_flag. At this time, all coefficients in the sub-block to be decoded need to be decoded by default.
[0368] Furthermore, when the sub-block to be decoded does not need to be encoded by default, that is, the value of default_sb_coded_flag is 0, in some embodiments, the method may further include:
[0369] Parse the code stream and obtain sub-block coding identification information;
[0370] When the value of the sub-block encoding identification information is the first value, all coefficients in the sub-block to be decoded are decoded.
[0371] It should be noted that if the sub-block to be decoded does not require encoding by default, then decoding is required to obtain the sub-block encoding identification information; then, whether to decode all coefficients in the sub-block to be decoded is determined based on the sub-block encoding identification information.
[0372] Furthermore, for the sub-block coding identification information, the method may further include:
[0373] If the value of the sub-block coding identification information is the first value, it is determined to decode all coefficients in the sub-block to be decoded; or,
[0374] If the value of the sub-block coding identification information is the second value, it is determined that all coefficients in the sub-block to be decoded are zero.
[0375] In the embodiment of the present application, the sub-block coding identification information can be represented by sb_coded_flag. Taking the first value as 1 and the second value as 0 as an example, if the value of sb_coded_flag is 1, 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, 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.
[0376] In this way, for certain situations, when encoding the coefficients, the scanned sub-blocks all need to be encoded by default, or in other words, the scanned sub-blocks all contain non-zero coefficients by default. That is to say, under normal circumstances, the coefficient encoding method is still the same as the existing method in the relevant technology. In a certain situation, for example, it may refer to high-bitwidth or high-quality or high-bitrate video or lossless compressed video encoding and decoding. In this case, there are many non-zero coefficients, and the scanned sub-blocks almost all need to be encoded; in other words, the scanned sub-blocks almost all contain non-zero coefficients. In this way, there is no need to transmit sb_coded_flag in the bitstream, and the encoder / decoder does not need to process this flag, thereby speeding up the encoding and decoding speed. Since an almost non-existent flag is removed, a slight improvement in compression performance will be brought about at this time.
[0377] The semantic modifications are shown in Table 8.
[0378] Table 8
[0379]
[0380] Where default_sb_coded_flag is a flag that indicates that the default sub-block needs to be encoded. If the value of default_sb_coded_flag is 1, then the value of sb_coded_flag[xS][yS] is guaranteed to be 1, and decoding from the bitstream is not required. Otherwise (the value of default_sb_coded_flag is 0), sb_coded_flag[xS][yS] still needs to be decoded from the bitstream.
[0381] It should also be noted that default_sb_coded_flag may be a sequence-level or higher-level flag, or a picture-level flag, a slice-level flag, a block-level flag, or a flag at another level. Block-level flags include maximum coding unit (LCU)-level flags, coding unit (CU)-level flags, or other block-level flags.
[0382] In addition, default_sb_coded_flag may depend on some other flags, such as high bit width flag information or high bit rate flag information, etc. That is, when the value of high bit width flag information or high bit rate flag information 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.
[0383] In a specific example, taking the sequence level as an example, it is assumed that there is a sequence-level flag sps_high_bit_depth_flag indicating whether the current video sequence is a high-bit-width sequence. If the value of sps_high_bit_depth_flag is 1, it means that the current video sequence is a high-bit-width sequence; otherwise, it means that the current video sequence is not a high-bit-width sequence. At the sequence level, if the value of sps_high_bit_depth_flag is 1, then it is necessary to decode sps_default_sb_coded_flag. Here, sps_default_sb_coded_flag is a flag indicating that the default sub-block of the current sequence needs to be encoded. If the value of sps_default_sb_coded_flag is 1, it means that the default sub-block of the block in the current sequence needs to be encoded; otherwise (that is, the value of sps_default_sb_coded_flag is 0), it means that the default sub-block of the block in the current sequence does not need to be encoded. The default_sb_coded_flag in the above syntax table is changed to sps_default_sb_coded_flag.
[0384] Its syntax elements are as follows (Sequence parameter set RBSP syntax), see Table 9.
[0385] Table 9
[0386]
[0387] In another specific example, taking the slice level as an example, it is assumed that there is a sequence-level flag sps_high_bit_depth_flag indicating whether the current video sequence is a high-bit-width sequence. If the value of sps_high_bit_depth_flag is 1, it means that the current video sequence is a high-bit-width sequence; otherwise, it means that the current video sequence is not a high-bit-width sequence. At the slice level, if the value of sps_high_bit_depth_flag is 1, then it is necessary to decode sh_default_sb_coded_flag. Here, sh_default_sb_coded_flag is a flag indicating that the default sub-block of the current slice needs to be encoded. If the value of sh_default_sb_coded_flag is 1, it means that the default sub-block of the block in the current slice needs to be encoded; otherwise (that is, the value of sh_default_sb_coded_flag is 0), it means that the default sub-block of the block in the current slice does not need to be encoded. The default_sb_coded_flag in the above syntax table is changed to sh_default_sb_coded_flag.
[0388] Its syntax elements are as follows (Slice header syntax), see Table 10.
[0389] Table 10
[0390]
[0391] It is understandable that the embodiments of this application involve three optimization methods, which are as follows:
[0392] Method 1: For certain situations, when encoding coefficients, it is necessary to encode all coefficients that may need to be encoded by default. That is to say, under normal circumstances, the coefficient encoding method is the same as the existing method in the relevant technology. In certain situations, for example, it may refer to high-bitwidth or high-quality or high-bitrate video or lossless compressed video encoding and decoding. By default, 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 coefficients of the current block that may not be 0 are scanned in the preset scanning order; in other words, the position of the last coefficient that needs to be encoded is placed at the last position of all coefficients of the current block that may not be 0 in the preset scanning order. The last coefficient position that needs to be encoded is used here instead of the last non-zero coefficient position. This is because the coefficient at the last coefficient position that needs to be encoded may be 0, while the coefficient at the last non-zero coefficient position must not be 0.
[0393] Additionally, a specific example is to still use the position of the last non-zero coefficient and place the position of the last non-zero coefficient at the last position among all the coefficients that may be non-zero in the current block in the preset scanning order.
[0394] Method 2: For a certain situation, when encoding coefficients, modify the derivation method of the position of the last non-zero coefficient. That is, generally, the method of encoding coefficients is still the same as the existing method in the related technology. A certain situation, for example, can refer to high-bitwidth or high-quality or high-bitrate videos or lossless compressed video encoding and decoding. Generally, last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the abscissa 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 ordinate of the position of the last non-zero coefficient, that is, the vertical distance relative to the upper left corner of the current block. In the case of high-bitwidth or high-quality or high-bitrate videos or lossless compressed video encoding and decoding, the position of the last non-zero coefficient generally approaches the lower right corner of the area of all the coefficients that may be non-zero in the current block. In this case, last_sig_coeff_x_prefix and last_sig_coeff_x_suffix encode the horizontal distance of the position of the last non-zero coefficient relative to the lower right corner of the area of all the coefficients that may be non-zero in the current block; last_sig_coeff_y_prefix and last_sig_coeff_y_suffix encode the vertical distance of the position of the last non-zero coefficient relative to the lower right corner of the area of all the coefficients that may be non-zero in the current block. For example, if the area of all the coefficients that may be non-zero in the current block is a rectangular area 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 position of the last non-zero coefficient 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 position of the last non-zero coefficient relative to the current block ((1 << log2ZoTbWidth) - 1, (1 << log2ZoTbHeight) - 1).
[0395] Method 3: In certain situations, when encoding coefficients, all scanned sub-blocks are encoded by default; in other words, all scanned sub-blocks contain non-zero coefficients by default. In other words, under normal circumstances, the coefficient encoding method is still the same as the existing methods in the related art. In certain situations, for example, it can refer to high-bitwidth, high-quality, high-bitrate video or lossless compression video encoding and decoding. In this case, there are many non-zero coefficients, and almost all scanned sub-blocks need to be encoded, or almost all scanned sub-blocks contain non-zero coefficients. In this case, there is no need to transmit sb_coded_flag in the bitstream, and the encoder / decoder does not need to process this flag.
[0396] For the above three methods, in high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding scenarios, since the coefficient distribution pattern is different from that of ordinary video scenarios, the coefficient coding throughput and encoding and decoding speed can be improved by reducing or even eliminating the number of syntax elements of context mode coding, such as the last non-zero coefficient position, sub-block coding identifier and other syntax elements; at the same time, since the above-mentioned flags have little effect in high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding, not using these flags will not reduce the compression efficiency but can improve the compression efficiency to a certain extent.
[0397] In addition, in an embodiment of the present application, taking the sequence level as an example, the sequence level flag sps_high_bit_depth_flag indicates whether the current video sequence is a high bit width sequence, and can also be replaced by sps_high_bit_rate_flag, which indicates whether the current video 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 coding.
[0398] It should also be noted that the coefficient decoding methods of the embodiments of the present application are all based on the use of the technology for all components in the video. All components refer to R, G, B of RGB format video, or Y, U, V (Y, Cb, Cr) of YUV format. The coefficient decoding methods of the embodiments of the present application can also be used for only one component, such as only the Y component of the YUV format. The coefficient decoding methods of the embodiments of the present application can also be used for each component separately, that is, each component can be controlled separately.
[0399] This embodiment provides a coefficient decoding method, applicable to a decoder. The method comprises parsing a bitstream to obtain video identification information; when the video identification information indicates that the video meets a preset condition, parsing the bitstream to obtain last non-zero coefficient position flip identification information and coordinate information of the last non-zero coefficient; when the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, calculating the coordinate information of the last non-zero coefficient to determine the position of the last non-zero coefficient; and decoding all coefficients preceding the position of the last non-zero coefficient in 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 video encoding and decoding scenarios, since the coefficient distribution pattern is different from that of conventional video scenarios, the number of grammatical elements encoded in the context mode can be reduced or even eliminated in the coefficient encoding, such as the grammatical elements about the last non-zero coefficient position, sub-block coding identifier, etc., and even the coordinate transformation can be performed when the value of the coordinate information of the last non-zero coefficient is too large, thereby reducing the encoding overhead in the bitstream and improving the coefficient encoding throughput and encoding and decoding speed; in addition, since the reduced or eliminated grammatical elements have little impact on high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding, the compression efficiency can also be improved.
[0400] In another embodiment of the present application, referring to FIG11 , a flow chart of a coefficient encoding method provided by an embodiment of the present application is shown. As shown in FIG11 , the method may include:
[0401] S1101: Determine video identification information and the position of the last non-zero coefficient.
[0402] S1102: When the video identification information indicates that the video meets a preset condition, determine the last non-zero coefficient position flip identification information.
[0403] S1103: Determine the coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information.
[0404] S1104: Encode all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and write the encoded bit information, video identification information and coordinate information of the last non-zero coefficient into the bitstream.
[0405] It should be noted that the coefficient coding method of the embodiment of the present application is applied to an encoder. Specifically, based on the structure of the encoder 100 shown in FIG8A , the coefficient coding method of the embodiment of the present application is mainly applied to the "entropy coding unit 115" in the encoder 100. For the entropy coding unit 115, an adaptive binary arithmetic coding mode based on a context model or a bypass mode can be used to entropy code the relevant identification information (or syntax elements) and then write it into the bitstream.
[0406] It should also be noted that the coefficient coding commonly referred to in video standards can include two parts: encoding and decoding. Therefore, coefficient coding includes the coefficient encoding method on the encoder side and the coefficient decoding method on the decoder side. The embodiments of this application describe the coefficient encoding method on the encoder side.
[0407] Under normal circumstances, such as for conventional videos, the coefficient encoding method is the same as the existing method in the related art; however, for certain situations, such as high-bit-width or high-quality or high-bit-rate or lossless compressed video encoding and decoding, the embodiment of the present application can modify the position derivation method of the last non-zero coefficient. At this time, the embodiment of the present application needs to introduce video identification information and the last non-zero coefficient position flip identification information to determine the position of the last non-zero coefficient, and then encode all coefficients before the position of the last non-zero coefficient in the current block according to the preset scanning order.
[0408] Among them, the embodiment of the present application first needs to determine whether the current video meets the preset conditions, which can be represented by video identification information. In some embodiments, the determination of video identification information may include:
[0409] If the video meets the preset condition, the value of the video identification information is determined to be the first value; or,
[0410] If the video does not meet the preset condition, the value of the video identification information is determined to be a second value.
[0411] Here, the first value is 1 and the second value is 0.
[0412] It should be noted that, in another specific example, the first value can be set to true, and the second value can be set to false. In yet another specific example, the first value can be set to 0, and the second value can be set to 1; or, the first value can be set to false, and the second value can be set to true. This is not limited in any way.
[0413] It should also be noted that the preset conditions include at least one of the following: high bit width, high quality, high bit rate, high frame rate and lossless compression.
[0414] Furthermore, the video identification information can be a sequence-level flag, or even a higher-level flag (such as VUI, SEI, etc.). Whether a video meets the preset conditions can also be determined by determining whether the video meets high bit width, high bit rate, high quality, or lossless compression requirements. The following describes these four cases as examples.
[0415] In some embodiments, when the video identification information is high-bitwidth identification information, the method may further include:
[0416] If the video meets the high bit width, it is determined that the high bit width identification information indicates that the video meets the preset condition.
[0417] In some embodiments, when the video identification information is high bit rate identification information, the method may further include:
[0418] If the video meets the high bit rate requirement, it is determined that the high bit rate identification information indicates that the video meets the preset condition.
[0419] In some embodiments, when the video identification information is high-quality identification information, the method may further include:
[0420] If the video meets the high quality requirement, it is determined that the high quality identification information indicates that the video meets the preset condition.
[0421] In some embodiments, when the video identification information is lossless compression identification information, the method may further include:
[0422] If the video satisfies lossless compression, it is determined that the lossless compression identification information indicates that the video satisfies a preset condition.
[0423] Exemplarily, taking the sequence level as an example, the video identification information can be high-bit-width identification information (represented by sps_high_bit_depth_flag), which is used to indicate whether the current video sequence is a high-bit-width sequence; or it can be replaced by high-bit-rate identification information (represented by sps_high_bit_rate_flag), which is used to indicate whether the current video sequence is a high-bit-rate sequence; or it can be replaced by other identification information indicating high bit-width, high bit-rate, high quality or lossless compression, which is not specifically limited in the embodiments of the present application.
[0424] Furthermore, for the last non-zero coefficient position flipping identification information, determining the last non-zero coefficient position flipping identification information may include:
[0425] If the current block uses the last non-zero coefficient position flipping, the value of the last non-zero coefficient position flipping identification information is determined to be the first value; or
[0426] If the current block does not use the last non-zero coefficient position flipping, the value of the last non-zero coefficient position flipping identification information is determined to be the second value.
[0427] In the embodiment of the present application, the last non-zero coefficient position flip flag information can be represented by reverse_last_sig_coeff_flag. Here, the last non-zero coefficient position flip flag information can be at least one of the following: sequence level, picture level, slice level, and block level; or even higher level (such as VUI, SEI, etc.), without any limitation here.
[0428] That is, reverse_last_sig_coeff_flag may be a sequence-level or higher-level flag, or may be a picture-level flag, a slice-level flag, a block-level flag, or a flag at another level. In addition, the block-level flag may include a maximum coding unit (LCU)-level flag, a coding unit (CU)-level flag, or another block-level flag, which is not limited in any way in the embodiments of the present application.
[0429] In this way, 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 non-zero coefficient position flip, then the value of reverse_last_sig_coeff_flag is 1; or, if it is determined that the current block does not use the last non-zero coefficient position flip, then the value of reverse_last_sig_coeff_flag is 0.
[0430] Furthermore, the position of the last non-zero coefficient may include an initial horizontal coordinate and an 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, determining the coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information may include:
[0431] If the value of the last non-zero coefficient position flip flag information is the first value, then calculating based on the initial horizontal coordinate and initial vertical coordinate of the last non-zero coefficient to determine the coordinate information of the last non-zero coefficient; or
[0432] If the value of the last non-zero coefficient position flip identification information is the second value, the coordinate information of the last non-zero coefficient is directly determined according to the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient.
[0433] In other words, in some embodiments, the method may further include:
[0434] If the value of the last non-zero coefficient position flip flag information is the first value, the coordinate information of the last non-zero coefficient is determined to be the horizontal distance and the vertical distance between the position of the last non-zero coefficient and the lower right corner of the current block; or
[0435] If the value of the last non-zero coefficient position flip identification information is the second value, the coordinate information 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.
[0436] That is to say, the coordinate information of the last non-zero coefficient is usually the horizontal distance and vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block. For conventional videos, since most of the non-zero coefficients are concentrated in the upper left corner, the large area in the lower right corner is 0; however, for high-bitwidth, high-quality, and high-bitrate video 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. At this time, in order to save overhead, coordinate transformation is required when encoding the coefficients (specifically, it can be a coordinate flip calculation, that is, the coordinate information of the last non-zero coefficient after the coordinate flip is the horizontal distance 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 flip calculation is also required when decoding the coefficients. After flipping again, the coordinate information of the last non-zero coefficient can be restored as the horizontal distance 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.
[0437] Furthermore, in some embodiments, calculating based on the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient to determine the coordinate information of the last non-zero coefficient may include:
[0438] Determine the width and height of the current block;
[0439] Subtracting the initial horizontal coordinate of the last non-zero coefficient from the width of the current block to obtain the horizontal coordinate of the last non-zero coefficient; and subtracting the initial vertical coordinate of the last non-zero coefficient from the height of the current block to obtain the vertical coordinate of the last non-zero coefficient;
[0440] Coordinate information of the last non-zero coefficient is determined according to the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.
[0441] It should be noted that the current block here can be a block without zero-out transformation or a block after zero-out transformation. Taking the block after zero-out transformation as an example, at this time, the width of the current block is 1<<log2ZoTbWidth, and the height of the current block is 1<<log2ZoTbHeight; then when reverse_last_sig_coeff_flag indicates to use the position of the last non-zero coefficient for flipping (that is, the value of reverse_last_sig_coeff_flag is 1),
[0442] LastSignificantCoeffX = (1<<log2ZoTbWidth)-1-LastSignificantCoeffX;
[0443] LastSignificantCoeffY = (1<<log2ZoTbHeight)-1-LastSignificantCoeffY.
[0444] Among them, (LastSignificantCoeffX, LastSignificantCoeffY) on the right side of the equation represents the coordinate information of the directly determined last non-zero coefficient (that is, the initial horizontal coordinate and the initial vertical coordinate 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 (that is, the coordinate information of the last non-zero coefficient written into the code stream when using the position of the last non-zero coefficient for flipping in the current block).
[0445] In some embodiments, writing the coordinate information of the last non-zero coefficient into the code stream may include:
[0446] Determining the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient according to the coordinate information of the last non-zero coefficient;
[0447] [[ID=第十八]]Writing the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient into the code stream
[0448] It should be noted that the prefix information of the horizontal coordinate of the last non-zero coefficient is represented by last_sig_coeff_x_prefix, the prefix information of the vertical coordinate of the last non-zero coefficient is represented by last_sig_coeff_y_prefix, the suffix information of the horizontal coordinate of the last non-zero coefficient is represented by last_sig_coeff_x_suffix, and the suffix information 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 to the bitstream so that the decoder can determine the coordinate information of the last non-zero coefficient by parsing the bitstream.
[0449] Thus, an embodiment of the present application provides a method for modifying the position of the last non-zero coefficient. That is to say, under normal circumstances, the coefficient encoding and decoding method is still the same as the existing method of the related art. In a certain case, for example, it may refer to high-bitwidth or high-quality or high-bitrate video or lossless compressed video encoding and decoding. Because 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. In the case of high-bitwidth or high-quality or high-bitrate video or lossless compressed video encoding and decoding, the position of the last non-zero coefficient is generally close to the lower right corner of all areas of the current block that may be 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 lower right corner of the area of all possible non-zero coefficients 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 lower right corner of the area of all possible non-zero coefficients in the current block, as shown in Figure 10B; therefore, the embodiment of the present application can solve the problem of greater overhead caused by encoding larger values in the code stream by introducing reverse_last_sig_coeff_flag.
[0450] Furthermore, when the video identification information indicates that the video meets the preset conditions, it can be 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, but all coefficients of the current block that may not be 0 are scanned according to the preset scanning order; therefore, the embodiment of the present application can also introduce the last coefficient enable identification information to determine whether the current block uses the last coefficient position.
[0451] In some embodiments, when the video identification information indicates that the video meets a preset condition, the method may further include:
[0452] Determine the last coefficient enable identification information;
[0453] When the last coefficient enable identification information indicates that the current block uses the last coefficient position, all coefficients before the last coefficient position are encoded according to a preset scanning order, and the encoded bit information, video identification information and the last coefficient enable identification information are written into the bitstream.
[0454] It should be noted that the last coefficient enable flag information can be represented by default_last_coeff_enabled_flag. In the embodiment of the present application, the last coefficient enable flag information can be at least one of the following flags: sequence level, picture level, slice level, and block level; or even higher-level flag information (such as VUI, SEI, etc.), without any limitation here.
[0455] It should also be noted that, for the last coefficient enable identification information, in some embodiments, determining the last coefficient enable identification information may include:
[0456] If the current block uses the last coefficient position, the value of the last coefficient enable identification information is determined to be the first value; or if the current block does not use the last coefficient position, the value of the last coefficient enable identification information is determined to be the second value.
[0457] 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.
[0458] Further, for the last coefficient position, in some embodiments, the last coefficient position is the lower right corner position of the matrix composed of all coefficients that may not be zero in the current block; or, the last coefficient position is the last position of the current block after scanning all coefficients that may not be zero according to a preset scanning order.
[0459] It should be noted that the last coefficient position in the embodiment of the present application does not represent the position of the last non-zero coefficient, 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.
[0460] In a specific example, the method may further include: setting the position of the last non-zero coefficient to the last coefficient position.
[0461] That is to say, the embodiment of the present application can still use the position of the last non-zero coefficient. At this time, the position of the last non-zero coefficient needs to be placed at the last position of all coefficients of the current block that may not be 0 according to the preset scanning order.
[0462] Furthermore, the last coefficient position can be represented by (LastCoeffX, LastCoeffY), that is, the last position of all coefficients of the current block that may not be 0 according to the preset scanning order. In some embodiments, the method may further include:
[0463] Determining the width and height of a transformed block obtained by performing a preset operation on the current block;
[0464] Performing coordinate calculation according to the width and height of the transformation block to obtain coordinate information of the lower right corner of the transformation block;
[0465] The last coefficient position is determined according to the coordinate information of the lower right corner of the transform block.
[0466] Here, the preset operation at least includes: a forced zero-out operation.
[0467] It should be noted that (LastCoeffX, LastCoeffY) represents the coordinate information of the lower right corner of the transform block after zero-out; wherein, the derivation method of (LastCoeffX, LastCoeffY) is as follows:
[0468] LastCoeffX=(1< <log2ZoTbWidth)-1;LastCoeffY=(1<<log2ZoTbHeight)-1。
[0469] In this way, if the value of default_last_coeff_enabled_flag is 1, the last coefficient position can be determined according to (LastCoeffX, LastCoeffY).
[0470] In a specific 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 last position of all coefficients of the current block that may be 0 according to the preset scanning order. In some embodiments, the method may further include:
[0471] 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 lower right corner coordinate information of the transform block.
[0472] That is, the position of the last non-zero coefficient can be expressed as (LastSignificantCoeffX, LastSignificantCoeffY), and the derivation method of (LastSignificantCoeffX, LastSignificantCoeffY) is as follows:
[0473] LastSignificantCoeffX=(1< <log2ZoTbWidth)-1;LastSignificantCoeffY=(1<<log2ZoTbHeight)-1。
[0474] 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 based on (LastSignificantCoeffX, LastSignificantCoeffY).
[0475] Furthermore, in the case where the last coefficient position is not used in the current block, that is, the value of the last coefficient enable identification information is 0, in some embodiments, the method may further include:
[0476] Determine prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient;
[0477] determining a position of the last non-zero coefficient according to prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient;
[0478] All coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient are written into the code stream.
[0479] It should be noted that if the last coefficient position is not used in the current block, then the position of the last non-zero coefficient needs to be determined. Specifically, last_sig_coeff_x_prefix, last_sig_coeff_x_suffix, last_sig_coeff_y_prefix, and last_sig_coeff_y_suffix need to be determined and then written into the bitstream.
[0480] In this way, when encoding coefficients, it is necessary to encode all coefficients that may need to be encoded by default. That is to say, under normal circumstances, the coefficient encoding and decoding method is still the same as the existing method in the relevant technology. In some cases, such as high-bitwidth or high-quality or high-bitrate video or lossless compressed video encoding and decoding, it is necessary to encode all coefficients that may need to be encoded by default, that is, the position of the last non-zero coefficient is no longer used, but all coefficients of the current block that may not be 0 are scanned in the preset scanning order; in other words, the position of the last coefficient that needs to be encoded is placed at the last position of all coefficients of the current block that may not be 0 in the preset scanning order. This position usually refers to the lower right corner of the matrix composed of all coefficients of the current block that may not be 0. Therefore, the embodiment of the present application can reduce or even eliminate the relevant syntax elements about the last non-zero coefficient position by introducing the default_last_coeff_enabled_flag, which can save overhead and avoid waste.
[0481] Furthermore, when the video identification information indicates that the video meets the preset conditions, all scanned sub-blocks are encoded by default. In this case, there is no need to transmit the sb_coded_flag in the bitstream, that is, the encoder / decoder does not need to process this flag, thereby speeding up encoding and decoding. Therefore, embodiments of the present application can also introduce sub-block default encoding identification information to determine whether the sub-block to be decoded in the current block is encoded by default.
[0482] In some embodiments, when the video identification information indicates that the video meets a preset condition, the method may further include:
[0483] Determining sub-block default encoding identification information of a sub-block to be encoded in the current block;
[0484] When the sub-block default coding identification information indicates that the sub-block to be coded is coded by default, all coefficients in the sub-block to be coded are coded, and bit information obtained after coding and the sub-block default coding identification information are written into the bitstream.
[0485] It should be noted that the sub-block default identification information can be represented by default_sb_coded_flag. In the embodiment of the present application, the sub-block default coding identification information is at least one of the following identification information: sequence level, picture level, slice level, and block level; it can even be identification information at a higher level (such as VUI, SEI, etc.), without any limitation here.
[0486] It should also be noted that, with respect to the sub-block default identification information, in some embodiments, determining the sub-block default coding identification information of the sub-block to be encoded may include:
[0487] If the sub-block to be encoded is encoded by default, determining that the value of the sub-block default encoding identification information is a first value; or,
[0488] If the sub-block to be encoded is not encoded by default, it is determined that the value of the sub-block default encoding identification information is a second value.
[0489] 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 decoded 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 decoded does not need to be encoded by default, then the value of default_sb_coded_flag is 0.
[0490] When the sub-block to be decoded requires encoding 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 does not need to be encoded. However, when the sub-block to be decoded does not require encoding by default, that is, when the sub-block default encoding identification information indicates that the sub-block to be encoded is not encoded by default, in some embodiments, the method may further include: determining sub-block encoding identification information of the sub-block to be encoded, and writing the sub-block encoding identification information into the bitstream.
[0491] Furthermore, in some embodiments, determining the sub-block coding identification information of the sub-block to be encoded may include:
[0492] If encoding is required within the sub-block, determining the value of the sub-block encoding identification information to be the first value; or,
[0493] If all coefficients in the sub-block are zero, the value of the sub-block coding identification information is determined to be the second value.
[0494] In the embodiment of the present application, the sub-block coding identification information can be represented by sb_coded_flag. 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 coded needs to be encoded, which means that the sub-block to be coded contains non-zero coefficients to be coded, then the value of sb_coded_flag is 1; or if it is determined that the sub-block to be coded does not need to be encoded, which means that all coefficients in the sub-block to be coded are zero, then the value of sb_coded_flag is 0.
[0495] In this way, when encoding the coefficients, the scanned sub-blocks all need to be encoded by default, or in other words, the scanned sub-blocks all contain non-zero coefficients by default. That is to say, under normal circumstances, the coefficient encoding method is still the same as the existing method in the related art. In some cases, such as high-bitwidth or high-quality or high-bitrate video or lossless compressed video encoding and decoding, there are many non-zero coefficients in this case, and the scanned sub-blocks almost all need to be encoded; in other words, the scanned sub-blocks almost all contain non-zero coefficients. In this way, there is no need to transmit sb_coded_flag in the bitstream, and the encoder does not need to process this flag, thereby speeding up the encoding and decoding speed. Since an almost non-existent flag is removed, there will be a slight improvement in compression performance at this time.
[0496] This embodiment also provides a coefficient encoding method, applied to an encoder. The method comprises determining video identification information and the position of the last non-zero coefficient; determining the last non-zero coefficient position flip identification information when the video identification information indicates that the video meets a preset condition; determining the coordinate information of the last non-zero coefficient based on the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information; encoding all coefficients before the position of the last non-zero coefficient according to a preset scanning order, and writing the encoded bit information, video identification information, and the coordinate information of the last non-zero coefficient into the bitstream. In this way, in high-bitwidth, high-bitrate, high-quality, or lossless video encoding and decoding scenarios, since the coefficient distribution pattern differs from that in conventional video scenarios, the number of syntax elements encoded in context mode can be reduced or even eliminated during coefficient encoding, such as syntax elements related to the last non-zero coefficient position and sub-block coding identifier. Coordinate transformation can even be performed when the value of the coordinate information of the last non-zero coefficient is too large, thereby reducing the encoding overhead in the bitstream and improving the coefficient encoding throughput and encoding speed. Furthermore, since the reduced or eliminated syntax elements have little impact in high-bitwidth, high-bitrate, high-quality, or lossless video encoding, compression efficiency can also be improved.
[0497] In another embodiment of the present application, based on the same inventive concept as the above embodiment, see Figure 12, which shows a schematic diagram of the composition structure of an encoder 120 provided in an embodiment of the present application. As shown in Figure 12, the encoder 120 may include: a first determining unit 1201 and an encoding unit 1202; wherein,
[0498] The first determining unit 1201 is configured to determine video identification information and the position of the last non-zero coefficient; and when the video identification information indicates that the video meets a preset condition, determine the last non-zero coefficient position flip identification information;
[0499] The first determining unit 1201 is further configured to determine the coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information;
[0500] 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 encoded bit information, video identification information and coordinate information of the last non-zero coefficient into the bitstream.
[0501] In some embodiments, the first determining unit 1201 is further configured to determine that the value of the video identification information is a first value if the video meets a preset condition; or determine that the value of the video identification information is a second value if the video does not meet the preset condition.
[0502] In some embodiments, the preset condition includes at least one of the following: high bit width, high quality, high bit rate, high frame rate and lossless compression.
[0503] In some embodiments, the first determination unit 1201 is further configured to determine that the value of the last non-zero coefficient position flip identification information is a first value if the current block uses the last non-zero coefficient position flip; or, if the current block does not use the last non-zero coefficient position flip, determine that the value of the last non-zero coefficient position flip identification information is a second value.
[0504] In some embodiments, the position of the last non-zero coefficient includes an initial horizontal coordinate and an initial vertical coordinate of the last non-zero coefficient, where the initial horizontal coordinate and the initial vertical coordinate are a horizontal distance and a vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block;
[0505] Accordingly, the first determination unit 1201 is further configured to, if the value of the last non-zero coefficient position flip identification information is the first value, perform calculation based on the initial horizontal coordinate and initial vertical coordinate of the last non-zero coefficient to determine the coordinate information of the last non-zero coefficient; or, if the value of the last non-zero coefficient position flip identification information is the second value, directly determine the coordinate information of the last non-zero coefficient based on the initial horizontal coordinate and initial vertical coordinate of the last non-zero coefficient.
[0506] In some embodiments, the first determination unit 1201 is further configured to determine the width and height of the current block; perform 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 perform 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 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.
[0507] In some embodiments, the first determination unit 1201 is further configured to determine the coordinate information of the last non-zero coefficient 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 if the value of the last non-zero coefficient position flip identification information is the first value; or, if the value of the last non-zero coefficient position flip identification information is the second value, the coordinate information of the last non-zero coefficient 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.
[0508] In some embodiments, the encoding unit 1202 is further configured to determine, based on the coordinate information of the last non-zero coefficient, the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient; and write the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient into the bitstream.
[0509] In some embodiments, the last non-zero coefficient position flip identification information is at least one of the following identification information: sequence level, picture level, slice level and block level.
[0510] In some embodiments, the first determining unit 1201 is further configured to determine the last coefficient enabling identification information when the video identification information indicates that the video meets a preset condition;
[0511] 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 identification information indicates that the current block uses the last coefficient position, and write the bit information, video identification information and the last coefficient enable identification information obtained after encoding into the bitstream.
[0512] In some embodiments, the first determination unit 1201 is further configured to determine that the value of the last coefficient enable identification information is 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 that the value of the last coefficient enable identification information is a second value.
[0513] In some embodiments, the last coefficient position is the lower right corner position of the matrix consisting 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 order.
[0514] 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.
[0515] In some embodiments, the first determination unit 1201 is further configured to determine the width and height of the transformation block obtained by the current block after a preset operation; perform coordinate calculation based on the width and height of the transformation block to obtain the lower right corner coordinate information of the transformation block; and determine the last coefficient position based on the lower right corner coordinate information of the transformation block.
[0516] In some embodiments, the preset operation includes at least a forced zero-out operation.
[0517] In some embodiments, the first determining unit 1201 is further configured to determine the position of the last non-zero coefficient according to the lower right corner coordinate information of the transform block when the position of the last non-zero coefficient is set at the last coefficient position.
[0518] In some embodiments, the first determining unit 1201 is further configured to, when the current block does not use the last coefficient position, determine prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient; and determine the position of the last non-zero coefficient based on the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient;
[0519] 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 prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient into the bitstream.
[0520] In some embodiments, the last coefficient enable identification information is identification information of at least one of the following: sequence level, picture level, slice level, and block level.
[0521] In some embodiments, the first determining unit 1201 is further configured to determine sub-block default encoding identification information of a sub-block to be encoded in the current block when the video identification information indicates that the video meets a preset condition;
[0522] The encoding unit 1202 is further configured to encode all coefficients in the sub-block to be encoded when the sub-block default encoding identification information indicates that the sub-block to be encoded is encoded by default, and write the encoded bit information and the sub-block default encoding identification information into the bitstream.
[0523] In some embodiments, the first determining unit 1201 is further configured to determine subblock coding identification information of the subblock to be coded and write the subblock coding identification information into the bitstream when the subblock default coding identification information indicates that the subblock to be coded is not coded by default.
[0524] In some embodiments, the first determination unit 1201 is further configured to determine that the value of the sub-block default encoding identification information is a first value if the sub-block to be encoded is encoded by default; or, if the sub-block to be encoded is not encoded by default, determine that the value of the sub-block default encoding identification information is a second value.
[0525] In some embodiments, the first determination unit 1201 is further configured to determine that the value of the sub-block coding identification information is a first value if coding is required within the sub-block; or, if all coefficients within the sub-block are zero, determine that the value of the sub-block coding identification information is a second value.
[0526] In some embodiments, the sub-block default encoding identification information is at least one of the following identification information: sequence level, picture level, slice level, and block level.
[0527] In some embodiments, the first value is 1 and the second value is 0.
[0528] In some embodiments, the first determining unit 1201 is further configured to, when the video identification information is high-bitwidth identification information, determine that the high-bitwidth identification information indicates that the video meets a preset condition if the video meets the high-bitwidth requirement.
[0529] In some embodiments, the first determining unit 1201 is further configured to, when the video identification information is high bit rate identification information, if the video meets the high bit rate, determine that the high bit rate identification information indicates that the video meets a preset condition.
[0530] In some embodiments, the first determining unit 1201 is further configured to, when the video identification information is high-quality identification information, determine that the high-quality identification information indicates that the video meets a preset condition if the video meets high quality.
[0531] In some embodiments, the first determining unit 1201 is further configured to, when the video identification information is lossless compression identification information, determine that the lossless compression identification information indicates that the video meets a preset condition if the video meets lossless compression requirements.
[0532] It is understandable that in the embodiments of the present application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and of course it can also be a module, or it can be non-modular. Moreover, the various components in this embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into a single unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional modules.
[0533] 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, or the portion 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 for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0534] Therefore, an embodiment of the present application provides a computer storage medium, which is applied to the encoder 120. The computer storage medium stores a computer program, and when the computer program is executed by the first processor, it implements the method described in any one of the above embodiments.
[0535] Based on the composition of the above-mentioned encoder 120 and the computer storage medium, refer to Figure 13, which shows a specific hardware structure diagram of the encoder 120 provided in an embodiment of the present application. As shown in Figure 13, 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 can be understood that the first bus system 1304 is used to realize the connection and communication between these components. In addition to the data bus, the first bus system 1304 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, various buses are marked as the first bus system 1304 in Figure 13. Among them,
[0536] The first communication interface 1301 is used to receive and send signals when sending and receiving information with other external network elements;
[0537] A first memory 1302 is used to store computer programs that can be run on the first processor 1303;
[0538] The first processor 1303 is configured to, when running the computer program, execute:
[0539] Determine the video identification information and the position of the last non-zero coefficient;
[0540] When the video identification information indicates that the video meets a preset condition, determining the last non-zero coefficient position flip identification information;
[0541] Determine the coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information;
[0542] All coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the bit information, video identification information and coordinate information of the last non-zero coefficient obtained after encoding are written into the bit stream.
[0543] It is understood that the first memory 1302 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The first memory 1302 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0544] The first processor 1303 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in the first processor 1303. The above-mentioned first processor 1303 can 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. The various methods, steps, and logic block diagrams disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly implemented as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the first memory 1302 , and the first processor 1303 reads the information in the first memory 1302 and completes the steps of the above method in combination with its hardware.
[0545] It is to be understood that these embodiments described in the present application can be implemented with hardware, software, firmware, middleware, microcode or its combination.For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processor (Digital Signal Processing, DSP), digital signal processing equipment (DSP Device, DSPD), programmable logic device (Programmable Logic Device, PLD), field programmable gate array (Field-Programmable Gate Array, FPGA), general-purpose processor, controller, microcontroller, microprocessor, other electronic units for performing functions described in the present application or its combination.For software implementation, the technology described in the present application can be realized by the module (such as process, function etc.) that performs functions described in the present application. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0546] Optionally, as another embodiment, the first processor 1303 is further configured to execute any one of the methods described in the foregoing embodiments when running the computer program.
[0547] This embodiment provides an encoder that may include a first determining unit and an encoding unit. Thus, in high-bitwidth, high-bitrate, high-quality, or lossless video encoding and decoding scenarios, since coefficient distribution patterns differ from those in conventional video scenarios, the number of syntax elements encoded in context modes can be reduced or even eliminated during coefficient encoding, thereby reducing the encoding overhead in the bitstream and improving coefficient encoding throughput and encoding and decoding speed. Furthermore, since the reduced or eliminated syntax elements have little impact on high-bitwidth, high-bitrate, high-quality, or lossless video encoding and decoding, compression efficiency can also be improved.
[0548] In another embodiment of the present application, based on the same inventive concept as the above embodiment, refer to FIG14 , which shows a schematic diagram of the structure of a decoder 140 provided in an embodiment of the present application. As shown in FIG14 , the decoder 140 may include: a parsing unit 1401 and a second determining unit 1402; wherein,
[0549] The parsing unit 1401 is configured to parse the bitstream to obtain video identification information; and when the video identification information indicates that the video meets a preset condition, parse the bitstream to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient;
[0550] The second determining unit 1402 is configured to calculate the coordinate information of the last non-zero coefficient to determine the position of the last non-zero coefficient when the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip;
[0551] The parsing unit 1401 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.
[0552] In some embodiments, the second determining unit 1402 is further configured to directly determine the position of the last non-zero coefficient according to the coordinate information of the last non-zero coefficient when the last non-zero coefficient position flip identification information indicates that the current block does not use the last non-zero coefficient position flip;
[0553] The parsing unit 1401 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.
[0554] In some embodiments, the second determination unit 1402 is further configured to determine that the video identification information indicates that the video meets the preset condition if the value of the video identification information is the first value; or, if the value of the video identification information is the second value, determine that the video identification information indicates that the video does not meet the preset condition.
[0555] In some embodiments, the preset condition includes at least one of the following: high bit width, high quality, high bit rate, high frame rate and lossless compression.
[0556] In some embodiments, the second determination unit 1402 is further configured to, if the value of the last non-zero coefficient position flip identification information is the first value, determine that the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip; or, if the value of the last non-zero coefficient position flip identification information is the second value, determine that the last non-zero coefficient position flip identification information indicates that the current block does not use the last non-zero coefficient position flip.
[0557] In some embodiments, the parsing unit 1401 is further configured to parse the bitstream to obtain prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient;
[0558] The second determination unit 1402 is further configured to determine the horizontal coordinate of the last non-zero coefficient based on the prefix information of the horizontal coordinate of the last non-zero coefficient and the suffix information of the horizontal coordinate of the last non-zero coefficient; and determine the vertical coordinate of the last non-zero coefficient based on the prefix information of the vertical coordinate of the last non-zero coefficient and the suffix information of the vertical coordinate of the last non-zero coefficient; and 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.
[0559] In some embodiments, the second determining unit 1402 is further configured to, when the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, determine the coordinate information of the last non-zero coefficient 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;
[0560] Furthermore, the second determination unit 1402 is also configured to determine the width and height of the current block; perform subtraction calculation based on the width of the current block and the horizontal distance between the position of the last non-zero coefficient relative to the lower right corner position of the current block to obtain the horizontal coordinate of the last non-zero coefficient; and perform subtraction calculation based on the height of the current block and the vertical distance between the position of the last non-zero coefficient relative to the lower right corner position of the current block to obtain the vertical coordinate of the last non-zero coefficient; and determine the position 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.
[0561] In some embodiments, the second determination unit 1402 is further configured to, when the last non-zero coefficient position flip identification information indicates that the current block does not use the last non-zero coefficient position flip, determine the coordinate information of the last non-zero coefficient 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; and determine the position of the last non-zero coefficient based on 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.
[0562] In some embodiments, the last non-zero coefficient position flip identification information is at least one of the following identification information: sequence level, picture level, slice level, and block level.
[0563] In some embodiments, the parsing unit 1401 is further configured to parse the code stream to obtain the last coefficient enable identification information; and when the last coefficient enable identification information indicates that the current block uses the last coefficient position, all coefficients before the last coefficient position are decoded according to a preset scanning order to determine the coefficient of the current block.
[0564] In some embodiments, the second determination unit 1402 is further configured to determine that the last coefficient enable identification information indicates that the current block uses the last coefficient position if the value of the last coefficient enable identification information is the first value; or, if the value of the last coefficient enable identification information is the second value, determine that the last coefficient enable identification information indicates that the current block does not use the last coefficient position.
[0565] In some embodiments, the parsing unit 1401 is further configured to, when the value of the last coefficient enable identification information is the second value, parse the bitstream to obtain prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient;
[0566] The second determination unit 1402 is further configured to determine the position of the last non-zero coefficient based on the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient; and to decode all coefficients before the position of the last non-zero coefficient in a preset scanning order to determine the coefficient of the current block.
[0567] In some embodiments, the last coefficient position is the lower right corner position of the matrix consisting 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 order.
[0568] 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.
[0569] In some embodiments, the second determination unit 1402 is further configured to determine the width and height of the transformation block obtained by the current block after a preset operation; and perform coordinate calculation based on the width and height of the transformation block to obtain the lower right corner coordinate information of the transformation block; and determine the last coefficient position based on the lower right corner coordinate information of the transformation block.
[0570] In some embodiments, the preset operation includes at least a forced zero-out operation.
[0571] In some embodiments, the second determining unit 1402 is further configured to determine the position of the last non-zero coefficient according to the lower right corner coordinate information of the transform block when the position of the last non-zero coefficient is set at the last coefficient position.
[0572] In some embodiments, the last coefficient enable identification information is identification information of at least one of the following: sequence level, picture level, slice level, and block level.
[0573] In some embodiments, the parsing unit 1401 is further configured to parse the code stream and obtain sub-block default coding identification information when the video identification information indicates that the video meets a preset condition; and when the sub-block default coding identification information indicates that the sub-block to be decoded in the current block is encoded by default, determine that the value of the sub-block coding identification information is a first value, and decode all coefficients in the sub-block to be decoded.
[0574] In some embodiments, the parsing unit 1401 is further configured to parse the code stream to obtain the sub-block coding identification information when the sub-block default coding identification information indicates that the sub-block to be decoded is not encoded by default; and when the value of the sub-block coding identification information is the first value, decode all coefficients in the sub-block to be decoded.
[0575] In some embodiments, the second determination unit 1402 is further configured to, if the value of the sub-block default coding identification information is a first value, determine that the sub-block default coding identification information indicates that the sub-block to be decoded is default coded; or, if the value of the sub-block default coding identification information is a second value, determine that the sub-block default coding identification information indicates that the sub-block to be decoded is not default coded.
[0576] In some embodiments, the second determination 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 coding identification information is a first value; or, if the value of the sub-block coding identification information is a second value, determine that all coefficients in the sub-block to be decoded are zero.
[0577] In some embodiments, the sub-block default encoding identification information is at least one of the following identification information: sequence level, picture level, slice level, and block level.
[0578] In some embodiments, the first value is 1 and the second value is 0.
[0579] In some embodiments, the second determining unit 1402 is further configured to, when the video identification information is high-bitwidth identification information, determine that the video meets the preset condition if the high-bitwidth identification information indicates that the video meets the high-bitwidth.
[0580] In some embodiments, the second determining unit 1402 is further configured to, when the video identification information is high bit rate identification information, determine that the video meets the preset condition if the high bit rate identification information indicates that the video meets the high bit rate.
[0581] In some embodiments, the second determining unit 1402 is further configured to, when the video identification information is high-quality identification information, determine that the video meets a preset condition if the high-quality identification information indicates that the video meets high quality.
[0582] In some embodiments, the second determining unit 1402 is further configured to, when the video identification information is lossless compression identification information, determine that the video meets the preset condition if the lossless compression identification information indicates that the video meets the lossless compression requirements.
[0583] It is understandable that in the embodiments of the present application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and of course it can also be a module, or it can be non-modular. Moreover, the various components in this embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into a single unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional modules.
[0584] 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, or the portion 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 for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0585] Therefore, an embodiment of the present application provides a computer storage medium, which is applied to the decoder 140. The computer storage medium stores a computer program, and when the computer program is executed by the first processor, it implements any one of the methods in the aforementioned embodiments.
[0586] Based on the composition of the above-mentioned decoder 140 and the computer storage medium, refer to Figure 15, which shows a specific hardware structure diagram of the decoder 140 provided in an embodiment of the present application. As shown in Figure 15, it may include: a second communication interface 1501, a second memory 1502 and a second processor 1503; each component is coupled together through a second bus system 1504. It can be understood that the second bus system 1504 is used to realize the connection and communication between these components. In addition to the data bus, the second bus system 1504 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, various buses are marked as the second bus system 1504 in Figure 15. Among them,
[0587] The second communication interface 1501 is used to receive and send signals during the process of sending and receiving information between other external network elements;
[0588] The second memory 1502 is used to store computer programs that can be run on the second processor 1503;
[0589] The second processor 1503 is configured to, when running the computer program, execute:
[0590] Parse the code stream and obtain video identification information;
[0591] When the video identification information indicates that the video meets the preset condition, the code stream is parsed to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient;
[0592] When the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, the coordinate information of the last non-zero coefficient is calculated to determine the position of the last non-zero coefficient;
[0593] All coefficients before the position of the last non-zero coefficient are decoded in a preset scanning order to determine the coefficients of the current block.
[0594] Optionally, as another embodiment, the second processor 1503 is further configured to execute any one of the methods described in the foregoing embodiments when running the computer program.
[0595] It can be 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; they will not be described in detail here.
[0596] This embodiment provides a decoder that may include a parsing unit and a second determining unit. Thus, in high-bitwidth, high-bitrate, high-quality, or lossless video scenarios, since the coefficient distribution pattern is different from that in conventional video encoding and decoding scenarios, the number of syntax elements encoded in the context mode can be reduced or even eliminated in coefficient encoding, thereby reducing the encoding overhead in the bitstream and improving the coefficient encoding throughput and encoding and decoding speed. In addition, since the reduced or eliminated syntax elements have little impact on high-bitwidth, high-bitrate, high-quality, or lossless video encoding and decoding, compression efficiency can also be improved.
[0597] It should be noted that, in this application, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0598] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0599] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0600] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0601] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0602] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims. Industrial Applicability
[0603] In the embodiments of the present application, whether it is an encoder or a decoder, in a high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding scenario, since the coefficient distribution pattern is different from that in a conventional video scenario, in the coefficient encoding, the number of syntax elements encoded in the context mode is reduced or even eliminated, such as syntax elements such as the position of the last non-zero coefficient and the sub-block coding identifier, and even coordinate transformation can be performed when the value of the coordinate information of the last non-zero coefficient is relatively large, thereby reducing the overhead caused by encoding in the bitstream and thus improving the coefficient encoding throughput and encoding and decoding speed; in addition, since the reduced or eliminated syntax elements have little impact on high-bit-width, high-bit-rate, high-quality or lossless video encoding and decoding, the compression efficiency can also be improved.
Claims
1. A coefficient decoding method, applied to a decoder, the method include: Parse the code stream and obtain video identification information; When the video identification information indicates that the video meets a preset condition, parsing the bitstream to obtain the last non-zero coefficient position flip identification information and the last non-zero coefficient coordinate information; When the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, calculating the coordinate information of the last non-zero coefficient to determine the position of the last non-zero coefficient; All coefficients before the position of the last non-zero coefficient are decoded in a preset scanning order to determine the coefficients of the current block.
2. The method according to claim 1, in, The method further comprises: When the last non-zero coefficient position flip identification information indicates that the current block does not use the last non-zero coefficient position flip, directly determining the position of the last non-zero coefficient according to the coordinate information of the last non-zero coefficient; All coefficients before the position of the last non-zero coefficient are decoded in a preset scanning order to determine the coefficients of the current block.
3. The method according to claim 1, in, The method further comprises: If the value of the video identification information is the first value, it is determined that the video identification information indicates that the video meets a preset condition; or, If the value of the video identification information is the second value, it is determined that the video identification information indicates that the video does not meet a preset condition.
4. The method according to claim 3, in, The preset condition includes 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 claim 1, in, The method further comprises: If the value of the last non-zero coefficient position flipping identification information is the first value, determining that the last non-zero coefficient position flipping identification information indicates that the current block uses the last non-zero coefficient position flipping; or If the value of the last non-zero coefficient position flipping identification information is the second value, it is determined that the last non-zero coefficient position flipping identification information indicates that the current block does not use the last non-zero coefficient position flipping.
6. The method according to claim 1, in, The parsing of the bitstream to obtain the coordinate information of the last non-zero coefficient includes: Parsing the bitstream to obtain prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient; Determine the horizontal coordinate of the last non-zero coefficient according to the prefix information of the horizontal coordinate of the last non-zero coefficient and the suffix information of the horizontal coordinate of the last non-zero coefficient; Determining the vertical coordinate of the last non-zero coefficient according to the prefix information of the vertical coordinate of the last non-zero coefficient and the suffix information of the vertical coordinate of the last non-zero coefficient; Coordinate information of the last non-zero coefficient is determined according to the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.
7. The method according to claim 1, in, The method further comprises: When the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip, determining the coordinate information of the last non-zero coefficient as a horizontal distance and a vertical distance between the position of the last non-zero coefficient and the lower right corner position of the current block; Accordingly, calculating the coordinate information of the last non-zero coefficient to determine the position 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 horizontal distance between the position of the last non-zero coefficient and the lower right corner of the current block to obtain the horizontal coordinate of the last non-zero coefficient; and Subtracting the height of the current block from the vertical distance between the position of the last non-zero coefficient and the lower right corner of the current block to obtain the vertical coordinate of the last non-zero coefficient; The position of the last non-zero coefficient is determined according to the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.
8. The method according to claim 1, in, The method further comprises: When the last non-zero coefficient position flip identification information indicates that the current block does not use the last non-zero coefficient position flip, determining the coordinate information of the last non-zero coefficient as a horizontal distance and a vertical distance between the position of the last non-zero coefficient and the upper left corner position of the current block; The position of the last non-zero coefficient is determined according to a horizontal distance and a vertical distance between the position of the last non-zero coefficient and the upper left corner position of the current block.
9. The method according to claim 1, in, The last non-zero coefficient position flip identification information is at least one of the following identification information: sequence level, picture level, slice level and block level.
10. The method according to any one of claims 1 to 9, in, When the video identification information indicates that the video meets a preset condition, the method further includes: Parsing the bitstream to obtain the last coefficient enable identification information; When the last coefficient enable identification information indicates that the current block uses the last coefficient position, all coefficients before the last coefficient position are decoded according to a preset scanning order to determine the coefficients of the current block.
11. The method according to claim 10, in, The method further comprises: If the value of the last coefficient enable identification information is the first value, determining that the last coefficient enable identification information indicates that the current block uses the last coefficient position; or, If the value of the last coefficient enable identification information is the second value, it is determined that the last coefficient enable identification information indicates that the current block does not use the last coefficient position.
12. The method according to claim 11, in, When the value of the last coefficient enabling identification information is a second value, the method further includes: Parsing the bitstream to obtain prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient; Determine the position of the last non-zero coefficient according to the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient; All coefficients before the position of the last non-zero coefficient are decoded in a preset scanning order to determine the coefficients of the current block.
13. The method according to claim 10, in, The last coefficient position is the lower right corner position of the matrix composed of all coefficients that may not be zero in the current block; or, The last coefficient position is the last position of the current block after scanning all coefficients that may not be zero according to a preset scanning order.
14. The method according to claim 10, in, The method further comprises: The position of the last non-zero coefficient is set at the last coefficient position.
15. The method according to claim 10, in, The method further comprises: Determining the width and height of a transformed block of the current block after a preset operation; Calculating coordinates according to the width and height of the transformation block to obtain coordinate information of the lower right corner of the transformation block; The last coefficient position is determined according to the lower right corner coordinate information of the transform block.
16. The method according to claim 15, in, The preset operation at least includes: a forced zero-out operation.
17. The method according to claim 15, in, The method further comprises: 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 lower right corner coordinate information of the transform block.
18. The method according to claim 10, in, The last coefficient enabling identification information is at least one of the following identification information: sequence level, picture level, slice level and block level.
19. The method according to any one of claims 1 to 18, in, When the video identification information indicates that the video meets a preset condition, the method further includes: Parsing the bitstream to obtain sub-block default encoding identification information; When the sub-block default coding identification information indicates the default coding of the sub-block to be decoded in the current block, the value of the sub-block coding identification information is determined to be a first value, and all coefficients in the sub-block to be decoded are decoded.
20. The method according to claim 19, in, When the sub-block default encoding identification information indicates that the sub-block to be decoded is not encoded by default, the method further includes: Parsing the code stream to obtain sub-block coding identification information; When the value of the sub-block encoding identification information is the first value, all coefficients in the sub-block to be decoded are decoded.
21. The method according to claim 19, in, The method further comprises: If the value of the sub-block default coding identification information is the first value, determining that the sub-block default coding identification information indicates the default coding of the sub-block to be decoded; or, If the value of the sub-block default encoding identification information is the second value, it is determined that the sub-block default encoding identification information indicates that the sub-block to be decoded is not encoded by default.
22. The method according to claim 19, in, The method further comprises: If the value of the sub-block coding identification information is the first value, it is determined to decode all coefficients in the sub-block to be decoded; or, If the value of the sub-block encoding identification information is the second value, it is determined that all coefficients in the sub-block to be decoded are zero.
23. The method according to claim 19, in, The sub-block default encoding identification information is at least one of the following identification information: sequence level, picture level, slice level and block level.
24. The method according to claim 3 or 5 or 11 or 21 or 22, in, The first value is 1, and the second value is 0.
25. The method according to claim 1, in, When the video identification information is high bit width identification information, the method further includes: If the high bit width identification information indicates that the video meets the high bit width, it is determined that the video meets the preset condition.
26. The method according to claim 1, in, When the video identification information is high bit rate identification information, the method further includes: If the high bit rate identification information indicates that the video meets a high bit rate, it is determined that the video meets a preset condition.
27. The method according to claim 1, in, When the video identification information is high-quality identification information, the method further includes: If the high-quality identification information indicates that the video meets high quality, it is determined that the video meets a preset condition.
28. The method according to claim 1, in, When the video identification information is lossless compression identification information, the method further includes: If the lossless compression identification information indicates that the video satisfies lossless compression, it is determined that the video satisfies a preset condition.
29. A coefficient encoding method, applied to an encoder, the method include: Determine the video identification information and the position of the last non-zero coefficient; When the video identification information indicates that the video meets a preset condition, determining the last non-zero coefficient position flip identification information; Determining coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information; All coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the bit information obtained after encoding, the video identification information and the coordinate information of the last non-zero coefficient are written into the bit stream.
30. The method according to claim 29, in, The determining of the video identification information includes: If the video meets the preset condition, determining that the value of the video identification information is a first value; or, If the video does not meet the preset condition, it is determined that the value of the video identification information is a second value.
31. The method according to claim 30, in, The preset condition includes at least one of the following: high bit width, high quality, high bit rate, high frame rate and lossless compression.
32. The method according to claim 29, in, The determining of the last non-zero coefficient position flip identification information includes: If the current block uses the last non-zero coefficient position flipping, determining that the value of the last non-zero coefficient position flipping identification information is the first value; or, If the current block does not use the last non-zero coefficient position flipping, it is determined that the value of the last non-zero coefficient position flipping identification information is a second value.
33. The method according to claim 32, in, The position of the last non-zero coefficient includes an initial horizontal coordinate and an initial vertical coordinate of the last non-zero coefficient, wherein the initial horizontal coordinate and the initial vertical coordinate are a horizontal distance and a vertical distance between the position of the last non-zero coefficient and the upper left corner of the current block; Accordingly, determining the coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information includes: If the value of the last non-zero coefficient position flip identification information is the first value, calculating according to the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient to determine the coordinate information of the last non-zero coefficient; or, If the value of the last non-zero coefficient position flip identification information is the second value, the coordinate information of the last non-zero coefficient is directly determined according to the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient.
34. The method according to claim 33, in, The calculating according to the initial horizontal coordinate and the initial vertical coordinate of the last non-zero coefficient to determine the coordinate information of the last non-zero coefficient includes: Determining the width and height of the current block; Subtracting the initial horizontal coordinate of the last non-zero coefficient from the width of the current block to obtain the horizontal coordinate of the last non-zero coefficient; and 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; Coordinate information of the last non-zero coefficient is determined according to the horizontal coordinate of the last non-zero coefficient and the vertical coordinate of the last non-zero coefficient.
35. The method according to claim 33, in, The method further comprises: If the value of the last non-zero coefficient position flip identification information is the first value, determining the coordinate information of the last non-zero coefficient as the horizontal distance and the vertical distance between the position of the last non-zero coefficient and the lower right corner position of the current block; or If the value of the last non-zero coefficient position flip identification information is the second value, the coordinate information 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.
36. The method according to claim 29, in, Writing the coordinate information of the last non-zero coefficient into the bitstream includes: Determine, according to the coordinate information of the last non-zero coefficient, prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient; The prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient are written into the bitstream.
37. The method according to claim 29, in, The last non-zero coefficient position flip identification information is at least one of the following identification information: sequence level, picture level, slice level and block level.
38. A method according to any one of claims 29 to 37, in, When the video identification information indicates that the video meets a preset condition, the method further includes: Determine the last coefficient enable identification information; When the last coefficient enable identification information indicates that the current block uses the last coefficient position, all coefficients before the last coefficient position are encoded according to a preset scanning order, and the encoded bit information, the video identification information and the last coefficient enable identification information are written into the bitstream.
39. The method according to claim 38, in, The determining of the last coefficient enabling identification information includes: If the current block uses the last coefficient position, determining that the value of the last coefficient enable identification information is a first value; or, If the current block does not use the last coefficient position, it is determined that the value of the last coefficient enable identification information is a second value.
40. The method according to claim 38, in, The last coefficient position is the lower right corner position of the matrix composed of all coefficients that may not be zero in the current block; or, The last coefficient position is the last position of the current block after scanning all coefficients that may not be zero according to a preset scanning order.
41. The method according to claim 38, in, The method further comprises: The position of the last non-zero coefficient is set at the last coefficient position.
42. The method according to claim 38, in, The method further comprises: Determining the width and height of a transformed block of the current block after a preset operation; Calculating coordinates according to the width and height of the transformation block to obtain coordinate information of the lower right corner of the transformation block; The last coefficient position is determined according to the lower right corner coordinate information of the transform block.
43. The method according to claim 42, in, The preset operation at least includes: a forced zero-out operation.
44. The method according to claim 42, in, The method further comprises: 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 lower right corner coordinate information of the transform block.
45. The method according to claim 39, in, When the current block does not use the last coefficient position, the method further includes: Determine prefix information of the horizontal coordinate of the last non-zero coefficient, prefix information of the vertical coordinate of the last non-zero coefficient, suffix information of the horizontal coordinate of the last non-zero coefficient, and suffix information of the vertical coordinate of the last non-zero coefficient; Determine the position of the last non-zero coefficient according to the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient; All coefficients before the position of the last non-zero coefficient are encoded according to a preset scanning order, and the prefix information of the horizontal coordinate of the last non-zero coefficient, the prefix information of the vertical coordinate of the last non-zero coefficient, the suffix information of the horizontal coordinate of the last non-zero coefficient, and the suffix information of the vertical coordinate of the last non-zero coefficient are written into the bitstream.
46. The method according to claim 38, in, The last coefficient enabling identification information is at least one of the following identification information: sequence level, picture level, slice level and block level.
47. A method according to any one of claims 29 to 46, in, When the video identification information indicates that the video meets a preset condition, the method further includes: Determining sub-block default encoding identification information of a sub-block to be encoded in the current block; When the sub-block default coding identification information indicates that the sub-block to be coded is coded by default, all coefficients in the sub-block to be coded are coded, and bit information obtained after coding and the sub-block default coding identification information are written into a bitstream.
48. The method according to claim 47, in, The method further comprises: When the sub-block default encoding identification information indicates that the to-be-encoded sub-block is not encoded by default, the sub-block encoding identification information of the to-be-encoded sub-block is determined, and the sub-block encoding identification information is written into a bitstream.
49. The method according to claim 47, in, The determining of the sub-block default encoding identification information of the sub-block to be encoded includes: If the sub-block to be encoded is encoded by default, determining that the value of the sub-block default encoding identification information is a first value; or, If the sub-block to be encoded is not encoded by default, it is determined that the value of the sub-block default encoding identification information is a second value.
50. The method according to claim 48, in, The determining the sub-block coding identification information of the sub-block to be encoded includes: If the sub-block needs to be encoded, determining that the value of the sub-block encoding identification information is a first value; or, If all coefficients in the sub-block are zero, it is determined that the value of the sub-block encoding identification information is a second value.
51. The method according to claim 47, in, The sub-block default encoding identification information is at least one of the following identification information: sequence level, picture level, slice level and block level.
52. The method of claim 30 or 32 or 39 or 49 or 50, in, The first value is 1, and the second value is 0.
53. The method according to claim 29, in, When the video identification information is high bit width sequence identification information, the method further includes: If the video meets the high bit width, it is determined that the high bit width sequence identification information indicates that the video meets a preset condition.
54. The method according to claim 29, in, When the video identification information is high bit rate identification information, the method further includes: If the video meets the high bit rate requirement, it is determined that the high bit rate identification information indicates that the video meets a preset condition.
55. The method according to claim 29, in, When the video identification information is high-quality identification information, the method further includes: If the video meets the high quality requirement, it is determined that the high quality identification information indicates that the video meets a preset condition.
56. The method according to claim 29, in, When the video identification information is lossless compression identification information, the method further includes: If the video satisfies lossless compression, it is determined that the lossless compression identification information indicates that the video satisfies a preset condition.
57. An encoder, comprising a first determining unit and an encoding unit; in, The first determination unit is configured to determine the video identification information and the position of the last non-zero coefficient; and when the video identification information indicates that the video meets a preset condition, determine the last non-zero coefficient position flip identification information; The first determining unit is further configured to determine the coordinate information of the last non-zero coefficient according to the position of the last non-zero coefficient and the last non-zero coefficient position flip identification information; 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 video identification information and the coordinate information of the last non-zero coefficient into the bit stream.
58. An encoder comprising a first memory and a first processor; in, The first memory is used to store a computer program that can be run on the first processor; The first processor is configured to execute the method according to any one of claims 29 to 56 when running the computer program.
59. A decoder, the decoder comprising a parsing unit and a second determining unit; in, The parsing unit is configured to parse the bitstream to obtain video identification information; and when the video identification information indicates that the video meets a preset condition, parse the bitstream to obtain the last non-zero coefficient position flip identification information and the coordinate information of the last non-zero coefficient; The second determining unit is configured to calculate the coordinate information of the last non-zero coefficient to determine the position of the last non-zero coefficient when the last non-zero coefficient position flip identification information indicates that the current block uses the last non-zero coefficient position flip; 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.
60. A decoder comprising a second memory and a second processor; in, The second memory is used to store a computer program that can be run on the second processor; The second processor is configured to execute the method according to any one of claims 1 to 28 when running the computer program.
61. A computer storage medium, in, The computer storage medium stores a computer program, and when the computer program is executed, it implements the method according to any one of claims 1 to 28, or implements the method according to any one of claims 29 to 56.