A compression method, apparatus, device, and medium

By optimizing the joint process of quantization and entropy coding and adjusting the quantization result to avoid codeword length jumps, the problem of high bit rate in existing technologies is solved, and the bit rate is reduced and the entropy coding efficiency is improved while ensuring image quality.

CN122269031APending Publication Date: 2026-06-23HUNAN GOKE MICROELECTRONICS CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUNAN GOKE MICROELECTRONICS CO LTD
Filing Date
2026-05-27
Publication Date
2026-06-23

Smart Images

  • Figure CN122269031A_ABST
    Figure CN122269031A_ABST
Patent Text Reader

Abstract

The application discloses a compression method, device, equipment and medium, and relates to the technical field of data compression. The method comprises the following steps: quantizing a current to-be-compressed source symbol by using a quantization parameter to obtain a current quantization result; if the current quantization result meets a preset condition, adjusting the current quantization result, so that the final adjusted quantization result belongs to the Nth interval before or after the interval where the current quantization result is located; wherein N is a positive integer greater than or equal to 1, and the original code words of a plurality of to-be-encoded values in the same interval have the same preset bits. The application jointly optimizes quantization and entropy coding. When the current quantization result meets the preset condition, the current quantization result is actively adjusted, the final adjusted quantization result falls into an interval with higher coding efficiency, the length jump of code words of a code table at a critical point can be avoided, redundant bits are directly reduced, and the code rate is significantly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data compression technology, and in particular to a compression method, apparatus, device, and medium. Background Technology

[0002] In lossy image / video compression algorithms, quantization and entropy coding are two core steps. Typically, the source symbols are first quantized, and then the quantization result is entropy-coded to obtain the final compressed result.

[0003] Currently, the quantization process and the entropy coding process are independent of each other. Quantization only completes the numerical mapping based on the quantization parameters, without combining the code table characteristics and codeword distribution patterns of entropy coding for optimization. Taking the exponential Golomb coding process as an example, by observing the code table of exponential Golomb coding, it can be found that the codeword length will jump at the critical point of the interval of the value to be encoded, and a small numerical difference will lead to a significant increase in the code rate.

[0004] In summary, how to jointly optimize quantization and entropy coding to further reduce the bit rate while ensuring image quality is a problem that needs to be solved. Summary of the Invention

[0005] In view of this, the purpose of this invention is to provide a compression method, apparatus, device, and medium capable of jointly optimizing quantization and entropy coding, thereby further reducing the bitrate while ensuring image quality. The specific solution is as follows: In a first aspect, this application discloses a compression method, comprising: The current source symbol to be compressed is quantized using quantization parameters to obtain the current quantization result; If the current quantization result meets the preset conditions, the current quantization result is adjusted so that the adjusted final quantization result belongs to the Nth interval before or after the interval where the current quantization result is located; where N is a positive integer greater than or equal to 1, and the original codewords of multiple values ​​to be encoded in the same interval have the same preset bit.

[0006] Optionally, the Nth interval includes historical quantization results, and the preset conditions include: The quantization parameter is not greater than a first preset threshold; The current quantization result and the historical quantization result do not belong to the same interval; The amplitude value of the current quantization result is greater than the amplitude value of the historical quantization result; The difference between the amplitude value of the current quantization result and the maximum value of the Nth interval is less than the second preset threshold. The step of adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval before the interval containing the current quantization result includes: The current quantization result is adjusted to the maximum encoded value of the Nth interval.

[0007] Optionally, the preset conditions include: The quantization parameter is not greater than a first preset threshold; The difference between the amplitude value of the current quantization result and the maximum value of the Nth interval is less than the second preset threshold. The step of adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval preceding the interval containing the current quantization result includes: The current quantization result is adjusted to the maximum encoded value of the Nth interval preceding the interval containing the current quantization result.

[0008] Optionally, the Nth interval includes historical quantization results, and the preset conditions include: The quantization parameter is not greater than a first preset threshold; The current quantization result and the historical quantization result do not belong to the same interval; The amplitude value of the historical quantization result is greater than the amplitude value of the current quantization result; The difference between the minimum value of the Nth interval and the amplitude value of the current quantization result is less than the second preset threshold. The step of adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval after the interval where the current quantization result is located includes: The current quantization result is adjusted to the minimum encoded value of the Nth interval.

[0009] Optionally, the method further includes: If the current quantization result does not meet the preset conditions, then the current quantization result is the final quantization result.

[0010] Optionally, the original codewords of multiple values ​​to be encoded within the same interval also have the same length.

[0011] Optionally, the method further includes: The adjusted final quantization result is encoded to obtain the encoded result; The encoding result includes a flag codeword and a suffix codeword. The flag codeword indicates that the adjusted final quantization result belongs to the same interval as any other encoded result in the Nth interval. The suffix codeword includes the original codeword of the adjusted final quantization result, excluding the preset codeword.

[0012] Secondly, this application discloses a compression device, comprising: The quantization module is used to quantize the current source symbols to be compressed using quantization parameters to obtain the current quantization result; An adjustment module is used to adjust the current quantization result if the current quantization result meets a preset condition, so that the adjusted final quantization result belongs to the Nth interval before or after the interval where the current quantization result is located; wherein, N is a positive integer greater than or equal to 1, and the original codewords of multiple values ​​to be encoded in the same interval have the same preset bit.

[0013] Thirdly, this application discloses an electronic device, including: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the aforementioned disclosed compression method.

[0014] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed compression method.

[0015] As can be seen, this application quantizes the current source symbol to be compressed using quantization parameters to obtain the current quantization result; if the current quantization result meets the preset conditions, the current quantization result is adjusted so that the adjusted final quantization result belongs to the Nth interval before or after the interval where the current quantization result is located; where N is a positive integer greater than or equal to 1, and the original codewords of multiple values ​​to be encoded in the same interval have the same preset bit.

