A character compression method, device, equipment and storage medium based on data stream

By using the data stream-based character compression method in the FPGA environment, the characters in the target data stream are parsed and judged, and the same characters are compressed as 0, and different characters are combined with 1, which solves the problem of low efficiency of traditional methods in FPGA bit stream data compression. , achieving higher storage, transmission and decompression efficiency.

CN117856798BActive Publication Date: 2024-10-11SUZHOU YIGE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311866720.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2024-10-11
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

Traditional compression methods such as RLE, Huffman compression method and PBA method have low compression efficiency, high time and space complexity, and difficulty in decompression in the bit stream binary data of FPGA, especially when processing a large number of consecutive identical characters.

Method used

Using a data stream-based character compression method, by parsing the target data stream, it determines whether each character is the same as the preset value. If it is the same, it will be compressed into a binary number 0; if it is different, it will be combined with a binary number 1 to generate a new data stream and improve storage. and transmission efficiency, and remove the first binary number during the decompression process to avoid repeated decompression.

Benefits of technology

Significantly improves data volume reduction and transmission efficiency, reduces time complexity and memory space occupation, and provides better performance, especially when processing a large amount of the same data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117856798B_ABST
    Figure CN117856798B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data transmission, and discloses a character compression method, device, equipment and storage medium based on data stream, the method comprising: obtaining a target data stream based on the data stream; parsing the target data stream to obtain at least one character and a preset bit width N of the character, the character consisting of N binary numbers, N>0; judging whether each of the characters in the target data stream is the same as a first preset value, the first preset value being a target character consisting of N binary numbers; if so, compressing each of the target characters into a binary number 0 to obtain a first target character containing the binary number 0, and outputting a first data stream corresponding to the target data stream, thereby realizing compression of the data stream, saving algorithm time compared to traditional compression methods, and occupying less space resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data transmission, and in particular to a character compression method, device, equipment and storage medium based on data stream. Background Art

[0002] FPGA (Field Programmable Gate Array) is a programmable logic device that can be programmed to implement specific logic functions. The use of FPGA chips is inseparable from the support of EDA (Electronic design automation) tools. The core functions of EDA tools can be divided into two parts: the front-end and the back-end. The front-end mainly includes the analysis, optimization, logic synthesis, and logic mapping of the user design, and the back-end mainly includes layout and routing, and bitstream generation.

[0003] Generally, the bit stream binary data of FPGA contains a large amount of binary data 0. In this case, traditional compression methods such as RLE (Run Length Encoding) method have low compression efficiency for FPGA. For example, the algorithms of Huffman compression method and PBA (Present Bits Algorithm) method are too complex, resulting in high time and space complexity and difficulty in decompression. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a data stream-based character compression method to solve the problem that the bit stream binary data of the FPGA contains a large amount of 0 data, the traditional compression methods such as the RLE method have low compression efficiency for the FPGA, and the algorithms such as the Huffman compression method and the PBA method are too complex, resulting in high time and space complexity and difficulty in decompression.

[0005] In the first aspect, an embodiment of the present invention provides a character compression method based on a data stream, which obtains a target data stream based on the data stream; parses the target data stream to obtain at least one character and a preset bit width N of the character, wherein the character consists of N binary numbers, and N>0; determines whether each of the characters in the target data stream is the same as a first preset value, wherein the first preset value is a target character consisting of N binary numbers; if so, compresses each of the target characters into a binary number 0 to obtain a first target character containing the binary number 0, and outputs a first data stream corresponding to the target data stream.

[0006] This embodiment provides a character compression method based on data stream, which is mainly used in FPGA environment. First, the target data stream is obtained from the FPGA, and the preset bit width of the character is parsed, and the bit width of the character is unified and preset. Then, it is determined whether each character is equal to the first preset value. If so, the character is compressed into a binary number 0. Finally, the first data stream corresponding to the original data stream is output. This compression method can significantly reduce the amount of data when processing a large number of consecutive identical characters, and improve storage and transmission efficiency. Compared with the traditional Huffman algorithm, this embodiment has smaller time complexity and occupies less memory space in the case of FPGA data stream, and has better performance.

