Encoding method, decoding method, device, electronic equipment and readable storage medium

By introducing an index related to the coefficient sequence in video coding, the sign hiding of non-zero coefficients within CG blocks is optimized, solving the problem of degraded video coding performance and achieving more efficient coding.

CN116074504BActive Publication Date: 2026-03-31BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-28
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

In existing video coding methods, as the video size increases, the amount of encoded data increases significantly, leading to a decline in coding performance. Traditional coding methods have failed to effectively optimize coefficient coding. In particular, the symbol hiding algorithm within CG blocks can only hide the symbol of the first non-zero coefficient in each CG block, and the coding performance needs to be improved.

Method used

By introducing an index related to the absolute value of the coefficient sequence, a predefined relationship is established between this index and the sign of the first two non-zero coefficients in the coefficient sequence, thus hiding the sign of the first two non-zero coefficients and optimizing the coefficient encoding process.

Benefits of technology

It effectively reduces redundancy between coefficients, improves coding performance, and enhances coding efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116074504B_ABST
    Figure CN116074504B_ABST
Patent Text Reader

Abstract

The present disclosure relates to an encoding method, a decoding method, a device, an electronic device and a readable storage medium. The encoding method comprises: obtaining a first coefficient sequence of a to-be-encoded CG block, wherein the first coefficient sequence comprises a first absolute value and a first sign value of each coefficient in the to-be-encoded CG block; determining a first index of the first coefficient sequence and a first sign value of a first N non-zero coefficients, wherein the first index is a value obtained by performing a preset processing on each first absolute value, and N is an integer greater than 1; determining a second absolute value and a second sign value of each coefficient in the first coefficient sequence based on a comparison between the first index and the first sign value of the first N non-zero coefficients and a preset sign index table, to obtain a second coefficient sequence; and encoding the second coefficient sequence to obtain encoding information of the to-be-encoded CG block, wherein the second sign value of the first N non-zero coefficients in the second coefficient sequence is not encoded. The method can improve the encoding performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of video transmission technology, and in particular to an encoding method, a decoding method, an apparatus, an electronic device, and a readable storage medium. Background Technology

[0002] In video encoding and decoding algorithms, the coefficients of the quantized TU (Transform Unit) block need to be written into the bitstream. Considering the efficiency of coefficient encoding, in most current encoding standards, writing coefficients into the bitstream typically involves two steps: first, dividing the TU block into multiple 4x4 CG (Coefficient Coding Group) blocks; second, encoding the coefficients within each CG block individually. The encoding of coefficients within each CG block also involves two steps: first, writing the absolute value of the coefficient into the bitstream; second, writing the sign of the coefficient into the bitstream.

[0003] As video file sizes increase significantly during transmission, the amount of data requiring encoding also increases dramatically, weakening encoding performance. Therefore, improving video encoding performance is urgently needed. Summary of the Invention

[0004] This disclosure provides an encoding method, a decoding method, an apparatus, an electronic device, and a readable storage medium to at least solve the problem of how to improve encoding performance in the related art, or it may not solve any of the above problems.

[0005] According to a first aspect of this disclosure, an encoding method is provided, comprising: obtaining a first coefficient sequence of a CG block to be encoded, wherein the first coefficient sequence includes a first absolute value and a first sign value of each coefficient in the CG block to be encoded; determining a first index and the first sign values ​​of the first N non-zero coefficients of the first coefficient sequence, wherein the first index is a value obtained by pre-processing each of the first absolute values, and N is an integer greater than 1; determining a second absolute value and a second sign value of each coefficient in the first coefficient sequence based on a comparison between the first index and the first sign values ​​of the first N non-zero coefficients and a preset sign index table, thereby obtaining a second coefficient sequence, wherein the preset sign index table indicates an expected correspondence between the first sign values ​​of the first N non-zero coefficients in the first coefficient sequence and the first index; and encoding the second coefficient sequence to obtain encoding information of the CG block to be encoded, wherein the second sign values ​​of the first N non-zero coefficients of the second coefficient sequence are not encoded.

[0006] Optionally, the step of determining the final second absolute value and second sign value of each coefficient in the first coefficient sequence based on the comparison between the first index and the first sign value of the first N non-zero coefficients and a preset sign index table to obtain the second coefficient sequence includes: if the first index and the first sign value of the first N non-zero coefficients are consistent with the preset sign index table, using the first coefficient sequence as the second coefficient sequence; if the first index and the first sign value of the first N non-zero coefficients are inconsistent with the preset sign index table, adjusting the value of at least one coefficient in the first coefficient sequence to obtain the second coefficient sequence.

[0007] Optionally, the preset symbol index table is established through the following steps: determining each possible combination of the first symbol values ​​of the first N non-zero coefficients in the first coefficient sequence as symbol combinations to be counted, and determining each possible value of the first index as an index to be counted; acquiring multiple historical CG blocks, and for each historical CG block, acquiring the historical coefficient sequence and historical index of the historical CG block to obtain multiple historical coefficient sequences and multiple historical indexes, wherein each historical coefficient sequence includes the absolute value and symbol value of each coefficient in the historical CG block, and each historical index is the value obtained after performing the preset processing on the absolute value of each coefficient in the historical coefficient sequence; based on the multiple historical coefficient sequences, calculating the probability of occurrence of each symbol combination to be counted as the symbol combination probability; based on the multiple historical indexes, calculating the probability of occurrence of each index to be counted as the index probability; and determining the correspondence between each symbol combination to be counted and each index to be counted according to the symbol combination probability and the index probability to obtain the preset symbol index table.

[0008] Optionally, the preset processing is a process of summing and then transforming, wherein adjusting the value of at least one coefficient in the first coefficient sequence to obtain the second coefficient sequence includes: searching the preset sign index table using the first sign values ​​of the first N non-zero coefficients of the first coefficient sequence to determine a second index; determining the target adjustment amount of the sum of each first absolute value based on the difference between the first index and the second index; and adjusting the first absolute value of at least one coefficient in the first coefficient sequence according to the target adjustment amount, while keeping the sign values ​​of the first N non-zero coefficients unchanged, to obtain the second coefficient sequence.

[0009] Optionally, determining the target adjustment amount of the sum of each of the first absolute values ​​based on the difference between the first index and the second index includes: determining the adjustment amount with the smallest adjustment range of the sum of each of the first absolute values ​​based on the difference between the first index and the second index, in conjunction with the preset processing, as the target adjustment amount.

[0010] Optionally, the step of adjusting the first absolute value of at least one coefficient in the first coefficient sequence according to the target adjustment amount, while keeping the sign values ​​of the first N non-zero coefficients unchanged, to obtain the second coefficient sequence, includes: recording the portion of the first coefficient sequence from the first non-zero coefficient to the last non-zero coefficient as the sequence segment to be adjusted, and adjusting the first absolute value of at least one coefficient in the sequence segment to be adjusted according to the target adjustment amount, while keeping the sign values ​​of the first N non-zero coefficients unchanged, to obtain the second coefficient sequence.

[0011] Optionally, the step of adjusting the first absolute value of at least one coefficient in the sequence segment to be adjusted according to the target adjustment amount, while keeping the sign values ​​of the first N non-zero coefficients unchanged, to obtain the second coefficient sequence includes: determining at least one adjustment scheme and corresponding rate-distortion cost of the sequence segment to be adjusted according to the target adjustment amount, while keeping the sign values ​​of the first N non-zero coefficients unchanged; determining an adjustment scheme from the at least one adjustment scheme according to the rate-distortion cost corresponding to each adjustment scheme; and adjusting the sequence segment to be adjusted accordingly using the determined adjustment scheme to obtain the second coefficient sequence.

[0012] Optionally, the at least one adjustment scheme satisfies the following: when adjusting the first absolute value of at least one coefficient among the first N non-zero coefficients without adjusting the zero coefficients before the Nth non-zero coefficient, the second sign value of the adjusted coefficient is kept equal to the first sign value, and the adjusted coefficient remains unchanged at 0; when adjusting other non-zero coefficients in the sequence segment to be adjusted other than the first N non-zero coefficients, the second sign value of the adjusted coefficient is kept equal to the first sign value or the adjusted coefficient is adjusted to 0; when the target adjustment amount is negative, the non-zero coefficients in the sequence segment to be adjusted are adjusted.

[0013] Optionally, N is 2, and determining at least one adjustment scheme and corresponding rate distortion cost of the sequence segment to be adjusted according to the target adjustment amount includes: when the target adjustment amount is 2 or -2, determining a first rate distortion cost after adding 2 to the first absolute value of each of at least one coefficient in the sequence segment to be adjusted, a second rate distortion cost after adding 1 to the first absolute value of each of at least two coefficients in the sequence segment to be adjusted, a third rate distortion cost after subtracting 2 from the first absolute value of each coefficient in the sequence segment to be adjusted whose first absolute value is greater than or equal to 2, and a fourth rate distortion cost after subtracting 1 from the first absolute value of each of at least two non-zero coefficients in the sequence segment to be adjusted; determining a first rate distortion cost from at least one first rate distortion cost as a first candidate rate distortion cost, and then... The first adjustment scheme is to add 2 to the first absolute value of the coefficient corresponding to the first candidate rate distortion cost; the second adjustment scheme is to determine the sum of two second rate distortion costs from at least two second rate distortion costs, and add 1 to the first absolute value of the two coefficients corresponding to the second candidate rate distortion cost; the third adjustment scheme is to determine a third rate distortion cost from at least one third rate distortion cost, and subtract 2 from the first absolute value of the coefficient corresponding to the third candidate rate distortion cost; the fourth adjustment scheme is to determine the sum of two fourth rate distortion costs from at least two fourth rate distortion costs, and subtract 1 from the first absolute value of the two coefficients corresponding to the fourth candidate rate distortion cost.

[0014] Optionally, N is 2. The step of determining at least one adjustment scheme and corresponding rate-distortion cost for the sequence segment to be adjusted based on the target adjustment amount, while keeping the sign values ​​of the first N non-zero coefficients unchanged, includes: when the target adjustment amount is 1, adjusting each coefficient between the first two non-zero coefficients in the first coefficient sequence by 1 in the direction consistent with the first sign value of the second non-zero coefficient; adjusting the non-zero coefficients in the sequence segment to be adjusted by 1 in the direction consistent with their own first sign value; adding 1 and / or subtracting 1 from the other coefficients in the sequence segment to be adjusted to obtain the at least one adjustment scheme, and determining the rate-distortion cost corresponding to the at least one adjustment scheme; when the target adjustment amount is -1, adjusting the non-zero coefficients in the sequence segment to be adjusted by 1 in the direction opposite to their own first sign value to obtain the at least one adjustment scheme, and determining the rate-distortion cost corresponding to the at least one adjustment scheme.

[0015] Optionally, determining the first index of the first coefficient sequence and the first sign value of the first N non-zero coefficients includes: determining the first index of the first coefficient sequence and the first sign value of the first N non-zero coefficients when the first coefficient sequence satisfies a preset condition, wherein the preset condition includes at least one of the following: the number of non-zero coefficients in the first coefficient sequence is greater than or equal to a first preset number, and the number of coefficients between the first non-zero coefficient and the last non-zero coefficient in the first coefficient sequence is greater than or equal to a second preset number.

[0016] According to a second aspect of this disclosure, a decoding method is provided, comprising: parsing the encoded information of a target CG block to obtain a target coefficient sequence, wherein the target coefficient sequence includes the absolute value of each coefficient in the target CG block and the sign values ​​of the coefficients other than the first N non-zero coefficients, where N is an integer greater than 1; determining a reference index of the target coefficient sequence, wherein the reference index is a value obtained by performing a preset processing on the absolute value of each coefficient in the target coefficient sequence; and searching a preset sign index table through the reference index to determine the sign values ​​of the first N non-zero coefficients in the target coefficient sequence, wherein the preset sign index table indicates the expected correspondence between the sign values ​​of the first N non-zero coefficients in the coefficient sequence of the CG block and the sign index, where the sign index is a value obtained by performing the preset processing on the absolute value of each coefficient in the coefficient sequence.