[0016] Beneficial Effects: This application jointly optimizes quantization and entropy coding, proactively adjusting the current quantization result when it meets preset conditions. This ensures the adjusted final quantization result falls within a range with higher coding efficiency and better bitstream saving, avoiding codeword length jumps at critical points in the code table, directly reducing redundant bits, and significantly lowering the bitrate. Furthermore, this application adjusts the current quantization result only when preset conditions are met, avoiding indiscriminate quantization result modifications and ensuring the rationality of quantization adjustments. Additionally, it should be noted that since the original codewords of multiple values ​​to be encoded within the same range have the same preset bits, in some cases, the adjusted final quantization result can reuse the common part of the range codewords, avoiding repeated encoding of the same codeword portion and effectively shortening the bitstream length. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0018] Figure 1 This is a flowchart of a compression method disclosed in this application; Figure 2 The intention of representing a partial code of the standard index Columbus encoding; Figure 3 This is a schematic diagram of an improved entropy coding scheme disclosed in this application when the order k is 0. Figure 4 This is a schematic diagram of an improved entropy coding scheme for an order k of 1 disclosed in this application; Figure 5 This is a schematic diagram of a compression device disclosed in this application; Figure 6 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0020] Currently, the quantization process and the entropy coding process are independent. Quantization only completes the numerical mapping based on the quantization parameters, without combining the code table characteristics and codeword distribution patterns of entropy coding for optimization. Taking the exponential Golomb coding process as an example, by observing the code table of exponential Golomb coding, it can be found that the codeword length jumps at the critical points of the interval, and small numerical differences can lead to a significant increase in the code rate. To address this, embodiments of this application disclose a compression method, apparatus, device, and medium that can jointly optimize quantization and entropy coding, thereby further reducing the code rate while ensuring image quality.

[0021] See Figure 1 As shown in the figure, this application discloses a compression method, which includes: Step S11: Quantize the current source symbol to be compressed using quantization parameters to obtain the current quantization result.

[0022] It should be noted that in lossy image / video compression, the source symbols are typically quantized first, and then the quantization result is entropy encoded to obtain the final compression result. When performing the quantization step, the quantization parameter (QP) must first be determined according to a certain method and strategy. Then, the quantization parameter is used to quantize the current source symbol to be compressed, obtaining the current quantization result.

[0023] QP is a key parameter controlling the quantization step size, determining the fineness of the quantization process. A smaller QP value results in a smaller quantization step size, less quantization loss, and higher image / video reconstruction quality, but also a higher bitrate. Conversely, a larger QP value results in a larger quantization step size, greater quantization loss, and a lower bitrate, but also a corresponding decrease in image quality. In specific implementations, a fixed QP value can be used empirically in testing or specific application scenarios to simplify the encoding control process. Alternatively, the QP value can be adaptively determined based on rate-distortion optimization, human visual characteristics, or bitrate control algorithms. Furthermore, QP can be dynamically adjusted based on features such as image texture complexity, motion intensity, and scene transition detection. For example, a larger QP can be assigned to areas with intense motion, while a smaller QP can be assigned to static areas. Therefore, the method for determining QP can be flexibly selected and combined according to specific application scenarios, and this application does not impose any limitations on this.

[0024] Furthermore, in lossy image or video compression, source symbols are the basic information units output from the image source that can be encoded. Their core function is to convert the visual information of the image (such as grayscale, color, pixel relationships, etc.) into quantifiable and coded symbolic forms, providing a foundation for subsequent redundancy elimination and efficient transmission. Source symbols can include original source symbols, i.e., basic symbols directly obtained from image acquisition devices (cameras and other visual electronic devices, etc.) without any transformation processing, directly corresponding to the original visual information of the image; source symbols can also include transformed source symbols (or new source symbols), i.e., coefficients obtained after transforming the original image (such as discrete cosine transform, wavelet transform, etc.), or error information generated after prediction / transformation of the original source symbols. For example, in one embodiment, the source symbol is the residual correlation data of the image, i.e., data related to the difference between the original pixel value and the predicted pixel value. This is the most common form of source symbol in video coding, such as intra-frame prediction residual and inter-frame prediction residual. Of course, in another embodiment, the source symbols can also be related to the transform values ​​of the image residuals, and the same technical effect can be achieved using this technical solution. Furthermore, the source symbols can also be symbolic information (such as coding block flags, mode selection flags, etc.), audio signals, video motion information, etc. For non-numerical source symbols, such as symbolic information, they can be first mapped to index values ​​or numerical values ​​before quantization.

[0025] Step S12: If the current quantization result meets the preset conditions, then adjust the current quantization result so that the adjusted final quantization result belongs to the Nth interval before or after the interval where the current quantization result is located; where N is a positive integer greater than or equal to 1, and the original codewords of multiple values ​​to be encoded within the same interval have the same preset bit. Of course, the value of N should not be too large, as a large value will cause the adjustment of the current quantization result to be too large, affecting the subsequent encoding and decoding quality of the image.

[0026] In one specific implementation, if the current quantization result does not meet the preset conditions, then the current quantization result is the final quantization result. That is, this application only adjusts the current quantization result when the preset conditions are met; if the current quantization result does not meet the preset conditions, it directly uses the current quantization result as the final quantization result. This method avoids indiscriminate modification of the quantization result and ensures the rationality of the quantization adjustment.