[0007] In combination with the first aspect, in one embodiment, the method also includes: if the target character is different from the first preset value, the target character and the binary number 1 are combined to form a second target character, the second target character is a combination of 1 and the target character, and 1 is before the target character; based on the first target character and the second target character, a second data stream corresponding to the target data stream is generated.

[0008] This embodiment is a further optimization of the character compression method based on data stream, by adding a step of judging whether the target character is not entirely the first preset value, and adopting different compression methods according to the judgment result. If the target character is not equal to the first preset value, the target character is combined with the binary number 1 to generate a second target character, and a second data stream corresponding to the original data stream is generated. This embodiment can effectively help distinguish characters equal to the first preset value from characters equal to the first preset value during decompression when processing characters that are not equal to the first preset value, thereby improving storage and transmission efficiency.

[0009] In combination with the first aspect or its corresponding embodiment, in another embodiment, the method also includes: acquiring the first data stream and the second data stream; parsing the first data stream and the second data stream to obtain the first target character and the second target character; determining whether the first binary number in the first target character or the second target character is 0; if so, decompressing the first binary number 0 in the first data stream and the second data stream to generate a third target character, the bit width of the third target character is the preset bit width N, and the third target character is composed of the first preset value; according to the third target character, outputting the target data stream corresponding to the first data stream and the second data stream.

[0010] This embodiment is a decompression method corresponding to the character compression method based on data stream, which includes obtaining data stream, parsing data stream, judging whether the first binary number is 0, generating a third target character, and outputting a target data stream corresponding to the first data stream and the second data stream according to the third target character. Through this process, the compressed character data can be decompressed to improve the decompression and transmission efficiency, especially for a data stream containing a large number of data streams that are the same as the first preset value.

[0011] In combination with the first aspect or its corresponding embodiment, in another embodiment, the method also includes: if no, then according to the preset bit width N of the character, truncating the N binary numbers after the first binary number; according to the N binary numbers after the first binary number, generating a fourth target character, the bit width of the fourth target character is the preset bit width N; according to the fourth target character, outputting the target data stream corresponding to the first data stream and the second data stream.

[0012] This embodiment is a further optimization of the character decompression method based on data stream. First, it determines whether the first binary number is 0. If it is not 0, the first character is 1. According to the preset bit width N of the character, the N binary numbers after 1 are intercepted to generate the fourth target character, and according to the fourth target character, the target data stream corresponding to the first data stream and the second data stream is output. Through this process, the characters that are not equal to the first preset value can be correctly processed and decompressed, ensuring the integrity and accuracy of the data and improving the efficiency of data compression.

[0013] In combination with the first aspect or its corresponding embodiment, in another embodiment, after generating the third target character or generating the fourth target character, it also includes: acquiring the first data stream and the second data stream; removing the first binary number of the first data stream and the second data stream, and updating the first binary number of the first data stream and the second data stream.

[0014] In combination with the first aspect or its corresponding embodiment, in another embodiment, after generating the fourth target character, it also includes: acquiring the first data stream and the second data stream; removing the first binary number of the first data stream and the second data stream; then removing the first N binary numbers of the first data stream and the second data stream, and updating the first binary number of the first data stream and the second data stream.

[0015] In this embodiment, the compressed data stream is updated by removing the first binary number of the first data stream and the second data stream, and then the first N compressed data are removed and the data stream is output to form a new compressed output. The first letters of the first data stream and the second data stream are continuously updated to avoid repeated decompression of the decompressed data stream.

[0016] In a second aspect, an embodiment of the present invention provides a character compression device based on a data stream, the device comprising:

[0017] The acquisition module is used to acquire the target data stream based on the data stream.

[0018] The parsing module is used to parse the target data stream to obtain at least one character and a preset bit width N of the character, wherein the character is composed of N binary numbers, and N>0.

[0019] The judging module is used to judge whether each of the characters in the target data stream is the same as a first preset value, where the first preset value is a target character composed of N binary numbers.

[0020] The first generating module is used for compressing each of the target characters into a binary number 0 if yes, obtaining a first target character including the binary number 0, and outputting a first data stream corresponding to the target data stream.