[0017] Optionally, the encoding information of the target CG block is obtained by encoding using the encoding method of this disclosure.

[0018] According to a third aspect of this disclosure, an encoding apparatus is provided, comprising: an acquisition unit configured to acquire a first coefficient sequence of a CG block to be encoded, wherein the first coefficient sequence includes a first absolute value and a first sign value of each coefficient in the CG block to be encoded; a determination unit configured to determine a first index and first sign values ​​of the first N non-zero coefficients of the first coefficient sequence, wherein the first index is a value obtained by pre-processing each of the first absolute values, and N is an integer greater than 1; the determination unit is further configured to perform a comparison based on the first index and the first sign values ​​of the first N non-zero coefficients with a preset sign index table to determine a second absolute value and a second sign value of each coefficient in the first coefficient sequence, thereby obtaining a second coefficient sequence, wherein the preset sign index table indicates an expected correspondence between the first sign values ​​of the first N non-zero coefficients in the first coefficient sequence and the first index; and an encoding unit configured to encode the second coefficient sequence to obtain encoding information of the CG block to be encoded, wherein the second sign values ​​of the first N non-zero coefficients of the second coefficient sequence are not encoded.

[0019] Optionally, the determining unit is further configured to perform the following actions: if the first symbol value of the first index and the first N non-zero coefficients is consistent with the preset symbol index table, the first coefficient sequence is used as the second coefficient sequence; if the first symbol value of the first index and the first N non-zero coefficients is inconsistent with the preset symbol index table, the value of at least one coefficient in the first coefficient sequence is adjusted to obtain the second coefficient sequence.

[0020] Optionally, the preset symbol index table is established through the following steps: determining each possible combination of the first symbol values ​​of the first N non-zero coefficients in the first coefficient sequence as symbol combinations to be counted, and determining each possible value of the first index as an index to be counted; acquiring multiple historical CG blocks, and for each historical CG block, acquiring the historical coefficient sequence and historical index of the historical CG block to obtain multiple historical coefficient sequences and multiple historical indexes, wherein each historical coefficient sequence includes the absolute value and symbol value of each coefficient in the historical CG block, and each historical index is the value obtained after performing the preset processing on the absolute value of each coefficient in the historical coefficient sequence; based on the multiple historical coefficient sequences, calculating the probability of occurrence of each symbol combination to be counted as the symbol combination probability; based on the multiple historical indexes, calculating the probability of occurrence of each index to be counted as the index probability; and determining the correspondence between each symbol combination to be counted and each index to be counted according to the symbol combination probability and the index probability to obtain the preset symbol index table.

[0021] Optionally, the preset processing is a process of summing and then transforming. The determining unit is further configured to perform the following: using the first sign value of the first N non-zero coefficients of the first coefficient sequence, searching the preset sign index table to determine the second index; determining the target adjustment amount of the sum of each first absolute value based on the difference between the first index and the second index; and adjusting the first absolute value of at least one coefficient in the first coefficient sequence according to the target adjustment amount, while keeping the sign value of the first N non-zero coefficients unchanged, to obtain the second coefficient sequence.

[0022] Optionally, the determining unit is further configured to perform an adjustment amount that minimizes the adjustment range of the sum of the first absolute values ​​based on the difference between the first index and the second index, in conjunction with the preset processing, as the target adjustment amount.

[0023] Optionally, the determining unit is further configured to perform the following: a portion of the first coefficient sequence from the first non-zero coefficient to the last non-zero coefficient is designated as the sequence segment to be adjusted, with the sign values ​​of the first N non-zero coefficients remaining unchanged; and the first absolute value of at least one coefficient in the sequence segment to be adjusted is adjusted according to the target adjustment amount to obtain the second coefficient sequence.

[0024] Optionally, the determining unit is further configured to perform, on the premise of keeping the sign values ​​of the first N non-zero coefficients unchanged, determine at least one adjustment scheme and corresponding rate-distortion cost of the sequence segment to be adjusted according to the target adjustment amount; determine an adjustment scheme from the at least one adjustment scheme according to the rate-distortion cost corresponding to each adjustment scheme, and adjust the sequence segment to be adjusted accordingly using the determined adjustment scheme to obtain the second coefficient sequence.

[0025] Optionally, the at least one adjustment scheme satisfies the following: when adjusting the first absolute value of at least one coefficient among the first N non-zero coefficients without adjusting the zero coefficients before the Nth non-zero coefficient, the second sign value of the adjusted coefficient is kept equal to the first sign value, and the adjusted coefficient remains unchanged at 0; when adjusting other non-zero coefficients in the sequence segment to be adjusted other than the first N non-zero coefficients, the second sign value of the adjusted coefficient is kept equal to the first sign value or the adjusted coefficient is adjusted to 0; when the target adjustment amount is negative, the non-zero coefficients in the sequence segment to be adjusted are adjusted.

[0026] Optionally, N is 2, and the determining unit is further configured to, when the target adjustment amount is 2 or -2, determine the following: a first rate-distortion cost (adding 2 to the first absolute value of each of at least one coefficient in the sequence segment to be adjusted); a second rate-distortion cost (adding 1 to the first absolute value of each of at least two coefficients in the sequence segment to be adjusted); a third rate-distortion cost (subtracting 2 from the first absolute value of each coefficient in the sequence segment to be adjusted that has a first absolute value greater than or equal to 2); and a fourth rate-distortion cost (subtracting 1 from the first absolute value of each of at least two coefficients in the sequence segment to be adjusted); determine a first rate-distortion cost from at least one first rate-distortion cost as a first candidate rate-distortion cost; and set the coefficient corresponding to the first candidate rate-distortion cost... The first absolute value is added by 2 to obtain the first adjustment scheme; the sum of two second rate distortion costs is determined from at least two second rate distortion costs as the second candidate rate distortion cost, and the first absolute value of the two coefficients corresponding to the second candidate rate distortion cost is added by 1 to obtain the second adjustment scheme; a third rate distortion cost is determined from at least one third rate distortion cost as the third candidate rate distortion cost, and the first absolute value of the coefficient corresponding to the third candidate rate distortion cost is subtracted by 2 to obtain the third adjustment scheme; the sum of two fourth rate distortion costs is determined from at least two fourth rate distortion costs as the fourth candidate rate distortion cost, and the first absolute value of the two coefficients corresponding to the fourth candidate rate distortion cost is subtracted by 1 to obtain the fourth adjustment scheme.

[0027] Optionally, N is 2, and the determining unit is further configured to perform the following actions when the target adjustment amount is 1: adjusting the coefficients between the first two non-zero coefficients in the first coefficient sequence by 1 in the direction consistent with the first sign value of the second non-zero coefficient; adjusting the non-zero coefficients in the sequence segment to be adjusted by 1 in the direction consistent with their own first sign value; adding 1 and / or subtracting 1 from the other coefficients in the sequence segment to be adjusted, to obtain the at least one adjustment scheme, and determining the rate distortion cost corresponding to the at least one adjustment scheme; and when the target adjustment amount is -1, adjusting the non-zero coefficients in the sequence segment to be adjusted by 1 in the direction opposite to their own first sign value, to obtain the at least one adjustment scheme, and determining the rate distortion cost corresponding to the at least one adjustment scheme.

[0028] Optionally, the determining unit is further configured to determine a first index and a first sign value of the first N non-zero coefficients of the first coefficient sequence when the first coefficient sequence satisfies a preset condition, wherein the preset condition includes at least one of the following: the number of non-zero coefficients in the first coefficient sequence is greater than or equal to a first preset number, and the number of coefficients between the first non-zero coefficient and the last non-zero coefficient in the first coefficient sequence is greater than or equal to a second preset number.

[0029] According to a fourth aspect of this disclosure, a decoding apparatus is provided, comprising: a parsing unit configured to perform parsing of encoded information of a target CG block to obtain a target coefficient sequence, wherein the target coefficient sequence includes the absolute value of each coefficient in the target CG block and the sign values ​​of the coefficients other than the first N non-zero coefficients, where N is an integer greater than 1; a determining unit configured to perform determining a reference index of the target coefficient sequence, wherein the reference index is a value obtained by performing a preset processing on the absolute values ​​of each coefficient in the target coefficient sequence; and a searching unit configured to perform searching a preset sign index table through the reference index to determine the sign values ​​of the first N non-zero coefficients in the target coefficient sequence, wherein the preset sign index table indicates an expected correspondence between the sign values ​​of the first N non-zero coefficients in the coefficient sequence of the CG block and the sign index, and the sign index is a value obtained by performing the preset processing on the absolute values ​​of each coefficient in the coefficient sequence.

[0030] Optionally, the encoding information of the target CG block is obtained by encoding using the encoding method of this disclosure.

[0031] According to a fifth aspect of this disclosure, an electronic device is provided, the electronic device comprising: at least one processor; at least one memory storing computer-executable instructions, wherein the computer-executable instructions, when executed by the at least one processor, cause the at least one processor to perform an encoding method or a decoding method according to this disclosure.

[0032] According to a sixth aspect of this disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by at least one processor, causes the at least one processor to perform an encoding method or a decoding method according to this disclosure.

[0033] According to a seventh aspect of this disclosure, a computer program product is provided, including computer instructions that, when executed by at least one processor, implement an encoding or decoding method according to this disclosure.

[0034] The technical solutions provided by the embodiments of this disclosure bring at least the following beneficial effects:

[0035] The encoding method, decoding method, encoding apparatus, and decoding apparatus according to embodiments of this disclosure break with conventional thinking. Analysis reveals that the signs of the first two non-zero coefficients in the coefficient sequence of a CG block (recorded in the form of a sequence of absolute values ​​and a sequence of sign values ​​of coefficients) are strongly correlated with the absolute values ​​of the coefficient sequence. This correlation indicates that redundancy still exists among the coefficients, and the more non-zero coefficients there are, the higher this redundancy becomes. Based on this, by introducing an index related to the absolute values ​​of the coefficient sequence and establishing a preset relationship between this index and the signs of the first two non-zero coefficients in the coefficient sequence, the signs of the first two non-zero coefficients can be hidden based on this preset relationship, thereby effectively reducing redundancy among coefficients and helping to improve encoding performance.

[0036] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0037] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.

[0038] Figure 1 A block diagram of a block-based video coding system is shown.

[0039] Figure 2 An exemplary block diagram of a block-based video decoding system is shown;

[0040] Figure 3 This is a schematic diagram illustrating the division of TU blocks and the encoding order in related technologies;

[0041] Figure 4 This is a schematic diagram illustrating the encoding order of CG blocks in related technologies;

[0042] Figure 5 This is a flowchart illustrating an encoding method according to an exemplary embodiment of the present disclosure;

[0043] Figure 6 This is a flowchart illustrating a decoding method according to an exemplary embodiment of the present disclosure;

[0044] Figure 7 This is a block diagram illustrating an encoding apparatus according to an exemplary embodiment of the present disclosure;

[0045] Figure 8 This is a block diagram illustrating a decoding apparatus according to an exemplary embodiment of the present disclosure;

[0046] Figure 9 This is a block diagram illustrating an electronic device according to exemplary embodiments of the present disclosure. Detailed Implementation

[0047] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.

[0048] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following examples do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0049] It should be noted that the phrase "at least one of several items" in this disclosure refers to three parallel cases: "any one of the several items", "a combination of any number of the several items", and "all of the several items". For example, "including at least one of A and B" includes the following three parallel cases: (1) including A; (2) including B; (3) including A and B. As another example, "performing at least one of step one and step two" indicates the following three parallel cases: (1) performing step one; (2) performing step two; (3) performing both step one and step two.

[0050] It should be noted that the user information involved in this disclosure (including but not limited to user device information, user personal information, etc.) is all information authorized by the user or fully authorized by all parties.

[0051] The following will first combine Figure 1 and Figure 2 Examples of block-based video coding and decoding systems are described.