[0027] In another specific implementation, if the current quantization result meets preset conditions, the current quantization result is actively adjusted so that the adjusted final quantization result falls into a range with higher coding efficiency. This avoids codeword length jumps at critical points in the code table, directly reduces redundant bits, and significantly lowers the code rate, thereby achieving joint optimization of quantization and entropy coding. Specifically, the range into which the final result falls refers to the Nth range before or after the range where the current quantization result is located, where N is a positive integer greater than or equal to 1. It should be noted that since the original codewords of multiple values ​​to be encoded within the same range have the same preset bits, in some cases, the adjusted final quantization result can reuse the common part of the range codewords, avoiding repeated encoding of the same codeword part and effectively shortening the bitstream length. Furthermore, it should be noted that the original codeword refers to the codeword obtained by applying the original entropy coding method to the value to be encoded; that is, an entropy coding method that existed prior to this patent application is considered the original entropy coding method. For example, in one embodiment, the original entropy coding method is the standard exponential Golomb coding method.

[0028] It should also be noted that the original codewords of multiple values ​​to be encoded within the same interval also have the same length. First, let's explain the concept of an interval: [The text abruptly ends here, so the translation stops as well.] Figure 2 Taking a partial code table of the standard exponential Golomb coding shown as an example, where the order k ranges from 0 to 4 and the input non-negative integer X ranges from 0 to 32, observing its code table reveals that the codeword length jumps at certain numerical points. For example, in the 0th order (i.e., k=0, k is the order) exponential Golomb coding, if the value X changes from 2 to 3, increasing by only 1, the codeword length jumps from 3 to 5. Similarly, critical values ​​appear at positions 1, 3, 7, 15, etc. Therefore, this application divides consecutive numerical values ​​with the same codeword length into an interval. The original codewords of multiple values ​​to be encoded within the same interval have the same preset position. Here, the original codewords with the same preset position refer to having the same prefix part and separator (the codeword structure of the standard exponential Golomb coding can be divided into prefix part + separator + suffix part), and multiple values ​​to be encoded within the same interval have the same original codeword length.

[0029] In addition, from Figure 2As can be seen, the division of intervals is related to the order k of the exponential Golomb code, with different k corresponding to different interval divisions. For example, when k=1, the intervals are divided into: 0~1, 2~5, 6~13, 14~29, etc.; when k=2, the intervals are divided into: 0~3, 4~11, 12~27, etc. Therefore, the method of interval division is general and not limited to the above examples.

[0030] Furthermore, for other entropy coding schemes besides exponential Golomb coding, the codeword length distribution can also be analyzed to identify codeword length transition points, thereby dividing intervals. The original codewords of the values ​​to be encoded within the same interval have the same preset bits; these identical bits can be prefixes, prefixes plus separators, or other forms of common codeword segments. That is, as long as other encoding methods result in some identical codewords in the encoded codewords, causing codeword redundancy, interval division can be performed according to the above scheme, thus making it applicable to the scheme of this application and achieving the goal of saving code rate.

[0031] As can be seen, this application jointly optimizes quantization and entropy coding, actively adjusting the current quantization result when it meets preset conditions. This ensures the adjusted final quantization result falls within a more efficient coding range, avoiding codeword length jumps at critical points in the code table, directly reducing redundant bits, and significantly lowering the code rate. Furthermore, this application adjusts the current quantization result only when preset conditions are met, avoiding indiscriminate modification of the quantization result and ensuring the rationality of the quantization adjustment. In addition, it should be noted that since the original codewords of multiple values ​​to be encoded within the same range have the same preset bits, in some cases, the adjusted final quantization result can reuse the common part of the range codewords, avoiding repeated encoding of the same codeword part and effectively shortening the bitstream length.

[0032] Based on the aforementioned embodiments, and still taking the standard exponential Golomb coding as an example, this application improves upon the standard exponential Golomb coding by utilizing the correlation between preceding and following data in the sequence to be coded, thereby obtaining a new entropy coding scheme. This results in entropy coding being more efficient than the original standard exponential Golomb coding in certain situations.

[0033] Understandably, Exponential Golomb coding is a parametric coding method. Given an order k, according to the rules of Exponential Golomb coding, a set of codewords corresponding to order k can be generated. (See reference...) Figure 2 The partial code table of the standard k-order exponential Golomb code, where different orders k correspond to their respective sets of codewords.

[0034] Furthermore, as mentioned above, the code table of the Exponential Golomb coding scheme contains some redundancy between adjacent codewords. For example, in the column where k=0, when the number to be encoded, X, takes values ​​from 3 to 6, the corresponding codewords are 11000 to 11011. The first part of each codeword in this range is 110. If joint encoding is considered, redundant codewords appear. Assuming the current three consecutive values ​​to be encoded in the sequence are 3, 4, and 5, according to standard Exponential Golomb coding, the codewords are 11000, 11001, and 11010, corresponding to a bitstream of 110001100111010, consuming a total of 15 bits. However, 110 appears three times in the bitstream, resulting in wasted bitrate. Therefore, this application optimizes the Exponential Golomb coding scheme to further save on coding bitrate and improve entropy coding efficiency.

[0035] Specifically, the codeword structure of standard exponential Golomb coding can be divided into a prefix part + separator + suffix part. Generally, when using standard exponential Golomb coding, adjacent values ​​to be encoded are encoded independently, each corresponding to its own exponential Golomb codeword. If these two values ​​belong to the same interval of the exponential Golomb codeword (i.e., the prefix part + separator is the same), then the prefix part + separator is encoded twice in the bitstream. If M consecutive values ​​to be encoded belong to the same interval of the exponential Golomb codeword (i.e., the prefix part + separator is the same), then the prefix part + separator is encoded M times in the bitstream, clearly resulting in a waste of bitrate.

