Data compression method and device, data decompression method and device, equipment, storage equipment and vehicle
By acquiring the reference data and calculating the target difference in data transmission, the high cost problem caused by high-frequency transmission is solved, and the rapid compression and decompression of data is achieved, which reduces the working pressure of the transmission channel and reduces the data transmission cost.
Patent Information
- Application Number
- CN202310675336.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-08
- Publication Date
- 2024-12-10
AI Technical Summary
During the data transmission process, high transmission costs and working pressure on the transmission path are caused by high frequency transmission data.
By obtaining the reference data in the data to be compressed, calculating the target difference between the reference data and other data, recording the position where the difference is not 0, and compressing the data length, reference data and position to achieve rapid data compression and decompress.
It reduces the cost of data transmission and reduces the working pressure of the transmission channel. Especially in high-frequency transmission scenarios, the rapid compression and decompression of data are realized. The generated compressed data is in line with sparse arrays and supports the compression and decompression functions of different data.
Smart Images

Figure CN119110343A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data compression and decompression method, device, equipment, storage device and vehicle. Background Art
[0002] In the process of transmitting data between multiple communication terminals, in order to monitor the first device to which the first communication terminal belongs, the first communication terminal needs to periodically send data to the second communication terminal, and the second device to which the second communication terminal belongs analyzes the operation status of the first device by analyzing the data.
[0003] However, if the frequency of monitoring the operation of the first device is high and the data transmission needs to be completed in a short time, for example, Figure 1a In the communication diagram between the vehicle system and the cloud system shown in FIG. 1 , during the operation of the vehicle system, the following Figure 1b The working logic diagram shown in the figure collects system and process information at regular intervals. The cloud system checks the data information reported by the vehicle system, including system load, CPU usage, memory usage, storage partition usage, and network card rate usage over the past period of time. It monitors the data in the vehicle system at regular intervals, and can troubleshoot CPU and memory problems through the reported data, and locate the process information that causes the problem. In order to realize the above data transmission process, there is high-frequency data transmission between the vehicle system and the cloud system, which requires high transmission costs. Summary of the invention
[0004] In view of this, the present application provides a data compression and decompression method, device, equipment, storage device and vehicle, the main purpose of which is to solve the problem of high transmission cost caused by high-frequency data transmission during data transmission, thereby causing greater working pressure on the transmission path.
[0005] To achieve the above object, the present application discloses a data compression method in a first aspect, the method comprising:
[0006] Obtaining benchmark data from the data to be compressed;
[0007] Calculate target differences between the reference data and other data in the data to be compressed except the reference data in sequence;
[0008] recording, in the data to be compressed, positions of the other data whose target difference with the reference data is not 0;
[0009] The length value of the data to be compressed, the reference data, the position of the other data recorded and the target difference value are subjected to data compression.
[0010] Optionally, the position of the other data recorded in the data to be compressed, whose target difference with the reference data is not 0, includes:
[0011] Obtaining data positions corresponding to the target difference values respectively;
[0012] According to the change of the target difference, determining the position of the starting point of the difference change from each of the data positions;
[0013] The position of the starting point of the difference change and the target difference corresponding to the starting point of the difference change are recorded.
[0014] Optionally, before compressing the length value of the data to be compressed, the reference data, the recorded position of the other data, and the target difference, the method further includes:
[0015] Read the compression start marker;
[0016] The step of compressing the length value of the data to be compressed, the reference data, the position of the other data recorded, and the target difference value comprises:
[0017] After reading the compression start mark, filling the length value of the data to be compressed and the reference data into the data to be updated;
[0018] According to the change of the target difference, the position of the starting point of the difference change and the target difference corresponding to the starting point of the difference change are sequentially filled into the data to be updated;
[0019] The data to be updated is compressed to obtain a data compression package.
[0020] Optionally, before compressing the data to be updated to obtain a data compression package, the method further includes:
[0021] Obtain the length value of the data to be updated;
[0022] Compare the length of the data to be updated with the length of the data to be compressed;
[0023] The step of compressing the data to be updated to obtain a data compression package includes:
[0024] If the length of the data to be updated is smaller than the length of the data to be compressed, data compression is performed on the data to be updated to obtain a data compression package.
[0025] A second aspect of the present application discloses a data decompression method, the method comprising:
[0026] Obtain the benchmark data in the data compression package;
[0027] According to the change of the target difference, restoring other data except the benchmark data through the benchmark data, wherein the target difference is the difference between the benchmark data and other data except the benchmark data;
[0028] According to the position of the starting point of the difference change of the target difference, the distribution positions of the reference data and other data except the reference data are restored to obtain a data decompression result.
[0029] Optionally, the restoring the distribution positions of the reference data and other data except the reference data according to the position of the starting point of the difference change of the target difference to obtain the data decompression result includes:
[0030] Acquire the quantity of the other data according to the position of the starting point of the difference change of the target difference;
[0031] By changing the position of the starting point of the difference change of the target difference, the distribution positions of other data of different quantities are restored to obtain the data decompression result.
[0032] Optionally, before obtaining the benchmark data in the data compression package, the method further includes:
[0033] Identify identification data in a data compression packet, wherein the identification data is data in a preset identification position in the compressed data packet;
[0034] Compare the identification data with a preset identification, and determine the type of the data compression package according to the comparison result, wherein the data compression package type includes a new data compression package and an original data package;
[0035] The step of obtaining the reference data in the data compression package includes:
[0036] If it is determined that the data compression package type is a new data compression package, the reference data in the new data compression package is obtained.
[0037] In a third aspect of the present application, an embodiment provides a data compression device, including:
[0038] An acquisition module, used for acquiring reference data from the data to be compressed;
[0039] A calculation module, used for sequentially calculating target differences between the reference data and other data in the data to be compressed except the reference data;
[0040] A recording module, used for recording the position of the other data in the data to be compressed whose target difference with the reference data is not 0;
[0041] The compression module is used to compress the length value of the data to be compressed, the reference data, the position of the other data recorded, and the target difference.
[0042] In a fourth aspect of the present application, an embodiment provides a data decompression device, including:
[0043] An acquisition module, used for acquiring the benchmark data in the data compression package;
[0044] A restoration module is used to restore other data except the benchmark data through the benchmark data according to the change of the target difference, and the target difference is the difference between the benchmark data and the other data except the benchmark data; according to the position of the starting point of the difference change of the target difference, the distribution position of the benchmark data and the other data except the benchmark data is restored to obtain the data decompression result.
[0045] In a fifth aspect of the present application, an electronic device is provided, including:
[0046] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of the methods disclosed in the first aspect and the second aspect.
[0047] In a sixth aspect embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in the first aspect is implemented.
[0048] A seventh embodiment of the present application provides a vehicle, in which the electronic device as described in the fifth embodiment is mounted.
[0049] In summary, according to the technical solution disclosed in the present application, a data compression and decompression method is disclosed. In the data compression stage, the benchmark data is obtained in the data to be compressed; the target difference between the benchmark data and the other data in the data to be compressed except the benchmark data is calculated in sequence; the position of other data in the data to be compressed whose target difference with the benchmark data is not 0 is recorded; the length value of the data to be compressed, the benchmark data, the position of the recorded other data and the target difference are subjected to data compression. In the data decompression stage, the benchmark data in the data compression package is obtained; according to the change of the target difference, the other data except the benchmark data is restored through the benchmark data, and the target difference is the difference between the benchmark data and the other data except the benchmark data; according to the position of the starting point of the difference change of the target difference, the distribution position of the benchmark data and the other data except the benchmark data is restored to obtain the data decompression result. By adopting the technical solution disclosed in the present application, it is possible to achieve rapid compression and decompression of data for a large amount of data with a high degree of repetition. The compressed data conforms to a sparse array, and the compression and decompression functions of different data can be realized, so that the transmission path of the transmission channel can be reduced during the transmission of the compressed data. At the same time, in the scenario of high-frequency transmission, the cost of data transmission can be reduced.
[0050] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0052] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0053] Figure 1a A schematic diagram showing the communication between the vehicle system and the cloud system is shown;
[0054] Figure 1b The working logic diagram of the vehicle-mounted system is shown;
[0055] Figure 2 A flow chart of a data compression method provided by an embodiment of the present application is shown;
[0056] Figure 3A schematic diagram of a data compression process in a first embodiment is shown;
[0057] Figure 4 A schematic diagram of a data compression process in a second embodiment is shown;
[0058] Figure 5 A schematic diagram of a data compression process in a third embodiment is shown;
[0059] Figure 6 A schematic diagram of a data compression process in a fourth embodiment is shown;
[0060] Figure 7 A flow chart of a data decompression method provided by an embodiment of the present application is shown;
[0061] Figure 8 A schematic diagram of a data decompression process in a first embodiment is shown;
[0062] Fig. 9 A schematic diagram of a data decompression process in a second embodiment is shown;
[0063] Fig.10 A schematic diagram of a data decompression process in a third embodiment is shown;
[0064] Fig.11 A schematic diagram of a data decompression process in a fourth embodiment is shown;
[0065] Fig.12 A structural diagram of a data compression device provided in an embodiment of the present application is shown;
[0066] Fig.13 A structural diagram of a data decompression device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0067] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0068] In order to solve the problem of high transmission cost caused by high-frequency data transmission during data transmission, thereby causing great working pressure on the transmission path, the present application provides the following embodiments to solve the above problem:
[0069] This embodiment provides a data compression method, such as Figure 2 FIG. 1 is a flow chart of a data compression method proposed in this embodiment. The method in this embodiment may specifically include the following steps:
[0070] Step 201: Obtain reference data from the data to be compressed.
[0071] After confirming the data to be compressed, the reference data is confirmed from the data to be compressed. There are many ways to determine the reference data. For example,
[0072] 1. The benchmark data may be data with quantitative characteristics in the data to be compressed. For example, the benchmark data may be a maximum value or a minimum value in the data to be compressed, or may be the median of the data to be compressed. Furthermore, the benchmark data may also be the average of all data in the data to be compressed.
[0073] 2. The benchmark data may also be data with quantity characteristics in the data to be compressed. For example, the benchmark data may be the data with the largest or smallest quantity in the data to be compressed.
[0074] 3. The reference data may also be data selected based on the order of data in the data to be compressed. For example, the reference data may be the first or last data in the data to be compressed.
[0075] Step 202, sequentially calculating target differences between the reference data and other data in the data to be compressed except the reference data.
[0076] After determining the benchmark data from the data to be compressed, the present embodiment proposes calculating the difference between the benchmark data and other data, wherein the order of calculating the difference is not specifically limited. For example, the difference between the benchmark data and other data can be calculated in sequence according to the arrangement order of the data to be compressed, and the target difference can be obtained.
[0077] Step 203 , recording the positions of other data in the data to be compressed whose target difference with the reference data is not zero.
[0078] In the process of calculating and obtaining the target difference, the specific positions of other data are recorded according to the result of the target difference. When the target difference is 0, the data to be compressed that is the target difference is the reference data. When the target difference is not 0, the data to be compressed here is different from the reference data. The data to be compressed here is regarded as other data except the reference data, and the positions of other data are recorded.
[0079] Step 204 , compress the length value of the data to be compressed, the reference data, the position of other recorded data and the target difference value.
[0080] After determining the target difference value and the corresponding position corresponding to other data, the value of the other recorded data can be directly calculated through the relationship between the value of the benchmark data and the target difference value, and the position of the data can be directly located through the position of the recorded data. Therefore, the length value of the data to be compressed, the benchmark data, the position of other recorded data and the target difference value are compressed, and the generated data compression package can directly meet the subsequent data positioning after decompression.
[0081] For the technical solution disclosed in this embodiment, an exemplary data compression process is proposed. There is a group of data to be compressed, and the group of data to be compressed has a total of 100 data, among which the first 1 to 60 data are 1, and the data 61 to 100 are 2. At this time, in the process of determining the benchmark data, data 1 is taken as the benchmark data, and in the process of calculating the target difference, the target difference between the benchmark data 1 and the other data 2 is -1, and the position of the other data when the target is -1 is recorded. The length of the data to be compressed is 100, the benchmark data 1, the position of the other data 61 to 75, and the target difference -1 corresponding to the data position are compressed to generate a data compression package for data transmission.
[0082] In the present embodiment, for data with a high degree of repetition, by extracting the reference data and calculating the comparison results between other data in the data to be compressed and the reference data, in the data compression process, the length value of the data to be compressed, the reference data, the position of other recorded data and the target difference are used as the characteristic data of the data compression package for data compression, which can realize the rapid compression of data when there is repeated data redundancy in the data to be compressed, and can reduce the occupied amount of data before compression, reduce the workload in the data compression process, and at the same time, the occupied space of the data compression package generated by this method can also be reduced, reducing the working pressure of the transmission path.
[0083] In a possible embodiment, the positions of other data whose target difference value with the reference data is not 0 and are recorded in the data to be compressed include:
[0084] Obtain the data positions corresponding to the target difference values respectively; determine the position of the starting point of the difference change from each data position according to the change of the target difference value; record the position of the starting point of the difference change and the target difference value corresponding to the starting point of the difference change.
[0085] In the process of obtaining the target difference, the data position corresponding to each target difference is obtained respectively. As the target difference is continuously calculated and generated by the data to be compressed and the reference data, if the value of the current target difference changes compared with the previous target difference, the starting point position where the target difference changes is recorded, and the values of other data corresponding to the changed starting point position are recorded.
[0086] Exemplarily, there are 100 data to be compressed, among which the first 1 to 60 data are 1, the first 61 to 75 data are 2, and the first 76 to 100 data are 3. In the process of obtaining the target difference, when the 61st data is reached, the target difference is -1, and the value of the target difference changes. The 61st data is the starting point of the difference change. The value of the 61st data at this time is recorded as 2, and the target difference is -1. The target difference is continued to be obtained. In the 62nd to 75th data, the target difference is still -1, which has not changed compared to the current target difference. The data and the target difference of 62 to 75 are not recorded. When the 76th data is reached, the target difference is -2, which has changed compared to the current target difference. The 76th data is also the starting point of the difference change. The value of the 76th data at this time is recorded as 3, and the target difference is -2.
[0087] The embodiment of the present application aims at data with a high degree of repetition, and proposes to record only the data corresponding to the different target difference values that appear for the first time for the current target difference value, so as to avoid recording only the value and position corresponding to the first digit of a repeated sequence in the process of maintaining data redundancy. When the positions of the previous and next data are confirmed, the position of the repeated sequence can also be confirmed at the same time. The technical solution of this embodiment further reduces the space occupied by the positions of other data and the numerical values of the target difference values recorded when data compression is performed, and further reduces the space occupied by the data compression package finally generated.
[0088] In a possible embodiment, before compressing the length value of the data to be compressed, the reference data, the position of the other data recorded, and the target difference value, the method further includes: reading a compression start mark;
[0089] The method further comprises: compressing the length value of the data to be compressed, the reference data, the position of the other data recorded, and the target difference value, including:
[0090] After reading the compression start mark, fill the length value of the data to be compressed and the reference data into the data to be updated; according to the change of the target difference, fill the position of the starting point of the difference change and the target difference corresponding to the starting point of the difference change into the data to be updated in turn; compress the data to be updated to obtain a data compression package.
[0091] The technical solution of this embodiment further illustrates the specific arrangement order of the data to be updated before compressing and generating a data data packet. For example, a compression start mark is set in the data to be updated to indicate the start of the compression function. At the same time, the length value and the reference data of the data to be compressed are first filled into the data to be updated, and then, according to the change of the target difference, the position of the target difference and the starting point of the difference change of the target difference are filled into the data to be updated in sequence. After the target difference and the starting point of the difference change of the target difference corresponding to all the data of the data to be compressed are all filled into the data to be updated, the data to be updated is subjected to the data compression function to generate a data compression package.
[0092] For example, there are 100 data to be compressed, among which the first 1 to 60 data are 1, the 61 to 75 data are 2, and the 76 to 100 data are 3. After the compression start mark is added and the data to be updated is generated, the length of the data to be compressed is 100, the reference data is 1, the target difference value -1 is recorded, and the change start point 61 corresponding to the target difference value -1 is recorded, and the change start point 76 corresponding to the target difference value -2 is recorded.
[0093] In a possible embodiment, before compressing the data to be updated to obtain a data compression package, the method further includes:
[0094] Obtain the length value of the data to be updated; compare the length value of the data to be updated with the length value of the data to be compressed;
[0095] Compress the data to be updated to obtain a data compression package, including:
[0096] If the length of the data to be updated is smaller than the length of the data to be compressed, the data to be updated is compressed to obtain a data compression package.
[0097] In the technical solution of this embodiment, it is proposed to compare the length values of the data to be updated and the data to be compressed. This process is to determine the necessity of compressing the data to be updated. The content of this embodiment is to consider that when the data composition of the data to be compressed is relatively complex, the difference interval between different target differences is small, and then the different target differences judged are relatively large. When the sum of the number of data positions corresponding to the different target differences and the target differences is equal to or exceeds the number of data to be compressed, the compression method of the technical solution of this embodiment can be omitted.
[0098] Therefore, the content of this embodiment further illustrates the application scenario of this embodiment, that is, the length of the data to be updated finally generated is smaller than the length of the data to be compressed.
[0099] With respect to the data compression method disclosed in the above embodiment, a specific data compression step flow chart is proposed, which is exemplary as follows: Figure 3 The data compression process diagram of the first embodiment is shown.
[0100] In this embodiment, a new array is constructed to store the data to be updated. First, the compression start mark is filled in, and the original data size and reference data representing the length value of the data to be compressed are filled in after the compressed data. In this embodiment, the first data in the data to be compressed is used as the reference data, and the reference data in the data to be compressed is continuously filled into the new array. The difference between the data to be compressed and the reference data is calculated in sequence to obtain the change of the target difference. If the target difference changes, the change position and the data corresponding to the change position are filled into the new array, and the next data to be compressed is continuously judged until all the data to be compressed are judged and all the data to be updated are generated. The size of the length value of the data to be updated and the length value of the data to be compressed are judged. If the length value of the data to be updated is less than the length value of the data to be compressed, the data to be updated is compressed. If the length value of the data to be updated is greater than the length value of the data to be compressed, the data to be compressed is used as the data to be updated for data compression. The data compression method of this embodiment can realize the function of data compression for data with the same increasing difference between the data to be compressed.
[0101] like Figure 4 A schematic diagram of a data compression process in the second embodiment is shown.
[0102] In this embodiment, a new array is constructed to store the data to be updated. First, the compression start mark and the reference value are filled in. In this embodiment, the data with the most occurrences in the data to be compressed is used as the reference data ( Figure 4 The benchmark data is expressed using a benchmark value), the difference between the data to be compressed and the benchmark data is calculated in sequence, and the change in the target difference is obtained. If the target difference changes, the change position and the data corresponding to the change position are filled into a new array, and the next data to be compressed is judged until all the data to be compressed are judged and all the data to be updated are generated. Calculate whether the size of the final data compression package is better than the result of the slow-changing compression, and judge the length value of the data to be updated and the length value of the data to be compressed. If the size of the final data compression package is better than the result of the slow-changing compression and the length value of the data to be updated is less than the length value of the data to be compressed, then the data to be updated is compressed, otherwise the data to be compressed is compressed as the data to be updated. The data compression method of this embodiment can realize the function of data compression for data with a large amount of repeated equal data between the data to be compressed.
[0103] like Figure 5 A schematic diagram of a data compression process in the third embodiment is shown.
[0104] In this embodiment, a new array is constructed to store the data to be updated. First, the compression start mark is filled in, and the original data size and reference data representing the length value of the data to be compressed are filled in after the compressed data. In this embodiment, the first data in the data to be compressed is used as the reference data, and the reference data in the data to be compressed is continuously filled into the new array. The difference between the data to be compressed and the reference data is calculated in sequence to obtain the change of the target difference. If the target difference changes, the change position and the data corresponding to the change position are filled into the new array, and the next data to be compressed is continuously judged until all the data to be compressed are judged and all the data to be updated are generated. The length value of the data to be updated and the length value of the data to be compressed are judged. If the length value of the data to be updated is less than the length value of the data to be compressed, the data to be updated is compressed. If the length value of the data to be updated is greater than the length value of the data to be compressed, the data to be compressed is used as the data to be updated for data compression. The data compression method of this embodiment can realize the function of data compression for data with slowly changing data between the data to be compressed.
[0105] Figure 6 FIG. 1 is a schematic diagram of a data compression process in a fourth embodiment.
[0106] In this embodiment, a new array is constructed to store the data to be updated. First, the compression start mark is filled in, and the original data size and reference data representing the length value of the data to be compressed are filled in after the compressed data. In this embodiment, the first data in the data to be compressed is used as the reference data, and the reference data in the data to be compressed is continuously filled in the new array. The difference between the data to be compressed and the reference data is calculated in sequence to obtain the change of the target difference. If the target difference changes, the change position and the data corresponding to the change position are filled in the new array, and the next data to be compressed is continuously judged until all the data to be compressed are judged and all the data to be updated are generated. The size of the length value of the data to be updated and the length value of the data to be compressed are judged. If the length value of the data to be updated is less than the length value of the data to be compressed, the data to be updated is compressed. If the length value of the data to be updated is greater than the length value of the data to be compressed, the data to be compressed is used as the data to be updated for data compression. The data compression method of this embodiment can realize the function of data compression for data that has no regularity among the data to be compressed, but the data string length is not much different.
[0107] This embodiment provides a data decompression method, such as Figure 7 FIG. 1 is a flow chart of a data decompression method proposed in this embodiment. The method in this embodiment may specifically include the following steps:
[0108] Step 701, obtaining the reference data in the data compression package.
[0109] After the data compression package is decompressed, the data at the preset position is determined as the reference data.
[0110] Illustratively, in the above data compression embodiment, the second group of data after the compression mark is used as the reference data, and then in the decompression process of the data compression package, the second group of data is used as the reference data packet.
[0111] Step 702, according to the change of the target difference, restore the other data except the benchmark data through the benchmark data, and the target difference is the difference between the benchmark data and the other data except the benchmark data;
[0112] After determining the target difference from the data compression package, the difference change of the target difference is identified, and the quantity value of the other data is restored through the calculation relationship between the target difference, the benchmark data and other data except the benchmark data.
[0113] Step 703, according to the position of the starting point of the difference change of the target difference, the distribution position of the reference data and other data except the reference data is restored to obtain the data decompression result.
[0114] During the data compression process, the target difference and the position of the starting point of the difference change of each target difference are stored respectively. The technical solution of this embodiment is to determine the position of the benchmark data and other data, and when the values of the benchmark data and other data have been determined, the distribution position of the benchmark data and other data is restored to realize data restoration of the data compression package.
[0115] The technical solution of this embodiment proposes a data decompression process, which obtains the values of the original benchmark data and other original data by reading the benchmark data, target difference and the starting point of the target difference difference change stored in the preset position of the data compression package, and restores the positions of the original benchmark data and other original data, thereby realizing the restoration of the original data to be compressed and the decompression of the data compression package.
[0116] In a possible embodiment, according to the position of the starting point of the difference change of the target difference, the distribution position of the reference data and other data except the reference data is restored to obtain the data decompression result, including:
[0117] The quantity of the other data is obtained according to the position of the starting point of the difference change of the target difference; the distribution position of the other data of different quantities is restored by changing the position of the starting point of the difference change of the target difference to obtain the data decompression result.
[0118] The technical solution of this embodiment further explains the restoration of the distribution position of the benchmark data and other data except the benchmark data, that is, relying on the position of the difference change starting point pre-stored in the data compression package, the other data between the two difference change starting points are the same data as the data corresponding to one of the difference change starting points, thereby realizing data restoration of all other data.
[0119] In a possible embodiment, before obtaining the reference data in the data compression package, the method further includes:
[0120] Identify identification data in the data compression package; compare the identification data with a preset identification, and determine the type of the data compression package based on the comparison result, the data compression package type includes a new data compression package and an original data package;
[0121] Get the benchmark data in the data compression package, including:
[0122] If the data compression package type is determined to be a new data compression package, the reference data in the new data compression package is obtained.
[0123] Before decompressing the data compression package, the identification data of the data compression package is identified and compared with the preset identification to determine the type of the data compression package. Exemplarily, the preset identification can be used to indicate the type of data stored in the data compression package, the length of the stored data, the data compression status, etc. For example, when the identification data is -1, it can indicate that the format of the data compression package is wrong or the data is wrong. When the identification data is less than 4 or the identification data is a number greater than 0, the data stored in the data compression package is uncompressed data. The new data compression package is a data packet generated by compressing the data to be updated, and the original data packet is a data packet generated by compressing the data to be compressed. After confirming the type of the data packet, the decompression method of the data packet can be selected in a targeted manner.
[0124] With respect to the data compression method disclosed in the above embodiment, a specific flow chart of data decompression steps is proposed, which is exemplary as follows: Figure 8 The figure shows a schematic diagram of the data decompression process in the first embodiment.
[0125] After obtaining the data compression package, the attributes of the data packet are judged, specifically including the data length and the 0th bit data of the data packet, so as to judge whether the data packet is a compressed data packet. In this embodiment, the data packet with a data length less than 4 and the 0th bit data greater than 0 or an odd data length is judged as a data packet of uncompressed data. At the same time, the data packet with the 0th bit data not being -1 is regarded as a format error data packet, and the data packet is confirmed to contain no data. The expected data length is confirmed from the 1st bit in the data compression package, that is, the length value of the data to be compressed, and the starting data, that is, the reference data, is confirmed from the 2nd bit in the data packet. The first group of target difference values is obtained, and the data and the expected data of each group of target difference values and the reference data are used in sequence to restore the expected data, and the current restored data is continuously compared with the expected data until the target difference values of the data compression package are all calculated. If the current restored data length is less than the expected data, the last group of target difference values is used to generate other data and added to the restored data until the current restored data length is greater than or equal to the expected data length. The data compression method of this embodiment can realize the function of data decompression for data with the same increasing difference between the data to be compressed.
[0126] like Fig. 9 The figure shows a schematic diagram of the data decompression process in the second embodiment.
[0127] After obtaining the data compression package, the attributes of the data packet are judged, specifically including the data length and the 0th bit data of the data packet, so as to judge whether the data packet is a compressed data packet. In this embodiment, the data packet with a data length less than 2 and the 0th bit data greater than 0 or an odd data length is judged as a data packet of uncompressed data. At the same time, the data packet with the 0th bit data not being -2 is regarded as a format error data packet, and the data packet is confirmed to contain no data. The expected data length is confirmed from the 1st bit in the data compression package, that is, the length value of the data to be compressed, and the starting data, that is, the reference data, is confirmed from the 2nd bit in the data packet. The first group of target difference values is obtained, and the data and the expected data of each group of target difference values and the reference data are used in sequence to restore the expected data, and the current restored data is continuously compared with the expected data until the target difference values of the data compression package are all calculated. If the current restored data length is less than the expected data, the last group of target difference values is used to generate other data and added to the restored data until the current restored data length is greater than or equal to the expected data length. The data compression method of this embodiment can realize the function of data decompression for a large number of repeated and equal data between the data to be compressed.
[0128] like Fig.10 The data decompression process diagram of the third embodiment is shown.
[0129] After obtaining the data compression package, the attributes of the data packet are judged, specifically including the data length of the data packet and the 0th bit data, so as to judge whether the data packet is a compressed data packet. In this embodiment, the data packet with a data length less than 2 and the 0th bit data greater than 0 or an odd data length is judged as a data packet of uncompressed data. At the same time, the data packet with the 0th bit data not being -3 is regarded as a format error data packet, and the data packet is confirmed to contain no data. The expected data length is confirmed from the 1st bit in the data compression package, that is, the length value of the data to be compressed, and the starting data, that is, the reference data, is confirmed from the 2nd bit in the data packet. The first group of target difference values is obtained, and the data and the expected data of each group of target difference values and the reference data are used in sequence to restore the expected data, and the current restored data is continuously compared with the expected data until the target difference values of the data compression package are all calculated. If the current restored data length is less than the expected data, the last group of target difference values is used to generate other data and added to the restored data until the current restored data length is greater than or equal to the expected data length. The data compression method of this embodiment can realize the function of data decompression for the existence of slowly changing data between the data to be compressed.
[0130] like Fig.11 The data decompression process diagram of the fourth embodiment is shown.
[0131] After obtaining the data compression package, the attributes of the data packet are judged, specifically including the data length and the 0th bit data of the data packet, so as to judge whether the data packet is a compressed data packet. In this embodiment, the data packet with a data length less than 2 and the 0th bit data greater than 0 or an odd data length is judged as a data packet of uncompressed data. At the same time, the data packet with the 0th bit data not being -4 is regarded as a format error data packet, and the data packet is confirmed to contain no data. The expected data length is confirmed from the 1st bit in the data compression package, that is, the length value of the data to be compressed, and the starting data, that is, the reference data, is confirmed from the 2nd bit in the data packet. The first group of target difference values is obtained, and the data and the expected data of each group of target difference values and the reference data are used in sequence to restore the expected data, and the current restored data is continuously compared with the expected data until the target difference values of the data compression package are all calculated. If the current restored data length is less than the expected data, the last group of target difference values is used to generate other data and added to the restored data until the current restored data length is greater than or equal to the expected data length. The data compression method of this embodiment can realize the function of data decompression for data that has no regularity between the data to be compressed, but the data string length is not much different.
[0132] This embodiment provides a data compression device, such as Fig.12 As shown in FIG. 1 , a data decompression device structure diagram proposed in this embodiment is shown, and the device may specifically include:
[0133] An acquisition module 121, used to acquire reference data from the data to be compressed;
[0134] A calculation module 122, used for sequentially calculating target differences between the reference data and other data in the data to be compressed except the reference data;
[0135] A recording module 123, configured to record, in the data to be compressed, positions of the other data whose target difference with the reference data is not 0;
[0136] The compression module 124 is used to compress the length value of the data to be compressed, the reference data, the position of the other data recorded, and the target difference.
[0137] In a possible embodiment, the recording module 123 is specifically configured to:
[0138] Obtaining data positions corresponding to the target difference values respectively;
[0139] According to the change of the target difference, determining the position of the starting point of the difference change from each of the data positions;
[0140] The position of the starting point of the difference change and the target difference corresponding to the starting point of the difference change are recorded.
[0141] In a possible embodiment, the compression module 124 is specifically configured to:
[0142] After the compression start mark, fill the length value of the data to be compressed and the reference data into the data to be updated;
[0143] According to the change of the target difference, the position of the starting point of the difference change and the target difference corresponding to the starting point of the difference change are sequentially filled into the data to be updated;
[0144] The data to be updated is compressed to obtain a data compression package.
[0145] In a possible embodiment, the compression module 124 is further configured to:
[0146] Obtain the length value of the data to be updated;
[0147] Compare the length of the data to be updated with the length of the data to be compressed;
[0148] The step of compressing the data to be updated to obtain a data compression package includes:
[0149] If the length of the data to be updated is smaller than the length of the data to be compressed, data compression is performed on the data to be updated to obtain a data compression package.
[0150] This embodiment provides a data decompression device, such as Fig.13 As shown in FIG. 1 , a data decompression device structure diagram proposed in this embodiment is shown, and the device may specifically include:
[0151] An acquisition module 131 is used to acquire the reference data in the data compression package;
[0152] The restoration module 132 is used to restore the other data except the benchmark data through the benchmark data according to the change of the target difference, and the target difference is the difference between the benchmark data and the other data except the benchmark data; according to the position of the starting point of the difference change of the target difference, the distribution position of the benchmark data and the other data except the benchmark data is restored to obtain the data decompression result.
[0153] In a possible embodiment, the restoration module 132 is specifically configured to:
[0154] Acquire the quantity of the other data according to the position of the starting point of the difference change of the target difference;
[0155] By changing the position of the starting point of the difference change of the target difference, the distribution positions of other data of different quantities are restored to obtain the data decompression result.
[0156] In a possible embodiment, the acquisition module 131 is further configured to:
[0157] Identify identification data in the data compression package;
[0158] Compare the identification data with a preset identification, and determine the type of the data compression package according to the comparison result, wherein the data compression package type includes a new data compression package and an original data package;
[0159] The step of obtaining the reference data in the data compression package includes:
[0160] If it is determined that the data compression package type is a new data compression package, the reference data in the new data compression package is obtained.
[0161] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0162] Based on the above Figure 2 , Figure 7 The method shown, and Fig.12 , Fig.13 In order to achieve the above-mentioned purpose, the embodiment of the present application further provides an electronic device that can be configured on the vehicle (such as a new energy vehicle) side, and the device includes at least one processor and a memory that is communicatively connected to the at least one processor; the memory is used to store instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor, and the processor is used to execute a computer program to implement the above-mentioned Figure 2 , Figure 7 The method shown.
[0163] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0164] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0165] Based on the above Figure 2 , Figure 7 The method shown, the embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method corresponding to any embodiment is implemented. The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned entity device, and supports the operation of information processing programs and other software and / or programs. The network communication module is used to realize communication between the components inside the storage medium, and communication with other hardware and software in the information processing entity device.
[0166] Based on the above electronic device, the embodiment of the present application further provides a vehicle, which may specifically include: the above electronic device. The vehicle may specifically be a new energy vehicle or a traditional vehicle.
[0167] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0168] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. A data compression method, characterized in that: include: Obtaining benchmark data from the data to be compressed; Calculate target differences between the reference data and other data in the data to be compressed except the reference data in sequence; recording, in the data to be compressed, positions of the other data whose target difference with the reference data is not 0; The length value of the data to be compressed, the reference data, the position of the other data recorded and the target difference value are subjected to data compression.
2. The method according to claim 1, characterized in that The position of the other data recorded in the data to be compressed, whose target difference value with the reference data is not 0, includes: Obtaining data positions corresponding to the target difference values respectively; According to the change of the target difference, determining the position of the starting point of the difference change from each of the data positions; The position of the starting point of the difference change and the target difference corresponding to the starting point of the difference change are recorded.
3. The method according to claim 2, characterized in that Before compressing the length value of the data to be compressed, the reference data, the position of the other data recorded, and the target difference value, the method further includes: Read the compression start marker; The step of compressing the length value of the data to be compressed, the reference data, the position of the other data recorded, and the target difference value comprises: After reading the compression start mark, filling the length value of the data to be compressed and the reference data into the data to be updated; According to the change of the target difference, the position of the starting point of the difference change and the target difference corresponding to the starting point of the difference change are sequentially filled into the data to be updated; The data to be updated is compressed to obtain a data compression package.
4. The method according to claim 3, characterized in that Before compressing the data to be updated to obtain a data compression package, the method further includes: Obtain the length value of the data to be updated; Compare the length of the data to be updated with the length of the data to be compressed; The step of compressing the data to be updated to obtain a data compression package includes: If the length of the data to be updated is smaller than the length of the data to be compressed, data compression is performed on the data to be updated to obtain a data compression package.
5. A data decompression method, characterized in that: include: Obtain the benchmark data in the data compression package; According to the change of the target difference, restoring other data except the benchmark data through the benchmark data, wherein the target difference is the difference between the benchmark data and other data except the benchmark data; According to the position of the starting point of the difference change of the target difference, the distribution positions of the reference data and other data except the reference data are restored to obtain a data decompression result.
6. The method according to claim 5, characterized in that The method of restoring the distribution positions of the reference data and other data except the reference data according to the position of the starting point of the difference change of the target difference to obtain the data decompression result includes: Acquire the quantity of the other data according to the position of the starting point of the difference change of the target difference; By changing the position of the starting point of the difference change of the target difference, the distribution positions of other data of different quantities are restored to obtain the data decompression result.
7. The method according to claim 5, characterized in that: Before obtaining the reference data in the data compression package, the method further includes: Identify identification data in a data compression packet, wherein the identification data is data in a preset identification position in the compressed data packet; Compare the identification data with a preset identification, and determine the type of the data compression package according to the comparison result, wherein the data compression package type includes a new data compression package and an original data package; The step of obtaining the reference data in the data compression package includes: If it is determined that the data compression package type is a new data compression package, the reference data in the new data compression package is obtained.
8. A data compression device, characterized in that: include: An acquisition module, used for acquiring reference data from the data to be compressed; A calculation module, used for sequentially calculating target differences between the reference data and other data in the data to be compressed except the reference data; A recording module, used for recording the position of the other data in the data to be compressed whose target difference with the reference data is not 0; The compression module is used to compress the length value of the data to be compressed, the reference data, the position of the other data recorded, and the target difference.
9. A data decompression device, characterized in that: The method comprises: An acquisition module, used for acquiring the benchmark data in the data compression package; A restoration module is used to restore other data except the benchmark data through the benchmark data according to the change of the target difference, and the target difference is the difference between the benchmark data and the other data except the benchmark data; according to the position of the starting point of the difference change of the target difference, the distribution position of the benchmark data and the other data except the benchmark data is restored to obtain the data decompression result.
10. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
12. A vehicle, characterized in that: The electronic device according to claim 10 is mounted in the vehicle.
Citation Information
Cited By
Data compression method and device, data decompression method and device and electronic equipment
CN119806412A