[0052] Figure 1 A block diagram of a block-based video coding system is shown. The input video signal includes signals of multiple image frames, each of which can be processed block by block. Here, a block can be, for example, but not limited to, a Coding Tree Unit (CTU), a Largest Coding Unit (LCU), a Coding Unit (CU), a Prediction Unit (PU), and a Transform Unit (TU).

[0053] The principle of video coding is to use the similarity between consecutive image frames and the similarity between adjacent blocks within the same image frame / strip to encode a portion of representative image frames or blocks according to their original pixel values. For other image frames or blocks besides the representative ones, the pixel values ​​are predicted by using the similarity between consecutive image frames or adjacent blocks, thereby compressing the video signal to remove redundancy in the spatial and temporal dimensions.

[0054] When performing video encoding, spatial and / or temporal predictions can be performed on blocks of the current image frame, depending on whether the similarity between adjacent blocks or between consecutive image frames is utilized.

[0055] Spatial prediction (or "intra-frame prediction") uses the pixel values ​​of pixels from reconstructed neighboring blocks (neighboring blocks refer to already encoded adjacent blocks) stored in memory (called reference pixels) to predict the current block, thus obtaining the predicted block. Spatial prediction reduces the spatial redundancy inherent in the video signal.

[0056] Temporal prediction (also known as "inter-frame prediction" or "motion-compensated prediction") corresponds to Figure 1 The "motion estimation" and "motion compensation" sections use reconstructed pixels (reconstructed pixels refer to pixels that have already been encoded) from the encoded image frames (called "reference image frames") stored in the image frame buffer to predict the current block, thus obtaining the predicted block. Temporal prediction reduces the inherent temporal redundancy in the video signal. The temporal prediction signal for the current block is typically determined based on one or more predicted motion vectors, which indicate the motion offset and direction between the current block and its temporal reference (called the "reference block," which is a block in the reference image frame). The process of determining the predicted motion vectors is called motion estimation; the process of determining the reference block based on the predicted motion vectors, the current block, and the reference image frame is called motion compensation, and the determined reference block becomes the predicted block. Furthermore, if the encoder and decoder support the use of multiple reference image frames, the encoder sends an additional reference image frame index when sending encoded information to the decoder. This index identifies which reference image frame in the image frame buffer the temporal prediction signal originates from, i.e., which reference image frame is used for motion compensation.

[0057] After spatial and / or temporal prediction, the encoder performs spatial / temporal mode determination, for example, by selecting the optimal prediction mode based on rate-distortion optimization methods. Then, the difference between the current block and the prediction block is determined, specifically by subtracting the corresponding pixel values ​​of the prediction block from the pixel values ​​of each pixel in the current block to obtain the prediction residual. The prediction residual is then transformed, for example, by Fourier transform, cosine transform, or wavelet transform, to obtain a series of coefficients. This removes the correlation of the spatial signal, concentrating the energy of the spatial signal onto a small subset of low-frequency coefficients in the frequency domain. These coefficients are then quantized, specifically by mapping them to smaller coefficients and selecting a representative value for several coefficients, for example, by using integer division, dividing the current coefficient by the quantization step size and rounding it to the nearest integer. This removes low-energy coefficients, obtaining residual coefficients, which further compress the data without affecting the quality of the reconstructed image. The quantized residual coefficients are then dequantized and inversely transformed to form the reconstructed residual. This reconstructed residual is then added back to the prediction block to form the reconstructed signal of the block (called the "reconstructed block"), which is stored in memory. Before placing the reconstructed block into the image frame buffer and using it as a reference for encoding future blocks, further loop filtering can be applied to the reconstructed block, such as, but not limited to, at least one of deblocking filters, pixel adaptive offsets, and adaptive loop filters. Finally, to form the encoded information of the output video, i.e., the bitstream, the encoding mode (spatial / temporal mode), prediction-related information such as the reference image frame, and the quantized residual coefficients are sent to the entropy coding unit for further compression and packing.

[0058] Figure 2 A block diagram of a block-based video decoding system is shown. Figure 2 As shown, after receiving the video bitstream, the decoder first performs entropy decoding to obtain prediction-related information and residual coefficients. The prediction-related information is sent to a spatial prediction unit (if spatial mode coding is used) or a temporal prediction unit (if temporal mode coding is used) to form prediction blocks. The residual coefficients are sent to an inverse quantization unit and an inverse transform unit to reconstruct residual blocks. The prediction blocks and residual blocks are then added together to determine the reconstructed blocks, which are stored in memory. The reconstructed blocks may undergo further loop filtering before being stored in the image frame buffer, such as, but not limited to, at least one of deblocking filters, pixel adaptive offsets, and adaptive loop filters. The reconstructed video in the image frame buffer is then output for display, along with blocks for predicting future blocks. In temporal mode, motion compensation can be performed on the current block using the corresponding prediction block in a reference image frame.

[0059] Specifically, regarding the processing of residual coefficients after quantization, considering the efficiency of coefficient encoding, in most current encoding standards, the process of writing coefficients into the bitstream typically involves two steps: the first step is to divide the TU block into multiple 4x4 CG blocks, and the second step is to encode the coefficients within each CG block individually. The encoding of coefficients within each CG block also involves two steps: the first step is to write the absolute value of the coefficient into the bitstream, and the second step is to write the sign of the coefficient into the bitstream. Encoding standards such as H.264, HEVC (High Efficiency Video Coding), and VVC (Versatile Video Coding) all have a Symbol Hiding Hierarchy (SDH) algorithm in their quantization modules. This algorithm optimizes the second step of coefficient encoding within the CG block by utilizing the correlation between coefficients.

[0060] Taking the HEVC encoding standard as an example, the coefficients of each TU block need to be quantized by a quantization module, and the quantized coefficients need to be written into the bitstream. The HEVC standard does not write the coefficients within the TU block into the bitstream one by one from left to right and top to bottom. Instead, it first divides the TU block into multiple 4x4 CG blocks; secondly, it determines the first and last CG blocks containing non-zero coefficients; and finally, it encodes each CG block from right to left and from back to front. (Refer to...) Figure 3 In the diagram, solid lines represent TU blocks, dashed lines represent CG blocks, and dark gray and light gray represent the first and last CG blocks containing non-zero coefficients, respectively. All CG blocks within the range from the light gray CG block to the dark gray CG block are arranged according to... Figure 3 Encoding is performed in the direction indicated by the arrows in the diagram. The coefficients within each non-zero CG block are then encoded according to... Figure 4 The zig-zag scanning order shown is used for encoding. It should be noted that the SDH algorithm uses the same processing method for the luma component and the chromaticity components (Cb component, Cr component), and the components do not interfere with each other.

[0061] Next, combine Figure 4 This paper introduces the specific process of implementing the SDH algorithm in the HEVC standard.

[0062] First refer to Figure 4 The coefficients within the CG block are scanned in zig-zag order, resulting in a sequence of absolute coefficient values: 0, 3, 2, 1, 1, 1, 0, 1, 0…, and a sequence of sign values: 0, 0, 0, 0, 1, 1, 0, 0, 0…. The sign values ​​0 and 1 represent positive and negative signs, respectively, with a sign value of 0 for a coefficient of 0. The positions of the first non-zero coefficient (firstNZPos) and the last non-zero coefficient (lastNZPos) are then calculated.

[0063] Next, calculate the sum of the absolute values ​​of the coefficients, absSum. The SDH algorithm stipulates that when absSum is odd, it means that the sign value of the first non-zero coefficient is negative; when absSum is even, it means that the sign value of the first non-zero coefficient is positive.

[0064] by Figure 4 For example, absSum = 9, firstNZPos = 1, and lastNZPos = 7. The first non-zero coefficient is positive (3), therefore it does not meet the requirements and absSum needs to be adjusted to an even number. Therefore, it is necessary to add or subtract 1 from one of the coefficients between firstNZPos and lastNZPos. The specific process is as follows:

[0065] Step 1: From lastNZPos to firstNZPos, traverse the coefficients one by one in reverse order (assuming the current coefficient value is val), add 1 and subtract 1 from val, and calculate the rate distortion costs CostPlus1 and CostSub1 for adding 1 and subtracting 1 respectively according to formula (1).

[0066] Cost = ΔD + λ*ΔBits (1)

[0067] Where ΔD and ΔBits represent the distortion when the coefficient is added by 1 and subtracted by 1, and the bitrate change when encoding the coefficient, respectively.

[0068] Then calculate the optimal rate-distortion cost, bestCost, for adjusting this coefficient. If CostPlus1 ≤ CostSub1, it means that adding 1 to this coefficient yields better performance than subtracting 1, so bestCost = CostPlus1; conversely, it means that subtracting 1 from this coefficient yields better performance than adding 1, so bestCost = CostSub1. Two points need to be noted here:

[0069] a) If val equals 0, then it is necessary to determine whether to add 1 or subtract 1 based on the sign of the value valUQ before quantization. If valUQ≥0, then it is only necessary to calculate the rate distortion cost CostPlus1 for adding 1 to val, and bestCost=CostPlus1; otherwise, if valUQ<0, then it is only necessary to calculate the rate distortion cost CostSub1 for subtracting 1 from val, and bestCost=CostSub1.

[0070] b) If the adjusted coefficient val is located at firstNZPos, i.e., the first non-zero coefficient, then in order to ensure that the sign value of the first non-zero coefficient remains unchanged, the rate distortion cost needs to be calculated according to the following conditions:

[0071] (1) If val equals 1, then we only need to calculate the rate distortion cost CostPlus1 of adding 1 to val, and bestCost = CostPlus1.

[0072] (2) If val equals -1, then we only need to calculate the rate distortion cost CostSub1 of reducing val by 1, and bestCost = CostSub1.

[0073] (3) If val is not equal to -1 or 1, the rate distortion cost of adding 1 and subtracting 1 needs to be calculated, and the bestCost is calculated according to the above steps.

[0074] After steps 1 and 2, the best cost is calculated for each coefficient from lastNZPos to firstNZPos. The minimum rate distortion cost is then compared and used as the bestSDHCost for rate distortion adjustment in the SDH algorithm. Based on the adjustment direction of the bestCost obtained in step 1, the corresponding coefficients are modified. Figure 4 After traversing and calculating the rate distortion cost, it is assumed that subtracting 1 from the value at the firstNZPos+1 position from 2 will achieve the best performance. At this point, absSum is adjusted from an odd number to an even number, thus completing the coefficient adjustment for the CG block.

[0075] Therefore, when encoding the coefficients of the CG block, the sign value of 0 at the position corresponding to firstNZPos does not need to be encoded and can be directly derived from the absSum value.

[0076] It should be noted that, usually when lastNZPos – firstNZPos ≥ 4, the current CG block will use the SDH algorithm; otherwise, the SDH algorithm will not be used, and the sign value at the firstNZPos position will be written into the bitstream.

[0077] Given the ever-increasing volume of video data during transmission, video coding performance urgently needs further improvement. Related technologies often focus on optimizing prediction modes to reduce spatial or temporal redundancy in order to improve coding performance. However, in terms of residual coefficient coding, the industry has consistently used the traditional SDH algorithm based on inertia. But the traditional SDH algorithm can only hide the sign of the first non-zero coefficient within each CG block, and its coding performance needs further improvement.

[0078] The encoding method, decoding method, encoding apparatus, and decoding apparatus according to exemplary embodiments of this disclosure break with conventional thinking. Analysis reveals that the signs of the first at least two non-zero coefficients in the coefficient sequence of a CG block (recorded in the form of a sequence of absolute values ​​and a sequence of sign values ​​of coefficients) are strongly correlated with the absolute values ​​of the coefficient sequence. This correlation indicates that redundancy still exists among the coefficients, and the more non-zero coefficients there are, the higher this redundancy becomes. Based on this, by introducing an index related to the absolute values ​​of the coefficient sequence and establishing a preset relationship between this index and the signs of the first at least two non-zero coefficients in the coefficient sequence, the signs of the first at least two non-zero coefficients can be hidden based on this preset relationship, thereby effectively reducing redundancy among coefficients and helping to improve encoding performance.