[0036] Therefore, the improvement in this application utilizes the correlation between adjacent values ​​to be encoded. If it is found that the next value to be encoded and the previous encoded value belong to the same interval of the exponential Golomb codeword, that is, the prefix part + separator is the same, then the next value to be encoded no longer needs the prefix part + separator part, and the suffix part can be encoded directly. Specifically, the improved entropy coding scheme can be described as follows: Figure 3 As shown in Scheme 1 and Scheme 2, where, Figure 3 This is a schematic diagram of an improved entropy coding scheme disclosed in this application when the order k is 0. Figure 3The paper also presents a comparison between the standard exponential Golomb code and the improved entropy coding scheme at k=0. It can be seen that the code tables of both new entropy coding schemes consist of two parts: a left code table and a right code table. The entropy coding efficiency of the right code table is significantly better than the original exponential Golomb code table, while the left code table is slightly better or slightly worse. It should be noted that the left and right code tables refer to whether, for the current value X to be encoded, the corresponding codeword should be taken from the left or right code table. This requires comparing the current value to be encoded with the previous encoded value. If the current value to be encoded and the previous encoded value belong to the same interval, the corresponding codeword from the right code table is taken; otherwise, the corresponding codeword from the left code table is taken.

[0037] Continuing with the example of three consecutive values ​​to be encoded, 3, 4, and 5, according to Scheme 1, the codewords are 001000, 101, and 110, corresponding to a bitstream of 001000101110, consuming a total of 12 bits, saving 3 bits compared to the standard exponential Golomb code of the same order. According to Scheme 2, the codewords are 011000, 101, and 110, corresponding to a bitstream of 011000101110, consuming a total of 12 bits, also saving 3 bits compared to the standard exponential Golomb code of the same order.

[0038] Furthermore, this application also discloses a schematic diagram of an improved entropy coding scheme when the order k is 1, specifically as shown in the figure. Figure 4 As shown, and Figure 4 The paper also presents a comparison between the standard exponential Golomb code and the improved entropy coding scheme at k=1. Taking three consecutive values ​​to be encoded, 6, 7, and 8, as an example, according to Scheme 1, the codewords are 0010000, 1001, and 1010, respectively, corresponding to a bitstream of 001000010011010, totaling 15 bits, saving 3 bits compared to the standard exponential Golomb code of the same order (110000110001110010). According to Scheme 2, the codewords are 0110000, 1001, and 1010, corresponding to a bitstream of 011000010011010, consuming a total of 15 bits, saving 3 bits compared to the standard exponential Golomb code of the same order.

[0039] Therefore, this application aims to jointly optimize quantization and entropy coding. It guides the quantization operation by incorporating the characteristics of the new entropy coding code table, ensuring that the quantized result utilizes the right-hand code table as much as possible during entropy coding without affecting subjective image quality, thus fully leveraging the coding efficiency of the aforementioned entropy coding scheme. The core objective is to ensure that the quantization process considers the current value to be encoded and the previously encoded value to belong to the same interval, thereby achieving higher entropy coding efficiency.

[0040] Based on the above, this application discloses a specific adjustment method under preset conditions. In one specific embodiment, the Nth interval before or after the current quantization result includes historical quantization results. The preset conditions include: the quantization parameter is not greater than a first preset threshold; the current quantization result and the historical quantization result do not belong to the same interval; the amplitude value of the current quantization result is greater than the amplitude value of the historical quantization result; the difference between the amplitude value of the current quantization result and the maximum value of the Nth interval is less than a second preset threshold. Then, adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval before the interval where the current quantization result is located includes: adjusting the current quantization result to the maximum encoded value of the Nth interval.

[0041] That is, the Nth interval also includes historical quantization results, specifically referring to the quantization results of the previous source symbol to be compressed. Let the quantization parameter be QP, the first preset threshold be TH1, the second preset threshold be TH2, the amplitude of the current quantization result be A1, the amplitude of the historical quantization result be B, and the maximum value of the Nth interval be A2; where the first preset threshold TH1 is less than the second preset threshold TH2. It should be noted that the quantization result is usually an integer, which may be positive, negative, or zero. For subsequent entropy coding (such as exponential Golomb coding), its absolute value, i.e., the amplitude value, needs to be extracted. When the following four conditions are met simultaneously, it is determined that the current quantization result needs adjustment: Condition 1: The quantization parameter QP is not greater than the first preset threshold TH1; Condition 2: The amplitude value A1 of the current quantization result and the amplitude value B of the historical quantization result do not belong to the same interval; Condition 3: The amplitude value A1 of the current quantization result is greater than the amplitude value B of the historical quantization result, i.e., A1 > B; Condition 4: The difference between the amplitude value of the current quantization result A1 and the maximum value A2 of the Nth interval is less than the second preset threshold TH2, i.e., A1-A2 <TH2。

[0042] The Nth interval is the interval containing the amplitude value B of the historical quantization result. This interval has a corresponding maximum value, which is the maximum allowed encoded value within this interval. When all four conditions are met, an adjustment operation is performed, that is, the amplitude value A1 of the current quantization result is adjusted to the maximum encoded value A2 of the interval containing B, and A2 is output as the final quantization result. If any of the above conditions are not met, A1 is output as the final quantization result.

[0043] It needs further explanation that the first preset threshold TH1 in condition 1 can be set according to actual compression requirements. This embodiment does not limit the specific value of TH1. For example, TH1 can be set to 3. By setting the threshold of the quantization parameter, its function is to restrict fine-tuning to only when the quantization step size is small (i.e., the QP is small). When the QP is large, the quantization itself is already relatively coarse, and further forced adjustment of the amplitude value may cause a significant decrease in image quality. When the QP is small, the quantization is finer, and small adjustments of the amplitude value have little impact on subjective quality, while saving codeword length. The second preset threshold TH2 in condition 4 can also be set according to actual compression requirements. This embodiment does not limit the specific value of TH2. For example, TH2 can be set to 5. By setting this threshold, the difference between the amplitude values ​​before and after fine-tuning cannot be too large, otherwise it may introduce obvious distortion. Although reducing the amplitude value can save bitrate, if it is adjusted too much, such as from 14 to 6, the difference is 8, and the image distortion may be obvious.

