An entropy coding-based coding method, system, storage medium and device

By calculating the remaining probability and adjusting the code length, the entropy coding scheme is dynamically corrected, which solves the information redundancy problem caused by fixed-length coding and improves storage efficiency.

CN115425986BActive Publication Date: 2026-03-27SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-23
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

The use of fixed-length encoding in existing entropy coding techniques leads to information redundancy and affects storage efficiency.

Method used

By calculating the sum of the probabilities of the remaining symbols that have not been fully encoded as the remaining probability, the code length and threshold of the current symbol are adjusted, and the code length is dynamically corrected to reduce redundancy, thus adopting a variable-length coding scheme.

Benefits of technology

It effectively reduces the encoding bit width, shrinks the data volume, and saves storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115425986B_ABST
    Figure CN115425986B_ABST
Patent Text Reader

Abstract

The application provides a coding and decoding method, system, storage medium and equipment based on entropy coding, the method comprising: in response to part of the symbols in the to-be-coded symbols having been coded, taking the sum of the probabilities corresponding to the remaining symbols which have not been coded as a remaining probability; in response to the current symbol being prepared to be coded, calculating the code length corresponding to the current probability of the current symbol, and calculating a threshold based on the code length and the remaining probability; modifying the code length based on the threshold to obtain a new code length; obtaining a current code word based on the current probability and the threshold, and decoding the current code word. The application solves the problem that the equal-length coding method in the prior art causes information redundancy in entropy coding, reduces the bit width required for coding, and in turn reduces the data quantity, which is beneficial to saving storage space.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of coding and decoding technology, and in particular to a coding and decoding method and system based on entropy coding, a storage medium and equipment. BACKGROUND

[0002] With the rapid development of Internet, Internet of Things and other technologies, human society has entered the era of "Internet of Everything". The rapid development of cutting-edge technologies such as cloud computing, big data, artificial intelligence and blockchain has led to explosive growth of data. In the continuous development of industrial digital transformation, data has become a key production factor. In the face of the continuous growth of massive data, data compression has become the most effective method to reduce server storage burden and storage cost.

[0003] Data compression can reduce storage space by reducing data volume without losing useful information, which can improve transmission, storage and processing efficiency. Lossless data compression is generally achieved by two methods: one is to achieve compression through a dictionary, including LZ series algorithms, which can search for repeated data; the other is an entropy coding algorithm based on a frequency statistical model, such as Huffman coding, arithmetic coding and asymmetric digital system (ANS), etc. The core idea of this algorithm is to assign code length according to symbol frequency, and the larger the symbol frequency, the shorter the code length, which can be described by the following two formulas:

[0004] P(1)≤P(2)≤P(3)…≤P(N-1)≤P(N)

[0005] L(1)≥L(2)≥L(3)…≥L(N-1)≥L(N)

[0006] In order to achieve higher compression ratio, the current most common data compression algorithm will use the above two methods for hybrid compression. All compression algorithms need to update and package the probability distribution of entropy coding periodically (in blocks). When packaging Huffman coding, the Deflate protocol only encodes and packages the Huffman code length of each symbol, which is equivalent to the probability of 2 raised to the power of -1. For entropy coding algorithms that pursue higher compression ratio, such as arithmetic coding and asymmetric digital system, both of which pursue more accurate probability to approach the information entropy of the information source.

[0007] Data compression algorithms usually perform probability statistics based on block data. In order to enable the decoding end to accurately decode and restore compressed data, the probability distribution obtained by the encoder needs to be encoded and packaged into compressed data. The decoding end obtains the same probability distribution as the encoding end by parsing, and then accurately restores the original data.

[0008] Most current compression formats use the method of equal-length coding to package the probability of symbols one by one, and each probability uses a uniform coding length n when packaging.

[0009] For example, the following probability distribution: {8, 17, 4, 5, 1, 1, 2, 3, 12, 40, 37, 5, 2, 19, 18, 17, 17, 1, 13, 5, 2, 1, 24, 1, 1}, the probability sum is 256, so each probability encoding code length n = 8, then the total code length required to package this probability set is 200 (i.e. 25 * 8) bits.