[0079] Below, we will refer to Figures 5 to 9 The specific description includes an encoding method, a decoding method, an encoding apparatus, and a decoding apparatus according to exemplary embodiments of the present disclosure.

[0080] Figure 5 This is a flowchart illustrating an encoding method according to exemplary embodiments of the present disclosure. It should be understood that the encoding method according to exemplary embodiments of the present disclosure can be implemented in terminal devices such as smartphones, tablets, and personal computers (PCs), or in devices such as servers.

[0081] Reference Figure 5 In step 501, a first coefficient sequence of the CG block to be encoded is obtained, wherein the first coefficient sequence includes the first absolute value and the first sign value of each coefficient in the CG block to be encoded. It should be understood that the first absolute value and the first sign value represent the original absolute value and sign value of each coefficient in the first coefficient sequence. The sign value, as described above, is used to indicate whether the corresponding coefficient is positive or negative. This step can be implemented by performing the aforementioned zig-zag sequential scan of the CG block to be encoded.

[0082] In step 502, the first index of the first coefficient sequence and the first sign value of the first N non-zero coefficients are determined, wherein the first index is the value obtained after pre-processing each first absolute value, and N is an integer greater than 1.

[0083] It should be noted that, in order to obtain a first index from multiple first absolute values, the multiple first absolute values ​​can be merged into one value first, and then the merged value can be processed. Alternatively, the multiple first absolute values ​​can be processed separately first, and then the processed values ​​can be merged into one value. The merging method is, for example, but not limited to, summation or averaging. This disclosure does not limit the specific form of the preset processing.

[0084] As an example, the first index is the sum of the individual first absolute values ​​divided by 2. NThe remainder obtained. It should be understood that, taking the sign value in the SDH algorithm as an example, the sign value of each non-zero coefficient has two possibilities: 0 (representing a positive coefficient or a coefficient of 0) and 1 (representing a negative coefficient). Therefore, the sign values ​​of the first N non-zero coefficients have a total of 2... N There are several possible combinations. By using the first index described above, it can be ensured that the number of possible values ​​of the first index is equal to the number of possible combinations of the sign values ​​of the first N non-zero coefficients. This facilitates the formation of a one-to-one correspondence between the value of the first index and the sign values ​​of the first N non-zero coefficients, which is the expected correspondence indicated by the preset sign index table described later. Of course, other forms of preset processing can also be used, as long as it can be ensured that the number of values ​​of the first index obtained after preset processing is greater than or equal to the number of combinations of the sign values ​​of the first N non-zero coefficients, so as to ensure that each combination of sign values ​​has a corresponding first index value.

[0085] Optionally, step 502 includes: if the first coefficient sequence satisfies preset conditions, determining the first index of the first coefficient sequence and the first sign value of the first N non-zero coefficients, wherein the preset conditions include at least one of the following: the number of non-zero coefficients in the first coefficient sequence is greater than or equal to a first preset number; the number of coefficients between the first and last non-zero coefficients in the first coefficient sequence (excluding the first and last non-zero coefficients) is greater than or equal to a second preset number. By configuring preset conditions, the sign values ​​of the first N non-zero coefficients can be hidden only when the number of non-zero coefficients is sufficiently large and the positional span is sufficiently large, which helps to balance the computational load and the amount of encoded data, and improves encoding performance. As an example, the first preset number is 4, and the second preset number is 5. Optionally, when the number of non-zero coefficients in the first coefficient sequence is greater than or equal to 2 and less than 4, and the number of coefficients between the first and last non-zero coefficients in the first coefficient sequence is greater than or equal to 3 and less than 5, the traditional SDH algorithm can be used, i.e., the sign value of the first non-zero coefficient is hidden. When the above preset conditions are met, the method of this disclosure is used to hide the sign values ​​of the first N non-zero coefficients. The two hiding methods can be combined to achieve reasonable hiding and comprehensively improve the coding performance.

[0086] In step 503, based on the comparison between the first index and the first sign value of the first N non-zero coefficients with a preset sign index table, the second absolute value and second sign value of each coefficient in the first coefficient sequence are determined to obtain the second coefficient sequence. The preset sign index table indicates the expected correspondence between the first sign values ​​of the first N non-zero coefficients in the first coefficient sequence and the first index. Specifically, this expected correspondence refers to the correspondence between a specific value of the first index and a specific combination of the first sign values ​​of the first N non-zero coefficients in the first coefficient sequence. For example, but not limited to, when the first sign values ​​of the first N non-zero coefficients in the first coefficient sequence are all 0, the expected corresponding first index is 1. By referring to the preset sign index table to determine the expected form of the first coefficient sequence, i.e., the second coefficient sequence, the final determined second coefficient sequence can satisfy the expected correspondence indicated by the preset sign index table. Therefore, the second index of the second coefficient sequence (calculated in the same way as the first index, for example, the sum of the second absolute values ​​of each coefficient in the second coefficient sequence divided by 2) can be used. N The remainder obtained is used to represent the second sign value of the first N non-zero coefficients in the second coefficient sequence. In the subsequent step 504, it is not necessary to encode the second sign value of the first N non-zero coefficients in the second coefficient sequence, thereby reducing the amount of data to be encoded, reducing redundancy between coefficients, and improving encoding performance.

[0087] In step 504, the second coefficient sequence is encoded to obtain the encoding information of the CG block to be encoded. The second sign value of the first N non-zero coefficients of the second coefficient sequence is not encoded.

[0088] Optionally, step 503 includes: if the first index and the first sign value of the first N non-zero coefficients are consistent with the preset sign index table, that is, if the first index and the first sign value of the first N non-zero coefficients conform to the preset relationship in the preset sign index table, then the first index can represent the first sign value of the first N non-zero coefficients in the first coefficient sequence. There is no need to adjust the first coefficient sequence; the first coefficient sequence can be directly used as the second coefficient sequence without increasing the computational load. Step 503 also includes: if the first index and the first sign value of the first N non-zero coefficients are inconsistent with the preset sign index table, that is, if the first index and the first sign value of the first N non-zero coefficients do not conform to the preset relationship in the preset sign index table, then adjust the value of at least one coefficient in the first coefficient sequence to obtain the second coefficient sequence. By adjusting the value of at least one coefficient in the first coefficient sequence, the sequence formed by the absolute values ​​of each coefficient can also change accordingly (that is, the sequence of the second absolute values ​​is different from the sequence of the first absolute values), thereby changing the index, that is, obtaining the second coefficient sequence and the second index, ensuring the reliable hiding of the second sign value of the first N non-zero coefficients. It should be understood that the second coefficient sequence is the final form of the first coefficient sequence used for encoding. Depending on the actual situation, it may be the same as the first coefficient sequence (i.e., the first coefficient sequence is not adjusted) or it may be slightly different from the first coefficient sequence (i.e., the first coefficient sequence is adjusted). In other words, the second absolute value of each coefficient in the second coefficient sequence is the final absolute value of each coefficient in the first coefficient sequence. It is the final state of the initial first absolute value of the corresponding coefficient. For each coefficient, depending on the actual adjustment, the second absolute value may be the same as the first absolute value or it may be different from the first absolute value.

[0089] Optionally, the preset symbol index table is established through the following steps: determining the possible combinations of the first symbol values ​​of the first N non-zero coefficients in the first coefficient sequence as symbol combinations to be counted, and determining the possible values ​​of the first index as indexes to be counted; acquiring multiple historical CG blocks, and for each historical CG block, acquiring the historical coefficient sequence and historical index of the historical CG block, resulting in multiple historical coefficient sequences and multiple historical indices, wherein each historical coefficient sequence includes the absolute value and symbol value of each coefficient in the historical CG block, and each historical index is the value obtained after pre-processing the absolute value of each coefficient in the historical coefficient sequence; based on the multiple historical coefficient sequences, calculating the probability of occurrence of each symbol combination to be counted as the symbol combination probability; based on the multiple historical indices, calculating the probability of occurrence of each index to be counted as the index probability; and determining the correspondence between each symbol combination to be counted and each index to be counted according to the symbol combination probability and the index probability, thus obtaining the preset symbol index table. By statistically analyzing the historical CG blocks in the existing video data, the probability of occurrence of each symbol combination of the first N non-zero coefficients (i.e., the symbol combination probability of each symbol combination to be counted) and the probability of occurrence of each index (i.e., the index probability of each index to be counted) can be obtained. Based on this, by combining the symbol combination probability and the index probability, we can establish the expected correspondence between each symbol combination to be counted and the index to be counted. Specifically, we can assign a symbol combination with a higher probability to an index with a higher probability, which can increase the probability that the first index and the first symbol values ​​of the first N non-zero coefficients meet the expected correspondence in the preset symbol index table. This can reduce the possibility of adjusting the first coefficient sequence, help reduce the amount of computation, and improve coding efficiency. As an example, when the number of symbol combinations to be counted is equal to the number of indexes to be counted, the symbol combinations to be counted can be arranged in descending order of their probability of occurrence, and the indexes to be counted can also be arranged in descending order of their probability of occurrence. Then, the symbol combinations to be counted and the indexes to be counted can be matched one-to-one in sequence. When the number of symbol combinations to be counted is less than the number of indexes to be counted, on the premise that each symbol combination to be counted has a corresponding index to be counted, at least one symbol combination to be counted can be matched with two or more indexes to be counted. For example, the matching method can be to match two or more indexes with higher probability of occurrence with a symbol combination with higher probability of occurrence, or to match two or more indexes with lower probability of occurrence with a symbol combination with lower probability of occurrence, so as to increase the probability that the first index and the first symbol values ​​of the first N non-zero coefficients meet the expected matching relationship in the preset symbol index table. This disclosure does not limit the specific matching method.It should be noted that when there are combinations of symbols or indices with the same probability to be counted, they can be sorted according to preset rules, such as, but not limited to, prioritizing combinations of symbols with a value of 0, or they can be sorted randomly. This disclosure does not limit this.

[0090] Next, we will describe in detail the method of adjusting the first coefficient sequence to obtain the second coefficient sequence in step 503.

[0091] In some embodiments, this adjustment method can adjust any coefficient in the first coefficient sequence, as long as the second index and the second sign values ​​of the first N non-zero coefficients in the resulting second coefficient sequence conform to a preset relationship. For example, by adjusting the value of the first non-zero coefficient, both the index value and the sign value of the first non-zero coefficient are changed, thus altering the combination of the sign values ​​of the first N non-zero coefficients, which then conforms to the preset relationship with the changed value of the second index. This method can potentially obtain the second coefficient sequence with a relatively small amount of change. Alternatively, the sign values ​​of the first N non-zero coefficients can be adjusted while keeping the index unchanged. Specifically, the first index can be used to look up a preset sign index table to determine the expected second sign values ​​of the corresponding first N non-zero coefficients. Then, the non-zero coefficients in the first N non-zero coefficient sequence that do not match the found second sign values ​​are adjusted to their opposites, thereby keeping the index unchanged while changing the sign values ​​of the first N non-zero coefficients.

[0092] In other embodiments, the preset processing involves summing followed by transformation, such as the aforementioned division by 2. NAnd determine the remainder obtained. Accordingly, the adjustment method includes: using the first sign values ​​of the first N non-zero coefficients of the first coefficient sequence, searching a preset sign index table to determine the second index; determining the target adjustment amount of the sum of each first absolute value based on the difference between the first index and the second index; and adjusting the first absolute value of at least one coefficient in the first coefficient sequence according to the target adjustment amount, while keeping the sign values ​​of the first N non-zero coefficients unchanged, to obtain the second coefficient sequence. By summing, multiple absolute values ​​can be easily merged into a single value, and then this value can be transformed to obtain a representative index value. By keeping the sign values ​​of the first N non-zero coefficients unchanged, a clear change amount can be provided for the index value and the change of the sum of absolute values ​​(the sum of absolute values ​​is the sum of each absolute value, and the change amount of the sum of absolute values ​​is the target adjustment amount), which facilitates the determination of an appropriate adjustment scheme and helps control the amount of computation in the encoding. It should be understood that the specific N coefficients that are the first N non-zero coefficients after adjustment may change. For example, the first two non-zero coefficients might change from the 2nd and 7th coefficients to the 1st and 7th coefficients. Therefore, it cannot be definitively said that the second sign value of the first N non-zero coefficients remains unchanged relative to the first sign value. In the example above, the second sign values ​​of the 1st and 2nd coefficients are different from their first sign values, while the second sign value of the 7th coefficient remains equal to its first sign value, unchanged. Therefore, the final result is that the sign values ​​of the first N non-zero coefficients remain unchanged. Hence, the premise here is described as keeping the "sign value" of the first N non-zero coefficients unchanged, without adding a first or second prefix before the "sign value". Furthermore, although this describes adjusting the first absolute value according to the target adjustment amount, it should be understood that the first sign value can also be adjusted as needed. Whether or not to adjust the first sign value can refer to the premise of keeping the sign value of the first N non-zero coefficients unchanged.