[0021] a combining module, configured to combine the target character and a binary number 1 to form a second target character if the target character is different from a first preset value, wherein the second target character is a combination of 1 and the target character, and 1 is before the target character;

[0022] The second generating module is used to generate a second data stream corresponding to the target data stream according to the first target character and the second target character.

[0023] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to thereby execute a data stream-based character compression method of the above-mentioned first aspect or any corresponding embodiment thereof.

[0024] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute a data stream-based character compression method according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0026] Figure 1is a flow chart of a character compression method based on data stream according to some embodiments of the present invention;

[0027] FIG. 2( a ) is a schematic diagram of a character compression method based on data stream according to some embodiments of the present invention;

[0028] FIG2( b) is a schematic diagram of another character compression method based on data stream according to some embodiments of the present invention;

[0029] Figure 3 is a flow chart of another character compression method based on data stream according to some embodiments of the present invention;

[0030] FIG4( a) is a flow chart of another data stream-based character compression method according to some embodiments of the present invention;

[0031] FIG4( b) is a schematic diagram of another character compression method based on data stream according to some embodiments of the present invention;

[0032] Figure 5 is a structural block diagram of a character compression device based on data stream according to an embodiment of the present invention;

[0033] Figure 6 It is a schematic diagram of the hardware structure of the electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0035] According to an embodiment of the present invention, a data stream-based character compression method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0036] In this embodiment, a character compression method based on data stream is provided, which can be executed by a server, a terminal or other device. Figure 1 is a flow chart of a character compression method based on data stream according to an embodiment of the present invention, such as Figure 1 As shown, the process includes the following steps:

[0037] Step 101, obtaining a target data stream based on a data stream.

[0038] FPGA is short for Field Programmable Gate Array, which is a highly flexible integrated circuit. FPGA can be configured to perform a variety of digital logic functions, so it is often used to implement customized hardware accelerators or processors. This flexibility makes FPGA an ideal choice for applications that require rapid prototyping and hardware acceleration, such as in high-performance computing, communications, image processing, audio processing, and other fields.

[0039] Specifically, the software obtains a target data stream based on the data stream, where the target data stream is binary data consisting of 0s and 1s, such as 0010 0010 0000.

[0040] Step 102, parse the target data stream to obtain at least one character and a preset bit width N of the character, wherein the character is composed of N binary numbers, N>0.

[0041] The character represents a character composed of binary numbers, and each character in the data stream has a fixed bit width, which is the number of bits of the character. Commonly used characters include ASCII (American Standard Code for Information Interchange) code, which is 8 bits, such as 00101100, and its bit width is 8. Unicode is 16 bits, and the bit width is 16. It can also be shorter, such as 0010, which has 4 bits and a bit width of 4.

[0042] The ASCII code is a character encoding standard that uses 7-bit or 8-bit binary numbers to represent different characters. The ASCII code is one of the most commonly used character encoding methods in computers. It can represent 128 different characters, including English letters, numbers, punctuation marks, etc. In the ASCII code, each character corresponds to a unique code value. The code value ranges from 0 to 127, where code values ​​from 32 to 126 correspond to printable characters, and code values ​​from 0 to 31 correspond to control characters, such as line feeds, carriage returns, etc.

[0043] In addition, Unicode is a character encoding standard that sets a unified and unique binary encoding for each character in each language to meet the requirements of text conversion and processing across languages ​​and platforms. The goal of Unicode is to cover the text of all writing systems in the world and to encode them uniformly as much as possible, so it includes characters from multiple languages, such as Latin letters, Greek letters, Arabic letters, Cyrillic letters, Chinese characters, Japanese symbols, etc. Unicode uses a 16-bit or 32-bit encoding scheme called UCS-2 or UCS-4, in which each character is represented by a unique code point. The code points range from 0 to 65535 or from 0 to 4294967295, which correspond to 16-bit or 32-bit binary numbers. Compared with ASCII code, Unicode can represent more characters and symbols, including non-English characters and emoticons. This makes Unicode a universal character encoding standard for text processing and data exchange in any language and writing system.

