An ANS encoding / decoding method, device, and medium based on finite field multiplication
By using the ANS encoding and decoding method based on finite field multiplication, the shortcomings of Huffman coding and arithmetic coding in data compression are solved, achieving efficient data compression and ensuring that the decoding end can parse the original symbol sequence.
Patent Information
- Application Number
- CN202211179219.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-27
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2042-09-27
AI Technical Summary
Existing Huffman coding and arithmetic coding have shortcomings in compression ratio and coding efficiency in the field of data compression. ANS coding cannot directly decode the original symbol sequence, making it difficult to achieve efficient data compression.
An ANS encoding and decoding method based on finite field multiplication is adopted. By using symbol probability statistics, probability normalization, construction of a cumulative frequency table and finite field multiplication calculation rules, a symbol allocation list is generated to achieve uniqueness and reversibility in the encoding and decoding process. The symbol allocation list Symbol[] is generated using the finite field multiplication calculation rules to construct the ANS encoding and decoding formula.
It improves data compression performance, achieving a compression ratio close to that of arithmetic coding and a coding efficiency close to that of Huffman coding, ensuring that the decoding end can parse the original symbol sequence.
Smart Images

Figure CN115765755B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and specifically to an ANS encoding / decoding method, device, and medium based on finite field multiplication. Background Technology
[0002] Entropy coding is a lossless data compression method. The core idea of entropy coding is to achieve compression by using fewer bits to represent frequently occurring symbols and more bits to represent rarely occurring elements.
[0003] Huffman coding and arithmetic coding are two of the most common entropy coding methods. Huffman coding is an entropy coding technique developed by David A. Huffman. The algorithm of Huffman coding is simple, based on the probabilistic ordering of the symbol set to allocate the code length. Huffman coding always uses integer bits to represent a symbol, and it encodes each symbol individually. Therefore, Huffman coding cannot guarantee optimal compression performance. Huffman coding produces optimal results when the probabilities of all symbols are negative powers of 2. In Huffman coding, each occurrence of a symbol is always encoded with the same codeword. The advantage of Huffman coding is its fast coding speed.
[0004] According to information theory, the ideal codeword length of a single symbol is determined solely by the probability of the symbol's occurrence: code-length(x) = -log p(x) If the probability of a symbol occurring is 0.4, then the ideal codeword length is 1.32(-log₂). 0.4 Unfortunately, Huffman coding can only assign codewords of integer length. This is a major drawback of the Huffman coding algorithm.
[0005] Arithmetic coding addresses this limitation of Huffman coding; it's another entropy coding technique. It encodes input data as a range of real numbers between 0 and 1. This range becomes smaller as the number of bits required to encode the input increases. Unlike Huffman coding, arithmetic coding uses near-precise probabilities, thus achieving compression rates close to the theoretical limit. However, the algorithm for arithmetic coding is more complex, and its coding efficiency is very low (roughly 1 / 10th that of Huffman coding), limiting its application in real-time data compression applications.
[0006] Therefore, in recent years, many scholars have been searching for a new algorithm that achieves a compression ratio close to that of arithmetic coding and a coding efficiency close to that of Huffman coding. In 2009, Jarek Duda proposed Asymmetric Numeral Systems (ANS). According to Jarek Duda, Asymmetric Numeral Systems achieve a compression ratio comparable to arithmetic coding while having a processing speed similar to Huffman coding. However, this mathematical relationship cannot be directly applied to ANS coding because it cannot be decoded; the decoding end cannot parse the original symbol sequence. Summary of the Invention
[0007] In view of this, the purpose of this invention is to propose an ANS encoding and decoding method, device and medium based on finite field multiplication, and to solve the technical problems in the background art by providing a feasible ANS encoding and decoding scheme.
[0008] To achieve the above objectives, on the one hand, the present invention provides an ANS encoding and decoding method based on finite field multiplication, including an ANS encoding method and an ANS decoding method, wherein the ANS encoding method includes the following steps:
[0009] The probability statistics of the symbols, probability normalization, yields the probability distribution {f1, f2, f3, ..., f}. n}, encoding probability distribution;
[0010] Construct a cumulative frequency table count[], and calculate the cumulative frequency as follows: count[s+1] = count[s] + freq[s];
[0011] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0012] According to the encoding formula, the symbol sequence is encoded sequentially in natural order;
[0013] The ANS decoding method includes the following steps:
[0014] Decode the probability distribution of each symbol set, {f1, f2, f3, ..., f...} n};
[0015] Construct a cumulative frequency lookup table count[], and the formula for calculating the cumulative frequency is: count[x+1]=count[x]+fx;
[0016] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0017] Parse the encoded number x, use the number x to decode the symbol sequence, and reverse the order of the symbol sequence from the previous step.
[0018] As a further aspect of the present invention, the ANS encoding / decoding method based on finite field multiplication performs encoding / decoding while satisfying the following conditions:
[0019] The symbol sequence is encoded using ANS to generate a number. The decoding end then reverse-engineers the number to obtain the entire sequence.
[0020] During encoding and decoding, the intermediate number x can only correspond to one symbol;
[0021] C(x,s1)≠C(x,s2), which holds true even if the probabilities of s1 and s2 are equal (p1=p2), where C() represents the encoding algorithm;
[0022] C(x1,s)≠C(x2,s), C(x1,s) m )≠C(x2,s n );
[0023] For any x and s, x ≠ C(x,s).
[0024] As a further aspect of the present invention, a data formula for ANS decoding is constructed based on the mathematical principles of ANS, wherein the mathematical principle of ANS is: the number x and the symbol s are combined and encoded into a natural number x′, and the formula for calculating x′ is:
[0025] Based on the calculation formula The data formula for ANS decoding is derived as: x = x′ × p.
[0026] As a further aspect of the present invention, the calculation formula for the encoding algorithm C(x,s) is as follows:
[0027]
[0028] As a further aspect of the present invention, the calculation formula for decoding the decoded symbol sequence is as follows:
[0029] s = Symbol[mod(x,T)]
[0030]
[0031] D(x) = (x, s).
[0032] As a further aspect of the present invention, when the sequence is reversed, the sequence of symbols after decoding is the opposite of the sequence of symbols at the encoding end: the encoding end encodes the first symbol first, and the decoding end decodes the last symbol first.
[0033] As a further aspect of the present invention, the finite field multiplication calculation rules include:
[0034] Based on the probability distribution of the symbol set, calculate and generate a cumulative frequency lookup table;
[0035] Given a period of T, determine a number P that is less than T and coprime to T, and a number Q, where P and Q satisfy: P × Q ≡ 1 (mod T);
[0036] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0037] Based on the encoding and decoding formulas, P is obtained using Euler's theorem. φ(T) ≡1 (mod T), when Q = P φ(T)-1 When P×x×Q≡x(mod T); find the order of Symbol[x] within the same period.
[0038] As a further aspect of the present invention, the sign distribution function is a periodic function: S(x+n×T)=S(x)
[0039] T=∑f s .
[0040] In another aspect, the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, performs any of the above-described ANS encoding / decoding methods based on finite field multiplication according to the present invention.
[0041] In another aspect, the present invention provides a computer-readable storage medium storing computer program instructions that, when executed, implement any of the above-described ANS encoding / decoding methods based on finite field multiplication according to the present invention.
[0042] Compared to traditional implementations, the main advantages of this invention are:
[0043] This invention relates to an ANS encoding / decoding method, device, and medium based on finite field multiplication. It proposes a symbol generation function based on finite field multiplication, generates a symbol allocation list Symbol[] according to the finite field multiplication calculation rules, and proposes an ANS encoding method based on the encoding. Furthermore, it generates a symbol allocation list Symbol[] according to the finite field multiplication calculation rules, and proposes a fast ANS decoding method based on finite field multiplication based on the decoding formula and the constructed symbol distribution function. The decoding end can parse the original symbol sequence, which can improve the data compression effect.
[0044] These or other aspects of this application will become more apparent from the following description of embodiments. It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the application. Attached Figure Description
[0045] 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.
[0046] In the diagram:
[0047] Figure 1 This is a flowchart of the ANS encoding / decoding method based on finite field multiplication in the present invention;
[0048] Figure 2 This is a flowchart of the ANS solution in the ANS encoding / decoding method based on finite field multiplication of the present invention;
[0049] Figure 3 This is a schematic diagram of an embodiment of the computer-readable storage medium implementing the ANS encoding / decoding method based on finite field multiplication of the present invention;
[0050] Figure 4 This is a schematic diagram of the hardware structure of a computer device implementing the ANS encoding / decoding method based on finite field multiplication according to an embodiment of the present invention. Detailed Implementation
[0051] 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.
[0052] 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.
[0053] 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. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the scope of this application.
[0054] Entropy coding (or entropy encoding) is a lossless data compression scheme. The core idea of entropy coding is to achieve compression by using fewer bits to represent frequently occurring symbols and more bits to represent rarely occurring elements. This can be described by the following two formulas:
[0055]
[0056] In the above formula, P(x) refers to the statistical frequency of symbol x, and L(x) is the code length assigned to symbol x by the entropy coding algorithm.
[0057] Huffman coding and arithmetic coding are two of the most common entropy coding methods, which will be briefly described below. Huffman coding is an entropy coding technique developed by David A. Huffman. The algorithm of Huffman coding is simple, based on the probabilistic ordering of the symbol set to allocate the code length. Huffman coding always uses integer bits to represent a symbol, and it encodes each symbol individually. Therefore, Huffman coding cannot guarantee optimal compression. Huffman coding produces the best results when the probabilities of all symbols are negative powers of 2. In Huffman coding, each occurrence of a symbol is always encoded with the same codeword. The advantage of Huffman coding is its fast encoding speed.
[0058] According to information theory, the ideal codeword length of a single symbol is determined solely by the probability of the symbol's occurrence: code-length(x) = -log p(x) If the probability of a symbol occurring is 0.4, then the ideal codeword length is 1.32(-log₂). 0.4 Unfortunately, Huffman coding can only assign codewords of integer length. This is a major drawback of the Huffman coding algorithm.
[0059] Arithmetic coding addresses this limitation of Huffman coding; it's another entropy coding technique. It encodes input data as a range of real numbers between 0 and 1. This range becomes smaller as the number of bits required to encode the input increases. Unlike Huffman coding, arithmetic coding uses near-precise probabilities, thus achieving compression rates close to the theoretical limit. However, the algorithm for arithmetic coding is more complex, and its coding efficiency is very low (roughly 1 / 10th that of Huffman coding), limiting its application in real-time data compression applications.
[0060] Therefore, in recent years, many scholars have been searching for a new algorithm that achieves a compression ratio close to that of arithmetic coding and a coding efficiency close to that of Huffman coding. In 2009, Jarek Duda proposed Asymmetric Numeral Systems (ANS). According to Jarek Duda, Asymmetric Numeral Systems achieve a compression ratio comparable to arithmetic coding while having a processing speed similar to Huffman coding. However, this mathematical relationship cannot be directly applied to ANS coding because it cannot be decoded; the decoding end cannot parse the original symbol sequence.
[0061] The mathematical principle of ANS is as follows:
[0062] Suppose we need to convert a set S of two symbols... i Encoding the symbol sequence ∈A={0,1} into a number num, first considering the standard binary number system, this symbol sequence can be encoded as num=∑S i ·2 i In this case, each symbol ("0" or "1") in the sequence occupies 1 bit. The bit width of the number num is n. Obviously, the binary number system ignores the frequency of occurrence of the two symbols (0,1), that is, the binary number system is applicable to the case that conforms to a uniform distribution of (0,1).
[0063] According to Shannon's information theory, assuming the probability distribution of each symbol in a sequence of symbols is {P1, P2, P3, ..., P...} n}, then the average amount of information per symbol in the symbol set is:
[0064]
[0065] The amount of information contained in symbol S and the probability P of that symbol S Related log(1 / P) s The information content of the two symbols S1 and S2 combined is:
[0066] Assuming natural numbers Therefore, the information content of x combined with S2 is:
[0067]
[0068] Based on the mathematical relationship in the above formula, JarekDuda further hypothesizes that if the number x and the symbol s are combined and encoded into a natural number x′, then the formula for calculating x′ is as follows:
[0069]
[0070] The above is the basic mathematical principle of ANS. ANS encodes a sequence of symbols into natural numbers, which is similar to the principle of the AC (arithmetic coding) algorithm.
[0071] Equations (2) and (3) above describe the mathematical principles of ANS, but these mathematical relationships cannot be directly used for ANS encoding because they cannot be decoded:
[0072] Suppose there are two sequences [x,s1,s2] and [x,s2,s1]. If we use equation (3) for encoding, the resulting numbers are x′1 and x′2, respectively:
[0073]
[0074] Since x′1 = x′2, the encoded numbers of the two sequences are the same, therefore, the decoding end cannot parse out the original symbol sequence.
[0075] Therefore, to facilitate the description of the ANS encoding and decoding process, this invention introduces two expressions as follows:
[0076]
[0077] s is the current symbol, x is the current number, x' is the encoded number, C() represents the encoding algorithm, and D() represents the decoding algorithm. (x,s) is the decoded result.
[0078] A feasible ANS encoding / decoding scheme needs to meet the following conditions:
[0079] 1. A symbol sequence is encoded by ANS to generate a number. The decoding end reverses the process by parsing this number to obtain the entire sequence.
[0080] 2. During the encoding and decoding process, the intermediate number x (state) can only correspond to one symbol.
[0081] 3. C(x,s1)≠C(x,s2), even if the probabilities of s1 and s2 are equal (p1=p2), it still holds true.
[0082] 4. C(x1,s)≠C(x2,s), C(x1,s) m )≠C(x2,s n ).
[0083] 5. For any x and s, x ≠ C(x,s).
[0084] Therefore, in this embodiment of the invention, an ANS encoding / decoding method based on finite field multiplication is provided, including an ANS encoding method and an ANS decoding method, wherein, see... Figure 1 As shown, the ANS encoding method includes the following steps:
[0085] Step S1: Perform probability statistics on the symbols, normalize the probabilities, and obtain the probability distribution {f1, f2, f3, ..., f...} n}, encoding probability distribution;
[0086] Step S2: Construct the cumulative frequency table count[]. The cumulative frequency is calculated as follows: count[s+1] = count[s] + freq[s].
[0087] Step S3: Generate a symbol assignment list Symbol[] according to the rules of finite field multiplication;
[0088] Step S4: Encode the symbol sequence in natural order according to the encoding formula;
[0089] Among them, see Figure 2 As shown, the ANS decoding method includes the following steps:
[0090] Step S10: Decode the probability distribution of each symbol set, {f1, f2, f3, ..., f...} n};
[0091] Step S20: Construct a cumulative frequency lookup table count[]. The formula for calculating the cumulative frequency is: count[x+1] = count[x] + fx;
[0092] Step S30: Generate a symbol assignment list Symbol[] according to the finite field multiplication calculation rules;
[0093] Step S40: Parse the encoded number x, use the number x to decode the symbol sequence, and reverse the order of the symbol sequence from the previous step.
[0094] As a further aspect of the present invention, the ANS encoding / decoding method based on finite field multiplication performs encoding / decoding while satisfying the following conditions:
[0095] The symbol sequence is encoded using ANS to generate a number. The decoding end then reverse-engineers the number to obtain the entire sequence.
[0096] During encoding and decoding, the intermediate number x can only correspond to one symbol;
[0097] C(x,s1)≠C(x,s2), which holds true even if the probabilities of s1 and s2 are equal (p1=p2), where C() represents the encoding algorithm;
[0098] C(x1,s)≠C(x2,s), C(x1,s) m )≠C(x2,s n );
[0099] For any x and s, x ≠ C(x,s).
[0100] In an embodiment of the present invention, a data formula for ANS decoding is constructed based on the mathematical principles of ANS, wherein the mathematical principle of ANS is: a number x and a symbol s are combined and encoded into a natural number x′, and the formula for calculating x′ is:
[0101] Based on the calculation formula The data formula for ANS decoding is derived as: x = x′ × p.
[0102] The formula for calculating the encoding algorithm C(x,s) is as follows:
[0103]
[0104] The formula for calculating the decoding of the decoded symbol sequence is:
[0105] s = Symbol[mod(x,T)]
[0106]
[0107] D(x) = (x, s).
[0108] When the sequence is reversed, the sequence of symbols after decoding is the opposite of the sequence of symbols at the encoding end: the encoding end encodes the first symbol first, and the decoding end decodes the last symbol first.
[0109] In the embodiments of this application, the finite field multiplication calculation rules include:
[0110] Based on the probability distribution of the symbol set, calculate and generate a cumulative frequency lookup table;
[0111] Given a period of T, determine a number P that is less than T and coprime to T, and a number Q, where P and Q satisfy: P × Q ≡ 1 (mod T);
[0112] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0113] Based on the encoding and decoding formulas, P is obtained using Euler's theorem. φ(T) ≡1 (mod T), when Q = P φ(T)-1 When P×x×Q≡x(mod T); find the order of Symbol[x] within the same period.
[0114] In the embodiments of this application, the mathematical principle of ANS is shown in formula (3). The mathematical relationship implied in formula (3) is the theoretical basis for constructing the proposed ANS scheme. From formula (3), the following formula can be easily derived:
[0115] x=x′×p (6)
[0116] Assuming that the probability distribution of the symbol set A={s|0≤s<max} is p={p1,p2,p3…}, and further assuming that there is a list List[] of length x′, each element in the list comes from A (list[i]∈A) and follows the probability distribution of A. Obviously, for a specific symbol s, the occurrence frequency of s in the entire list is approximately:
[0117] f s =x′×p s (7)
[0118] (6) and (7) are completely identical in form, so we can consider that there are x symbols in the interval (0,x′], that is, List[x′] is the x-th occurrence of s in the list List[].
[0119] ANS converts a sequence of symbols into a single number. Obviously, this number will be very large, so it is impossible for us to construct an infinitely long list. The most feasible solution is to construct a fixed-length list in a finite domain, and extend this list to infinity, that is, the symbol distribution function is a periodic function S(x+n×T)=S(x)
[0120] T=∑f s .
[0121] Assuming that the number of occurrences of the symbol s in one period is f s , then obviously the number of periods in which the x-th s will occur is and it is the m-th occurrence in this period, m=mod(x,f s ).
[0122] Assuming that the period length of S(x) is T, for a specific number y, obviously the symbol at position y is consistent with the symbol at position y′=mod(y,T) in the first period, that is, S(y)=S(mod(y,T)). Let S(y′) be the m-th occurrence in this period, and also assume that y is the x-th occurrence
[0123] A symbol distribution function is constructed. In the present invention, a "sequential cycle" symbol allocation scheme is used, and the "sequential cycle" allocation scheme is as follows:
[0124] Assign values to the list in ascending order of symbol values: Symbol[x]=n, Symbol[x+1]=n+1;
[0125] After each assignment, the list index (assignment position) is incremented by one (+1), and the frequency of the symbol is decremented by one (-1);
[0126] When the current symbol is the last one, the next symbol starts from the smallest (0);
[0127] Only assign values to symbols with positive frequencies, i.e., skip symbols with zero frequencies.
[0128] The ANS encoding / decoding method based on finite field multiplication of the present invention can improve the data compression effect.
[0129] The allocation scheme for "finite field multiplication" is as follows:
[0130] Based on the probability distribution of the symbol set, calculate and generate a cumulative frequency lookup table Count[]:
[0131] count[x] = count[x-1] + f x-1 .
[0132] Assuming the period is T, find a number P that is less than T and coprime to T. Ideally, P should be a prime number, and a recommended range for P is [T / 2, 2T / 3]. Then find another number Q, where P and Q have the following relationship:
[0133] P×Q≡1(mod T) (8)
[0134] According to the rules of finite field multiplication, a symbol assignment list Symbol[] is generated, and the symbol assignment formula is as follows:
[0135] Symbol[mod(x×P,T)]=s,if(count[s]≤x <count[s+1])
[0136] or (9)
[0137] Symbol[x]=s,if(count[s]≤mod(x×Q,T) <count[s+1])
[0138] According to Euler's theorem, P φ(T) ≡1 (mod T), obviously when Q = P φ(T)-1 When the time is right, the mathematical relationship shown in equation (8) holds, that is, Q definitely exists. From equation (8), we know that:
[0139] P×x×Q≡x(mod T) (12)
[0140] For the P×x constructor scheme, the order of Symbol[x] within the same period can be quickly found using formula (12).
[0141] It should be understood that although the above description follows a certain order, these steps are not necessarily executed in that order. Unless otherwise expressly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, some steps in this embodiment may include multiple steps or multiple stages, which are not necessarily completed at the same time, but may be executed at different times. The execution order of these steps or stages is not necessarily sequential, but may be performed alternately or in turn with other steps or at least a portion of the steps or stages in other steps.
[0142] It should be noted that the pseudocode for the encoding process is as follows:
[0143]
[0144]
[0145]
[0146] A third aspect of the present invention also provides a computer device 400, including a memory 420 and a processor 410. The memory stores a computer program, which, when executed by the processor, implements the method of any of the above embodiments, including an ANS encoding method and an ANS decoding method, wherein the ANS encoding method includes the following steps:
[0147] The probability statistics of the symbols, probability normalization, yields the probability distribution {f1, f2, f3, ..., f}. n}, encoding probability distribution;
[0148] Construct a cumulative frequency table count[], and calculate the cumulative frequency as follows: count[s+1] = count[s] + freq[s];
[0149] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0150] According to the encoding formula, the symbol sequence is encoded sequentially in natural order;
[0151] The ANS decoding method includes the following steps:
[0152] Decode the probability distribution of each symbol set, {f1, f2, f3, ..., f...} n};
[0153] Construct a cumulative frequency lookup table count[], and the formula for calculating the cumulative frequency is: count[x+1]=count[x]+fx;
[0154] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0155] Parse the encoded number x, use the number x to decode the symbol sequence, and reverse the order of the symbol sequence from the previous step.
[0156] like Figure 4 The diagram shown is a hardware structure schematic of an embodiment of a computer device for executing an ANS encoding / decoding method based on finite field multiplication provided by the present invention. Figure 4 Taking the computer device 400 shown as an example, this computer device includes a processor 410 and a memory 420, and may also include an input device 430 and an output device 440. The processor 410, memory 420, input device 430, and output device 440 can be connected via a bus or other means. Figure 4 Taking a bus connection as an example, input device 430 can receive input digital or character information and generate signal inputs related to ANS encoding and decoding based on finite field multiplication. Output device 440 may include display devices such as a display screen.
[0157] Memory 420, 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 the program instructions / modules corresponding to the ANS encoding / decoding method based on finite field multiplication in the embodiments of this application. Memory 420 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 ANS encoding / decoding method based on finite field multiplication, etc. In addition, memory 420 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 420 may optionally include memory remotely located relative to processor 410, and these remote memories can be connected to the local module via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0158] The processor 410 executes various server functions and data processing by running non-volatile software programs, instructions, and modules stored in the memory 420, thereby implementing the ANS encoding / decoding method based on finite field multiplication in the above method embodiment, including an ANS encoding method and an ANS decoding method, wherein the ANS encoding method includes the following steps:
[0159] The probability statistics of the symbols, probability normalization, yields the probability distribution {f1, f2, f3, ..., f}. n}, encoding probability distribution;
[0160] Construct a cumulative frequency table count[], and calculate the cumulative frequency as follows: count[s+1] = count[s] + freq[s];
[0161] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0162] According to the encoding formula, the symbol sequence is encoded sequentially in natural order;
[0163] The ANS decoding method includes the following steps:
[0164] Decode the probability distribution of each symbol set, {f1, f2, f3, ..., f...} n};
[0165] Construct a cumulative frequency lookup table count[], and the formula for calculating the cumulative frequency is: count[x+1]=count[x]+fx;
[0166] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0167] Parse the encoded number x, use the number x to decode the symbol sequence, and reverse the order of the symbol sequence from the previous step.
[0168] A fourth aspect of the present invention also provides a computer-readable storage medium. Figure 3 This is a schematic diagram of a computer-readable storage medium for an ANS encoding / decoding method based on finite field multiplication provided in an embodiment of the present invention. Figure 3 As shown, the computer-readable storage medium 300 stores computer program instructions 310, which can be executed by a processor. When executed, the computer program instructions 310 implement the method of any of the above embodiments, including an ANS encoding method and an ANS decoding method, wherein the ANS encoding method includes the following steps:
[0169] The probability statistics of the symbols, probability normalization, yields the probability distribution {f1, f2, f3, ..., f}. n}, encoding probability distribution;
[0170] Construct a cumulative frequency table count[], and calculate the cumulative frequency as follows: count[s+1] = count[s] + freq[s];
[0171] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0172] According to the encoding formula, the symbol sequence is encoded sequentially in natural order;
[0173] The ANS decoding method includes the following steps:
[0174] Decode the probability distribution of each symbol set, {f1, f2, f3, ..., f...} n};
[0175] Construct a cumulative frequency lookup table count[], and the formula for calculating the cumulative frequency is: count[x+1]=count[x]+fx;
[0176] According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated;
[0177] Parse the encoded number x, use the number x to decode the symbol sequence, and reverse the order of the symbol sequence from the previous step.
[0178] It should be understood that, where there is no conflict, all the embodiments, features and advantages described above for the finite field multiplication-based ANS encoding and decoding method according to the present invention are equally applicable to the finite field multiplication-based ANS encoding and decoding system and storage medium according to the present invention.
[0179] Finally, it should be noted that the computer-readable storage medium (e.g., memory) described herein can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. By way of example, and not limitation, non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which can act as external cache memory. By way of example, and not limitation, RAM can be obtained in various forms, such as synchronous RAM (DRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The storage devices disclosed herein are intended to include, but are not limited to, these and other suitable types of memory.
[0180] This invention relates to an ANS encoding / decoding method, device, and medium based on finite field multiplication. It proposes a symbol generation function based on finite field multiplication, generates a symbol allocation list Symbol[] according to the finite field multiplication calculation rules, and proposes an ANS encoding method based on the encoding. Furthermore, it generates a symbol allocation list Symbol[] according to the finite field multiplication calculation rules, and proposes a fast ANS decoding method based on finite field multiplication based on the decoding formula and the constructed symbol distribution function. The decoding end can parse the original symbol sequence, which can improve the data compression effect.
[0181] The above are exemplary embodiments disclosed in this invention. However, it should be noted that various changes and modifications can be made without departing from the scope of the embodiments of this invention as defined by the claims. The functions, steps, and / or actions of the methods according to the disclosed embodiments described herein do not need to be performed in any particular order. Furthermore, although the elements disclosed in the embodiments of this invention may be described or claimed individually, they may be understood as multiple unless explicitly limited to a singular number.
[0182] It should be understood that, as used herein, the singular form "a" is intended to include the plural form as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" refers to any and all possible combinations of one or more of the associatedly listed items. The embodiment numbers disclosed above are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0183] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the invention (including the claims) is limited to these examples. Within the framework of the invention, technical features of the above embodiments or different embodiments can be combined, and many other variations of different aspects of the invention exist, which are not provided in the details for the sake of brevity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the protection scope of the invention.
Claims
1. An ANS encoding / decoding method based on finite field multiplication, characterized in that, This includes an ANS encoding method and an ANS decoding method, wherein the ANS encoding method includes the following steps: Probability statistics of symbols, probability normalization, and probability distribution are obtained. Encoding probability distribution; Construct a cumulative frequency table count[], and calculate the cumulative frequency as follows: count[s+1] = count[s] + freq[s]; According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated; According to the encoding formula, the symbol sequence is encoded sequentially in natural order; The ANS decoding method includes the following steps: Decode the probability distribution of each symbol set. ; Construct a cumulative frequency lookup table count[], and the formula for calculating the cumulative frequency is: count[x+1] = count[x] + fx; According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated; Parse the encoded number x, use the number x to decode the symbol sequence, and reverse the order of the symbol sequence from the previous step; In this process, a symbol allocation list Symbol[] is generated according to the rules of finite field multiplication, including generating the symbol allocation list Symbol[] according to the following allocation formula: ; Where x is the current number, s is the current symbol, T is the period of the allocation list, P is a number coprime to period T, with a range of [T / 2, 2T / 3], and Q is another number coprime to period T, and P and Q satisfy... ; The encoding formula includes: ; The decoding formula includes: ; Among them, f s Assign the frequency of occurrence of symbol s in the list. Let be the cumulative frequency of symbol s, and D(x) be the decoding algorithm for digit x.
2. The ANS encoding / decoding method based on finite field multiplication according to claim 1, characterized in that, ANS is used to convert a sequence of symbols into a single number, constructing a fixed-length list in a finite field, and extending this list to infinity, i.e., the symbol distribution function is a periodic function: If the number of times symbol s appears in one period is fs, then it is clear that the number of periods in which the x-th s will appear is... And it appears for the mth time in this period, m=mod(x,fs), where n is the index of the allocation list.
3. The ANS encoding / decoding method based on finite field multiplication according to claim 2, characterized in that, If the period length of S(x) is T, for a number y, the sign at position y is different from the sign in the first period. The signs in the positions are consistent, that is ,set up It is assumed that y is the mth occurrence within this period, and that y is the xth occurrence. .
4. The ANS encoding / decoding method based on finite field multiplication according to claim 1, characterized in that, When the sequence is reversed, the sequence of symbols after decoding is the opposite of the sequence of symbols at the encoding end: the encoding end encodes the first symbol first, and the decoding end decodes the last symbol first.
5. The ANS encoding / decoding method based on finite field multiplication according to claim 1, characterized in that, The rules for multiplication in finite fields include: Based on the probability distribution of the symbol set, calculate and generate a cumulative frequency lookup table; Given a period of T, determine a number P that is less than T and coprime to T, and a number Q, where P and Q satisfy: ; According to the rules of finite field multiplication, a symbol allocation list Symbol[] is generated; Based on the encoding and decoding formulas, Euler's theorem is obtained. ,when hour, ; Find and retrieve the order of Symbol[x] within the same period.
6. The ANS encoding / decoding method based on finite field multiplication according to claim 5, characterized in that, The sign distribution function is a periodic function: 。 7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the computer program is executed by the processor, it performs the ANS encoding / decoding method based on finite field multiplication as described in any one of claims 1-6.
8. A computer-readable storage medium storing computer program instructions, characterized in that, When the computer program instructions are executed, they implement the ANS encoding / decoding method based on finite field multiplication as described in any one of claims 1-6.
Citation Information
Patent Citations
Coding method and device
CN107332567A
State selection method and system for finite state entropy coding, storage medium and equipment
CN114513210A