[0093] Optionally, for some of the embodiments described above, the step of determining the target adjustment amount of the sum of each first absolute value based on the difference between the first index and the second index includes: determining the adjustment amount with the smallest adjustment range of the sum of each first absolute value based on the difference between the first index and the second index, combined with a preset processing, as the target adjustment amount. For the determined preset processing, the number of possible values ​​for the sum of absolute values ​​is often much larger than the number of possible values ​​for the index. Therefore, there are cases where different sums of absolute values ​​result in the same index after preset processing, so there can be multiple feasible adjustment amounts for the sum of absolute values. By using the amount with the smallest adjustment range among these adjustment amounts as the target adjustment amount, the change in the first coefficient sequence can be reduced, which can reduce both the change in the second coefficient sequence relative to the first coefficient sequence and the number of adjustment schemes, thus contributing to a comprehensive improvement in coding performance.

[0094] In some of the above embodiments, when determining the available adjustment schemes, one can first select which coefficient(s) to adjust, then determine the adjustment amount for that coefficient in conjunction with the target adjustment amount, or list different adjustment amounts for these coefficients in conjunction with the target adjustment amount, thus obtaining multiple adjustment schemes; then, another one or more coefficients to adjust are selected, and the adjustment amounts are determined or listed again, resulting in multiple adjustment schemes; by continuing to select coefficients and determine or list adjustment amounts according to this rule, multiple available adjustment schemes can be obtained. Optionally, for certain special coefficients, reasonable adjustment amounts can be pre-defined using certain rules, without having to exhaustively list all adjustment amounts, which is equivalent to pre-screening adjustment schemes, significantly reducing the number of available adjustment schemes, helping to reduce computational load and improve coding efficiency. It should be understood that this is a requirement for the adjustment amounts of certain special coefficients. On the one hand, this does not mean that only these special coefficients can be adjusted, but that these special coefficients and other coefficients can be adjusted simultaneously; on the other hand, if other coefficients besides these special coefficients are adjusted, the requirement for the adjustment amounts of these special coefficients does not need to be followed.

[0095] Specifically, at least one adjustment scheme must satisfy the following condition: When adjusting the first absolute value of at least one coefficient among the first N non-zero coefficients without adjusting the zero coefficients before the Nth non-zero coefficient, the second sign value of the adjusted coefficient (i.e., at least one coefficient among the first N non-zero coefficients) must be equal to its first sign value; that is, the sign value remains unchanged. Furthermore, the adjusted coefficient must remain 0. This means that the second sign value cannot be different from the first sign value, nor can the coefficient become 0. For example, assuming N is 2, and the second non-zero coefficient and all coefficients before it are 0, 0, 1, 0, 0, 2 respectively, then the first two non-zero coefficients are 1 and 2, and the zero coefficients before the second non-zero coefficient are the four 0s listed here. If the first two non-zero coefficients are both positive, taking the sign value in the SDH algorithm as an example, then their first sign values ​​are both 0. If we choose to adjust the first absolute value of 1 and / or 2, and do not adjust the four zeros, that is, to adjust at least one non-zero coefficient among the six coefficients, then the first two non-zero coefficients will still be the third and sixth coefficients. When adjusting, we need to keep these two coefficients positive, that is, the second sign value after adjustment is still 0, and the second absolute value remains unchanged at 0, so as to ensure that the sign values ​​of the first two non-zero coefficients remain unchanged. It should be noted that the reason for specifying "not adjusting zero coefficients before the Nth non-zero coefficient," i.e., not adjusting the four zeros in the example, is that adjusting any one of the zeros will inevitably change the first two non-zero coefficients. In the example above, the first two non-zero coefficients will no longer be the 3rd and 6th coefficients (but one of the 3rd and 6th coefficients could still be one of the first two non-zero coefficients; for example, if the sequence becomes 1, 0, 1, 0, 0, 2, then the first two non-zero coefficients become the 1st and 3rd coefficients). If the original first two non-zero coefficients are still to be adjusted, then the constraint of "keeping the second sign value of the adjusted coefficient equal to the first sign value, and the adjusted coefficient not being 0" does not need to be followed. Continuing with the example above, if the 1st coefficient (i.e., the 1st zero) is adjusted to a positive value, then the 6th coefficient (i.e., 2) will no longer be among the first two non-zero coefficients. Therefore, if the 6th coefficient is chosen to be adjusted, the constraint of keeping the 6th coefficient positive does not need to be followed.

[0096] At least one adjustment scheme should also satisfy the following: when adjusting non-zero coefficients other than the first N non-zero coefficients, the second sign value of the adjusted coefficient should be kept equal to the first sign value, or the adjusted coefficient should be adjusted to 0. In other words, the adjusted coefficient cannot be changed from a positive value to a negative value, nor from a negative value to a positive value. This is because the target adjustment amount is the adjustment amount of the sum of the absolute values ​​of the coefficient sequence, not the adjustment amount of the sum of the individual coefficients in the coefficient sequence. For a coefficient, if both the sign and absolute value of the coefficient need to be changed, then compared to changing only the absolute value, it will inevitably cause a larger change to the coefficient, increasing the risk of excessive changes in the coefficient sequence and affecting coding quality. For example, for coefficient 2, if its absolute value is to be reduced by 1, then without changing its sign value, the coefficient would be adjusted to 1, reducing the value by 1; if its sign value is changed, the coefficient would be adjusted to -1, reducing the value by 3, a larger change.

[0097] In some of the other embodiments described above, the coefficients to be adjusted can be selected randomly or based on a specific target adjustment amount. As an example, at least one adjustment scheme can also satisfy the following: when the target adjustment amount is negative, adjust the non-zero coefficients. This is because adjusting 0 to a non-zero coefficient will inevitably increase the sum of absolute values, contradicting the negative target adjustment amount. Therefore, it is necessary to reduce the absolute values ​​of other non-zero coefficients to compensate, resulting in an increase in the number of coefficients to be adjusted and thus increasing the number of adjustment schemes. Therefore, by selecting to adjust non-zero coefficients, the number of adjustment schemes can be effectively controlled, the computational load reduced, and the risk of excessive changes in the first coefficient sequence affecting coding quality lowered.

[0098] Optionally, while keeping the sign values ​​of the first N non-zero coefficients unchanged, the first absolute value of at least one coefficient in the first coefficient sequence is adjusted according to the target adjustment amount to obtain the second coefficient sequence. This includes: defining the portion of the first coefficient sequence from the first non-zero coefficient to the last non-zero coefficient as the segment to be adjusted; and, while keeping the sign values ​​of the first N non-zero coefficients unchanged, adjusting the first absolute value of at least one coefficient in the segment to be adjusted according to the target adjustment amount to obtain the second coefficient sequence. By adjusting the segment to be adjusted from the first non-zero coefficient to the last non-zero coefficient, the number of coefficients involved in the adjustment can be reduced, further reducing the number of adjustment schemes.

[0099] Optionally, while keeping the sign values ​​of the first N non-zero coefficients unchanged, the first absolute value of at least one coefficient in the sequence segment to be adjusted is adjusted according to the target adjustment amount to obtain a second coefficient sequence. This includes: while keeping the sign values ​​of the first N non-zero coefficients unchanged, determining at least one adjustment scheme and its corresponding rate-distortion cost for the sequence segment to be adjusted according to the target adjustment amount; determining an adjustment scheme from the at least one adjustment scheme according to the rate-distortion cost corresponding to each adjustment scheme; and applying the determined adjustment scheme to adjust the sequence segment to be adjusted accordingly to obtain the second coefficient sequence. Based on the target adjustment amount, at least one adjustment scheme can be determined. For example, when the target adjustment amount is 1, the first absolute value of one coefficient in the sequence segment to be adjusted can be increased by 1, thus obtaining multiple adjustment schemes. Similarly, when the target adjustment amount is 3, the first absolute value of one coefficient in the sequence segment to be adjusted can be increased by 3, or the first absolute value of one coefficient can be increased by 1 and the first absolute value of another coefficient can be increased by 2, or the first absolute values ​​of three different coefficients can be increased by 1 respectively, thus obtaining multiple adjustment schemes. By combining the rate-distortion cost of each adjustment scheme, the one with the relatively smaller rate-distortion cost can be selected. Adjusting the sequence segment to be adjusted accordingly yields the second coefficient sequence. Determining a reasonable adjustment scheme provides candidate options for the final adjustment, ensuring the orderly progress of the adjustment process. Selecting an adjustment scheme based on rate-distortion cost provides a reliable basis for selection and reduces coding loss. It should be understood that when selecting an adjustment scheme with a relatively smaller rate-distortion cost, one can directly choose the scheme with the lowest rate-distortion cost, or consider other parameters of interest in the specific situation and make a comprehensive judgment to select an adjustment scheme with a relatively balanced rate-distortion cost among other parameters of interest. This disclosure does not impose any restrictions in this regard. The calculation method for rate-distortion cost is described above.

[0100] Next, the first index is the sum of the first absolute values ​​of the coefficients in the first coefficient sequence divided by 2. N The method for adjusting the first coefficient sequence to obtain the second coefficient sequence will be further introduced when the remainder is obtained and N is 2.

[0101] It should be understood that when N is 2, there are 4 possible combinations of the sign values ​​of the first two non-zero coefficients, and the first and second indices also each have 4 possible values, namely 0, 1, 2, and 3. Based on the aforementioned steps for establishing the preset symbol index table, as an example, the preset symbol index table shown in Table 1 below can be obtained.

[0102] Table 1 Preset Symbol Index Table

[0103] index sign1 sign2 0 0 1 1 0 0 2 1 1 3 1 0

[0104] Where index represents the index, sign1 represents the first sign value of the first non-zero coefficient, and sign2 represents the first sign value of the second non-zero coefficient, with sign value 0 representing positive and 1 representing negative.

[0105] Based on this, excluding the case where the first index and the second index are equal and the first coefficient sequence is not adjusted, and the first coefficient sequence is used as the second coefficient sequence, the difference between the first index and the second index, that is, the absolute value of their difference, may be 1, 2, or 3. The difference between them has 6 possible values, as shown in Table 2 below.

[0106] Table 2 lists the differences between the first and second indexes.

[0107]

[0108] Here, index1 represents the first index, index2 represents the second index, and the values ​​in the table are the difference between the first index and the second index.

[0109] Optionally, the target adjustment amount for the absolute sum of the first coefficient sequence is determined based on the difference between the first index and the second index. This includes: determining the target adjustment amount as 1 when the difference between the first index and the second index is -1 or 3; determining the target adjustment amount as -1 when the difference between the first index and the second index is 1 or -3; and determining the target adjustment amount as 2 or -2 when the difference between the first index and the second index is 2 or -2. That is, regardless of whether the difference between the first index and the second index is 2 or -2, the adjustment of the first coefficient sequence can be achieved by using the target adjustment amount of 2 or -2. As an example, assuming the absolute sum of the first coefficient sequence is 11, and the first two non-zero coefficients are both positive, then the first index is 3. By looking up Table 1, it can be determined that the desired second index is 1. The difference between the first index and the second index is 2, thus determining the target adjustment amount as 2 or -2. That is, the absolute sum of the second coefficient sequence can be 13 or 9, both of which ensure that the second index is 1. By configuring the target adjustment amount as described above, the absolute value of the target adjustment amount, that is, the adjustment range of the sum of the absolute values ​​of the first coefficient sequence, can be controlled within 2 while ensuring that the desired second index is obtained. This helps to reduce the adjustment amount, which can effectively reduce the number of adjustment schemes, improve the calculation speed, reduce the changes in the first coefficient sequence, ensure the coding quality, and thus improve coding efficiency and help improve coding performance.