[0044] Specifically, the target data stream is parsed to obtain at least one character and a preset bit width N of the character, wherein the preset bit width is set by default when data is input, and the bit widths of all characters in a target data stream are equal. For example, if the target data stream is 16-bit data of 0100 0010 0000 0000, and the bit width is 4, there are 4 4-bit characters such as 0100, 0010, 0000 and 0000 in the data stream, and the bit widths of the characters are all 4. If the preset bit width is 8, there are 2 8-bit characters such as 0100 0010 and 0000 0000 in the data stream, and the preset bit width of the characters is 8. If the preset bit width is 16, there is 1 16-bit character such as 0100 0010 0000 0000 in the data stream.

[0045] Step 103: determine whether each of the characters in the target data stream is the same as a first preset value.

[0046] The first preset value is a target character composed of N binary numbers.

[0047] Specifically, as shown in FIG2(a), the system needs to determine whether each character in the target data is composed of N preset binary numbers, where N is the preset bit width of the character. For example, the target data stream is 16-bit data of 0100 0010 0000 0000, the preset bit width of the character is 4, that is, N is 4, and there are 4 4-bit characters such as 0100, 0010, 0000 and 0000 in the target data stream. Among them, the frequency of occurrence of the character 0000 is the highest, so the character 0000 is the first preset value of the target data stream, and the system needs to determine whether 0100 or 0010 or 0000 or 0000 is composed of the first preset value, that is, 4 zeros.

[0048] Step 104: if yes, compress each of the target characters into a binary number 0, obtain a first target character including the binary number 0, and output a first data stream corresponding to the target data stream.

[0049] Specifically, as shown in FIG2(a), if the character is composed of N zeros, for example, the target data stream is 16-bit data of 01000010 0000 0000, the first preset value is 0000, the preset bit width of the character is 4, that is, N is equal to 4, and there are 4 4-bit characters such as 0100, 0010, 0000 and 0000 in the target data stream. Among them, the third 0000 character and the fourth 0000 satisfy the requirement of being composed of 4 zeros, that is, being composed of N zeros. Then the system will output the 0000 character as a 0 character, that is, the system compresses the 4-bit character of 0000 into 0, a one-bit character. The first target character is 0 0, and the target data stream becomes a first data stream such as 0100 0010 0 0, and the first data stream is a compressed data stream.

[0050] The data compression method provided in this embodiment obtains at least one character and the bit width N of the character by parsing the target data stream. It is then determined whether there is a character identical to the first preset value for each of the characters. If so, the target character is compressed into 1 0. The entire data stream is compressed. Since the FPGA bit stream contains a large amount of identical data, this method can greatly improve the data compression efficiency in the FPGA bit stream. Compared with traditional algorithms such as Huffman and PBA, the method in this embodiment has less time complexity and space complexity, and is faster in processing compressed and decompressed data, and occupies less memory space and hardware device resources.

[0051] Huffman compression is mainly used to compress text and program files. It belongs to the family of variable code length algorithms. Its principle is to re-encode the characters in the text file. For characters with higher frequency of use, the encoding is shorter. For characters with lower frequency of use, longer bit sequences are used to represent them.

[0052] The method comprises: step 105, if the target character is different from the first preset value, combining the target character with a binary number 1 to form a second target character, wherein the second target character is a combination of 1 and the target character, and 1 is before the target character.

[0053] Specifically, as shown in FIG2(b), if the target character is different from the first preset value, for example, the target data stream is 16-bit data of 0100 0010 0000 0000, the first preset value is 0000, the preset bit width of the character is 4, that is, N is equal to 4, and there are 4 4-bit characters such as 0100, 0010, 0000 and 0000 in the target data stream. Among them, 0100 and 0010 are data that are not equal to the first preset value. In order to distinguish it from the data compressed by the first preset value, it is necessary to add 1 before 0100 to generate the second target character. The second target characters are 10100 and 10010. The second target character is changed from the original 4-bit width of 4 bits to 5 bits.

[0054] Step 106: Generate a second data stream corresponding to the target data stream according to the first target character and the second target character.

