An ANS packet coding and decoding method, a computer device and a storage medium

CN115801021BActive Publication Date: 2026-09-22SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211180870.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-27
Publication Date
2026-09-22
Estimated Expiration
2042-09-27

AI Technical Summary

Technical Problem

但是,受制于计算机数据处理的位宽,软硬件难以处理如此大的数字,限制了ANS的应用场景

Benefits of technology

[0035]相比于传统的实现方式,本发明的主要优势有:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115801021B_ABST
    Figure CN115801021B_ABST
Patent Text Reader

Abstract

The application provides an ANS packet coding and decoding method, a computer device and a storage medium, the method comprises an ANS encoding method and an ANS decoding method; when encoding, an encoding bit width n is set, the bit width of each encoded number is equal, and a threshold Thresh is set; each symbol is extracted in a natural order, and is encoded according to an encoding formula; according to a grouping rule and the encoded symbol sequence, a plurality of numbers with the bit width n are obtained after encoding is completed; when decoding, each number is extracted in turn, each symbol is analyzed in turn according to a decoding formula; all sub-sequences are spliced in a natural order to obtain a whole symbol sequence; the sub-sequences can be encoded by small natural numbers, the numbers obtained by encoding the sub-sequences have consistent bit widths, and computer processing is facilitated. In addition, since each sub-sequence is independently encoded, there is no dependency relationship, and parallel decoding can be performed when decoding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, specifically to an ANS packet encoding / decoding method, computer equipment, and storage medium. Background Technology

[0002] Entropy coding is a lossless data compression scheme. The core idea of ​​entropy coding is to use 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, due to the limitations of computer data processing bit width, both hardware and software struggle to handle such large numbers, limiting the application scenarios of ANS. Summary of the Invention

[0007] In view of this, the purpose of this invention is to propose an ANS block encoding and decoding method, computer equipment and storage medium, which solves the technical problems in the background art by changing the implementation form of ANS encoding, splitting the entire symbol sequence into several subsequences according to certain rules, and generating several numbers after encoding the subsequences by the ANS algorithm.

[0008] To achieve the above objectives, in one respect, the present invention provides an ANS block encoding and decoding method, including an ANS encoding method and an ANS decoding method, wherein the ANS encoding method includes the following steps:

[0009] Define a bit width n, where each encoded digit has the same bit width. Define a threshold Thresh, and the relationship between Thresh and the bit width n is: Thresh = 2. n ;

[0010] Extract each symbol in natural order and encode it according to the encoding formula;

[0011] Based on the grouping rules and the sequence of encoded symbols, several numbers with a bit width of n are obtained after encoding.

[0012] The ANS decoding method includes the following steps:

[0013] Extract each number in turn, and then analyze each symbol in turn according to the decoding formula;

[0014] By concatenating all subsequences in natural order, the entire symbol sequence is obtained.

[0015] As a further aspect of the present invention, in each group of codes, the initial value of the current number x is a fixed value.

[0016] As a further aspect of the present invention, when extracting each symbol in natural order and encoding it according to the encoding formula, the method further includes:

[0017] Set the current symbol to s, and x′=C(x,s);

[0018] If x′ < thresh, update the value of x, x = x′;

[0019] If x′>=thresh, the current x is encoded and output with a bit width of x, resulting in a set of ANS compressed data;

[0020] Update the value of x to x = C(0, s); start encoding the next subsequence.