[0110] Optionally, for cases where the target adjustment amount is 1 or -1, the steps of determining at least one adjustment scheme and the corresponding rate-distortion cost of the sequence segment to be adjusted based on the target adjustment amount, on the premise of keeping the sign values ​​of the first N non-zero coefficients unchanged, include the following two cases.

[0111] In the first category, with a target adjustment of 1, the coefficients between the first two non-zero coefficients in the first coefficient sequence are each adjusted by 1 in the direction consistent with the first sign value of the second non-zero coefficient. That is, if the second non-zero coefficient is positive, these coefficients are each incremented by 1; if it is negative, they are each decremented by 1, thus keeping the sign value of the second non-zero coefficient unchanged after adjustment. The non-zero coefficients in the sequence segment to be adjusted are then adjusted by 1 in the direction consistent with their own first sign value. That is, positive coefficients are incremented by 1, and negative coefficients are decremented by 1, reducing the coefficient adjustment amount while maintaining the target adjustment. Other coefficients in the sequence segment to be adjusted are incremented by 1 and / or decremented by 1, meaning they can be incremented or decremented to change 0 to 1 or -1, satisfying the requirement of a target adjustment of 1. It should be understood that at this point, only other coefficients can be incremented by 1, only other coefficients can be decremented by 1, or other coefficients can be both incremented and decremented by 1 to increase the number of adjustment schemes. Based on the above adjustments, at least one adjustment scheme can be obtained as a candidate, and then the rate-distortion cost corresponding to this at least one adjustment scheme is determined.

[0112] The second type involves not adjusting any coefficients that are zero when the target adjustment amount is -1. Instead, the non-zero coefficients in the sequence segment to be adjusted are adjusted by 1 in the opposite direction to their first sign value. That is, if the current non-zero coefficient is positive, it is reduced by 1, and if it is negative, it is increased by 1, in order to achieve the target adjustment amount. At least one adjustment scheme can be obtained, and then the rate distortion cost corresponding to at least one adjustment scheme is determined.

[0113] The embodiments in the above two categories, by specifically defining which coefficients to adjust, clarify feasible adjustment schemes, effectively reduce the increase in computational load caused by unreasonable adjustment schemes, and improve the coding speed. It should be noted that the above-described adjustments can be made to all coefficients that meet the conditions, or only some coefficients can be adjusted. For example, in the first category, all coefficients between the first two non-zero coefficients can be adjusted by 1 in the direction consistent with the first sign value of the second non-zero coefficient, or only some coefficients between the first two non-zero coefficients can be adjusted. These are all implementation methods of this disclosure and fall within the protection scope of this disclosure.

[0114] Optionally, for cases where the target adjustment amount is 2 or -2, the step of determining at least one adjustment scheme for the sequence segment to be adjusted and the corresponding rate distortion cost based on the target adjustment amount includes: when the target adjustment amount is 2 or -2, determining a first rate distortion cost after adding 2 to the first absolute value of each of at least one coefficient in the sequence segment to be adjusted, a second rate distortion cost after adding 1 to the first absolute value of each of at least two coefficients in the sequence segment to be adjusted, a third rate distortion cost after subtracting 2 from the first absolute value of each coefficient in the sequence segment to be adjusted whose first absolute value is greater than or equal to 2, and a fourth rate distortion cost after subtracting 1 from the first absolute value of each of at least two non-zero coefficients in the sequence segment to be adjusted; and determining a first rate distortion cost from at least one first rate distortion cost as a first candidate rate distortion cost. The cost is determined by adding 2 to the first absolute value of the coefficient corresponding to the first candidate rate distortion cost, as a first adjustment scheme; determining the sum of two second rate distortion costs from at least two second rate distortion costs, as a second candidate rate distortion cost, and adding 1 to the first absolute value of the two coefficients corresponding to the second candidate rate distortion cost, as a second adjustment scheme; determining a third rate distortion cost from at least one third rate distortion cost, as a third candidate rate distortion cost, and subtracting 2 from the first absolute value of the coefficient corresponding to the third candidate rate distortion cost, as a third adjustment scheme; determining the sum of two fourth rate distortion costs from at least two fourth rate distortion costs, as a fourth candidate rate distortion cost, and subtracting 1 from the first absolute value of the two coefficients corresponding to the fourth candidate rate distortion cost, as a fourth adjustment scheme.

[0115] When the target adjustment is 2 or -2, the rate distortion cost can be calculated by adding 2 to the first absolute value of one coefficient, adding 1 to the first absolute values ​​of two coefficients, subtracting 2 from the first absolute value of a coefficient whose first absolute value is greater than or equal to 2, or subtracting 1 from the first absolute value of two non-zero coefficients. By calculating the rate distortion cost after adjusting each coefficient for these four scenarios, we can discuss each case separately and select the most suitable adjustment scheme. It should be understood that in the above calculation process, when selecting coefficients, the aforementioned requirements for coefficient adjustment must be met simultaneously; furthermore, it should be noted that the adjustment is to the absolute value of the coefficient, not the coefficient value itself.

[0116] Specifically, for adjusting a single coefficient, the adjustment scheme is determined first, while maintaining the sign values ​​of the first N non-zero coefficients. Then, the rate distortion cost is calculated. Specifically, on one hand, multiple coefficients (e.g., all coefficients can be selected) are chosen from the sequence segment to be adjusted, and each selected coefficient is incremented by 2 as an adjustment scheme. The first rate distortion cost of each adjustment scheme is calculated, and the optimal value is taken as the first candidate rate distortion cost. The corresponding adjustment scheme is then selected as the first adjustment scheme. On the other hand, coefficients with a first absolute value greater than or equal to 2 are selected from the sequence segment to be adjusted. It should be understood that for the first two non-zero coefficients, the first absolute value must be greater than 2. Then, multiple non-zero coefficients are selected from these (e.g., all selected non-zero coefficients can be chosen), and each of these selected non-zero coefficients is incremented by 2 as an adjustment scheme. The third rate distortion cost of each adjustment scheme is calculated, and the optimal value is taken as the third candidate rate distortion cost. The corresponding adjustment scheme is then selected as the third adjustment scheme.

[0117] For cases requiring adjustment of two coefficients, the second and fourth rate-distortion costs after adjusting a single coefficient can be determined first. Then, based on the calculated second or fourth rate-distortion cost, two coefficients are selected. It is determined whether adjusting these two coefficients will maintain the sign values ​​of the first two non-zero coefficients. If the determination is affirmative, the corresponding adjustment scheme is selected. Specifically, taking the determination of the second adjustment scheme as an example, the second rate-distortion cost is first calculated by adding 1 to the first absolute value of each of the at least two coefficients in the sequence segment to be adjusted. Then, the two coefficients to be adjusted when the second rate-distortion cost is minimized are determined. The first absolute values ​​of both coefficients are added by 1, and it is determined whether the sign values ​​of the first two non-zero coefficients change. If they remain unchanged, these two coefficients can be adjusted. If they change, the coefficients adjusted by the minimum and third smallest values ​​of the second rate-distortion cost are selected, and the sign values ​​of the first two non-zero coefficients are determined again. If they still change, the coefficients adjusted by the second and third smallest values ​​are selected, and so on, gradually selecting larger second rate-distortion costs and continuing the determination until the determination result is unchanged. In other words, from multiple second rate-distortion costs, we determine the two second rate-distortion costs that have the smallest relative values ​​and whose corresponding coefficient sequences maintain the sign values ​​of the first two non-zero coefficients. We then add 1 to the first absolute value of the corresponding coefficients of these two costs, using them as the second adjustment scheme, and the sum of the two is taken as the second candidate rate-distortion cost. The determination of the fourth adjustment scheme is similar and will not be elaborated further.

[0118] After obtaining these first to fourth adjustment schemes, the final adjustment scheme can be selected by comparing the rate distortion costs of the first to fourth candidate schemes, thus achieving the orderly determination of the adjustment schemes.

[0119] It should be noted that, for the sake of explaining how to determine the adjustment scheme and the corresponding rate distortion cost, the first index was introduced earlier as the sum of the first absolute values ​​of the coefficients in the first coefficient sequence divided by 2. N The condition for the remainder obtained is not a conditional limitation on the above scheme. Under other preset processing conditions, as long as the target adjustment amount is 1, -1, 2 or -2, the above scheme can still be used to determine the adjustment scheme and the corresponding rate distortion cost.

[0120] Figure 6 This is a flowchart illustrating a decoding method according to exemplary embodiments of the present disclosure. It should be understood that the decoding method according to exemplary embodiments of the present disclosure can be implemented in terminal devices such as smartphones, tablets, and personal computers (PCs), or in devices such as servers.

[0121] Reference Figure 6 In step 601, the encoding information of the target CG block is parsed to obtain the target coefficient sequence. The target coefficient sequence includes the absolute value of each coefficient in the target CG block and the sign values ​​of all coefficients except the first N non-zero coefficients, where N is an integer greater than 1. At this point, the sign values ​​of the first N non-zero coefficients are still unknown.

[0122] Optionally, the encoding information of the target CG block is obtained by encoding using the encoding method according to the exemplary embodiments of this disclosure, and thus possesses all the beneficial technical effects of the encoding method, which will not be elaborated further here.

[0123] In step 602, a reference index for the target coefficient sequence is determined, wherein the reference index is a value obtained by pre-processing the absolute values ​​of each coefficient in the target coefficient sequence. A description of the pre-processing is provided in the encoding method section according to exemplary embodiments of this disclosure, and will not be repeated here.

[0124] In step 603, the sign values ​​of the first N non-zero coefficients in the target coefficient sequence are determined by searching a preset sign index table using a reference index. The preset sign index table indicates the expected correspondence between the sign values ​​of the first N non-zero coefficients in the coefficient sequence of the CG block and their sign indices. The sign index is a value obtained by pre-processing the absolute value of each coefficient in the coefficient sequence. By combining the reference index with searching the preset sign index table, the sign values ​​of the first N non-zero coefficients can be quickly determined, achieving reliable decoding.

[0125] Figure 7 This is a block diagram illustrating an encoding apparatus according to exemplary embodiments of the present disclosure. It should be understood that the encoding apparatus according to exemplary embodiments of the present disclosure can be implemented in terminal devices such as smartphones, tablets, and personal computers (PCs) in a software, hardware, or software-hardware combination manner, or in devices such as servers.

[0126] Reference Figure 7 The encoding device 700 includes an acquisition unit 701, a determination unit 702, and an encoding unit 703.

[0127] The acquisition unit 701 can acquire the first coefficient sequence of the CG block to be encoded, wherein the first coefficient sequence includes the first absolute value and the first sign value of each coefficient in the CG block to be encoded.

[0128] The determining unit 702 can determine the first index of the first coefficient sequence and the first sign value of the first N non-zero coefficients, wherein the first index is the value obtained after pre-processing each first absolute value, and N is an integer greater than 1.

[0129] The determining unit 702 can also determine the final second absolute value and second sign value of each coefficient in the first coefficient sequence based on the comparison between the first index and the first sign value of the first N non-zero coefficients and the preset sign index table, thereby obtaining the second coefficient sequence. The preset sign index table indicates the expected correspondence between the first sign value of the first N non-zero coefficients in the first coefficient sequence and the first index.