[0055] Specifically, the second data stream is generated by combining the first target character and the second target character, and the second data stream is a compressed data stream. For example, the target data stream is 16-bit data of 0100 0010 0000 0000, the first preset value is 0000, the preset bit width of the character is 4, that is, N is equal to 4, and there are 4 4-bit characters such as 0100, 0010, 0000 and 0000 in the target data stream. Among them, the 0000 0000 character that satisfies all 0 generates the first target character 0 0, and the characters that do not satisfy all 0 generate the second target characters 10100 and 10010. Since the system will start judging from the first character, the generated compressed stream is also arranged in the order of the original characters. The compressed stream finally generated is 10100 1001000. The target data stream is changed from the original 16 bits to the compressed data stream of 12 bits.

[0056] In this embodiment, a character compression method based on data stream is provided, by adding 1 to characters that are not equal to the first preset value to distinguish between characters that are the same as the first preset value and characters that are not the same as the first preset value. Finally, a compressed data stream of the target data stream is generated. This facilitates the system to judge different compressed characters in the FPGA, and is used to distinguish different data whose first digit is 0 and whose first digit is 1, and improves the compression efficiency of the FPGA data stream, because there is a large amount of identical data in the FPGA data stream.

[0057] In this embodiment, a character compression method based on data stream is provided, which can be executed by a server, a terminal or other device. Figure 3 is a flow chart of a character compression method based on data stream according to an embodiment of the present invention, such as Figure 3 As shown, the process includes the following steps:

[0058] Step 301: Acquire the first data stream and the second data stream.

[0059] The first data stream and the second data stream refer to data streams after the target data stream is compressed, and are hereinafter referred to as compressed data streams. A compressed data stream is a data stream that has been compressed and is usually used to store, transmit or process a large amount of data to reduce the storage space, transmission bandwidth or processing time occupied by the data. When processing a compressed data stream, it is usually necessary to decompress it to restore the original data. The decompression process is the opposite of the compression process, and a corresponding decompression algorithm needs to be used to restore the data.

[0060] Specifically, for example, the system compresses the data 0000 0100 0000 with a preset bit width of 4 to obtain a compressed data stream of 0 101000.

[0061] Step 302: Parse the first data stream and the second data stream to obtain the first target character and the second target character.

[0062] Specifically, the system will parse the compressed data stream to obtain the first target character and the second target character obtained after compression. For example, in the data 0 10100 0, the first target character is 0 and the second target character is 10100.

[0063] Step 303: determine whether the first binary number in the first target character or the second target character is 0.

[0064] Specifically, in this embodiment, the system distinguishes the compressed data, that is, the first target character and the second target character, so as to facilitate the subsequent decompression operation. For example, in the data 0 10100 0, the first letter is 0 and the system will determine that the first letter is 0. If the system determines that a first binary number is removed from the compressed data, for example, when 010100 0, the first binary number is determined to be 0. The compressed data thereafter is 10100 0, which does not include the first compressed character.

[0065] Step 304: If yes, decompress the first binary number 0 in the first data stream and the second data stream to generate a third target character, the bit width of the third target character is the preset bit width N, and the third target character is composed of the first preset value.

[0066] Specifically, as shown in FIG4(a), if the first binary number is 0, then this 0 is used as the new third target character. The preset bit width of this third target character is N, which is completely composed of N 0s. For example, the first preset value is 0000, data 0 10100 0, and the first binary number is judged to be 0. After that, this data 0 will generate data 0000, and the generated number is related to the preset bit width of the original target data stream. When the first target character 0 generates the third target character 0000, the data in the original compressed data stream becomes 10100 0.

[0067] Step 305: output a target data stream corresponding to the first data stream and the second data stream according to the third target character.

[0068] Specifically, when the first target character 0 generates the third target character 0000, the data in the original compressed data stream becomes 10100 0. After the 10100 0 in the original compressed data stream is added to the decompressed 0000, 000010100 0 is generated, but the decompressed data system will not make any further judgments, and then the pointer points to the first word 1 in 10100 0 for judgment.

[0069] In this embodiment, this step is a further decompression process of the compressed data stream, especially when there is a large amount of continuous identical data in the data stream, this processing method can further improve the compression efficiency of the data. In this way, the redundancy of the data stream can be reduced, making the storage and transmission of data more efficient.

[0070] Step 306: If not, then according to the preset bit width N of the character, N binary numbers after the first binary number are intercepted.