[0044] Understandably, since the amplitude value A1 of the current quantization result is greater than the amplitude value B of the historical quantization result, and the two are not in the same interval, by reducing A1 to the maximum encoded value of the interval where B is located, the adjusted A2 falls into the same interval as B. In this way, during subsequent entropy coding, A2 can reuse the interval encoded information of B, thereby reducing the codeword length and saving code rate. At the same time, since the adjustment amplitude is constrained by condition 4 (difference less than TH2), and the small QP ensures a small quantization step size, this adjustment has a minimal impact on the subjective quality of the image.

[0045] The following example illustrates the above scheme: Let QP = 1, TH1 = 3, TH2 = 5, the current quantization result A1 = 7, and the historical quantization result B = 4. Analysis shows that since QP = 1 ≤ TH1 = 3, condition 1 is satisfied; through... Figure 3 From the code table, we know that A1=7 and B=4 do not belong to the same interval, so condition 2 is satisfied; since A1=7>B=4, condition 3 is satisfied; the maximum value of the interval where B is located, A2, is 6, and A1-A2=7-6=1<5, so condition 4 is satisfied. In other words, all four conditions are satisfied, so A1 is adjusted to the maximum code value of interval 2, 6, i.e., A2=6. It can be seen that if A1 is not adjusted, since A1 and B do not belong to the same interval, if A1=7 is encoded according to scheme 1, it requires 7 bits (codeword 0_011_000); however, after adjustment, A2=6, and A2 and B belong to the same interval, so only 3 bits (codeword 1_11) are needed according to the same encoding scheme, thus saving 4 bits of code rate.

[0046] This application also discloses a specific adjustment method under preset conditions. In one specific embodiment, the Nth interval includes historical quantization results, and the preset conditions include: the quantization parameter is not greater than a first preset threshold; the current quantization result and the historical quantization result do not belong to the same interval; the amplitude value of the historical quantization result is greater than the amplitude value of the current quantization result; the difference between the minimum value of the Nth interval and the amplitude value of the current quantization result is less than a second preset threshold; then adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval after the interval where the current quantization result is located includes: adjusting the current quantization result to the minimum encoded value of the Nth interval.

[0047] In other words, similar to the above, the Nth interval also includes historical quantization results. Let the current quantization parameter be QP, the first preset threshold be TH1, the second preset threshold be TH2, the amplitude of the current quantization result be A1, and the amplitude of the historical quantization result be B. Unlike the previous example, here the minimum value of the Nth interval is set to A2. The first preset threshold TH1 is less than the second preset threshold TH2. The current quantization result is adjusted when the following four preset conditions are met simultaneously: Condition 1: The quantization parameter QP is not greater than the first preset threshold TH1; Condition 2: The amplitude value A1 of the current quantization result and the amplitude value B of the historical quantization result do not belong to the same interval; Condition 3: The amplitude value B of the historical quantization result is greater than the amplitude value A1 of the current quantization result, i.e., B > A1; Condition 4: The difference between the minimum encoded value A2 of the Nth interval and the amplitude value A1 of the current quantization result is less than the second preset threshold TH2, i.e., A2-A1 <TH2。

[0048] The Nth interval is the encoding interval containing the amplitude value B of the historical quantization result. This interval has a corresponding minimum encoding value, which is the minimum allowed encoding value within this interval. When all four conditions are met, an adjustment operation is performed, that is, the amplitude value A1 of the current quantization result is adjusted to the maximum encoding value A2 of the interval containing B, and A2 is output as the final quantization result. If any of the above conditions are not met, A1 is output as the final quantization result.

[0049] In addition, the values ​​of TH1 and TH2 can be found in the previous content, and will not be repeated here.

[0050] Understandably, since the amplitude value B of the historical quantization result is greater than the amplitude value A1 of the current quantization result, and the two are not in the same interval, by increasing A1 to the minimum coding value of the interval where B is located, the adjusted A2 falls into the same coding interval as B. In this way, during subsequent entropy coding, A2 can reuse the interval coding information of B, thereby reducing codeword length and saving code rate. At the same time, since the adjustment amplitude is constrained by condition 4 (difference less than TH2), and the small QP ensures a small quantization step size, this adjustment has a small impact on the subjective quality of the image.

[0051] The following example illustrates the above scheme: Let QP = 1, TH1 = 3, TH2 = 5, current quantization result A1 = 2, and historical quantization result B = 4. Analysis shows that since QP = 1 ≤ TH1 = 3, condition 1 is satisfied; through... Figure 3 From the code table, we know that A1=2 and B=4 do not belong to the same interval, so condition 2 is satisfied; since B=4>A1=2, condition 3 is satisfied; the minimum value of the interval where B is located is 3, and the difference between this minimum code value and A1 is 3-2=1<5, so condition 4 is satisfied. In other words, all four conditions are satisfied, so A1 is adjusted to the minimum code value of interval 2, 3, i.e., A2=3. It can be seen that if A1 is not adjusted, since A1 and B do not belong to the same interval, if A1=2 is encoded according to scheme 1, it requires 5 bits (codeword 0_001_1); however, after adjustment, A2=3, and A2 and B belong to the same interval, so only 3 bits (codeword 1_00) are needed according to the same encoding scheme, thus saving 2 bits of code rate.

[0052] As can be seen, the first adjustment method described above is suitable for scenarios where the current quantization result is greater than the historical quantization result, by reducing the current value to make it fall within the range of the historical value; the second adjustment method is suitable for scenarios where the historical quantization result is greater than the current quantization result, by increasing the current value to make it fall within the range of the historical value. In this way, the codeword length can be reduced and the entropy coding efficiency can be improved.