[0130] Optionally, the preset symbol index table is established through the following steps: determining the possible combinations of the first symbol values ​​of the first N non-zero coefficients in the first coefficient sequence as symbol combinations to be counted, and determining the possible values ​​of the first index as indexes to be counted; acquiring multiple historical CG blocks, and for each historical CG block, acquiring the historical coefficient sequence and historical index of the historical CG block to obtain multiple historical coefficient sequences and multiple historical indices, wherein each historical coefficient sequence includes the absolute value and symbol value of each coefficient in the historical CG block, and each historical index is the value obtained after pre-processing the absolute value of each coefficient in the historical coefficient sequence; based on the multiple historical coefficient sequences, calculating the probability of occurrence of each symbol combination to be counted as the symbol combination probability; based on the multiple historical indices, calculating the probability of occurrence of each index to be counted as the index probability; and determining the correspondence between each symbol combination to be counted and each index to be counted according to the symbol combination probability and the index probability to obtain the preset symbol index table.

[0131] The encoding unit 703 can encode the second coefficient sequence to obtain the encoding information of the CG block to be encoded, wherein the second sign value of the first N non-zero coefficients of the second coefficient sequence is not encoded.

[0132] Optionally, the determining unit 702 may also, if the first sign value of the first index and the first N non-zero coefficients is consistent with the preset sign index table, use the first coefficient sequence as the second coefficient sequence; if the first sign value of the first index and the first N non-zero coefficients is inconsistent with the preset sign index table, adjust the value of at least one coefficient in the first coefficient sequence to obtain the second coefficient sequence.

[0133] Optionally, the preset processing is a process of summing and then transforming. The determining unit 702 can also find the preset sign index table by using the first sign value of the first N non-zero coefficients of the first coefficient sequence to determine the second index; determine the target adjustment amount of the sum of each first absolute value according to the difference between the first index and the second index; and adjust the first absolute value of at least one coefficient in the first coefficient sequence according to the target adjustment amount, while keeping the sign value of the first N non-zero coefficients unchanged, to obtain the second coefficient sequence.

[0134] Optionally, the determining unit 702 may also determine the adjustment amount with the smallest adjustment range of the sum of each first absolute value based on the difference between the first index and the second index, combined with preset processing, as the target adjustment amount.

[0135] Optionally, the determining unit 702 may also denote the portion of the first coefficient sequence from the first non-zero coefficient to the last non-zero coefficient as the sequence segment to be adjusted, and, on the premise of keeping the sign values ​​of the first N non-zero coefficients unchanged, adjust the first absolute value of at least one coefficient in the sequence segment to be adjusted according to the target adjustment amount to obtain the second coefficient sequence.

[0136] Optionally, the determining unit 702 may also keep the sign values ​​of the first N non-zero coefficients unchanged, and determine at least one adjustment scheme and the corresponding rate distortion cost of the sequence segment to be adjusted according to the target adjustment amount; based on the rate distortion cost corresponding to each adjustment scheme, determine one adjustment scheme from at least one adjustment scheme, and use the determined adjustment scheme to adjust the sequence segment to be adjusted accordingly to obtain the second coefficient sequence.

[0137] Optionally, at least one adjustment scheme satisfies the following: when adjusting the first absolute value of at least one coefficient among the first N non-zero coefficients without adjusting the zero coefficients before the Nth non-zero coefficient, the second sign value of the adjusted coefficient is kept equal to the first sign value, and the adjusted coefficient remains unchanged at 0; when adjusting other non-zero coefficients in the sequence segment to be adjusted other than the first N non-zero coefficients, the second sign value of the adjusted coefficient is kept equal to the first sign value or the adjusted coefficient is adjusted to 0; when the target adjustment amount is negative, the non-zero coefficients in the sequence segment to be adjusted are adjusted.

[0138] Optionally, when N is 2, the determining unit 702 may further determine, when the target adjustment amount is 2 or -2, a first rate distortion cost after adding 2 to the first absolute value of each of at least one coefficient in the sequence segment to be adjusted, a second rate distortion cost after adding 1 to the first absolute value of each of at least two coefficients in the sequence segment to be adjusted, a third rate distortion cost after subtracting 2 from the first absolute value of each coefficient in the sequence segment to be adjusted whose first absolute value is greater than or equal to 2, and a fourth rate distortion cost after subtracting 1 from the first absolute value of each of at least two non-zero coefficients in the sequence segment to be adjusted; determine a first rate distortion cost from at least one first rate distortion cost as a first candidate rate distortion cost, and set the first absolute value of the coefficient corresponding to the first candidate rate distortion cost as the first absolute value of the coefficient. Add 2 to the value as the first adjustment scheme; determine the sum of two second rate distortion costs from at least two second rate distortion costs as the second candidate rate distortion cost, and add 1 to the first absolute value of the two coefficients corresponding to the second candidate rate distortion cost as the second adjustment scheme; determine a third rate distortion cost from at least one third rate distortion cost as the third candidate rate distortion cost, and subtract 2 from the first absolute value of the coefficient corresponding to the third candidate rate distortion cost as the third adjustment scheme; determine the sum of two fourth rate distortion costs from at least two fourth rate distortion costs as the fourth candidate rate distortion cost, and subtract 1 from the first absolute value of the two coefficients corresponding to the fourth candidate rate distortion cost as the fourth adjustment scheme.

[0139] Optionally, when N is 2, the determining unit 702 may further adjust the coefficients between the first two non-zero coefficients in the first coefficient sequence by 1 in the direction consistent with the first sign value of the second non-zero coefficient, adjust the non-zero coefficients in the sequence segment to be adjusted by 1 in the direction consistent with their own first sign value, and add 1 and / or subtract 1 from the other coefficients in the sequence segment to be adjusted, thereby obtaining at least one adjustment scheme and determining the rate distortion cost corresponding to at least one adjustment scheme; when the target adjustment amount is -1, adjust the non-zero coefficients in the sequence segment to be adjusted by 1 in the direction opposite to their own first sign value, thereby obtaining at least one adjustment scheme and determining the rate distortion cost corresponding to at least one adjustment scheme.

[0140] Optionally, the determining unit 702 may further determine the first index of the first coefficient sequence and the first sign value of the first N non-zero coefficients when the first coefficient sequence satisfies the preset conditions, wherein the preset conditions include at least one of the following: the number of non-zero coefficients in the first coefficient sequence is greater than or equal to a first preset number, and the number of coefficients between the first non-zero coefficient and the last non-zero coefficient in the first coefficient sequence is greater than or equal to a second preset number.

[0141] Figure 8This is a block diagram illustrating a decoding apparatus according to exemplary embodiments of the present disclosure. It should be understood that the decoding apparatus according to exemplary embodiments of the present disclosure can be implemented in terminal devices such as smartphones, tablets, and personal computers (PCs) in a software, hardware, or software-hardware combination manner, or in devices such as servers.

[0142] Reference Figure 8 The decoding device 800 includes a parsing unit 801, a determining unit 802, and a searching unit 803.

[0143] The parsing unit 801 can parse the encoding information of the target CG block to obtain the target coefficient sequence. The target coefficient sequence includes the absolute value of each coefficient in the target CG block and the sign value of the other coefficients except for the first N non-zero coefficients, where N is an integer greater than 1.

[0144] Optionally, the encoding information of the target CG block is obtained by encoding using the encoding method of this disclosure.

[0145] The determining unit 802 can determine the reference index of the target coefficient sequence, wherein the reference index is the value obtained after pre-processing the absolute value of each coefficient in the target coefficient sequence.

[0146] The lookup unit 803 can refer to the reference index to look up the preset symbol index table and determine the symbol values ​​of the first N non-zero coefficients in the target coefficient sequence. The preset symbol index table indicates the expected correspondence between the symbol values ​​of the first N non-zero coefficients in the coefficient sequence of the CG block and the symbol index. The symbol index is the value obtained after preset processing of the absolute value of each coefficient in the coefficient sequence.

[0147] Regarding the apparatus in the above embodiments, the specific manner in which each unit performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0148] Figure 9 This is a block diagram of an electronic device according to exemplary embodiments of the present disclosure.

[0149] Reference Figure 9 The electronic device 900 includes at least one memory 901 and at least one processor 902. The at least one memory 901 stores a set of computer-executable instructions. When the set of computer-executable instructions is executed by the at least one processor 902, an encoding method or a decoding method according to an exemplary embodiment of the present disclosure is performed.

[0150] As an example, electronic device 900 may be a PC, tablet, personal digital assistant, smartphone, or other device capable of executing the aforementioned set of instructions. Here, electronic device 900 is not necessarily a single electronic device, but may be any collection of devices or circuits capable of executing the aforementioned instructions (or instruction sets) individually or in combination. Electronic device 900 may also be part of an integrated control system or system manager, or may be configured to interconnect with a portable electronic device locally or remotely (e.g., via wireless transmission) through an interface.

[0151] In electronic device 900, processor 902 may include a central processing unit (CPU), a graphics processing unit (GPU), a programmable logic device, a dedicated processor system, a microcontroller, or a microprocessor. By way of example and not limitation, processor may also include analog processors, digital processors, microprocessors, multi-core processors, processor arrays, network processors, etc.

[0152] The processor 902 can execute instructions or code stored in the memory 901, which can also store data. Instructions and data can also be sent and received via a network through a network interface device, which can employ any known transmission protocol.

[0153] The memory 901 may be integrated with the processor 902, for example, by placing RAM or flash memory within an integrated circuit microprocessor. Alternatively, the memory 901 may include a separate device, such as an external disk drive, a storage array, or other storage device usable by any database system. The memory 901 and the processor 902 may be operatively coupled, or may communicate with each other, for example, via I / O ports, network connections, etc., enabling the processor 902 to read files stored in the memory.

[0154] In addition, the electronic device 900 may also include a video display (such as a liquid crystal display) and a user interaction interface (such as a keyboard, mouse, touch input device, etc.). All components of the electronic device 900 can be interconnected via a bus and / or network.

[0155] According to exemplary embodiments of the present disclosure, a computer-readable storage medium may also be provided, which, when instructions in the computer-readable storage medium are executed by at least one processor, causes at least one processor to perform an encoding method or a decoding method according to exemplary embodiments of the present disclosure. Examples of computer-readable storage media herein include: read-only memory (ROM), random access programmable read-only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), flash memory, non-volatile memory, CD-ROM, CD-R, CD+R, CD-RW, CD+RW, DVD-ROM, DVD-R, DVD+R, DVD-RW, DVD+RW, DVD-RAM, BD-ROM, BD-R, BD-R LTH, BD-RE, Blu-ray or optical disc storage, hard disk drive (HDD), solid-state drive (SSD), card storage (such as multimedia cards, secure digital (SD) cards, or ultra-fast digital (XD) cards), magnetic tape, floppy disk, magneto-optical data storage device, optical data storage device, hard disk, solid-state drive, and any other device configured to store a computer program and any associated data, data files, and data structures in a non-transitory manner and to provide the computer program and any associated data, data files, and data structures to a processor or computer so that the processor or computer can execute the computer program. The computer program in the aforementioned computer-readable storage medium can run in an environment deployed in computer devices such as clients, hosts, agent devices, servers, etc. Furthermore, in one example, the computer program and any associated data, data files, and data structures are distributed across a networked computer system, such that the computer program and any associated data, data files, and data structures are stored, accessed, and executed in a distributed manner through one or more processors or computers.

[0156] According to exemplary embodiments of the present disclosure, a computer program product may also be provided, the computer program product including computer instructions, which, when executed by at least one processor, cause at least one processor to perform an encoding method or a decoding method according to exemplary embodiments of the present disclosure.

[0157] The encoding method, decoding method, and apparatus according to exemplary embodiments of the present disclosure break with conventional thinking. By introducing an index related to the absolute value of the coefficient sequence and establishing a preset relationship between the index and the symbols of the first at least two non-zero coefficients in the coefficient sequence, the symbols of the first at least two non-zero coefficients can be hidden based on the preset relationship, thereby effectively reducing redundancy between coefficients and helping to improve encoding performance.