[0010] The reason why the equal length coding adopts the bit width n corresponding to the probability sum is that the possible value of a single probability is large, and the decoding end cannot know the value of the probability, and can only decode the probability with the maximum bit width. However, the packaging of the probability distribution is sequentially packaged for the probability, so after the encoding of a probability is completed, the subsequent probability value range (maximum value) will be reduced accordingly. In the above example, when the first probability "8" is encoded and packaged, the value range of the second probability will be changed to [0, 248]. It should be noted that the value range of this probability is perceptible to the decoding end.

[0011] Based on this, after the encoding of a probability is completed, not only the possible value range (maximum value) of the subsequent probability can be calculated, but also the bit width of the subsequent probability can be updated in time. For example, when 37 is encoded, the value range of the subsequent probability is updated to [0, 126], and at this time, the encoding bit width of the subsequent probability can be adjusted to

[0012] The sum of the probabilities that have not been encoded in the encoding process is called the remaining probability. A coding bit width can be calculated from the remaining probability, and according to information theory, the best code length is Obviously, the former is not less than the latter, and there is a certain information redundancy. In order to solve this information redundancy, a coding mode with variable code length, especially a coding mode with reducible code length is needed. SUMMARY

[0013] Therefore, the purpose of the present application is to provide an entropy coding method, system, storage medium and device based on entropy coding, to solve the problem of information redundancy caused by the equal length coding in the entropy coding in the prior art.

[0014] In order to achieve the above purpose, the present application provides an entropy coding method based on entropy coding, comprising the following steps:

[0015] In response to the fact that part of the symbols in the to-be-encoded symbol have been encoded, the sum of the probabilities corresponding to the remaining symbols that have not been encoded is taken as the remaining probability;

[0016] In response to the fact that the current symbol is ready to be encoded, the code length corresponding to the current probability of the current symbol is calculated, and a threshold value is calculated based on the code length and the remaining probability;

[0017] The code length is corrected based on the threshold to obtain a new code length.

[0018] A current code word is obtained based on the current probability and the threshold, and the current code word is decoded.

[0019] In some embodiments, the code length is corrected based on the threshold to obtain a new code length includes:

[0020] determining whether the current probability is less than the threshold;

[0021] in response to the current probability being less than the threshold, decreasing the code length by one to obtain a corrected new code length.

[0022] In some embodiments, the current code word is obtained based on the current probability and the threshold includes:

[0023] determining whether the current probability is less than the threshold;

[0024] in response to the current probability being less than the threshold, taking a value of the current probability as the current code word; or

[0025] in response to the current probability being greater than or equal to the threshold, calculating a sum of the value of the current probability and the threshold as the current code word.

[0026] In some embodiments, the code length corresponding to the current probability of the current symbol is calculated, and the threshold is calculated based on the code length and the residual probability includes:

[0027] calculating a logarithm of the residual probability with a base of 2 to obtain the code length;

[0028] performing an exponentiation operation with the code length as an exponent and 2 as a base to obtain an exponentiation result, and calculating a difference between the exponentiation result and the residual probability to obtain the threshold.

[0029] In some embodiments, decoding the current code word includes:

[0030] parsing the current code word to obtain a decoded code word, wherein a number of bits parsed is equal to the new code length;

[0031] determining whether a value of the decoded code word is less than the threshold, and determining whether the number of bits parsed is increased by one based on the determination result, and determining a probability value corresponding to a symbol decoded from the current code word based on the determination result.

[0032] In some embodiments, determining whether the number of bits parsed is increased by one based on the determination result includes:

[0033] in response to the value of the decoded code word being less than the threshold, determining that the number of bits parsed does not need to be increased;

[0034] in response to the value of the decoded code word being greater than or equal to the threshold, determining that the number of bits parsed needs to be increased by one.

[0035] In some embodiments, determining the probability value corresponding to the decoded symbol of the current code word based on the determination result comprises:

[0036] in response to the value of the decoded code word being less than the threshold, taking the value of the decoded code word as the probability value corresponding to the decoded symbol;

[0037] in response to the value of the decoded code word being greater than or equal to the threshold, determining the probability value corresponding to the decoded symbol based on the value of the decoded code word, the threshold, and the number of bits read from the bit stream.

[0038] Another aspect of the present application also provides a coding and decoding system based on entropy coding, comprising:

[0039] a residual probability module configured to, in response to some of the symbols in the to-be-coded symbols having been coded, take the sum of the probabilities corresponding to the remaining symbols that have not been coded as the residual probability;

