An encoding method, a decoding method, a device, an apparatus, and a medium
By dividing the source symbol interval in exponential Golomb coding and using the combination of flag bits and suffix codewords, the problem of redundancy in continuous source symbol codewords is solved, and more efficient entropy coding is achieved.
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-26
AI Technical Summary
In existing exponential Golomb coding and other similar entropy coding methods, there is redundancy in the codewords of multiple consecutive source symbols, which limits the coding efficiency.
By pre-dividing the encoding range of the source symbols and using a combination of flag codewords and suffix codewords, the repeated preset part is identified and omitted, thus optimizing the encoding process.
It effectively reduces the code rate, improves the efficiency of entropy coding, and reduces the transmission of redundant codewords.
Smart Images

Figure CN122293095A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data compression technology, and in particular to an encoding method, decoding method, apparatus, device, and medium. Background Technology
[0002] In the fields of data compression and image / video coding, entropy coding is a key technology for removing data redundancy and reducing bitrate. Exponential Golomb coding, as a lightweight and hardware-friendly entropy coding method, is widely used in bandwidth-constrained scenarios due to its simple codeword structure and low encoding / decoding overhead.
[0003] The codeword structure of Exponential Golomb coding typically includes a prefix, a separator, and a suffix. In actual encoding, each source symbol to be encoded is encoded independently, generating its own codeword. However, when multiple consecutive source symbols to be encoded have the same codeword length in Exponential Golomb coding, these codewords often share the same prefix and separator. During encoding, because each symbol is encoded independently, the same prefix and separator are repeatedly encoded, resulting in wasted code rate and limiting further improvements in entropy coding efficiency. This problem is not unique to Exponential Golomb coding; other entropy coding methods with similar structures also suffer from this redundancy issue, where multiple consecutive source symbols to be encoded have partially identical codewords under a certain encoding scheme.
[0004] Therefore, how to further improve the efficiency of entropy coding 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 an encoding method, decoding method, apparatus, device, and medium that can further improve entropy coding efficiency. The specific solution is as follows: Firstly, this application discloses an encoding method, including: Obtain the source symbols to be encoded; The flag bit codeword of the source symbol to be encoded is determined based on whether the source symbol to be encoded and the previously encoded source symbol belong to the same interval. The original codewords of multiple source symbols to be encoded within the same interval have the same preset bit. The suffix codeword of the source symbol to be encoded is determined according to the flag bit codeword, wherein the suffix codeword includes at least a portion of the original codeword of the source symbol to be encoded; The target codeword for encoding the source symbol to be encoded is determined based on the flag codeword and the suffix codeword, wherein the target codeword includes the flag codeword and the suffix codeword.
[0006] Optionally, the original codewords of multiple source symbols to be encoded within the same interval also have the same length.
[0007] Optionally, determining the flag bit codeword of the source symbol to be encoded based on whether the source symbol to be encoded belongs to the same interval as the previously encoded source symbol includes: If the source symbol to be encoded belongs to the same interval as the previously encoded source symbol, then the flag bit codeword is determined to be the first codeword; If the source symbol to be encoded does not belong to the same interval as the previously encoded source symbol, then the flag bit codeword is determined to be the second codeword.
[0008] Optionally, determining the suffix codeword of the source symbol to be encoded based on the flag bit codeword includes: If the flag bit codeword is the first codeword, then the codewords in the original codeword other than the preset bit identical codewords are used as the suffix codewords of the source symbol to be encoded. If the flag codeword is the second codeword, then all the codewords in the original codeword are used as the suffix codewords of the source symbol to be encoded, or the interval codewords of the interval to which the source symbol to be encoded belongs and the codewords in the original codeword other than the preset codewords are used as the suffix codewords of the source symbol to be encoded.
[0009] Optionally, the encoding method further includes: Count the total number of intervals under different order parameters; The encoding length of the interval codeword is determined based on the total number of intervals, and a fixed-length encoding method is used to assign a corresponding interval codeword to each interval based on the encoding length.
[0010] Optionally, determining the target codeword for encoding the source symbol to be encoded based on the flag codeword and the suffix codeword includes: The flag codeword and the suffix codeword are concatenated to obtain the target codeword for encoding the source symbol to be encoded.
[0011] Optionally, the source symbol to be encoded is obtained by quantizing the original information to be encoded; wherein, the quantization process is as follows: The original information to be encoded is quantized using quantization parameters to obtain the current quantization result; If the current quantization result and the historical quantization result corresponding to the previous original information to be encoded meet the preset conditions, then the current quantization result is adjusted so that the adjusted result and the historical quantization result belong to the same interval; The adjusted result is used as the source symbol to be encoded; If the current quantization result does not meet the preset conditions with the historical quantization result corresponding to the previous original information to be encoded, then the current quantization result is the source symbol to be encoded.
[0012] Secondly, this application discloses a decoding method, including: Obtain the target codeword to be decoded; Parse the flag bit codeword from the target codeword; wherein the flag bit codeword is used to characterize whether the source symbol corresponding to the target codeword belongs to the same interval as the previously decoded source symbol, and the original codewords of multiple source symbols in the same interval have the same preset bit; The codeword structure of the suffix codeword is determined based on the flag codeword, so as to parse the suffix codeword from the target codeword based on the codeword structure; The source symbol is recovered based on the flag codeword and the suffix codeword.
[0013] Thirdly, this application discloses an encoding device, comprising: The acquisition module is used to acquire the source symbols to be encoded. The flag bit determination module is used to determine the flag bit codeword of the source symbol to be encoded based on whether the source symbol to be encoded and the previously encoded source symbol belong to the same interval, wherein the original codewords of multiple source symbols to be encoded within the same interval have the same preset bit; The suffix determination module is used to determine the suffix codeword of the source symbol to be encoded based on the flag bit codeword, wherein the suffix codeword includes at least a portion of the original codeword of the source symbol to be encoded; The codeword determination module is used to determine the target codeword for encoding the source symbol to be encoded based on the flag codeword and the suffix codeword, wherein the target codeword includes the flag codeword and the suffix codeword.
[0014] Fourthly, this application discloses an electronic device, comprising: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the aforementioned disclosed encoding or decoding method.
[0015] Fifthly, 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 encoding or decoding method.
[0016] As can be seen, this application obtains the source symbol to be encoded; determines the flag codeword of the source symbol to be encoded based on whether the source symbol to be encoded and the previously encoded source symbol belong to the same interval, wherein the original codewords of multiple source symbols to be encoded within the same interval have the same preset bit; determines the suffix codeword of the source symbol to be encoded based on the flag codeword, wherein the suffix codeword includes at least a portion of the original codeword of the source symbol to be encoded; and determines the target codeword for encoding the source symbol to be encoded based on the flag codeword and the suffix codeword, wherein the target codeword includes the flag codeword and the suffix codeword.
[0017] Beneficial Effects: This application pre-divides intervals so that the original codewords of multiple source symbols to be encoded within the same interval have the same preset bits. Then, during the actual encoding process, the corresponding flag bit codeword is determined based on whether the current source symbol to be encoded belongs to the same interval as the previously encoded source symbol. This achieves the identification and marking of the identical preset bit portions, avoiding the repeated transmission of the same preset bit codeword during continuous encoding, thereby effectively reducing the code rate. Furthermore, the specific content of the suffix codeword is determined based on the determined flag bit codeword. Finally, the target codeword is composed of the flag bit codeword and the suffix codeword, thus completing the encoding process. In other words, this application improves encoding efficiency by utilizing the correlation between adjacent source symbols to omit the encoding of identical preset bit portions. Attached Figure Description
[0018] 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.
[0019] Figure 1 Intended code representation for a standard k-order exponential Golomb code; Figure 2 This is a flowchart of an encoding method disclosed in this application; 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 flowchart of a decoding method disclosed in this application; Figure 6 This is a schematic diagram of the structure of an encoding device disclosed in this application; Figure 7This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0020] 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 skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Taking Exponential Golomb coding as an example, it 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. The codeword structure of Exponential Golomb coding typically includes a prefix, a separator, and a suffix. In the actual coding process, each source symbol to be encoded is encoded independently, generating its corresponding codeword. When multiple consecutive source symbols to be encoded have the same codeword length in Exponential Golomb coding, these codewords often have the same prefix and separator. During the encoding process, because each symbol is encoded independently, the same prefix and separator are repeatedly encoded, resulting in wasted code rate and limiting further improvement in entropy coding efficiency.
[0022] For example, see Figure 1 The partial code table of the k-order exponential Golomb coding shown below, for the column k=0, when the number to be encoded X takes values from 3 to 6, the corresponding codewords are 11000 to 11011. The codewords within this range all begin with 110. If joint coding 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.
[0023] The aforementioned problem exists not only in exponential Golomb coding, but also in other coding methods with similar structures, where multiple consecutive source symbols to be encoded have partially identical codewords under a certain coding scheme. To address this, embodiments of this application disclose an encoding method, a decoding method, an apparatus, a device, and a medium that can further improve coding efficiency.
[0024] See Figure 2 As shown in the figure, this application discloses an encoding method, which includes: Step S11: Obtain the source symbols to be encoded.
[0025] In this embodiment, the source symbols to be encoded are first obtained. These source symbols can be various types of data, including but not limited to residual data, video motion vectors, audio sample values, and pixel values. These source symbols can be obtained by directly acquiring the original data or by preprocessing the original information. Specifically, source symbols are 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. Furthermore, source symbols can include original source symbols, i.e., basic symbols directly acquired from the image acquisition device (camera 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. In lossy image or video compression, in one embodiment, the source symbol can refer to the residual value, that is, 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 symbol can also be related to the transformed value of the image residual, and the same technical effect can be achieved using this technical solution. In addition, the source symbol can also be symbolic information (such as coding block flags, mode selection flags, etc.), audio signals, video motion information, etc. Among them, for non-numerical source symbols, such as symbolic information, they can be mapped to index values or numerical values before encoding operations.
[0026] Step S12: Determine the flag bit codeword of the source symbol to be encoded based on whether the source symbol to be encoded and the previously encoded source symbol belong to the same interval, wherein the original codewords of multiple source symbols to be encoded within the same interval have the same preset bit.
[0027] In this embodiment, by pre-dividing intervals, the original codewords of multiple source symbols to be encoded within the same interval have the same preset bit. Then, during the actual encoding process, the corresponding flag bit codeword is determined based on whether the current source symbol to be encoded and the previously encoded source symbol belong to the same interval. This achieves the identification and marking of the same preset bit portion, avoiding the repeated transmission of the same preset bit codeword during continuous encoding, thereby effectively reducing the code rate. It should be noted that the original codeword refers to the codeword obtained by applying the original entropy encoding method to the value to be encoded; that is, the entropy encoding method that existed before this patent application is the original entropy encoding method. For example, in one embodiment, the original entropy encoding method is the standard exponential Columbus encoding method.
[0028] It should also be noted that the original codewords of multiple source symbols 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 1 Taking the partial code table of the k-order exponential Golomb coding shown as an example, observing its code table reveals that the codeword length jumps at certain numerical points. For instance, in the 0-order (i.e., k=0, k is the order) exponential Golomb coding, if the value X to be encoded 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, original codewords with the same preset position refer to having the same prefix part and separator (the codeword structure of standard k-order exponential Golomb coding can be divided into prefix part + separator + suffix part), and the original codewords of multiple values to be encoded within the same interval have the same length. It should be further noted that in this application, the concepts of suffix codeword and suffix part, and the content they indicate, are not necessarily the same and need to be distinguished. The overall understanding can be based on the specific explanations of the various embodiments in this application. Specifically, the suffix codeword is a component of the codeword after the source symbol to be encoded is encoded using the method of this application. It refers to the codeword after the source symbol to be encoded, excluding the flag bit codeword. The suffix part refers to a component of the codeword after some entropy coding (such as exponential Golomb coding), which refers to the codeword after entropy coding, excluding the prefix part and the separator.
[0029] Therefore, the division of intervals is based on observing the original code table of the k-order exponential Golomb coding. Symbols to be encoded with the same codeword length are considered to belong to the same coding interval, thus sharing the same prefix + separator in the exponential Golomb coding. For example, when 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 coding residual (represented by X), the values from 0 to 254 can be divided into 8 intervals: interval 0 corresponds to X=0, interval 1 corresponds to X=1~2, interval 2 corresponds to X=3~6, interval 3 corresponds to X=7~14, interval 4 corresponds to X=15~30, interval 5 corresponds to X=31~62, interval 6 corresponds to X=63~126, and interval 7 corresponds to X=127~254. The values within each interval have the same codeword length in the exponential Golomb coding, as shown in Table 1. Table 1. Encoding interval division of the 8-bit residual absolute value X, with k set to 0.
[0030] 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.
[0031] In addition, from Figure 1 As 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 as follows: 0~1, 2~5, 6~13, 14~29, etc.; when k=2, the intervals are divided as follows: 0~3, 4~11, 12~27, etc., as shown in Tables 2 and 3. Therefore, the method of interval division is general and not limited to the above examples.
[0032] Table 2. Encoding interval division of the 8-bit residual absolute value X, with k set to 1.
[0033] Table 3. Encoding interval division of the 8-bit residual absolute value X, with k = 2.
[0034] 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 the space into intervals. The original codewords of the values to be encoded within the same interval have the same preset bits. These same preset 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, the 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.
[0035] In a specific implementation, determining the flag bit codeword of the source symbol to be encoded based on whether the source symbol to be encoded and the previously encoded source symbol belong to the same interval includes: if the source symbol to be encoded and the previously encoded source symbol belong to the same interval, then the flag bit codeword is determined to be the first codeword; if the source symbol to be encoded and the previously encoded source symbol do not belong to the same interval, then the flag bit codeword is determined to be the second codeword.
[0036] Understandably, this application can specifically use a 1-bit flag to indicate whether the current source symbol to be encoded belongs to the same encoding interval as the previously encoded source symbol. The flag codeword specifically includes a first codeword and a second codeword, which are inverse binary values. For example, it can be agreed that when the first codeword is 1, it indicates that they belong to the same interval, and when the second codeword is 0, it indicates that they do not belong to the same interval; or it can be agreed that when the first codeword is 0, it indicates that they belong to the same interval, and when the second codeword is 1, it indicates that they do not belong to the same interval. The specific agreement method can be determined according to the actual application scenario.
[0037] Furthermore, when more state information needs to be represented (such as the encoding state of multiple consecutive symbols in the same interval, the buffer state, etc.), the flag codeword is not limited to 1 bit and can be set to 2 bits or longer flag bits according to actual needs.
[0038] Step S13: Determine the suffix codeword of the source symbol to be encoded based on the flag bit codeword, wherein the suffix codeword includes at least a portion of the original codeword of the source symbol to be encoded.
[0039] In this embodiment, the original codeword refers to the complete codeword obtained after the source symbol to be encoded is encoded using a preset encoding method (such as exponential Golomb coding). Taking exponential Golomb coding as an example, the structure of the original codeword can be divided into a prefix part, a separator, and a suffix part. The specific content of the suffix codeword varies depending on the flag bit codeword.
[0040] In a specific implementation, determining the suffix codeword of the source symbol to be encoded based on the flag bit codeword includes: if the flag bit codeword is the first codeword, then using the codewords in the original codeword other than the preset codewords with the same bit as the suffix codeword of the source symbol to be encoded; if the flag bit codeword is the second codeword, then using all the codewords in the original codeword as the suffix codeword of the source symbol to be encoded, or using the interval codeword of the interval to which the source symbol to be encoded belongs and the codewords in the original codeword other than the preset codewords with the same bit as the suffix codeword of the source symbol to be encoded.
[0041] First, it's important to explain that, taking k-order exponential Golomb coding as an example, as discussed earlier, the standard k-order exponential Golomb coding codeword structure consists of a prefix part + a separator + a suffix part. Generally, when using standard exponential Golomb coding, adjacent values 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 N consecutive 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 N times in the bitstream, clearly resulting in a waste of bitrate.
[0042] Therefore, the improvement of this application is to utilize 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 directly encoded.
[0043] In one specific implementation, when the flag codeword is the first codeword, it indicates that the current source symbol to be encoded belongs to the same interval as the previously encoded source symbol. Therefore, the codewords in the original codeword, excluding the codewords with the same preset bit, are used as the suffix codewords of the source symbol to be encoded. For example, in k-order exponential Golomb coding, the suffix codeword at this time refers to the suffix part of the exponential Golomb coding, thus eliminating the need to encode the prefix part and separator (i.e., the codewords with the same preset bit), further shortening the code stream length. For example, if the values to be encoded 3, 4, and 5 all belong to the same interval, k=0, the original codewords of the standard k-order exponential Golomb coding are 11000, 11001, and 11010, respectively, with the same prefix 110. When encoding the subsequent values 4 and 5, since they belong to the same interval as the previous value 3, the suffix codeword only needs to encode the suffix parts 01 and 10, without needing to repeatedly encode the prefix 110.
[0044] Furthermore, according to Tables 1 to 3 above, the code value of the suffix is specifically defined as the difference between the current source symbol to be encoded and the starting value of its corresponding interval. Let the starting value of the interval be A, and the current source symbol to be encoded be X, then the code value of the suffix = XA. Moreover, the encoding length L1 of the suffix is determined by the interval; different intervals correspond to different suffix code lengths L1. For example, when K=0, the suffix code length for interval 0 is 0, for interval 1 it is 1, for interval 2 it is 2, for interval 3 it is 3, and so on, with the suffix code length for interval 7 being 7. By binary encoding the suffix code value and limiting it to the corresponding interval code length, the codeword for the suffix can be obtained.
[0045] In another specific implementation, when the flag codeword is the second codeword, it indicates that the current source symbol to be encoded does not belong to the same interval as the previously encoded source symbol. For this situation, this application discloses two specific suffix codeword determination schemes. Scheme 1 uses the interval codeword of the interval to which the source symbol to be encoded belongs and the codewords in the original codeword (excluding the codewords with the same preset bit) as the suffix codeword of the source symbol to be encoded. Here, the interval codeword is used to identify the interval to which the current source symbol to be encoded belongs, and the codewords excluding the codewords with the same preset bit are the suffix part of the exponential Golomb coding, specifically represented as the difference between the source symbol to be encoded and the starting value of the interval. Scheme 2 uses all the codewords in the original codeword as the suffix codeword of the source symbol to be encoded. Taking k-order exponential Golomb coding as an example, the suffix codeword here refers to the complete exponential Golomb coding codeword, i.e., prefix part + separator + suffix part. In other words, compared to Scheme 2, Scheme 1 uses the interval codeword instead of the prefix part + separator part.
[0046] The generation process of interval codewords is as follows: Under different order parameters, the total number of intervals is counted; the encoding length of the interval codeword is determined based on the total number of intervals; and a fixed-length encoding method is used to assign a corresponding interval codeword to each interval based on the encoding length. That is, this application can use a fixed-length encoding method to represent intervals, thereby obtaining the interval codeword for each interval. Specifically, the encoding length L of the interval codeword is determined according to the total number of intervals M. The division of intervals is related to the order k of the exponential Golomb coding; different k correspond to different interval divisions. For example, when k=0, the values from 0 to 254 can be divided into 8 intervals (intervals 0~7); when k=1, the intervals are divided into 7 intervals: 0~1, 2~5, 6~13, 14~29, etc.; when k=2, the intervals are divided into 7 intervals: 0~3, 4~11, 12~27, etc. When using the fixed-length encoding method, the encoding length L=ceil(log2M) of the interval codeword is first determined based on the total number of intervals. For example, when the total number of intervals is 8, the interval codeword length is 3 bits (because 2³=8); when the total number of intervals is 7, the interval codeword length is also 3 bits (because 2²=4<7, so 2³=8 is needed, rounded up). Furthermore, according to the fixed-length encoding method, the interval codewords corresponding to each interval index can use natural binary encoding. For example, the interval codeword corresponding to interval 0 is 000, the interval codeword corresponding to interval 1 is 001, the interval codeword corresponding to interval 2 is 010, and so on. The specific results are shown in Table 1.
[0047] The following example illustrates the process of determining the suffix codeword in Scheme 1 and Scheme 2. Assume we use k-order exponential Golomb coding, where k=0, the value to be encoded is 3, and the flag codeword has been determined as the second codeword. If Scheme 1 is used, the suffix codeword includes the interval codeword (010) and the suffix part (00). If Scheme 2 is used, the suffix codeword is the original codeword, i.e., the original exponential Golomb coding: 11000.
[0048] Furthermore, interval codewords can also be generated using variable-length encoding. Specifically, the probability distribution of interval values can be determined based on the total number of intervals and the value information within each interval. Then, based on the interval value probability distribution, a variable-length encoding method (such as Huffman coding) can be used to assign a corresponding interval codeword to each interval. For example, if the probability of interval 0 occurring is 50%, the probability of interval 1 occurring is 30%, and the probability of other intervals occurring is lower, then a shorter codeword (such as 0) can be assigned to interval 0, the second shortest codeword (such as 10) can be assigned to interval 1, and longer codewords (such as 110, 1110, etc.) can be assigned to other intervals.
[0049] Step S14: Determine the target codeword for encoding the source symbol to be encoded based on the flag codeword and the suffix codeword, wherein the target codeword includes the flag codeword and the suffix codeword.
[0050] In this embodiment, the final determined target codeword includes a flag bit codeword and a suffix codeword. Specifically, determining the target codeword for encoding the source symbol to be encoded based on the flag bit codeword and the suffix codeword includes concatenating the flag bit codeword and the suffix codeword to obtain the target codeword for encoding the source symbol to be encoded. That is, this embodiment obtains the target codeword for encoding the source symbol to be encoded by concatenating the flag bit codeword and the suffix codeword in a certain order. The concatenation order is generally set to flag bit codeword first and suffix codeword second. Alternatively, it can be suffix codeword first and flag bit codeword second, as long as the encoding and decoding ends agree on the same method. It should also be noted that in some complex scenarios, the target codeword may not be limited to a simple concatenation method. For example, depending on the scenario requirements, other information, such as check bits, mode indicator bits, and suffix length indicators, can be inserted between the flag bit codeword and the suffix codeword to improve the robustness of the bitstream or support more encoding modes.
[0051] Taking three consecutive values to be encoded, 3, 4, and 5, as an example, the process of determining the target codeword is explained in conjunction with the content of Scheme 1 and Scheme 2 above. Specifically, k-order exponential Golomb coding is used, and k=0: Scheme 1: When encoding the value 3, since there is no preceding value, the flag codeword is the second codeword (0), the suffix codeword includes the interval codeword 010 and the suffix part 00, and the target codeword is 001000; when encoding the value 4, since it belongs to the same interval as the value 3, the flag codeword is the first codeword (1), the suffix codeword is the suffix part 01, and the target codeword is 101; when encoding the value 5, the flag codeword is the first codeword (1), the suffix codeword is the suffix part 10, and the target codeword is 110. The final code stream is 001000101110, a total of 12 bits, which saves 3 bits compared to the standard exponential Golomb code of the same order (110001100111010).
[0052] Scheme 2: When encoding the value 3, since there is no previous value, the flag bit codeword is the second codeword (0), the suffix codeword is the original codeword 11000, and the concatenated target codeword is 011000; when encoding the value 4, since it belongs to the same interval as the value 3, the flag bit codeword is the first codeword (1), the suffix codeword is the suffix part 01, and the target codeword is 101; when encoding the value 5, the flag bit codeword is the first codeword (1), the suffix codeword is the suffix part 10, and the target codeword is 110. The final code stream is 011000101110, a total of 12 bits, which saves 3 bits compared to the standard exponential Golomb code of the same order (110001100111010).
[0053] Furthermore, taking three consecutive values to be encoded, 6, 7, and 8, as an example, the process of determining the target codeword is explained in conjunction with the content of Scheme 1 and Scheme 2 above. Specifically, k-order exponential Golomb coding is used, and k=1: Scheme 1: When encoding the value 6, since there is no preceding value, the flag codeword is the second codeword (0), the suffix codeword includes the interval codeword 010 and the suffix part 000, and the target codeword is 0010000; when encoding the value 7, since it belongs to the same interval as the value 6, the flag codeword is the first codeword (1), the suffix codeword is the suffix part 001, and the target codeword is 1001; when encoding the value 8, the flag codeword is the first codeword (1), the suffix codeword is the suffix part 010, and the target codeword is 1010. The final code stream is 001000010011010, a total of 15 bits, which saves 3 bits compared to the standard exponential Golomb code of the same order (110000110001110010).
[0054] Scheme 2: When encoding the value 6, since there is no previous value, the flag bit codeword is the second codeword (0), the suffix codeword is the original codeword 110000, and the concatenated target codeword is 0110000; when encoding the value 7, since it belongs to the same interval as the value 6, the flag bit codeword is the first codeword (1), the suffix codeword is the suffix part 001, and the target codeword is 1001; when encoding the value 8, the flag bit codeword is the first codeword (1), the suffix codeword is the suffix part 010, and the target codeword is 1010. The final code stream is 011000010011010, a total of 15 bits, which saves 3 bits compared to the standard exponential Golomb code of the same order (110000110001110010).
[0055] In other words, this application improves upon the standard exponential Golomb coding by leveraging the correlation between preceding and following data in the sequence to be encoded, resulting in a new entropy coding scheme. This entropy coding scheme is more efficient than the original standard exponential Golomb coding in certain situations. The improved entropy coding scheme of this application can be specifically described as follows: Figure 3 and Figure 4 As shown, Figure 3 The code tables corresponding to Scheme 1 and Scheme 2 above, respectively, when k=0, are disclosed. Figure 4 The code tables corresponding to Scheme 1 and Scheme 2, respectively, when k=1, are disclosed. 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 than the original exponential Golomb code table. It should be noted that the left and right code tables refer to whether, for the current value X to be encoded, the codeword in the left code table or the codeword in the right code table should be used. 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 codeword in the right code table is used; otherwise, the codeword in the left code table is used.
[0056] In Scheme 1, if the current value to be encoded does not belong to the same interval as the previous encoded value, then flag is 0, and the codeword structure is: flag + current interval codeword + suffix of exponential Golomb code; if they belong to the same interval, flag is 1, and the codeword structure is: flag + suffix of exponential Golomb code.
[0057] In Scheme 2, if the current value to be encoded does not belong to the same interval as the previous encoded value, then flag is 0, and the codeword structure is: flag + the original codeword of the complete exponential Golomb code; if they belong to the same interval, flag is 1, and the codeword structure is: flag + the suffix part of the exponential Golomb code.
[0058] As can be seen, this application pre-divides intervals so that the original codewords of multiple source symbols to be encoded within the same interval have the same preset bits. Then, during the actual encoding process, the corresponding flag bit codeword is determined based on whether the current source symbol to be encoded belongs to the same interval as the previously encoded source symbol. This achieves the identification and marking of the same preset bit portion, avoiding the repeated transmission of the same preset bit codeword during continuous encoding, thereby effectively reducing the code rate. Furthermore, the specific content of the suffix codeword is determined based on the determined flag bit codeword. Finally, the target codeword is composed of the flag bit codeword and the suffix codeword, thus completing the entropy encoding process. In other words, this application improves the entropy encoding efficiency by utilizing the correlation between adjacent source symbols to omit the encoding of the same preset bit portion.
[0059] Building upon the foregoing embodiments, this application further provides a scheme for joint optimization of quantization and entropy coding. It is understood that, in order to achieve joint optimization of quantization and entropy coding, and to guide the quantization operation by incorporating the characteristics of the new entropy coding code table, the quantized result is used as much as possible in entropy coding as possible 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 current value to be encoded and the previously encoded value belong to the same interval during the quantization process, thereby achieving higher entropy coding efficiency.
[0060] Specifically, the source symbol to be encoded is obtained by quantizing the original information to be encoded; wherein, the quantization process is as follows: quantizing the original information to be encoded using quantization parameters to obtain the current quantization result; if the current quantization result and the historical quantization result corresponding to the previous original information to be encoded meet a preset condition, then the current quantization result is adjusted so that the adjusted result and the historical quantization result belong to the same interval; the adjusted result is used as the source symbol to be encoded; if the current quantization result and the historical quantization result corresponding to the previous original information to be encoded do not meet the preset condition, then the current quantization result is the source symbol to be encoded.
[0061] First, it should be noted that in some compression scenarios, such as lossy image or video compression, the original information is usually quantized first, and then the quantization result is entropy encoded to obtain the final compression result. Specifically, when performing the quantization step, the quantization parameter (QP) needs to be determined according to a certain method and strategy. Then, the original information to be encoded is quantized using the quantization parameter to obtain the current quantization result.
[0062] 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.
[0063] Furthermore, by judging whether the current quantization result meets the preset conditions with the historical quantization result corresponding to the previous original information to be encoded, it is determined whether the current quantization result needs to be adjusted.
[0064] In one specific implementation, if the current quantization result does not meet the preset conditions compared to the historical quantization result corresponding to the previous original information to be encoded, the current quantization result is directly used as the source symbol to be encoded, that is, the current quantization result is not adjusted. In other words, this application only adjusts the current quantization result when the preset conditions are met. This avoids indiscriminate modification of the quantization result and ensures the rationality of the quantization adjustment.
[0065] In another specific implementation, if the current quantization result and the historical quantization result corresponding to the previous original information to be encoded meet a preset condition, the current quantization result is actively adjusted so that the adjusted final quantization result belongs to the same interval as the historical quantization result, thereby using the adjusted result as the source symbol to be encoded. That is, this application adjusts the current quantization result to fall into a more efficient encoding interval, enabling it to be used in subsequent encoding. Figure 3 Encoding is performed using the code table on the right side of the code table, so that the value to be encoded belongs to the same interval as the previously encoded value, and the same codeword part is avoided from being encoded repeatedly, effectively shortening the code stream length, directly reducing redundant bits, significantly reducing the code rate, and realizing the joint optimization of quantization and entropy coding.
[0066] In one specific embodiment, 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; and the difference between the amplitude value of the current quantization result and the maximum value of the interval to which the historical quantization result belongs is less than a second preset threshold.
[0067] Specifically, 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 interval to which the historical quantization result belongs is A2. It should be noted that the quantization result is usually an integer, which may be positive, negative, or zero. For subsequent entropy encoding (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 (i.e., QP≤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 interval to which the historical quantization results belong is less than the second preset threshold TH2, i.e., A1-A2 <TH2。
[0068] The historical quantization result interval refers to the interval where B is located, which has a corresponding maximum value, i.e., the maximum allowed encoded value within that interval. When all four conditions above 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 where B is located, 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.
[0069] 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.
[0070] 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.
[0071] 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.
[0072] In another specific embodiment, 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; and the difference between the minimum value of the interval to which the historical quantization result belongs and the amplitude value of the current quantization result is less than a second preset threshold.
[0073] Specifically, 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, the amplitude of the historical quantization result be B, and the minimum value of the interval to which the historical quantization result belongs be A2. When all four of the following conditions are met, 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 (i.e., QP≤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 interval to which the historical quantization results belong and the amplitude value A1 of the current quantization result is less than the second preset threshold TH2, i.e., A2-A1. <TH2。
[0074] The historical quantization result interval refers to the interval where B is located, which has a corresponding minimum encoded value, i.e., the minimum allowed encoded value within that interval. When all four conditions above are met, an adjustment operation is performed, that is, the amplitude value A1 of the current quantization result is adjusted to the minimum encoded value A2 of the interval where B is located, 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.
[0075] In addition, the values of TH1 and TH2 can be found in the previous content, and will not be repeated here.
[0076] 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.
[0077] 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.
[0078] 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.
[0079] In another specific embodiment, this application also provides a quantization adjustment method that does not rely on historical quantization results. It is understood that, taking the standard exponential Columbus coding as an example, referring to... Figure 1 Observing the column with order k=0, we find some critical values X (e.g., 1 / 3 / 7 / 15…). The exponential Golomb codeword length jumps at these critical values. For example, when X=2, the codeword is 101 with a length of 3, but immediately after X=3, the codeword is 11000, and the length jumps from 3 to 5. A small change in the value of X causes a jump in codeword length. If we force quantization from X=3 to X=2, we gain 2 bits in code rate. Therefore, this embodiment can directly perform quantization fine-tuning from the critical points of the code table, 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 boundaries), this quantization adjustment method can be used.
[0080] Specifically, the preset conditions include: the quantization parameter is not greater than a first preset threshold; and the difference between the amplitude value of the current quantization result and the maximum value of the previous interval in the interval where the current quantization result is located is less than a second preset threshold.
[0081] 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 a critical point 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 previous interval of the current quantization result be A2. When both of the following 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 (i.e., QP≤TH1). Condition 2: The difference between the amplitude value A1 of the current quantization result and the maximum value A2 of the previous interval in the interval containing the current quantization result is less than the second preset threshold TH2, i.e., A1-A2 <TH2。
[0082] Here, the preceding interval refers to the encoding interval preceding the current quantization result (i.e., the interval with an index value less than 1), which has a corresponding maximum value. When both of the above 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 preceding interval, and A2 is output as the final quantization result. If either of the above conditions is not met, A1 is output as the final quantization result.
[0083] 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.
[0084] 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.
[0085] See Figure 5 As shown in the figure, this application discloses a specific decoding method, which specifically includes: Step S21: Obtain the target codeword to be decoded.
[0086] In this step, the target codeword to be decoded is obtained. This target codeword is a part of the bitstream generated by the above encoding method. It can be read from the storage medium or received from the transmission channel.
[0087] Step S22: Parse the flag bit codeword from the target codeword; wherein, the flag bit codeword is used to characterize whether the source symbol corresponding to the target codeword belongs to the same interval as the previously decoded source symbol, and the original codewords of multiple source symbols in the same interval have the same preset bit.
[0088] In this embodiment, the encoding and decoding ends agree on the same flag bit codeword length (usually 1 bit). During decoding, the flag bit codeword is first read from the target codeword. If the flag bit codeword is the first codeword (e.g., 1), it indicates that the currently decoded source symbol belongs to the same interval as the previously decoded source symbol; if the flag bit codeword is the second codeword (e.g., 0), it indicates that they do not belong to the same interval. The original codewords of multiple source symbols within the same interval have the same preset bits.
[0089] Step S23: Determine the codeword structure of the suffix codeword based on the flag codeword, so as to parse the suffix codeword from the target codeword based on the codeword structure.
[0090] In this embodiment, the codeword structure of the suffix codeword varies depending on the flag codeword. If the flag codeword is the first codeword, the suffix codeword only contains the suffix portion of the current source symbol within its respective interval. If the flag codeword is the second codeword, the suffix codeword may have two structures: the suffix codeword is the complete original codeword, or the suffix codeword includes both the interval codeword and the suffix portion.
[0091] The decoding end needs to determine which structure to use based on the scheme agreed upon by the encoding end. A fixed scheme can be pre-agreed between the encoding and decoding ends, or a mode indicator bit can be added to the bitstream to dynamically switch schemes.
[0092] Step S24: Recover the source symbol based on the flag codeword and the suffix codeword.
[0093] In this embodiment, the original source symbol can be recovered after obtaining the flag codeword and suffix codeword. The decoding process corresponding to Scheme 1 is illustrated below: Step 1: Read 1 bit from the target codeword to obtain the flag codeword. 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.
[0094] 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.
[0095] 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.
[0096] 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.
[0097] 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.
[0098] 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.
[0099] 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.
[0100] In summary, this application can correctly parse the target codeword generated by the encoding end, determine the codeword structure of the suffix codeword by parsing the flag bit codeword, and then parse the suffix codeword from the target codeword to finally recover the original source symbol. The decoding process and the encoding process are inverse processes of each other, ensuring the correctness and consistency of data compression and recovery.
[0101] See Figure 6 As shown in the figure, an encoding device is disclosed in this application embodiment, the device comprising: Acquisition module 11 is used to acquire the source symbols to be encoded; The flag bit determination module 12 is used to determine the flag bit codeword of the source symbol to be encoded based on whether the source symbol to be encoded and the previously encoded source symbol belong to the same interval, wherein the original codewords of multiple source symbols to be encoded within the same interval have the same preset bit; The suffix determination module 13 is used to determine the suffix codeword of the source symbol to be encoded based on the flag bit codeword, wherein the suffix codeword includes at least a portion of the original codeword of the source symbol to be encoded; The codeword determination module 14 is used to determine the target codeword for encoding the source symbol to be encoded based on the flag bit codeword and the suffix codeword, wherein the target codeword includes the flag bit codeword and the suffix codeword.
[0102] As can be seen, this application pre-divides intervals so that the original codewords of multiple source symbols to be encoded within the same interval have the same preset bits. Then, during the actual encoding process, the corresponding flag bit codeword is determined based on whether the current source symbol to be encoded belongs to the same interval as the previously encoded source symbol. This achieves the identification and marking of the same preset bit portion, avoiding the repeated transmission of the same preset bit codeword during continuous encoding, thereby effectively reducing the code rate. Furthermore, the specific content of the suffix codeword is determined based on the determined flag bit codeword. Finally, the target codeword is composed of the flag bit codeword and the suffix codeword, thus completing the entropy encoding process. In other words, this application improves the entropy encoding efficiency by utilizing the correlation between adjacent source symbols to omit the encoding of the same preset bit portion.
[0103] 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.
[0104] Figure 7 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 encoding or decoding methods performed by the electronic device disclosed in any of the foregoing embodiments.
[0105] 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.
[0106] 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.
[0107] 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.
[0108] 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 computer programs capable of performing the encoding or decoding methods disclosed in any of the foregoing embodiments and executed by the electronic device 20, 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.
[0109] 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 encoding or decoding method steps disclosed in any of the foregoing embodiments.
[0110] 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.
[0111] 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.
[0112] 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.
[0113] 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.
[0114] The above provides a detailed description of the encoding method, decoding 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, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. An encoding method, characterized in that, include: Obtain the source symbols to be encoded; The flag bit codeword of the source symbol to be encoded is determined based on whether the source symbol to be encoded and the previously encoded source symbol belong to the same interval. The original codewords of multiple source symbols to be encoded within the same interval have the same preset bit. The suffix codeword of the source symbol to be encoded is determined according to the flag bit codeword, wherein the suffix codeword includes at least a portion of the original codeword of the source symbol to be encoded; The target codeword for encoding the source symbol to be encoded is determined based on the flag codeword and the suffix codeword, wherein the target codeword includes the flag codeword and the suffix codeword.
2. The encoding method according to claim 1, characterized in that, The original codewords of multiple source symbols to be encoded within the same interval also have the same length.
3. The encoding method according to claim 1, characterized in that, The step of determining the flag bit codeword of the source symbol to be encoded based on whether the source symbol to be encoded belongs to the same interval as the previously encoded source symbol includes: If the source symbol to be encoded belongs to the same interval as the previously encoded source symbol, then the flag bit codeword is determined to be the first codeword; If the source symbol to be encoded does not belong to the same interval as the previously encoded source symbol, then the flag bit codeword is determined to be the second codeword.
4. The encoding method according to claim 3, characterized in that, Determining the suffix codeword of the source symbol to be encoded based on the flag bit codeword includes: If the flag bit codeword is the first codeword, then the codewords in the original codeword other than the preset bit identical codewords are used as the suffix codewords of the source symbol to be encoded. If the flag codeword is the second codeword, then all the codewords in the original codeword are used as the suffix codewords of the source symbol to be encoded, or the interval codewords of the interval to which the source symbol to be encoded belongs and the codewords in the original codeword other than the preset codewords are used as the suffix codewords of the source symbol to be encoded.
5. The encoding method according to claim 4, characterized in that, Also includes: Count the total number of intervals under different order parameters; The encoding length of the interval codeword is determined based on the total number of intervals, and a fixed-length encoding method is used to assign a corresponding interval codeword to each interval based on the encoding length.
6. The encoding method according to claim 1, characterized in that, Determining the target codeword for encoding the source symbol to be encoded based on the flag codeword and the suffix codeword includes: The flag codeword and the suffix codeword are concatenated to obtain the target codeword for encoding the source symbol to be encoded.
7. The encoding method according to any one of claims 1 to 6, characterized in that, The source symbol to be encoded is obtained by quantizing the original information to be encoded; wherein, the quantization process is as follows: The original information to be encoded is quantized using quantization parameters to obtain the current quantization result; If the current quantization result and the historical quantization result corresponding to the previous original information to be encoded meet the preset conditions, then the current quantization result is adjusted so that the adjusted result and the historical quantization result belong to the same interval; The adjusted result is used as the source symbol to be encoded; If the current quantization result does not meet the preset conditions with the historical quantization result corresponding to the previous original information to be encoded, then the current quantization result is the source symbol to be encoded.
8. A decoding method, characterized in that, include: Obtain the target codeword to be decoded; Parse the flag bit codeword from the target codeword; wherein, the flag bit codeword is used to characterize whether the source symbol corresponding to the target codeword belongs to the same interval as the previously decoded source symbol, and the original codewords of multiple source symbols in the same interval have the same preset bit; The codeword structure of the suffix codeword is determined based on the flag codeword, so as to parse the suffix codeword from the target codeword based on the codeword structure; The source symbol is recovered based on the flag codeword and the suffix codeword.
9. An encoding device, characterized in that, include: The acquisition module is used to acquire the source symbols to be encoded. The flag bit determination module is used to determine the flag bit codeword of the source symbol to be encoded based on whether the source symbol to be encoded and the previously encoded source symbol belong to the same interval, wherein the original codewords of multiple source symbols to be encoded within the same interval have the same preset bit; The suffix determination module is used to determine the suffix codeword of the source symbol to be encoded based on the flag bit codeword, wherein the suffix codeword includes at least a portion of the original codeword of the source symbol to be encoded; The codeword determination module is used to determine the target codeword for encoding the source symbol to be encoded based on the flag codeword and the suffix codeword, wherein the target codeword includes the flag codeword and the suffix codeword.
10. 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 encoding method as claimed in any one of claims 1 to 7 and / or to implement the steps of the decoding method as claimed in claim 8.