[0071] Specifically, if the first binary number of the compressed data stream is not 0, it is 1. As shown in FIG4(b), the compressed data with a preset character width of 4 is 101010. The system determines that the first word is 1, and then intercepts the four binary numbers 0101 after the first word 1.

[0072] Step 307: Generate a fourth target character according to the N binary numbers following the first binary number, wherein the bit width of the fourth target character is a preset bit width N.

[0073] Specifically, as shown in FIG4(b), for example, if the output character is 0101, 0101 is the fourth target character, and its bit width is 4. The first binary number 1 will be removed, and the compressed data stream of 10101 0 becomes 0101 0. Since 0101 has been successfully decompressed, the pointer points to the last 0, and the last 0 is the first binary character. According to step 304, 0 is decompressed to 0000.

[0074] Step 308: output a target data stream corresponding to the first data stream and the second data stream according to the fourth target character.

[0075] Specifically, the target data stream corresponding to the compressed data stream is output according to the decompressed fourth target character and the third target character described in step 304. Finally, the original compressed data is 0 10101 0, which becomes the original target data of 0000 01010000 after decompression.

[0076] In this embodiment, by judging whether the first binary number is 0, if it is not 0, the first word is 1, and the fourth target character is generated by intercepting N binary numbers after 1 according to the bit width N of the character, and the final target data stream is formed according to the fourth target character and other characters. Through this process, characters that are not equal to the first preset value can be correctly processed, the integrity and accuracy of the data can be ensured, and the efficiency of data compression can be improved.

[0077] This implementation can achieve good compression effects for data containing a large number of identical characters, and traditional hardware compression and RLE methods will quickly fail. If the identical characters do not exceed 80% of the total characters, the RLE compression method is very inefficient. Both the PBA method and Huffman code are still effective and can compress to 50% of the original data, but due to the complexity of their algorithms, the implementation will also become more time-consuming and space-consuming. Since the FPGA bit stream contains a large amount of identical character data, this embodiment can achieve a good effect to improve the efficiency of data compression and decompression. As shown in the following formula:

[0078] Z+(LZ)(W+1)=LW+L-ZW

[0079] Wherein, L is the total number of characters of the target data, Z is the first preset number of characters, and W is the character width. For example, the target data is 0000 0100 0000 0011 0000, the first preset value is 0000, and the character width in the target data is W=4. The total number of characters of the target data is L=5, the number of 0 characters of the target data is Z=3, and the number of bits of the original data is L*W=5*4=20 bits. The number of bits after the target data is compressed is LW+L-ZW=20+5-3*4=13 bits.

[0080] In the present embodiment, a character compression device based on data stream is also provided, and the device is used to implement the above-mentioned embodiment and preferred implementation mode, and the descriptions that have been made are not repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.

[0081] This embodiment provides a character compression device based on data stream, such as Figure 5 As shown, including:

[0082] The acquisition module 501 is used to acquire a target data stream based on a data stream.

[0083] The parsing module 502 is used to parse the target data stream to obtain at least one character and a preset bit width N of the character, wherein the character is composed of N binary numbers, and N>0.

[0084] The judging module 503 is used to judge whether each of the characters in the target data stream is the same as a first preset value, where the first preset value is a target character composed of N binary numbers.

[0085] The first generating module 504 is configured to, if yes, compress each of the target characters into a binary number 0, obtain a first target character including the binary number 0, and output a first data stream corresponding to the target data stream.

[0086] A combining module 505 is used for combining the target character and a binary number 1 into a second target character if the target character is different from the first preset value, wherein the second target character is a combination of 1 and the target character, and 1 is before the target character;

[0087] The second generating module is used to generate a second data stream corresponding to the target data stream according to the first target character and the second target character.

[0088] In some optional implementations, the judgment module 503 specifically further includes: parsing the first data stream and the second data stream to obtain the first target character and the second target character; and judging whether the first binary number in the first target character or the second target character is 0.

[0089] In some other optional implementations, the first generation module 504 specifically also includes: if yes, then decompressing the first binary number 0 in the first data stream and the second data stream to generate a third target character, the bit width of the third target character is the preset bit width N, and the third target character is composed of the first preset value; according to the third target character, outputting the target data stream corresponding to the first data stream and the second data stream.