[0021] As a further aspect of the present invention, each symbol (x,s) = D(x`) is parsed sequentially according to the decoding formula, where s is the decoded character and x is the updated value;

[0022] If x > 0, the symbol is ready to be resolved and the value of x is updated;

[0023] If x = 0, stop parsing, obtain a subsequence, and then reverse the order of the subsequence.

[0024] As a further embodiment of the present invention, the ANS block encoding and decoding method is also used to split the entire symbol sequence into several sub-sequences according to rules, and to generate several numbers after encoding the sub-sequences by the ANS algorithm, wherein the bit width of the numbers is set to a fixed value.

[0025] As a further aspect of the present invention, the ANS block encoding / decoding method performs encoding / decoding under the following conditions:

[0026] The symbol sequence is encoded using ANS to generate a number. The decoding end then reverse-engineers the number to obtain the entire sequence.

[0027] During encoding and decoding, the intermediate number x can only correspond to one symbol;

[0028] 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;

[0029] C(x1,s)≠C(x2,s), C(x1,s) m )≠C(x2,s n );

[0030] For any x and s, x ≠ C(x,s).

[0031] 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:

[0032] Based on the calculation formula The data formula for ANS decoding is derived as: x = x′ × p.

[0033] In another aspect, the present invention provides a computer device including a memory and a processor, the memory storing a computer program which, when executed by the processor, performs any of the ANS packet encoding / decoding methods according to the present invention.

[0034] 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 block encoding / decoding methods according to the present invention.

[0035] Compared to traditional implementations, the main advantages of this invention are:

[0036] The ANS block encoding / decoding method, computer device, and storage medium of the present invention split the entire symbol sequence into several subsequences according to rules, and encode the subsequences using the ANS algorithm to generate several numbers, wherein the bit width of the numbers is set to a fixed value. After splitting the entire symbol sequence into several subsequences, the subsequences can be encoded using small natural numbers. Since the encoded numbers obtained from the subsequences have a consistent bit width, it is convenient for computer processing. In addition, since each subsequence is encoded independently and there is no dependency, decoding can be performed in parallel.

[0037] 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

[0038] 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.

[0039] In the diagram:

[0040] Figure 1 This is a flowchart of the ANS encoding and decoding process in the ANS block encoding and decoding method of the present invention;

[0041] Figure 2 This is a flowchart of the ANS encoding / decoding operation in the ANS block encoding / decoding method of the present invention;

[0042] Figure 3 This is a flowchart of the ANS decomposition process in the ANS block encoding / decoding method of the present invention;

[0043] Figure 4 This is a schematic diagram of an embodiment of a computer-readable storage medium for implementing the ANS block encoding / decoding method of the present invention;

[0044] Figure 5 This is a schematic diagram of the hardware structure of a computer device for implementing the ANS packet encoding / decoding method of the present invention. Detailed Implementation

[0045] 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.

[0046] 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.

[0047] 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.

[0048] 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:

[0049]

[0050] 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.

[0051] 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.

[0052] 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.

[0053] 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.

[0054] 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, due to the limitations of computer data processing bit width, both hardware and software struggle to handle such large numbers.

[0055] The mathematical principle of ANS is as follows:

[0056] 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 = ∑Si ·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).

[0057] 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:

[0058]

[0059] 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:

[0060] Assuming natural numbers Therefore, the information content of x combined with S2 is:

[0061]

[0062] 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:

[0063]

[0064] 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.

[0065] In fact, the calculation formula shown in (3) cannot be directly used for ANS encoding. In order to facilitate the description of the ANS encoding and decoding process, this invention introduces two expressions as follows:

[0066]

[0067] 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.

[0068] Formula (3) describes the encoding principle of natural numbers and (probability) symbols, which belongs to the local level. The encoding principle of natural numbers and symbol sequences is as follows: Suppose that the natural number x is encoded with the symbol sequence [S1, S2, S3, ... S...n The symbols are synthesized and encoded, with the probabilities of each symbol being [P1, P2, P3, ..., Pn].

[0069] x and S1 are combined to generate the natural number x1.

[0070] x2 and S2 are combined to generate the natural number x2.

[0071] x2 and S3 are combined to generate the natural number x3.

[0072] ...

[0073] X n-1 With S N Synthetic encoding generates the natural number x3.

[0074] From a macroscopic perspective, the symbol sequence, after being encoded using the ANS algorithm, ultimately generates the number y:

[0075]

[0076] Clearly, the natural number calculated by equation (5) is an extremely large number. Due to the limitations of computer data processing bit width, both hardware and software struggle to handle such a large number. It can be said that it is almost impossible to achieve such a "whole package" ANS encoding and decoding.

[0077] Symbol sequences encoded using ANS (Answer Sequence of Symbols) result in extremely large natural numbers, which current mainstream computers cannot process, thus limiting the application scenarios of ANS. To solve this problem...

[0078] Therefore, this invention provides an ANS packet encoding / decoding method, a computer device, and a storage medium. To facilitate the description of the ANS encoding / decoding process, two expressions are introduced as follows:

[0079]

[0080] 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.

[0081] The entire symbol sequence is divided into several subsequences according to certain rules. These subsequences are encoded by the ANS algorithm to generate several numbers. In order to ensure the consistency of the encoding, the bit width of these numbers will be set to a fixed value (that is, the value of the encoded number has a fixed value).

[0082] A feasible ANS encoding / decoding scheme needs to meet the following conditions:

[0083] 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.

[0084] 2. During the encoding and decoding process, the intermediate number x (state) can only correspond to one symbol.

[0085] 3. C(x,s1)≠C(x,s2), even if the probabilities of s1 and s2 are equal (p1=p2), it still holds true.

[0086] 4. C(x1,s)≠C(x2,s), C(x1,s) m )≠C(x2,s n ).

[0087] 5. For any x and s, x ≠ C(x,s).

[0088] Therefore, in this embodiment of the invention, an ANS block encoding / decoding method is provided, including an ANS encoding method and an ANS decoding method, wherein, see... Figure 1 and Figure 2 As shown, the ANS encoding method includes the following steps:

[0089] Step S1: Set an encoding bit width n, where the bit width of each encoded number is equal, and set a threshold Thresh;

[0090] Step S2: Extract each symbol in natural order and encode it according to the encoding formula;

[0091] Step S3: Based on the grouping rules and the sequence of encoded symbols, several numbers with a bit width of n are obtained after encoding.

[0092] Among them, see Figure 3 As shown, the ANS decoding method includes the following steps:

[0093] Step S10: Extract each number in turn, and parse each symbol in turn according to the decoding formula;

[0094] Step S20: Concatenate all subsequences in natural order to obtain the entire symbol sequence.

[0095] In an embodiment of the present invention, the relationship between the threshold Thresh and the encoding bit width n is: thresh = 2 n .

[0096] In each group of codes, the initial value of the current number x is a fixed value. The fixed value is preferably 1.

[0097] In embodiments of the present invention, when extracting each symbol in natural order and encoding it according to the encoding formula, the method further includes:

[0098] Set the current symbol to s, and x′=C(x,s);

[0099] If x′ < thresh, update the value of x, x = x′;

[0100] If x′>=thresh, the current x is encoded and output with a bit width of x, resulting in a set of ANS compressed data;

[0101] Update the value of x to x = C(0, s); start the next subsequence encoding.

[0102] In an embodiment of the present invention, each symbol (x,s) = D(x`) is parsed sequentially according to the decoding formula, where s is the decoded character and x is the updated value;