[0053] Furthermore, based on the aforementioned embodiments, this application also discloses another adjustment method under preset conditions. Specifically, the preset conditions can be independent of historical quantization results, and quantization fine-tuning can be performed directly from the code table critical point. This method is applicable to standard exponential Golomb coding or other entropy coding schemes with similar codeword length jump characteristics. That is, as long as the entropy coding code table has interval division characteristics (i.e., the codeword length jumps at the interval boundary), this quantization adjustment method can be used.

[0054] Specifically, the preset conditions include: the quantization parameter is not greater than a first preset threshold; the difference between the amplitude value of the current quantization result and the maximum value of the Nth interval is less than a second preset threshold; then adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval before the interval where the current quantization result is located includes: adjusting the current quantization result to the maximum encoding value of the Nth interval before the interval where the current quantization result is located.

[0055] In other words, in this embodiment, the adjustment method does not rely on historical quantization results; it only determines whether the current quantization result is near the interval threshold based on its own interval position. Similarly, let the current quantization parameter be QP, the first preset threshold be TH1, the second preset threshold be TH2, the amplitude value of the current quantization result be A1, and the maximum value of the Nth interval be A2. Here, the Nth interval refers to the interval preceding the current quantization result. If the difference between the amplitude value A1 of the current quantization result and the maximum value A2 of the preceding interval is less than TH2, and QP is not greater than TH1, then the current quantization result is adjusted to the maximum encoding value of the preceding interval, and A2 is output as the final quantization result, thereby avoiding the code rate waste caused by codeword length jumps. If any of the above conditions are not met, then A1 is output as the final quantization result.

[0056] The following example illustrates the above scheme: Taking standard exponential Golomb coding as an example, let QP = 1, TH1 = 3, TH2 = 5, and the current quantization result A1 = 7. Since QP < TH1, the maximum value of the previous interval containing A1 is A2 = 6, and the difference between A1 and A2 is 1 < 5, satisfying the condition. Therefore, A1 is adjusted to 6. According to 0th-order exponential Golomb coding, the codeword for A1 = 7 is 1110000 (7 bits), and the codeword for A2 = 6 after adjustment is 11011 (5 bits), thus saving 2 bits of code rate.

[0057] As can be seen, by adjusting the current quantization result near the critical point of codeword length jump to the maximum coding value of the previous interval, this application can avoid codeword length jumps in the entropy coding code table with extremely simple judgment logic, and effectively reduce the code rate without affecting the subjective image quality.

[0058] Furthermore, this application also discloses the specific process of entropy coding. The method further includes: encoding the adjusted final quantization result to obtain an encoding result; wherein, the encoding result includes a flag codeword and a suffix codeword, the flag codeword indicating that the adjusted final quantization result belongs to the same interval as any other encoded result in the Nth interval, and the suffix codeword including the codewords of the original codeword of the adjusted final quantization result other than the preset bit identical codeword.

[0059] It is understandable that after the corresponding quantization result adjustment is completed in the quantization stage, the embodiments of this application further perform entropy encoding processing on the adjusted final quantization result to obtain the encoding result.

[0060] The entropy coding scheme adopted in this application will be described in detail below. Taking the standard exponential Golomb coding as an example, its codeword structure can be divided into three parts: a prefix, a separator, and a suffix. As is known from the foregoing, when multiple consecutive values ​​to be encoded belong to the same interval, the codewords of these values ​​have the same prefix and separator, resulting in repeated encoding of the same prefix and separator in the bitstream, causing a waste of bitrate. Therefore, this application discloses an improved entropy coding scheme, such as... Figure 3 As shown in Schemes 1 and 2, specifically, if the next value to be encoded belongs to the same encoding interval as the previous encoded value (i.e., the prefix and separator are the same), then the next value to be encoded will not repeat the encoding of the prefix and separator; the suffix part can be encoded directly. Simultaneously, a 1-bit flag is used to indicate whether the current value to be encoded belongs to the same interval as the previous encoded value. For example, if they belong to the same interval, the flag is 1 (or 0); if they do not belong, the flag is 0 (or 1).

[0061] In Scheme 1, if the current value to be encoded does not belong to the same interval as the previously encoded value, the codeword structure is: flag + current interval codeword + suffix of the exponential Golomb code; if they belong to the same interval, the codeword structure is: flag + suffix of the exponential Golomb code. Here, based on the range of values ​​X to be encoded, a fixed-length code can be used to represent the interval, and the interval codeword replaces the prefix + separator part. When using fixed-length encoding, the length of the interval codeword L = ceil(log2(total number of intervals)). Alternatively, variable-length encoding can be used based on the probability of the value to be encoded.

[0062] Assuming the order k is 0, taking an 8-bit pixel as an example, the residual may range from -255 to 255. Considering only the absolute value of the encoded residual (denoted by X), taking k=0 as an example, it can be divided into the following intervals, as shown in Table 1: Table 1

[0063] It should be noted that when k is 0, if X ranges from 0 to 255, it can theoretically be divided into 9 intervals. However, each interval codeword occupies 4 bits. To save on the code rate of interval encoding, it is stipulated that interval encoding schemes are not used when X is 255. In this case, the value range of X is 0 to 254, which is exactly divided into 8 intervals, with each interval code occupying 3 bits. If the residual amplitude value does indeed appear as 255, it can be forcibly changed to 254 before encoding, which is equivalent to the previous module performing quantization.

[0064] In Scheme 2, if the current value to be encoded does not belong to the same interval as the previous encoded value, the codeword structure is: flag + the original codeword of the complete exponential Golomb code; if they belong to the same interval, the codeword structure is: flag + the suffix part of the exponential Golomb code.