[0158] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0159] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. An encoding method characterized by comprising: The method comprises: obtaining a first coefficient sequence of a to-be-encoded CG block, wherein the first coefficient sequence comprises a first absolute value and a first sign value of each coefficient in the to-be-encoded CG block; determining a first index of the first coefficient sequence and a first sign value of the first N non-zero coefficients, wherein the first index is a value obtained by performing a preset processing on each first absolute value, N is an integer greater than 1, and the preset processing is a processing of summing first and then calculating the sum value, so that the number of values of the obtained first index is greater than or equal to the number of combinations of the sign values of the first N non-zero coefficients; determining a second absolute value and a second sign value of each coefficient in the first coefficient sequence based on a comparison between the first index and the first sign value of the first N non-zero coefficients and a preset sign index table, to obtain a second coefficient sequence, wherein the preset sign index table indicates an expected correspondence between the first sign value of the first N non-zero coefficients in the first coefficient sequence and the first index; encoding the second coefficient sequence to obtain encoding information of the to-be-encoded CG block, wherein the second sign value of the first N non-zero coefficients in the second coefficient sequence is not encoded.

2. The encoding method of claim 1, wherein, The method further comprises: in a case where the first index and the first sign value of the first N non-zero coefficients are consistent with the preset sign index table, taking the first coefficient sequence as the second coefficient sequence; in a case where the first index and the first sign value of the first N non-zero coefficients are inconsistent with the preset sign index table, adjusting a value of at least one coefficient in the first coefficient sequence to obtain the second coefficient sequence.

3. The encoding method of claim 2, wherein, The preset sign index table is established by the following steps: determining each possible combination of the first sign value of the first N non-zero coefficients in the first coefficient sequence as a to-be-counted sign combination, and determining each possible value of the first index as a to-be-counted index; obtaining a plurality of historical CG blocks, and for each historical CG block, obtaining a historical coefficient sequence and a historical index of the historical CG block to obtain a plurality of historical coefficient sequences and a plurality of historical indexes, wherein each historical coefficient sequence comprises an absolute value and a sign value of each coefficient in the historical CG block, and each historical index is a value obtained by performing the preset processing on the absolute value of each coefficient in the historical coefficient sequence; based on the plurality of historical coefficient sequences, counting a probability of occurrence of each to-be-counted sign combination as a sign combination probability; based on the plurality of historical indexes, counting a probability of occurrence of each to-be-counted index as an index probability; determining a correspondence between each to-be-counted sign combination and each to-be-counted index according to the sign combination probability and the index probability to obtain the preset sign index table.

4. The encoding method of claim 2, wherein, The method further comprises: adjusting a value of at least one coefficient in the first coefficient sequence to obtain the second coefficient sequence. determining a second index by searching the preset sign index table according to first sign values of the first N non-zero coefficients of the first coefficient sequence; determining a target adjustment amount of the sum of the first absolute values according to a difference between the first index and the second index; adjusting the first absolute values of at least one coefficient in the first coefficient sequence according to the target adjustment amount to obtain the second coefficient sequence, with a premise that sign values of the first N non-zero coefficients remain unchanged.

5. The encoding method of claim 4, wherein, The determining a target adjustment amount of the sum of the first absolute values according to a difference between the first index and the second index comprises: determining, according to the difference between the first index and the second index and in combination with the preset processing, an adjustment amount with a minimum adjustment amplitude of the sum of the first absolute values as the target adjustment amount.

6. The encoding method of claim 4, wherein, The adjusting the first absolute values of at least one coefficient in the first coefficient sequence according to the target adjustment amount to obtain the second coefficient sequence, with a premise that sign values of the first N non-zero coefficients remain unchanged, comprises: regarding a part of the first coefficient sequence from the first non-zero coefficient to the last non-zero coefficient as a sequence segment to be adjusted, and adjusting the first absolute values of at least one coefficient in the sequence segment to be adjusted according to the target adjustment amount to obtain the second coefficient sequence, with a premise that sign values of the first N non-zero coefficients remain unchanged.

7. The encoding method of claim 6, wherein, The adjusting the first absolute values of at least one coefficient in the sequence segment to be adjusted according to the target adjustment amount to obtain the second coefficient sequence, with a premise that sign values of the first N non-zero coefficients remain unchanged, comprises: determining at least one adjustment scheme of the sequence segment to be adjusted and a corresponding rate-distortion cost according to the target adjustment amount, with a premise that sign values of the first N non-zero coefficients remain unchanged; determining an adjustment scheme from the at least one adjustment scheme according to the rate-distortion cost corresponding to each adjustment scheme, and performing corresponding adjustment on the sequence segment to be adjusted by using the determined adjustment scheme to obtain the second coefficient sequence.

8. The encoding method of claim 7, wherein, The at least one adjustment scheme satisfies: in a case of adjusting the first absolute values of at least one coefficient in the first N non-zero coefficients and not adjusting a zero coefficient before the Nth non-zero coefficient, keeping a second sign value of the adjusted coefficient equal to a first sign value, and keeping the adjusted coefficient unchanged from 0; in a case of adjusting a non-zero coefficient other than the first N non-zero coefficients in the sequence segment to be adjusted, keeping a second sign value of the adjusted coefficient equal to a first sign value or adjusting the adjusted coefficient to 0; in a case that the target adjustment amount is a negative value, adjusting a non-zero coefficient in the sequence segment to be adjusted.

9. The encoding method of claim 7, wherein, N is 2, and the determining at least one adjustment scheme of the sequence segment to be adjusted and a corresponding rate-distortion cost according to the target adjustment amount comprises: In a case where the target adjustment amount is 2 or -2, a first rate-distortion cost of each first absolute value of at least one coefficient in the to-be-adjusted sequence segment plus 2, a second rate-distortion cost of each first absolute value of at least two coefficients in the to-be-adjusted sequence segment plus 1, a third rate-distortion cost of each first absolute value of a coefficient in the to-be-adjusted sequence segment greater than or equal to 2 minus 2, and a fourth rate-distortion cost of each first absolute value of at least two non-zero coefficients in the to-be-adjusted sequence segment minus 1 are determined. A first rate-distortion cost is determined from at least one first rate-distortion cost as a first candidate rate-distortion cost, and a first absolute value of a coefficient corresponding to the first candidate rate-distortion cost is added by 2 as a first adjustment scheme. A sum of two second rate-distortion costs is determined from at least two second rate-distortion costs as a second candidate rate-distortion cost, and first absolute values of two coefficients corresponding to the second candidate rate-distortion cost are added by 1 respectively as a second adjustment scheme. A third rate-distortion cost is determined from at least one third rate-distortion cost as a third candidate rate-distortion cost, and a first absolute value of a coefficient corresponding to the third candidate rate-distortion cost is subtracted by 2 as a third adjustment scheme. A sum of two fourth rate-distortion costs is determined from at least two fourth rate-distortion costs as a fourth candidate rate-distortion cost, and first absolute values of two coefficients corresponding to the fourth candidate rate-distortion cost are subtracted by 1 respectively as a fourth adjustment scheme.

10. The encoding method of claim 7, wherein, N is 2, and the at least one adjustment scheme and the corresponding rate-distortion cost of the to-be-adjusted sequence segment are determined according to the target adjustment amount on the premise that the sign values of the first N non-zero coefficients are kept unchanged, including: In a case where the target adjustment amount is 1, each coefficient between the first two non-zero coefficients in the first coefficient sequence is adjusted by 1 in a direction consistent with the first sign value of the second non-zero coefficient, a non-zero coefficient in the to-be-adjusted sequence segment is adjusted by 1 in a direction consistent with the first sign value of the non-zero coefficient, and other coefficients in the to-be-adjusted sequence segment are added by 1 and / or subtracted by 1 to obtain the at least one adjustment scheme, and a rate-distortion cost corresponding to the at least one adjustment scheme is determined. In a case where the target adjustment amount is -1, a non-zero coefficient in the to-be-adjusted sequence segment is adjusted by 1 in a direction opposite to the first sign value of the non-zero coefficient to obtain the at least one adjustment scheme, and a rate-distortion cost corresponding to the at least one adjustment scheme is determined.

11. The encoding method of any one of claims 1 to 10, wherein, The first index of the first coefficient sequence and the first sign values of the first N non-zero coefficients are determined, including: In a case where the first coefficient sequence satisfies a preset condition, the first index of the first coefficient sequence and the first sign values of the first N non-zero coefficients are determined, wherein the preset condition includes at least one of the following: the number of non-zero coefficients in the first coefficient sequence is greater than or equal to a first preset number, and the number of coefficients between the first non-zero coefficient and the last non-zero coefficient in the first coefficient sequence is greater than or equal to a second preset number.

12. A decoding method, comprising: including: Analyzing coding information of a target CG block to obtain a target coefficient sequence, wherein the coding information of the target CG block is obtained by the coding method in any one of claims 1 to 11, and the target coefficient sequence comprises absolute values of each coefficient in the target CG block and sign values of other coefficients except for the first N non-zero coefficients, N being an integer greater than 1; Determining a reference index of the target coefficient sequence, wherein the reference index is a value obtained by performing the preset processing on the absolute values of each coefficient in the target coefficient sequence; Looking up a preset sign index table through the reference index to determine the sign values of the first N non-zero coefficients in the target coefficient sequence, wherein the preset sign index table indicates an expected correspondence between the sign values of the first N non-zero coefficients in a coefficient sequence of a CG block and a sign index, and the sign index is a value obtained by performing the preset processing on the absolute values of each coefficient in the coefficient sequence.

13. An encoding apparatus, comprising: Comprise: An acquisition unit configured to acquire a first coefficient sequence of a CG block to be encoded, wherein the first coefficient sequence comprises first absolute values of each coefficient in the CG block to be encoded and first sign values; A determination unit configured to determine a first index of the first coefficient sequence and first sign values of the first N non-zero coefficients, wherein the first index is a value obtained by performing a preset processing on each first absolute value, N being an integer greater than 1, and the preset processing is a processing of summing first and then calculating the sum value, so that the number of values of the first index obtained is greater than or equal to the number of combinations of the sign values of the first N non-zero coefficients; The determination unit is further configured to determine second absolute values and second sign values of each coefficient in the first coefficient sequence based on a comparison between the first index and the first sign values of the first N non-zero coefficients and a preset sign index table, to obtain a second coefficient sequence, wherein the preset sign index table indicates an expected correspondence between the first sign values of the first N non-zero coefficients in the first coefficient sequence and the first index; An encoding unit configured to encode the second coefficient sequence to obtain coding information of the CG block to be encoded, wherein the second sign values of the first N non-zero coefficients in the second coefficient sequence are not encoded.

14. A decoding apparatus, characterized by comprising: Comprise: An analysis unit configured to analyze coding information of a target CG block to obtain a target coefficient sequence, wherein the coding information of the target CG block is obtained by the coding method in any one of claims 1 to 11, and the target coefficient sequence comprises absolute values of each coefficient in the target CG block and sign values of other coefficients except for the first N non-zero coefficients, N being an integer greater than 1; A determination unit configured to determine a reference index of the target coefficient sequence, wherein the reference index is a value obtained by performing the preset processing on the absolute values of each coefficient in the target coefficient sequence; The searching unit is configured to search a preset sign index table by using the reference index to determine the sign values of the first N non-zero coefficients in the target coefficient sequence, wherein the preset sign index table indicates an expected correspondence between the sign values of the first N non-zero coefficients in the coefficient sequence of the CG block and sign indexes, and the sign indexes are values obtained by performing the preset processing on the absolute values of the respective coefficients in the coefficient sequence.

15. An electronic device, comprising: Comprise: at least one processor; at least one memory storing computer-executable instructions, wherein the computer-executable instructions, when executed by the at least one processor, cause the at least one processor to perform the encoding method of any one of claims 1 to 11 or the decoding method of claim 12.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium, when the instructions in the computer-readable storage medium are executed by at least one processor, cause the at least one processor to perform the encoding method of any one of claims 1 to 11 or the decoding method of claim 12.

Citation Information

Patent Citations

  • Improved transformation coefficient sign data hiding method based on recovered transformation coefficient

    CN105898300A