[0040] a calculation module configured to, in response to the current symbol being ready to be coded, calculate the code length corresponding to the current probability of the current symbol, and calculate the threshold based on the code length and the residual probability;

[0041] a code length correction module configured to correct the code length based on the threshold to obtain a new code length; and

[0042] a decoding module configured to obtain the current code word based on the current probability and the threshold, and decode the current code word.

[0043] Still another aspect of the present application also provides a computer readable storage medium storing computer program instructions, which, when executed by a processor, implement the above method.

[0044] Still another aspect of the present application also provides a computer device comprising a memory and a processor, the memory storing a computer program, which, when executed by the processor, performs the above method.

[0045] The present application has at least the following beneficial technical effects:

[0046] The present application takes the sum of the probabilities corresponding to the remaining symbols that have not been coded as the residual probability, and in response to the current symbol being ready to be coded, calculates the code length corresponding to the current probability of the current symbol, and calculates the threshold based on the code length and the residual probability, and corrects the code length based on the threshold to obtain a new code length, and then obtains the current code word based on the current probability and the threshold, and decodes the current code word, thereby solving the problem of information redundancy caused by the use of equal length coding in entropy coding in the prior art, reducing the bit width required for coding, and further reducing the data volume, which is beneficial to saving storage space. BRIEF DESCRIPTION OF DRAWINGS