[0103] If x > 0, the symbol is ready to be resolved and the value of x is updated;

[0104] If x = 0, stop parsing, obtain a subsequence, and then reverse the order of the subsequence.

[0105] In an embodiment of the present invention, the ANS block encoding and decoding method is further used to split the entire symbol sequence into several sub-sequences according to rules, and to generate several numbers after encoding the sub-sequences by the ANS algorithm, wherein the bit width of the numbers is set to a fixed value.

[0106] The ANS block encoding / decoding method performs encoding / decoding under the following conditions:

[0107] The symbol sequence is encoded using ANS to generate a number. The decoding end then reverse-engineers the number to obtain the entire sequence.

[0108] During encoding and decoding, the intermediate number x can only correspond to one symbol;

[0109] 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;

[0110] C(x1,s)≠C(x2,s), C(x1,s) m )≠C(x2,s n );

[0111] For any x and s, x ≠ C(x,s).

[0112] In this embodiment, the data formula for ANS decoding is constructed based on the mathematical principles of ANS. The mathematical principle of ANS is: combining the digit x and the symbol s together to encode a natural number x′, and the formula for calculating x′ is...

[0113] The ANS block encoding and decoding method of the present invention can improve the data compression effect.

[0114] It should be noted that this patent only changes the application mode of ANS. This grouping mode is not related to the form of ANS algorithm represented by formula (4) and is applicable to any ANS encoding algorithm.