[0065] Therefore, when the quantization adjustment is successful and the current quantization result falls into the same interval as the previous quantization result, the adjusted final quantization result will be encoded using the right-hand code table of Scheme 1 and Scheme 2 during the entropy coding stage. This ensures that the final encoded result only includes the flag codeword and the suffix codeword. The suffix codeword here refers to the suffix part of the exponential Golomb coding, thus eliminating the need to encode the prefix part and separator, further shortening the bitstream length. Taking the previous adjustment example, after adjusting the current quantization result A1=7 to A2=6, A2 and the historical quantization result B=4 belong to the same interval. Therefore, the encoding result of A2 is "1_11" (flag=1 is the flag codeword, indicating that it belongs to the same interval, and the suffix codeword "11" represents the suffix part of the exponential Golomb code), requiring only 3 bits. However, without adjustment, the encoding result of A1=7 is "0_011_000" (flag=0 is the flag codeword, indicating that it does not belong to the same interval, the interval codeword is "011", and the suffix part is "000"), requiring 7 bits. It can be seen that the joint optimization of quantization adjustment and improved entropy coding can produce a significant code rate saving effect.

[0066] Furthermore, when quantization fails due to unmet preset conditions, in one embodiment, if the current quantization result is not in the same interval as the previous quantization result, the final encoding result is "flag + current interval codeword + suffix of exponential Golomb code" according to Scheme 1, or "flag + original codeword of complete exponential Golomb code" according to Scheme 2. In another embodiment, if the current quantization result is in the same interval as the previous quantization result, the final encoding result is "flag + suffix of exponential Golomb code" according to Scheme 1, or "flag + suffix of complete exponential Golomb code" according to Scheme 2.

[0067] Accordingly, this application also discloses a decoding process corresponding to the above encoding scheme. Decoding is the reverse process of encoding and is used to recover the original value to be encoded from the bitstream.

[0068] In one specific implementation, the decoding process corresponding to Scheme 1 is as follows (the current order parameter k is known): Step 1: Read 1 bit from the bitstream to obtain the flag bit. Based on the value of the flag, determine the codeword structure used for the value currently being decoded. It is assumed that the encoder and decoder agree that a value of 1 indicates belonging to the same interval, and a value of 0 indicates not belonging to the same interval.

[0069] Step 2: If flag is 0, the codeword structure of the current value to be decoded is determined to be: flag + current interval codeword + suffix part of the exponential Golomb code. At this point, continue reading L bits from the bitstream, where L is the length of the interval codeword, L = ceil(log2(total number of intervals)). Parse the interval codeword using the fixed-length decoding method, and then map the interval codeword and parameter k to obtain the corresponding interval start value A and exponential Golomb code suffix length L1 (or directly map the interval codeword and parameter k to the interval start value A and exponential Golomb code suffix length L1). Then, continue reading L1 bits from the bitstream to obtain the value B corresponding to the exponential Golomb code suffix part. Finally, add the interval start value A and the suffix value B, i.e., A + B, to obtain the current value to be decoded.

[0070] Step 3: If flag is 1, the codeword structure of the current value to be decoded is determined to be: flag + the suffix of the exponential Golomb code, indicating that the current value to be decoded belongs to the same interval as the previously decoded value. At this point, the encoding interval information to which the previous decoded value belongs can be obtained from the previous decoded value, including the starting value A of the interval and the length L1 of the exponential Golomb code suffix. Then, continue to read L1 bits from the bitstream to obtain the value B corresponding to the suffix. Finally, add the interval starting value A and the suffix value B, i.e., A + B, to obtain the current value to be decoded.

[0071] For scheme 2 on the encoding side, the decoding process is similar: when flag is 0, the complete original codeword is directly decoded according to the standard k-order exponential Columbus decoding process to obtain the current value to be decoded; when flag is 1, the current value to be decoded is restored according to the interval information of the previous decoded value and the decoded suffix part in the manner described in step 3 above.

[0072] It should be noted that the decoding process in this embodiment is not unique, and the above description is merely an intuitive decoding method. For example, during the decoding process, the prefix of the exponential Golomb code can be obtained based on the interval codeword mapping (assuming that k-order exponential Golomb decoding is currently underway and the prefix has already been decoded), and then the subsequent process of standard k-order exponential Golomb decoding can be directly reused to obtain the final value to be decoded. Although the decoding method is not unique, the codeword structure is always unique and definite, and the decoded value is also exactly the same.

[0073] The decoding process described above is illustrated with a specific example. Assume the bitstream contains "1_11", the previously decoded value is known to be 4, and the current order k=0. First, read 1 bit to obtain flag=1, indicating that the current value to be decoded belongs to the same interval as the previously decoded value. Based on the previously decoded value 4, the starting value of its interval is A=3, and the suffix code length L1=2. Next, read 2 bits to obtain the suffix "11", whose corresponding value is B=3. Therefore, the current value to be decoded is A+B=3+3=6. The decoding result is consistent with the adjustment result at the encoding end, verifying the correctness of the decoding process.

[0074] Let's illustrate with another example. Assume the bitstream contains "0_011_000", and the current order k=0. First, read 1 bit to get flag=0, indicating that the current value to be decoded does not belong to the same interval as the previously decoded value. Then read L=3 bits (because there are 8 intervals when k=0, L=ceil(log2(8))=3) to get the interval codeword "011". According to Table 1, this interval codeword corresponds to interval index 3, interval start value A=7, and suffix code length L1=3. Then read 3 bits to get the suffix "000", whose corresponding value B=0. Then the current value to be decoded is A+B=7+0=7.