[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention 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 some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a schematic diagram of an entropy-based encoding / decoding method provided according to an embodiment of the present invention;

[0049] Figure 2 This is a schematic diagram of an entropy-based encoding / decoding system provided according to an embodiment of the present invention;

[0050] Figure 3 This is a schematic diagram of a computer-readable storage medium for implementing an entropy-based encoding / decoding method according to an embodiment of the present invention;

[0051] Figure 4 This is a schematic diagram of the hardware structure of a computer device for executing an entropy-based encoding / decoding method according to an embodiment of the present invention. Detailed Implementation

[0052] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to specific examples and the accompanying drawings.

[0053] It should be noted that all uses of "first" and "second" in the embodiments of the present invention are for the purpose of distinguishing two different entities or different parameters with the same name. Therefore, "first" and "second" are merely for convenience of expression and should not be construed as limiting the embodiments of the present invention. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, such as other steps or units inherent in a process, method, system, product, or device that includes a series of steps or units.

[0054] To achieve the above objectives, a first aspect of the present invention provides an embodiment of an entropy-based encoding and decoding method. Figure 1 The diagram shown is a schematic representation of an embodiment of the entropy-based encoding / decoding method provided by the present invention. Figure 1 As shown, the embodiments of the present invention include the following steps:

[0055] Step S10: In response to the fact that some symbols in the symbols to be encoded have been encoded, the sum of the probabilities corresponding to the remaining symbols that have not been encoded is taken as the remaining probability;

[0056] Step S20, in response to the current symbol being ready for encoding, calculating the code length corresponding to the current probability of the current symbol, and calculating the threshold value based on the code length and the residual probability;

[0057] Step S30, correcting the code length based on the threshold value to obtain a new code length;

[0058] Step S40, obtaining the current code word based on the current probability and the threshold value, and decoding the current code word.

[0059] The embodiment of the present application solves the problem of information redundancy caused by the equal length coding method in the entropy coding in the prior art by calculating the code length corresponding to the current probability of the current symbol when the current symbol is ready for encoding, calculating the threshold value based on the code length and the residual probability, correcting the code length based on the threshold value to obtain a new code length, and obtaining the current code word based on the current probability and the threshold value and decoding the current code word, thereby reducing the bit width required for encoding, and further reducing the data amount, which is beneficial to saving storage space.

[0060] In some embodiments, the step of correcting the code length based on the threshold value to obtain a new code length comprises: judging whether the current probability is less than the threshold value; and in response to the current probability being less than the threshold value, reducing the code length by one to obtain the corrected new code length.

[0061] In some embodiments, the step of obtaining the current code word based on the current probability and the threshold value comprises: judging whether the current probability is less than the threshold value; in response to the current probability being less than the threshold value, taking the value of the current probability as the current code word; or in response to the current probability being greater than or equal to the threshold value, calculating the sum of the value of the current probability and the threshold value as the current code word.

[0062] In some embodiments, the step of calculating the code length corresponding to the current probability of the current symbol and calculating the threshold value based on the code length and the residual probability comprises: calculating the logarithm of the residual probability with base 2 to obtain the code length; performing power operation with the code length as the exponent and 2 as the base to obtain a power operation result, and calculating the difference between the power operation result and the residual probability to obtain the threshold value.

[0063] In some embodiments, the step of decoding the current code word comprises: parsing the current code word to obtain a decoded code word, wherein the number of bits parsed is equal to the new code length; judging whether the value of the decoded code word is less than the threshold value, and based on the judgment result, determining whether the number of bits parsed is increased by one bit, and based on the judgment result, determining the probability value corresponding to the symbol decoded from the current code word.

[0064] In some embodiments, determining whether the number of bits of the parsed symbol is increased by one based on the result of the judgment comprises: in response to the value of the decoded code word being less than the threshold, determining that the number of bits of the parsed symbol does not need to be increased; and in response to the value of the decoded code word being greater than or equal to the threshold, determining that the number of bits of the parsed symbol needs to be increased by one.

[0065] In some embodiments, determining the probability value corresponding to the decoded symbol of the current code word based on the result of the judgment comprises: in response to the value of the decoded code word being less than the threshold, taking the value of the decoded code word as the probability value corresponding to the decoded symbol; and in response to the value of the decoded code word being greater than or equal to the threshold, determining the probability value corresponding to the decoded symbol based on the value of the decoded code word, the threshold, and the number of bits read from the bit stream.

[0066] The specific implementation of the entropy coding method of the present application is as follows:

[0067] Since the coding bit width of each probability is determined by the information amount of the remaining probability, assuming that the remaining probability is p, and the corresponding coding code length is L, then

[0068] The relationship between L and P satisfies the following relationship: 2 L ≥P, the subsequent probability value range is [1, P], but the value range of the number with code length L is [1, 2 L ], and obviously the range of the latter is greater than that of the former, and there is a number redundancy. To solve this problem, the simplest assumption is to divide the interval [1, P] into two parts, one part has a coding code length (code length represents the bit width required by the coding symbol) of L, and the other part has a code length of L-1. If this assumption is true, it is obvious that a more efficient coding scheme has been found. In order to construct a feasible coding scheme for this assumption, the following problems need to be considered and solved:

[0069] 1. The probability value range corresponding to each of the two code lengths;

[0070] 2. For a single possible probability, how to allocate the code length and the code word;

[0071] 3. Since the decoding end is not aware of the code length and can only perceive the code word, how does the decoding end determine the code length of the probability.

[0072] Regarding the calculation of determining the number of symbols corresponding to the two code lengths, here the number corresponding to the short code length (L-1) is num1, and the number corresponding to the longer code length (L) is num2. Obviously, num1 and num2 satisfy the following relationship:

[0073] num1+num2=P (1)

[0074] Thus, to solve num1 and num2, another relationship needs to be found: the total space of code words of code length L (the total number of code words) is 2 L , if a single short code length (L-1) is mapped to the space of code length L, it can correspond to two code words. Thus, num1 and num2 have the following relationship: 2*num1+num2=2 L ;

[0075] The following equation set can be obtained:

[0076]

[0077] Solving the above equation set, the following solution can be obtained:

[0078]

[0079] Each symbol code length and code word allocation:

[0080] After the above calculation, the total number of symbols corresponding to two code lengths: num1 and num2 has been obtained. In this step, the code length and code word of each symbol need to be determined. The following method can be used: smaller symbols are allocated smaller code length (L-1), and larger symbols are allocated longer code length (L), as shown in the following formula:

[0081]

[0082] Regarding code word allocation, variable length coding generally uses a "continuous" allocation scheme, that is, the code words of symbols with the same code length belong to the same interval. For the case of "two code lengths" here, there are two possible schemes:

[0083] a. The base value (the minimum value / reference value of the numerical interval) corresponding to the code word interval of the short code length is smaller, and the base value corresponding to the code word interval of the longer code length is larger. As shown in formula (5)

[0084]

[0085] Where code refers to the code word after encoding packaging; S refers to symbol, also refers to probability value; between the two, it can be regarded as a corresponding relationship: the encoding end transforms S to get code(s), and the decoding end transforms code(s) to get s.

[0086] b. The base value corresponding to the code word interval of the short code length is larger, and the base value corresponding to the code word interval of the longer code length is smaller. As shown in formula (6):

[0087]

[0088] Comparing (5) and (6), it can be found that the code word of the symbol in the short code length interval in (5) is equal to the symbol itself, which is beneficial to code word calculation at the encoding end and code word decoding at the decoding end. Therefore, the code word allocation scheme in (5) is adopted in the embodiment.

[0089] Regarding determination of the code length at the decoding end: since the decoding end is not aware of the code length and can only perceive the code word, the code length and the symbol can only be determined according to the code word. The encoding end and the decoding end share a symbol set {s}, and the decoding end is aware of the number N of types of {s}, so the decoding end is also aware of num1 and num2. The decoding scheme corresponding to formula (5) is as follows:

[0090] First, a (L-1) bit binary code is read. If the code < num1, the code is the final decoding result, and the code length is (L-1);

[0091] If the code ≥ num1, 1 bit needs to be additionally read, and the final decoding result is calculated by carry, and the code length is L.

[0092]

[0093] Wherein, read represents reading data from the code stream, and read_bits(1) represents reading 1 bit of data.

[0094] In the entropy encoding algorithm, the probability distribution has the following characteristics:

[0095] 1. The total number of probabilities is limited to 2 n , where n determines the accuracy of the probability, and the larger the value of n, the higher the accuracy of the probability;

[0096] 2. For the probability of a single symbol, the possible value range is large, and the limit range fp s ∈[1,2 n ), and the empirical value is approximately fp s ∈[1,2 n-2 ];

[0097] 3. The total number of data is limited, which is related to the specific compression format protocol, and is usually 20-50.

[0098] Based on the above, the embodiment designs a code length variable encoding scheme to minimize the code length and efficiently encode and package the probability distribution. The process is as follows:

[0099] 1) Calculate (update) the remaining probability, that is, the sum of the subsequent probability values to be encoded:

[0100]

[0101] 2) Calculate (update) the current probability corresponding to the encoding bit width: bit is the longer code length.

[0102] 3) Calculate the threshold thresh, the calculation method is the same as the num1 calculation method of the above formula (3): thresh = 2 bit -P res

[0103] 4) Encoding bit width correction, get new code length, same as the above formula (4), as follows:

[0104]

[0105] 5) Binary original code encoding current probability value, the code word formula of encoding is the same as the above formula (5), as follows:

[0106]

[0107] The pseudo code is as follows:

[0108]

[0109]

[0110] Take the probability distribution: {8, 17, 4, 5, 1, 1, 2, 3, 12, 40, 37, 5, 2, 19, 18, 17, 17, 1, 13, 5, 2, 1, 24, 1, 1} as an example, the probability sum is 256. The encoding results of each probability in the probability distribution are shown in the following table 1:

[0111] Table 1: Encoding results of each probability

[0112]

[0113]

[0114] The decoding process corresponding to the encoding scheme of the embodiment is as follows:

[0115] 1) Calculate (update) the remaining probability, that is, the sum P of the subsequent to-be-encoded probability values res ;

[0116] 2) Determine the reference code length bit from the remaining probability calculation

[0117] 3) Threshold thresh calculation, thresh = 2 bit -P res ;

[0118] 4) First parse (bit-1) from the code stream to get a binary code;

[0119] 5) According to the value of code, it is determined whether an additional bit needs to be parsed:

[0120] code is compared with thresh, and then it is determined whether an additional bit needs to be read:

[0121] If code < thresh, an additional bit does not need to be read, and the probability value is fp s = code;

[0122] If code >= thresh, an additional bit needs to be read, and the probability value is fp s = 2*code + read_bit(1) - thresh.

[0123] In the embodiment, the code length and code word of the 25 probabilities are shown in the last two columns of Table 1. The code length of each probability is added, and the total code length of the probability distribution package is 147 bits (i.e. 8x2 + 7x11 + 6x4 + 5x4 + 4x2 + 2). Compared with the equal length coding (200 bits), the advantage of the embodiment is obvious.

