Data compression method and data decompression method
Through the data compression method of grouping and valid generation of target signals, the problem of excessive bit width of mark signals is solved, and the effect of reducing hardware overhead and design complexity is achieved.
Patent Information
- Application Number
- CN202510157753.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-12
- Publication Date
- 2025-06-17
AI Technical Summary
In the prior art, the bit width of the marking signal needs to match the byte width of the transmitted data, resulting in an increase in hardware design complexity and hardware overhead when data is transmitted at high bit width.
Through the data compression method, the target signals are grouped and a compressed signal is generated according to the effectiveness of the data signal, thereby reducing the bit width of the marking signal. The specific steps include acquiring the target signal, grouping processing, and generating a compressed signal.
It reduces the use of linewidth resources, reduces the complexity and hardware overhead of hardware design, and ensures the accuracy and completeness of data transmission.
Smart Images

Figure CN120165692A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a data compression method and a data decompression method. Background Art
[0002] In modern computer systems and digital signal processing fields, data buses play a crucial role. They are responsible for efficiently transmitting data between processors, memories, and other peripherals. To improve the flexibility and efficiency of data transmission, multiple bus protocols have been designed. One key function is to indicate which bytes in the transmitted data are valid through specific marking signals.
[0003] In the prior art, the bit width of the marking signal needs to match the byte width of the transmitted data. However, as the data bus width continues to increase, when the bit width of the transmitted data reaches a very large level, the bit width of the marking signal will also increase accordingly, thus occupying a considerable wire width resource. This not only increases the complexity of hardware design but also brings additional hardware overheads, including more pins, a larger circuit board area, and higher manufacturing costs. Summary of the Invention
[0004] In view of this, the purpose of the embodiments of the present invention is to provide a data compression method and a data decompression method, which can reduce the bit width of the marking signal, thereby reducing the occupation of wire width resources, reducing the complexity of hardware design, and reducing additional hardware overheads.
[0005] In a first aspect, an embodiment of the present invention provides a data compression method, and the method includes:
[0006] Obtain a target signal, where the target signal includes a first data signal of N bytes and a first marking signal of N bits. Each bit of the first marking signal is used to represent the validity of one byte in the first data signal, and N is a positive integer greater than or equal to 1;
[0007] Group the target signal according to a predetermined number of bytes to obtain M first signal groups. Each of the first signal groups includes at least one bit of the first marking signal and at least one byte of the first data signal, and M is a positive integer greater than or equal to 1;
[0008] Generate M second signal groups according to the validity of the first data signal in the first signal group. The second signal group includes a second marking signal of one bit and at least one byte of a second data signal;
[0009] Generate a compressed signal according to the second signal group, where the compressed signal includes a second data signal of N bytes and a second flag signal of M bits, and each bit of the second flag signal is used to characterize the full validity of one or more bytes in the second data signal.
[0010] In a second aspect, an embodiment of the present invention provides a data decompression method, and the method includes:
[0011] Obtain a compressed signal, where the compressed signal includes a second data signal of N bytes and a second flag signal of M bits, and each bit of the second flag signal is used to characterize the full validity of one or more bytes in the second data signal, N is a positive integer greater than or equal to 1, and M is a positive integer greater than or equal to 1;
[0012] Group the compressed signal according to a predetermined number of bytes to obtain M second signal groups, and each second signal group includes a second flag signal of one bit and a second data signal of at least one byte;
[0013] Generate M first signal groups according to the validity of the second data signal in the second signal group, where the first signal group includes a first flag signal of at least one bit and a first data signal of at least one byte;
[0014] Generate a target signal according to the first signal group, where the target signal includes a first data signal of N bytes and a first flag signal of N bits, and each bit of the first flag signal is used to characterize the validity of one byte in the first data signal.
[0015] In a third aspect, an embodiment of the present invention provides a data compression device, and the device includes:
[0016] A first acquisition unit, configured to acquire a target signal, where the target signal includes a first data signal of N bytes and a first flag signal of N bits, and each bit of the first flag signal is used to characterize the validity of one byte in the first data signal, and N is a positive integer greater than or equal to 1;
[0017] A first grouping unit, configured to group the target signal according to a predetermined number of bytes to obtain M first signal groups, and each first signal group includes a first flag signal of at least one bit and a first data signal of at least one byte, and M is a positive integer greater than or equal to 1;
[0018] A first generation unit, configured to generate M second signal groups according to the validity of the first data signal in the first signal group, where the second signal group includes a second flag signal of one bit and a second data signal of at least one byte;
[0019] A first compression unit, configured to generate a compression signal according to the second signal group, where the compression signal includes a second data signal of N bytes and a second marker signal of M bits, and each bit of the second marker signal is used to characterize the full validity of one or more bytes in the second data signal.
[0020] In a fourth aspect, an embodiment of the present invention provides a data decompression device, where the device includes:
[0021] A second acquisition unit, configured to acquire a compression signal, where the compression signal includes a second data signal of N bytes and a second marker signal of M bits, and each bit of the second marker signal is used to characterize the full validity of one or more bytes in the second data signal, N is a positive integer greater than or equal to 1, and M is a positive integer greater than or equal to 1;
[0022] A second grouping unit, configured to group the compression signal according to a predetermined number of bytes to obtain M second signal groups, and each of the second signal groups includes a second marker signal of one bit and a second data signal of at least one byte;
[0023] A second generation unit, configured to generate M first signal groups according to the validity of the second data signal in the second signal group, where the first signal group includes a first marker signal of at least one bit and a first data signal of at least one byte;
[0024] A second decompression unit, configured to generate a target signal according to the first signal group, where the target signal includes a first data signal of N bytes and a first marker signal of N bits, and each bit of the first marker signal is used to characterize the validity of one byte in the first data signal.
[0025] In a fifth aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor, where the memory is configured to store one or more computer program instructions, and where the one or more computer program instructions are executed by the processor to implement the methods described in the first aspect and the second aspect.
[0026] In the technical solution of the embodiment of the present invention during the compression process, a target signal is obtained. Each bit of the first marker signal of the target signal is used to represent the validity of one byte in the first data signal. The target signal is grouped according to a predetermined number of bytes to obtain M first signal groups. M second signal groups are generated according to the validity of the first data signal in the first signal groups. The second signal group includes a one-bit second marker signal and at least one byte of second data signal. A compressed signal is generated according to the second signal group. Thus, compared with the target signal, the generated compressed signal can reduce the bit width of the marker signal, thereby reducing the occupation of line width resources, reducing the complexity of hardware design, and reducing additional hardware overhead. At the same time, during the decompression process, by obtaining the compressed signal, the compressed signal is grouped according to a predetermined number of bytes to obtain M second signal groups. M first signal groups are generated according to the validity of the second data signal in the second signal groups. A target signal is generated according to the first signal groups. Each bit of the first marker signal of the target signal is used to represent the validity of one byte in the first data signal of the target signal. Thus, the valid bytes of the compressed signal can be accurately decompressed without losing the information carried by the original data. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Through the following description of the embodiments of the present invention with reference to the drawings, the above and other objects, features, and advantages of the present invention will become clearer. In the drawings:
[0028] Figure 1 is a flowchart of a data compression method according to an embodiment of the present invention;
[0029] Figure 2 is a schematic diagram of data compression in the first example of the embodiment of the present invention;
[0030] Figure 3 is a schematic diagram of data compression in the second example of the embodiment of the present invention;
[0031] Figure 4 is a schematic diagram of data compression in the third example of the embodiment of the present invention;
[0032] Figure 5 is a schematic diagram of data compression in the fourth example of the embodiment of the present invention;
[0033] Figure 6 is a flowchart of a data decompression method according to an embodiment of the present invention;
[0034] Figure 7 is a schematic diagram of data decompression in the first example of the embodiment of the present invention;
[0035] Figure 8 is a schematic diagram of data decompression in the second example of the embodiment of the present invention;
[0036] Figure 9 It is a schematic diagram of data decompression for the third example of the embodiment of the present invention;
[0037] Figure 10 It is a schematic diagram of data decompression for the fourth example of the embodiment of the present invention
[0038] Figure 11 It is a flowchart of a data compression method according to another embodiment of the present invention;
[0039] Figure 12 It is a flowchart of a data decompression method according to another embodiment of the present invention;
[0040] Figure 13 It is a schematic diagram of a data compression device according to an embodiment of the present invention;
[0041] Figure 14 It is a schematic diagram of a data decompression device according to an embodiment of the present invention;
[0042] Figure 15 It is a schematic diagram of an electronic device according to an embodiment of the present invention. Detailed implementation manners
[0043] The following describes the present application based on embodiments, but the present application is not limited to these embodiments. In the following detailed description of the present application, some specific details are described in detail. Those skilled in the art can fully understand the present application without the description of these details. In order to avoid obscuring the essence of the present application, well-known methods, processes, flows, components, and circuits are not described in detail.
[0044] In addition, those of ordinary skill in the art should understand that the drawings provided herein are for illustrative purposes only, and the drawings are not necessarily drawn to scale.
[0045] Unless the context clearly requires otherwise, words such as "including" and "comprising" in the entire application document should be interpreted in an inclusive sense rather than an exclusive or exhaustive sense; that is, it is the meaning of "including but not limited to".
[0046] In the description of the present application, it should be understood that terms such as "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0047] In modern computer systems and digital signal processing fields, data buses play a crucial role, and they are responsible for efficiently transmitting data between processors, memories, and other peripherals. To improve the flexibility and efficiency of data transmission, multiple bus protocols have been designed, and one of the key functions is to indicate which bytes in the transmitted data are valid through specific marker signals.
[0048] Among them, common marking signals include wstrb (Write_Strobe), be (Byte_Enable), dm (Data_Mask), etc. wstrb is a control signal used to indicate which bytes in the write data (wdata) are valid. The bit width of wstrb usually matches the byte width of wdata, and each bit of it represents whether the byte at the corresponding position in wdata is valid. The be signal is used to identify which bytes should be enabled or processed during data transmission. Similar to wstrb, the bit width of the be signal usually corresponds to the byte width of the data, but the specific implementation and usage vary depending on different bus protocols. The Dm signal is used to mask or ignore certain bytes during data transmission. When writing data, the dm signal can indicate which bytes are invalid or do not need to be written, thus avoiding unnecessary write operations and data conflicts.
[0049] These signals play a crucial role in data transmission and processing, which is essential for avoiding data errors, optimizing storage bandwidth, and improving the overall system performance. They can ensure the correctness and integrity of data, while enhancing the efficiency and flexibility of data transmission. However, with the increase in the data bus width, these signals may also bring additional hardware overhead and signal integrity challenges. Therefore, when designing and implementing these signals, various factors need to be carefully weighed to ensure the performance and stability of the system.
[0050] In the prior art, the bit width of the marking signal needs to match the byte width of the transmitted data. However, with the continuous increase in the data bus width, when the bit width of the transmitted data reaches a very large level, the bit width of the marking signal will also increase accordingly, thus occupying a considerable line width resource. This not only increases the complexity of the hardware design but also brings additional hardware overhead, including more pins, a larger circuit board area, and higher manufacturing costs.
[0051] Taking wstrb as an example for illustration, the design of the wstrb signal generally follows a basic principle: the bit width of wstrb needs to match the byte width of wdata. Specifically, each bit of wstrb directly corresponds to a byte in wdata and is used to identify whether the byte should be received or processed. For example, if wdata is a 32-bit wide data (i.e., contains 4 bytes), then wstrb will also be a 4-bit wide signal, and each bit controls a byte in wdata respectively. This design ensures the accuracy and flexibility of data transmission, enabling the system to selectively receive or ignore specific bytes in the data as needed.
[0052] However, with the continuous increase in the data bus width, significant problems have emerged in the design of marker signals in the prior art. Especially when the bit width of the data reaches a very large level (such as 64 bits, 128 bits or even higher), the bit width of the marker signal will also increase accordingly, thus occupying a considerable amount of line width resources. This not only increases the complexity of the hardware design but also brings additional hardware overheads, including more pins, a larger circuit board area, and higher manufacturing costs. In addition, for the backend routing, wide-bit-width marker signals are also a severe challenge because they may lead to an exacerbation of signal integrity problems, such as signal attenuation, crosstalk, and timing offset, thus affecting the reliability and stability of data transmission. These problems are common to all bus protocols containing marker signals and limit their further promotion and application in high-performance and high-bandwidth applications. Therefore, it is particularly important to develop a new technology that can effectively reduce the line width occupation of marker signals, reduce hardware overheads, and improve the performance of backend routing.
[0053] In view of this, embodiments of the present invention provide a data compression method and a data decompression method. After compressing the marker signals in the data to be transmitted through the data compression method, the data is then transmitted, which can reduce the bit width of the marker signals, thereby reducing the occupation of line width resources, reducing the complexity of the hardware design, and reducing additional hardware overheads. Through the data decompression method, after decompressing the received compressed data, the marker signals and valid data before compression are obtained, so as to accurately obtain all valid original data.
[0054] The following explains the terms and technologies involved in the embodiments of the present invention:
[0055] Bit: It is short for binary digit. The information of a computer is processed and transmitted in binary. Binary is 0 and 1. For example, a 0 is a bit, and a 1 is also a bit.
[0056] Byte, one byte is equal to eight bits, that is, each byte is represented by eight binary digits.
[0057] wstrb (Write_Strobe, write strobe signal): A control signal used to indicate which bytes in the write data (wdata) are valid.
[0058] wdata (Write Data, write data): Represents the data to be written into a certain storage unit or transmitted to a certain device.
[0059] Target signal: In the data compression process, it refers to the transmission signal before compression; in the data decompression process, it refers to the transmission signal obtained after decompression. The target signal includes the wstrb signal and the wdata signal.
[0060] Compressed signal: In the data compression process, it refers to the transmitted signal after compression; in the data decompression process, it refers to the signal to be decompressed.
[0061] First data signal: In the data compression process, it refers to the wdata signal in the target signal before compression; in the data decompression process, it refers to the wdata signal in the target signal after decompression.
[0062] First marking signal: In the data compression process, it refers to the wstrb signal in the target signal before compression; in the data decompression process, it refers to the wstrb signal in the target signal after decompression.
[0063] Second data signal: In the data compression process, it refers to the wdata signal in the compressed signal after compression; in the data decompression process, it refers to the wdata signal in the compressed signal before decompression.
[0064] Second marking signal: In the data compression process, it refers to the wstrb signal in the compressed signal after compression; in the data decompression process, it refers to the wstrb signal in the compressed signal before decompression.
[0065] Designated byte: The designated byte is determined as any one byte specified in advance, and its function is to store the replacement signal when the first data signal is not all valid.
[0066] Determination method of the designated byte: The lowest - order byte can be determined as the designated byte, the highest - order byte can be determined as the designated byte, etc., and the determination methods in the compression stage and the decompression stage are the same. In the embodiments of the present invention, the determination method of determining the lowest - order byte as the designated byte is adopted.
[0067] Replacement signal: The replacement signal is a signal generated according to the first marking signal when the first data signal is not all valid. When the first marking signal is eight bits, the replacement signal is the first marking signal. When the first marking signal is less than eight bits, during compression, it is obtained by complementing the first marking signal according to a predetermined complementing method and filled into the designated byte. During decompression, the replacement signal is obtained from the designated byte, and then the first marking signal is obtained by extracting according to a predetermined extraction method.
[0068] Completing method: When the first marking signal is less than eight bits, it can be completed to eight bits by an appropriate completing method as the replacement signal. The adopted completing method can be completing the lower bits, completing the higher bits or other completing methods. For example, assuming that the first marking signal of five bits 11111 needs to be completed to eight bits, completing the lower bits means complementing the number 0 at the lower bits of 11111, and the replaced signal after completion is 11111000; completing the higher bits means complementing the number 0 at the higher bits of 11111, and the replaced signal after completion is 00011111. Or, other completing methods can also be adopted. In addition, in the embodiments of the present invention, when K = 8 and N is an integer multiple of K, there is no need to adopt an additional completing method to obtain the replacement signal.
[0069] Extracting method: Corresponding to the completing method, if the lower bits are completed, the higher bits are extracted; if the higher bits are completed, the lower bits are extracted. For example, assuming that the first marking signal of five bits 11111 needs to be completed to eight bits, completing the lower bits means complementing the number 0 at the lower three bits of 11111, and the replaced signal after completion is 11111000, then the corresponding extracting method is to extract the "11111" of the higher five bits; another example, assuming that the first marking signal of five bits 11111 needs to be completed to eight bits, completing the higher bits means complementing the number 0 at the higher three bits of 11111, and the replaced signal after completion is 00011111, then the corresponding extracting method is to extract the "11111" of the lower five bits. If other methods are adopted for completing, the extracting method is set corresponding to the completing method.
[0070] Target invalid byte: An invalid byte determined from all the invalid bytes in a predetermined manner. The target invalid byte is used to store the replacement signal or the content of the specified byte. When the first data signal in the first signal group is not all valid, when the specified byte is the target invalid byte, the target invalid byte is used to store the replacement signal obtained according to the first marking signal, so that the valid data will not be lost; when the specified byte is not the target invalid byte, the target invalid byte is used to store the content of the specified byte to ensure that the valid data will not be lost. In the compression stage, when the first data signal in the first signal group is not all valid, an invalid byte determined from all the invalid bytes in the first signal group in a predetermined manner. In the decompression stage, when the second data signal in the second signal group is not all valid, an invalid byte determined from all the invalid bytes in the second signal group in a predetermined manner. The determination methods in the compression stage and the decompression stage are the same.
[0071] Determination method of the target invalid byte: The target invalid byte is a previously determined invalid byte, and the determination methods in the compression stage and the decompression stage are the same. The determination method can be determining the first invalid byte starting from the low bit as the target invalid byte, determining the last invalid byte starting from the low bit as the target invalid byte, determining the first invalid byte starting from the high bit as the target invalid byte, determining the last invalid byte starting from the high bit as the target invalid byte, etc. In the embodiment of the present invention, the first invalid byte starting from the low bit is determined as the target invalid byte.
[0072] Content filling method of the target invalid byte: In the decompression stage, it is necessary to fill the content of the target invalid byte, and the filling methods include: keeping the original value, replacing it with any value, replacing it with a predetermined value, etc. Among them, keeping the original value means keeping the value of the target invalid byte unchanged from before decompression; replacing it with any value means replacing the target invalid byte with various randomly generated or other obtained values; replacing it with a predetermined value means replacing the target invalid byte with various pre-set values, for example, 11111111, 00000000, 10101010, 11110000, etc. In the embodiment of the present invention, the filling method of keeping the original value is adopted.
[0073] First value / Second value: In the binary description of the marker signal in the embodiment of the present invention, the first value and the second value are adopted, and the first value is used to represent valid and the second value is used to represent invalid. In the embodiment of the present invention, the first value of the first marker signal and the second marker signal both takes the binary value of 1, and the second value both takes the binary value of 0, that is, 1 represents valid and 0 represents invalid. However, the present invention does not limit whether the first value / second value of the second marker signal is consistent with that of the first marker signal. That is, in some application environments, the first value / second value of the second marker signal can have the same value as the first value / second value of the first marker signal, while in other application environments, the first value / second value of the second marker signal can have a different value from the first value / second value of the first marker signal. In the embodiment of the present invention, the second marker signal adopts the same first value / second value as the first marker signal, so the first value / second value in the example of the present invention no longer distinguishes between the first marker signal and the second marker signal. In addition, the present invention does not limit the values of the first value and the second value, that is, the specific values of the first value and the second value can be set according to the requirements of the actual application scenario. For example, in some application environments, it may be agreed that 1 represents valid and 0 represents invalid; while in other scenarios, it may be the opposite, using 0 to represent valid and 1 to represent invalid.
[0074] Grouping: Grouping is involved in both the compression and decompression processes in the embodiments of the present invention. In the description of the embodiments of the present invention, the grouping method is to group in sequence and according to a predetermined number of bytes K. However, the present invention does not limit the grouping method. In specific practices, it is not necessary to group in sequence, nor is it necessary to group according to a predetermined number of bytes. The present invention can adopt various grouping methods as long as the grouping methods in the compression and decompression processes are consistent.
[0075] Figure 1 is a flowchart of a data compression method according to an embodiment of the present invention. Figure 1 The data compression method shown can be applied to various electronic devices and specifically includes the following steps:
[0076] Step S101, obtain a target signal.
[0077] In this embodiment, a target signal is obtained. The target signal is a signal to be transmitted and can also be referred to as a signal to be compressed. The target signal includes a first data signal and a first marker signal. Each bit of the first marker signal is used to characterize the validity of the byte at the corresponding position in the first data signal.
[0078] Among them, the first data signal is a wdata (Write Data) signal, which represents the data to be written into a certain storage unit or transmitted to a certain device or module. The first data signal includes multiple bytes, and each byte is eight bits.
[0079] The first marker signal is a wstrb (Write_Strobe) signal, which is a control signal used to indicate which bytes in the write data (wdata) are valid.
[0080] In some embodiments, the first data signal includes N bytes. Correspondingly, the first marker signal includes N bits, and each bit is used to characterize the validity of the byte at the corresponding position in the first data signal. That is to say, the first data signal is data of 8 * N bits, and the first marker signal is data of N bits, where N is a positive integer greater than or equal to 1.
[0081] Step S102, group the target signal to obtain M first signal groups.
[0082] In this embodiment, the target signal is grouped according to a predetermined number of bytes to obtain M first signal groups. Each of the first signal groups includes at least one bit of the first marker signal and at least one byte of the first data signal, where M is a positive integer greater than or equal to 1.
[0083] The predetermined number of bytes is K, where K is a positive integer greater than or equal to 2 and less than or equal to 8. The predetermined number of bytes is the maximum number of bytes of the first data signal in the first signal group.
[0084] Among them, grouping the target signal according to the predetermined number of bytes to obtain M first signal groups includes:
[0085] In response to N being less than or equal to K, the target signal is grouped to obtain one first signal group, and the first signal group includes a first marker signal of N bits and a first data signal of N bytes. That is, if N is less than or equal to K, it means that the number of bytes in the target signal is less than or equal to the predetermined number of bytes, and all bytes only need to be added to one first signal group. For example, assuming N = 4 and K = 6, then all four bytes are divided into one first signal group. Another example, assuming N = 6 and K = 6, then all six bytes are divided into one first signal group.
[0086] In response to N being greater than K and N being an integer multiple of K, the target signal is grouped to obtain M first signal groups, and each first signal group includes a first marker signal of K bits and a first data signal of K bytes. At this time, M is greater than or equal to 2. That is, if N is greater than K and N is an integer multiple of K, then N bytes are divided into N / K first signal groups, and each first signal group includes K bytes. For example, assuming N = 64 and K = 8, then every eight bytes are divided into one first signal group, and a total of eight first signal groups can be divided.
[0087] In response to N being greater than K and N not being an integer multiple of K, the target signal is grouped to obtain M first signal groups. The first M - 1 first signal groups include a first marker signal of K bits and a first data signal of K bytes, and the Mth first signal group includes a first marker signal of L bits and a first data signal of L bytes, where L is a positive integer greater than or equal to 1 and less than K. For example, assuming N = 66 and K = 8, then every eight bytes are divided into one first signal group. The first 64 bytes can obtain eight first signal groups, and the last two bytes obtain one first signal group.
[0088] It should be noted that when grouping the target signal, it can be in a predetermined order. For example, assuming the target signal is 64 bytes, starting from the low bit, the 1 - 8th bytes are the first group, the 9 - 16th bytes are the second group, and so on. Among the multiple first signal groups finally obtained, the bytes between the multiple first signal groups are continuous, and the bytes in each first signal group are also continuous.
[0089] Further, after obtaining multiple first signal groups, each first signal group is processed separately. Steps S103 - S110 provide a processing flow for one first signal group, and the processing flow for each first signal group is the same. This will not be elaborated in this embodiment of the present invention.
[0090] Step S103: Determine whether all the first data signals are valid.
[0091] In this embodiment, the validity of the first data signal is determined according to the first marker signal in the first signal group. For each bit of the first marker signal, if it is the first value, it indicates that the byte at the corresponding position is valid; if it is the second value, it indicates that the byte at the corresponding position is invalid. Thus, the first marker signal in the first signal group is converted into a hexadecimal value. In response to the hexadecimal value being a predetermined value, it is determined that all the first data signals in the first signal group are valid. In response to the hexadecimal value not being the predetermined value, it is determined that not all the first data signals in the first signal group are valid. Among them, the predetermined value is determined according to the number of bytes of the first data signal in the first signal group. Not all valid means partially valid or all invalid. Among them, the first value is 1 and the second value is 0.
[0092] For example, assume that the number of bytes of the first data signal in the first signal group is 8. If the first marker signal is 11111111, it means that all the bytes in the first data signal in the first signal group are valid; if it is not 11111111, it means that not all the bytes in the first data signal in the first signal group are valid. At this time, the predetermined value is ff.
[0093] Another example, assume that the number of bytes of the first data signal in the first signal group is 6. If the first marker signal is 111111, it means that all the bytes in the first data signal in the first signal group are valid; if it is not 111111, it means that not all the bytes in the first data signal in the first signal group are valid. At this time, the predetermined value is 3f.
[0094] It should be noted that this embodiment of the present invention takes the first value as 1 and the second value as 0 as an example for illustration, but the present invention does not limit the first value and the second value. That is, the specific values of the first value and the second value can be set according to the requirements of the actual application scenario. For example, in some application environments, it may be agreed that 1 represents valid and 0 represents invalid; in other scenarios, it may be the opposite, with 0 representing valid and 1 representing invalid.
[0095] Further, M second signal groups are generated according to the validity of the first data signal in the first signal group. The second signal group includes a one - bit second marker signal and multiple bytes of second data signals.
[0096] Specifically, in response to all the first data signals in the first signal group being valid, the second signal group is determined through steps S104 - S105.
[0097] In response to not all the first data signals in the first signal group being valid, the second signal group is determined through steps S106 - S110.
[0098] Step S104: Determine that the second marker signal is a first value of one bit.
[0099] In this embodiment, in response to all the first data signals in the first signal group being valid, it is determined that the second marker signal is a first value of one bit. Among them, the first value is 1.
[0100] Step S105: Determine the first data signal as the second data signal.
[0101] In this embodiment, for steps S104 - S105, in response to all the first data signals in the first signal group being valid, it is determined that the second marker signal is a first value of one bit, and the first data signal is determined as the second data signal. Thus, the second signal group can be obtained.
[0102] At this time, the first data signal is the same as the second data signal. Meanwhile, the first marker signal is converted into a second marker signal of one bit. Suppose there are eight bytes of first data signals and eight bits of first marker signals in the original first signal group. After conversion, the bit width of the marker signal is compressed to 1 / 8 of the original. Thus, the bit width of the marker signal can be reduced, thereby reducing the occupancy of line width resources, lowering the complexity of hardware design, and reducing additional hardware overhead.
[0103] Step S106: Determine that the second marker signal is a second value of one bit.
[0104] In this embodiment, in response to not all the first data signals in the first signal group being valid, it is determined that the second marker signal is a second value of one bit. Among them, the second value is 0.
[0105] Among them, each bit of the second marker signal is used to characterize the all - validity of one or more bytes in the second data signal. The all - validity refers to all valid or not all valid. That is, each bit of the second marker signal is used to characterize whether the bytes in the second data signal are all valid.
[0106] Suppose that the first data signal in the original first signal group has eight bytes and the first marker signal has eight bits. After conversion, the bit width of the marker signal is compressed to 1 / 8 of the original. Thus, the bit width of the marker signal can be reduced, thereby reducing the occupancy of line width resources, lowering the complexity of hardware design, and reducing additional hardware overhead.
[0107] Step S107: Determine the target invalid byte.
[0108] In this embodiment, the target invalid byte is determined according to the first marker signal according to a predetermined rule. Among them, determining the target invalid byte according to the first marker signal according to a predetermined rule includes the following one:
[0109] Starting from the low bit of the first marker signal, determine the first invalid byte in the first data signal according to the first marker signal, and determine the first invalid byte as the target invalid byte; or
[0110] Starting from the low bit of the first marker signal, determine the last invalid byte in the first data signal according to the first marker signal, and determine the last invalid byte as the target invalid byte; or
[0111] Starting from the high bit of the first marker signal, determine the first invalid byte in the first data signal according to the first marker signal, and determine the first invalid byte as the target invalid byte; or
[0112] Starting from the high bit of the first marker signal, determine the last invalid byte in the first data signal according to the first marker signal, and determine the last invalid byte as the target invalid byte.
[0113] It should be noted that the present invention only needs to select one as the target invalid byte from all the invalid bytes according to a predetermined rule, and the present invention does not limit the specific selection method. The four determination methods listed above are only several examples provided by the embodiments of the present invention. In specific practice, any of the above methods can be adopted, or other methods can also be adopted.
[0114] Taking the example of starting from the low bit of the first marker signal and determining the first invalid byte in the first data signal according to the first marker signal in the embodiment of the present invention, assume that the eight-bit first marker signal is 10110011. Starting from the low bit of the first marker signal means starting from right to left, and the third bit is 0, that is, the first invalid byte is the third byte starting from the low bit, that is, the target invalid byte is the third byte.
[0115] Step S108: Determine whether the target invalid byte is a specified byte.
[0116] In this embodiment, in the bytes of the first signal group, one byte is designated to store the replacement signal generated from the first marking signal, and this designated byte is used as the designated byte, where the designated byte can be any one of the bytes in the pre-designated first data signal. Detect whether the target invalid byte is the designated byte. For example, assume that the eight-bit first marking signal is 10110011. Starting from the low bit of the first marking signal, that is, from right to left, the third bit is 0. That is to say, the first invalid byte is the third byte starting from the low bit, that is, the target invalid byte is the third byte. If the designated byte is the third byte starting from the low bit, it means that the target invalid byte is the designated byte; if the designated byte is not the third byte starting from the low bit, it means that the target invalid byte is not the designated byte. In the embodiment of the present invention, the designated byte is taken as the first invalid byte starting from the low bit as an example for illustration.
[0117] In response to the target invalid byte being the designated byte, proceed to step S109.
[0118] In response to the target invalid byte not being the designated byte, proceed to step S110.
[0119] Step S109: Generate a replacement signal according to the first marking signal, and write the replacement signal into the designated byte, while keeping the other bytes unchanged.
[0120] In this embodiment, in response to the target invalid byte being the designated byte, generate a replacement signal according to the first marking signal, and write the replacement signal into the designated byte, while keeping the other bytes unchanged, to obtain the second data signal.
[0121] Step S110: Write the content of the designated byte into the target invalid byte, generate a replacement signal according to the first marking signal, and write the replacement signal into the designated byte, while keeping the other bytes unchanged.
[0122] In this embodiment, in response to the target invalid byte not being the designated byte, write the content of the designated byte into the target invalid byte, generate a replacement signal according to the first marking signal, and write the replacement signal into the designated byte, while keeping the other bytes unchanged, to obtain the second data signal.
[0123] For the above step S109 or step S110, generating a replacement signal according to the first marking signal includes:
[0124] In response to K being equal to 8, N being greater than or equal to K, and N being an integer multiple of K, determine the eight-bit first marking signal as the replacement signal.
[0125] In response to K being equal to 8, N being greater than K, and N not being an integer multiple of K, the first marker signal of eight bits in the first M - 1 first signal groups is determined as the replacement signal; in the Mth first signal group, the first marker signal is complemented according to a predetermined complementing method to obtain a replacement signal of eight bits.
[0126] In response to K being equal to 8 and N being less than K, the first marker signal is complemented according to a predetermined complementing method to obtain a replacement signal of eight bits.
[0127] In response to K being greater than or equal to 2 and less than 8, the first marker signal is complemented according to a predetermined complementing method to obtain a replacement signal of eight bits.
[0128] Among them, the predetermined complementing method can complement the lower bits, complement the higher bits, or other complementing methods. For example, assuming that the first marker signal of five bits 11111 needs to be complemented to eight bits, complementing the lower bits means complementing the number 0 at the lower bits of 11111, and the complemented first marker signal is 11111000; complementing the higher bits means complementing the number 0 at the higher bits of 11111, and the complemented first marker signal is 00011111. Or, other complementing methods can also be used.
[0129] Step S111, generate a compressed signal.
[0130] In this embodiment, by repeatedly executing the above steps S103 - S110, the second signal group corresponding to each first signal group can be obtained, and a compressed signal is generated according to the second signal group.
[0131] Specifically, as described above, when grouping the target signal, it is necessary to follow a predetermined order. For example, assuming that the target signal is 64 bytes, starting from the lower bits, the 1st - 8th bytes are the first group, the 9th - 16th bytes are the second group, and so on. Among the finally obtained multiple first signal groups, the bytes between the multiple first signal groups are continuous, and the bytes in each first signal group are also continuous. Thus, the finally obtained second signal group also has this characteristic. Thus, the second data signals of each second signal group are spliced in the same order to obtain the second data signal corresponding to the compressed signal, and the second marker signals are spliced to obtain the second marker signal corresponding to the compressed signal. At this time, the bit width of the marker signal in the compressed signal is compressed to 1 / 8 of the original target signal. Thus, the bit width of the marker signal can be reduced, thereby reducing the occupancy of line width resources, reducing the complexity of hardware design, and reducing additional hardware overhead.
[0132] In some embodiments, the method further includes:
[0133] Transmit the compressed signal.
[0134] Specifically, the compressed signal is transmitted through a bus.
[0135] Figure 2 It is a schematic diagram of data compression for the first example of the embodiment of the present invention. Figure 2 It shows a first signal group and a corresponding second signal group, where K = 8. The first signal group includes a first data signal and a first marker signal. The first data signal includes eight bytes, and the first marker signal is eight bits. Each bit of the first marker signal corresponds to one byte. In Figure 2 the illustrated embodiment, the first marker signal is 11111111, that is, all the first data signals are valid. Determine that the second marker signal is 1, and determine the first data signal as the second data signal. Thus, the second signal group can be obtained. Among them, the second signal group includes a second marker signal and a second data signal. The second marker signal is one bit, and the second data signal is eight bytes. The second marker signal is used to indicate whether the bytes of the second data signal in the second signal group are all valid. If the second marker signal is 1, it indicates that the bytes of the second data signal in the second signal group are all valid. If the second marker signal is 0, it indicates that the bytes of the second data signal in the second signal group are not all valid. In Figure 2 the illustrated embodiment, the first data signal and the second data signal are exactly the same.
[0136] Figure 3 It is a schematic diagram of data compression for the second example of the embodiment of the present invention. Figure 3 It shows a first signal group and a corresponding second signal group, where K = 8, the specified byte is the lowest - order byte, and the target invalid byte is the first invalid byte starting from the low - order bit. In Figure 3 it, the first data signal includes eight bytes, and the first marker signal is eight bits. Each bit of the first marker signal corresponds to one byte. In Figure 3 the illustrated embodiment, the first marker signal is 11111110, that is, the first data signal is not all valid. Determine that the second marker signal is 0. At the same time, the target invalid byte is the first byte starting from the lowest - order bit. Therefore, the target invalid byte is the specified byte. Thus, the first marker signal (11111110) is written into the lowest - order byte. Thus, the second signal group can be obtained. Among them, the second signal group includes a second marker signal and a second data signal. The second marker signal is one bit, and the second data signal is eight bytes. The second marker signal is used to indicate whether the bytes of the second data signal in the second signal group are all valid. If the second marker signal is 1, it indicates that the bytes of the second data signal in the second signal group are all valid. If the second marker signal is 0, it indicates that the bytes of the second data signal in the second signal group are not all valid. In Figure 3In the illustrated embodiment, the difference between the first data signal and the second data signal is that: the least significant byte of the first data signal and the second data signal is different. The least significant byte of the first data signal is the original target data, and the least significant byte of the second data signal is the first marker signal. Since the least significant byte is an invalid byte, the second data signal does not lose the information carried by the original data.
[0137] Figure 4 It is a schematic diagram of data compression for the third example of the embodiment of the present invention. Figure 4 A first signal group and a corresponding second signal group are shown. Among them, K = 8, the designated byte is the least significant byte, and the target invalid byte is the first invalid byte starting from the low bit. In Figure 4 the first data signal includes eight bytes, and the first marker signal is eight bits. Each bit of the first marker signal corresponds to a byte. In Figure 4 the illustrated embodiment, the first marker signal is 11111011. That is, the first data signal is not all valid. It is determined that the second marker signal is 0. At the same time, the target invalid byte is the third byte starting from the low bit. Therefore, the target invalid byte is not the designated byte. Therefore, the first marker signal (11111011) is written into the designated byte (the least significant byte), and at the same time, the original content (10101010) of the designated byte is written into the target invalid byte. Thus, the second signal group can be obtained. Among them, the second signal group includes a second marker signal and a second data signal. The second marker signal is one bit, and the second data signal is eight bytes. The second marker signal is used to indicate whether the bytes of the second data signal in the second signal group are all valid. If the second marker signal is 1, it indicates that the bytes of the second data signal in the second signal group are all valid. If the second marker signal is 0, it indicates that the bytes of the second data signal in the second signal group are not all valid. In Figure 4 the illustrated embodiment, the difference between the first data signal and the second data signal is that: the least significant byte and the first invalid byte of the first data signal and the second data signal are different. The least significant byte and the first invalid byte of the first data signal are the original target data, the least significant byte of the second data signal is the first marker signal, and the first invalid byte is the original least significant byte.
[0138] Figure 5 It is a schematic diagram of data compression for the fourth example of the embodiment of the present invention. Figure 5 A first signal group and a corresponding second signal group are shown. Among them, K = 8, the designated byte is the least significant byte, and the target invalid byte is the first invalid byte starting from the low bit. In Figure 5 the first data signal includes eight bytes, and the first marker signal is eight bits. Each bit of the first marker signal corresponds to a byte. InFigure 5 In the illustrated embodiment, the first marker signal is 11011011, that is, not all of the first data signals are valid, and it is determined that the second marker signal is 0. At the same time, there are two invalid bytes in the first data signal. Starting from the least significant bit, the third byte and the sixth byte are invalid bytes. Among them, the third byte is the first invalid byte (i.e., the target invalid byte). Therefore, the first marker signal (11011011) is written into the least significant byte, and at the same time, the original content (10101010) of the least significant byte is written into the first invalid byte. Thus, the second signal group can be obtained. In Figure 5 In the illustrated embodiment, the difference between the first data signal and the second data signal is that: the least significant byte and the first invalid byte of the first data signal and the second data signal are different. The least significant byte and the first invalid byte of the first data signal are the original target data, the least significant byte of the second data signal is the first marker signal, and the first invalid byte is the original least significant byte.
[0139] It should be noted that the above several examples are all described with K equal to 8 and N being an integer multiple of K. When K is not equal to 8 or N is not an integer multiple of K, some of the first data signals of the first signal group have less than eight bytes. When compressing these first signal groups, if all of the first data signals are valid, the second marker signal is 1; otherwise, the second marker signal is 0. When the second marker signal is 0, the first marker signal with less than eight bits needs to be filled to an eight-bit replacement signal, and the processing of the remaining part is similar to the processing of the first signal group in the above examples, which will not be elaborated herein in the embodiments of the present invention.
[0140] Through the above compression method, the bit width of the marker signal can be reduced, specifically as follows:
[0141] When N is greater than or equal to K and N is an integer multiple of K, the bit width of the second marker signal of the compressed signal is reduced to 1 / K of the bit width of the first marker signal of the target signal.
[0142] When N is greater than K and N is not an integer multiple of K, the bit width of the second marker signal of the compressed signal is reduced to about 1 / K of the bit width of the first marker signal of the target signal.
[0143] When N is less than K, the bit width of the second marker signal of the compressed signal is reduced to 1 / N of the bit width of the first marker signal of the target signal.
[0144] In an embodiment of the present invention, a target signal is obtained. Each bit of the first marking signal of the target signal is used to represent the validity of one byte in the first data signal. The target signal is grouped according to a predetermined number of bytes to obtain a first signal group. A second signal group is generated according to the validity of the first data signal in the first signal group. The second signal group includes a second marking signal of one bit and at least one byte of second data signal. A compressed signal is generated according to the second signal group. Thus, compared with the target signal, the generated compressed signal can reduce the bit width of the marking signal, thereby reducing the occupation of line width resources, reducing the complexity of hardware design, and reducing additional hardware overhead.
[0145] Figure 6 It is a flowchart of a data decompression method according to an embodiment of the present invention. Figure 6 The data decompression method shown can be applied to various electronic devices, and specifically includes the following steps:
[0146] Step S201, obtain a compressed signal.
[0147] In this embodiment, the compressed signal is a signal obtained by the compression method of the above steps S101 - S111. The compressed signal includes second data signals of N bytes and a second marking signal of M bits. Each bit of the second marking signal is used to represent the overall validity of one or more bytes in the second data signal. N is a positive integer greater than or equal to 1, and M is a positive integer greater than or equal to 1.
[0148] Step S202, group the compressed signal to obtain a second signal group.
[0149] In this embodiment, the compressed signal is grouped according to a predetermined number of bytes to obtain M second signal groups. Each of the second signal groups includes a second marking signal of one bit and at least one byte of second data signal.
[0150] Among them, the predetermined number of bytes is K, and K is a positive integer greater than or equal to 2 and less than or equal to 8;
[0151] Among them, grouping the compressed signal according to a predetermined number of bytes to obtain M second signal groups includes:
[0152] In response to N being less than or equal to K, the compressed signal is grouped to obtain a second signal group, and the second signal group includes a second marking signal of one bit and N bytes of second data signal.
[0153] In response to N being greater than K and N being an integer multiple of K, the compressed signal is grouped to obtain M second signal groups, and each second signal group includes a second marking signal of one bit and K bytes of second data signal;
[0154] In response to N being greater than K and N not being an integer multiple of K, the compressed signal is grouped to obtain M second signal groups. The first M - 1 second signal groups each include a one - bit second marker signal and K bytes of second data signals, and the Mth second signal group includes a one - bit second marker signal and L bytes of second data signals, where L is a positive integer greater than or equal to 1 and less than K.
[0155] It should be noted that when grouping the compressed signal, it can be in a predetermined order. For example, when N = 64 and K = 8, starting from the lower bit, the 1st - 8th bytes are the first group, the 9th - 16th bytes are the second group, and so on. Among the multiple second signal groups finally obtained, the bytes between the multiple second signal groups are continuous, and the bytes within each second signal group are also continuous.
[0156] Furthermore, after obtaining the multiple second signal groups, each second signal group is processed separately. Steps S203 - S210 provide the processing flow for one second signal group, and the processing flow for each second signal group is the same. This embodiment of the present invention will not be elaborated herein.
[0157] Step S203: Determine whether all the second data signals are valid.
[0158] In this embodiment, the validity of the second data signal is determined according to the second marker signal in the second signal group. In response to the second marker signal being the first value, it is determined that all the second data signals in the second signal group are valid; in response to the second marker signal being the second value, it is determined that not all the second data signals in the second signal group are valid. Here, the first value is 1 and the second value is 0. That is, for a one - bit second marker signal, if it is 0, it means that the bytes in the corresponding second data signal are not all valid, and if it is 1, it means that the bytes in the corresponding second data signal are all valid. Among them, not all valid means partially valid or all invalid.
[0159] Thus, M first signal groups are generated according to the validity of the second data signals in the second signal group. The first signal group includes at least one - bit first marker signal and at least one - byte first data signal.
[0160] Specifically, in response to all the second data signals in the second signal group being valid, the first signal group is determined through steps S204 - S205.
[0161] In response to not all the second data signals in the second signal group being valid, the first signal group is determined through steps S206 - S210.
[0162] Step S204: Determine that the first marker signal is a first value of K bits.
[0163] Step S205: Determine the second data signal as the first data signal.
[0164] In this embodiment, for steps S204 - S205, in response to all the second data signals in the second signal group being valid, determine that the first marker signal is a first value of K bits, and determine the second data signal as the first data signal. Thus, a first signal group can be obtained. Wherein, the first signal group includes a first marker signal and a first data signal, the first marker signal is K bits, and the first data signal is K bytes. Each bit of the first marker signal is used to characterize the validity of the byte at the corresponding position in the first data signal.
[0165] Wherein, the first value is 1. For example, assume K = 8. If the second marker signal in the second signal group is 1, then the first marker signal in the generated first signal group is 11111111.
[0166] It should be noted that the above steps S204 - S205 are applicable to a second signal group including K bytes. However, in some special cases, the number of bytes in some second signal groups is not K. For example, when N is less than K, the number of bytes in the obtained second signal group is N, or when N is greater than K and N is not an integer multiple of K, the number of bytes in the last second signal group is L. At this time, determine that the first marker signal is a first value of the number of bits corresponding to the number of bytes. That is, when N is less than K, the first marker signal is N bits; when N is greater than K and N is not an integer multiple of K, the first marker signal obtained through the last second signal group is L bits. That is, determine that the first marker signal in the first signal group is a first value of N bits or K bits or L bits
[0167] Furthermore, in response to not all the second data signals in the second signal group being valid, generate the first data signal and the first marker signal according to the second data signal. Specifically, as described in the following steps S206 - S210.
[0168] Step S206: Determine the first marker signal according to the specified byte in the second data signal.
[0169] In this embodiment, in response to not all of the second data signals in the second signal group being valid, the first marking signal is determined according to a specified byte in the second data signals, where the specified byte is any byte in the second data signals specified in advance. The specified byte used in the decompression process of this step is the byte at the same position as the specified byte used in the above compression process. For example, assuming that the specified byte in the compression process is the least significant byte, the specified byte in the decompression process is also the least significant byte.
[0170] Wherein, in response to K being equal to 8, N being greater than or equal to K, and N being an integer multiple of K, the specified byte is determined as the first marking signal.
[0171] In response to K being equal to 8, N being greater than K, and N not being an integer multiple of K, the specified byte is determined as the first marking signal in the first M - 1 second signal groups; in the Mth second signal group, L bits of the first marking signal are extracted from the specified byte according to a predetermined extraction method.
[0172] In response to K being equal to 8 and N being less than K, N bits of the first marking signal are extracted from the specified byte according to a predetermined extraction method.
[0173] In response to K being greater than or equal to 2 and less than 8, the corresponding number of bits of the first marking signal are extracted from the specified byte according to a predetermined extraction method.
[0174] Wherein, the predetermined extraction method corresponds to the predetermined complement method in the compression process. For example, assuming that the predetermined complement method is to complement the low bits, the predetermined extraction method is to extract the high bits.
[0175] Step S207: Determine the target invalid byte.
[0176] In this embodiment, the target invalid byte in the second data signals is determined according to a predetermined rule based on the first marking signal.
[0177] Wherein, determining the target invalid byte in the second data signals according to a predetermined rule based on the first marking signal includes one of the following:
[0178] Starting from the low bit of the first marking signal, the first invalid byte in the first data signals is determined according to the first marking signal, and the first invalid byte is determined as the target invalid byte; or
[0179] Starting from the low bit of the first marking signal, the last invalid byte in the first data signals is determined according to the first marking signal, and the last invalid byte is determined as the target invalid byte; or
[0180] Starting from the high bit of the first marking signal, determine the first invalid byte in the first data signal according to the first marking signal, and determine the first invalid byte as the target invalid byte; or
[0181] Starting from the high bit of the first marking signal, determine the last invalid byte in the first data signal according to the first marking signal, and determine the last invalid byte as the target invalid byte.
[0182] It should be noted that the present invention only needs to select one from all the invalid bytes as the target invalid byte according to a predetermined rule, and the present invention does not limit the specific selection method. The four determination methods listed above are only several examples provided by the embodiments of the present invention. In specific practice, any of the above methods can be adopted, or other methods can be adopted. At the same time, the target invalid byte determined in the decompression process should be the byte at the same position as the target invalid byte determined in the compression process.
[0183] For example, assume that the generated eight-bit first marking signal is 10110011, and the method for determining the target invalid byte is: starting from the low bit of the first marking signal, the first invalid byte is the target invalid byte. Then starting from the low bit of the first marking signal means from right to left, and the third bit is 0, that is, the target invalid byte is the third byte starting from the low bit.
[0184] Step S208, determine whether the target invalid byte is a specified byte.
[0185] In this embodiment, detect whether the target invalid byte is a specified byte.
[0186] In response to the target invalid byte not being a specified byte, enter step S209.
[0187] In response to the target invalid byte being a specified byte, enter step S210.
[0188] Step S209, write the content of the target invalid byte in the second data signal into the specified byte.
[0189] As described above, during the compression process, in response to the target invalid byte not being the specified byte, the content of the specified byte in the first data signal is written into the target invalid byte, and the replacement signal generated from the first marker signal is written into the specified byte to obtain the second data signal. Thus, during the decompression process, in response to the target invalid byte not being the specified byte, the content of the target invalid byte in the second data signal is written into the specified byte, and at the same time, the content of the target invalid byte is maintained at its original value, or replaced with any value, or replaced with a predetermined content, to obtain the first data signal. Thus, it can be ensured that the valid bytes of the first data signal obtained after decompression are consistent with those before compression.
[0190] Step S210: Determine the second data signal as the first data signal.
[0191] In this embodiment, in response to the target invalid byte being the specified byte, the second data signal is determined as the first data signal.
[0192] Specifically, during the compression process, in response to the target invalid byte being the specified byte, the specified byte is replaced with the replacement signal generated from the first marker signal, and other bytes remain unchanged. That is to say, during the compression process, except for the specified byte that has changed, other bytes have not changed, and the changed specified byte is an invalid byte. Therefore, the second data signal can be determined as the first data signal.
[0193] It should be noted that in the embodiments of the present invention, the second data signal is directly determined as the first data signal as an example for description. However, since the specified byte is the target invalid byte, the content of the specified byte of the second data signal can also be maintained at its original value, replaced with any value or a predetermined value, and other bytes remain unchanged to obtain the first data signal.
[0194] Step S211: Generate a target signal according to the first signal group.
[0195] In this embodiment, by repeatedly executing the above steps S203 - S210, the first signal group corresponding to each second signal group can be obtained, and a target signal is generated according to the first signal group.
[0196] Specifically, each first signal group is used to splice the first data signal in the same predetermined order as in the compression process to obtain the first data signal corresponding to the target signal, and the first marker signals are spliced to obtain the first marker signal corresponding to the target signal.
[0197] The embodiments of the present invention are described by taking the specified byte as the least significant byte and the target invalid byte as the first invalid byte starting from the low bit as an example. Figures 7 - 10 Four example data decompression methods are shown.
[0198] Figure 7 It is a schematic diagram of data decompression for the first example of the embodiment of the present invention. Figure 7 The decompression shown corresponds to Figure 2 the compression process shown, wherein the second signal group includes a second marker signal and a second data signal. The second marker signal is one bit, and the second data signal is eight bytes. The second marker signal is used to indicate whether the bytes of the second data signal in the second signal group are all valid. At this time, the second marker signal is 1, indicating that the bytes of the second data signal in the second signal group are all valid. Thus, during decompression, a first marker signal of 11111111 is generated, and at the same time, the second data signal is directly used as the first data signal. That is, in Figure 7 the embodiment shown, the first data signal and the second data signal are exactly the same.
[0199] Figure 8 It is a schematic diagram of data decompression for the second example of the embodiment of the present invention. Figure 8 The decompression shown corresponds to Figure 3 the compression process shown, as Figure 8 shown, the second signal group includes a second marker signal and a second data signal. The second marker signal is one bit, and the second data signal is eight bytes. At this time, the second marker signal is 0, indicating that the second data signal is not all valid. Thus, the lowest byte (11111110) of the second data signal is used as the first marker signal. From the first marker signal, it can be seen that the first invalid byte is the lowest byte. Thus, the second data signal is directly used as the first data signal. That is, in Figure 8 the embodiment shown, the first data signal and the second data signal are exactly the same.
[0200] However, referring to Figure 3 and Figure 8 it can be known that the first data signal before compression and the first data signal after decompression are different. Specifically, the lowest byte of the first data signal before compression and the first data signal after decompression are different. However, since the lowest byte is an invalid byte, in this case, the compression and decompression do not lose the information carried by the original data.
[0201] It should be noted that Figure 8 in the embodiment shown, taking the second data signal being directly used as the first data signal as an example for illustration. However, for the lowest byte, since it is an invalid byte, it can be set to any value. It can remain the original 11111110, or can be a predetermined value (such as 00000000, 11111111, etc.), or can be a randomly generated value.
[0202] Figure 9 It is a schematic diagram of data decompression for the third example of the embodiment of the present invention. Figure 9 The decompression shown corresponds to Figure 4 the compression process shown, as Figure 9 shown, the second signal group includes a second marker signal and a second data signal. The second marker signal is one bit, and the second data signal is eight bytes. At this time, the second marker signal is 0, indicating that not all of the second data signal is valid. Thus, the lowest-order byte (11111011) of the second data signal is used as the first marker signal. From the first marker signal, it can be known that the first invalid byte is not the lowest-order byte. Thus, the content (10101010) of the first invalid byte in the second data signal is restored to the lowest-order byte to obtain the first data signal. Among them, the first invalid byte (xxxxxxxx in the figure) of the decompressed first data signal can be any value, can remain the original 10101010 unchanged, can be a predetermined value (such as 00000000, 11111111, etc.), or can be a randomly generated value.
[0203] However, referring to Figure 4 and Figure 9 it can be known that the first data signal before compression and the first data signal after decompression are different. Specifically, the first invalid byte of the first data signal before compression and the first data signal after decompression are different. However, since it is an invalid byte, in this case, the compression and decompression do not lose the information carried by the original data.
[0204] Figure 10 It is a schematic diagram of data decompression for the fourth example of the embodiment of the present invention. Figure 10 The decompression shown corresponds to Figure 5 the compression process shown, as Figure 10As shown, the second signal group includes a second marker signal and a second data signal. The second marker signal is one bit, and the second data signal is eight bytes. At this time, the second marker signal is 0, indicating that not all of the second data signal is valid. Thus, the lowest-order byte (11011011) of the second data signal is used as the first marker signal. From the first marker signal, it can be seen that there are two invalid bytes in the second data signal. The third byte and the sixth byte starting from the low order are invalid bytes. Among them, the first invalid byte is the third byte starting from the low order and is not the lowest-order byte. Thus, the content (10101010) of the first invalid byte in the second data signal is restored to the lowest-order byte to obtain the first data signal. Among them, the first invalid byte (xxxxxxxx in the figure) of the decompressed first data signal can be any value, can remain the original 10101010 unchanged, can be a predetermined value (such as 00000000, 11111111, etc.), or can be a randomly generated value.
[0205] However, referring to Figure 5 and Figure 10 it can be seen that the first data signal before compression and the first data signal after decompression are different. Specifically, the first invalid bytes of the first data signal before compression and the first data signal after decompression are different. However, since it is an invalid byte, in this case, the compression and decompression do not lose the information carried by the original data.
[0206] In an embodiment of the present invention, by obtaining a compressed signal, grouping the compressed signal according to a predetermined number of bytes to obtain M second signal groups, generating M first signal groups according to the validity of the second data signal in the second signal group, and generating a target signal according to the first signal group, each bit of the first marker signal of the target signal is used to characterize the validity of one byte in the first data signal of the target signal. Thus, the valid bytes of the compressed signal can be accurately decompressed without losing the information carried by the original data.
[0207] Figure 11 is a flowchart of a data compression method according to another embodiment of the present invention. As Figure 11 shown, the data compression method according to an embodiment of the present invention includes the following steps:
[0208] Step S310, obtain a target signal, where the target signal includes a first data signal of N bytes and a first marker signal of N bits, and each bit of the first marker signal is used to characterize the validity of one byte in the first data signal, and N is a positive integer greater than or equal to 1.
[0209] Step S320: Group the target signal according to a predetermined number of bytes to obtain M first signal groups, where each first signal group includes a first marker signal of at least one bit and a first data signal of at least one byte, and M is a positive integer greater than or equal to 1.
[0210] Step S330: Generate M second signal groups according to the validity of the first data signal in the first signal group, where the second signal group includes a second marker signal of one bit and a second data signal of at least one byte.
[0211] Step S340: Generate a compressed signal according to the second signal group, where the compressed signal includes a second data signal of N bytes and a second marker signal of M bits, and each bit of the second marker signal is used to characterize the overall validity of one or more bytes in the second data signal.
[0212] In some embodiments, the predetermined number of bytes is K, and K is a positive integer greater than or equal to 2 and less than or equal to 8;
[0213] Among them, grouping the target signal according to a predetermined number of bytes to obtain M first signal groups includes:
[0214] In response to N being less than or equal to K, group the target signal to obtain one first signal group, where the first signal group includes a first marker signal of N bits and a first data signal of N bytes;
[0215] In response to N being greater than K and N being an integer multiple of K, group the target signal to obtain M first signal groups, and each first signal group includes a first marker signal of K bits and a first data signal of K bytes;
[0216] In response to N being greater than K and N not being an integer multiple of K, group the target signal to obtain M first signal groups. The first M - 1 first signal groups include a first marker signal of K bits and a first data signal of K bytes, and the Mth first signal group includes a first marker signal of L bits and a first data signal of L bytes, where L is a positive integer greater than or equal to 1 and less than K.
[0217] In some embodiments, generating M second signal groups according to the validity of the first data signal in the first signal group includes:
[0218] Determine the validity of the first data signal according to the first marker signal in the first signal group;
[0219] In response to all the first data signals in the first signal group being valid, determine the second marker signal as a first value of one bit, and determine the first data signal as the second data signal;
[0220] In response to not all of the first data signals in the first signal group being valid, determine that the second marker signal is a second numerical value of one bit, and generate the second data signal according to the first data signal and the first marker signal.
[0221] In some embodiments, the determining the validity of the first data signal according to the first marker signal in the first signal group includes:
[0222] Convert the first marker signal in the first signal group into a hexadecimal numerical value;
[0223] In response to the hexadecimal numerical value being a predetermined value, determine that all of the first data signals in the first signal group are valid;
[0224] In response to the hexadecimal numerical value not being a predetermined value, determine that not all of the first data signals in the first signal group are valid;
[0225] Wherein, the predetermined value is determined according to the number of bytes of the first data signal in the first signal group.
[0226] In some embodiments, the generating the second data signal according to the first data signal and the first marker signal includes:
[0227] Determine the target invalid byte in the first data signal according to the first marker signal;
[0228] In response to the target invalid byte being a specified byte, generate a replacement signal according to the first marker signal, write the replacement signal into the specified byte, and keep other bytes unchanged to obtain the second data signal;
[0229] In response to the target invalid byte not being a specified byte, write the content of the specified byte into the target invalid byte, generate a replacement signal according to the first marker signal, write the replacement signal into the specified byte, and keep other bytes unchanged to obtain the second data signal;
[0230] Wherein, the specified byte is any byte in the first data signal specified in advance.
[0231] In some embodiments, the specifically determining the target invalid byte in the first data signal according to the first marker signal is:
[0232] Determine the target invalid byte according to the first marker signal according to a predetermined rule.
[0233] In some embodiments, the generating the replacement signal according to the first marker signal includes:
[0234] In response to K being equal to 8, N being greater than or equal to K, and N being an integer multiple of K, determine an eight-bit first marker signal as the replacement signal;
[0235] In response to K being equal to 8, N being greater than K, and N not being an integer multiple of K, determine an eight-bit first marker signal as the replacement signal in the first M - 1 first signal groups; in the Mth first signal group, complete the first marker signal in a predetermined completion manner to obtain an eight-bit replacement signal;
[0236] In response to K being equal to 8 and N being less than K, complete the first marker signal in a predetermined completion manner to obtain an eight-bit replacement signal;
[0237] In response to K being greater than or equal to 2 and less than 8, complete the first marker signal in a predetermined completion manner to obtain an eight-bit replacement signal.
[0238] In some embodiments, the method further includes:
[0239] Transmit the compressed signal.
[0240] In an embodiment of the present invention, by obtaining a target signal, each bit of the first marker signal of the target signal is used to characterize the validity of one byte in the first data signal, grouping the target signal according to a predetermined number of bytes to obtain first signal groups, generating second signal groups according to the validity of the first data signals in the first signal groups, where the second signal groups include a one-bit second marker signal and at least one byte of second data signals, and generating a compressed signal according to the second signal groups. Thus, compared with the target signal, the generated compressed signal can reduce the bit width of the marker signal, thereby reducing the occupation of line width resources, reducing the complexity of hardware design, and reducing additional hardware overhead.
[0241] Figure 12 It is a flowchart of a data decompression method according to another embodiment of the present invention. As Figure 12 shown, the data decompression method according to an embodiment of the present invention includes the following steps:
[0242] Step S410: Obtain a compressed signal, where the compressed signal includes N bytes of second data signals and M bits of second marker signals, and each bit of the second marker signal is used to characterize the overall validity of one or more bytes in the second data signals, N is a positive integer greater than or equal to 1, and M is a positive integer greater than or equal to 1.
[0243] Step S420: Group the compressed signal according to a predetermined number of bytes to obtain M second signal groups, and each of the second signal groups includes a one-bit second marker signal and at least one byte of second data signals.
[0244] Step S430: Generate M first signal groups according to the validity of the second data signals in the second signal group, where each first signal group includes at least one bit of first marker signal and at least one byte of first data signal.
[0245] Step S440: Generate a target signal according to the first signal group, where the target signal includes N bytes of first data signal and N bits of first marker signal, and each bit of the first marker signal is used to characterize the validity of one byte in the first data signal.
[0246] In some embodiments, the predetermined number of bytes is K, and K is a positive integer greater than or equal to 2 and less than or equal to 8;
[0247] Wherein, grouping the compressed signal according to the predetermined number of bytes to obtain M second signal groups includes:
[0248] In response to N being less than or equal to K, group the compressed signal to obtain one second signal group, where the second signal group includes one bit of second marker signal and N bytes of second data signal;
[0249] In response to N being greater than K and N being an integer multiple of K, group the compressed signal to obtain M second signal groups, and each second signal group includes one bit of second marker signal and K bytes of second data signal;
[0250] In response to N being greater than K and N not being an integer multiple of K, group the compressed signal to obtain M second signal groups, where the first M - 1 second signal groups include one bit of second marker signal and K bytes of second data signal, and the Mth second signal group includes one bit of second marker signal and L bytes of second data signal, and L is a positive integer greater than or equal to 1 and less than K.
[0251] In some embodiments, the generating M first signal groups according to the validity of the second data signals in the second signal group includes:
[0252] Determine the validity of the second data signal according to the second marker signal in the second signal group;
[0253] In response to all the second data signals in the second signal group being valid, determine the first marker signal in the first signal group as a first value of N bits or K bits or L bits, and determine the second data signal as the first data signal;
[0254] In response to the second data signals in the second signal group not all being valid, generate the first data signal and the first marker signal according to the second data signal.
[0255] In some embodiments, determining the validity of the second data signal according to the second marker signal in the second signal group includes:
[0256] In response to the second marker signal being a first value, determining that all of the second data signals in the second signal group are valid;
[0257] In response to the second marker signal being a second value, determining that not all of the second data signals in the second signal group are valid.
[0258] In some embodiments, generating the first data signal and the first marker signal according to the second data signal includes:
[0259] Determining the first marker signal according to a specified byte in the second data signal, where the specified byte is any byte in the second data signal specified in advance;
[0260] Determining a target invalid byte in the second data signal according to the first marker signal;
[0261] Generating the first data signal according to the target invalid byte in the second data signal.
[0262] In some embodiments, determining the first marker signal according to the specified byte in the second data signal includes:
[0263] In response to K being equal to 8, N being greater than or equal to K, and N being an integer multiple of K, determining the specified byte as the first marker signal;
[0264] In response to K being equal to 8, N being greater than K, and N not being an integer multiple of K, determining the specified byte as the first marker signal in the first M - 1 second signal groups; in the Mth second signal group, extracting L bits of the first marker signal from the specified byte according to a predetermined extraction method;
[0265] In response to K being equal to 8 and N being less than K, extracting N bits of the first marker signal from the specified byte according to a predetermined extraction method;
[0266] In response to K being greater than or equal to 2 and less than 8, extracting a corresponding number of bits of the first marker signal from the specified byte according to a predetermined extraction method.
[0267] In some embodiments, specifically determining the target invalid byte in the second data signal according to the first marker signal is:
[0268] Determining the target invalid byte in the second data signal according to a predetermined rule according to the first marker signal.
[0269] In some embodiments, generating the first data signal based on the target invalid byte in the second data signal includes:
[0270] In response to the target invalid byte being a specified byte, determining the second data signal as the first data signal;
[0271] In response to the target invalid byte not being a specified byte, writing the content of the target invalid byte in the second data signal into the specified byte to obtain the first data signal.
[0272] In some embodiments, generating the first data signal based on the target invalid byte in the second data signal further includes:
[0273] In response to the target invalid byte being a specified byte, keeping the content of the specified byte unchanged, or replacing it with any value, or replacing it with a predetermined content;
[0274] In response to the target invalid byte not being a specified byte, keeping the content of the target invalid byte unchanged, or replacing it with any value, or replacing it with a predetermined content.
[0275] In the embodiments of the present invention, by obtaining a compressed signal, grouping the compressed signal according to a predetermined number of bytes to obtain M second signal groups, generating M first signal groups according to the validity of the second data signal in the second signal groups, and generating a target signal according to the first signal groups, each bit of the first marker signal of the target signal is used to characterize the validity of one byte in the first data signal of the target signal. Thus, the valid bytes of the compressed signal can be accurately decompressed without losing the information carried by the original data.
[0276] Figure 13 is a schematic diagram of the data compression device according to the embodiments of the present invention. As Figure 13As shown in the figure, the data compression device according to an embodiment of the present invention includes a first acquisition unit 131, a first grouping unit 132, a first generation unit 133, and a first compression unit 134. Among them, the first acquisition unit 131 is configured to acquire a target signal, where the target signal includes a first data signal of N bytes and a first marker signal of N bits, and each bit of the first marker signal is used to represent the validity of one byte in the first data signal, and N is a positive integer greater than or equal to 1. The first grouping unit 132 is configured to group the target signal according to a predetermined number of bytes to obtain M first signal groups, and each of the first signal groups includes at least one bit of the first marker signal and at least one byte of the first data signal, and M is a positive integer greater than or equal to 1. The first generation unit 133 is configured to generate M second signal groups according to the validity of the first data signal in the first signal group, and the second signal groups include a second marker signal of one bit and at least one byte of a second data signal. The first compression unit 134 is configured to generate a compressed signal according to the second signal group, and the compressed signal includes a second data signal of N bytes and M bits of a second marker signal, and each bit of the second marker signal is used to represent the overall validity of one or more bytes in the second data signal.
[0277] In an embodiment of the present invention, by acquiring a target signal, where each bit of the first marker signal of the target signal is used to represent the validity of one byte in the first data signal, grouping the target signal according to a predetermined number of bytes to obtain a first signal group, generating a second signal group according to the validity of the first data signal in the first signal group, where the second signal group includes a second marker signal of one bit and at least one byte of a second data signal, and generating a compressed signal according to the second signal group. Thus, compared with the target signal, the generated compressed signal can reduce the bit width of the marker signal, thereby reducing the occupancy of line width resources, reducing the complexity of hardware design, and reducing additional hardware overhead.
[0278] Figure 14 is a schematic diagram of the data decompression device according to an embodiment of the present invention. As Figure 14As shown in the figure, the data decompression device according to the embodiment of the present invention includes a second acquisition unit 141, a second grouping unit 142, a second generation unit 143, and a second decompression unit 144. Among them, the second acquisition unit 141 is configured to acquire a compression signal, where the compression signal includes a second data signal of N bytes and a second marker signal of M bits, and each bit of the second marker signal is used to characterize the full validity of one or more bytes in the second data signal. N is a positive integer greater than or equal to 1, and M is a positive integer greater than or equal to 1. The second grouping unit 142 is configured to group the compression signal according to a predetermined number of bytes to obtain M second signal groups, and each of the second signal groups includes a second marker signal of one bit and a second data signal of at least one byte. The second generation unit 143 is configured to generate M first signal groups according to the validity of the second data signal in the second signal group, and the first signal group includes a first marker signal of at least one bit and a first data signal of at least one byte. The second decompression unit 144 is configured to generate a target signal according to the first signal group, where the target signal includes a first data signal of N bytes and a first marker signal of N bits, and each bit of the first marker signal is used to characterize the validity of one byte in the first data signal.
[0279] In the embodiment of the present invention, by acquiring a compression signal, grouping the compression signal according to a predetermined number of bytes to obtain M second signal groups, generating M first signal groups according to the validity of the second data signal in the second signal group, and generating a target signal according to the first signal group, each bit of the first marker signal of the target signal is used to characterize the validity of one byte in the first data signal of the target signal. Thus, the valid bytes of the compression signal can be accurately decompressed without losing the information carried by the original data.
[0280] Figure 15 is a schematic diagram of an electronic device according to an embodiment of the present invention. In this embodiment, the electronic device includes a server, a terminal, etc. As Figure 15 shown, the electronic device: includes at least one processor 151; and, a memory 152 communicatively connected to at least one processor 151; and, a communication component 153, and the communication component 153 receives and transmits data under the control of the processor 151; where, the memory 152 stores instructions executable by at least one processor 151, and the instructions are executed by at least one processor 151 to implement the above data compression method and / or data decompression method.
[0281] Specifically, the electronic device includes: one or more processors 151 and a memory 152, Figure 15 where one processor 151 is taken as an example. The processor 151 and the memory 152 can be connected by a bus or other means, Figure 15Take the bus connection as an example. As a non-volatile computer-readable storage medium, the memory 152 can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. By running the non-volatile software programs, instructions, and modules stored in the memory 152, the processor 151 executes various functional applications and data processing of the device, that is, implements the above data compression method and / or data decompression method.
[0282] The memory 152 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store an option list, etc. In addition, the memory 152 may include high-speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 152 includes a memory remotely disposed relative to the processor 151, and these remote memories can be connected to an external device through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0283] One or more modules are stored in the memory 152 and, when executed by one or more processors 151, execute the above data compression method and / or data decompression method.
[0284] The above product can execute the method provided in the embodiment of the present application, has functional modules corresponding to the executed method and beneficial effects. For technical details not described in detail in this embodiment, reference can be made to the method provided in the embodiment of the present application.
[0285] In the compression stage of the embodiment of the present invention, by obtaining a target signal, each bit of the first marker signal of the target signal is used to represent the validity of one byte in the first data signal. The target signal is grouped according to a predetermined number of bytes to obtain M first signal groups. M second signal groups are generated according to the validity of the first data signal in the first signal group. The second signal group includes a one-bit second marker signal and at least one byte of second data signal. A compressed signal is generated according to the second signal group. Thus, compared with the target signal, the generated compressed signal can reduce the bit width of the marker signal, thereby reducing the occupation of line width resources, reducing the complexity of hardware design, and reducing additional hardware overhead. At the same time, in the decompression stage, by obtaining the compressed signal, the compressed signal is grouped according to a predetermined number of bytes to obtain M second signal groups. M first signal groups are generated according to the validity of the second data signal in the second signal group. A target signal is generated according to the first signal group. Each bit of the first marker signal of the target signal is used to represent the validity of one byte in the first data signal of the target signal. Thus, the valid bytes of the compressed signal can be accurately decompressed without losing the information carried by the original data.
[0286] Another embodiment of the present invention relates to a non-volatile storage medium for storing a computer-readable program for a computer to execute the above-mentioned partial or all method embodiments.
[0287] That is, those skilled in the art can understand that all or part of the steps in implementing the above-mentioned embodiment methods can be completed by instructing relevant hardware through a program. The program is stored in a storage medium and includes several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.
[0288] In some embodiments, the electronic device includes a compressor for implementing the above data compression method.
[0289] In some embodiments, the electronic device includes a decompressor for implementing the above data decompression method.
[0290] The embodiment of the present invention also provides A1. A data compression method, the method includes:
[0291] Obtain a target signal, where the target signal includes a first data signal of N bytes and a first marker signal of N bits, and each bit of the first marker signal is used to characterize the validity of one byte in the first data signal, and N is a positive integer greater than or equal to 1;
[0292] Group the target signal according to a predetermined number of bytes to obtain M first signal groups, and each of the first signal groups includes at least one bit of the first marker signal and at least one byte of the first data signal, and M is a positive integer greater than or equal to 1;
[0293] Generate M second signal groups according to the validity of the first data signal in the first signal group, and the second signal group includes a second marker signal of one bit and at least one byte of the second data signal;
[0294] Generate a compressed signal according to the second signal group, where the compressed signal includes a second data signal of N bytes and an M-bit second marker signal, and each bit of the second marker signal is used to characterize the overall validity of one or more bytes in the second data signal.
[0295] A2. The method according to A1, where the predetermined number of bytes is K, and K is a positive integer greater than or equal to 2 and less than or equal to 8;
[0296] Among them, grouping the target signal according to a predetermined number of bytes to obtain M first signal groups includes:
[0297] In response to N being less than or equal to K, group the target signal to obtain one first signal group, and the first signal group includes an N-bit first marker signal and an N-byte first data signal;
[0298] In response to N being greater than K and N being an integer multiple of K, group the target signal to obtain M first signal groups, and each first signal group includes a K-bit first marker signal and a K-byte first data signal;
[0299] In response to N being greater than K and N not being an integer multiple of K, group the target signal to obtain M first signal groups. The first M-1 first signal groups include a K-bit first marker signal and a K-byte first data signal, and the Mth first signal group includes an L-bit first marker signal and an L-byte first data signal, where L is a positive integer greater than or equal to 1 and less than K.
[0300] A3. The method according to A1, where generating M second signal groups according to the validity of the first data signal in the first signal group includes:
[0301] Determine the validity of the first data signal according to the first marking signal in the first signal group;
[0302] In response to all the first data signals in the first signal group being valid, determine that the second marking signal is a first numerical value of one bit, and determine the first data signal as the second data signal;
[0303] In response to not all the first data signals in the first signal group being valid, determine that the second marking signal is a second numerical value of one bit, and generate the second data signal according to the first data signal and the first marking signal.
[0304] A4. The method as described in A3, wherein the determining the validity of the first data signal according to the first marking signal in the first signal group includes:
[0305] Convert the first marking signal in the first signal group into a hexadecimal numerical value;
[0306] In response to the hexadecimal numerical value being a predetermined value, determine that all the first data signals in the first signal group are valid;
[0307] In response to the hexadecimal numerical value not being a predetermined value, determine that not all the first data signals in the first signal group are valid;
[0308] Wherein, the predetermined value is determined according to the number of bytes of the first data signal in the first signal group.
[0309] A5. The method as described in A3, wherein the generating the second data signal according to the first data signal and the first marking signal includes:
[0310] Determine the target invalid byte in the first data signal according to the first marking signal;
[0311] In response to the target invalid byte being a specified byte, generate a replacement signal according to the first marking signal, write the replacement signal into the specified byte, and keep other bytes unchanged to obtain the second data signal;
[0312] In response to the target invalid byte not being a specified byte, write the content of the specified byte into the target invalid byte, generate a replacement signal according to the first marking signal, and write the replacement signal into the specified byte to obtain the second data signal;
[0313] Wherein, the specified byte is any byte in the first data signal specified in advance.
[0314] A6. The method as described in A5, wherein the step of determining the target invalid bytes in the first data signal according to the first marking signal specifically includes:
[0315] Determining the target invalid bytes according to the first marking signal according to a predetermined rule.
[0316] A7. The method as described in A5, wherein the step of generating a replacement signal according to the first marking signal includes:
[0317] In response to K being equal to 8, N being greater than or equal to K, and N being an integer multiple of K, determining an eight-bit first marking signal as the replacement signal;
[0318] In response to K being equal to 8, N being greater than K, and N not being an integer multiple of K, determining an eight-bit first marking signal as the replacement signal in the first M - 1 first signal groups; in the Mth first signal group, complementing the first marking signal according to a predetermined complementing method to obtain an eight-bit replacement signal;
[0319] In response to K being equal to 8 and N being less than K, complementing the first marking signal according to a predetermined complementing method to obtain an eight-bit replacement signal;
[0320] In response to K being greater than or equal to 2 and less than 8, complementing the first marking signal according to a predetermined complementing method to obtain an eight-bit replacement signal.
[0321] A8. The method as described in A1, further comprising:
[0322] Transmitting the compressed signal.
[0323] A9. A data decompression method, the method comprising:
[0324] Obtaining a compressed signal, the compressed signal including an N-byte second data signal and an M-bit second marking signal, each bit of the second marking signal being used to characterize the full validity of one or more bytes in the second data signal, N being a positive integer greater than or equal to 1, and M being a positive integer greater than or equal to 1;
[0325] Grouping the compressed signal according to a predetermined number of bytes to obtain M second signal groups, each of the second signal groups including a one-bit second marking signal and at least one byte of second data signal;
[0326] Generating M first signal groups according to the validity of the second data signal in the second signal group, the first signal group including at least one-bit first marking signal and at least one byte of first data signal;
[0327] Generate a target signal according to the first signal group, where the target signal includes a first data signal of N bytes and a first marker signal of N bits, and each bit of the first marker signal is used to characterize the validity of one byte in the first data signal.
[0328] A10. The method as described in A9, where the predetermined number of bytes is K, and K is a positive integer greater than or equal to 2 and less than or equal to 8;
[0329] Among them, grouping the compressed signal according to the predetermined number of bytes to obtain M second signal groups includes:
[0330] In response to N being less than or equal to K, group the compressed signal to obtain one second signal group, where the second signal group includes a second marker signal of one bit and a second data signal of N bytes;
[0331] In response to N being greater than K and N being an integer multiple of K, group the compressed signal to obtain M second signal groups, and each second signal group includes a second marker signal of one bit and a second data signal of K bytes;
[0332] In response to N being greater than K and N not being an integer multiple of K, group the compressed signal to obtain M second signal groups. The first M - 1 second signal groups include a second marker signal of one bit and a second data signal of K bytes, and the Mth second signal group includes a second marker signal of one bit and a second data signal of L bytes, where L is a positive integer greater than or equal to 1 and less than K.
[0333] A11. The method as described in A9, where generating M first signal groups according to the validity of the second data signal in the second signal group includes:
[0334] Determine the validity of the second data signal according to the second marker signal in the second signal group;
[0335] In response to all the second data signals in the second signal group being valid, determine that the first marker signal in the first signal group is a first value of N bits or K bits or L bits, and determine the second data signal as the first data signal;
[0336] In response to not all the second data signals in the second signal group being valid, generate the first data signal and the first marker signal according to the second data signal.
[0337] A12. The method as described in A11, where determining the validity of the second data signal according to the second marker signal in the second signal group includes:
[0338] In response to the second marking signal being a first value, determine that all second data signals in the second signal group are valid;
[0339] In response to the second marking signal being a second value, determine that not all second data signals in the second signal group are valid.
[0340] A13. The method as described in A11, wherein generating the first data signal and the first marking signal according to the second data signal includes:
[0341] Determine the first marking signal according to a specified byte in the second data signal, where the specified byte is any byte in the second data signal specified in advance;
[0342] Determine the target invalid byte in the second data signal according to the first marking signal;
[0343] Generate the first data signal according to the target invalid byte in the second data signal.
[0344] A14. The method as described in A13, wherein determining the first marking signal according to the specified byte in the second data signal includes:
[0345] In response to K being equal to 8, N being greater than or equal to K, and N being an integer multiple of K, determine the specified byte as the first marking signal;
[0346] In response to K being equal to 8, N being greater than K, and N not being an integer multiple of K, determine the specified byte as the first marking signal in the first M - 1 second signal groups; in the Mth second signal group, extract L bits of the first marking signal from the specified byte according to a predetermined extraction method;
[0347] In response to K being equal to 8 and N being less than K, extract N bits of the first marking signal from the specified byte according to a predetermined extraction method;
[0348] In response to K being greater than or equal to 2 and less than 8, extract a corresponding number of bits of the first marking signal from the specified byte according to a predetermined extraction method.
[0349] A15. The method as described in A13, wherein specifically determining the target invalid byte in the second data signal according to the first marking signal is:
[0350] Determine the target invalid byte in the second data signal according to a predetermined rule according to the first marking signal.
[0351] A16. The method as described in A13, wherein generating the first data signal according to the target invalid byte in the second data signal includes:
[0352] In response to the target invalid byte being a specified byte, determining the second data signal as the first data signal;
[0353] In response to the target invalid byte not being a specified byte, writing the content of the target invalid byte in the second data signal into the specified byte to obtain the first data signal.
[0354] A17. The method according to A13, wherein generating the first data signal according to the target invalid byte in the second data signal further includes:
[0355] In response to the target invalid byte being a specified byte, keeping the content of the specified byte unchanged, or replacing it with any value, or replacing it with a predetermined content;
[0356] In response to the target invalid byte not being a specified byte, keeping the content of the target invalid byte unchanged, or replacing it with any value, or replacing it with a predetermined content.
[0357] A18. A data compression device, the device includes:
[0358] A first acquisition unit, configured to acquire a target signal, the target signal includes a first data signal of N bytes and a first marker signal of N bits, each bit of the first marker signal is used to characterize the validity of one byte in the first data signal, and N is a positive integer greater than or equal to 1;
[0359] A first grouping unit, configured to group the target signal according to a predetermined number of bytes to obtain M first signal groups, each of the first signal groups includes at least one bit of the first marker signal and at least one byte of the first data signal, and M is a positive integer greater than or equal to 1;
[0360] A first generation unit, configured to generate M second signal groups according to the validity of the first data signal in the first signal group, the second signal group includes a second marker signal of one bit and at least one byte of the second data signal;
[0361] A first compression unit, configured to generate a compression signal according to the second signal group, the compression signal includes a second data signal of N bytes and a second marker signal of M bits, each bit of the second marker signal is used to characterize the overall validity of one or more bytes in the second data signal.
[0362] A19. A data decompression device, the device includes:
[0363] A second acquisition unit, configured to acquire a compressed signal, where the compressed signal includes a second data signal of N bytes and a second marker signal of M bits, and each bit of the second marker signal is used to characterize the overall validity of one or more bytes in the second data signal, N is a positive integer greater than or equal to 1, and M is a positive integer greater than or equal to 1;
[0364] A second grouping unit, configured to group the compressed signal according to a predetermined number of bytes to obtain M second signal groups, and each of the second signal groups includes a second marker signal of one bit and a second data signal of at least one byte;
[0365] A second generation unit, configured to generate M first signal groups according to the validity of the second data signal in the second signal group, where the first signal group includes a first marker signal of at least one bit and a first data signal of at least one byte;
[0366] A second decompression unit, configured to generate a target signal according to the first signal group, where the target signal includes a first data signal of N bytes and a first marker signal of N bits, and each bit of the first marker signal is used to characterize the validity of one byte in the first data signal.
[0367] A20. An electronic device, including a memory and a processor, where the memory is configured to store one or more computer program instructions, and wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of A1 - A17.
[0368] The foregoing are only preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, various modifications and changes can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
Claims
1. A data compression method, characterized in that: The method comprises: Acquire a target signal, where the target signal includes a first data signal of N bytes and a first mark signal of N bits, where each bit of the first mark signal is used to indicate the validity of a byte in the first data signal, and N is a positive integer greater than or equal to 1; Grouping the target signal according to a predetermined number of bytes to obtain M first signal groups, each of the first signal groups includes at least one bit of a first mark signal and at least one byte of a first data signal, where M is a positive integer greater than or equal to 1; Generate M second signal groups according to the validity of the first data signal in the first signal group, wherein the second signal group includes a one-bit second flag signal and at least one byte of a second data signal; A compressed signal is generated according to the second signal group, wherein the compressed signal includes N bytes of second data signals and M bits of second mark signals, wherein each bit of the second mark signal is used to characterize the overall validity of one or more bytes in the second data signal.
2. The method according to claim 1, characterized in that The predetermined number of bytes is K, where K is a positive integer greater than or equal to 2 and less than or equal to 8; The step of grouping the target signal according to a predetermined number of bytes to obtain M first signal groups includes: In response to N being less than or equal to K, grouping the target signal to obtain a first signal group, the first signal group including a first flag signal of N bits and a first data signal of N bytes; In response to N being greater than K and N being an integer multiple of K, grouping the target signal to obtain M first signal groups, each first signal group including a first mark signal of K bits and a first data signal of K bytes; In response to N being greater than K and N being not an integer multiple of K, the target signal is grouped to obtain M first signal groups, the first M-1 first signal groups include K-bit first mark signals and K-byte first data signals, the Mth first signal group includes L-bit first mark signals and L-byte first data signals, where L is a positive integer greater than or equal to 1 and less than K.
3. The method according to claim 1, characterized in that Generating M second signal groups according to the validity of the first data signal in the first signal group includes: determining the validity of the first data signal according to a first flag signal in the first signal group; In response to all first data signals in the first signal group being valid, determining the second flag signal to be a first value of one bit, and determining the first data signal to be the second data signal; In response to the fact that not all first data signals in the first signal group are valid, the second flag signal is determined to be a second value of one bit, and the second data signal is generated according to the first data signal and the first flag signal.
4. A data decompression method, characterized in that: The method comprises: Acquire a compressed signal, where the compressed signal includes a second data signal of N bytes and a second mark signal of M bits, where each bit of the second mark signal is used to represent the entire validity of one or more bytes in the second data signal, where N is a positive integer greater than or equal to 1, and M is a positive integer greater than or equal to 1; Grouping the compressed signal according to a predetermined number of bytes to obtain M second signal groups, each of the second signal groups comprising a one-bit second flag signal and at least one byte of a second data signal; Generate M first signal groups according to the validity of the second data signal in the second signal group, wherein the first signal group includes at least one bit of the first flag signal and at least one byte of the first data signal; A target signal is generated according to the first signal group, wherein the target signal includes N bytes of first data signals and N bits of first flag signals, wherein each bit of the first flag signal is used to indicate the validity of a byte in the first data signal.
5. The method according to claim 4, characterized in that The predetermined number of bytes is K, where K is a positive integer greater than or equal to 2 and less than or equal to 8; The step of grouping the compressed signal according to a predetermined number of bytes to obtain M second signal groups comprises: In response to N being less than or equal to K, grouping the compressed signal to obtain a second signal group, wherein the second signal group includes a one-bit second flag signal and N bytes of second data signals; In response to N being greater than K and N being an integer multiple of K, grouping the compressed signal to obtain M second signal groups, each second signal group including a one-bit second flag signal and K bytes of second data signals; In response to N being greater than K and N being not an integer multiple of K, the compressed signal is grouped to obtain M second signal groups, the first M-1 second signal groups include a one-bit second mark signal and K bytes of second data signals, the Mth second signal group includes a one-bit second mark signal and L bytes of second data signals, where L is a positive integer greater than or equal to 1 and less than K.
6. The method according to claim 4, characterized in that Generating M first signal groups according to the validity of the second data signal in the second signal group includes: determining the validity of the second data signal according to a second flag signal in the second signal group; In response to all the second data signals in the second signal group being valid, determining the first mark signal in the first signal group to be a first value of N bits, K bits, or L bits, and determining the second data signal to be the first data signal; In response to not all of the second data signals in the second signal group being valid, the first data signal and the first flag signal are generated according to the second data signal.
7. The method according to claim 6, characterized in that Determining the validity of the second data signal according to the second flag signal in the second signal group includes: In response to the second flag signal being a first value, determining that all second data signals in the second signal group are valid; In response to the second flag signal being a second value, it is determined that not all second data signals in the second signal group are valid.
8. A data compression device, characterized in that: The device comprises: A first acquisition unit, configured to acquire a target signal, wherein the target signal includes a first data signal of N bytes and a first mark signal of N bits, wherein each bit of the first mark signal is used to indicate the validity of a byte in the first data signal, and N is a positive integer greater than or equal to 1; a first grouping unit, configured to group the target signal according to a predetermined number of bytes to obtain M first signal groups, each of the first signal groups including at least one bit of a first mark signal and at least one byte of a first data signal, where M is a positive integer greater than or equal to 1; A first generating unit, configured to generate M second signal groups according to the validity of the first data signal in the first signal group, wherein the second signal group includes a one-bit second flag signal and at least one byte of a second data signal; A first compression unit is used to generate a compressed signal according to the second signal group, wherein the compressed signal includes N bytes of second data signals and M bits of second mark signals, and each bit of the second mark signal is used to characterize the overall validity of one or more bytes in the second data signal.
9. A data decompression device, characterized in that: The device comprises: A second acquisition unit, used to acquire a compressed signal, the compressed signal including a second data signal of N bytes and a second mark signal of M bits, each bit of the second mark signal is used to represent the full validity of one or more bytes in the second data signal, N is a positive integer greater than or equal to 1, and M is a positive integer greater than or equal to 1; a second grouping unit, configured to group the compressed signal according to a predetermined number of bytes to obtain M second signal groups, each of the second signal groups comprising a one-bit second mark signal and at least one byte of a second data signal; A second generating unit, configured to generate M first signal groups according to the validity of the second data signal in the second signal group, wherein the first signal group includes at least one bit of the first mark signal and at least one byte of the first data signal; The second decompression unit is used to generate a target signal according to the first signal group, wherein the target signal includes N bytes of first data signals and N bits of first mark signals, and each bit of the first mark signal is used to indicate the validity of a byte in the first data signal.
10. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1 to 7.