Coefficient coding and decoding method, coding and decoding equipment and storage medium
Through a new coefficient encoding and decoding method, the coefficients in video data are decoded using syntax elements, and the problem of high transmission bandwidth and traffic pressure in the prior art is solved, thereby achieving efficient video encoding and decoding and high-definition video transmission.
Patent Information
- Application Number
- CN202510119166.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-12
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2041-03-12
AI Technical Summary
Existing digital video compression technologies still have room for improvement in reducing video data bandwidth and traffic pressure, especially when meeting high-definition video needs.
A coefficient encoding and decoding method is proposed, which determines the value of the coefficient by analyzing the code stream and decoding the syntax elements of the decoding coefficients. The method includes non-zero flags, flags whose absolute value is greater than a certain threshold, modulus result flags, residual value flags and symbol flags, and is used to calculate the absolute value and symbols of coefficients.
It effectively reduces the transmission bandwidth and traffic of video data, improves the efficiency of video encoding and decoding, and meets the needs of high-definition video.
Smart Images

Figure CN119893123A_ABST
Abstract
Description
[0001] The present disclosure is a divisional application of the PCT international patent application PCT / CN2021 / 080635 with an application date of March 12, 2021, which has entered the Chinese national phase and has Chinese patent application number 202180095282.6 and the invention name “Coefficient encoding and decoding method, encoding and decoding device and storage medium”. Technical Field
[0002] The embodiments of the present disclosure relate to but are not limited to video coding and decoding technology, and in particular provide a coefficient coding and decoding method, a coding and decoding device, and a storage medium. Background Art
[0003] Digital video compression technology is mainly used to compress huge digital video data for transmission and storage. With the surge in Internet videos and people's increasing demand for video clarity, although the existing digital video compression standards can save a lot of video data, there is still a need to pursue better digital video compression technology to reduce the bandwidth and traffic pressure of digital video transmission. Summary of the invention
[0004] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
[0005] The present disclosure provides a coefficient decoding method, including:
[0006] Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded;
[0007] Determine the value of the coefficient to be decoded according to the syntax element obtained by decoding;
[0008] The syntax elements include: a non-zero flag, M absolute values greater than X i flag, modulo result flag, residual value flag and sign flag; the absolute value of the coefficient to be decoded is the coded value of the non-zero flag, M absolute values greater than X i The sum of the code value of the flag and the code value of the modulo result flag, plus the product of the code value of the residual value flag and N, is obtained; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign indicating the positive or negative sign; the code value of the modulo result flag is determined according to the modulo operation of the coefficient on N, i≥M, i, M are positive integers, N is a positive integer greater than 1, X i is a positive integer and when i takes different values, X i The values are different and increase with the value of i.
[0009] The present disclosure provides a coefficient encoding method, including:
[0010] Generate a coefficient block based on the residual block, scan coefficients in the coefficient block, and encode syntax elements of the coefficients to be encoded;
[0011] Write the codeword generated by encoding into the code stream;
[0012] The syntax elements include: a non-zero flag, M absolute values greater than X i flag, modulo result flag, residual value flag and sign flag; the absolute value of the coefficient to be decoded is the coded value of the non-zero flag, M absolute values greater than X i The sum of the code value of the flag and the code value of the modulo result flag, plus the product of the code value of the residual value flag and N, is obtained; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign indicating the positive or negative sign; the code value of the modulo result flag is determined according to the modulo operation of the coefficient on N, i≥M, i, M are positive integers, N is a positive integer greater than 1, X i is a positive integer and when i takes different values, X i The values are different and increase with the value of i. The present disclosure provides a coefficient decoding method, including:
[0013] Parsing the acquired bitstream and decoding the syntax elements of the coefficients to be decoded; determining the values of the coefficients to be decoded according to the syntax elements obtained by decoding;
[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 corresponding numerical values of the non-zero flag, the absolute value greater than 1 flag, and the modulo result flag, and the product of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positive or negative; the modulo result flag is determined according to the modulo operation of the coefficient on N, where N=2, 3, 4 or 5. The disclosed embodiment provides a coefficient encoding method, including:
[0015] Generate a coefficient block based on the residual block, scan coefficients in the coefficient block, and encode syntax elements of the coefficients to be encoded;
[0016] Write the codeword generated by encoding into the code stream;
[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 corresponding numerical values of the non-zero flag, the absolute value greater than 1 flag, and the modulo result flag, and the product of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positive or negative; the modulo result flag is determined according to the modulo operation of the coefficient on N, where N=2, 3, 4 or 5. The disclosed embodiment provides a coefficient decoding method, including:
[0018] Parsing the acquired bitstream and decoding the syntax elements of the coefficients to be decoded; determining the values of the coefficients to be decoded according to the syntax elements obtained by decoding;
[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 corresponding numerical 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, and the product of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positive or negative; the modulo result flag is determined according to the modulo operation of the coefficient on N, where N=2, 3, 4 or 5. The disclosed embodiment provides a coefficient encoding method, including:
[0020] Generate a coefficient block based on the residual block, scan coefficients in the coefficient block, and encode syntax elements of the coefficients to be encoded;
[0021] Write the codeword generated by encoding into the code stream;
[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 numerical 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, and the product of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positive or negative; the modulo result flag is determined according to the modulo operation of the coefficient on N, N = 2, 3, 4 or 5. The embodiment of the present disclosure provides a decoding device, including: a processor and a memory storing a computer program that can be run on the processor, wherein the processor implements any of the above-mentioned coefficient decoding methods when executing the computer program.
[0023] An embodiment of the present disclosure provides a coding device, including: a processor and a memory storing a computer program that can be run on the processor, wherein the processor implements any of the above-mentioned coefficient coding methods when executing the computer program.
[0024] An embodiment of the present disclosure provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements any of the above-mentioned coefficient decoding methods, or implements any of the above-mentioned coefficient encoding methods.
[0025] Other aspects will be apparent upon reading and understanding the drawings and detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are used to provide an understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solutions of the present disclosure and do not constitute a limitation to the technical solutions of the present disclosure.
[0027] Figure 1 A schematic diagram of a video compression coding framework;
[0028] Figure 2 A schematic diagram of a diagonal scan in VVC;
[0029] Figure 3 A schematic diagram of a coefficient absolute value encoding method in VVC;
[0030] Figure 4 A schematic diagram of an anti-zig-zag scan in AVS;
[0031] Figure 5 A schematic diagram of a coefficient absolute value encoding method in AVS;
[0032] Figure 6 A schematic diagram of a flow chart of a coefficient decoding method according to an embodiment of the present disclosure;
[0033] Figure 7 Schematic diagram of a flow chart of a coefficient encoding method according to an embodiment of the present disclosure;
[0034] Figure 8 A schematic diagram of a flow chart of a coefficient decoding method according to an embodiment of the present disclosure;
[0035] Fig. 9 Schematic diagram of a flow chart of a coefficient encoding method according to an embodiment of the present disclosure;
[0036] Fig.10 Schematic diagram of a coefficient absolute value encoding method with modulus 3 in an exemplary embodiment of the present disclosure;
[0037] Fig.11 It is a flowchart of a coefficient encoding method in an exemplary embodiment of the present disclosure;
[0038] Fig.12 is an example diagram of diagonal scanning in an exemplary embodiment of the present disclosure;
[0039] Fig.13 Schematic diagram of encoding of a scanned coefficient string in an exemplary embodiment of the present disclosure;
[0040] Fig.14 A schematic diagram of a flow chart of a coefficient decoding method in an exemplary embodiment of the present disclosure;
[0041] Fig.15 Schematic diagram of a coefficient absolute value encoding method with modulus 3 in an exemplary embodiment of the present disclosure;
[0042] Fig.16 It is a flowchart of a coefficient encoding method in an exemplary embodiment of the present disclosure;
[0043] Fig.17 A schematic diagram of a flow chart of a coefficient decoding method in an exemplary embodiment of the present disclosure;
[0044] Fig.18 Schematic diagram of a coefficient absolute value encoding method with a modulus of 5 in an exemplary embodiment of the present disclosure;
[0045] Fig.19 It is a flowchart of a coefficient encoding method in an exemplary embodiment of the present disclosure;
[0046] Fig. 20 A schematic diagram of a flow chart of a coefficient decoding method in an exemplary embodiment of the present disclosure;
[0047] Fig.21Schematic diagram of a coefficient absolute value encoding method with modulus 4 in an exemplary embodiment of the present disclosure;
[0048] Fig. 22 It is a flowchart of a coefficient encoding method in an exemplary embodiment of the present disclosure;
[0049] Fig.23 A schematic diagram of a flow chart of a coefficient decoding method in an exemplary embodiment of the present disclosure;
[0050] Fig.24 A schematic diagram of a flow chart of a coefficient decoding method according to an embodiment of the present disclosure;
[0051] Fig.25 Schematic diagram of a flow chart of a coefficient encoding method according to an embodiment of the present disclosure;
[0052] Fig.26 A schematic diagram of a flow chart of a coefficient decoding method according to an embodiment of the present disclosure;
[0053] Fig. 27 Schematic diagram of a flow chart of a coefficient encoding method according to an embodiment of the present disclosure;
[0054] Fig.28 It is a schematic diagram of the structure of the encoding device according to an embodiment of the present disclosure;
[0055] Fig.29 is a structural block diagram of a video encoder in an exemplary embodiment of the present disclosure;
[0056] Fig.30 It is a structural schematic diagram of a decoding device according to an embodiment of the present disclosure;
[0057] Fig.31 FIG. 4 is a structural block diagram of a video decoder in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0058] The present disclosure describes multiple embodiments, but the description is exemplary rather than restrictive, and it is obvious to those skilled in the art that there may be more embodiments and implementations within the scope of the embodiments described in the present disclosure.
[0059] In the present disclosure, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment described as "exemplary" or "for example" in the present disclosure should not be interpreted as being preferred or advantageous over other embodiments.
[0060] When describing representative exemplary embodiments, the specification may have presented the method and / or process as a specific sequence of steps. However, to the extent that the method or process does not rely on the specific order of the steps described herein, the method or process should not be limited to the steps in the specific order described. As will be appreciated by those of ordinary skill in the art, other orders of steps are also possible. Therefore, the specific order of the steps set forth in the specification should not be interpreted as a limitation on the claims. In addition, the claims for the method and / or process should not be limited to the steps that are performed in the order written, and those skilled in the art can easily understand that these orders can be changed and still remain within the spirit and scope of the disclosed embodiments.
[0061] Video coding standards include H.264 / Advanced Video Coding (AVC), H.265 / High Efficiency Video Coding (HEVC), H.266 / Versatile Video Coding (VVC) and their extensions, MPEG (Moving Picture Experts Group), AOM (Alliance for Open Media) or any other customized standards. These standards use video compression technology to reduce the amount of data transmitted and stored to achieve more efficient video coding and decoding and transmission and storage.
[0062] Video compression includes multiple modules such as intra-frame prediction (spatial domain) and / or inter-frame prediction (temporal domain) for reducing or removing redundancy in the video, transformation, quantization and inverse quantization and inverse transformation of residual information, loop filtering and entropy coding for improving the subjective and objective reconstruction quality. Figure 1 A schematic diagram of a video compression coding framework, such as Figure 1 As shown, it includes: intra-frame prediction, motion estimation / compensation, transformation / quantization, inverse transformation / inverse quantization, loop filtering, entropy coding and other modules.
[0063] Some video compression standards are block-based compression techniques. For example, a video clip, a frame or a series of pictures can be divided into coding tree units CTU (Coding Tree Unit), and the coding tree unit CTU is further divided into image blocks with CU (Coding Unit) as the basic unit. Intra-frame prediction refers to prediction based on the pixels around the block as reference, and inter-frame prediction refers to prediction based on the neighboring block information in the reference space and the reference information in other frames. The prediction block of the unit to be coded CU can be obtained through intra-frame prediction or inter-frame prediction. The residual information represents the pixel difference between the original CU to be coded and the predicted CU, also known as the residual block. In contrast to the prediction 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 the residual coefficients, which can then be quantized into a one-dimensional vector in the two-dimensional array according to the coefficient scanning order. The transformed and quantized coefficients can be applied to entropy coding to achieve more compression. These video compression techniques are described in the standards and implemented in various fields related to video compression.
[0064] Some concepts involved in the embodiments of the present disclosure are first introduced below.
[0065] Coding Unit (CU) is the basic unit for performing various types of encoding or decoding operations in the video encoding and decoding process, such as CU-based prediction, transformation, entropy coding and other operations. CU refers to a two-dimensional array of sampling points, which can be a square array or a rectangular array. For example, a 4x8 CU can be regarded as a square array of sampling points consisting of 4x8, a total of 32 sampling points. CU can also be called an image block.
[0066] The current coding unit CU refers to the coding unit currently being processed, and may also be referred to 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: refers to the CU that provides a reference signal for the current CU, and can also be called a reference block. The pixel points of the reference CU refer to the pixel points contained in the reference CU.
[0068] Prediction CU: refers to the CU that provides prediction for the current CU, also known as prediction unit (PU). Each CU may contain one or more PUs. A PU may include pixel data in the spatial domain (also known as the pixel domain).
[0069] A residual block refers to a residual image block formed by subtracting the prediction block from the current block to be encoded after the prediction block of the current block is generated through inter-frame prediction and / or intra-frame prediction, and may also be called residual data.
[0070] Transform unit TU (TU, transform unit) refers to the block that presents residual (Residual) or coefficients (Transform Coefficients) obtained by transforming residual data, which can also be called transform block. Each CU can contain one or more TUs. For example, the residual data can be transformed into coefficients using discrete cosine transform, integer transform, wavelet transform or similar transform, that is, the residual data is converted from the pixel domain to the transform domain.
[0071] The coefficient block includes a transform block containing transform coefficients obtained by transforming the residual block, or a residual block containing residual data (residual signal) without transforming the residual block.
[0072] In the disclosed embodiment, the coefficients include coefficients of a transform block obtained by transforming a residual block, or coefficients of the residual block, and entropy encoding the coefficients includes entropy encoding the coefficients of the transform block after quantization, or, if the transform is not applied to the residual data, includes entropy encoding 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. In order to perform effective compression, the coefficients generally need to be quantized. The quantized coefficients can also be called levels.
[0074] Quantization is usually used to reduce the dynamic range of coefficients, so as to achieve the purpose of expressing video with fewer code words. The quantized value is usually called level. The quantization operation is usually to divide the coefficient by the quantization step size, which is determined by the quantization factor transmitted in the bitstream. Inverse quantization is completed by multiplying the level by the quantization step size. For a block of size NxM, the quantization of all coefficients can be completed independently. This technology is widely used in many international video compression standards, such as H.264 and HEVC. In the VVC international video compression standard, the quantization operation can use the correlation between coefficients and the characteristics of the quantized coefficients to select a better quantization method, so as to achieve the purpose of optimizing quantization.
[0075] Entropy encoding of the coefficients consists of two parts:
[0076] One is to scan the coefficients, which includes transforming a two-dimensional coefficient block into a one-dimensional coefficient stream;
[0077] The scanning order may be diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning or any other order of scanning.
[0078] The second is to entropy encode the coefficient values and then write them into the bitstream.
[0079] After the coefficient block is 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 coding CAVLC (context-based adaptive variable-length code), context-based adaptive binary arithmetic coding (context-based adaptive binary arithmetic coding), syntax-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), the coefficients in a transform block are usually 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. Figure 2 As shown, first, an 8x8 transform block is divided into four 4x4 sub-blocks, and then the coefficients are quantized from a two-dimensional vector to a one-dimensional vector using a diagonal scanning method.
[0081] In VVC, after scanning, the syntax elements of the coefficient at each position include six parts: non-zero flag sig_coeff_flag, coefficient absolute value greater than 1 flag abs_level_gtx_flag[0], parity check flag par_level_flag, coefficient absolute value greater than 3 flag abs_level_gtx_flag[1], residual value flags abs_remainder and dec_abs_level, and 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 coefficient absolute value greater than 1 flag is used to indicate whether the absolute value of the coefficient │qk│ is greater than 1. The parity check flag is used to indicate whether the absolute value of the coefficient │qk│ is odd or even. The coefficient absolute value greater than 3 flag 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, qk is the value of the coefficient, sig is the coded value of the non-zero flag, gt1 is the coded value of the coefficient absolute value greater than 1, par is the coded value of the parity check flag, gt3 is the coded value of the coefficient absolute value greater than 3, and rem is the coded value of the coefficient residual value. When a flag does not exist, its value is treated as 0. The sign flag is used to indicate the positive or negative nature of the coefficient.
[0082] In VVC, the correspondence between the flag bits included 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 absolute value encoding method of the coefficients shown in the figure, the process of entropy encoding the coefficients includes:
[0084] Encode the non-zero flag sig_coeff_flag. When the coefficient is 0, encode sig_coeff_flag as 0; when the coefficient is not 0, encode sig_coeff_flag as 1;
[0085] When sig_coeff_flag is encoded as 0, skip encoding of the coefficient absolute value greater than 1 flag abs_level_gtx_flag[0], parity check flag par_level_flag, coefficient absolute value greater than 3 flag abs_level_gtx_flag[1], residual value flags abs_remainder and dec_abs_level, and sign flag coeff_sign_flag; when sig_coeff_flag is encoded as 1, encode abs_level_gtx_flag[0], and when the absolute value of the coefficient is 1, encode abs_level_gtx_flag[0] as 0; when the absolute value of the coefficient is greater than 1, encode abs_level_gtx_flag[0] as 1;
[0086] When abs_level_gtx_flag[0] is 0, the parity check flag par_level_flag, the coefficient absolute value greater than 3 flag abs_level_gtx_flag[1], the residual value flag abs_remainder and dec_abs_level are skipped; when abs_level_gtx_flag[0] is 1, par_level_flag is encoded, and when the absolute value of the coefficient is an even number, par_level_flag is encoded as 0; when the absolute value of the coefficient is an odd number, par_level_flag is encoded 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 remaining 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] Among them, the remaining 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 positivity 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 coding method, and the other flags can be encoded using a context-based adaptive coding method.
[0092] In AVS (Audio and Video Coding Standard), the coefficients to be encoded are usually limited to a range through SRCC technology. For example, Figure 4 As shown, the coefficient scanning method is SR X— SR Y The lower right corner of the range is taken as the starting point, and 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 of the coefficients at each position include the non-zero flag sig_flag, the coefficient absolute value greater than 1 flag coeff_abs_level_greater1_flag, the coefficient absolute value greater than 2 flag coeff_abs_level_greater2_flag, the residual value flag coeff_abs_level_remaining and the sign flag coeff_sign. Among them, the non-zero flag is used to indicate whether the absolute value of the coefficient │qk│ is non-zero. The coefficient absolute value greater than 1 flag is used to indicate whether the absolute value of the coefficient │qk│ is greater than 1. The coefficient absolute value greater than 2 flag is used to indicate whether the absolute value of the coefficient │qk│ is greater than 2. The residual value flag indicates the residual value of the coefficient, which can be determined using the following formula: |qk|=sig+gt1+gt2+rem. qk is the value of the coefficient, sig is the coded value of the non-zero flag, gt1 is the coded value of the coefficient absolute value greater than 1, gt2 is the coded value of the coefficient absolute value greater than 2, and rem is the coded value of the coefficient residual value. In this formula, when a flag does not exist, its value is treated as 0. The sign flag is used to indicate the positive or negative nature of the coefficient.
[0094] In AVS, the corresponding relationship between the flag bits included in the syntax element of the coefficient qk and the absolute value of the coefficient is as follows: Figure 5 shown.
[0095] based on Figure 5 The absolute value encoding method of the coefficients shown in the figure, the process of entropy encoding the coefficients includes:
[0096] Encode the non-zero flag sig_flag. When the coefficient is 0, encode sig_flag as 0; when the coefficient is not 0, encode sig_flag as 1;
[0097] When sig_flag is encoded as 0, the encoding of the coefficient absolute value greater than 1 flag coeff_abs_level_greater1_flag, the coefficient absolute value greater than 2 flag coeff_abs_level_greater2_flag, the residual value flag coeff_abs_level_remaining and the sign flag coeff_sign is skipped; when sig_flag is encoded as 1, coeff_abs_level_greater1_flag is encoded, and when the absolute value of the coefficient is not greater than 1, coeff_abs_level_greater1_flag is encoded as 0; when 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, the coding of the coefficient absolute value greater than 2 flag coeff_abs_level_greater2_flag and the residual value flag coeff_abs_level_remaining is skipped; when coeff_abs_level_greater1_flag is 1, coeff_abs_level_greater2_flag is coded, and when the absolute value of the coefficient is not greater than 2, coeff_abs_level_greater2_flag is coded as 0; when the absolute value of the coefficient is greater than 2, coeff_abs_level_greater2_flag is coded as 1;
[0099] When coeff_abs_level_greater2_flag is 0, the encoding of the remaining value flag coeff_abs_level_remaining is skipped; when coeff_abs_level_greater2_flag is 1, the remaining value flag coeff_abs_level_remaining is encoded;
[0100] Among them, coeff_abs_level_remaining can be determined according to the following formula: |qk|=sig+gt1+gt2+rem.
[0101] When sig_flag is encoded as 1, coeff_sign is encoded according to the positivity 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 coding method, and the other flags can be encoded using a context-based adaptive coding method.
[0103] There are many statistical characteristics between the coefficients at each position after scanning, but the above encoding method is relatively simple, and the context-based adaptive binary arithmetic coding does not fully utilize these statistical characteristics. Therefore, the current coefficient entropy coding method still has a lot of room for improvement.
[0104] The present disclosure provides a coefficient decoding method, such as Figure 6 As shown, including:
[0105] Step 601, parsing the acquired bitstream and decoding the syntax elements of the coefficients to be decoded;
[0106] Step 602, determining the value of the coefficient to be decoded according to the syntax element obtained by decoding;
[0107] The syntax elements include: a non-zero flag, M absolute values greater than X i flag, modulo result flag, residual value flag and sign flag; the absolute value of the coefficient to be decoded is the coded value of the non-zero flag, M absolute values greater than X i The sum of the code value of the flag and the code value of the modulo result flag, plus the product of the code value of the residual value flag and N, is obtained; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign indicating the positive or negative sign; the code value of the modulo result flag is determined according to the modulo operation of the coefficient on N, i≥M, i, M are positive integers, N is a positive integer greater than 1, X i is a positive integer and when i takes different values, X i The values are different and increase with the value of i.
[0108] In an exemplary embodiment, the method further comprises: presetting 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 to 0, skip decoding of M coefficients whose absolute values are greater than the i flag, the modulo result flag, the residual value flag, and the sign flag;
[0110] When the non-zero flag is decoded as 1, decode M absolute values greater than Xi flags. When the g-th absolute value greater than Xi flag is decoded as 0, skip the decoding of subsequent Mg absolute values greater than Xi flags, modulo result flags, and residual value flags; 1≤g≤M;
[0111] When the absolute values of M coefficients are greater than i and the flags are all 1, the modulo result flag is decoded;
[0112] When the encoded value of the modulo result flag is decoded to the specific encoded value, the decoding of the remaining value flag is skipped;
[0113] When the modulo result flag is not decoded to the specific encoding value, decoding the remaining value flag;
[0114] When the non-zero flag decodes to 1, the sign flag is decoded.
[0115] In an exemplary embodiment, the method further comprises:
[0116] Decode the non-zero flag. When the non-zero flag is decoded to 0, skip decoding of M coefficients whose absolute values are greater than the i flag, the modulo result flag, the residual value flag, and the sign flag;
[0117] When the non-zero flag is decoded as 1, decode M absolute values 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 values greater than Xi flags, modulo result flags, and residual value flags. 1≤g≤M, when i has different values, X i The values are different and increase with the value of i;
[0118] When the M absolute values are greater than Xi and the flags are all 1, the modulo result flag and the residual value flag are decoded in sequence;
[0119] When the non-zero flag decodes to 1, the sign flag is decoded.
[0120] In an exemplary embodiment, the method further comprises:
[0121] Absolute value of coefficient = decoded value of non-zero flag + decoded values corresponding to M absolute values greater than Xi flags + decoded value of modulo result flag corresponding value set in advance + residual value flag × N;
[0122] Among them, when any syntax element among the decoded value of the non-zero flag, the decoded values corresponding to the M absolute values greater than the Xi flag, the decoded value of the modulo result flag, and the residual value flag does not exist, the decoded value of the non-existent syntax element or the pre-set corresponding numerical value is taken as 0.
[0123] In an 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 coding value pre-set for the modulo result flag of the specified coefficient absolute value is 00B;.
[0126] In an exemplary embodiment, M=1, X1=1, N=3;
[0127] When the modulo result flag is decoded to 11B, the preset corresponding value is 0;
[0128] When the modulo result flag is decoded to 00B, the preset corresponding value is 1;
[0129] When the modulo result flag is decoded to 01B, the preset corresponding value is 2;
[0130] When the modulo result flag is decoded to 10B, the preset corresponding value is 3.
[0131] In an exemplary embodiment, M=2, X1=1, X2=2, N=3;
[0132] When the modulo result flag is decoded to 00B, the preset corresponding value is 0;
[0133] When the modulo result flag is decoded to 01B, the preset corresponding value is 1;
[0134] When the modulo result flag is decoded to 10B, the preset corresponding value is 2;
[0135] When the modulo result flag is decoded to 11B, the preset corresponding value is 3.
[0136] In an exemplary embodiment, M=1, X1=1, N=4;
[0137] When the modulo result flag is decoded to 00B, the preset corresponding value is 0;
[0138] When the modulo result flag is decoded to 01B, the preset corresponding value is 1;
[0139] When the modulo result flag is decoded to 10B, the preset corresponding value is 2;
[0140] When the modulo result flag is decoded to 11B, the preset corresponding value is 3.
[0141] The present disclosure provides a coefficient encoding method, such as Figure 7As shown, including:
[0142] Step 701, generating a coefficient block based on the residual block, scanning coefficients in the coefficient block, and encoding syntax elements of the coefficients to be encoded;
[0143] Step 702, writing the codeword generated by encoding into the code stream;
[0144] The syntax elements include: a non-zero flag, M absolute values greater than X i flag, modulo result flag, residual value flag and sign flag; the absolute value of the coefficient to be decoded is the coded value of the non-zero flag, M absolute values greater than X i The sum of the code value of the flag and the code value of the modulo result flag, plus the product of the code value of the residual value flag and N, is obtained; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign indicating the positive or negative sign; the code value of the modulo result flag is determined according to the modulo operation of the coefficient on N, i≥M, i, M are positive integers, N is a positive integer greater than 1, X i is a positive integer and when i takes different values, X i The values are different and increase with the value of i.
[0145] In an exemplary embodiment, the encoding of the modulo result flag is binary encoding, occupying K flag bits, and the binary encoding of the modulo result flag has 2 K kind;
[0146] The method further includes: presetting a specific coding value for a modulo result flag of a specified coefficient absolute value; encoding the non-zero flag, encoding the non-zero flag as 0 when the coefficient absolute value is 0, skipping the coding of M coefficient absolute values greater than i flags, modulo result flags, residual value flags and sign flags; encoding the non-zero flag as 1 when the coefficient absolute value is not 0;
[0147] When the non-zero flag is coded as 1, M flags with absolute values greater than Xi are coded in sequence. When the absolute value of the coefficient is Q, X i The absolute value greater than Q is greater than Xi, and the code is 0, skipping the subsequent absolute value greater than Xi code; i If the absolute value is less than or equal to Q and greater than Xi, the flag code is 1;
[0148] When any one of the M absolute values greater than Xi flags is encoded as 0, the encoding of the modulo result flag and the residual value flag is skipped; when the M absolute values greater than Xi flags are all encoded as 1, the modulo result flag is encoded, and when the absolute value of the coefficient is the specified coefficient absolute value, the modulo result flag is encoded as the specific encoding value, wherein the specific encoding value has global uniqueness; when the absolute value of the coefficient is not the specified coefficient absolute value, (2 K -N) binary codes are encoded with absolute values from M+1 to M+2 K -N coefficient modulo result flag, and define the above binary coded values as 0 to 2 respectively K -N-1; Encode the remaining N binary codes as the absolute values greater than M+2 K -N coefficient modulo result flag, and the code 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, encode the residual value flag, and encode the residual value flag as a quotient value, which is the absolute value of the coefficient minus the coded value corresponding to the non-zero flag, the coded values corresponding to the M coefficients whose absolute values are greater than the i flag, and the coded value of the modulo result flag pre-set corresponding numerical values, and then divided by N to obtain the quotient value, wherein the coded value of the modulo result flag pre-set corresponding numerical value satisfies the calculated quotient value is an integer;
[0150] The sign flag is encoded when the non-zero flag is encoded as 1, the sign flag is encoded as 0 when the coefficient is positive, and the sign flag is encoded as 1 when the coefficient is negative.
[0151] In an exemplary embodiment, the encoding of the modulo result flag is binary encoding, occupying K flag bits, and the binary encoding of the modulo result flag has 2 K kind;
[0152] The method further comprises:
[0153] Encode the non-zero flag, when the absolute value of the coefficient is 0, encode the non-zero flag as 0, skip encoding the flags of M coefficients with absolute values greater than i, the modulo result flag, the residual value flag and the sign flag; when the absolute value of the coefficient is not 0, encode the non-zero flag as 1;
[0154] When the non-zero flag is coded as 1, M flags with absolute values greater than Xi are coded in sequence. When the absolute value of the coefficient is Q, X i The absolute value greater than Q is greater than Xi, and the code is 0, skipping the subsequent absolute value greater than Xi code; iThe absolute value less than or equal to Q is greater than Xi flag is encoded as 1; when any of the M absolute values greater than Xi flags is encoded as 0, skip the encoding of the modulo result flag and the residual value flag; when the M absolute values greater than Xi flags are all encoded as 1, encode the modulo result flag, and (2 K -N) binary codes are encoded with absolute values from M+1 to M+2 K -N coefficient modulo result flag, and define the above binary coded values as 0 to 2 respectively K -N-1; Encode the remaining N binary codes as the absolute values greater than M+2 K -N coefficient modulo result flag, and the code values of the N binary codes are defined as 1 to N respectively;
[0155] When M absolute values greater than the Xi flag are all encoded as 1, encode the residual value flag, and encode the residual value flag as a quotient value, which is the absolute value of the coefficient minus the encoding value corresponding to the non-zero flag, the encoding values corresponding to the M coefficient absolute values greater than the i flag, and the encoding value of the modulo result flag pre-set corresponding numerical values, and then divided by N to obtain the quotient value, wherein the pre-set corresponding numerical value of the encoding value of the modulo result flag satisfies the calculated quotient value to be an integer;
[0156] The sign flag is encoded when the non-zero flag is encoded as 1, the sign flag is encoded as 0 when the coefficient is positive, and the sign flag is encoded as 1 when the coefficient is negative.
[0157] In an exemplary embodiment, M=1, 2, or 3, and N=2, 3, 4, or 5.
[0158] In an exemplary embodiment, M=1, X1=1N=3, K=2, the specified coefficient absolute value is 2, and the specific encoding value pre-set for the modulo result flag of the specified absolute value is 11B; the coefficient modulo result flag whose remainder after modulo 3 of the coefficient absolute value is 0 is encoded as 00B, the coefficient modulo result flag whose remainder after modulo 3 of the coefficient absolute value is 1 is encoded as 01B, and the coefficient modulo result flag whose remainder after modulo 3 of the coefficient absolute value is 2 is encoded as 10B;
[0159] When the modulo result flag code is 11B, the preset corresponding value is 0;
[0160] When the modulo 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 modulo result flag is encoded as 10B, the preset corresponding value is 3.
[0163] In an exemplary embodiment, M=2, X1=1, X2=2, N=3, K=2, the specified coefficient absolute value is 3, and the specific encoding value pre-set for the modulo result flag of the specified coefficient absolute value is 00B; the coefficient modulo result flag whose remainder after modulo 3 of the coefficient absolute value is 0 is encoded as 11B, the coefficient modulo result flag whose remainder after modulo 3 of the coefficient absolute value is 1 is encoded as 01B, and the coefficient modulo result flag whose remainder after modulo 3 of the coefficient absolute value is 2 is encoded as 10B;
[0164] When the modulo result flag is decoded to 00B, the preset corresponding value is 0;
[0165] When the modulo result flag is decoded to 01B, the preset corresponding value is 1;
[0166] When the modulo result flag is decoded to 10B, the preset corresponding value is 2;
[0167] When the modulo result flag is decoded to 11B, the preset corresponding value is 3.
[0168] In an exemplary embodiment, M=1, X1=1, N=4, K=2, the coefficient modulo result flag of the coefficient absolute value modulo 4 with a remainder of 0 is encoded as 10B, the coefficient modulo result flag of the coefficient absolute value modulo 4 with a remainder of 1 is encoded as 11B, the coefficient modulo result flag of the coefficient absolute value modulo 4 with a remainder of 2 is encoded as 00B, and the coefficient modulo result flag of the coefficient absolute value modulo 4 with a remainder of 3 is encoded as 01B
[0169] When the modulo result flag is decoded to 00B, the preset corresponding value is 0;
[0170] When the modulo result flag is decoded to 01B, the preset corresponding value is 1;
[0171] When the modulo result flag is decoded to 10B, the preset corresponding value is 2;
[0172] When the modulo result flag is decoded to 11B, the preset corresponding value is 3.
[0173] The present disclosure provides a coefficient decoding method, such as Figure 8 As shown, including:
[0174] Step 801, obtain a bitstream, and parse the current coding unit to determine the position of the coefficient;
[0175] Step 802, performing entropy decoding on the coefficients according to positions to obtain syntax elements of the coefficients;
[0176] Step 803, determining the value of the coefficient according to the syntax element of the coefficient;
[0177] Among them, the coefficient is entropy decoded, including: decoding five syntax elements of the coefficient's non-zero flag, M absolute values greater than Xi flags, modulo result flags, residual value flags and sign flags, and the encoding of the modulo result flag and the residual value flag is 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.
[0178] In an exemplary embodiment, when a specific coding value is set in advance for a modulo result flag of a specified coefficient absolute value, entropy decoding of the coefficient is implemented in the following manner:
[0179] Decode the non-zero flag. When the non-zero flag is decoded to 0, skip decoding of M coefficients whose absolute values are greater than the i flag, the modulo result flag, the residual value flag, and the sign flag;
[0180] When the non-zero flag is decoded as 1, M absolute value greater than Xi flags are decoded in sequence. When the g-th absolute value greater than Xi flag is decoded as 0, the decoding of the subsequent Mg absolute value greater than Xi flags, modulo result flags and residual value flags is skipped; 1≤g≤M, when i has different values, X i The values are different and increase with the value of i;
[0181] When the absolute values of M coefficients are greater than i and the flags are all 1, the modulo result flag is decoded;
[0182] When the modulo result flag is decoded to the specific encoding value, the decoding of the remaining value flag is skipped;
[0183] When the modulo result flag is not decoded to the specific encoding value, decoding the remaining value flag;
[0184] When the non-zero flag decodes to 1, the sign flag is decoded.
[0185] In an exemplary embodiment, entropy decoding of the coefficients is achieved by:
[0186] Decode the non-zero flag. When the non-zero flag is decoded to 0, skip decoding of M coefficients whose absolute values are greater than the i flag, the modulo result flag, the residual value flag, and the sign flag;
[0187] When the non-zero flag is decoded as 1, M absolute value greater than Xi flags are decoded in sequence. When the g-th absolute value greater than Xi flag is decoded as 0, the decoding of the subsequent Mg absolute value greater than Xi flags, modulo result flags and residual value flags is skipped; 1≤g≤M, when i has different values, X i The values are different and increase with the value of i; when the absolute values of the M coefficients are greater than the i flag and are all 1, the modulo result flag and the residual value flag are decoded in sequence;
[0188] When the non-zero flag decodes to 1, the sign flag is decoded.
[0189] In an exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is achieved in the following manner:
[0190] The decoded value of the non-zero flag is added with M decoded values whose absolute values are greater than the decoded values corresponding to the Xi flag, the corresponding values of the decoded value of the modulo result flag set in advance, and the residual value flag multiplied by N, and the sum is obtained 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; the modulo operation is an operation modulo N;
[0191] Among them, when any syntax element among the decoded value of the non-zero flag, the decoded values corresponding to the M absolute values greater than the Xi flag, the decoded value of the modulo result flag, and the residual value flag does not exist, the decoded value of the non-existent syntax element is taken as 0.
[0192] In an exemplary embodiment, when a specific coding value is set in advance for a modulo result flag of a specified coefficient absolute value, determining the value of the coefficient according to the syntax element of the coefficient is achieved by any of the following methods:
[0193] When the non-zero flag is decoded to 0, determining the value of the coefficient to be 0;
[0194] When the non-zero flag is decoded as 1, and the M absolute values greater than Xi flags are not all 1, the X corresponding to the flags with M absolute values greater than Xi flags that are 0 is i The value is taken 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;
[0195] When the non-zero flag is decoded to 1, the M absolute values greater than the Xi flag are all 1, and the modulo result flag is a specific encoding value, the specified coefficient absolute value 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 to 1 and M absolute values greater than the Xi flag are all 1, the decoded value of the non-zero flag is added to the decoded values corresponding to the M absolute values greater than the Xi flag, the corresponding numerical value pre-set for the encoded value of the modulo result flag, and the residual value flag multiplied by N, and the sum is taken 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; the modulo operation is an operation modulo N.
[0197] In an exemplary embodiment, M=1, 2, or 3, and N=2, 3, 4, or 5.
[0198] The present disclosure provides a coefficient encoding method, such as Fig. 9 As shown, including:
[0199] Step 901, generating a coefficient block based on a residual block, scanning coefficients in the coefficient block, and performing entropy coding on values of the coefficients;
[0200] Step 902, write the codeword generated by entropy coding into the bitstream; wherein, entropy coding is performed on the value of the coefficient, including coding of five syntax elements: a non-zero flag of the coefficient, a flag of M absolute values greater than Xi, a modulo result flag, a residual value flag, and a sign flag. The coding values of the modulo result flag and the 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, in the process of entropy encoding the value of the coefficient, the encoding of the modulo result flag is implemented by any of the following methods:
[0202] Pre-setting a specific coding value for a modulo result flag of a specified coefficient absolute value, and when the absolute value of the coefficient is the specified coefficient absolute value, encoding the modulo result flag as the specific coding value, wherein the corresponding coding value has global uniqueness;
[0203] A specific coding value is set in advance for a modulo result flag of a specified coefficient absolute value, and when the absolute value of the coefficient is not the specified coefficient absolute value, the modulo result flag is encoded as a pre-set coding value of a remainder, wherein the remainder is a remainder obtained by modulo N of the absolute value of the coefficient; or, the remainder is a remainder obtained by modulo N of the difference obtained by subtracting a non-zero flag and a flag that the absolute values of M coefficients are greater than i from the absolute value of the coefficient;
[0204] Encoding the modulo result flag as a preset encoding value of the remainder obtained by taking the absolute value of the coefficient modulo N;
[0205] The modulo result flag is encoded as the absolute value of the coefficient minus the non-zero flag and the flag that the absolute values of M coefficients are greater than i, and the difference is then modulo N to obtain a preset encoding value of the remainder;
[0206] The preset coding value is a binary coding value, and each remainder corresponds to a binary coding value.
[0207] In an exemplary embodiment, in the process of entropy encoding the value of the coefficient, the encoding of the residual value flag is implemented by any one of the following methods:
[0208] When the absolute value of the coefficient is the specified absolute value of the 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 a quotient value, which is the absolute value of the coefficient minus the encoding value corresponding to the non-zero flag, the encoding values corresponding to M absolute values greater than the Xi flag, and the corresponding numerical values pre-set for the encoding value of the modulo result flag, and then divided by N to obtain the quotient value, wherein the pre-set corresponding numerical value of the encoding value of the modulo result flag satisfies the calculated quotient value to be an integer.
[0210] In an exemplary embodiment, in the process of entropy coding the values of the coefficients, the coding of the M coefficients whose absolute values are greater than the i flag is implemented by any of the following methods:
[0211] When the non-zero flag is coded as 1, M flags with absolute values greater than Xi are coded in sequence. When the absolute value of the coefficient is Q, X i The absolute value greater than Q is greater than Xi, and the code is 0, skipping the subsequent absolute value greater than Xi code; i The absolute value less than or equal to Q is greater than Xi and the flag is encoded as 1.
[0212] In an exemplary embodiment, in the process of entropy encoding the coefficient, when the absolute value of the coefficient is 0, the non-zero flag is encoded as 0, and the encoding of the M coefficient absolute value greater than i flag, the modulo result flag, the residual value flag and the sign flag is skipped;
[0213] When the absolute value of the coefficient is not 0, the non-zero flag, the flag that the absolute values of the M coefficients are greater than i, the modulo result flag, the residual value flag and the sign flag are encoded in sequence, wherein when the non-zero flag is encoded as 1 and when the flag that the absolute values of the M coefficients are greater than i is 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 encoding value preset for the modulo result flag is in two-bit binary.
[0215] In an exemplary embodiment, the encoding of the modulo result flag is binary encoding, occupying K flag bits, and the binary encoding of the modulo result flag has 2 K kind;
[0216] When entropy coding is performed on the values of the coefficients, (2 K -N) binary codes are encoded with absolute values from M+1 to M+2 K -N coefficient modulo result sign, and define the above binary coded values as 0 to 2 respectively K-N-1; Encode the remaining N binary codes as the absolute values greater than M+2 K -N coefficient modulo result flag, and define the code values of the N binary codes as 1 to N respectively.
[0217] In an exemplary embodiment, N=3, K=2, M=1, the modulo result flag of the coefficient absolute value of 2 is encoded as 11B, the modulo result flag of the coefficient absolute value modulo 3 with a remainder of 0 is encoded as 00B, the modulo result flag of the coefficient absolute value modulo 3 with a remainder of 1 is encoded as 01B, and the modulo result flag of the coefficient absolute value modulo 3 with a remainder of 2 is encoded as 10B, and the encoding value of the residual value flag rem is determined by the following calculation method: |q k |=sig+gt1+f(rem_flag)+3×rem, wherein qk is the coefficient, │qk│ is the absolute value of the coefficient, sig is the coded value of the non-zero flag, gt1 is the coded value of the flag that the absolute value of the coefficient is greater than 1, rem_flag is the coded value of the modulo result flag, and f(rem_flag) is the corresponding numerical value pre-set by rem_flag. When the coded value rem_flag of the modulo result flag is 11B, the corresponding f(rem_flag) is 0; when the coded value rem_flag of the modulo result flag is 00B, the corresponding f(rem_flag) is 1; when the coded value rem_flag of the modulo result flag is 01B, the corresponding f(rem_flag) is 2; when the coded value rem_flag of the modulo result 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 of the coefficient absolute value of 3 is encoded as 00B, the modulo result flag of the coefficient absolute value modulo 3 with a remainder of 0 is encoded as 11B, the modulo result flag of the coefficient absolute value modulo 3 with a remainder of 1 is encoded as 01B, and the modulo result flag of the coefficient absolute value modulo 3 with a remainder of 2 is encoded as 10B, and the encoding value of the residual value flag rem is determined by the following calculation method: |q k|=sig+gt1+gt2+f(rem_flag)+3×rem, wherein qk is the coefficient, │qk│ is the absolute value of the coefficient, sig is the coded value of the non-zero flag, gt1 is the coded value of the flag that the absolute value of the coefficient is greater than 1, gt2 is the coded value of the flag that the absolute value of the coefficient is greater than 2, rem_flag is the coded value of the modulo result flag, and f(rem_flag) is the corresponding numerical value pre-set by rem_flag. When the coded value rem_flag of the modulo result flag is 00B, the corresponding f(rem_flag) is 0; when the coded value rem_flag of the modulo result flag is 01B, the corresponding f(rem_flag) is 1; when the coded value rem_flag of the modulo result flag is 10B, the corresponding f(rem_flag) is 2; when the coded value rem_flag of the modulo result flag is 11B, the corresponding f(rem_flag) is 3.
[0219] In an exemplary embodiment, the encoding of the modulo result flag is binary encoding, and there are N types of binary encodings of the modulo result flag;
[0220] When entropy coding is performed on the value of the coefficient, the absolute value of the coefficient minus the coded value of the non-zero flag and the coded value of the flag of the M coefficients whose absolute values are greater than 1 are subtracted, and the difference is then modulo N to obtain the remainder, which is encoded into the coded value of the modulo result flag of the coefficient.
[0221] In an exemplary embodiment, N=4, K=2, M=1, the modulo result flag of the coefficient absolute value modulo 4 with a remainder of 0 is encoded as 10B, the modulo result flag of the coefficient absolute value modulo 4 with a remainder of 1 is encoded as 11B, the modulo result flag of the coefficient absolute value modulo 4 with a remainder of 2 is encoded as 00B, and the modulo result flag of the coefficient absolute value modulo 4 with a remainder of 3 is encoded as 01B. The encoded value of the residual value flag rem is determined by the following calculation method: |qk|=sig+gt1+g(rem_flag)+4×rem, wherein 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 greater than the encoding value of 1, rem_flag is the encoding value of the modulo result flag, g(rem_flag) is the corresponding numerical value pre-set by rem_flag, when the encoding value rem_flag of the modulo result flag is 00B, the corresponding g(rem_flag) is 0, when the encoding value rem_flag of the modulo result flag is 01B, the corresponding g(rem_flag) is 1, when the encoding value rem_flag of the modulo result flag is 10B, the corresponding g(rem_flag) is 2, when the encoding value rem_flag of the modulo result flag is 11B, the corresponding g(rem_flag) is 3.
[0222] In the disclosed embodiment, the syntax elements of the coefficient include five parts: a non-zero flag sig, a coefficient absolute value greater than i flag gti, a modulo result flag rem_flag, a residual value flag rem, and a sign flag coeff_sign.
[0223] Among them, the non-zero flag sig is used to indicate whether the coefficient is non-zero.
[0224] The coefficient absolute value greater than i flag gti indicates whether the coefficient absolute value is greater than i, for example, the coefficient absolute value greater than i flag gti at least includes the coefficient absolute value greater than 1 flag gt1. The coefficient absolute value greater than i flag can also be called the absolute value greater than Xi flag.
[0225] The value to be encoded of the modulo result flag rem_flag is determined by the modulo value and the remainder obtained. In one example, the modulo result flag can be encoded as a code value corresponding to the remainder, wherein the remainder is the remainder obtained by modulo N of the absolute value of the coefficient; or, the remainder is the remainder obtained by subtracting the non-zero flag and the M coefficient absolute values greater than i flag from the absolute value of the coefficient, and then modulo N. In another example, a specific code value can be set in advance for the modulo result flag of the specified coefficient absolute value, and when the absolute value of the coefficient is the specified coefficient absolute value, the modulo result flag is encoded as the specific code value, wherein the specific code has global uniqueness. In another example, a specific coding value may be set in advance for a modulo result flag of a specified coefficient absolute value, and when the absolute value of the coefficient is not the specified coefficient absolute value, the modulo result flag is encoded as a coding value corresponding to a remainder, wherein the remainder is a remainder obtained by modulo N the absolute value of the coefficient; or, the remainder is a remainder obtained by modulo N the difference obtained by subtracting a non-zero flag and a flag that the absolute values of M coefficients are greater than i from the absolute value of the coefficient;
[0226] Among them, the value required to be encoded for the residual value flag rem is determined by the absolute value of the coefficient minus the encoding value corresponding to the non-zero flag, the encoding values corresponding to the M coefficient absolute values greater than the i flag, and the pre-set corresponding values of the encoding value of the modulo result flag, and then divided by N to obtain the quotient value, wherein the pre-set corresponding value of the encoding value of the modulo result flag satisfies the calculated quotient value to be an integer.
[0227] Among them, the sign flag coeff_sign is used to indicate the positive or negative nature of the level.
[0228] In an exemplary embodiment, the technical solution of the embodiment of the present disclosure is described in detail by taking the modulus as 3 as an example.
[0229] In this exemplary embodiment, the syntax elements of the coefficient 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 by two bits of binary.
[0230] In this exemplary embodiment, when the modulus is 3, the coefficient encoding method is as follows: Fig.10 As shown, the values of each flag satisfy formula 1: |q k |=sig+gt1+f(rem_flag)+3×rem. In Formula 1, when any of the non-zero flag sig, the coefficient absolute value greater than 1 flag gt1, the modulo result flag rem_flag, and the residual value flag rem does not exist, the corresponding value in the formula is treated as 0.
[0231] In this exemplary embodiment, rem_flag is a binary coded value, f(rem_flag) is a numerical value corresponding to rem_flag, expressed in decimal, and the corresponding relationship 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 the coefficient absolute value of 2 is set to 11B in advance. Fig.10 The encoding method shown in Table 1 and the corresponding relationship shown in Table 1, this exemplary embodiment provides a coefficient entropy encoding method, such as Fig.11 As shown, the method includes:
[0235] Step 1101, generating a coefficient block based on the residual block, and scanning coefficients in the coefficient block;
[0236] In an exemplary embodiment, the current block is predicted through the prediction part, that is, through inter-frame prediction or intra-frame prediction, etc., to obtain a prediction block, take the image block at the corresponding position of the original image and the prediction block coordinates, and make a difference with the prediction block to obtain the residual block of the current block, and then transform or not transform the residual block to obtain a transform block containing transformed coefficients or a non-transformed coefficient block, which is collectively referred to as a coefficient block here. Then, the coefficient block is quantized, and the quantized coefficients are entropy encoded according to the coefficient scanning order.
[0237] In an exemplary embodiment, the scanning may be performed in the form of diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other sequential scanning.
[0238] Step 1102, the value of the coefficient is based on Fig.10 The encoding method shown and the corresponding relationship shown in Table 1 are entropy encoded;
[0239] In an exemplary embodiment, the value of the coefficient is based on Fig.10 The encoding method shown in the figure and the corresponding relationship shown in Table 1 are entropy encoded, including: entropy encoding the value of each coefficient in the coefficient block according to the scanning position:
[0240] Encode the non-zero flag sig of the coefficient. 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, the encoding of the coefficient absolute value greater than 1 flag, the modulo result flag, the residual value flag and the sign flag of the coefficient is skipped; when the non-zero flag sig is 1, the coefficient absolute value greater than 1 flag gt1 is encoded, when the coefficient absolute value is not greater than 1, the coefficient absolute value greater than 1 flag gt1 is encoded as 0, and when the coefficient absolute value is greater than 1, the coefficient absolute value greater than 1 flag gt1 is encoded as 1;
[0242] When the coefficient absolute value is greater than 1, flag gt1 is 0, skip encoding the modulo result flag and the residual value flag of the coefficient. When the coefficient absolute value is greater than 1, flag gt1 is 1, encode the modulo result flag rem_flag. When the coefficient absolute value is 2, encode the modulo result flag rem_flag as 11B. When the coefficient absolute value modulo 3 result is 0, encode the modulo result flag rem_flag as 00B; when the coefficient absolute value modulo 3 result is 1, encode the modulo result flag rem_flag as 01B; when the coefficient absolute value modulo 3 result is 2, encode the modulo result flag rem_flag as 10B.
[0243] When the modulo result flag rem_flag is 11B, the encoding of the residual value flag of the coefficient is skipped; when the modulo result flag rem_flag is not 11B, the residual value flag rem of the coefficient is encoded;
[0244] The remaining value mark rem can be calculated according to the above formula 1 and Table 1.
[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 an example, when the coefficient is -3, the encoding result of the coefficient is: sig=1, gt1=1, rem_flag=00B, rem=0, coeff_sign=1.
[0247] In one example, assuming that the 4x4 transform block after the residual transform, Fig.12 As shown, the transform coefficient string obtained after diagonal scanning quantization is {0, 2, 4, 5, 0, 6, 3, 7, 0, 2, 1, 0, 9, 3, 0, 8}, and each coefficient in the coefficient string is quantized in sequence. Fig. 9 The encoding method shown in the figure and the corresponding relationship shown in Table 1 are respectively entropy encoded, and the encoding value is as follows: Fig.13 shown.
[0248] Step 1103: Write the codeword generated by entropy coding into the bitstream.
[0249] based on Fig.10 The encoding method shown in Table 1 and the corresponding relationship shown in Table 1, this exemplary embodiment provides a coefficient entropy decoding method, such as Fig.14 As shown, the method includes:
[0250] Step 1401, obtain a bitstream, parse the current coding unit, and determine the position of the coefficient according to the scanning method used in encoding;
[0251] In an exemplary embodiment, the scanning mode may be diagonal scanning, zigzag scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning or any other sequential scanning. For example, in this exemplary embodiment, diagonal scanning is used during encoding and diagonal scanning is also used during decoding.
[0252] Step 1402, performing entropy decoding on the coefficients according to positions to obtain syntax elements of the coefficients;
[0253] In an exemplary embodiment, the first coefficient of all coefficients may be entropy decoded in sequence according to position to obtain the syntax element of the coefficient, and then the value of the coefficient may be determined according to the syntax element of the coefficient, and then the entropy decoding of the next coefficient may be performed.
[0254] In an exemplary embodiment, entropy decoding the coefficients according to positions to obtain syntax elements of the coefficients is implemented in the following manner:
[0255] Decode the non-zero flag. When the non-zero flag is decoded to 0, skip decoding the coefficient absolute value greater than 1 flag, the modulo result flag, the residual value flag, and the sign flag;
[0256] When the non-zero flag is decoded as 1, the coefficient absolute value is greater than 1 flag is decoded. When the coefficient absolute value 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 coefficient absolute value is greater than 1, the flag is decoded as 1, and the modulo result flag is decoded; when the modulo result flag is decoded as 11B, the decoding of the residual value flag is skipped;
[0258] When the modulo result flag is not decoded to 11B, decode the remaining value flag;
[0259] When the non-zero flag decodes to 1, the sign flag is decoded.
[0260] Step 1403: Determine the value of the coefficient according to the syntax element of the coefficient.
[0261] In this exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is achieved in the following manner:
[0262] 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, the preset corresponding value, and the residual value flag are multiplied by 3, and the sum is taken 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;
[0263] Among them, when any syntax element among 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, and the residual value flag does not exist, the decoded value of the non-existent syntax element or the pre-set corresponding numerical value is taken as 0.
[0264] In the present exemplary embodiment, the absolute value of the coefficient is calculated by Formula 1 above.
[0265] In another exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is implemented by any one of the following methods:
[0266] When the non-zero flag is decoded to 0, determining the value of the coefficient to be 0;
[0267] When the non-zero flag is decoded as 1 and the coefficient absolute value 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 coefficient absolute value 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 coefficient absolute value greater than 1 flag is decoded as 1, and the modulo result flag is not decoded as 11B, the absolute value of the coefficient is calculated according to the above formula 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.
[0270] In an example, when the decoding result of the coefficient is: sig=1, gt1=1, rem_flag=00B, rem=0, and coeff_sign=1, the coefficient is -3.
[0271] Above Fig.10 The encoding method and corresponding relationship shown in Table 1 are an exemplary description. Other encoding methods and corresponding relationships may also be used. For example, two binary numbers include four binary codes. Any one of the binary codes is used as the encoding value of the modulo result flag rem_flag with an absolute value of 2 for the coefficient, and the other three are used as the encoding values of the modulo result flag rem_flag with an absolute value of 0, 1, and 2 for the coefficient modulo 3, respectively. The corresponding relationship 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 embodiment of the present disclosure is described in detail by taking the modulus as 3 as an example.
[0273] In this exemplary embodiment, the syntax elements of the coefficient 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 by two bits of binary.
[0274] In this exemplary embodiment, when the modulus is 3, the coefficient encoding method is as follows: Fig.15 As shown, the values of each flag satisfy Formula 2: |qk|=sig+gt1+gt2+f(rem_flag)+3×rem. In Formula 2, when any of the non-zero flag sig, the coefficient absolute value greater than 1 flag gt1, the coefficient absolute value greater than 2 flag gt2, the modulo result flag rem_flag, and the residual value flag rem does not exist, the corresponding value in the formula is treated as 0.
[0275] In this exemplary embodiment, rem_flag is a binary coded value, f(rem_flag) is a numerical value corresponding to rem_flag, expressed in decimal, and the corresponding relationship 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 coefficient absolute value of 3 is set to 00B in advance.
[0279] based on Fig.15 The encoding method shown in Table 2 and the corresponding relationship shown in Table 2, this exemplary embodiment provides a coefficient entropy encoding method, such as Fig.16 As shown, the method includes:
[0280] Step 1601, generating a coefficient block based on the residual block, and scanning coefficients in the coefficient block;
[0281] In an exemplary embodiment, the current block is predicted through the prediction part, that is, through inter-frame prediction or intra-frame prediction, etc., to obtain a prediction block, take the image block at the corresponding position of the original image and the prediction block coordinates, and make a difference with the prediction block to obtain the residual block of the current block, and then transform or not transform the residual block to obtain a transform block containing transformed coefficients or a non-transformed coefficient block, which is collectively referred to as a coefficient block here. Then, the coefficient block is quantized, and the quantized coefficients are entropy encoded according to the coefficient scanning order.
[0282] In an exemplary embodiment, the scanning may be performed in the form of diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other sequential scanning.
[0283] Step 1602, the value of the coefficient is based on Fig.15 The encoding method shown and the corresponding relationship shown in Table 2 are entropy encoded;
[0284] In an exemplary embodiment, the value of the coefficient is based on Fig.15 The encoding method shown in the figure and the corresponding relationship shown in Table 2 are entropy encoded, including: entropy encoding the value of each coefficient in the coefficient block according to the scanning position:
[0285] Encode the non-zero flag sig of the coefficient. 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, the encoding of the coefficient absolute value greater than 1 flag, the coefficient absolute value greater than 2 flag, the modulo result flag, the residual value flag and the sign flag of the coefficient is skipped; when the non-zero flag sig is 1, the coefficient absolute value greater than 1 flag gt1 is encoded, when the coefficient absolute value is not greater than 1, the coefficient absolute value greater than 1 flag gt1 is encoded as 0, and when the coefficient absolute value is greater than 1, the coefficient absolute value greater than 1 flag gt1 is encoded as 1;
[0287] When the coefficient absolute value is greater than 1 flag gt1 is 0, skip encoding the coefficient absolute value greater than 2 flag, modulo result flag and residual value flag of the coefficient. When the coefficient absolute value is greater than 1 flag gt1 is 1, encode the coefficient absolute value greater than 2 flag. When the coefficient absolute value is not greater than 2, encode the coefficient absolute value greater than 2 flag gt1 as 0. When the coefficient absolute value is greater than 2, encode the coefficient absolute value greater than 2 flag gt1 as 1.
[0288] When the coefficient absolute value is greater than 2, flag gt2 is 0, skip encoding the modulo result flag and the residual value flag of the coefficient; when the coefficient absolute value is greater than 2, flag gt2 is 1, encode the modulo result flag rem_flag, when the coefficient absolute value is 3, encode the modulo result flag rem_flag as 00B, when the coefficient absolute value modulo 3 result is 0, encode the modulo result flag rem_flag as 11B; when the coefficient absolute value modulo 3 result is 1, encode the modulo result flag rem_flag as 01B; when the coefficient absolute value modulo 3 result is 2, encode the modulo result flag rem_flag as 10B;
[0289] When the modulo result flag rem_flag is 00B, the encoding of the residual value flag is skipped; when the modulo result flag rem_flag is not 00B, the residual value flag rem is encoded;
[0290] The remaining value mark rem can be calculated according to the above formula 2 and table 2.
[0291] When the non-zero flag sig is 1, the sign flag coeff_sign 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.
[0292] In an 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 codeword generated by entropy coding into the bitstream.
[0294] based on Fig.15The encoding method shown in Table 2 and the corresponding relationship shown in Table 2, this exemplary embodiment provides a coefficient entropy decoding method, such as Fig.17 As shown, the method includes:
[0295] Step 1701, obtain a bitstream, parse the current coding unit, and determine the position of the coefficient according to the scanning method used in encoding;
[0296] In an exemplary embodiment, the scanning mode may be diagonal scanning, zigzag scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning or any other sequential scanning. For example, in this exemplary embodiment, zigzag scanning is used during encoding and zigzag scanning is also used during decoding.
[0297] Step 1702, performing entropy decoding on the coefficients according to positions to obtain syntax elements of the coefficients;
[0298] In an exemplary embodiment, the first coefficient of all coefficients may be entropy decoded in sequence according to position to obtain the syntax element of the coefficient, and then the value of the coefficient may be determined according to the syntax element of the coefficient, and then the entropy decoding of the next coefficient may be performed.
[0299] In an exemplary embodiment, entropy decoding the coefficients according to positions to obtain syntax elements of the coefficients is implemented in the following manner:
[0300] Decode the non-zero flag. When the non-zero flag is decoded to 0, skip decoding the coefficient absolute value greater than 1 flag, the coefficient absolute value greater than 2 flag, the modulo result flag, the residual value flag, and the sign flag;
[0301] When the non-zero flag is decoded as 1, the coefficient absolute value is greater than 1 flag is decoded. When the coefficient absolute value is greater than 1 flag is decoded as 0, the decoding of the coefficient absolute value is greater than 2 flag, the modulo result flag, and the residual value flag is skipped;
[0302] When the coefficient absolute value is greater than 1 flag is decoded as 1, the coefficient absolute value is greater than 2 flag is decoded; when the coefficient absolute value is greater than 2 flag is decoded as 0, the decoding of the modulus result flag and the residual value flag is skipped;
[0303] When the coefficient absolute value is greater than 2, the flag is decoded as 1, and the modulo result flag is decoded. When the modulo result flag is encoded as 00B, the decoding of the residual value flag is skipped.
[0304] When the modulo result flag code is not 00B, continue decoding the remaining value flag;
[0305] When the non-zero flag is decoded as 1, the sign flag is decoded.
[0306] Step 1703, determining the value of the coefficient according to the syntax element of the coefficient;
[0307] In this exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is achieved in the following manner:
[0308] The decoded value of the non-zero flag is added to 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, the corresponding value set in advance, and the residual value flag multiplied by 3, and the sum is taken 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;
[0309] Among them, when any syntax element among 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, and the residual value flag does not exist, the decoded value of the non-existent syntax element or the pre-set corresponding numerical value is taken as 0.
[0310] In the present exemplary embodiment, the absolute value of the coefficient is calculated by the above-mentioned Formula 2.
[0311] In another exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is implemented by any one of the following methods:
[0312] When the non-zero flag is decoded to 0, determining the value of the coefficient to be 0;
[0313] When the non-zero flag is decoded as 1 and the coefficient absolute value 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 coefficient absolute value is greater than 1 flag is decoded as 1, and the coefficient absolute value is greater than 2 flag 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 coefficient absolute value is greater than 1 flag is decoded as 1, the coefficient absolute value is greater than 2 flag 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 coefficient absolute value greater than 1 flag is decoded as 1, the coefficient absolute value greater than 2 flag 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 an example, when the decoding result of the coefficient is: sig=1, gt1=1, rem_flag=00B, and coeff_sign=1, the coefficient is -3.
[0318] Above Fig.15 The encoding method and corresponding relationship shown in Table 2 are an exemplary description. Other encoding methods and corresponding relationships may also be used. For example, two binary digits include four binary codes. Any one of the binary codes is used as the encoding value of the modulo result flag rem_flag with an absolute value of 3 for the coefficient, and the other three are used as the encoding values of the modulo result flag rem_flag with an absolute value of 0, 1, and 2 for the coefficient modulo 3, respectively. The corresponding relationship 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 embodiment of the present disclosure is described in detail by taking the modulus as 5 as an example.
[0320] In this exemplary embodiment, the syntax elements of the coefficient 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 by three bits of binary.
[0321] In this exemplary embodiment, when the modulus is 5, the coefficient encoding method is as follows: Fig.18 As shown, the values of each flag satisfy Formula 3: |qk|=sig+gt1+f(rem_flag)+5×rem. In Formula 3, when any of the non-zero flag sig, the coefficient absolute value greater than 1 flag gt1, the modulus result flag rem_flag, and the residual value flag rem does not exist, the corresponding value in the formula is treated as 0.
[0322] In this exemplary embodiment, rem_flag is a binary coded value, f(rem_flag) is a numerical value corresponding to rem_flag, expressed in decimal, and the corresponding relationship 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 in advance, 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 Fig.18 The encoding method shown in Table 3 and the corresponding relationship shown in Table 3, this exemplary embodiment provides a coefficient entropy encoding method, such as Fig.19 As shown, the method includes:
[0327] Step 1901, generating a coefficient block based on the residual block, and scanning coefficients in the coefficient block;
[0328] In an exemplary embodiment, the current block is predicted through the prediction part, that is, through inter-frame prediction or intra-frame prediction, etc., to obtain a prediction block, take the image block at the corresponding position of the original image and the prediction block coordinates, and make a difference with the prediction block to obtain the residual block of the current block, and then transform or not transform the residual block to obtain a transform block containing transformed coefficients or a non-transformed coefficient block, which is collectively referred to as a coefficient block here. Then, the coefficient block is quantized, and the quantized coefficients are entropy encoded according to the coefficient scanning order.
[0329] In an exemplary embodiment, the scanning may be performed in the form of diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other sequential scanning.
[0330] Step 1902, the value of the coefficient is based on Fig.18 The encoding method shown and the corresponding relationship shown in Table 3 are entropy encoded;
[0331] In an exemplary embodiment, the value of the coefficient is based on Fig.18 The encoding method shown in the figure and the corresponding relationship shown in Table 3 are entropy encoded, including: entropy encoding the value of each coefficient in the coefficient block according to the scanning position:
[0332] Encode the non-zero flag sig of the coefficient. 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, the encoding of the coefficient absolute value greater than 1 flag, the modulo result flag, the residual value flag and the sign flag of the coefficient is skipped; when the non-zero flag sig is 1, the coefficient absolute value greater than 1 flag gt1 is encoded, and when the absolute value of the coefficient is not greater than 1, the coefficient absolute value greater than 1 flag gt1 is encoded as 0, and when the absolute value of the coefficient is greater than 1, the coefficient absolute value greater than 1 flag gt1 is encoded as 1;
[0334] When the coefficient absolute value is greater than 1 flag gt1 is 0, skip encoding the modulo result flag and the residual value flag of the coefficient. When the coefficient absolute value is greater than 1 flag gt1 is 1, encode the modulo result flag of the coefficient. When the coefficient absolute value modulus is 2, encode the modulo result flag rem_flag as 101B. When the coefficient absolute value modulus is 3, encode the modulo result flag rem_flag as 110B. When the coefficient absolute value modulus is 4, encode the modulo result flag rem_flag as 111B. When the value modulo 5 result is 0, the modulo result flag rem_flag is encoded as 000B; when the absolute value modulo 5 result of the coefficient is 1, the modulo result flag rem_flag is encoded as 001B, when the absolute value modulo 5 result of the coefficient is 2, the modulo result flag rem_flag is encoded as 010B, when the absolute value modulo 5 result of the coefficient is 3, the modulo result flag rem_flag is encoded as 011B, when the absolute value modulo 5 result of the coefficient 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, the encoding of the remaining value flag is skipped;
[0336] When the modulo result flag rem_flag is not encoded as 101B, 110B or 111B, the remaining value flag is encoded;
[0337] The remaining value mark rem can be calculated according to the above formula 3 and Table 3.
[0338] When the non-zero flag sig is 1, the sign flag coeff_sign 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.
[0339] In an 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 codeword generated by entropy coding into the bitstream.
[0341] based on Fig.18 The encoding method shown in Table 3 and the corresponding relationship shown in Table 3, this exemplary embodiment provides a coefficient entropy decoding method, such as Fig. 20 As shown, the method includes:
[0342] Step 2001, obtain a bitstream, parse the current coding unit, and determine the position of the coefficient according to the scanning method used in encoding;
[0343] In an exemplary embodiment, the scanning mode may be diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning or any other sequential scanning. For example, in this exemplary embodiment, horizontal scanning is used during encoding and horizontal scanning is also used during decoding.
[0344] Step 2002, performing entropy decoding on the coefficients according to positions to obtain syntax elements of the coefficients;
[0345] In an exemplary embodiment, the first coefficient of all coefficients may be entropy decoded in sequence according to position to obtain the syntax element of the coefficient, and then the value of the coefficient may be determined according to the syntax element of the coefficient, and then the entropy decoding of the next coefficient may be performed.
[0346] In an exemplary embodiment, entropy decoding the coefficients according to positions to obtain syntax elements of the coefficients is implemented in the following manner:
[0347] Decode the non-zero flag. When the non-zero flag is decoded to 0, skip decoding the coefficient absolute value greater than 1 flag, the modulo result flag, the residual value flag, and the sign flag;
[0348] When the non-zero flag is decoded as 1, the coefficient absolute value is greater than 1 flag is decoded. When the coefficient absolute value 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 coefficient absolute value is greater than 1, the flag is decoded as 1, the modulo result flag is decoded, and when the modulo result flag is decoded as 101B, 110B or 111B, the decoding of the residual value flag is skipped;
[0350] When the modulo result flag is not decoded as 101B, 110B or 111B, the remaining value flag is decoded;
[0351] When the non-zero flag is decoded as 1, the sign flag is decoded.
[0352] Step 2003, determining the value of the coefficient according to the syntax element of the coefficient;
[0353] In this exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is achieved in the following manner:
[0354] 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, the preset corresponding value, and the residual value flag are multiplied by 5, and the sum is taken 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;
[0355] Among them, when any syntax element among 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, and the residual value flag does not exist, the decoded value of the non-existent syntax element or the pre-set corresponding numerical value is taken as 0.
[0356] In the present exemplary embodiment, the absolute value of the coefficient is calculated by the above-mentioned Formula 3.
[0357] In another exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is implemented by any one of the following methods:
[0358] When the non-zero flag is decoded to 0, determining the value of the coefficient to be 0;
[0359] When the non-zero flag is decoded as 1 and the coefficient absolute value 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 coefficient absolute value 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 coefficient absolute value 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 coefficient absolute value 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 coefficient absolute value greater than 1 flag is decoded as 1, and the modulo result flag is not decoded as 101B, 110B or 111B, the absolute value of the coefficient is calculated according to the above formula 3 and Table 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.
[0364] In an example, when the decoding result of the coefficient is: sig=1, gt1=1, rem_flag=000B, rem=0, and coeff_sign=1, the coefficient is -5.
[0365] Above Fig.18 The encoding method and corresponding relationship shown in Table 3 are an exemplary description. Other encoding methods and corresponding relationships may also be used. For example, three-bit binary includes eight binary codes, and any three of the binary codes are used as the encoding values of the modulo result flag rem_flag when the absolute value of the coefficient is 2, 3, and 4, respectively. The other five binary codes are used as the encoding values of the five modulo result flags rem_flag when the absolute value of the coefficient modulo 5 is remainder 0, remainder 1, remainder 2, remainder 3, and remainder 4, respectively. The corresponding relationship 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 embodiment of the present disclosure is described in detail by taking the modulus as 4 as an example.
[0367] In this exemplary embodiment, the syntax elements of the coefficient 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 by two bits of binary.
[0368] In this exemplary embodiment, when the modulus is 4, the coefficient encoding method is as follows: Fig.21 As shown, the values of each flag satisfy Formula 4: |qk|=sig+gt1+g(rem_flag)+4×rem. When any of the non-zero flag sig, the coefficient absolute value greater than 1 flag gt1, the modulo result flag rem_flag, and the residual value flag rem does not exist, the corresponding value in the formula is treated as 0.
[0369] In this exemplary embodiment, rem_flag is a corresponding binary code value, g(rem_flag) is a numerical value corresponding to rem_flag, and the numerical value is expressed in decimal. The corresponding relationship 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 Fig.21 The encoding method shown in Table 4 and the corresponding relationship shown in Table 4, this exemplary embodiment provides a coefficient entropy encoding method, such as Fig. 22 As shown, the method includes:
[0373] Step 2201, generating a coefficient block based on the residual block, and scanning coefficients in the coefficient block;
[0374] In an exemplary embodiment, the current block is predicted through the prediction part, that is, through inter-frame prediction or intra-frame prediction, etc., to obtain a prediction block, take the image block at the corresponding position of the original image and the prediction block coordinates, and make a difference with the prediction block to obtain the residual block of the current block, and then transform or not transform the residual block to obtain a transform block containing transformed coefficients or a non-transformed coefficient block, which is collectively referred to as a coefficient block here. Then, the coefficient block is quantized, and the quantized coefficients are entropy encoded according to the coefficient scanning order.
[0375] In an exemplary embodiment, the scanning may be performed in the form of diagonal scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning, or any other sequential scanning.
[0376] Step 2202, the value of the coefficient is based on Fig.21 The encoding method shown and the corresponding relationship shown in Table 4 are entropy encoded;
[0377] In an exemplary embodiment, the value of the coefficient is based on Fig.21 The encoding method shown in the figure and the corresponding relationship shown in Table 4 are entropy encoded, including: entropy encoding the value of each coefficient in the coefficient block according to the scanning position:
[0378] Encode the non-zero flag sig of the coefficient. 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, the encoding of the coefficient absolute value greater than 1 flag, the modulo result flag, the residual value flag and the sign flag of the coefficient is skipped; when the non-zero flag sig is 1, the coefficient absolute value greater than 1 flag gt1 is encoded, and when the absolute value of the coefficient is not greater than 1, the coefficient absolute value greater than 1 flag gt1 is encoded as 0, and when the absolute value of the coefficient is greater than 1, the coefficient absolute value greater than 1 flag gt1 is encoded as 1;
[0380] When the coefficient absolute value is greater than 1 flag gt1 is 0, skip encoding the modulo result flag and the residual value flag of the coefficient. When the coefficient absolute value is greater than 1 flag gt1 is 1, encode the modulo result flag of the coefficient; when the coefficient absolute value modulo 4 result is 0, encode the modulo result flag rem_flag as 00B; when the coefficient absolute value modulo 4 result is 1, encode the modulo result flag rem_flag as 01B, when the coefficient absolute value modulo 4 result is 2, encode the modulo result flag rem_flag as 10B, and when the coefficient absolute value modulo 4 result is 3, encode the modulo result flag rem_flag as 11B;
[0381] Encode the remaining value flag;
[0382] The remaining value mark rem can be calculated according to the above formula 4 and table 4.
[0383] When the non-zero flag sig is 1, the sign flag coeff_sign 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.
[0384] In an 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 codeword generated by entropy coding into the bitstream.
[0386] based on Fig.21 The encoding method shown in Table 4 and the corresponding relationship shown in Table 4, this exemplary embodiment provides a coefficient entropy decoding method, such as Fig.23 As shown, the method includes:
[0387] Step 2301, obtain a bitstream, parse the current coding unit, and determine the position of the coefficient according to the scanning method used in encoding;
[0388] In an exemplary embodiment, the scanning mode may be diagonal scanning, zigzag scanning, zigzag scanning, horizontal scanning, vertical scanning, 4x4 sub-block scanning or any other sequential scanning. For example, in this exemplary embodiment, vertical scanning is used during encoding and vertical scanning is also used during decoding.
[0389] Step 2302, performing entropy decoding on the coefficients according to positions to obtain syntax elements of the coefficients;
[0390] In an exemplary embodiment, the first coefficient of all coefficients may be entropy decoded in sequence according to position to obtain the syntax element of the coefficient, and then the value of the coefficient may be determined according to the syntax element of the coefficient, and then the entropy decoding of the next coefficient may be performed.
[0391] In an exemplary embodiment, entropy decoding the coefficients according to positions to obtain syntax elements of the coefficients is implemented in the following manner:
[0392] Decode the non-zero flag. When the non-zero flag is decoded to 0, skip decoding the coefficient absolute value greater than 1 flag, the modulo result flag, the residual value flag, and the sign flag;
[0393] When the non-zero flag is decoded as 1, the coefficient absolute value is greater than 1 flag is decoded. When the coefficient absolute value 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, the flag is decoded as 1, and the decoding of the modulo result flag and the residual value flag continues;
[0395] When the non-zero flag is decoded as 1, the sign flag is decoded.
[0396] Step 2303: Determine the value of the coefficient according to the syntax element of the coefficient.
[0397] In this exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is achieved in the following manner:
[0398] 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, the preset corresponding value, and the residual value flag are multiplied by 4, and the sum is taken 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;
[0399] Among them, when any syntax element among 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, and the residual value flag does not exist, the decoded value of the non-existent syntax element or the pre-set corresponding numerical value is taken as 0.
[0400] In the present exemplary embodiment, the absolute value of the coefficient is calculated by the above-mentioned Formula 4.
[0401] In another exemplary embodiment, determining the value of the coefficient according to the syntax element of the coefficient is implemented by any one of the following methods:
[0402] When the non-zero flag is decoded to 0, determining the value of the coefficient to be 0;
[0403] When the non-zero flag is decoded as 1 and the coefficient absolute value 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 coefficient absolute value greater than 1 flag is decoded as 1, the absolute value of the coefficient is calculated according to the above formula 4 and Table 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.
[0405] In an example, when the decoding result of the coefficient is: sig=1, gt1=1, rem_flag=10B, rem=1, and coeff_sign=1, the coefficient is -8.
[0406] Above Fig.21 The encoding method and corresponding relationship shown in Table 4 are an exemplary description. Other encoding methods and corresponding relationships may also be used. For example, two binary digits include four binary codes, which are used as the encoding values of the four modulo result flags rem_flag of the coefficient absolute value modulo 4 with remainder 0, remainder 1, remainder 2, and remainder 3. The corresponding relationship 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 the disclosed embodiment is described in detail by taking the modulus as 4 as an example. The difference between this exemplary embodiment and the previous exemplary embodiment is that the value of each flag satisfies Formula 5: |q k |=sig+gt1+rem_flag+4×rem.
[0408] The present disclosure provides a coefficient decoding method, such as Fig.24 As shown, including:
[0409] Step 2401, parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded;
[0410] Step 2402, determining the value of the coefficient to be decoded according to the syntax element obtained by decoding;
[0411] Among them, 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 numerical values of the coding value of the non-zero flag, the coding value of the absolute value greater than 1 flag and the coding value of the modulo result flag, plus the product of the coding value of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positivity; the coding value of the modulo result flag is determined according to the modulo operation of the coefficient on N, N = 2, 3, 4 or 5.
[0412] In an exemplary embodiment, N=3;
[0413] When the modulo result flag is decoded to 11B, the preset corresponding value is 0;
[0414] When the modulo result flag is decoded to 00B, the preset corresponding value is 1;
[0415] When the modulo result flag is decoded to 01B, the preset corresponding value is 2;
[0416] When the modulo result flag is decoded to 10B, the preset corresponding value is 3.
[0417] In an exemplary embodiment, N=4;
[0418] When the modulo result flag is decoded to 00B, the preset corresponding value is 0;
[0419] When the modulo result flag is decoded to 01B, the preset corresponding value is 1;
[0420] When the modulo result flag is decoded to 10B, the preset corresponding value is 2;
[0421] When the modulo result flag is decoded to 11B, the preset corresponding value is 3. The present disclosure provides a coefficient encoding method, such as Fig.25 As shown, including:
[0422] Step 2501, generating a coefficient block based on the residual block, scanning coefficients in the coefficient block, and encoding syntax elements of the coefficients to be encoded;
[0423] Step 2502, writing the codeword generated by encoding into the code stream;
[0424] Among them, 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 numerical values of the coding value of the non-zero flag, the coding value of the absolute value greater than 1 flag and the coding value of the modulo result flag, plus the product of the coding value of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positivity; the coding value of the modulo result flag is determined according to the modulo operation of the coefficient on N, N = 2, 3, 4 or 5.
[0425] In an exemplary embodiment, N=3;
[0426] When the absolute value of the coefficient is 2, the modulo result flag is encoded as 11B.
[0427] The modulo result flag of the coefficient whose absolute value modulo 3 is 0 is encoded as 00B;
[0428] The modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 1 is encoded as 01B;
[0429] The modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 2 is encoded as 10B;
[0430] When the modulo result flag code is 11B, the preset corresponding value is 0;
[0431] When the modulo 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 modulo result flag is encoded as 10B, the preset corresponding value is 3.
[0434] In an exemplary embodiment, N=3;
[0435] When the absolute value of the coefficient is 3, the modulo result flag is encoded as 00B.
[0436] The modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 0 is encoded as 11B;
[0437] The modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 1 is encoded as 01B;
[0438] The modulo result flag of the coefficient whose absolute value modulo 3 has a remainder of 2 is encoded as 10B;
[0439] When the modulo result flag is decoded to 00B, the preset corresponding value is 0;
[0440] When the modulo result flag is decoded to 01B, the preset corresponding value is 1;
[0441] When the modulo result flag is decoded to 10B, the preset corresponding value is 2;
[0442] When the modulo result flag is decoded to 11B, the preset corresponding value is 3.
[0443] The present disclosure provides a coefficient decoding method, such as Fig.26 As shown, including:
[0444] Step 2601, parsing the acquired bitstream and decoding the syntax elements of the coefficients to be decoded;
[0445] Step 2602, determining the value of the coefficient to be decoded according to the syntax element obtained by decoding;
[0446] Among them, 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 numerical values of the coding value of the non-zero flag, the coding value of the absolute value greater than 1 flag, the coding value of the absolute value greater than 2 flag and the coding value of the modulo result flag, and the product of the coding value of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positivity; the coding value of the modulo result flag is determined according to the modulo operation of the coefficient on N, N = 2, 3, 4 or 5.
[0447] In an exemplary embodiment, N=4;
[0448] The modulo result flag of the coefficient whose absolute value modulo 4 is 0 is encoded as 10B;
[0449] The modulo result flag of the coefficient whose absolute value modulo 4 is 1 is encoded as 11B;
[0450] The modulo result flag of the coefficient whose absolute value modulo 4 has a remainder of 2 is encoded as 00B;
[0451] The modulo result flag of the coefficient whose absolute value modulo 4 has a remainder of 3 is encoded as 01B;
[0452] When the modulo result flag is decoded to 00B, the preset corresponding value is 0;
[0453] When the modulo result flag is decoded to 01B, the preset corresponding value is 1;
[0454] When the modulo result flag is decoded to 10B, the preset corresponding value is 2;
[0455] When the modulo result flag is decoded to 11B, the preset corresponding value is 3.
[0456] The present disclosure provides a coefficient encoding method, such as Fig. 27 As shown, including:
[0457] Step 2701, generating a coefficient block based on the residual block, scanning coefficients in the coefficient block, and encoding syntax elements of the coefficients to be encoded;
[0458] Step 2702, writing the codeword generated by encoding into the code stream;
[0459] Among them, 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 numerical values of the coding value of the non-zero flag, the coding value of the absolute value greater than 1 flag, the coding value of the absolute value greater than 2 flag and the coding value of the modulo result flag, and the product of the coding value of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positivity; the coding value of the modulo result flag is determined according to the modulo operation of the coefficient on N, N = 2, 3, 4 or 5.
[0460] In an exemplary embodiment, N=4;
[0461] The coefficient modulo result flag of the coefficient absolute value modulo 4 with a remainder of 0 is encoded as 10B, the coefficient modulo result flag of the coefficient absolute value modulo 4 with a remainder of 1 is encoded as 11B, the coefficient modulo result flag of the coefficient absolute value modulo 4 with a remainder of 2 is encoded as 00B, and the coefficient modulo result flag of the coefficient absolute value modulo 4 with a remainder of 3 is encoded as 01B;
[0462] When the modulo result flag is decoded to 00B, the preset corresponding value is 0;
[0463] When the modulo result flag is decoded to 01B, the preset corresponding value is 1;
[0464] When the modulo result flag is decoded to 10B, the preset corresponding value is 2;
[0465] When the modulo result flag is decoded to 11B, the preset corresponding value is 3.
[0466] In an exemplary embodiment, in the process of encoding the syntax elements of the coefficients, any one or more of the following methods are used for encoding: context-based adaptive variable-length coding CAVLC (context-based adaptive variable-length code), context-based adaptive binary arithmetic coding (context-based adaptive binary arithmetic coding), syntax-based adaptive binary arithmetic coding (syntax-basedadaptive binary arithmetic coding), probability interval partitioning entropy (PIPE), bypass coding or other entropy coding methods.
[0467] In one example, in the process of encoding the syntax elements of the coefficients, the residual value flag rem and the sign flag coeff_sign can be encoded using a bypass coding method, and 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 coding method.
[0468] In one example, in the process of encoding the syntax elements of the coefficients, the residual value flag rem and the sign flag coeff_sign can be encoded using a bypass coding method, and the non-zero flag sig, the coefficient absolute value greater than 1 flag gt1, the coefficient absolute value greater than 1 flag gt1, and the modulo result flag rem_flag can be encoded using a context-based adaptive coding method.
[0469] The technical solution provided by the above-mentioned embodiments of the present disclosure improves the original coefficient entropy coding method, can better utilize the characteristics of adaptive coding, effectively save bit rate, and improve coding performance.
[0470] The present disclosure also provides a coding device, such as Fig.28 As shown, it includes: a processor and a memory storing a computer program that can be run on the processor, wherein the processor implements any of the coefficient entropy coding methods described above when executing the computer program. The coding device can be a video encoder or a video codec of any structure.
[0471] In an exemplary embodiment, Fig.29 is a structural block diagram of a video encoder, such as Fig.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 volume 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 the description is omitted for ease of explanation, the description is omitted for ease of explanation. Fig.29 4, but it should be understood that MEU 42, MCU 44, intra-prediction processing unit 46, and IBC unit 48 may actually be highly integrated. For video block reconstruction, video encoder 20 also includes inverse quantization unit 58, inverse transform processing unit 60, summer 62, filter unit 64, and decoded picture buffer (DPB) 66.
[0472] In an embodiment of the present disclosure, the coefficient decoding method described in any of the above embodiments may be executed by a video decoder.
[0473] The present disclosure also provides a decoding device, such as Fig.30 As shown, it includes: a processor and a memory storing a computer program that can be run on the processor, wherein the processor implements any of the coefficient entropy decoding methods described above when executing the computer program. The encoding device can be a video decoder or a video codec of any structure.
[0474] In an exemplary embodiment, Fig.31 A structural block diagram of a video decoder is shown in FIG. Fig.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 filter 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 examples, the video decoder 30 may perform operations related to the video data from the video decoder 30. Fig.30 The encoding process described for video encoder 20 is generally the inverse of the decoding process.
[0475] An embodiment of the present disclosure also provides a non-transitory computer-readable storage medium, which stores a computer program, wherein the computer program, when executed by a processor, implements any of the above-mentioned coefficient entropy encoding methods, or implements any of the above-mentioned coefficient entropy decoding methods.
[0476] The decoding described in the embodiments of the present disclosure may be interpreted as including a decoding operation, or as including an encoding operation and a decoding operation. The encoding described in the embodiments of the present disclosure may be interpreted as including an encoding operation, or as including an encoding operation and a decoding operation.
[0477] The decoded value recorded in the embodiments of the present disclosure may also be referred to as the encoded value, and the encoded value may also be referred to as the decoded value, which are the same.
[0478] In one or more exemplary embodiments, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted via a computer-readable medium as one or more instructions or codes, and executed by a hardware-based processing unit. A computer-readable medium may include a computer-readable storage medium corresponding to a tangible medium such as a data storage medium, or a communication medium that facilitates the computer program to be transmitted from one place to another, such as according to a communication protocol. In this way, a computer-readable medium may generally correspond to a non-temporary tangible computer-readable storage medium or a communication medium such as a signal or carrier wave. A data storage medium may be any available medium that can be accessed by one or more computers or one or more processors to retrieve instructions, codes, and / or data structures for implementing the techniques described in the present invention. A computer program product may include a computer-readable medium.
[0479] By way of example and not limitation, such computer-readable storage media may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage, flash memory, or any other medium that can be used to store the desired program code in the form of instructions or data structures and can be accessed by a computer. Moreover, 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 (transient) media, but are directed to non-transient tangible storage media. As used herein, disks and optical disks include compact disks (CDs), laser disks, optical disks, digital versatile disks (DVDs), floppy disks, or Blu-ray disks, etc., where disks typically reproduce data magnetically, while optical disks use lasers to reproduce data optically. Combinations of the above should also be included within the scope of computer-readable media.
[0480] Instructions may 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. Thus, the term "processor" as used herein may refer to any of the above structures or any other structures suitable for implementing the techniques described herein. Additionally, in some aspects, the functionality described herein may be provided within dedicated hardware and / or software modules configured for encoding and decoding, or incorporated in a combined codec. Also, the techniques may be fully implemented in one or more circuits or logic elements.
[0481] The technical solutions of the embodiments of the present disclosure can be implemented in a wide variety of devices or equipment, including wireless mobile phones, integrated circuits (ICs) or a group of ICs (e.g., chipsets). Various components, modules or units are described in the embodiments of the present disclosure to emphasize the functional aspects of the devices configured to perform the described techniques, but they do not necessarily need to be implemented by different hardware units. Instead, as described above, the various units can be combined in a codec hardware unit or provided by a collection of interoperable hardware units (including one or more processors as described above) in combination with suitable software and / or firmware.
[0482] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description 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 by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium 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 technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
Claims
1. A coefficient decoding method, comprising: Parse the acquired bitstream and decode the syntax elements of the coefficients to be decoded; Determine the value of the coefficient to be decoded according to the syntax element obtained by decoding; The syntax elements include: a non-zero flag, M absolute values greater than X i flag, modulo result flag, residual value flag and sign flag; the absolute value of the coefficient to be decoded is the coded value of the non-zero flag, M absolute values greater than X i The sum of the code value of the flag and the code value of the modulo result flag, plus the product of the code value of the residual value flag and N, is obtained; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign indicating the positive or negative sign; the code value of the modulo result flag is determined according to the modulo operation of the coefficient on N, i≥M, i, M are positive integers, N is a positive integer greater than 1, X i is a positive integer and when i takes different values, X 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 to 0, skip decoding of M coefficients whose absolute values are greater than the i flag, the modulo result flag, the residual value flag, and the sign flag; When the non-zero flag is decoded as 1, decode M absolute values greater than Xi flags. When the g-th absolute value greater than Xi flag is decoded as 0, skip the decoding of subsequent Mg absolute values greater than Xi flags, modulo result flags, and residual value flags; 1≤g≤M; When the absolute values of M coefficients are greater than i and the flags are all 1, the modulo result flag is decoded; When the encoded value of the modulo result flag is decoded to the specific encoded value, the decoding of the remaining value flag is skipped; When the modulo result flag is not decoded to the specific encoding value, decoding the remaining value flag; When the non-zero flag decodes to 1, the sign 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 to 0, skip decoding of M coefficients whose absolute values are greater than the i flag, the modulo result flag, the residual value flag, and the sign flag; When the non-zero flag is decoded as 1, decode M absolute values 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 values greater than Xi flags, modulo result flags, and residual value flags. 1≤g≤M, when i has different values, X i The values are different and increase with the value of i; When the M absolute values are greater than Xi and the flags are all 1, the modulo result flag and the residual value flag are decoded in sequence; When the non-zero flag decodes to 1, the sign flag is decoded.
4. The coefficient decoding method according to claim 2 or 3, further comprising: Absolute value of coefficient = decoded value of non-zero flag + decoded values corresponding to M absolute values greater than Xi flags + decoded value of modulo result flag corresponding value set in advance + residual value flag × N; Among them, when any syntax element among the decoded value of the non-zero flag, the decoded values corresponding to the M absolute values greater than the Xi flag, the decoded value of the modulo result flag, and the residual value flag does not exist, the decoded value of the non-existent syntax element or the pre-set corresponding numerical value is taken as 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 pre-set 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 coding value pre-set for 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 to 11B, the preset corresponding value is 0; When the modulo result flag is decoded to 00B, the preset corresponding value is 1; When the modulo result flag is decoded to 01B, the preset corresponding value is 2; When the modulo result flag is decoded to 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 to 00B, the preset corresponding value is 0; When the modulo result flag is decoded to 01B, the preset corresponding value is 1; When the modulo result flag is decoded to 10B, the preset corresponding value is 2; When the modulo result flag is decoded to 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 to 00B, the preset corresponding value is 0; When the modulo result flag is decoded to 01B, the preset corresponding value is 1; When the modulo result flag is decoded to 10B, the preset corresponding value is 2; When the modulo result flag is decoded to 11B, the preset corresponding value is 3.
10. A coefficient encoding method, comprising: Generate a coefficient block based on the residual block, scan coefficients in the coefficient block, and encode syntax elements of the coefficients to be encoded; Write the codeword generated by encoding into the code stream; The syntax elements include: a non-zero flag, M absolute values greater than X i flag, modulo result flag, residual value flag and sign flag; the absolute value of the coefficient to be decoded is the coded value of the non-zero flag, M absolute values greater than X i The sum of the code value of the flag and the code value of the modulo result flag, plus the product of the code value of the residual value flag and N, is obtained; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign indicating the positive or negative sign; the code value of the modulo result flag is determined according to the modulo operation of the coefficient on N, i≥M, i, M are positive integers, N is a positive integer greater than 1, X i is a positive integer and when i takes different values, X 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; Determine the value of the coefficient to be decoded according to the syntax element obtained by decoding; Among them, 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 numerical values of the coding value of the non-zero flag, the coding value of the absolute value greater than 1 flag and the coding value of the modulo result flag, and the product of the coding value of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positivity; the coding value of the modulo result flag is determined according to the modulo operation of the coefficient on N, N = 2, 3, 4 or 5.
12. A coefficient encoding method, comprising: Generate a coefficient block based on the residual block, scan coefficients in the coefficient block, and encode syntax elements of the coefficients to be encoded; Write the codeword generated by encoding into the code stream; Among them, 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 numerical values of the coding value of the non-zero flag, the coding value of the absolute value greater than 1 flag and the coding value of the modulo result flag, and the product of the coding value of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positivity; the coding value of the modulo result flag is determined according to the modulo operation of the coefficient on N, 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; Determine the value of the coefficient to be decoded according to the syntax element obtained by decoding; Among them, 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 numerical values of the coding value of the non-zero flag, the coding value of the absolute value greater than 1 flag, the coding value of the absolute value greater than 2 flag and the coding value of the modulo result flag, and the product of the coding value of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positivity; the coding value of the modulo result flag is determined according to the modulo operation of the coefficient on N, N = 2, 3, 4 or 5.
14. A coefficient encoding method, comprising: Generate a coefficient block based on the residual block, scan coefficients in the coefficient block, and encode syntax elements of the coefficients to be encoded; Write the codeword generated by encoding into the code stream; Among them, 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 numerical values of the coding value of the non-zero flag, the coding value of the absolute value greater than 1 flag, the coding value of the absolute value greater than 2 flag and the coding value of the modulo result flag, and the product of the coding value of the residual value flag and N, to obtain the sum; the value of the coefficient to be decoded is a value determined according to the absolute value of the coefficient to be decoded and the sign flag indicating the positivity; the coding value of the modulo result flag is determined according to the modulo operation of the coefficient on N, N = 2, 3, 4 or 5.
15. A non-transitory computer-readable storage medium storing a computer program, wherein: When the computer program is executed by a processor, it implements the coefficient decoding method according to any one of claims 1 to 9, or claim 11, or claim 13, or implements the coefficient encoding method according to any one of claim 10, or claim 12, or claim 14.
Citation Information
Patent Citations
Image decoding method and image decoding device
CN107809645A
Decoding method, encoding method and device
CN110708552A
Rice parameter update for coefficient level coding in video coding process
US20140307800A1