[0124] The second aspect of the embodiment of the present application further provides an entropy coding-based coding and decoding system. Figure 2 An embodiment of the entropy coding-based coding and decoding system provided by the present application is shown in the schematic diagram. As shown in the diagram, the entropy coding-based coding and decoding system comprises: a residual probability module 10 configured to, in response to part of the symbols in the to-be-coded symbols having been coded, take the sum of the probabilities corresponding to the residual symbols which have not been coded as a residual probability; a calculation module 20 configured to, in response to the current symbol being ready to be coded, calculate the code length corresponding to the current probability of the current symbol, and calculate a threshold based on the code length and the residual probability; a code length correction module 30 configured to correct the code length based on the threshold to obtain a new code length; and a decoding module 40 configured to obtain the current code word based on the current probability and the threshold, and decode the current code word. Figure 2 The third aspect of the embodiment of the present application further provides a computer readable storage medium,

[0125] An embodiment of the computer readable storage medium for implementing the entropy coding-based coding and decoding method provided by the present application is shown in the schematic diagram. As shown in the diagram, the computer readable storage medium 3 stores computer program instructions 31. The computer program instructions 31 are executed by a processor to implement the method of any one of the above embodiments. Figure 3 Figure 3

[0126] ​​It should be understood that, where there is no conflict, all the embodiments, features and advantages described above for the entropy-based encoding and decoding method according to the present invention are equally applicable to the entropy-based encoding and decoding system and storage medium according to the present invention.

[0127] A fourth aspect of the present invention also provides a computer device, including as follows: Figure 4 The memory 402 and processor 401 shown are provided. The memory 402 stores a computer program that, when executed by the processor 401, implements the method of any of the above embodiments.

[0128] like Figure 4 The diagram shown is a hardware structure schematic of an embodiment of a computer device for executing an entropy-based encoding / decoding method provided by the present invention. Figure 4 Taking the computer device shown as an example, this computer device includes a processor 401 and a memory 402, and may also include an input device 403 and an output device 404. The processor 401, memory 402, input device 403, and output device 404 can be connected via a bus or other means. Figure 4 Taking a bus connection as an example, input device 403 can receive input digital or character information, and generate key signal inputs related to user settings and function control of the entropy-based encoding / decoding system. Output device 404 may include display devices such as a display screen.

[0129] Memory 402, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions / modules corresponding to the entropy-based encoding / decoding method in the embodiments of this application. Memory 402 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created by using the entropy-based encoding / decoding method, etc. In addition, memory 402 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 402 may optionally include memory remotely located relative to processor 401, and these remote memories can be connected to the local module via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0130] The processor 401 executes various server functions and data processing by running non-volatile software programs, instructions, and modules stored in the memory 402, thereby implementing the entropy-based encoding and decoding method of the above method embodiment.

[0131] Finally, it is noted that the computer-readable storage media of the present application, for example, the memory, can be volatile or nonvolatile memory, or can include both volatile and nonvolatile memory. By way of example, and not limitation, nonvolatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM), which can act as external cache memory. By way of example, and not limitation, RAM is available in many forms such as Static RAM (DRAM), Dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The memory of the disclosed aspects is intended to include, without being limited to including, these and any other suitable types of memory.

[0132] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein can be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans can implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application embodiments disclosed.

[0133] The foregoing is a summary of the example embodiments disclosed herein, but it should be noted that various changes and modifications could be made therein without departing from the scope of the present application embodiments disclosed. The functions, steps and / or actions of the method claims in accordance with the embodiments described herein need not be performed in any particular order. Furthermore, although the elements of the present application embodiments disclosed can be described or claimed in particular combinations, each of these combinations is not limited to that combination. The methods and processes can be applied to other embodiments and the elements and components described herein can be arranged and combined in a variety of ways.

[0134] It is to be understood that the singular forms "a," "an," and "the" include plural referents unless the context clearly dictates otherwise. It is to be understood that the term "and / or" as used herein encompasses all possible combinations of the items listed. The above-described embodiments of the application embodiments disclosed are merely descriptive of its application embodiments disclosed and are not intended to be limiting.

[0135] Those skilled in the art should understand that the above discussion of any embodiment is only exemplary, and is not intended to mean that the scope of the embodiments disclosed by the present application (including claims) is limited to these examples; under the idea of the embodiments of the present application, the above embodiments or technical features in different embodiments can also be combined, and there are many other changes of different aspects of the embodiments of the present application as above. In order to be brief, they are not provided in details. Therefore, any omission, modification, equivalent replacement, improvement, etc. made in the spirit and principle of the embodiments of the present application shall be included in the protection scope of the embodiments of the present application.

Claims