[0075] In summary, this application achieves the technical effect of effectively reducing the bit rate while ensuring the subjective quality of the image through joint optimization of quantization adjustment and improved entropy coding at the encoding end, and corresponding decoding process at the decoding end. Moreover, the encoding and decoding process is simple and hardware-friendly, making it particularly suitable for application scenarios that are sensitive to real-time performance and power consumption, such as bandwidth compression.

[0076] See Figure 5 As shown in the figure, this application discloses a compression device, which includes: Quantization module 11 is used to quantize the current source symbol to be compressed using quantization parameters to obtain the current quantization result; The adjustment module 12 is used to adjust the current quantization result if the current quantization result meets the preset conditions, so that the adjusted final quantization result belongs to the Nth interval before or after the interval where the current quantization result is located; wherein, N is a positive integer greater than or equal to 1, and the original codewords of multiple values ​​to be encoded in the same interval have the same preset bit.

[0077] As can be seen, this application jointly optimizes quantization and entropy coding, actively adjusting the current quantization result when it meets preset conditions. This ensures the adjusted final quantization result falls within a more efficient coding range, avoiding codeword length jumps at critical points in the code table, directly reducing redundant bits, and significantly lowering the code rate. Furthermore, this application adjusts the current quantization result only when preset conditions are met, avoiding indiscriminate modification of the quantization result and ensuring the rationality of the quantization adjustment. In addition, it should be noted that since the original codewords of multiple values ​​to be encoded within the same range have the same preset bits, in some cases, the adjusted final quantization result can reuse the common part of the range codewords, avoiding repeated encoding of the same codeword part and effectively shortening the bitstream length.

[0078] Since the embodiments of the device part correspond to the embodiments described above, please refer to the embodiments described in the method part for the embodiments of the device part, and will not be repeated here.

[0079] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the compression method performed by the electronic device disclosed in any of the foregoing embodiments.

[0080] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0081] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0082] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system 221, computer program 222 and data 223, etc., and the storage method can be temporary storage or permanent storage.

[0083] The operating system 221 manages and controls the various hardware devices and computer programs 222 on the electronic device 20 to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. The operating system 221 can be Windows, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the compression method disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.

[0084] Furthermore, embodiments of this application also disclose a computer-readable storage medium storing a computer program, which, when loaded and executed by a processor, implements the compression method steps disclosed in any of the foregoing embodiments.

[0085] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0086] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0087] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, compact disc read-only memory (CD-ROM), or any other form of storage medium known in the art.

[0088] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0089] The above provides a detailed description of the compression method, apparatus, device, and medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only intended to help understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A compression method, characterized in that, include: The current source symbol to be compressed is quantized using quantization parameters to obtain the current quantization result; If the current quantization result meets the preset conditions, the current quantization result is adjusted so that the adjusted final quantization result belongs to the Nth interval before or after the interval where the current quantization result is located; where N is a positive integer greater than or equal to 1, and the original codewords of multiple values ​​to be encoded in the same interval have the same preset bit.

2. The compression method according to claim 1, characterized in that, The Nth interval includes historical quantification results, and the preset conditions include: The quantization parameter is not greater than a first preset threshold; The current quantization result and the historical quantization result do not belong to the same interval; The amplitude value of the current quantization result is greater than the amplitude value of the historical quantization result; The difference between the amplitude value of the current quantization result and the maximum value of the Nth interval is less than the second preset threshold. The step of adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval preceding the interval containing the current quantization result includes: The current quantization result is adjusted to the maximum encoded value of the Nth interval.

3. The compression method according to claim 1, characterized in that, The preset conditions include: The quantization parameter is not greater than a first preset threshold; The difference between the amplitude value of the current quantization result and the maximum value of the Nth interval is less than the second preset threshold. The step of adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval preceding the interval containing the current quantization result includes: The current quantization result is adjusted to the maximum encoded value of the Nth interval preceding the interval containing the current quantization result.

4. The compression method according to claim 1, characterized in that, The Nth interval includes historical quantification results, and the preset conditions include: The quantization parameter is not greater than a first preset threshold; The current quantization result and the historical quantization result do not belong to the same interval; The amplitude value of the historical quantization result is greater than the amplitude value of the current quantization result; The difference between the minimum value of the Nth interval and the amplitude value of the current quantization result is less than the second preset threshold. The step of adjusting the current quantization result so that the adjusted final quantization result belongs to the Nth interval after the interval where the current quantization result is located includes: The current quantization result is adjusted to the minimum encoded value of the Nth interval.

5. The compression method according to claim 1, characterized in that, The method further includes: If the current quantization result does not meet the preset conditions, then the current quantization result is the final quantization result.

6. The compression method according to any one of claims 1 to 5, characterized in that, The original codewords of multiple values ​​to be encoded within the same interval also have the same length.

7. The compression method according to any one of claims 2 to 4, characterized in that, The method further includes: The adjusted final quantization result is encoded to obtain the encoded result; The encoding result includes a flag codeword and a suffix codeword. The flag codeword indicates that the adjusted final quantization result belongs to the same interval as any other encoded result in the Nth interval. The suffix codeword includes the original codeword of the adjusted final quantization result, excluding the preset codeword.

8. A compression device, characterized in that, include: The quantization module is used to quantize the current source symbols to be compressed using quantization parameters to obtain the current quantization result; An adjustment module is used to adjust the current quantization result if the current quantization result meets a preset condition, so that the adjusted final quantization result belongs to the Nth interval before or after the interval where the current quantization result is located; wherein, N is a positive integer greater than or equal to 1, and the original codewords of multiple values ​​to be encoded in the same interval have the same preset bit.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the compression method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used for storing computer programs; wherein, when the computer programs are executed by a processor, they implement the steps of the compression method as described in any one of claims 1 to 7.