Coefficient coding method, coding device and storage medium
By optimizing the coefficient encoding and decoding method and utilizing syntax elements such as non-zero flags, absolute value greater than Xi flags, modulo result flags, and sign flags, the shortcomings of existing video compression technologies in terms of bandwidth and traffic pressure are solved, and more efficient video data transmission and storage are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-12
- Publication Date
- 2026-03-24
AI Technical Summary
Existing video compression technologies still have room for improvement in reducing digital video transmission bandwidth and traffic pressure, especially in utilizing the statistical characteristics of video compression standards, where existing coefficient entropy coding methods have not been fully optimized.
A novel coefficient encoding and decoding method is adopted. By parsing the bitstream and decoding and encoding the syntax elements of the coefficients to be decoded, the entropy encoding process of the coefficients is optimized by using syntax elements such as non-zero flags, absolute value greater than Xi flags, modulo result flags, residual value flags, and sign flags, combined with modulo operations and pre-set encoding values.
It improves video compression efficiency, reduces data transmission and storage requirements, and enhances video encoding and decoding performance.
Smart Images

Figure CN119893123B_ABST
Abstract
Description
[0001] This disclosure is a divisional application of Chinese Patent Application No. 202180095282.6, entitled "Coefficient Encoding / Decoding Method, Encoding / Decoding Device and Storage Medium", which entered the Chinese national phase of PCT international patent application PCT / CN2021 / 080635, filed on March 12, 2021. Technical Field
[0002] This disclosure relates to, but is not limited to, video encoding and decoding technology, and particularly provides a coefficient encoding and decoding method, encoding and decoding device, and storage medium. Background Technology
[0003] Digital video compression technology primarily compresses massive amounts of digital video data to facilitate transmission and storage. With the surge in internet video and increasing demands for video clarity, while existing digital video compression standards can save considerable video data, there is still a need to pursue better digital video compression technologies to reduce the bandwidth and traffic burden of digital video transmission. Summary of the Invention
[0004] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of the claims.
[0005] This disclosure provides a coefficient decoding method, including:
[0006] Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded;
[0007] The value of the coefficient to be decoded is determined based on the decoded syntax elements;
[0008] The syntax elements include: a non-zero flag, and M absolute values greater than X. i Flags, modulo result flags, residual value flags, and sign flags; the absolute value of the coefficient to be decoded is the encoded value of the non-zero flag, and M absolute values greater than X. i The sum of the pre-set corresponding values of the encoded values of the flag and the encoded values of the modulo result flag, plus the product of the encoded value of the residual value flag and N, is the obtained sum value; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient to be decoded and the sign flag indicating positive or negative; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, i≥M, i and M are positive integers, N is a positive integer greater than 1, X i X is a positive integer and X takes different values when i is different. i The values are different and increase with the value of i.
[0009] This disclosure provides a coefficient encoding method, including:
[0010] A coefficient block is generated based on the residual block, the coefficients in the coefficient block are scanned, and the syntax elements of the coefficients to be encoded are encoded.
[0011] Write the encoded codewords into the bitstream;
[0012] The syntax elements include: a non-zero flag, and M absolute values greater than X. i Flags, modulo result flags, residual value flags, and sign flags; the absolute value of the coefficient to be decoded is the encoded value of the non-zero flag, and M absolute values greater than X. i The sum of the pre-set corresponding values of the encoded values of the flag and the encoded values of the modulo result flag, plus the product of the encoded value of the residual value flag and N, is the obtained sum value; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient to be decoded and the sign flag indicating positive or negative; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, i≥M, i and M are positive integers, N is a positive integer greater than 1, X i X is a positive integer and X takes different values when i is different. i The values are different and increase with the value of i. This disclosure provides a coefficient decoding method, including:
[0013] The acquired bitstream is parsed, and the syntax elements of the coefficients to be decoded are decoded; the value of the coefficients to be decoded is determined based on the decoded syntax elements.
[0014] The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the pre-set corresponding values of the encoded values of the non-zero flag, the absolute value greater than 1 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5. This disclosure provides a coefficient encoding method, including:
[0015] A coefficient block is generated based on the residual block, the coefficients in the coefficient block are scanned, and the syntax elements of the coefficients to be encoded are encoded.
[0016] Write the encoded codewords into the bitstream;
[0017] The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the pre-set corresponding values of the encoded values of the non-zero flag, the absolute value greater than 1 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5. This disclosure provides a coefficient decoding method, including:
[0018] The acquired bitstream is parsed, and the syntax elements of the coefficients to be decoded are decoded; the value of the coefficients to be decoded is determined based on the decoded syntax elements.
[0019] The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, an absolute value greater than 2 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the pre-set corresponding values of the non-zero flag, the absolute value greater than 1 flag, the absolute value greater than 2 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5. This disclosure provides a coefficient encoding method, including:
[0020] A coefficient block is generated based on the residual block, the coefficients in the coefficient block are scanned, and the syntax elements of the coefficients to be encoded are encoded.
[0021] Write the encoded codewords into the bitstream;
[0022] The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, an absolute value greater than 2 flag, a modulo result flag, a residual value flag, and a sign flag. The absolute value of the coefficient to be decoded is the sum of the corresponding pre-set values of the non-zero flag, the absolute value greater than 1 flag, the absolute value greater than 2 flag, and the modulo result flag, plus the product of the residual value flag and N. The value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign. The encoded value of the modulo result flag is determined by taking the coefficient modulo N, where N = 2, 3, 4, or 5. This disclosure provides a decoding device, including: a processor and a memory storing a computer program executable on the processor, wherein the processor implements the coefficient decoding method described above when executing the computer program.
[0023] This disclosure provides an encoding device, including: a processor and a memory storing a computer program executable on the processor, wherein the processor executes the computer program to implement the coefficient encoding method described in any of the preceding claims.
[0024] This disclosure provides a non-transient computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements either the coefficient decoding method or the coefficient encoding method described above.
[0025] After reading and understanding the accompanying diagrams and detailed descriptions, the other aspects can be understood. Attached Figure Description
[0026] The accompanying drawings are provided to illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the technical solutions of this disclosure and do not constitute a limitation on the technical solutions of this disclosure.
[0027] Figure 1 This is a schematic diagram of a video compression coding framework;
[0028] Figure 2 This is a schematic diagram of a diagonal scan in VVC;
[0029] Figure 3 This is a schematic diagram of an absolute value encoding method for coefficients in VVC;
[0030] Figure 4 This is a schematic diagram of an anti-zig-zag scan in AVS;
[0031] Figure 5 This is a schematic diagram of an absolute value encoding method for coefficients in AVS;
[0032] Figure 6 This is a schematic flowchart of a coefficient decoding method according to an embodiment of the present disclosure;
[0033] Figure 7 This is a schematic flowchart of a coefficient encoding method according to an embodiment of the present disclosure;
[0034] Figure 8 This is a schematic flowchart of a coefficient decoding method according to an embodiment of the present disclosure;
[0035] Figure 9 This is a schematic flowchart of a coefficient encoding method according to an embodiment of the present disclosure;
[0036] Figure 10 This is a schematic diagram of an absolute value encoding method for coefficients modulo 3 in an exemplary embodiment of this disclosure;
[0037] Figure 11 This is a flowchart illustrating a coefficient encoding method in an exemplary embodiment of this disclosure;
[0038] Figure 12 This is an example diagram of diagonal scanning in an exemplary embodiment of this disclosure;
[0039] Figure 13 This is a schematic diagram illustrating the encoding of the scanned coefficient string in an exemplary embodiment of this disclosure;
[0040] Figure 14 This is a flowchart illustrating a coefficient decoding method in an exemplary embodiment of this disclosure;
[0041] Figure 15 This is a schematic diagram of an absolute value encoding method for coefficients modulo 3 in an exemplary embodiment of this disclosure;
[0042] Figure 16 This is a flowchart illustrating a coefficient encoding method in an exemplary embodiment of this disclosure;
[0043] Figure 17 This is a flowchart illustrating a coefficient decoding method in an exemplary embodiment of this disclosure;
[0044] Figure 18 This is a schematic diagram of an absolute value encoding method for coefficients modulo 5 in an exemplary embodiment of this disclosure;
[0045] Figure 19 This is a flowchart illustrating a coefficient encoding method in an exemplary embodiment of this disclosure;
[0046] Figure 20 This is a flowchart illustrating a coefficient decoding method in an exemplary embodiment of this disclosure;
[0047] Figure 21This is a schematic diagram of an absolute value encoding method for coefficients modulo 4 in an exemplary embodiment of this disclosure;
[0048] Figure 22 This is a flowchart illustrating a coefficient encoding method in an exemplary embodiment of this disclosure;
[0049] Figure 23 This is a flowchart illustrating a coefficient decoding method in an exemplary embodiment of this disclosure;
[0050] Figure 24 This is a schematic flowchart of a coefficient decoding method according to an embodiment of the present disclosure;
[0051] Figure 25 This is a schematic flowchart of a coefficient encoding method according to an embodiment of the present disclosure;
[0052] Figure 26 This is a schematic flowchart of a coefficient decoding method according to an embodiment of the present disclosure;
[0053] Figure 27 This is a schematic flowchart of a coefficient encoding method according to an embodiment of the present disclosure;
[0054] Figure 28 This is a schematic diagram of the structure of the encoding device according to an embodiment of the present disclosure;
[0055] Figure 29 This is a structural block diagram of a video encoder in an exemplary embodiment of the present disclosure;
[0056] Figure 30 This is a schematic diagram of the structure of the decoding device according to an embodiment of the present disclosure;
[0057] Figure 31 This is a structural block diagram of a video decoder in an exemplary embodiment of the present disclosure. Detailed Implementation
[0058] This disclosure describes several embodiments, but these descriptions are exemplary and not restrictive, and it will be apparent to those skilled in the art that more embodiments and implementations are possible within the scope of the embodiments described herein.
[0059] In this disclosure, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or illustration. Any embodiment described as "exemplary" or "for example" in this disclosure should not be construed as being more preferred or advantageous than other embodiments.
[0060] In describing representative exemplary embodiments, the specification may have presented methods and / or processes as a specific sequence of steps. However, the method or process should not be limited to the specific order of steps described herein, to the extent that it does not depend on such a specific order. Other sequences of steps are possible, as will be understood by those skilled in the art. Therefore, the specific order of steps set forth in the specification should not be construed as a limitation of the claims. Furthermore, the claims relating to the method and / or process should not be limited to the steps performed in the order written, and those skilled in the art will readily understand that these orders may be varied and still remain within the spirit and scope of the embodiments disclosed herein.
[0061] Video codec standards include H.264 / Advanced Video Coding (AVC), H.265 / High Efficiency Video Coding (HEVC), H.266 / Versatile Video Coding (VVC), and extensions to these standards, such as MPEG (Moving Picture Experts Group), AOM (Alliance for Open Media), or any other custom standards. These standards reduce the amount of data transmitted and stored through video compression technology to achieve more efficient video codecs, decoding, transmission, and storage.
[0062] Video compression includes multiple modules such as intra-frame prediction (spatial domain) and / or inter-frame prediction (temporal domain) to reduce or remove redundancy within the video, transformation, quantization, and inverse quantization of residual information, and loop filtering and entropy coding to improve the quality of subjective and objective reconstruction. Figure 1 This is a schematic diagram of a video compression coding framework, as shown below. Figure 1 As shown, it includes modules such as intra-frame prediction, motion estimation / compensation, transform / quantization, inverse transform / inverse quantization, loop filtering, and entropy coding.
[0063] Some video compression standards are block-based compression techniques. For example, a video clip, a frame, or a series of images can be divided into Coding Tree Units (CTUs), and then each CTU can be further divided into image blocks with CUs (Coding Units) as the basic unit. Intra-frame prediction refers to prediction using the pixels surrounding the block as a reference, while inter-frame prediction refers to prediction using information from neighboring blocks in the reference space and reference information from other frames. Through intra-frame or inter-frame prediction, the predicted block of the CU to be encoded can be obtained. Residual information represents the pixel difference between the original CU to be encoded and the predicted CU, also known as the residual block. In contrast to the predicted signal, the residual block can be transformed, quantized, and entropy-encoded into a bitstream for transmission or storage. For example, for better compression, the residual information can be transformed from the pixel domain to the transform domain to obtain residual coefficients. These coefficients can then be quantized into a one-dimensional vector by scanning the coefficients in coefficient order. The transformed and quantized coefficients can be applied to entropy coding to achieve greater compression. These video compression techniques are described in standards and implemented in various fields related to video compression.
[0064] The following section will introduce some concepts involved in the embodiments of this disclosure.
[0065] A Coding Unit (CU) is the basic unit for performing various types of encoding or decoding operations during video encoding and decoding, such as CU-based prediction, transform, entropy coding, and other operations. A CU refers to a two-dimensional array of sampled points, which can be a square array or a rectangular array. For example, a 4x8 CU can be viewed as a square array of 32 sampled points (4x8). A CU can also be called an image block.
[0066] The current coding unit (CU) refers to the coding unit currently being processed, also known as the current block. For example, in encoding, the current CU refers to the CU currently being encoded; in decoding, the current CU refers to the CU currently being decoded.
[0067] Reference CU: This refers to the CU that provides a reference signal for the current CU, and can also be called a reference block. The pixels of the reference CU refer to the pixels contained within that reference CU.
[0068] Prediction CU: This refers to the CU that provides predictions for the current CU, also known as a prediction unit (PU). Each CU can contain one or more PUs. PUs can include pixel data in the spatial domain (also known as the pixel domain).
[0069] A residual block is a residual image block formed by subtracting the prediction block from the current block to be encoded after inter-frame prediction and / or intra-frame prediction has generated the prediction block of the current block. It can also be called residual data.
[0070] A transform unit (TU) is a block that transforms residual data to represent either residuals or transform coefficients; it can also be called a transform block. Each core (CU) can contain one or more TUs. For example, residual data can be transformed into coefficients using discrete cosine transform, integer transform, wavelet transform, or similar transforms, that is, transforming the residual data from the pixel domain to the transform domain.
[0071] The coefficient block includes a transformed block containing transformed coefficients obtained by transforming the residual block, or a residual block containing residual data (residual signal) without transformation.
[0072] In this embodiment of the disclosure, the coefficients include the coefficients of the transform block obtained by transforming the residual block, or the coefficients of the residual block. Entropy encoding of the coefficients includes entropy encoding of the coefficients of the transform block after quantization, or, if the transform is not applied to the residual data, entropy encoding of the coefficients of the residual block after quantization.
[0073] The untransformed residual signal and the transformed residual signal can also be collectively referred to as coefficients. For effective compression, coefficients generally need to be quantized. Quantized coefficients can also be called levels.
[0074] Quantization is typically used to reduce the dynamic range of coefficients, thereby representing video with fewer codewords. The quantized value is usually called a level. Quantization is usually performed by dividing the coefficient by the quantization step size, which is determined by the quantization factor transmitted in the bitstream. Inverse quantization is performed by multiplying the level by the quantization step size. For an N x M block, the quantization of all coefficients can be performed independently. This technique is widely used in many international video compression standards, such as H.264 and HEVC. In the VVC international video compression standard, quantization can leverage the correlation between coefficients and the characteristics of quantized coefficients to select a better quantization method, thus optimizing quantization.
[0075] Entropy encoding of coefficients involves two parts:
[0076] The first step is to scan the coefficients, which involves transforming a two-dimensional coefficient block into a one-dimensional coefficient stream.
[0077] The scanning order can be diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other scanning order.
[0078] Second, the values of the coefficients are entropy encoded and then written into the bitstream.
[0079] After the coefficient blocks are scanned and quantized to form a one-dimensional coefficient stream (or coefficient string), the coefficients can be entropy encoded according to context-based adaptive variable-length code (CAVLC), context-based adaptive binary arithmetic coding, syntax-based adaptive binary arithmetic coding, probability interval partitioning entropy (PIPE), bypass coding, or other entropy coding methods.
[0080] In Versatile Video Coding (VVC, also known as H.266), the coefficients in a transform block are typically divided into multiple non-overlapping coefficient groups. The size of the coefficient group depends on the size of the transform block; for example, it can include 1x16, 2x8, 8x2, 2x4, 4x2, or 16x1, etc. Figure 2 As shown, an 8x8 transform block is first divided into four 4x4 sub-blocks, and then the coefficients are quantized from two-dimensional vectors to one-dimensional vectors using a diagonal scanning method.
[0081] In VVC, after scanning, the syntax elements of the coefficients at each position include six parts: a non-zero flag sig_coeff_flag, a flag indicating that the absolute value of the coefficient is greater than 1 abs_level_gtx_flag[0], a parity flag par_level_flag, a flag indicating that the absolute value of the coefficient is greater than 3 abs_level_gtx_flag[1], a residual value flags abs_remainder and dec_abs_level, and a sign flag coeff_sign_flag. Among them, the non-zero flag is used to indicate whether the absolute value of the coefficient |qk| is non-zero. The flag indicating that the absolute value of the coefficient is greater than 1 is used to indicate whether the absolute value of the coefficient |qk| is greater than 1. The parity flag is used to indicate whether the absolute value of the coefficient |qk| is odd or even. The flag indicating that the absolute value of the coefficient |qk| is greater than 3 is used to indicate whether the absolute value of the coefficient |qk| is greater than 3. The residual value flag indicates the residual value of the coefficient, which can be determined using the following formula: |q k | = sig + gt1 + par + 2 × gt3 + 2 × rem, where qk is the value of the coefficient, sig is the encoded value of the non-zero flag, gt1 is the encoded value of the flag indicating that the absolute value of the coefficient is greater than 1, par is the encoded value of the parity flag, gt3 is the encoded value of the flag indicating that the absolute value of the coefficient is greater than 3, and rem is the encoded value of the remaining value of the coefficient. When a flag is missing, its value is treated as 0. The sign flag is used to indicate the positive or negative sign of the coefficient.
[0082] In VVC, the correspondence between the flags in the coefficient syntax elements and the absolute values of the coefficients is as follows: Figure 3 As shown,
[0083] based on Figure 3 The coefficient absolute value encoding method shown includes the following entropy encoding process for the coefficients:
[0084] The non-zero flag sig_coeff_flag is encoded as 0 when the coefficient is 0 and as 1 when the coefficient is not 0.
[0085] When sig_coeff_flag is encoded as 0, the encoding of the absolute value of coefficient greater than 1 flag abs_level_gtx_flag[0], the parity flag par_level_flag, the absolute value of coefficient greater than 3 flag abs_level_gtx_flag[1], the residual value flags abs_remainder and dec_abs_level, and the sign flag coeff_sign_flag is skipped; when sig_coeff_flag is encoded as 1, abs_level_gtx_flag[0] is encoded; when the absolute value of coefficient is 1, abs_level_gtx_flag[0] is encoded as 0; when the absolute value of coefficient is greater than 1, abs_level_gtx_flag[0] is encoded as 1.
[0086] When abs_level_gtx_flag[0] is 0, skip the encoding of parity check flag par_level_flag, absolute value of coefficient greater than 3 flag abs_level_gtx_flag[1], residual value flag abs_remainder and dec_abs_level; when abs_level_gtx_flag[0] is 1, encode par_level_flag; when the absolute value of coefficient is even, encode par_level_flag as 0; when the absolute value of coefficient is odd, encode par_level_flag as 1.
[0087] Encode abs_level_gtx_flag[1]. When the absolute value of the coefficient is not greater than 3, encode abs_level_gtx_flag[1] as 0; when the absolute value of the coefficient is greater than 3, encode abs_level_gtx_flag[1] as 1.
[0088] When abs_level_gtx_flag[1] is 0, the encoding of the residual value flags abs_remainder and dec_abs_level is skipped; when abs_level_gtx_flag[1] is 1, abs_remainder and dec_abs_level are encoded.
[0089] The residual value flag can be determined according to the following formula: |q k |=sig+gt1+par+2×gt3+2×rem;
[0090] When sig_coeff_flag is encoded as 1, coeff_sign_flag is encoded according to the sign of the coefficient. When the coefficient is positive, coeff_sign_flag is encoded as 0; when the coefficient is negative, coeff_sign_flag is encoded as 1.
[0091] Among them, the residual value flag and the symbol flag are encoded using a bypass encoding method, while all other flags can be encoded using a context-based adaptive encoding method.
[0092] In AVS (Audio and Video Coding Standard), the coefficients to be encoded are typically limited to a range using SRCC technology. For example, Figure 4 As shown, the coefficient scanning method is based on SR. X— SR Y Starting from the bottom right corner of the range, the coefficients are quantized from a two-dimensional vector to a one-dimensional vector by scanning in reverse zig-zag order.
[0093] In AVS, after scanning, the syntax elements for the coefficients at each position include five parts: a non-zero flag (sig_flag), a flag indicating whether the absolute value of the coefficient |qk| is non-zero; a flag indicating whether the absolute value of the coefficient |qk| is greater than 1; a flag indicating whether the absolute value of the coefficient |qk| is greater than 2; and a flag indicating whether the absolute value of the coefficient |qk| is greater than 2. The flag indicating the remaining value of the coefficient can be determined using the following formula: |qk| = sig + gt1 + gt2 + rem. qk represents the value of the coefficient, sig represents the encoded value of the non-zero flag, gt1 represents the encoded value of the flag indicating that the absolute value of the coefficient is greater than 1, gt2 represents the encoded value of the flag indicating that the absolute value of the coefficient is greater than 2, and rem represents the encoded value of the remaining value of the coefficient. In this formula, when a flag is absent, its value is treated as 0. The sign flag is used to indicate the positive or negative sign of the coefficient.
[0094] In AVS, the correspondence between the flags and the absolute values of the coefficients in the syntax elements of coefficient qk is as follows: Figure 5 As shown.
[0095] based on Figure 5 The coefficient absolute value encoding method shown includes the following entropy encoding process for the coefficients:
[0096] The non-zero flag sig_flag is encoded as 0 when the coefficient is 0 and as 1 when the coefficient is not 0.
[0097] When sig_flag is encoded as 0, the encoding of the following flags is skipped: coeff_abs_level_greater1_flag (for coefficients with absolute values greater than 1), coeff_abs_level_greater2_flag (for coefficients with absolute values greater than 2), coeff_abs_level_remaining (for residual values), and coeff_sign (for sign). When sig_flag is encoded as 1, coeff_abs_level_greater1_flag is encoded. If the absolute value of the coefficient is not greater than 1, coeff_abs_level_greater1_flag is encoded as 0; if the absolute value of the coefficient is greater than 1, coeff_abs_level_greater1_flag is encoded as 1.
[0098] When coeff_abs_level_greater1_flag is 0, skip the encoding of the coefficient absolute value greater than 2 flag coeff_abs_level_greater2_flag and the residual value flag coeff_abs_level_remaining; when coeff_abs_level_greater1_flag is 1, encode coeff_abs_level_greater2_flag; when the coefficient absolute value is not greater than 2, encode coeff_abs_level_greater2_flag as 0; when the coefficient absolute value is greater than 2, encode coeff_abs_level_greater2_flag as 1.
[0099] When coeff_abs_level_greater2_flag is 0, the encoding of the remainder flag coeff_abs_level_remaining is skipped; when coeff_abs_level_greater2_flag is 1, the remainder flag coeff_abs_level_remaining is encoded.
[0100] The coeff_abs_level_remaining can be determined using the following formula: |qk|=sig+gt1+gt2+rem.
[0101] When sig_flag is encoded as 1, coeff_sign is encoded according to the sign of the coefficient. When the coefficient is positive, coeff_sign is encoded as 0; when the coefficient is negative, coeff_sign is encoded as 1.
[0102] Among them, the residual value flag and the symbol flag are encoded using a bypass encoding method, while all other flags can be encoded using a context-based adaptive encoding method.
[0103] There are many statistical characteristics among the coefficients at different positions after scanning, but the above encoding method is relatively simple. Context-based adaptive binary arithmetic encoding does not make full use of these statistical characteristics. Therefore, there is still much room for improvement in the current coefficient entropy encoding method.
[0104] This disclosure provides a coefficient decoding method, such as... Figure 6 As shown, it includes:
[0105] Step 601: Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded;
[0106] Step 602: Determine the value of the coefficient to be decoded based on the decoded syntax elements;
[0107] The syntax elements include: a non-zero flag, and M absolute values greater than X. i Flags, modulo result flags, residual value flags, and sign flags; the absolute value of the coefficient to be decoded is the encoded value of the non-zero flag, and M absolute values greater than X. i The sum of the pre-set corresponding values of the encoded values of the flag and the encoded values of the modulo result flag, plus the product of the encoded value of the residual value flag and N, is the obtained sum value; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient to be decoded and the sign flag indicating positive or negative; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, i≥M, i and M are positive integers, N is a positive integer greater than 1, X i X is a positive integer and X takes different values when i is different. i The values are different and increase with the value of i.
[0108] In one exemplary embodiment, the method further includes: pre-setting a specific encoding value for a modulo result flag of a specified absolute value;
[0109] Decode the non-zero flag. When the non-zero flag is decoded as 0, skip the decoding of the M coefficient absolute value greater than i flags, modulo result flags, residual value flags, and sign flags.
[0110] When the non-zero flag is decoded as 1, decode M absolute value greater than Xi flags. When the g-th absolute value greater than Xi flag is decoded as 0, skip the decoding of the subsequent Mg absolute value greater than Xi flags, modulo result flags, and residual value flags; 1≤g≤M;
[0111] When the absolute value of M coefficients is greater than the i flag and all of them are 1, the decoding modulo result flag is set.
[0112] When the encoded value of the modulo result flag is decoded into the specific encoded value, the decoding of the residual value flag is skipped;
[0113] When the modulo result flag is not decoded to the specific encoded value, the remaining value flag is decoded.
[0114] When the non-zero flag is decoded as 1, the symbol flag is decoded.
[0115] In one exemplary embodiment, the method further includes:
[0116] Decode the non-zero flag. When the non-zero flag is decoded as 0, skip the decoding of the M coefficient absolute value greater than i flags, modulo result flags, residual value flags, and sign flags.
[0117] When the non-zero flag is decoded as 1, decode M absolute value greater than Xi flags. When the g-th absolute value greater than Xi flag is decoded as 0, skip the decoding of the subsequent Mg absolute value greater than Xi flags, modulo result flags, and residual value flags; 1≤g≤M, when i takes different values, X i The values are different and increase with the value of i;
[0118] When all M absolute values greater than Xi are 1, decode the modulo result flag and the residual value flag in sequence;
[0119] When the non-zero flag is decoded as 1, the symbol flag is decoded.
[0120] In one exemplary embodiment, the method further includes:
[0121] The absolute value of the coefficient = the decoded value of the non-zero flag + the decoded values corresponding to the M flags whose absolute values are greater than Xi + the corresponding value of the decoded value of the modulo result flag (pre-set) + the residual value flag × N;
[0122] Specifically, if any one of the following syntax elements does not exist: the decoded value of the non-zero flag, the decoded values corresponding to the M absolute values greater than Xi flags, the decoded value of the modulo result flag, or the residual value flag, the decoded value of the non-zero syntax element or the corresponding pre-set value is set to 0.
[0123] In one exemplary embodiment, M = 1, 2, or 3, and N = 2, 3, 4, or 5.
[0124] In an exemplary embodiment, M = 1, X1 = 1, N = 3, the specified absolute value is 2, and the specific encoding value pre-set for the modulo result flag of the specified coefficient absolute value is 11B;
[0125] Alternatively, M = 2, X1 = 1, X2 = 2, N = 3, the specified absolute value is 3, and the specific encoding value of the modulo result flag of the specified coefficient absolute value is 00B.
[0126] In one exemplary embodiment, M = 1, X1 = 1, N = 3;
[0127] When the modulo result flag is decoded as 11B, the pre-set corresponding value is 0;
[0128] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 1;
[0129] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 2;
[0130] When the modulus result flag is decoded as 10B, the preset corresponding value is 3.
[0131] In one exemplary embodiment, M = 2, X1 = 1, X2 = 2, N = 3;
[0132] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0;
[0133] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1;
[0134] When the modulus result flag is decoded as 10B, the preset corresponding value is 2;
[0135] When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
[0136] In one exemplary embodiment, M = 1, X1 = 1, N = 4;
[0137] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0;
[0138] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1;
[0139] When the modulus result flag is decoded as 10B, the preset corresponding value is 2;
[0140] When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
[0141] This disclosure provides a coefficient encoding method, such as... Figure 7As shown, it includes:
[0142] Step 701: Generate coefficient blocks based on residual blocks, scan the coefficients in the coefficient blocks, and encode the syntax elements of the coefficients to be encoded;
[0143] Step 702: Write the encoded codewords into the bitstream;
[0144] The syntax elements include: a non-zero flag, and M absolute values greater than X. i Flags, modulo result flags, residual value flags, and sign flags; the absolute value of the coefficient to be decoded is the encoded value of the non-zero flag, and M absolute values greater than X. i The sum of the pre-set corresponding values of the encoded values of the flag and the encoded values of the modulo result flag, plus the product of the encoded value of the residual value flag and N, is the obtained sum value; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient to be decoded and the sign flag indicating positive or negative; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, i≥M, i and M are positive integers, N is a positive integer greater than 1, X i X is a positive integer and X takes different values when i is different. i The values are different and increase with the value of i.
[0145] In one exemplary embodiment, the encoding of the modulo result flag is binary, occupying K flag bits, so the binary encoding of the modulo result flag has 2... K kind;
[0146] The method further includes: pre-setting a specific encoding value for the modulo result flag of the specified coefficient absolute value; encoding the non-zero flag, wherein when the coefficient absolute value is 0, the non-zero flag is encoded as 0, and the encoding of M coefficient absolute value greater than i flags, modulo result flags, residual value flags and sign flags is skipped; and when the coefficient absolute value is not 0, the non-zero flag is encoded as 1.
[0147] When the non-zero flag is encoded as 1, M flags with absolute values greater than Xi are encoded sequentially. When the absolute value of the coefficient is Q, X is... i The absolute value greater than Q is greater than Xi, which is encoded as 0. Subsequent encoding of the absolute value greater than Xi flag is skipped. X... i The flag code for an absolute value less than or equal to Q that is greater than Xi is 1;
[0148] When any one of the M absolute values greater than Xi flags is 0, skip encoding the modulo result flag and the residual value flag; when all M absolute values greater than Xi flags are 1, encode the modulo result flag; when the absolute value of the coefficient is the specified absolute value, encode the modulo result flag as the specific code value, wherein the specific code value is globally unique; when the absolute value of the coefficient is not the specified absolute value, set (2... K -N) binary encodings are used to encode values from M+1 to M+2. K The modulo result of the coefficients of -N is used as a flag, and the encoded values of the above binary codes are defined as 0 to 2. K -N-1; Encode the remaining N binary codes into sets whose absolute values are greater than M+2. K The modulo result of the coefficients of -N is used as a flag, and the encoded values of the N binary codes are defined as 1 to N respectively;
[0149] When the absolute value of the coefficient is not the specified absolute value of the coefficient, a residual value flag is encoded, and the residual value flag is encoded as a quotient value. The quotient value is the absolute value of the coefficient minus the encoded value corresponding to the non-zero flag, the encoded values corresponding to the M coefficient absolute values greater than i flags, and the encoded value of the modulo result flag (pre-set corresponding values), and then divided by N. The pre-set corresponding value of the encoded value of the modulo result flag satisfies that the calculated quotient value is an integer.
[0150] When the non-zero flag is encoded as 1, the symbol flag is encoded; when the coefficient is positive, the symbol flag is encoded as 0; when the coefficient is negative, the symbol flag is encoded as 1.
[0151] In one exemplary embodiment, the encoding of the modulo result flag is binary, occupying K flag bits, so the binary encoding of the modulo result flag has 2... K kind;
[0152] The method further includes:
[0153] The non-zero flag is encoded as follows: when the absolute value of the coefficient is 0, the non-zero flag is encoded as 0, and the encoding of M coefficient absolute value greater than i flags, modulo result flags, residual value flags and sign flags is skipped; when the absolute value of the coefficient is not 0, the non-zero flag is encoded as 1.
[0154] When the non-zero flag is encoded as 1, M flags with absolute values greater than Xi are encoded sequentially. When the absolute value of the coefficient is Q, X is... i The absolute value greater than Q is greater than Xi, which is encoded as 0. Subsequent encoding of the absolute value greater than Xi flag is skipped. X... iThe absolute value greater than Xi for values less than or equal to Q is encoded as 1; when any one of the M absolute value greater than Xi flags is encoded as 0, the encoding of the modulo result flag and the residual value flag is skipped; when all M absolute value greater than Xi flags are encoded as 1, the modulo result flag is encoded, and the (2) K -N) binary encodings are used to encode values from M+1 to M+2. K The modulo result of the coefficients of -N is used as a flag, and the encoded values of the above binary codes are defined as 0 to 2. K -N-1; Encode the remaining N binary codes into sets whose absolute values are greater than M+2. K The modulo result of the coefficients of -N is used as a flag, and the encoded values of the N binary codes are defined as 1 to N respectively;
[0155] When all M absolute values greater than Xi are encoded as 1, the residual value flag is encoded and encoded as a quotient. The quotient is the absolute value of the coefficient minus the encoded value corresponding to the non-zero flag, the encoded values corresponding to the M absolute values greater than i flags, and the encoded value of the modulo result flag (pre-set corresponding values), and then divided by N. The pre-set corresponding value of the encoded value of the modulo result flag satisfies that the calculated quotient is an integer.
[0156] When the non-zero flag is encoded as 1, the symbol flag is encoded; when the coefficient is positive, the symbol flag is encoded as 0; when the coefficient is negative, the symbol flag is encoded as 1.
[0157] In one exemplary embodiment, M = 1, 2, or 3, and N = 2, 3, 4, or 5.
[0158] In one exemplary embodiment, M = 1, X1 = 1, N = 3, K = 2, the absolute value of the specified coefficient is 2, and the specific encoding value set in advance for the modulo result flag of the specified absolute value is 11B; the modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 0 is encoded as 00B, the modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 1 is encoded as 01B, and the modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 2 is encoded as 10B;
[0159] When the modulus result flag code is 11B, the preset corresponding value is 0;
[0160] When the modulus result flag code is 00B, the preset corresponding value is 1;
[0161] When the modulo result flag code is 01B, the preset corresponding value is 2;
[0162] When the modulus result flag is coded as 10B, the preset corresponding value is 3.
[0163] In one exemplary embodiment, M = 2, X1 = 1, X2 = 2, N = 3, K = 2, the absolute value of the specified coefficient is 3, and the specific encoding value set in advance for the modulo result flag of the absolute value of the specified coefficient is 00B; the modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 0 is encoded as 11B, the modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 1 is encoded as 01B, and the modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 2 is encoded as 10B;
[0164] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0;
[0165] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1;
[0166] When the modulus result flag is decoded as 10B, the preset corresponding value is 2;
[0167] When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
[0168] In an exemplary embodiment, M = 1, X1 = 1, N = 4, K = 2. The modulo result flag for coefficients whose absolute value modulo 4 leaves a remainder of 0 is encoded as 10B, the modulo result flag for coefficients whose absolute value modulo 4 leaves a remainder of 1 is encoded as 11B, the modulo result flag for coefficients whose absolute value modulo 4 leaves a remainder of 2 is encoded as 00B, and the modulo result flag for coefficients whose absolute value modulo 4 leaves a remainder of 3 is encoded as 01B.
[0169] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0;
[0170] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1;
[0171] When the modulus result flag is decoded as 10B, the preset corresponding value is 2;
[0172] When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
[0173] This disclosure provides a coefficient decoding method, such as... Figure 8 As shown, it includes:
[0174] Step 801: Obtain the bitstream and parse the current coding unit to determine the position of the coefficients;
[0175] Step 802: Perform entropy decoding on the coefficients according to their positions to obtain the syntax elements of the coefficients;
[0176] Step 803: Determine the value of the coefficient based on the syntax elements of the coefficient;
[0177] The entropy decoding of the coefficients includes decoding five syntax elements: a non-zero flag, M absolute values greater than Xi flags, a modulo result flag, a residual value flag, and a sign flag. The encoding of the modulo result flag and the residual value flag is determined based on the modulo operation of the coefficients on N, where i ≥ M, i and M are positive integers, and N is a positive integer greater than 1.
[0178] In an exemplary embodiment, when a specific encoding value is pre-set for the modulo result flag of the specified coefficient absolute value, entropy decoding of the coefficient is achieved in the following manner:
[0179] Decode the non-zero flag. When the non-zero flag is decoded as 0, skip the decoding of the M coefficient absolute value greater than i flags, modulo result flags, residual value flags, and sign flags.
[0180] When the non-zero flag is decoded as 1, decode the M absolute value greater than Xi flags sequentially. When the g-th absolute value greater than Xi flag is decoded as 0, skip the decoding of the subsequent Mg absolute value greater than Xi flags, modulo result flags, and residual value flags; 1≤g≤M, when i takes different values, X i The values are different and increase with the value of i;
[0181] When the absolute value of M coefficients is greater than the i flag and all of them are 1, the decoding modulo result flag is set.
[0182] When the modulo result flag is decoded into the specific encoded value, the decoding of the remaining value flag is skipped;
[0183] When the modulo result flag is not decoded to the specific encoded value, the remaining value flag is decoded.
[0184] When the non-zero flag is decoded as 1, the symbol flag is decoded.
[0185] In an exemplary embodiment, the coefficients are entropy decoded in the following manner:
[0186] Decode the non-zero flag. When the non-zero flag is decoded as 0, skip the decoding of the M coefficient absolute value greater than i flags, modulo result flags, residual value flags, and sign flags.
[0187] When the non-zero flag is decoded as 1, decode the M absolute value greater than Xi flags sequentially. When the g-th absolute value greater than Xi flag is decoded as 0, skip the decoding of the subsequent Mg absolute value greater than Xi flags, modulo result flags, and residual value flags; 1≤g≤M, when i takes different values, X i The values are different and increase with the value of i; when the absolute value of M coefficients is greater than i and all flags are 1, the modulo result flag and the residual value flag are decoded in sequence.
[0188] When the non-zero flag is decoded as 1, the symbol flag is decoded.
[0189] In one exemplary embodiment, the value of the coefficient is determined based on the syntax elements of the coefficient in the following manner:
[0190] The absolute value of the coefficient is obtained by adding the decoded value of the non-zero flag to the decoded values of M flags whose absolute values are greater than Xi, the corresponding values of the decoded value of the modulo result flag, and the residual value flag multiplied by N. When the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative. The modulo operation is a modulo operation on N.
[0191] Specifically, if any one of the following syntax elements does not exist: the decoded value of the non-zero flag, the decoded values corresponding to the M absolute values greater than Xi flags, the decoded value of the modulo result flag, or the residual value flag, the decoded value of the non-zero syntax element is set to 0.
[0192] In one exemplary embodiment, when a specific encoded value is pre-set for a modulo result flag of a specified coefficient absolute value, the value of the coefficient is determined based on the syntax elements of the coefficient in any of the following ways:
[0193] When the non-zero flag is decoded to 0, the value of the coefficient is determined to be 0;
[0194] When the non-zero flag is decoded as 1, and not all of the M absolute value greater than Xi flags are 1, the X flags corresponding to the M absolute value greater than Xi flags that are 0 are... i The value is the absolute value of the coefficient; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0195] When the non-zero flag is decoded as 1, the M absolute values greater than Xi flags are all 1, and the modulo result flag is a specific encoded value, the specified absolute value of the coefficient is used as the absolute value of the coefficient; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0196] When the non-zero flag is decoded as 1, and all M absolute values greater than Xi flags are 1, the decoded value of the non-zero flag is added to the decoded values corresponding to the M absolute values greater than Xi flags, the pre-set corresponding values of the encoded values of the modulo result flag, and the residual value flag multiplied by N. The sum is used as the absolute value of the coefficient. When the sign flag is 0, the value of the coefficient is positive; when the sign flag is 1, the value of the coefficient is negative. The modulo operation is a modulo operation on N.
[0197] In one exemplary embodiment, M = 1, 2, or 3, and N = 2, 3, 4, or 5.
[0198] This disclosure provides a coefficient encoding method, such as... Figure 9 As shown, it includes:
[0199] Step 901: Generate a coefficient block based on the residual block, scan the coefficients in the coefficient block, and entropy encode the values of the coefficients;
[0200] Step 902: Write the codewords generated by entropy encoding into the code stream; wherein, entropy encoding is performed on the value of the coefficient, including encoding five syntax elements: non-zero flag of the coefficient, M absolute values greater than Xi flags, modulo result flag, residual value flag and sign flag. The encoded values of the modulo result flag and residual value flag are determined according to the modulo operation of the coefficient on N, i≥M, i and M are positive integers, and N is a positive integer greater than 1.
[0201] In an exemplary embodiment, during the entropy encoding of the values of the coefficients, the encoding of the modulo result flag is implemented in any of the following ways:
[0202] A specific encoding value is pre-set for the modulo result flag of the absolute value of a specified coefficient. When the absolute value of the coefficient is the absolute value of the specified coefficient, the modulo result flag is encoded as the specific encoding value, wherein the corresponding encoding value has global uniqueness.
[0203] A specific encoding value is pre-set for the modulo result flag of the absolute value of a specified coefficient. When the absolute value of the coefficient is not the specified absolute value of the coefficient, the modulo result flag is encoded as a pre-set encoding value of the remainder, wherein the remainder is the remainder obtained by taking the absolute value of the coefficient modulo N; or, the remainder is the remainder obtained by taking the difference obtained by subtracting the non-zero flag and the M coefficient absolute values greater than i flags from the absolute value of the coefficient modulo N.
[0204] The modulo result is encoded as a pre-defined encoding value of the remainder obtained by taking the absolute value of the coefficient modulo N;
[0205] The modulo result is encoded as the remainder obtained by taking the modulo of the difference between the absolute value of the coefficient and the non-zero flag and the M coefficient absolute values greater than i, and then taking the modulo of N.
[0206] The preset encoding value is a binary encoding value, and each remainder corresponds to a binary encoding value.
[0207] In an exemplary embodiment, during the entropy encoding of the coefficient values, the encoding of the residual value flag is implemented in any of the following ways:
[0208] When the absolute value of the coefficient is the absolute value of the specified coefficient, skip encoding the residual value flag;
[0209] When the modulo result flag is encoded as the remainder, the remainder value flag is encoded as the quotient value. The quotient value is the absolute value of the coefficient minus the encoded value corresponding to the non-zero flag, the encoded values corresponding to the M absolute values greater than Xi flags, and the corresponding values of the encoded value of the modulo result flag (pre-set), and then divided by N. The corresponding values of the encoded value of the modulo result flag (pre-set) satisfy that the calculated quotient value is an integer.
[0210] In an exemplary embodiment, during the entropy encoding of the values of the coefficients, the encoding of the flag indicating that the absolute value of the M coefficients is greater than i is implemented in any of the following ways:
[0211] When the non-zero flag is encoded as 1, M flags with absolute values greater than Xi are encoded sequentially. When the absolute value of the coefficient is Q, X is... i The absolute value greater than Q is greater than Xi, which is encoded as 0. Subsequent encoding of the absolute value greater than Xi flag is skipped. X... i The absolute value of Q, which is less than or equal to Q, is greater than Xi and is coded as 1.
[0212] In an exemplary embodiment, during the entropy encoding of the coefficients, when the absolute value of the coefficient is 0, the non-zero flag is encoded as 0, and the encoding of M coefficient absolute value greater than i flags, modulo result flags, residual value flags and sign flags is skipped;
[0213] When the absolute value of the coefficient is not 0, the non-zero flag, the M coefficient absolute values greater than i flag, the modulo result flag, the residual value flag and the sign flag are encoded in sequence. When the non-zero flag is encoded as 1, and when the M coefficient absolute values greater than i flags are not all 1, the encoding of the modulo result flag and the residual value flag is skipped.
[0214] In an exemplary embodiment, when N is not greater than 4, the pre-set encoding value of the modulo result flag is a two-bit binary number.
[0215] In one exemplary embodiment, the encoding of the modulo result flag is binary, occupying K flag bits, so the binary encoding of the modulo result flag has 2... K kind;
[0216] When entropy encoding the values of the coefficients, (2) K -N) binary encodings are used to encode values from M+1 to M+2. K The modulo result of the coefficients of -N is used as a flag, and the encoded values of the above binary codes are defined as 0 to 2. K-N-1; Encode the remaining N binary codes into sets whose absolute values are greater than M+2. K The modulo result of the coefficients of -N is used as a flag, and the encoded values of the N binary codes are defined as 1 to N respectively.
[0217] In an exemplary embodiment, N=3, K=2, M=1. The modulo result flag with an absolute value of 2 is encoded as 11B, the modulo result flag with a remainder of 0 when the absolute value of the coefficient is modulo 3 is encoded as 00B, the modulo result flag with a remainder of 1 when the absolute value of the coefficient is modulo 3 is encoded as 01B, and the modulo result flag with a remainder of 2 when the absolute value of the coefficient is modulo 3 is encoded as 10B. The encoded value of the remainder value flag rem is determined by the following calculation method: |q k |=sig+gt1+f(rem_flag)+3×rem, where qk is the coefficient, |qk| is the absolute value of the coefficient, sig is the encoded value of the non-zero flag, gt1 is the encoded value of the flag indicating that the absolute value of the coefficient is greater than 1, rem_flag is the encoded value of the modulo result flag, and f(rem_flag) is the corresponding value of rem_flag that is preset. When the encoded value of the modulo result flag rem_flag is 11B, the corresponding f(rem_flag) is 0; when the encoded value of the modulo result flag rem_flag is 00B, the corresponding f(rem_flag) is 1; when the encoded value of the modulo result flag rem_flag is 01B, the corresponding f(rem_flag) is 2; and when the encoded value of the modulo result flag rem_flag is 10B, the corresponding f(rem_flag) is 3.
[0218] In an exemplary embodiment, N=3, K=2, M=2. The modulo result flag with an absolute value of 3 is encoded as 00B, the modulo result flag with a remainder of 0 after modulo 3 is encoded as 11B, the modulo result flag with a remainder of 1 after modulo 3 is encoded as 01B, and the modulo result flag with a remainder of 2 after modulo 3 is encoded as 10B. The encoded value of the remainder value flag rem is determined by the following calculation method: |q k|=sig+gt1+gt2+f(rem_flag)+3×rem, where qk is the coefficient, |qk| is the absolute value of the coefficient, sig is the encoded value of the non-zero flag, gt1 is the encoded value of the flag indicating that the absolute value of the coefficient is greater than 1, gt2 is the encoded value of the flag indicating that the absolute value of the coefficient is greater than 2, rem_flag is the encoded value of the modulo result flag, and f(rem_flag) is the corresponding value preset by rem_flag. When the encoded value of the modulo result flag rem_flag is 00B, the corresponding f(rem_flag) is 0; when the encoded value of the modulo result flag rem_flag is 01B, the corresponding f(rem_flag) is 1; when the encoded value of the modulo result flag rem_flag is 10B, the corresponding f(rem_flag) is 2; and when the encoded value of the modulo result flag rem_flag is 11B, the corresponding f(rem_flag) is 3.
[0219] In one exemplary embodiment, the encoding of the modulo result flag is binary encoding, and there are N possible binary encodings for the modulo result flag;
[0220] When entropy encoding the value of the coefficient, the absolute value of the coefficient is subtracted from the encoded value of the non-zero flag and the encoded values of the M coefficients whose absolute values are greater than 1. The remainder obtained by taking the modulo of the difference with N is encoded as the encoded value of the modulo result flag of the coefficient in a pre-defined binary code.
[0221] In an exemplary embodiment, N=4, K=2, M=1. The modulo result flag where the absolute value of the coefficient modulo 4 has a remainder of 0 is encoded as 10B, the modulo result flag where the absolute value of the coefficient modulo 4 has a remainder of 1 is encoded as 11B, the modulo result flag where the absolute value of the coefficient modulo 4 has a remainder of 2 is encoded as 00B, and the modulo result flag where the absolute value of the coefficient modulo 4 has a remainder of 3 is encoded as 01B. The encoded value of the remainder flag rem is determined by the following calculation method: |qk|=sig+gt1+g(rem_flag)+4×rem, where qk is the coefficient, |qk| is the absolute value of the coefficient, sig is the encoded value of the non-zero flag, and gt1 is the absolute value of the coefficient. The value is the encoded value of the flag with a value greater than 1. rem_flag is the encoded value of the modulo result flag, and g(rem_flag) is the corresponding value preset by rem_flag. When the encoded value of the modulo result flag rem_flag is 00B, the corresponding g(rem_flag) is 0. When the encoded value of the modulo result flag rem_flag is 01B, the corresponding g(rem_flag) is 1. When the encoded value of the modulo result flag rem_flag is 10B, the corresponding g(rem_flag) is 2. When the encoded value of the modulo result flag rem_flag is 11B, the corresponding g(rem_flag) is 3.
[0222] In this embodiment of the disclosure, the syntax elements of the coefficient include five parts: non-zero flag sig, absolute value of coefficient greater than i flag gti, modulo result flag rem_flag, residual value flag rem, and sign flag coeff_sign.
[0223] The non-zero flag sig is used to indicate whether the coefficient is non-zero.
[0224] The flag gti, indicating whether the absolute value of the coefficient is greater than i, means whether the absolute value of the coefficient is greater than i. For example, the flag gti includes at least the flag gt1, indicating that the absolute value of the coefficient is greater than 1. The flag gti can also be called the flag indicating that the absolute value is greater than Xi.
[0225] The value to be encoded for the modulo result flag `rem_flag` is determined by the modulo value and the remainder. In one example, the modulo result flag can be encoded as the remainder corresponding to the remainder, where the remainder is the remainder obtained by taking the absolute value of the coefficient modulo N; or, the remainder is the remainder obtained by taking the difference between the absolute value of the coefficient and the non-zero flag and the M coefficient absolute values greater than i flags, modulo N. In another example, a specific encoding value can be pre-set for the modulo result flag of a specified coefficient absolute value. When the absolute value of the coefficient is the specified coefficient absolute value, the modulo result flag is encoded as the specific encoding value, where the specific encoding is globally unique. In another example, a specific encoding value can be pre-set for the modulo result flag of the absolute value of a specified coefficient. When the absolute value of the coefficient is not the specified absolute value of the coefficient, the modulo result flag is encoded as the encoding value corresponding to the remainder, wherein the remainder is the remainder obtained by taking the absolute value of the coefficient modulo N; or, the remainder is the remainder obtained by taking the difference obtained by subtracting the non-zero flag and the M coefficient absolute values greater than i flags from the absolute value of the coefficient modulo N.
[0226] The value to be encoded for the residual value flag rem is determined by subtracting the encoded value corresponding to the non-zero flag, the encoded values corresponding to the M coefficients whose absolute values are greater than i, and the pre-set corresponding value of the encoded value of the modulo result flag from the absolute value of the coefficient, and then dividing by N. The pre-set corresponding value of the encoded value of the modulo result flag satisfies that the calculated quotient is an integer.
[0227] The symbol coeff_sign is used to indicate the positive or negative nature of the level.
[0228] In an exemplary embodiment, the technical solution of the present disclosure is described in detail using a modulus of 3 as an example.
[0229] In this exemplary embodiment, the syntax elements of the coefficients include a non-zero flag sig, a coefficient absolute value greater than 1 flag gt1, a modulo result flag rem_flag, a residual value flag rem, and a sign flag coeff_sign. The modulo result flag rem_flag is represented using two binary bits.
[0230] In this exemplary embodiment, when the modulus is 3, the coefficient encoding method is as follows: Figure 10 As shown, the values of each flag satisfy Formula 1: |q k |=sig+gt1+f(rem_flag)+3×rem. In this formula 1, if any of the following flags is missing: non-zero flag sig, absolute value of coefficient greater than 1 flag gt1, modulo result flag rem_flag, or residual value flag rem, its corresponding value in this formula is treated as 0.
[0231] In this exemplary embodiment, rem_flag is a binary encoded value, and f(rem_flag) is the numerical value corresponding to rem_flag, represented in decimal. The correspondence between rem_flag and f(rem_flag) is shown in Table 1:
[0232] Table 1:
[0233] rem_flag 1 1 0 0 0 1 1 0 f(rem_flag) 0 1 2 3
[0234] In this exemplary embodiment, the encoding value of the modulo result flag rem_flag corresponding to a coefficient with an absolute value of 2 is pre-set to 11B. Based on Figure 10 The encoding methods shown and the correspondences shown in Table 1 illustrate a coefficient entropy encoding method in this exemplary embodiment. Figure 11 As shown, the method includes:
[0235] Step 1101: Generate a coefficient block based on the residual block, and scan the coefficients in the coefficient block;
[0236] In one exemplary embodiment, the current block is predicted by a prediction part, i.e., through inter-frame prediction or intra-frame prediction, to obtain a prediction block. Image blocks at corresponding positions of the original image and the prediction block are taken, and the difference between the prediction block and the prediction block is calculated to obtain a residual block for the current block. The residual block is then transformed or not transformed to obtain a transformed block containing transformed coefficients or a non-transformed coefficient block, collectively referred to here as a coefficient block. The coefficient block is then quantized, and the quantized coefficients are entropy-encoded according to the coefficient scanning order.
[0237] In one exemplary embodiment, the scanning may be a diagonal scan, a zigzag scan, a horizontal scan, a vertical scan, a 4x4 sub-block scan, or any other scan sequence.
[0238] Step 1102, the value of the coefficient is based on Figure 10 The encoding method shown and the corresponding relationship shown in Table 1 are used for entropy encoding;
[0239] In one exemplary embodiment, the value of the coefficient is based on Figure 10 The encoding method shown and the correspondence shown in Table 1 are used for entropy encoding, including: entropy encoding the value of each coefficient in the coefficient block according to the scan position:
[0240] The non-zero flag sig of the coefficient is encoded as follows: when the absolute value of the coefficient is 0, the non-zero flag sig is encoded as 0; when the absolute value of the coefficient is not 0, the non-zero flag sig is encoded as 1.
[0241] When the non-zero flag sig is 0, skip the encoding of the coefficient absolute value greater than 1 flag, modulo result flag, residual value flag and sign flag; when the non-zero flag sig is 1, encode the coefficient absolute value greater than 1 flag gt1; when the coefficient absolute value is not greater than 1, encode the coefficient absolute value greater than 1 flag gt1 as 0; when the coefficient absolute value is greater than 1, encode the coefficient absolute value greater than 1 flag gt1 as 1.
[0242] When the absolute value of the coefficient is greater than 1 and the flag gt1 is 0, skip encoding the modulo result flag and the residual value flag for that coefficient. When the absolute value of the coefficient is greater than 1 and the flag gt1 is 1, encode the modulo result flag rem_flag. When the absolute value of the coefficient is 2, encode the modulo result flag rem_flag as 11B. When the absolute value of the coefficient modulo 3 is 0, encode the modulo result flag rem_flag as 00B. When the absolute value of the coefficient modulo 3 is 1, encode the modulo result flag rem_flag as 01B. When the absolute value of the coefficient modulo 3 is 2, encode the modulo result flag rem_flag as 10B.
[0243] When the modulo result flag rem_flag is 11B, skip encoding the residual value flag of the coefficient; when the modulo result flag rem_flag is not 11B, encode the residual value flag rem of the coefficient.
[0244] The residual value flag rem can be calculated according to Formula 1 and Table 1 above.
[0245] When the non-zero flag sig is 1, the sign flag coeff_sign of the coefficient is encoded. When the coefficient is positive, the sign flag coeff_sign is encoded as 0; when the coefficient is negative, the sign flag coeff_sign is encoded as 1.
[0246] In one example, when the coefficient is -3, the encoding result for the coefficient is: sig=1, gt1=1, rem_flag=00B, rem=0, coeff_sign=1.
[0247] In one example, suppose we consider a 4x4 transform block after residual transformation. Figure 12 As shown, the transform coefficient string obtained after diagonal scan quantization is {0, 2, 4, 5, 0, 6, 3, 7, 0, 2, 1, 0, 9, 3, 0, 8}. Each coefficient in this string is then processed sequentially using... Figure 9 The encoding methods shown and the correspondence shown in Table 1 are respectively subjected to entropy encoding, and the encoded values are as follows: Figure 13 As shown.
[0248] Step 1103: Write the codewords generated by entropy encoding into the bitstream.
[0249] based on Figure 10 Based on the encoding methods shown and the correspondences shown in Table 1, this exemplary embodiment provides a coefficient entropy decoding method, such as... Figure 14 As shown, the method includes:
[0250] Step 1401: Obtain the bitstream, parse the current encoding unit, and determine the position of the coefficients according to the scanning method used during encoding;
[0251] In one exemplary embodiment, the scanning method can be diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other scanning sequence. For example, in this exemplary embodiment, diagonal scanning is used during encoding and also during decoding.
[0252] Step 1402: Perform entropy decoding on the coefficients according to their positions to obtain the syntax elements of the coefficients;
[0253] In one exemplary embodiment, the first coefficient in all coefficients can be entropy decoded sequentially according to its position to obtain the syntax element of the coefficient. Then, the value of the coefficient can be determined based on the syntax element of the coefficient, and then the entropy decoding of the next coefficient can be performed.
[0254] In one exemplary embodiment, the syntax elements of the coefficients are obtained by entropy decoding according to their positions:
[0255] Decode the non-zero flag. When the non-zero flag is decoded as 0, skip decoding the flags for the absolute value of the coefficient being greater than 1, the modulo result flag, the residual value flag, and the sign flag.
[0256] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 flag is decoded; when the absolute value of the coefficient is greater than 1 flag is decoded as 0, the decoding of the modulo result flag and the residual value flag is skipped.
[0257] When the absolute value of the coefficient is greater than 1, the decoded modulo result flag is 1; when the decoded modulo result flag is 11B, the decoding of the residual value flag is skipped.
[0258] When the decoded modulo result flag is not 11B, decode the remaining value flag;
[0259] When the non-zero flag is decoded as 1, the symbol flag is decoded.
[0260] Step 1403: Determine the value of the coefficient based on the syntax elements of the coefficient.
[0261] In this exemplary embodiment, the value of the coefficient is determined based on the syntax elements of the coefficient in the following manner:
[0262] The absolute value of the coefficient is obtained by adding the decoded value of the non-zero flag, the decoded value of the coefficient absolute value greater than 1 flag, the decoded value of the modulo result flag (pre-set corresponding value), and the residual value flag (multiplied by 3). When the sign flag is 0, the value of the coefficient is positive; when the sign flag is 1, the value of the coefficient is negative.
[0263] Specifically, if any of the following syntax elements is missing: the non-zero flag, the absolute value of the coefficient greater than 1 flag, the modulo result flag, or the residual value flag, the decoding value of the missing syntax element or the corresponding pre-set value is set to 0.
[0264] In this exemplary embodiment, the absolute value of the coefficient is calculated using Formula 1 above.
[0265] In another exemplary embodiment, the value of the coefficient is determined based on the syntax element of the coefficient in any of the following ways:
[0266] When the non-zero flag is decoded to 0, the value of the coefficient is determined to be 0;
[0267] When the non-zero flag is decoded as 1 and the absolute value of the coefficient is greater than 1 flag is decoded as 0, the absolute value of the coefficient is determined to be 1; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0268] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 flag is decoded as 1, and the modulo result flag is decoded as 11B, the absolute value of the coefficient is determined to be 2; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0269] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1, the modulo result flag is decoded as not being 11B, the absolute value of the coefficient is calculated according to Formula 1 above; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0270] In one example, when the decoding result of the coefficient is: sig=1, gt1=1, rem_flag=00B, rem=0, coeff_sign=1, the coefficient is -3.
[0271] The above Figure 10 The encoding methods and correspondences shown in Table 1 are illustrative examples. Other encoding methods and correspondences can also be used. For example, two binary bits include four binary codes. Any one of these binary codes is used as the encoding value of the modulo result flag rem_flag with an absolute value of 2. The other three are used as the encoding values of the three modulo result flags rem_flag with an absolute value of 3 modulo 0, 1, and 2, respectively. The correspondence between rem_flag and f(rem_flag) satisfies that the absolute value of the coefficient calculated according to Formula 1 is an integer.
[0272] In an exemplary embodiment, the technical solution of the present disclosure is described in detail using a modulus of 3 as an example.
[0273] In this exemplary embodiment, the syntax elements of the coefficients include a non-zero flag sig, a coefficient absolute value greater than 1 flag gt1, a coefficient absolute value greater than 2 flag gt2, a modulo result flag rem_flag, a residual value flag rem, and a sign flag coeff_sign. The modulo result flag rem_flag is represented using two binary bits.
[0274] In this exemplary embodiment, when the modulus is 3, the coefficient encoding method is as follows: Figure 15 As shown, the values of each flag satisfy Formula 2: |qk|=sig+gt1+gt2+f(rem_flag)+3×rem. In Formula 2, if any of the following flags is missing: non-zero flag sig, coefficient absolute value greater than 1 flag gt1, coefficient absolute value greater than 2 flag gt2, modulo result flag rem_flag, or residual value flag rem, its corresponding value in the formula is treated as 0.
[0275] In this exemplary embodiment, rem_flag is a binary encoded value, and f(rem_flag) is the numerical value corresponding to rem_flag, represented in decimal. The correspondence between rem_flag and f(rem_flag) is shown in Table 2:
[0276] Table 2:
[0277] rem_flag 00 0 1 10 11 f(rem_flag) 0 1 2 3
[0278] In this exemplary embodiment, the encoding value of the modulo result flag rem_flag corresponding to the absolute value of the coefficient is set to 00B in advance.
[0279] based on Figure 15 The encoding methods shown in the figure and the corresponding relationships shown in Table 2 illustrate a coefficient entropy encoding method in this exemplary embodiment. Figure 16 As shown, the method includes:
[0280] Step 1601: Generate a coefficient block based on the residual block, and scan the coefficients in the coefficient block;
[0281] In one exemplary embodiment, the current block is predicted by a prediction part, i.e., through inter-frame prediction or intra-frame prediction, to obtain a prediction block. Image blocks at corresponding positions of the original image and the prediction block are taken, and the difference between the prediction block and the prediction block is calculated to obtain a residual block for the current block. The residual block is then transformed or not transformed to obtain a transformed block containing transformed coefficients or a non-transformed coefficient block, collectively referred to here as a coefficient block. The coefficient block is then quantized, and the quantized coefficients are entropy-encoded according to the coefficient scanning order.
[0282] In one exemplary embodiment, the scanning may be a diagonal scan, a zigzag scan, a horizontal scan, a vertical scan, a 4x4 sub-block scan, or any other scan sequence.
[0283] Step 1602, the value of the coefficient is based on Figure 15 The encoding method shown and the corresponding relationship shown in Table 2 are used for entropy encoding;
[0284] In one exemplary embodiment, the value of the coefficient is based on Figure 15 The encoding method shown and the correspondence shown in Table 2 are used for entropy encoding, including: entropy encoding the value of each coefficient in the coefficient block according to the scan position:
[0285] The non-zero flag sig of the coefficient is encoded as follows: when the absolute value of the coefficient is 0, the non-zero flag sig is encoded as 0; when the absolute value of the coefficient is not 0, the non-zero flag sig is encoded as 1.
[0286] When the non-zero flag sig is 0, skip the encoding of the coefficient absolute value greater than 1 flag, coefficient absolute value greater than 2 flag, modulo result flag, residual value flag, and sign flag; when the non-zero flag sig is 1, encode the coefficient absolute value greater than 1 flag gt1; when the coefficient absolute value is not greater than 1, encode the coefficient absolute value greater than 1 flag gt1 as 0; when the coefficient absolute value is greater than 1, encode the coefficient absolute value greater than 1 flag gt1 as 1.
[0287] When the absolute value of the coefficient is greater than 1 and the flag gt1 is 0, skip the encoding of the absolute value of the coefficient greater than 2 flag, the modulus result flag, and the residual value flag for that coefficient. When the absolute value of the coefficient is greater than 1 and the flag gt1 is 1, encode the absolute value of the coefficient greater than 2 flag. When the absolute value of the coefficient is not greater than 2, encode the absolute value of the coefficient greater than 2 flag gt1 as 0. When the absolute value of the coefficient is greater than 2, encode the absolute value of the coefficient greater than 2 flag gt1 as 1.
[0288] When the absolute value of the coefficient is greater than 2 and the flag gt2 is 0, skip encoding the modulo result flag and residual value flag for that coefficient; when the absolute value of the coefficient is greater than 2 and the flag gt2 is 1, encode the modulo result flag rem_flag; when the absolute value of the coefficient is 3, encode the modulo result flag rem_flag as 00B; when the absolute value of the coefficient modulo 3 is 0, encode the modulo result flag rem_flag as 11B; when the absolute value of the coefficient modulo 3 is 1, encode the modulo result flag rem_flag as 01B; when the absolute value of the coefficient modulo 3 is 2, encode the modulo result flag rem_flag as 10B.
[0289] When the modulo result flag rem_flag is 00B, skip encoding the residual value flag; when the modulo result flag rem_flag is not 00B, encode the residual value flag rem.
[0290] The residual value flag rem can be calculated according to Formula 2 and Table 2 above.
[0291] When the non-zero flag sig is 1, the symbol flag coeff_sign is encoded. When the coefficient is positive, the symbol flag coeff_sign is encoded as 0; when the coefficient is negative, the symbol flag coeff_sign is encoded as 1.
[0292] In one example, when the coefficient is -3, the encoding result is: sig=1, gt1=1, gt2=1, rem_flag=00B, coeff_sign=1.
[0293] Step 1603: Write the codewords generated by entropy encoding into the bitstream.
[0294] based on Figure 15Based on the encoding methods shown in the figure and the corresponding relationships shown in Table 2, this exemplary embodiment provides a coefficient entropy decoding method, such as... Figure 17 As shown, the method includes:
[0295] Step 1701: Obtain the bitstream, parse the current coding unit, and determine the position of the coefficients according to the scanning method used during encoding;
[0296] In one exemplary embodiment, the scanning method can be diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other scanning sequence. For example, in this exemplary embodiment, zigzag scanning is used during encoding and decoding.
[0297] Step 1702: Perform entropy decoding on the coefficients according to their positions to obtain the syntax elements of the coefficients;
[0298] In one exemplary embodiment, the first coefficient in all coefficients can be entropy decoded sequentially according to its position to obtain the syntax element of the coefficient. Then, the value of the coefficient can be determined based on the syntax element of the coefficient, and then the entropy decoding of the next coefficient can be performed.
[0299] In one exemplary embodiment, the syntax elements of the coefficients are obtained by entropy decoding according to their positions:
[0300] Decode the non-zero flag. When the non-zero flag is decoded as 0, skip decoding the flags for absolute coefficient value greater than 1, absolute coefficient value greater than 2, modulo result, residual value, and sign.
[0301] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 flag is decoded. When the absolute value of the coefficient is greater than 1 flag is decoded as 0, the decoding of the absolute value of the coefficient is greater than 2 flag, the modulo result flag, and the residual value flag is skipped.
[0302] When the absolute value of the coefficient is greater than 1, the flag is decoded as 1, and the flag is decoded as 2; when the flag is decoded as 0, the decoding of the modulo result flag and the residual value flag is skipped.
[0303] When the absolute value of the coefficient is greater than 2, the flag is decoded as 1. When the modulo result flag is encoded as 00B, the decoding of the residual value flag is skipped.
[0304] If the modulo result flag encoding is not 00B, continue decoding the residual value flag;
[0305] When the non-zero flag is decoded as 1, the symbol flag is decoded.
[0306] Step 1703: Determine the value of the coefficient based on the syntax elements of the coefficient;
[0307] In this exemplary embodiment, the value of the coefficient is determined based on the syntax elements of the coefficient in the following manner:
[0308] The absolute value of the coefficient is obtained by adding the decoded value of the non-zero flag, the decoded value of the coefficient absolute value greater than 1 flag, the decoded value of the coefficient absolute value greater than 2 flag, the corresponding value of the modulo result flag (pre-set), and the residual value flag (multiplied by 3). When the sign flag is 0, the value of the coefficient is positive; when the sign flag is 1, the value of the coefficient is negative.
[0309] Specifically, if any of the following syntax elements does not exist: the decoded value of the non-zero flag, the decoded value of the coefficient absolute value greater than 1 flag, the decoded value of the coefficient absolute value greater than 2 flag, the decoded value of the modulo result flag, or the residual value flag, the decoded value of the non-zero syntax element or the corresponding pre-set value is set to 0.
[0310] In this exemplary embodiment, the absolute value of the coefficient is calculated using Formula 2 above.
[0311] In another exemplary embodiment, the value of the coefficient is determined based on the syntax element of the coefficient in any of the following ways:
[0312] When the non-zero flag is decoded to 0, the value of the coefficient is determined to be 0;
[0313] When the non-zero flag is decoded as 1 and the absolute value of the coefficient is greater than 1 flag is decoded as 0, the absolute value of the coefficient is determined to be 1; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0314] When the non-zero flag is decoded as 1, the absolute value of the coefficient greater than 1 is decoded as 1, and the absolute value of the coefficient greater than 2 is decoded as 0, the absolute value of the coefficient is determined to be 2; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0315] When the non-zero flag is decoded as 1, the absolute value of the coefficient greater than 1 is decoded as 1, the absolute value of the coefficient greater than 2 is decoded as 1, and the modulo result flag is decoded as 00B, the absolute value of the coefficient is determined to be 3; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0316] When the non-zero flag is decoded as 1, the absolute value of the coefficient greater than 1 is decoded as 1, the absolute value of the coefficient greater than 2 is decoded as 1, and the modulo result flag is not decoded as 00B, the absolute value of the coefficient is calculated according to the above formula 2; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0317] In one example, when the decoding result of the coefficient is: sig=1, gt1=1, rem_flag=00B, coeff_sign=1, the coefficient is -3.
[0318] The above Figure 15 The encoding methods and correspondences shown in Table 2 are illustrative examples. Other encoding methods and correspondences can also be used. For example, two binary bits include four binary codes. Any one of these binary codes is used as the encoding value of the modulo result flag rem_flag with an absolute value of 3. The other three are used as the encoding values of the three modulo result flags rem_flag with an absolute value of 3 modulo 3 remainder of 0, remainder of 1, and remainder of 2, respectively. The correspondence between rem_flag and f(rem_flag) satisfies that the absolute value of the coefficient calculated according to Formula 2 is an integer.
[0319] In an exemplary embodiment, the technical solution of the present disclosure is described in detail using a modulus of 5 as an example.
[0320] In this exemplary embodiment, the syntax elements of the coefficients include a non-zero flag sig, a coefficient absolute value greater than 1 flag gt1, a modulo result flag rem_flag, a residual value flag rem, and a sign flag coeff_sign. The modulo result flag rem_flag is represented using three binary digits.
[0321] In this exemplary embodiment, when the modulus is 5, the coefficient encoding method is as follows: Figure 18 As shown, the values of each flag satisfy formula 3: |qk|=sig+gt1+f(rem_flag)+5×rem. In formula 3, when any one of the following flags is not present: non-zero flag sig, coefficient absolute value greater than 1 flag gt1, modulo result flag rem_flag, or residual value flag rem, its corresponding value in the formula is treated as 0.
[0322] In this exemplary embodiment, rem_flag is a binary encoded value, and f(rem_flag) is the numerical value corresponding to rem_flag, represented in decimal. The correspondence between rem_flag and f(rem_flag) is shown in Table 3.
[0323] Table 3:
[0324]
[0325] In this exemplary embodiment, the encoding value of the modulo result flag rem_flag corresponding to the absolute value of the coefficient is set to 101B, the encoding value of the modulo result flag rem_flag corresponding to the absolute value of the coefficient is set to 110B, and the encoding value of the modulo result flag rem_flag corresponding to the absolute value of the coefficient is set to 11B.
[0326] based on Figure 18 The encoding methods shown in the figure and the corresponding relationships shown in Table 3 illustrate a coefficient entropy encoding method in this exemplary embodiment. Figure 19 As shown, the method includes:
[0327] Step 1901: Generate a coefficient block based on the residual block, and scan the coefficients in the coefficient block;
[0328] In one exemplary embodiment, the current block is predicted by a prediction part, i.e., through inter-frame prediction or intra-frame prediction, to obtain a prediction block. Image blocks at corresponding positions of the original image and the prediction block are taken, and the difference between the prediction block and the prediction block is calculated to obtain a residual block for the current block. The residual block is then transformed or not transformed to obtain a transformed block containing transformed coefficients or a non-transformed coefficient block, collectively referred to here as a coefficient block. The coefficient block is then quantized, and the quantized coefficients are entropy-encoded according to the coefficient scanning order.
[0329] In one exemplary embodiment, the scanning may be a diagonal scan, a zigzag scan, a horizontal scan, a vertical scan, a 4x4 sub-block scan, or any other scan sequence.
[0330] Step 1902, the value of the coefficient is based on Figure 18 The encoding method shown and the corresponding relationship shown in Table 3 are used for entropy encoding;
[0331] In one exemplary embodiment, the value of the coefficient is based on Figure 18 The encoding method shown and the correspondence shown in Table 3 are used for entropy encoding, including: entropy encoding the value of each coefficient in the coefficient block according to the scan position:
[0332] The non-zero flag sig of the coefficient is encoded as follows: when the absolute value of the coefficient is 0, the non-zero flag sig is encoded as 0; when the absolute value of the coefficient is not 0, the non-zero flag sig is encoded as 1.
[0333] When the non-zero flag sig is 0, skip the encoding of the coefficient absolute value greater than 1 flag, modulo result flag, residual value flag and sign flag; when the non-zero flag sig is 1, encode the coefficient absolute value greater than 1 flag gt1; when the coefficient absolute value is not greater than 1, encode the coefficient absolute value greater than 1 flag gt1 as 0; when the coefficient absolute value is greater than 1, encode the coefficient absolute value greater than 1 flag gt1 as 1.
[0334] When the absolute value of a coefficient is greater than 1 and the flag gt1 is 0, the encoding of the modulus result flag and the residual value flag for that coefficient is skipped. When the absolute value of a coefficient is greater than 1 and the flag gt1 is 1, the modulus result flag for that coefficient is encoded. When the modulus of the absolute value of the coefficient is 2, the modulus result flag rem_flag is encoded as 101B; when the modulus of the absolute value of the coefficient is 3, the modulus result flag rem_flag is encoded as 110B; when the modulus of the absolute value of the coefficient is 4, the modulus result flag rem_flag is encoded as 111B; when the absolute value of the coefficient is greater than 1, the modulus result flag rem_flag is encoded as 111B. When the result of modulo 5 is 0, the modulo result flag rem_flag is encoded as 000B; when the result of modulo 5 is 1, the modulo result flag rem_flag is encoded as 001B; when the result of modulo 5 is 2, the modulo result flag rem_flag is encoded as 010B; when the result of modulo 5 is 3, the modulo result flag rem_flag is encoded as 011B; and when the result of modulo 5 is 4, the modulo result flag rem_flag is encoded as 100B.
[0335] When the modulo result flag rem_flag is encoded as 101B, 110B or 111B, skip the encoding residual value flag.
[0336] When the encoding of the modulo result flag rem_flag is not 101B, 110B or 111B, the remaining value flag is encoded.
[0337] The residual value flag rem can be calculated according to Formula 3 and Table 3 above.
[0338] When the non-zero flag sig is 1, the symbol flag coeff_sign is encoded. When the coefficient is positive, the symbol flag coeff_sign is encoded as 0; when the coefficient is negative, the symbol flag coeff_sign is encoded as 1.
[0339] In one example, when the coefficient is -3, the encoding result is: sig=1, gt1=1, rem_flag=110B, coeff_sign=1.
[0340] Step 1903: Write the codewords generated by entropy encoding into the bitstream.
[0341] based on Figure 18 Based on the encoding methods shown and the correspondences shown in Table 3, this exemplary embodiment provides a coefficient entropy decoding method, such as... Figure 20 As shown, the method includes:
[0342] Step 2001: Obtain the bitstream, parse the current encoding unit, and determine the position of the coefficients according to the scanning method used during encoding;
[0343] In one exemplary embodiment, the scanning method can be diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other scanning sequence. For example, in this exemplary embodiment, horizontal scanning is used during encoding and also during decoding.
[0344] Step 2002: Perform entropy decoding on the coefficients according to their positions to obtain the syntax elements of the coefficients;
[0345] In one exemplary embodiment, the first coefficient in all coefficients can be entropy decoded sequentially according to its position to obtain the syntax element of the coefficient. Then, the value of the coefficient can be determined based on the syntax element of the coefficient, and then the entropy decoding of the next coefficient can be performed.
[0346] In one exemplary embodiment, the syntax elements of the coefficients are obtained by entropy decoding according to their positions:
[0347] Decode the non-zero flag. When the non-zero flag is decoded as 0, skip decoding the flags for the absolute value of the coefficient being greater than 1, the modulo result flag, the residual value flag, and the sign flag.
[0348] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 flag is decoded; when the absolute value of the coefficient is greater than 1 flag is decoded as 0, the decoding of the modulo result flag and the residual value flag is skipped.
[0349] When the absolute value of the coefficient is greater than 1, the flag is decoded as 1. When the modulo result flag is decoded as 101B, 110B or 111B, the decoding of the residual value flag is skipped.
[0350] When the decoded result of the modulo operation is not 101B, 110B or 111B, the remaining value flag is decoded.
[0351] When the non-zero flag is decoded as 1, the symbol flag is decoded.
[0352] Step 2003: Determine the value of the coefficient based on the syntax elements of the coefficient;
[0353] In this exemplary embodiment, the value of the coefficient is determined based on the syntax elements of the coefficient in the following manner:
[0354] The absolute value of the coefficient is obtained by adding the decoded value of the non-zero flag, the decoded value of the coefficient absolute value greater than 1 flag, the decoded value of the modulo result flag (pre-set corresponding value), and the residual value flag (multiplied by 5). When the sign flag is 0, the value of the coefficient is positive; when the sign flag is 1, the value of the coefficient is negative.
[0355] Specifically, if any of the following syntax elements does not exist: the decoded value of the non-zero flag, the decoded value corresponding to the coefficient absolute value greater than 1 flag, the decoded value of the modulo result flag, or the residual value flag, the decoded value of the non-zero syntax element or the corresponding pre-set value is set to 0.
[0356] In this exemplary embodiment, the absolute value of the coefficient is calculated using Formula 3 above.
[0357] In another exemplary embodiment, the value of the coefficient is determined based on the syntax element of the coefficient in any of the following ways:
[0358] When the non-zero flag is decoded to 0, the value of the coefficient is determined to be 0;
[0359] When the non-zero flag is decoded as 1 and the absolute value of the coefficient is greater than 1 flag is decoded as 0, the absolute value of the coefficient is determined to be 1; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0360] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 flag is decoded as 1, and the modulo result flag is decoded as 101B, the absolute value of the coefficient is determined to be 2. When the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0361] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 flag is decoded as 1, and the modulo result flag is decoded as 110B, the absolute value of the coefficient is determined to be 3. When the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0362] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 flag is decoded as 1, and the modulo result flag is decoded as 111B, the absolute value of the coefficient is determined to be 4. When the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0363] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 and the absolute value of the coefficient is greater than 1 and the modulo result flag is not decoded as 101B, 110B or 111B, the absolute value of the coefficient is calculated according to Formula 3 and Table 3 above; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0364] In one example, when the decoding result of the coefficient is: sig=1, gt1=1, rem_flag=000B, rem=0, coeff_sign=1, the coefficient is -5.
[0365] The above Figure 18 The encoding methods and correspondences shown in Table 3 are illustrative examples. Other encoding methods and correspondences can also be used. For example, three binary digits include eight binary codes. Any three of these binary codes can be used as the encoding values of the modulo result flag rem_flag with the absolute values of the coefficients being 2, 3, and 4, respectively. The other five binary codes can be used as the encoding values of the five modulo result flags rem_flag with the absolute values of the coefficients being modulo 5 with remainders of 0, 1, 2, 3, and 4, respectively. The correspondence between rem_flag and f(rem_flag) satisfies that the absolute value of the coefficient calculated according to Formula 3 is an integer.
[0366] In an exemplary embodiment, the technical solution of the present disclosure is described in detail using a modulus of 4 as an example.
[0367] In this exemplary embodiment, the syntax elements of the coefficients include a non-zero flag sig, a coefficient absolute value greater than 1 flag gt1, a modulo result flag rem_flag, a residual value flag rem, and a sign flag coeff_sign. The modulo result flag rem_flag is represented using two binary bits.
[0368] In this exemplary embodiment, when the modulus is 4, the coefficient encoding method is as follows: Figure 21 As shown, the values of each flag satisfy formula 4: |qk|=sig+gt1+g(rem_flag)+4×rem. When any one of the following flags is missing: non-zero flag sig, coefficient absolute value greater than 1 flag gt1, modulo result flag rem_flag, or residual value flag rem, its corresponding value in this formula is treated as 0.
[0369] In this exemplary embodiment, rem_flag is the corresponding binary encoded value, and g(rem_flag) is the numerical value corresponding to rem_flag, which is represented in decimal. The correspondence between rem_flag and g(rem_flag) is shown in Table 4:
[0370] Table 4:
[0371] rem_flag 00 01 10 11 f(rem_flag) 0 1 2 3
[0372] based on Figure 21 The encoding methods shown in the figure and the corresponding relationships shown in Table 4 illustrate a coefficient entropy encoding method in this exemplary embodiment. Figure 22 As shown, the method includes:
[0373] Step 2201: Generate a coefficient block based on the residual block, and scan the coefficients in the coefficient block;
[0374] In one exemplary embodiment, the current block is predicted by a prediction part, i.e., through inter-frame prediction or intra-frame prediction, to obtain a prediction block. Image blocks at corresponding positions of the original image and the prediction block are taken, and the difference between the prediction block and the prediction block is calculated to obtain a residual block for the current block. The residual block is then transformed or not transformed to obtain a transformed block containing transformed coefficients or a non-transformed coefficient block, collectively referred to here as a coefficient block. The coefficient block is then quantized, and the quantized coefficients are entropy-encoded according to the coefficient scanning order.
[0375] In one exemplary embodiment, the scanning may be a diagonal scan, a zigzag scan, a horizontal scan, a vertical scan, a 4x4 sub-block scan, or any other scan sequence.
[0376] Step 2202, the value of the coefficient is based on Figure 21 The encoding method shown and the corresponding relationship shown in Table 4 are used for entropy encoding;
[0377] In one exemplary embodiment, the value of the coefficient is based on Figure 21 The encoding method shown and the correspondence shown in Table 4 are used for entropy encoding, including: entropy encoding the value of each coefficient in the coefficient block according to the scan position:
[0378] The non-zero flag sig of the coefficient is encoded as follows: when the absolute value of the coefficient is 0, the non-zero flag sig is encoded as 0; when the absolute value of the coefficient is not 0, the non-zero flag sig is encoded as 1.
[0379] When the non-zero flag sig is 0, skip the encoding of the coefficient absolute value greater than 1 flag, modulo result flag, residual value flag and sign flag; when the non-zero flag sig is 1, encode the coefficient absolute value greater than 1 flag gt1; when the coefficient absolute value is not greater than 1, encode the coefficient absolute value greater than 1 flag gt1 as 0; when the coefficient absolute value is greater than 1, encode the coefficient absolute value greater than 1 flag gt1 as 1.
[0380] When the absolute value of a coefficient is greater than 1 and the flag gt1 is 0, skip encoding the modulo result flag and the residual value flag for that coefficient. When the absolute value of a coefficient is greater than 1 and the flag gt1 is 1, encode the modulo result flag for that coefficient. When the absolute value of the coefficient modulo 4 is 0, encode the modulo result flag rem_flag as 00B. When the absolute value of the coefficient modulo 4 is 1, encode the modulo result flag rem_flag as 01B. When the absolute value of the coefficient modulo 4 is 2, encode the modulo result flag rem_flag as 10B. When the absolute value of the coefficient modulo 4 is 3, encode the modulo result flag rem_flag as 11B.
[0381] Encode the remaining value flag;
[0382] The residual value flag rem can be calculated according to Formula 4 and Table 4 above.
[0383] When the non-zero flag sig is 1, the symbol flag coeff_sign is encoded. When the coefficient is positive, the symbol flag coeff_sign is encoded as 0; when the coefficient is negative, the symbol flag coeff_sign is encoded as 1.
[0384] In one example, when the coefficient is -3, the encoding result is: sig=1, gt1=1, rem_flag=01B, rem=0, coeff_sign=1.
[0385] Step 2203: Write the codewords generated by entropy encoding into the bitstream.
[0386] based on Figure 21 Based on the encoding methods shown and the correspondences shown in Table 4, this exemplary embodiment provides a coefficient entropy decoding method, such as... Figure 23 As shown, the method includes:
[0387] Step 2301: Obtain the bitstream, parse the current encoding unit, and determine the position of the coefficients according to the scanning method used during encoding;
[0388] In one exemplary embodiment, the scanning method can be diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other scanning sequence. For example, in this exemplary embodiment, vertical scanning is used during encoding and also during decoding.
[0389] Step 2302: Perform entropy decoding on the coefficients according to their positions to obtain the syntax elements of the coefficients;
[0390] In one exemplary embodiment, the first coefficient in all coefficients can be entropy decoded sequentially according to its position to obtain the syntax element of the coefficient. Then, the value of the coefficient can be determined based on the syntax element of the coefficient, and then the entropy decoding of the next coefficient can be performed.
[0391] In one exemplary embodiment, the syntax elements of the coefficients are obtained by entropy decoding according to their positions:
[0392] Decode the non-zero flag. When the non-zero flag is decoded as 0, skip decoding the flags for the absolute value of the coefficient being greater than 1, the modulo result flag, the residual value flag, and the sign flag.
[0393] When the non-zero flag is decoded as 1, the absolute value of the coefficient is greater than 1 flag is decoded; when the absolute value of the coefficient is greater than 1 flag is decoded as 0, the decoding of the modulo result flag and the residual value flag is skipped.
[0394] When the absolute value of the coefficient is greater than 1 and the flag is decoded as 1, continue decoding the modulo result flag and the residual value flag;
[0395] When the non-zero flag is decoded as 1, the symbol flag is decoded.
[0396] Step 2303: Determine the value of the coefficient based on the syntax elements of the coefficient.
[0397] In this exemplary embodiment, the value of the coefficient is determined based on the syntax elements of the coefficient in the following manner:
[0398] The absolute value of the coefficient is obtained by adding the decoded value of the non-zero flag, the decoded value of the coefficient absolute value greater than 1 flag, the decoded value of the modulo result flag (pre-set corresponding value), and the residual value flag (multiplied by 4). When the sign flag is 0, the value of the coefficient is positive; when the sign flag is 1, the value of the coefficient is negative.
[0399] Specifically, if any of the following syntax elements does not exist: the decoded value of the non-zero flag, the decoded value corresponding to the coefficient absolute value greater than 1 flag, the decoded value of the modulo result flag, or the residual value flag, the decoded value of the non-zero syntax element or the corresponding pre-set value is set to 0.
[0400] In this exemplary embodiment, the absolute value of the coefficient is calculated using Formula 4 above.
[0401] In another exemplary embodiment, the value of the coefficient is determined based on the syntax element of the coefficient in any of the following ways:
[0402] When the non-zero flag is decoded to 0, the value of the coefficient is determined to be 0;
[0403] When the non-zero flag is decoded as 1 and the absolute value of the coefficient is greater than 1 flag is decoded as 0, the absolute value of the coefficient is determined to be 1; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0404] When the non-zero flag is decoded as 1 and the absolute value of the coefficient is greater than 1, the absolute value of the coefficient is calculated according to Formula 4 and Table 4 above; when the sign flag is 0, the value of the coefficient is positive, and when the sign flag is 1, the value of the coefficient is negative.
[0405] In one example, when the decoding result of the coefficient is: sig=1, gt1=1, rem_flag=10B, rem=1, coeff_sign=1, the coefficient is -8.
[0406] The above Figure 21 The encoding methods and correspondences shown in Table 4 are illustrative examples. Other encoding methods and correspondences can also be used. For example, two binary bits can include four binary codes, which are used as the encoding values of rem_flag, the four modulo results of the absolute value of the coefficient modulo 4: remainder 0, remainder 1, remainder 2, and remainder 3. The correspondence between rem_flag and f(rem_flag) satisfies that the absolute value of the coefficient calculated according to Formula 4 is an integer.
[0407] In another exemplary embodiment, the technical solution of this disclosure embodiment is described in detail using a modulo of 4 as an example. The difference between this exemplary embodiment and the previous exemplary embodiment is that the values of each flag satisfy formula 5: |q k |=sig+gt1+rem_flag+4×rem.
[0408] This disclosure provides a coefficient decoding method, such as... Figure 24 As shown, it includes:
[0409] Step 2401: Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded;
[0410] Step 2402: Determine the value of the coefficient to be decoded based on the decoded syntax elements;
[0411] The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the pre-set corresponding values of the encoded values of the non-zero flag, the absolute value greater than 1 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5.
[0412] In one exemplary embodiment, N = 3;
[0413] When the modulo result flag is decoded as 11B, the pre-set corresponding value is 0;
[0414] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 1;
[0415] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 2;
[0416] When the modulus result flag is decoded as 10B, the preset corresponding value is 3.
[0417] In one exemplary embodiment, N = 4;
[0418] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0;
[0419] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1;
[0420] When the modulus result flag is decoded as 10B, the preset corresponding value is 2;
[0421] When the modulo result flag is decoded as 11B, the pre-set corresponding value is 3. This disclosure provides a coefficient encoding method, such as... Figure 25 As shown, it includes:
[0422] Step 2501: Generate coefficient blocks based on residual blocks, scan the coefficients in the coefficient blocks, and encode the syntax elements of the coefficients to be encoded;
[0423] Step 2502: Write the encoded codewords into the bitstream;
[0424] The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the pre-set corresponding values of the encoded values of the non-zero flag, the absolute value greater than 1 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5.
[0425] In one exemplary embodiment, N = 3;
[0426] When the absolute value of the coefficient is 2, the modulo result is encoded as 11B.
[0427] The result of taking the modulus of the coefficient whose absolute value modulo 3 leaves a remainder of 0 is coded as 00B;
[0428] The result of taking the modulus of the coefficient whose absolute value modulo 3 leaves a remainder of 1 is coded as 01B;
[0429] The result of taking the modulo of the absolute value of the coefficient and obtaining a remainder of 2 is coded as 10B;
[0430] When the modulus result flag code is 11B, the preset corresponding value is 0;
[0431] When the modulus result flag code is 00B, the preset corresponding value is 1;
[0432] When the modulo result flag code is 01B, the preset corresponding value is 2;
[0433] When the modulus result flag is coded as 10B, the preset corresponding value is 3.
[0434] In one exemplary embodiment, N = 3;
[0435] When the absolute value of the coefficient is 3, the modulo result is encoded as 00B.
[0436] The result of taking the modulus of the coefficient whose absolute value modulo 3 leaves a remainder of 0 is coded as 11B;
[0437] The result of taking the modulus of the coefficient whose absolute value modulo 3 leaves a remainder of 1 is coded as 01B;
[0438] The result of taking the modulo of the absolute value of the coefficient and obtaining a remainder of 2 is coded as 10B;
[0439] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0;
[0440] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1;
[0441] When the modulus result flag is decoded as 10B, the preset corresponding value is 2;
[0442] When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
[0443] This disclosure provides a coefficient decoding method, such as... Figure 26 As shown, it includes:
[0444] Step 2601: Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded;
[0445] Step 2602: Determine the value of the coefficient to be decoded based on the decoded syntax elements;
[0446] The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, an absolute value greater than 2 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the corresponding pre-set values of the non-zero flag, the absolute value greater than 1 flag, the absolute value greater than 2 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5.
[0447] In one exemplary embodiment, N = 4;
[0448] The result of taking the modulo of the absolute value of the coefficient and obtaining a remainder of 0 is coded as 10B;
[0449] The result of taking the modulo of the absolute value of the coefficient modulo 4 and obtaining a remainder of 1 is coded as 11B;
[0450] The result of taking the modulo of the absolute value of the coefficient modulo 4 and obtaining a remainder of 2 is coded as 00B;
[0451] The result of taking the modulo of the absolute value of the coefficient and obtaining a remainder of 3 is coded as 01B;
[0452] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0;
[0453] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1;
[0454] When the modulus result flag is decoded as 10B, the preset corresponding value is 2;
[0455] When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
[0456] This disclosure provides a coefficient encoding method, such as... Figure 27 As shown, it includes:
[0457] Step 2701: Generate a coefficient block based on the residual block, scan the coefficients in the coefficient block, and encode the syntax elements of the coefficients to be encoded;
[0458] Step 2702: Write the encoded codewords into the bitstream;
[0459] The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, an absolute value greater than 2 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the corresponding pre-set values of the non-zero flag, the absolute value greater than 1 flag, the absolute value greater than 2 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5.
[0460] In one exemplary embodiment, N = 4;
[0461] The result of taking the modulus of a coefficient whose absolute value modulo 4 leaves a remainder of 0 is coded as 10B, the result of taking the modulus of a coefficient whose absolute value modulo 4 leaves a remainder of 1 is coded as 11B, the result of taking the modulus of a coefficient whose absolute value modulo 4 leaves a remainder of 2 is coded as 00B, and the result of taking the modulus of a coefficient whose absolute value modulo 4 leaves a remainder of 3 is coded as 01B.
[0462] When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0;
[0463] When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1;
[0464] When the modulus result flag is decoded as 10B, the preset corresponding value is 2;
[0465] When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
[0466] In an exemplary embodiment, during the encoding of the syntactic elements of the coefficients, one or more of the following methods are used for encoding: context-based adaptive variable-length code (CAVLC), context-based adaptive binary arithmetic coding, syntax-based adaptive binary arithmetic coding, probability interval partitioning entropy (PIPE), bypass coding, or other entropy coding methods.
[0467] In one example, during the encoding of the syntax elements of the coefficients, the residual value flag rem and the sign flag coeff_sign can be encoded using a bypass encoding method, while the non-zero flag sig, the coefficient absolute value greater than 1 flag gt1, and the modulo result flag rem_flag can be encoded using a context-based adaptive encoding method.
[0468] In one example, during the encoding of the syntax elements of the coefficients, the residual value flag rem and the sign flag coeff_sign can be encoded using a bypass encoding method, while the non-zero flag sig, the coefficient absolute value greater than 1 flag gt1, and the modulo result flag rem_flag can be encoded using a context-based adaptive encoding method.
[0469] The technical solutions provided in the above embodiments of this disclosure improve the original coefficient entropy coding method, which can better utilize the characteristics of adaptive coding, effectively save code rate, and improve coding performance.
[0470] This disclosure also provides an encoding device, such as... Figure 28 As shown, it includes: a processor and a memory storing a computer program executable on the processor, wherein the processor, when executing the computer program, implements the coefficient entropy encoding method described in any of the preceding claims. The encoding device can be a video encoder or video codec of any architecture.
[0471] In one exemplary embodiment, Figure 29 Here is a structural block diagram of a video encoder, such as Figure 29As shown, the video encoder 20 includes a video data memory 33, a segmentation unit 35, a prediction processing unit 41, a summer 50, a transform processing unit 52, a quantization unit 54, and an entropy coding unit 56. The prediction processing unit 41 includes a motion estimation unit (MEU) 42, a motion compensation unit (MCU) 44, an intra-frame prediction processing unit 46, and an intra-frame block copy (IBC) unit 48. Although for ease of explanation... Figure 29 While shown separately, it should be understood that the MEU42, MCU44, intra-frame prediction processing unit 46, and IBC unit 48 can be practically highly integrated. For video block reconstruction, the video encoder 20 also includes an inverse quantization unit 58, an inverse transform processing unit 60, a summer 62, a filter unit 64, and a decoded picture buffer (DPB) 66.
[0472] In one embodiment of this disclosure, the coefficient decoding method described in any of the above embodiments can be performed by a video decoder.
[0473] This disclosure also provides a decoding device, such as... Figure 30 As shown, it includes: a processor and a memory storing a computer program executable on the processor, wherein the processor, when executing the computer program, implements the coefficient entropy decoding method described in any of the preceding claims. The encoding device can be a video decoder or video codec of any architecture.
[0474] In one exemplary embodiment, Figure 31 Here is a block diagram of the structure of a video decoder, such as Figure 31 As shown, the video decoder 30 includes a video data memory 78, an entropy decoding unit 80, a prediction processing unit 81, an inverse quantization unit 86, an inverse transform processing unit 88, a summer 90, a waveform converter unit 92, and a DPB 94. The prediction processing unit 81 includes an MCU 82, an intra-frame prediction processing unit 84, and an IBC unit 85. In some instances, the video decoder 30 can perform operations related to data from... Figure 30 The encoding process described by the video encoder 20 is largely the inverse of the decoding process.
[0475] This disclosure also provides a non-transient computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the coefficient entropy encoding method or the coefficient entropy decoding method described in any of the preceding claims.
[0476] The decoding described in the embodiments of this disclosure can be interpreted as including a decoding operation, or as including an encoding operation and a decoding operation. The encoding described in the embodiments of this disclosure can be interpreted as including an encoding operation, or as including an encoding operation and a decoding operation.
[0477] The decoded value described in the embodiments of this disclosure can also be called the encoded value, and the encoded value can also be called the decoded value; they are the same.
[0478] In one or more exemplary embodiments, the described functionality may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functionality may be stored as one or more instructions or code on or transmitted via a computer-readable medium and executed by a hardware-based processing unit. The computer-readable medium may comprise a computer-readable storage medium corresponding to a tangible medium such as a data storage medium, or a communication medium comprising any medium facilitating the transfer of a computer program from one place to another, for example, according to a communication protocol. In this manner, the computer-readable medium may generally correspond to a non-transitory tangible computer-readable storage medium or a communication medium such as a signal or carrier wave. The data storage medium may be any available medium accessible by one or more computers or one or more processors to retrieve instructions, code, and / or data structures for implementing the techniques described herein. Computer program products may comprise computer-readable media.
[0479] For example, and not as a limitation, such computer-readable storage media may include RAM, ROM, EEPROM, CD-ROM or other optical disc storage devices, magnetic disk storage devices or other magnetic storage devices, flash memory, or any other medium that can be used to store desired program code in the form of instructions or data structures and is accessible by a computer. Furthermore, any connection may also be referred to as a computer-readable medium. For example, if instructions are transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. However, it should be understood that computer-readable storage media and data storage media do not include connections, carrier waves, signals, or other transient media, but rather refer to non-transient tangible storage media. As used herein, disks and optical discs include compact optical discs (CDs), laser discs, optical discs, digital versatile discs (DVDs), floppy disks, or Blu-ray discs, where disks typically reproduce data magnetically, while optical discs use lasers to reproduce data optically. The above combinations should also be included within the scope of computer-readable media.
[0480] Instructions can be executed by one or more processors, such as one or more digital signal processors (DSPs), general-purpose microprocessors, application-specific integrated circuits (ASICs), field-programmable logic arrays (FPGAs), or other equivalent integrated or discrete logic circuits. Therefore, the term "processor" as used herein can refer to any of the above-described structures or any other structures suitable for implementing the techniques described herein. Additionally, in some aspects, the functionality described herein can be provided within dedicated hardware and / or software modules configured for encoding and decoding, or incorporated into combined codecs. Furthermore, the techniques can be fully implemented in one or more circuit or logic elements.
[0481] The technical solutions of the embodiments of this disclosure can be implemented in a wide variety of devices or equipment, including wireless mobile phones, integrated circuits (ICs), or a set of ICs (e.g., chipsets). Various components, modules, or units are described in the embodiments of this disclosure to emphasize functional aspects of a device configured to perform the described techniques, but they do not necessarily need to be implemented through different hardware units. Rather, as described above, the various units can be combined in codec hardware units or provided by a collection of interoperable hardware units (including one or more processors as described above) combined with suitable software and / or firmware.
[0482] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
Claims
1. A coefficient decoding method, comprising: Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded; The value of the coefficient to be decoded is determined based on the decoded syntax elements; The syntax elements include: a non-zero flag, and M absolute values greater than X. i Flags, modulo result flags, residual value flags, and sign flags; the absolute value of the coefficient to be decoded is the encoded value of the non-zero flag, and M absolute values greater than X. i The sum of the pre-set corresponding values of the encoded values of the flag and the encoded values of the modulo result flag, plus the product of the encoded value of the residual value flag and N, is the obtained sum value; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient to be decoded and the sign flag indicating positive or negative; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, i≥M, i and M are positive integers, N is a positive integer greater than 1, X i X is a positive integer and X takes different values when i is different. i The values are different and increase with the value of i.
2. The coefficient decoding method according to claim 1, further comprising: Pre-set a specific encoding value for the modulo result flag of the specified absolute value; Decode the non-zero flag. When the non-zero flag is decoded as 0, skip the decoding of the M coefficient absolute value greater than i flags, modulo result flags, residual value flags, and sign flags. When the non-zero flag is decoded as 1, decode M absolute value greater than Xi flags. When the g-th absolute value greater than Xi flag is decoded as 0, skip the decoding of the subsequent Mg absolute value greater than Xi flags, modulo result flags, and residual value flags; 1≤g≤M; When the absolute value of M coefficients is greater than the i flag and all of them are 1, the decoding modulo result flag is set. When the encoded value of the modulo result flag is decoded into the specific encoded value, the decoding of the residual value flag is skipped; When the modulo result flag is not decoded to the specific encoded value, the remaining value flag is decoded. When the non-zero flag is decoded as 1, the symbol flag is decoded.
3. The coefficient decoding method according to claim 1, further comprising: Decode the non-zero flag. When the non-zero flag is decoded as 0, skip the decoding of the M coefficient absolute value greater than i flags, modulo result flags, residual value flags, and sign flags. When the non-zero flag is decoded as 1, decode M absolute value greater than Xi flags. When the g-th absolute value greater than Xi flag is decoded as 0, skip the decoding of the subsequent Mg absolute value greater than Xi flags, modulo result flags, and residual value flags; 1≤g≤M, when i takes different values, X i The values are different and increase with the value of i; When all M absolute values greater than Xi are 1, decode the modulo result flag and the residual value flag in sequence; When the non-zero flag is decoded as 1, the symbol flag is decoded.
4. The coefficient decoding method according to claim 2 or 3, further comprising: The absolute value of the coefficient = the decoded value of the non-zero flag + the decoded values corresponding to the M flags whose absolute values are greater than Xi + the corresponding value of the decoded value of the modulo result flag (pre-set) + the residual value flag × N; Specifically, if any one of the following syntax elements does not exist: the decoded value of the non-zero flag, the decoded values corresponding to the M absolute values greater than Xi flags, the decoded value of the modulo result flag, or the residual value flag, the decoded value of the non-zero syntax element or the corresponding pre-set value is set to 0.
5. The coefficient decoding method according to claim 1, wherein, M = 1, 2, or 3, N = 2, 3, 4, or 5.
6. The coefficient decoding method according to claim 2, wherein, M=1, X1=1, N=3, the specified absolute value is 2, and the specific encoding value set in advance for the modulo result flag of the specified coefficient absolute value is 11B; Alternatively, M=2, X1=1, X2=2, N=3, the specified absolute value is 3, and the specific encoding value of the modulo result flag of the specified coefficient absolute value is 00B.
7. The coefficient decoding method according to claim 2, wherein, M=1, X1=1, N=3; When the modulo result flag is decoded as 11B, the pre-set corresponding value is 0; When the modulo result flag is decoded as 00B, the pre-set corresponding value is 1; When the modulo result flag is decoded as 01B, the pre-set corresponding value is 2; When the modulus result flag is decoded as 10B, the preset corresponding value is 3.
8. The coefficient decoding method according to claim 2, wherein, M=2, X1=1, X2=2, N=3; When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0; When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1; When the modulus result flag is decoded as 10B, the preset corresponding value is 2; When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
9. The coefficient decoding method according to claim 3, wherein, M=1, X1=1, N=4; When the modulo result flag is decoded as 00B, the pre-set corresponding value is 0; When the modulo result flag is decoded as 01B, the pre-set corresponding value is 1; When the modulus result flag is decoded as 10B, the preset corresponding value is 2; When the modulus result flag is decoded as 11B, the preset corresponding value is 3.
10. A coefficient encoding method, comprising: A coefficient block is generated based on the residual block, the coefficients in the coefficient block are scanned, and the syntax elements of the coefficients to be encoded are encoded. Write the encoded codewords into the bitstream; The syntax elements include: a non-zero flag, and M absolute values greater than X. i The flags include a modulo result flag, a residual value flag, and a symbol flag; the absolute value of the coefficient to be encoded is the encoded value of the non-zero flag, and M absolute values greater than X. i The sum of the pre-set corresponding values of the flag's encoded value and the modulo result flag's encoded value, plus the product of the remaining value flag's encoded value and N, is the obtained sum value; the value of the coefficient to be encoded is determined based on the absolute value of the coefficient to be encoded and the sign flag indicating positive or negative; the encoded value of the modulo result flag is determined based on the coefficient modulo N, where i ≥ M, i and M are positive integers, N is a positive integer greater than 1, and X i X is a positive integer and X takes different values when i is different. i The values are different and increase with the value of i.
11. A coefficient decoding method, comprising: Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded; The value of the coefficient to be decoded is determined based on the decoded syntax elements; The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the corresponding pre-set values of the non-zero flag, the absolute value greater than 1 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5.
12. A coefficient encoding method, comprising: A coefficient block is generated based on the residual block, the coefficients in the coefficient block are scanned, and the syntax elements of the coefficients to be encoded are encoded. Write the encoded codewords into the bitstream; The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be encoded is the sum of the corresponding pre-set values of the non-zero flag, the absolute value greater than 1 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be encoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5.
13. A coefficient decoding method, comprising: Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded; The value of the coefficient to be decoded is determined based on the decoded syntax elements; The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, an absolute value greater than 2 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be decoded is the sum of the corresponding pre-set values of the non-zero flag, the absolute value greater than 1 flag, the absolute value greater than 2 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be decoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5.
14. A coefficient encoding method, comprising: A coefficient block is generated based on the residual block, the coefficients in the coefficient block are scanned, and the syntax elements of the coefficients to be encoded are encoded. Write the encoded codewords into the bitstream; The syntax elements include: a non-zero flag, an absolute value greater than 1 flag, an absolute value greater than 2 flag, a modulo result flag, a residual value flag, and a sign flag; the absolute value of the coefficient to be encoded is the sum of the corresponding pre-set values of the non-zero flag, the absolute value greater than 1 flag, the absolute value greater than 2 flag, and the modulo result flag, plus the product of the residual value flag and N; the value of the coefficient to be encoded is determined based on the absolute value of the coefficient and the sign flag indicating positive or negative sign; the encoded value of the modulo result flag is determined based on the modulo operation of the coefficient with respect to N, where N = 2, 3, 4, or 5.
15. A non-transient computer-readable storage medium storing a computer program, wherein, When the computer program is executed by a processor, it implements the coefficient decoding method as described in any one of claims 1 to 9, or claim 11, or claim 13, or the coefficient encoding method as described in any one of claims 10, 12, or 14.
Citation Information
Patent Citations
Image decoding method and image decoding device
CN107809645A
Rice parameter update for coefficient level coding in video coding process
US20140307800A1