1. An encoding / decoding method based on entropy coding, characterized in that, Includes the following steps: In response to the fact that some symbols in the symbols to be encoded have been encoded, the sum of the probabilities corresponding to the remaining symbols that have not been encoded is taken as the remaining probability; In response to the current symbol being prepared for encoding, the code length corresponding to the current probability of the current symbol is calculated, and a threshold is calculated based on the code length and the remaining probability; The code length is corrected based on the threshold to obtain a new code length; The current codeword is obtained based on the current probability and the threshold, and the current codeword is decoded. Decoding the current codeword includes: The current codeword is parsed to obtain the decoded codeword, wherein the number of parsed bits is equal to the new code length; Determine whether the value of the decoded codeword is less than the threshold, and based on the determination result, determine whether the number of bits to be parsed should be increased by one bit, and based on the determination result, determine the probability value corresponding to the symbol obtained by decoding the current codeword; The probability value corresponding to the symbol obtained by decoding the current codeword based on the judgment result includes: In response to the fact that the value of the decoded codeword is less than the threshold, the value of the decoded codeword is used as the probability value corresponding to the decoded symbol; In response to the value of the decoded codeword being greater than or equal to the threshold, the probability value corresponding to the decoded symbol is obtained based on the value of the decoded codeword, the threshold, and the number of bits read from the bitstream.

2. The method according to claim 1, characterized in that, The code length is corrected based on the threshold to obtain a new code length, including: Determine whether the current probability is less than the threshold; In response to the current probability being less than the threshold, the code length is reduced by one to obtain a corrected new code length.

3. The method according to claim 1, characterized in that, The current codeword is obtained based on the current probability and the threshold, including: Determine whether the current probability is less than the threshold; In response to the current probability being less than the threshold, the value of the current probability is used as the current codeword; or In response to the current probability being greater than or equal to the threshold, the sum of the current probability and the threshold is calculated as the current codeword.

4. The method according to claim 1, characterized in that, Calculating the code length corresponding to the current probability of the current symbol, and calculating the threshold based on the code length and the remaining probability, includes: The code length is obtained by calculating the logarithm of the remaining probability to base 2; Using the code length as the exponent and 2 as the base, perform a power operation to obtain the power operation result, and calculate the difference between the power operation result and the remaining probability to obtain the threshold.

5. The method according to claim 1, characterized in that, Determining whether to increase the number of bits in the parsed data based on the judgment result includes: In response to the fact that the value of the decoded codeword is less than the threshold, it is determined that the number of bits to be parsed does not need to be increased; In response to the value of the decoded codeword being greater than or equal to the threshold, it is determined that the number of bits to be parsed needs to be increased by one.

6. An entropy-based encoding and decoding system, characterized in that, include: The remaining probability module is configured to, in response to the fact that some symbols in the symbols to be encoded have been encoded, use the sum of the probabilities corresponding to the remaining symbols that have not been encoded as the remaining probability; The calculation module is configured to perform encoding in response to the current symbol preparation, calculate the code length corresponding to the current probability of the current symbol, and calculate a threshold based on the code length and the remaining probability; A code length correction module is configured to correct the code length based on the threshold to obtain a new code length; as well as A decoding module is configured to obtain the current codeword based on the current probability and the threshold, and to decode the current codeword; Decoding the current codeword includes: The current codeword is parsed to obtain the decoded codeword, wherein the number of parsed bits is equal to the new code length; Determine whether the value of the decoded codeword is less than the threshold, and based on the determination result, determine whether the number of bits to be parsed should be increased by one bit, and based on the determination result, determine the probability value corresponding to the symbol obtained by decoding the current codeword; The probability value corresponding to the symbol obtained by decoding the current codeword based on the judgment result includes: In response to the fact that the value of the decoded codeword is less than the threshold, the value of the decoded codeword is used as the probability value corresponding to the decoded symbol; In response to the value of the decoded codeword being greater than or equal to the threshold, the probability value corresponding to the decoded symbol is obtained based on the value of the decoded codeword, the threshold, and the number of bits read from the bitstream.

7. A computer-readable storage medium, characterized in that, The system stores computer program instructions that, when executed by a processor, implement the method as described in any one of claims 1-5.

8. A computer device, comprising a memory and a processor, characterized in that, The memory stores a computer program, which, when executed by the processor, performs the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • State selection method and system for finite state entropy coding, storage medium and equipment

    CN114513210A