[0090] In some further optional implementations, the first generation module 504 specifically also includes: if not, then according to the preset bit width N of the character, truncating the N binary numbers after the first binary number; generating a fourth target character according to the N binary numbers after the first binary number, the bit width of the fourth target character being the preset bit width N; and outputting a target data stream corresponding to the first data stream and the second data stream according to the fourth target character.

[0091] In this embodiment, a data stream-based character compression device is presented in the form of a functional unit, where the unit refers to an ASIC circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0092] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0093] The embodiment of the present invention also provides an electronic device having the above Figure 5 A character compression device based on data stream is shown.

[0094] See also Figure 6 , Figure 6 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present invention, such as Figure 6As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including a high-speed interface and a low-speed interface. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input / output device. In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations. Figure 6 A processor 10 is taken as an example.

[0095] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0096] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0097] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of an electronic device based on the presentation of a small program landing page, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0098] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0099] The electronic device further includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.

[0100] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device, a tactile feedback device, etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.

[0101] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0102] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A character compression method based on data stream, characterized in that: The method comprises: Get the target data stream based on the data stream; Parsing the target data stream to obtain at least one character and a preset bit width N of the character, wherein the character is composed of N binary numbers, N>0; Determine whether each of the characters in the target data stream is the same as a first preset value, where the first preset value is a target character consisting of N binary numbers; If yes, compress each of the target characters into a binary number 0, obtain a first target character including the binary number 0, and output a first data stream corresponding to the target data stream; If the target character is different from the first preset value, the target character and the binary number 1 are combined into a second target character, where the second target character is a combination of 1 and the target character, and 1 is before the target character; A second data stream corresponding to the target data stream is generated according to the first target character and the second target character.

2. The method according to claim 1, characterized in that: The method further comprises: Acquire the first data stream and the second data stream; Parsing the first data stream and the second data stream to obtain the first target character and the second target character; Determine whether the first binary number in the first target character or the second target character is 0; If yes, decompress the first binary number 0 in the first data stream and the second data stream to generate a third target character, the bit width of the third target character is the preset bit width N, and the third target character is composed of the first preset value; According to the third target character, a target data stream corresponding to the first data stream and the second data stream is output.

3. The method according to claim 2, characterized in that The method further comprises: If not, then intercepting N binary numbers after the first binary number according to the preset bit width N of the character; Generate a fourth target character according to the N binary numbers after the first binary number, wherein the bit width of the fourth target character is a preset bit width N; According to the fourth target character, a target data stream corresponding to the first data stream and the second data stream is output.

4. The method according to claim 2, characterized in that: After generating the third target character, the method further includes: Acquire the first data stream and the second data stream; The first binary numbers of the first data stream and the second data stream are removed, and the first binary numbers of the first data stream and the second data stream are updated.

5. The method according to claim 3, characterized in that: After generating the fourth target character, the method further includes: Acquire the first data stream and the second data stream; removing the first binary number of the first data stream and the second data stream; Then, the first N binary numbers of the first data stream and the second data stream are removed, and the first binary numbers of the first data stream and the second data stream are updated.

6. A character compression device based on data stream, characterized in that: The device comprises: An acquisition module, used for acquiring a target data stream based on a data stream; A parsing module, used for parsing the target data stream to obtain at least one character and a preset bit width N of the character, wherein the character is composed of N binary numbers, N>0; A judging module, used for judging whether each of the characters in the target data stream is the same as a first preset value, wherein the first preset value is a target character composed of N binary numbers; A first generating module is used for compressing each of the target characters into a binary number 0 if yes, obtaining a first target character including the binary number 0, and outputting a first data stream corresponding to the target data stream; a combining module, configured to combine the target character and a binary number 1 to form a second target character if the target character is different from a first preset value, wherein the second target character is a combination of 1 and the target character, and 1 is before the target character; The second generating module is used to generate a second data stream corresponding to the target data stream according to the first target character and the second target character.

7. An electronic device, characterized in that: It comprises a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes a data stream-based character compression method as described in any one of claims 1 to 5 by executing the computer instructions.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute a character compression method based on data stream according to any one of claims 1 to 5.