[0115] In ANS block coding, the initial value of x in each block is a fixed value; in this case, the initial value of x is 1.

[0116] Set an encoding bit width n (16, 32, 64, 128), where the bit width of each encoded number is equal;

[0117] Let's set a threshold, Thresh. This threshold is the upper limit of the encoded number. Obviously, this upper limit has the following relationship with the encoding bit width n: thresh = 2 n ;

[0118] Extract each symbol in natural order and encode it according to the encoding formula in formula (4): Assume the current symbol is s, x′=C(x,s);

[0119] If x′ < thresh, update the value of x, x = x′;

[0120] If x′>=thresh, the current x needs to be encoded and output with a bit width of x, resulting in a set of ANS compressed data;

[0121] At the same time, update the value of x to x = C(0,s); start the next subsequence encoding.

[0122] Grouping and encoding symbol sequences according to the above rules. After encoding, several numbers with a bit width of n will be obtained, assuming these numbers are {X1, X2, ..., X...}. n}

[0123] During decoding, each number is extracted sequentially, and each symbol (x,s) = D(x`) is parsed sequentially according to the decoding formula, where s is the decoded character and x is the updated value.

[0124] If x > 0, the symbol is ready to be resolved and the value of x is updated;

[0125] If x = 0, stop parsing. At this point, a subsequence is obtained, and the subsequence is sorted in reverse order.

[0126] By concatenating all subsequences in natural order, the entire symbol sequence is obtained.

[0127] 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.

[0128] It should be noted that the pseudocode for the encoding process is as follows:

[0129]

[0130]

[0131] It should be noted that the pseudocode for ANS decoding is as follows:

[0132]

[0133]

[0134] 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:

[0135] Set an encoding bit width n, where the bit width of each encoded number is equal, and set a threshold Thresh;

[0136] Extract each symbol in natural order and encode it according to the encoding formula;

[0137] Based on the grouping rules and the sequence of encoded symbols, several numbers with a bit width of n are obtained after encoding.

[0138] The ANS decoding method includes the following steps:

[0139] Extract each number in turn, and then analyze each symbol in turn according to the decoding formula;

[0140] By concatenating all subsequences in natural order, the entire symbol sequence is obtained.

[0141] like Figure 5The diagram shown is a hardware structure schematic of an embodiment of a computer device for executing the ANS packet encoding / decoding method provided by the present invention. Figure 5 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 5 Taking a bus connection as an example, input device 430 can receive input digital or character information and generate signal inputs related to ANS packet encoding and decoding. Output device 440 may include display devices such as a display screen.

[0142] 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 program instructions / modules corresponding to the ANS packet encoding / decoding method 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 the use of the ANS packet encoding / decoding method, 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 such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0143] 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 block encoding / decoding method of the above method embodiment, including an ANS encoding method and an ANS decoding method, wherein the ANS encoding method includes the following steps:

[0144] Set an encoding bit width n, where the bit width of each encoded number is equal, and set a threshold Thresh;

[0145] Extract each symbol in natural order and encode it according to the encoding formula;

[0146] Based on the grouping rules and the sequence of encoded symbols, several numbers with a bit width of n are obtained after encoding.

[0147] The ANS decoding method includes the following steps:

[0148] Extract each number in turn, and then analyze each symbol in turn according to the decoding formula;

[0149] By concatenating all subsequences in natural order, the entire symbol sequence is obtained.

[0150] A fourth aspect of the present invention also provides a computer-readable storage medium. Figure 4 This is a schematic diagram of a computer-readable storage medium for the ANS packet encoding / decoding method provided in an embodiment of the present invention. Figure 4 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:

[0151] Set an encoding bit width n, where the bit width of each encoded number is equal, and set a threshold Thresh;

[0152] Extract each symbol in natural order and encode it according to the encoding formula;

[0153] Based on the grouping rules and the sequence of encoded symbols, several numbers with a bit width of n are obtained after encoding.

[0154] The ANS decoding method includes the following steps:

[0155] Extract each number in turn, and then analyze each symbol in turn according to the decoding formula;

[0156] By concatenating all subsequences in natural order, the entire symbol sequence is obtained.

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

[0158] 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.

[0159] The ANS block encoding / decoding method, computer device, and storage medium of the present invention split the entire symbol sequence into several subsequences according to rules, and encode the subsequences using the ANS algorithm to generate several numbers, wherein the bit width of the numbers is set to a fixed value. After splitting the entire symbol sequence into several subsequences, the subsequences can be encoded using small natural numbers. Since the encoded numbers obtained from the subsequences have a consistent bit width, it is convenient for computer processing. In addition, since each subsequence is encoded independently and there is no dependency, decoding can be performed in parallel.

[0160] 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.

[0161] 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.

[0162] 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 block encoding / decoding method, characterized in that, This includes an ANS encoding method and an ANS decoding method, wherein the ANS encoding method includes the following steps: Define an encoding bit width n, where each encoded digit has the same bit width, and set a threshold. ; Extract each symbol in natural order and encode it according to the encoding formula; Based on the grouping rules and the sequence of encoded symbols, several numbers with a bit width of n are obtained after encoding. This process, which involves extracting each symbol in natural order and encoding it according to the encoding formula, also includes: Set the current symbol to Using encoding algorithms For symbols and the current state value Encode to obtain new state values : ; like Then the new state value As the current state value : Continue encoding the next symbol; like Set the current state value As a digital X with an encoding bit width of n, a set of ANS compressed data is obtained; Will The value is updated to the initial value, and the next subsequence encoding begins; The ANS decoding method includes the following steps: Extract each number X in sequence and use number X as the current state value. Input into decoding formula D ( ), and then analyze each symbol in turn, where the decoding formula D ( Output ( ,s), The symbols obtained from decoding, The new state value obtained from decoding; like If the value is greater than 0, then the new state value will be... As the current state value : Continue decoding the next symbol; like =0, stop decoding, obtain a subsequence, and sort the subsequence in reverse order; By concatenating all subsequences in natural order, the entire symbol sequence is obtained.

2. The ANS block encoding / decoding method according to claim 1, characterized in that, threshold The relationship with the encoding bit width n is as follows: .

3. The ANS block encoding / decoding method according to claim 2, characterized in that, In each group of codes, The initial value is a fixed value.

4. The ANS block encoding / decoding method according to claim 1, characterized in that, The ANS block encoding / decoding method is also used to split the entire symbol sequence into several sub-sequences according to rules, and to generate several numbers after encoding the sub-sequences by the ANS algorithm, wherein the bit width of the numbers is set to a fixed value.

5. 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 a processor, it performs the ANS block encoding / decoding method according to any one of claims 1-4.

6. A computer-readable storage medium storing computer program instructions, characterized in that, When the computer program instructions are executed, they implement the ANS block encoding / decoding method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Self-adaptive finite state entropy coding method

    CN110602498A

  • Method, system and equipment for calculating digital effective bit width and storage medium

    CN114268322A

  • FSE coding method and device, equipment and storage medium

    CN114301468A