A data compression method and a data decompression method

By converting floating-point numbers to integers and calculating the XOR result for grouped storage, the problem of low lossless compression ratio of floating-point numbers is solved, achieving a more efficient data compression effect.

CN119512438BActive Publication Date: 2025-11-04HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311069679.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-22
Publication Date
2025-11-04
Estimated Expiration
2043-08-22

AI Technical Summary

Technical Problem

In existing technologies, the lossless compression rate of floating-point numbers is far lower than that of integers, resulting in higher data storage and transmission costs in IoT scenarios.

Method used

The floating-point number sequence is converted into an integer sequence, and the integers are grouped by calculating the XOR result to generate different stored data to reflect the data fluctuation of the floating-point number, thereby achieving lossless compression.

Benefits of technology

It improves the lossless compression rate of floating-point numbers and performs personalized compression by differentiating different data fluctuations, thereby reducing storage space and transmission costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512438B_ABST
    Figure CN119512438B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a data compression method, which can convert a floating-point number sequence to be compressed into an integer sequence, write a first integer in the integer sequence into a preset storage space, then perform XOR calculation on the integers in the integer sequence to obtain a result sequence; perform result group division on the result sequence to obtain a result group sequence; determine each first type combination and each second type combination in the result group sequence; determine first storage data of each first type combination and second storage data of each second type combination; write the first storage data and the second storage data into the preset storage space; and determine the first integer, the first storage data and the second storage data written in the preset storage space as compressed data of the floating-point number sequence. The data compression method provided by the embodiment of the present application can improve the compression rate of data compression on floating-point numbers.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data compression, in particular to a data compression method and a data decompression method. BACKGROUND

[0002] With the explosive growth of Internet of Things data, how to effectively process such a large and rapidly growing data in the face of the current characteristics of low energy consumption, limited storage resources and insufficient computing resources of Internet of Things devices is a great challenge. Compression technology can be applied to the sensor end and the center end, greatly reducing the data space occupation, reducing the cost of data storage and data transmission, and playing an important role in time sequence scenarios.

[0003] In related technologies, the compression technology of integers is increasingly mature, and in most time sequence scenarios, the compression of integers can achieve a relatively ideal compression rate, while the compression rate of the lossless compression method of floating-point numbers is far from that of integers. Since the data collected by sensors in most Internet of Things scenarios are of floating-point type, optimizing the compression of floating-point numbers is of great value in Internet of Things time sequence scenarios.

[0004] There is an urgent need for a data compression method to improve the compression rate of lossless compression of floating-point numbers. SUMMARY

[0005] The purpose of the embodiments of the present application is to provide a data compression method and a data decompression method to improve the compression rate of lossless compression of floating-point numbers. The specific technical solutions are as follows:

[0006] In a first aspect, the embodiments of the present application provide a data compression method, which comprises:

[0007] Converting a plurality of floating-point numbers in a floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and writing a first integer in the integer sequence into a preset storage space;

[0008] Starting from a second integer in the integer sequence, calculating the exclusive OR result of each integer and the previous integer of the integer to obtain a result sequence, and starting from a first exclusive OR result in the result sequence, grouping the result sequence according to a preset number to obtain a result group sequence;

[0009] Determining a first type combination and a second type combination in the result group sequence; wherein the first type combination is a plurality of result groups including only 0 and being continuous, or a result group including only 0 and adjacent result groups including an exclusive OR result other than 0, and the second type combination is a result group including an exclusive OR result other than 0;

[0010] generate first storage data about the first type of combination according to the number of result groups in each first type of combination, and generate second storage data about the second type of combination according to the XOR result in each second type of combination;

[0011] write the generated first storage data and second storage data into the preset storage space in sequence from the next storage location of the storage location of the first integer in the preset storage space according to the arrangement order of the result groups in each first type of combination and each second type of combination in the result group sequence;

[0012] determine the first integer, the first storage data and the second storage data written in the preset storage space as compressed data of the floating point number sequence.

[0013] Optionally, in a specific implementation, the determining the first type of combination and the second type of combination in the result group sequence comprises:

[0014] traverse each result group in sequence according to the arrangement order of the result groups in the result group sequence, and determine whether each XOR result included in the result group is 0 when traversing each result group;

[0015] if yes, traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not divided into any combination and includes each XOR result that is 0 as the first type of combination;

[0016] if no, determine the result group as the second type of combination.

[0017] Optionally, in a specific implementation, the generating first storage data about the first type of combination according to the number of result groups in each first type of combination, and generating second storage data about the second type of combination according to the XOR result in each second type of combination comprises:

[0018] generate storage data including preset first identification information, a first byte number and the first number of result groups in the first type of combination as the first storage data about the first type of combination when each first type of combination is determined; wherein the first byte number is used to represent the byte number occupied by the first number when the first number is stored;

[0019] generate second storage data about the second type of combination according to the distribution of 0 in each XOR result in the second type of combination when each second type of combination is determined.

[0020] Optionally, in an implementation form, the generating the second storage data about the second type of combination according to the distribution of the 0 in each of the XOR results of the second type of combination comprises:

[0021] generating the first information or the second information about the second type of combination as the second storage data about the second type of combination according to the distribution of the 0 in each of the XOR results of the second type of combination;

[0022] The first information comprises preset second identification information, common valid bit quantity, common low bit 0 quantity and valid bit information; and the second information comprises preset third identification information, common high bit 0 quantity and data information.

[0023] The common low bit 0 quantity is used to represent the minimum quantity of bit positions or the minimum quantity of complete bytes occupied by the low bit 0 of each XOR result of the second type of combination; and the low bit 0 of each XOR result is the 0 before the first non-0 number in the order from the lowest bit to the highest bit.

[0024] The common valid bit quantity is used to represent the maximum value of the quantity of valid bits in each XOR result of the second type of combination; and the valid bit of each XOR result is the bit position occupied by the first non-0 number to the last non-0 number in the order from the highest bit to the lowest bit among the bit positions occupied by each XOR result.

[0025] The common high bit 0 quantity is used to represent the minimum quantity of bit positions or the minimum quantity of complete bytes occupied by the high bit 0 of each XOR result of the second type of combination; and the high bit 0 of each XOR result is the 0 before the first non-0 number in the order from the highest bit to the lowest bit.

[0026] The valid bit information is the value of the common valid bit of each XOR result of the second type of combination arranged according to the arrangement information of each XOR result of the second type of combination; and the common valid bit of each XOR result is the remaining bit position after removing the common high bit 0 quantity of bit positions and removing the common low bit 0 quantity of bit positions in the order from the lowest bit to the highest bit among the bit positions occupied by each XOR result in the order from the highest bit to the lowest bit.

[0027] The data information includes: target information of each XOR result in the second type of combination arranged according to arrangement information of the XOR result; for each XOR result in the second type of combination, if the XOR result is 0, the target information of the XOR result is a first value, if the XOR result is not 0, the target information of the XOR result includes: a second value, and values of bit positions left after removing the common high-bit 0 quantity bit positions in the XOR result in order from the highest bit to the lowest bit.

[0028] Optionally, in an implementation, the generating the first information or the second information about the second type of combination as the second storage data about the second type of combination includes:

[0029] If the number of XOR results of 0 included in the second type of combination is less than a specified number, the first information about the second type of combination is generated as the second storage data about the second type of combination.

[0030] If the number of XOR results of 0 included in the second type of combination is not less than the specified number, the second information about the second type of combination is generated as the second storage data about the second type of combination.

[0031] Or,

[0032] The first data amount of the first information about the second type of combination and the second data amount of the second information about the second type of combination are determined.

[0033] If the first data amount is less than the second data amount, the first information about the second type of combination is generated as the second storage data about the second type of combination.

[0034] If the first data amount is not less than the second data amount, the second information about the second type of combination is generated as the second storage data about the second type of combination.

[0035] Optionally, in an implementation, the sequentially writing the generated each first storage data and each second storage data into the preset storage space from the next storage position of the storage position of the first integer in the preset storage space according to the arrangement order of the result group in the result group sequence in each first type of combination and each second type of combination includes:

[0036] The first storage data or the second storage data is sequentially written into the preset storage space from the next storage position of the storage position of the first integer in the preset storage space after the first storage data or the second storage data is generated.

[0037] Optionally, in an implementation form, the writing, in the preset storage space, the first integer in the integer sequence comprises:

[0038] writing, in the preset storage space, the first integer in the integer sequence and a target number of integers in the integer sequence in sequence;

[0039] the writing, in the preset storage space, the generated first storage data and the generated second storage data in sequence from a next storage location of a storage location where the first integer is located in the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence comprises:

[0040] the writing, in the preset storage space, the generated first storage data and the generated second storage data in sequence from a next storage location of a storage location where the target number is located in the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence;

[0041] the determining, as the compressed data of the floating-point number sequence, the first integer, the first storage data and the second storage data written in the preset storage space comprises:

[0042] the determining, as the compressed data of the floating-point number sequence, the first integer, the target number, the first storage data and the second storage data written in the preset storage space.

[0043] Optionally, in an implementation form, before the converting, into integers, the plurality of floating-point numbers in the floating-point number sequence to be compressed to obtain the integer sequence, the method further comprises:

[0044] adding a preset floating-point number after a last floating-point number in the floating-point number sequence to be compressed; wherein the preset floating-point number is different from each floating-point number in the floating-point number sequence to be compressed;

[0045] the converting, into integers, the plurality of floating-point numbers in the floating-point number sequence to be compressed to obtain the integer sequence comprises:

[0046] the converting, into integers, the plurality of floating-point numbers in the floating-point number sequence to which the preset floating-point number is added to obtain the integer sequence.

[0047] Optionally, in an implementation form, the method further comprises:

[0048] compressing, by using a preset compression method, the compressed data of the floating-point number sequence to obtain target compressed data.

[0049] Optionally, in an implementation form, the sequence of floating-point numbers is a sequence of multimedia data; and the multimedia data comprises at least one of video data, audio data and image data.

[0050] In a second aspect, an embodiment of the present application provides a data decompression method, the method comprising:

[0051] obtaining to-be-decompressed data, and reading a first integer in the to-be-decompressed data; wherein the to-be-decompressed data is obtained by the data compression method described above;

[0052] reading each stored data in the to-be-decompressed data in turn according to the arrangement order of the stored data in the to-be-decompressed data;

[0053] when each stored data is read, parsing the stored data according to the data content of the stored data to obtain an exclusive-OR result corresponding to the stored data;

[0054] performing exclusive-OR calculation on each exclusive-OR result and the last obtained integer according to the order in which the exclusive-OR results are obtained, to obtain a target integer corresponding to the exclusive-OR result;

[0055] converting each obtained integer into a floating-point number, and writing each floating-point number corresponding to each integer into a sequence of floating-point numbers according to the order in which the integers are obtained, to obtain decompressed data corresponding to the to-be-decompressed data.

[0056] In a third aspect, an embodiment of the present application provides a data compression device, the device comprising:

[0057] a data conversion module, configured to convert a plurality of floating-point numbers in a to-be-compressed sequence of floating-point numbers into integers respectively to obtain a sequence of integers, and write a first integer in the sequence of integers into a preset storage space;

[0058] a result calculation module, configured to calculate an exclusive-OR result of each integer and a previous integer of the integer from a second integer in the sequence of integers, to obtain a sequence of results, and group the sequence of results according to a preset number from a first exclusive-OR result in the sequence of results, to obtain a sequence of result groups;

[0059] a combination determination module, configured to determine a first type of combination and a second type of combination in the sequence of result groups; wherein the first type of combination is a plurality of result groups including only 0 and being continuous, or a result group including only 0 and adjacent result groups including a non-0 exclusive-OR result, and the second type of combination is a result group including a non-0 exclusive-OR result;

[0060] The data generation module is configured to generate first storage data about each first type of combination according to the number of result groups in the combination, and generate second storage data about each second type of combination according to the XOR result in the combination.

[0061] The data writing module is configured to sequentially write the generated first storage data and second storage data into the preset storage space according to the arrangement order of the result groups in the result group sequence in each first type of combination and each second type of combination, starting from the next storage location of the storage location where the first integer is located in the preset storage space.

[0062] The data determination module is configured to determine the first integer, the first storage data and the second storage data written in the preset storage space as the compressed data of the floating point number sequence.

[0063] Optionally, in an implementation mode, the combination determination module is specifically configured to:

[0064] arrange the result groups in the result group sequence in order, and determine each result group as a first type of combination when the result group includes all 0s, or as a second type of combination when the result group includes at least one non-0 XOR result.

[0065] If yes, the next result group is traversed until a result group including all 0s is found, and the result group is determined as a first type of combination.

[0066] If no, the result group is determined as a second type of combination.

[0067] Optionally, in an implementation mode, the data generation module comprises:

[0068] The first generation submodule is configured to generate, as the first storage data about each first type of combination, storage data including preset first identification information, a first number of result groups in the first type of combination and a first byte number when the first number of result groups is stored.

[0069] The second generation submodule is configured to generate, as the second storage data about each second type of combination, storage data according to the distribution of 0s in each XOR result in the second type of combination.

[0070] Optionally, in an implementation mode, the second generation submodule is specifically configured to:

[0071] Based on the distribution of 0 in each XOR result of the second type of combination, generate first information or second information about the second type of combination as second stored data about the second type of combination;

[0072] The first information includes: preset second identification information, number of common valid bits, number of common low-order zeros, and valid bit information; the second information includes: preset third identification information, number of common high-order zeros, and data information.

[0073] The number of common low-order zeros is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the low-order zeros of each XOR result in the second type of combination; the low-order zeros of each XOR result are: the zeros before the first non-zero number in the order from the least significant bit to the most significant bit.

[0074] The number of common valid bits is used to represent the maximum number of valid bits in each XOR result of the second type of combination. The valid bits of each XOR result are the bits occupied by each XOR result in the order from the highest bit to the lowest bit, from the first non-zero number to the last non-zero number.

[0075] The number of common high-order zeros is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the high-order zeros of each XOR result in the second type of combination; the high-order zeros of each XOR result are: the zeros before the first non-zero number in the order from the highest bit to the lowest bit;

[0076] The effective bit information is: the value of the common effective bit of each XOR result in the second type of combination, arranged according to the arrangement information of each XOR result in the second type of combination; the common effective bit of each XOR result is: the bits remaining after removing the number of common high-order 0 bits in the bit bits occupied by each XOR result in the order from the highest bit to the lowest bit, and removing the number of common low-order 0 bits in the order from the lowest bit to the highest bit;

[0077] The data information includes: target information of each XOR result in the second type of combination, arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, the target information of the XOR result is a first value; if the XOR result is not 0, the target information of the XOR result includes: a second value, and the value of the remaining bits after removing the number of common high-order 0 bits in the XOR result in the order from the highest bit to the lowest bit;

[0078] Optionally, in an implementation form, the second generating sub-module is specifically configured to:

[0079] If the number of XOR results of 0 included in the second type of combination is less than the specified number, generate the first information about the second type of combination as the second storage data about the second type of combination;

[0080] If the number of XOR results of 0 included in the second type of combination is not less than the specified number, generate the second information about the second type of combination as the second storage data about the second type of combination;

[0081] Or,

[0082] Determine a first data amount of the first information about the second type of combination and a second data amount of the second information about the second type of combination;

[0083] If the first data amount is less than the second data amount, generate the first information about the second type of combination as the second storage data about the second type of combination;

[0084] If the first data amount is not less than the second data amount, generate the second information about the second type of combination as the second storage data about the second type of combination;

[0085] Optionally, in an implementation form, the data writing module is specifically configured to:

[0086] From a next storage location of the storage location where the first integer is located in the preset storage space, sequentially write the first storage data or the second storage data into the preset storage space after generating each first storage data or second storage data;

[0087] Optionally, in an implementation form, the data converting module is specifically configured to:

[0088] In the preset storage space, sequentially write the first integer in the integer sequence and the target number of integers in the integer sequence;

[0089] The data writing module is specifically configured to:

[0090] From a next storage location of the storage location where the target number is located in the preset storage space, sequentially write the generated each first storage data and each second storage data into the preset storage space according to the arrangement order of the result groups in each first type of combination and each second type of combination in the result group sequence;

[0091] The data determining module is specifically configured to:

[0092] The first integer, the target number, each first storage data and each second storage data written in the preset storage space are determined as compression data of the floating-point number sequence;

[0093] Optionally, in a specific implementation, the apparatus further includes:

[0094] a floating-point number adding module, configured to add a preset floating-point number after a last floating-point number sequence in the floating-point number sequence to be compressed; wherein the preset floating-point number is different from each floating-point number in the floating-point number sequence to be compressed;

[0095] The data conversion module is specifically configured to:

[0096] convert the plurality of floating-point numbers in the floating-point number sequence to which the preset floating-point number is added into integers respectively to obtain an integer sequence;

[0097] Optionally, in a specific implementation, the apparatus further includes:

[0098] a data compression module, configured to compress the compression data of the floating-point number sequence by using a preset compression method to obtain target compression data.

[0099] Optionally, in a specific implementation, the floating-point number sequence is a multimedia data sequence; and the multimedia data includes at least one of video data, audio data and image data.

[0100] In a fourth aspect, an embodiment of the present application provides a data decompression apparatus, and the apparatus includes:

[0101] a decompression data obtaining module, configured to obtain to-be-decompressed data and read a first integer in the to-be-decompressed data; wherein the to-be-decompressed data is obtained by using any of the data compression methods described above;

[0102] a data reading module, configured to read each storage data in the to-be-decompressed data in turn according to an arrangement order of the storage data in the to-be-decompressed data;

[0103] a data analyzing module, configured to analyze each storage data according to data content of the storage data when the storage data is read to obtain an exclusive-OR result corresponding to the storage data;

[0104] an exclusive-OR calculating module, configured to perform exclusive-OR calculation on each exclusive-OR result and a last obtained integer according to an order in which the exclusive-OR results are obtained to obtain a target integer corresponding to the exclusive-OR result;

[0105] The floating-point conversion module is configured to convert each of the obtained integers into a floating-point number, and write each floating-point number corresponding to each integer into a floating-point number sequence according to the order in which each integer is obtained, to obtain decompressed data corresponding to the to-be-decompressed data.

[0106] In a fifth aspect, an electronic device is provided, and the electronic device comprises:

[0107] a memory configured to store a computer program;

[0108] a processor configured to execute the computer program stored in the memory, so as to implement the data compression method and / or the data decompression method.

[0109] In a sixth aspect, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the data compression method and / or the data decompression method.

[0110] The embodiments of the present application also provide a computer program product comprising instructions which, when executed on a computer, cause the computer to carry out the data compression method and / or the data decompression method.

[0111] The embodiments of the present application have the following beneficial effects:

[0112] Based on this, the data compression method provided in the embodiment of the present application can improve the compression rate of lossless compression of floating point numbers.

[0113] That is to say, in the embodiment of the present application, different data fluctuation conditions can correspond to different data compression modes, and since lossless compression of floating point data can be realized in the compression process of floating point data in the embodiment of the present application, the data compression method provided in the embodiment of the present application can improve the compression rate of lossless compression of floating point numbers. BRIEF DESCRIPTION OF DRAWINGS

[0114] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other embodiments can also be obtained by those skilled in the art according to these drawings.

[0115] Figure 1 A flowchart of the data compression method provided in the embodiment of the present application;

[0116] Figure 2 A data structure diagram provided in the embodiment of the present application;

[0117] Figure 3Another flowchart of a data compression method provided by the embodiment of the present application;

[0118] Figure 4 A data storage structure diagram provided by the embodiment of the present application;

[0119] Fig. 5(a) is a data structure diagram provided by the embodiment of the present application;

[0120] Fig. 5(b) is another data storage structure diagram provided by the embodiment of the present application;

[0121] Fig. 5(c) is still another data storage structure diagram provided by the embodiment of the present application;

[0122] Figure 6 A flowchart of a data decompression method provided by the embodiment of the present application;

[0123] Figure 7 Another flowchart of a data compression method provided by the embodiment of the present application;

[0124] Figure 8 Another flowchart of a data decompression method provided by the embodiment of the present application;

[0125] Fig. 9(a)-(c) are respectively a data compression effect diagram provided by the embodiment of the present application;

[0126] Figure 10 A data compression device structure diagram provided by the embodiment of the present application;

[0127] Figure 11 A data decompression device structure diagram provided by the embodiment of the present application;

[0128] Figure 12 A structure diagram of an electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION

[0129] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art based on the present application belong to the scope of protection of the present application.

[0130] In the related art, the compression technology of integers is increasingly mature. In most timing scenarios, the compression of integers can achieve a relatively ideal compression rate, while the compression rate of the lossless compression method of floating-point numbers is far less than that of integers. Since in most Internet of Things scenarios, the data collected by sensors are of floating-point number type, optimizing the compression of floating-point numbers has important value in the Internet of Things timing scenarios.

[0131] There is an urgent need for a data compression method to improve the compression rate of the lossless compression of floating-point numbers.

[0132] To solve the above problems, the embodiments of the present application provide a data compression method.

[0133] The method can be applied to various scenarios of data compression of floating-point numbers, for example, scenarios in which a device compresses the floating-point number sequence generated by itself, scenarios in which a device compresses the floating-point number sequence received by itself, and the like. The embodiments of the present application do not limit the specific application scenarios.

[0134] In addition, the execution subject of the embodiments of the present application can be various electronic devices that can perform data processing, such as sensors, mobile phones, notebook computers, desktop computers, various Internet of Things devices, and the like. The electronic device can be a standalone electronic device or a device cluster composed of multiple electronic devices. The embodiments of the present application do not limit the specific application scenarios, and the electronic device is referred to as an electronic device hereinafter.

[0135] Optionally, the sensor with data processing function can include at least one of various sensors such as image sensors, infrared sensors, microphones, light-sensitive sensors, sound-sensitive sensors, and pressure-sensitive sensors. The processor in the electronic device can convert the data collected by the sensor into floating-point numbers to generate a floating-point number sequence, thereby compressing the floating-point number sequence generated by itself, and then storing the compressed data in the memory.

[0136] The data compression method provided by the embodiments of the present application can include the following steps:

[0137] The plurality of floating-point numbers in the floating-point number sequence to be compressed are respectively converted into integers to obtain an integer sequence, and the first integer in the integer sequence is written in a preset storage space;

[0138] Starting from the second integer in the integer sequence, the exclusive OR result of each integer and the previous integer of the integer is calculated to obtain a result sequence, and starting from the first exclusive OR result in the result sequence, the result sequence is grouped according to a preset number to obtain a result group sequence;

[0139] determining a first type combination and a second type combination in the result group sequence; wherein the first type combination is: a plurality of result groups including all 0 XOR results and being continuous, or one result group including all 0 XOR results and adjacent result groups all including a non-0 XOR result, and the second type combination is one result group including a non-0 XOR result;

[0140] generating first storage data about each first type combination according to the number of result groups in the first type combination, and generating second storage data about each second type combination according to the XOR result in the second type combination;

[0141] writing the generated first storage data and second storage data in the preset storage space in sequence from the next storage location of the storage location where the first integer is located in the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence;

[0142] determining the first integer, the first storage data and the second storage data written in the preset storage space as compressed data of the floating point number sequence.

[0143] Therefore, by applying the data compression method provided in the embodiments of the present application, since the integer sequence is determined based on the floating point number sequence to be compressed, and the result sequence is determined by calculating the XOR result of each integer and the previous integer of the integer from the second integer in the integer sequence, if the floating point number sequence has no data fluctuation, that is, each floating point number in the floating point number sequence is the same, each integer in the integer sequence is the same, and each XOR result in the result sequence is 0. It can be seen that each XOR result in the result sequence can reflect the data fluctuation of the floating point number sequence. Furthermore, for each result group, if the XOR results included in the result group are all 0, it indicates that the floating point numbers corresponding to each XOR result in the result group have no data fluctuation; if the result group includes a non-0 XOR result, it indicates that the floating point numbers corresponding to each XOR result in the result group have data fluctuation. Since in the data compression method provided in the embodiments of the present application, the first type combination is: a plurality of result groups including all 0 XOR results and being continuous, or one result group including all 0 XOR results and adjacent result groups all including a non-0 XOR result, and the second type combination is one result group including a non-0 XOR result; the first storage data of each first type combination is generated according to the number of result groups in the first type combination; and the second storage data of each second type combination is generated according to the XOR result in the second type combination; therefore, the embodiments of the present application can determine the storage data of each result group according to the data fluctuation of the floating point numbers corresponding to each XOR result included in each result group in the result group sequence.

[0144] That is to say, in the embodiment of the present application, different data fluctuation conditions can correspond to different data compression modes, and since in the embodiment of the present application, lossless compression of floating-point data can be realized in the compression process of floating-point data, therefore, application of the data compression method provided by the embodiment of the present application can improve the compression rate of lossless compression of floating-point numbers.

[0145] Next, a data compression method provided by the embodiment of the present application is described in detail in combination with the drawings.

[0146] Figure 1 A flowchart of the data compression method provided by the embodiment of the present application is shown in FIG. 1, which can include the following steps S101-S106. Figure 1

[0147] S101: converting a plurality of floating-point numbers in a floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and writing a first integer in the integer sequence into a preset storage space.

[0148] In the compression of the floating-point number sequence to be compressed, a plurality of floating-point numbers in the floating-point number sequence to be compressed can be converted into integers respectively to obtain an integer sequence, and a first integer in the integer sequence can be written into a preset storage space.

[0149] The arrangement order of each integer obtained by converting each floating-point number into an integer in the integer sequence is the same as the arrangement order of each floating-point number in the floating-point number sequence to be compressed.

[0150] Optionally, in a specific implementation, the plurality of floating-point numbers in the floating-point number sequence to be compressed can be converted into integers respectively by IEEE745 standard.

[0151] For example, after conversion of a 64-bit floating-point number into an integer representation by IEEE745 standard, the format of the obtained integer can be as shown in FIG. 2. Figure 2 As can be seen, the integer obtained after conversion of the 64-bit floating-point number into an integer representation can include a sign bit, an exponent bit and a mantissa bit, and the sign bit can occupy 1 bit (1 bit), the exponent bit can occupy 11 bits (11 bits), and the mantissa bit can occupy 52 bits (52 bits).

[0152] For example, after conversion of the floating-point number 15.5 into an integer by IEEE745 standard, the obtained integer is 0x402f000000000000.

[0153] ​Optionally, in some specific implementations, the sequence of floating-point numbers is a sequence of multimedia data, and the multimedia data includes at least one of video data, audio data and image data. In the field of multimedia technology, when compressing data of types such as video data, audio data and image data, the data compression method provided in the application can improve the data compression rate. When transmitting or storing data of types such as video data, audio data and image data, the data is compressed by using the data compression method provided in the application first, which can improve the data transmission efficiency and save storage space.

[0154] Of course, in the embodiments of the application, the specific data type of each floating-point number in the sequence of floating-point numbers is not limited, for example, each floating-point number in the sequence of floating-point numbers can also be text data, etc.

[0155] S102: Starting from the second integer in the sequence of integers, the exclusive OR result of each integer and the previous integer of the integer is calculated to obtain a result sequence, and starting from the first exclusive OR result in the result sequence, the result sequence is grouped according to a preset number to obtain a result group sequence.

[0156] After the first integer in the sequence of integers is written into the preset storage space, starting from the second integer in the sequence of integers, the exclusive OR result of each integer and the previous integer of the integer is calculated to obtain a result sequence composed of the exclusive OR results, and starting from the first exclusive OR result in the result sequence, the result sequence is grouped according to a preset number to obtain a result group sequence.

[0157] For example, if the first two numbers in the sequence of floating-point numbers are 15.5 and 14.0625 in turn, 15.5 can be converted into an integer 0x402f000000000000, and 14.0625 can be converted into an integer 0x402c200000000000, then the first integer in the obtained sequence of integers is 0x402f000000000000, and the second integer is 0x402c200000000000, and then the exclusive OR result of the second integer and the first integer in the sequence of integers is calculated, that is, the exclusive OR calculation of 0x402f000000000000 and 0x402c200000000000 is performed, so that the first exclusive OR result 0x0003200000000000 in the result sequence is obtained.

[0158] The preset number can be set by those skilled in the art according to actual application, which is not limited in the embodiments of the application.

[0159] Optionally, the preset number can be 8, and then each 8 continuous XOR results in the result sequence can be divided into 1 result group, and a result group sequence can be obtained.

[0160] For example, if the result sequence includes 30 XOR results, and all the 30 XOR results are 0, then each 8 continuous XOR results can be divided into 1 result group, and the obtained result group sequence can include: the first 3 result groups including 8 XOR results 0 and the fourth result group including 6 XOR results 0.

[0161] Optionally, each XOR result in the result group sequence can be traversed according to the arrangement order of each XOR result in the result group sequence, starting from the first XOR result in the result sequence, and each time a preset number of XOR results not divided into a result group is traversed, the preset number of XOR results can be divided into a result group, and then a result group sequence can be obtained.

[0162] S103: Determine the first type of combination and the second type of combination in the result group sequence.

[0163] The first type of combination is: a plurality of result groups including XOR results all being 0 and being continuous, or a result group including XOR results all being 0 and adjacent result groups all including XOR results not being 0, and the second type of combination is: a result group including XOR results not being 0.

[0164] After obtaining the result group sequence, for each result group in the result group sequence, a plurality of result groups including XOR results all being 0 and being continuous, or a result group including XOR results all being 0 and adjacent result groups all including XOR results not being 0 can be determined as a first type of combination, and a result group including XOR results not being 0 can be determined as a second type of combination, so as to obtain each first type of combination and each second type of combination.

[0165] S104: Generate first storage data about each first type of combination according to the number of result groups in the first type of combination, and generate second storage data about each second type of combination according to the XOR result in the second type of combination.

[0166] For each first type of combination, first storage data about the first type of combination can be generated according to the number of result groups in the first type of combination; and for each second type of combination, second storage data about the second type of combination can be generated according to the XOR result in the second type of combination.

[0167] S105: sequentially write the generated first storage data and the generated second storage data into the preset storage space, starting from a next storage location of a storage location where the first integer is located in the preset storage space, according to an arrangement order of the result groups in the result group sequence.

[0168] The storage data can include the first storage data and the second storage data, and after the storage data is obtained, the storage data can be written into the storage space. When the storage data is written into the storage space, the generated first storage data and the generated second storage data can be sequentially written into the preset storage space, starting from a next storage location of a storage location where the first integer is located in the preset storage space, according to an arrangement order of the result groups in the result group sequence.

[0169] That is, the first integer, the target number, the first storage data, and the second storage data are sequentially written into the preset storage space.

[0170] The preset storage space can be a memory space of an electronic device that executes the data compression method provided in the embodiments of the present application, can be a disk installed in the electronic device, or can be a cloud storage space associated with the electronic device, and all of these are reasonable. The embodiments of the present application do not limit the specific type of the preset storage space, and in actual application, the preset storage space can be set according to actual needs of a data compression scene.

[0171] Optionally, in a specific implementation, after all the first storage data about the first type of combination and all the second storage data about the second type of combination are generated, the generated first storage data and the generated second storage data can be sequentially written into the preset storage space, starting from a next storage location of a storage location where the first integer is located in the preset storage space, according to an arrangement order of the result groups in the result group sequence.

[0172] Optionally, in a specific implementation, the first storage data and the second storage data are generated according to an arrangement order of the result groups in the result group sequence, and thus in this case, each storage data can be written into the preset storage space after the storage data is generated.

[0173] And, the generated first storage data can be written into the preset storage space from a next storage location of a storage location where the first integer is located; the generated second storage data can be written into the preset storage space from a next storage location of a storage location where the first storage data is located; the generated third storage data can be written into the preset storage space from a next storage location of a storage location where the second storage data is located; and so on, until all the first storage data about the first type of combination and all the second storage data about the second type of combination are written into the preset storage space.

[0174] S106: determining the first integer, the first storage data and the second storage data written in the preset storage space as the compressed data of the floating-point number sequence.

[0175] After the first storage data and the second storage data are written into the preset storage space, the first integer, the first storage data and the second storage data written in the preset storage space can be determined as the compressed data of the floating-point number sequence.

[0176] Optionally, in a specific implementation, the data compression method provided by the embodiments of the present application can further include the following step 11.

[0177] Step 11: compressing the compressed data of the floating-point number sequence by using a preset compression method to obtain target compressed data.

[0178] In the specific implementation, after the compressed data of the floating-point number sequence is obtained, the obtained compressed data can be further compressed by using a preset compression method to obtain target compressed data.

[0179] The preset compression method can be set by those skilled in the art according to specific application conditions, and the embodiments of the present application do not make specific limitations here. For example, the preset compression method can be a general entropy encoding method such as huffman encoding.

[0180] As can be seen from the above, the data compression method provided in the embodiments of the present application is used, since the integer sequence is determined based on the floating-point number sequence to be compressed, and the result sequence is determined by calculating the XOR result of each integer and the previous integer of the integer, therefore, if the floating-point number sequence does not have data fluctuation, that is, each floating-point number in the floating-point number sequence is the same, each integer in the integer sequence is the same, and each XOR result in the result sequence is 0. As can be seen, each XOR result in the result sequence can reflect the data fluctuation of the floating-point number sequence. Further, for each result group, if the XOR results included in the result group are all 0, it indicates that the floating-point numbers corresponding to each XOR result in the result group do not have data fluctuation; if the result group includes an XOR result that is not 0, it indicates that the floating-point numbers corresponding to each XOR result in the result group have data fluctuation. Since in the data compression method provided in the embodiments of the present application, the first type of combination is: a plurality of result groups including XOR results that are all 0 and continuous, or a result group including XOR results that are all 0 and adjacent result groups all include an XOR result that is not 0, the second type of combination is: a result group including an XOR result that is not 0; the first storage data of each first type of combination is generated according to the number of result groups in the first type of combination; the second storage data of each second type of combination is generated according to the XOR result in the second type of combination; therefore, the embodiments of the present application can determine the storage data of each result group according to the data fluctuation of the floating-point numbers corresponding to each XOR result included in each result group in the result group sequence.

[0181] That is, in the embodiments of the present application, different data fluctuation conditions can correspond to different data compression modes, and since in the embodiments of the present application, lossless compression of floating-point data can be achieved in the compression process of floating-point data, therefore, the data compression method provided in the embodiments of the present application can improve the compression rate of lossless compression of floating-point numbers.

[0182] Optionally, in a specific implementation, the step S103 of determining the first type of combination and the second type of combination in the result group sequence can include the following steps 21-23.

[0183] Step 21: according to the arrangement order of each result group in the result group sequence, each result group is sequentially traversed, and when each result group is traversed, it is judged whether each XOR result included in the result group is 0.

[0184] If yes, step 22 is executed; if no, step 23 is executed.

[0185] Step 22: traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not divided into any combination and includes all 0 XOR results as a first type combination.

[0186] Step 23: determine the result group as a second type combination.

[0187] In the determination of the first type combination and the second type combination in the result group sequence, each result group in the result group sequence can be traversed in sequence according to the arrangement order, and when each result group is traversed, it is judged whether all the XOR results included in the result group are 0. If all the XOR results included in the result group are 0, the next result group can be traversed until there is an XOR result that is not 0 in the traversed result group, and the traversed result group that is not divided into any combination and includes all 0 XOR results is determined as a first type combination; if there is an XOR result that is not 0 in the result group, the result group can be determined as a second type combination.

[0188] For example, the result group including all 0 XOR results can be regarded as a first result group, and the result group including an XOR result that is not 0 can be regarded as a second result group. Then, if the result groups in the result group sequence A are in sequence according to the arrangement order: the first result group 1, the second result group 2, the first result group 3, the first result group 4, the second result group 5, in the determination of the first type combination and the second type combination in the result group sequence A, the first result group 1 can be traversed first. Since the first result group 1 includes all 0 XOR results, the second result group 2 can be traversed. Since there is an XOR result that is not 0 in the second result group 2, the traversed first result group 1 that is not divided into any combination and includes all 0 XOR results can be determined as a first type combination, and the second result group 2 can be determined as a second type combination. In this way, the first result group 3 and the first result group 4 can be determined as a first type combination, and the second result group 5 can be determined as a second type combination, so as to obtain each first type combination and each second type combination in the result group sequence A.

[0189] Optionally, in a specific implementation, the above step S104: generating first storage data about each first type combination according to the number of result groups in the first type combination, and generating second storage data about each second type combination according to the XOR result in the second type combination, can include the following steps 31-32.

[0190] Step 31: when each first-type combination is determined, generate storage data including preset first identification information, first byte number and first quantity of result groups in the first-type combination, as first storage data about the first-type combination.

[0191] The first byte number is used to represent the byte number occupied by the first quantity when the first quantity is stored.

[0192] When each first-type combination is determined, storage data including preset first identification information, first byte number and first quantity of result groups in the first-type combination can be generated, as first storage data about the first-type combination.

[0193] The first identification information can be set by those skilled in the art according to specific application conditions, and the bit number occupied by the first byte number can also be set by those skilled in the art according to specific application conditions, which is not limited in the present application.

[0194] 1 byte includes 8 bits, and the range of integer numbers that can be represented is 0-255; 2 bytes include 16 bits, and the range of integer numbers that can be represented is 0-65535; and so on.

[0195] For example, the first identification information can be a number 0 occupying one bit, and the bit number occupied by the first byte number can be 3. If the first-type combination B includes 10 result groups, the first quantity of result groups in the first-type combination B can be 10, since the first quantity 10 can be represented by 1 byte, the first byte number can be 1, and thus the data storage structure of the first storage data of the first-type combination B can be as shown in Figure 4 .

[0196] Step 32: when each second-type combination is determined, generate second storage data about the second-type combination according to the distribution of 0 in each exclusive OR result in the second-type combination.

[0197] When each second-type combination is determined, second storage data about the second-type combination can be generated according to the distribution of 0 in each exclusive OR result in the second-type combination.

[0198] Optionally, in a specific implementation, the step S105: starting from the next storage location of the storage location where the first integer is located in the preset storage space, sequentially writing the generated first storage data and second storage data into the preset storage space according to the arrangement order of the result groups in the result group sequence in each first-type combination and each second-type combination, can include the following step 41.

[0199] Step 41: After generating each first storage data or second storage data, sequentially write the first storage data or second storage data into the preset storage space, starting from the next storage location of the storage location where the first integer is located in the preset storage space.

[0200] In the process of writing the storage data into the storage space, after generating each first storage data or second storage data, sequentially write the first storage data or second storage data into the preset storage space, starting from the next storage location of the storage location where the first integer is located in the preset storage space.

[0201] Optionally, in a specific implementation manner, as shown in the following table, the data compression method provided by the embodiments of the present application can include the following steps S301-S309. Figure 3

[0202] S301: Convert a plurality of floating-point numbers in a floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and write a first integer in the integer sequence into a preset storage space.

[0203] S302: Starting from a second integer in the integer sequence, calculate an exclusive-OR result of each integer and the previous integer of the integer to obtain a result sequence, and starting from a first exclusive-OR result in the result sequence, group the result sequence according to a preset number to obtain a result group sequence.

[0204] S303: Traverse each result group in the result group sequence according to the arrangement order of each result group in the result group sequence, and when each result group is traversed, determine whether each exclusive-OR result included in the result group is 0.

[0205] If yes, execute step S304; if no, execute step S306.

[0206] S304: Traverse the next result group until there is an exclusive-OR result that is not 0 in the traversed result group, and determine the traversed result group that is not divided into any combination and includes each exclusive-OR result that is 0 as a first type of combination.

[0207] S305: When each first type of combination is determined, generate storage data including preset first identification information, a first number of bytes, and a first number of result groups in the first type of combination as first storage data about the first type of combination.

[0208] The first number of bytes is used to represent the number of bytes occupied by the first number of result groups.

[0209] S306: Determine the result group as a second type of combination.

[0210] ​S307: When each second-type combination is determined, second storage data about the second-type combination is generated according to the distribution of 0 in each exclusive-OR result in the second-type combination.

[0211] S308: After each first storage data or second storage data is generated, the first storage data or second storage data is sequentially written into the preset storage space from the next storage location of the storage location of the first integer in the preset storage space.

[0212] S309: The first integer, each first storage data, and each second storage data written in the preset storage space are determined as compressed data of the floating-point number sequence.

[0213] Since the above step S301 is the same as the above step S101, the above step S302 is the same as the above step S102, the above step S303 is the same as the above step 21, the above step S304 is the same as the above step 22, the above step S305 is the same as the above step 31, the above step S306 is the same as the above step 23, the above step S307 is the same as the above step 32, the above step S308 is the same as the above step 41, and the above step S309 is the same as the above step S106, the steps S301-S309 are not described again in the present specific implementation manner.

[0214] Optionally, in a specific implementation manner, the second storage data about the second-type combination is generated according to the distribution of 0 in each exclusive-OR result in the second-type combination in the above step S305 can include the following step 51.

[0215] Step 51: First information or second information about the second-type combination is generated as the second storage data about the second-type combination according to the distribution of 0 in each exclusive-OR result in the second-type combination.

[0216] The first information includes preset second identification information, a number of common valid bits, a number of common low bits of 0, and valid bit information; and the second information includes preset third identification information, a number of common high bits of 0, and data information.

[0217] The second identification information and the third identification information can be set by those skilled in the art according to specific application conditions, and the present application embodiment does not make specific limitations.

[0218] The number of common low bits of 0 is used to represent the minimum number of bit positions or the minimum number of complete bytes occupied by the low bits of 0 of each exclusive-OR result in the second-type combination; and the low bits of 0 of each exclusive-OR result are 0 before the first non-0 number in the order from the lowest bit to the highest bit.

[0219] For example, as shown in FIG. 5(a), the low 0 of the 16-bit XOR result 0000001010110000 is the 0 in the last 4 bits of the XOR result.

[0220] For example, if the number of bits occupied by the low 0 of each XOR result in the second type of combination is 10, 20, 30, 15, 10, and 20 respectively, if the common low 0 number is used to represent the minimum number of bits occupied by the low 0 of each XOR result in the second type of combination, the common low 0 number is 10; if the common low 0 number is used to represent the minimum number of complete bytes occupied by the low 0 of each XOR result in the second type of combination, the common low 0 number is 1.

[0221] The common valid bit number is used to represent the maximum value of the number of valid bits in each XOR result in the second type of combination, and the valid bit of each XOR result is the bit occupied by the non-0 number appearing first to the non-0 number appearing last in each XOR result in the order from the highest bit to the lowest bit.

[0222] For example, as shown in FIG. 5(a), the valid bit of the 16-bit XOR result 0000001010110000 is 101011, and the number of valid bits is 6.

[0223] For example, if the number of valid bits in each XOR result in the second type of combination is 30, 30, 30, 30, 40, 50, 40, and 35 respectively, the common valid bit number of each XOR result in the second type of combination is 50.

[0224] The common high 0 number is used to represent the minimum number of bits occupied by the high 0 of each XOR result in the second type of combination or the minimum number of complete bytes; and the high 0 of each XOR result is the 0 before the non-0 number appearing first in the order from the highest bit to the lowest bit.

[0225] For example, as shown in FIG. 5(a), the high 0 of the 16-bit XOR result 0000001010110000 is the 0 in the first 6 bits of the XOR result.

[0226] For example, if the number of bits occupied by the high 0 of each XOR result in the second type of combination is 10, 20, 30, 15, 10 and 20 respectively, if the above common high 0 number is used to represent the minimum number of bits occupied by the high 0 of each XOR result in the second type of combination, the above common high 0 number is 10; if the above common high 0 number is used to represent the minimum number of complete bytes occupied by the high 0 of each XOR result in the second type of combination, the above common high 0 number is 1.

[0227] The above valid bit information is: the value of the common valid bit of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; the common valid bit of each XOR result is: in the bits occupied by each XOR result, the number of bits occupied by the common high 0 is removed in the order from the highest bit to the lowest bit, and the number of bits occupied by the common low 0 is removed in the order from the lowest bit to the highest bit.

[0228] For example, the number of high 0 of XOR result 00101000 is 2, and the number of low 0 is 3; the number of high 0 of XOR result 00011100 is 3, and the number of low 0 is 2; further, the common number of high 0 of the two XOR results is 2, the common number of low 0 is 2, and the common valid bit is the 3rd, 4th, 5th and 6th valid bit in the order from the highest bit to the lowest bit; further, the valid bit information of XOR result 00101000 is 1010, and the valid bit information of XOR result 00011100 is 0111.

[0229] For example, the preset second identification information can be 11, and the data storage structure of the above first information can be as shown in FIG. 5(b), wherein data 11-data 1n is the valid bit information of each XOR result in the second type of combination. It can be seen that for each second type of combination, the preset second identification information, the common valid bit number of each XOR result in the second type of combination, the common low 0 number of each XOR result in the second type of combination and the valid bit information of each XOR result in the second type of combination can constitute the first information about the second type of combination in the form of sequential arrangement.

[0230] The above data information includes: the target information of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, the target information of the XOR result is the first value, if the XOR result is not 0, the target information of the XOR result includes: the second value, and the value of the remaining bits after removing the common high 0 number of bits in the XOR result in the order from the highest bit to the lowest bit.

[0231] The first value and the second value can be set by those skilled in the art according to specific application, and the embodiment of the present application does not make specific limitation.

[0232] For example, if the second value is 1, the XOR result is 00011100, and the number of common high bits 0 is 2, the target information of the XOR result is 1011100.

[0233] For example, the preset third identification information can be 10, the first value can be 0, and the second value can be 1. Then, the data storage structure of the first information can be as shown in FIG. 5(c), wherein data21-data2n represents, when the XOR result is not 0, the value of the remaining bits in the order from the highest bit to the lowest bit in the XOR result after removing the common high bits 0. It can be seen that for each second type combination, the preset third identification information, the number of common high bits 0 of each XOR result in the second type combination, and the data information of each XOR result in the second type combination can form the second information about the second type combination in the form of sequential arrangement.

[0234] Optionally, in a specific implementation, the step 51 of generating the first information or the second information about the second type combination as the second storage data about the second type combination can include steps 61-62.

[0235] Step 61: If the number of XOR results of 0 included in the second type combination is less than the specified number, the first information about the second type combination is generated as the second storage data about the second type combination.

[0236] For each second type combination, if the number of XOR results of 0 included in the second type combination is less than the specified number, the first information about the second type combination can be generated as the second storage data about the second type combination when determining the second storage data about the second type combination.

[0237] Step 62: If the number of XOR results of 0 included in the second type combination is not less than the specified number, the second information about the second type combination is generated as the second storage data about the second type combination.

[0238] If the number of XOR results of 0 included in the second type combination is not less than the specified number, the second information about the second type combination can be generated as the second storage data about the second type combination.

[0239] The specified number can be set by those skilled in the art according to specific application, and the specific embodiment does not make specific limitation here.

[0240] Optionally, in a specific implementation, the step 51 of generating the first information or the second information about the second type of combination as the second stored data about the second type of combination can include the following steps 63-65.

[0241] Step 63: determining a first data amount of the first information about the second type of combination and a second data amount of the second information about the second type of combination.

[0242] For each second type of combination, when determining the second stored data about the second type of combination, a first data amount of the first information about the second type of combination and a second data amount of the second information about the second type of combination can be determined first.

[0243] Step 64: if the first data amount is less than the second data amount, generating the first information about the second type of combination as the second stored data about the second type of combination.

[0244] If the first data amount is less than the second data amount, the first information about the second type of combination can be generated as the second stored data about the second type of combination.

[0245] Step 65: if the first data amount is not less than the second data amount, generating the second information about the second type of combination as the second stored data about the second type of combination.

[0246] If the first data amount is not less than the second data amount, the second information about the second type of combination can be generated as the second stored data about the second type of combination.

[0247] Based on this, by applying the specific implementation, for each second type of combination, when determining the second stored data about the second type of combination, the information with a smaller data amount between the first information and the second information can be determined as the second stored data about the second type of combination, thereby further improving the compression rate of the floating-point number.

[0248] Optionally, in a specific implementation, the step S101 of writing the first integer in the integer sequence into the preset storage space can include the following step 71.

[0249] Step 71: sequentially writing the first integer in the integer sequence and the target number of integers in the integer sequence into the preset storage space.

[0250] Correspondingly, the step S105 of sequentially writing the generated first storage data and second storage data into the preset storage space according to the arrangement order of the result groups in the result group sequence in each first type combination and each second type combination, starting from the next storage location of the storage location where the first integer is located in the preset storage space, can include the following step 72.

[0251] The step 72 of sequentially writing the generated first storage data and second storage data into the preset storage space according to the arrangement order of the result groups in the result group sequence in each first type combination and each second type combination, starting from the next storage location of the storage location where the target number is located in the preset storage space.

[0252] Correspondingly, the step S106 of determining the first integer, the first storage data and the second storage data written in the preset storage space as the compressed data of the floating-point number sequence can include the following step 73.

[0253] The step 73 of determining the first integer, the target number, the first storage data and the second storage data written in the preset storage space as the compressed data of the floating-point number sequence.

[0254] After the plurality of floating-point numbers in the floating-point number sequence to be compressed are respectively converted into integers to obtain an integer sequence, the first integer in the integer sequence and the target number of the integers in the integer sequence can be sequentially written in the preset storage space. Then, when the generated first storage data and second storage data are written into the preset storage space, the generated first storage data and second storage data can be sequentially written into the preset storage space according to the arrangement order of the result groups in the result group sequence in each first type combination and each second type combination, starting from the next storage location of the storage location where the target number is located in the preset storage space. Further, the first integer, the target number, the first storage data and the second storage data written in the preset storage space can be determined as the compressed data of the floating-point number sequence.

[0255] Based on this, when decompressing the compressed data, the first integer and the target number in the compressed data can be read first, then each first storage data and each second storage data included in the compressed data can be sequentially read according to the arrangement order of each storage data in the compressed data, and each storage data is parsed when it is read to obtain the corresponding XOR result of the storage data. When the number of obtained XOR results reaches the difference between the target number and 1, it means that all the first storage data and the second storage data have been read, and then the reading of the compressed data can be stopped when the number of obtained XOR results reaches the difference between the target number and 1. According to the order in which each XOR result is obtained, each XOR result and the obtained previous integer are XOR calculated in sequence to obtain the target integer corresponding to the XOR result. Finally, each integer is converted into a floating-point number, and each floating-point number corresponding to each integer is written into a floating-point number sequence according to the order in which each integer is obtained, so that the decompressed data corresponding to the compressed data can be obtained.

[0256] Optionally, after the first integer is read, the first integer can be written into the first sequence, and after each XOR result is obtained, the XOR result can be written into the second sequence. Then, when the number of XOR results in the second sequence reaches the difference between the target number and 1, starting from the first XOR result in the second sequence, each XOR result in the second sequence can be XOR calculated with the obtained previous integer to obtain the target integer corresponding to the XOR result, and the target integer can be written into the first sequence. After the target integer corresponding to the last XOR result in the second sequence is written into the first sequence, each integer in the integer sequence can be converted into a floating-point number, and each floating-point number corresponding to each integer can be written into the floating-point number sequence according to the order in which each integer is written into the first sequence, so that the decompressed data corresponding to the compressed data can be obtained.

[0257] Optionally, when the first integer and the target number are written into the preset storage space, the target number and the first integer can also be sequentially written into the preset storage space. Then, when each first storage data and each second storage data generated are written into the preset storage space, each first storage data and each second storage data generated can be sequentially written into the preset storage space starting from the next storage location of the storage location of the first integer in the preset storage space according to the arrangement order of the result group in the result group sequence in each first type combination and each second type combination.

[0258] Optionally, before the step of converting the plurality of floating-point numbers in the floating-point number sequence to be compressed into integers in the step S101, the data compression method provided by the embodiment of the present application can further include the following step 81.

[0259] Step 81: adding a preset floating-point number after the last floating-point number sequence in the floating-point number sequence to be compressed.

[0260] Wherein, the preset floating-point number is different from each floating-point number in the floating-point number sequence to be compressed.

[0261] Correspondingly, the step of converting the plurality of floating-point numbers in the floating-point number sequence to be compressed into integers in the step S101 can include the following step 82.

[0262] Step 82: converting the plurality of floating-point numbers in the floating-point number sequence to which the preset floating-point number is added into integers to obtain an integer sequence.

[0263] Before the plurality of floating-point numbers in the floating-point number sequence to be compressed are converted into integers, a preset floating-point number can be added after the last floating-point number sequence in the floating-point number sequence to be compressed, and the preset floating-point number can be different from each floating-point number in the floating-point number sequence to be compressed. Correspondingly, when the plurality of floating-point numbers in the floating-point number sequence to be compressed are converted into integers, the plurality of floating-point numbers in the floating-point number sequence to which the preset floating-point number is added can be converted into integers, thereby obtaining an integer sequence.

[0264] Further, when the compressed data is decompressed, the first integer in the compressed data can be read first, then each first storage data and each second storage data included in the compressed data can be sequentially read according to the arrangement order of each storage data in the compressed data, and each storage data is parsed to obtain the exclusive-OR result corresponding to the storage data when each storage data is read. After each exclusive-OR result is obtained, the exclusive-OR result and the obtained previous integer can be exclusive-OR calculated to obtain the target integer corresponding to the exclusive-OR result, and the target integer corresponding to the exclusive-OR result is converted into a floating-point number. After each floating-point number is obtained, it can be judged whether the floating-point number is a preset floating-point number, if the floating-point number is not a preset floating-point number, the floating-point number can be written into a floating-point number sequence; if the floating-point number is a floating-point number, it indicates that the decompression is completed. Further, the current floating-point number sequence can be determined as the decompressed data corresponding to the data to be decompressed.

[0265] Wherein, the preset floating-point number is not specifically limited in the embodiment of the present application, and the preset floating-point number can be set according to specific application by those skilled in the art.

[0266] Exemplarily, the preset floating point number can be an NAN (Not A Number) floating point number.

[0267] Corresponding to the data compression method provided in the embodiments of the present application, the embodiments of the present application further provide a data decompression method. Figure 6 As shown in the figure, the data decompression method can include the following steps S601-S605.

[0268] S601: Obtain the to-be-decompressed data, and read the first integer in the to-be-decompressed data.

[0269] The to-be-decompressed data is obtained by any of the data compression methods described above.

[0270] Since the to-be-decompressed data is obtained by any of the data compression methods described above, when the to-be-decompressed data is decompressed, the to-be-decompressed data can be obtained first, and then the first integer in the to-be-decompressed data can be read.

[0271] Optionally, the position and the number of bytes occupied by the first integer in the to-be-decompressed data are known, and then, after the to-be-decompressed data is obtained, the first integer in the to-be-decompressed data can be read according to the position and the number of bytes occupied by the first integer in the to-be-decompressed data.

[0272] Exemplarily, in the to-be-decompressed data, the first integer is represented by a bytes at the starting position, and then, after the to-be-decompressed data is obtained, the first integer in the to-be-decompressed data can be obtained by reading the a bytes first.

[0273] S602: According to the arrangement order of each stored data in the to-be-decompressed data, each stored data in the to-be-decompressed data is read in sequence.

[0274] According to any of the data compression methods described above, the to-be-decompressed data can include the first integer, each first stored data, and each second stored data, and thus, after the first integer in the to-be-decompressed data is obtained, each stored data in the to-be-decompressed data can be read in sequence according to the arrangement order of each stored data in the to-be-decompressed data.

[0275] S603: When each stored data is read, the stored data is parsed according to the data content of the stored data to obtain the XOR result corresponding to the stored data.

[0276] According to the data compression method, the first storage data is generated based on a first type of combination, and the second storage data is generated based on a second type of combination; the first type of combination is that a plurality of result groups included in a result group sequence are all 0 and continuous, or a result group included in the result group sequence is not 0; the second type of combination is that a result group included in the result group sequence is not 0; the result group sequence is obtained by grouping a result sequence according to a preset number, starting from a first XOR result in the result sequence; the result sequence is obtained by calculating an XOR result of each integer and a previous integer of the integer, starting from a second integer in an integer sequence; therefore, when each storage data is read, the storage data can be parsed according to data content of the storage data, so that an XOR result corresponding to the storage data is obtained.

[0277] S604: XOR calculating each XOR result and a previous integer obtained, in a sequence in which the XOR results are obtained, to obtain a target integer corresponding to the XOR result.

[0278] Since the sequence in which the XOR results are obtained in the data decompression process is the same as the sequence in which the XOR results are obtained in the data compression process, and each XOR result in the data compression process is obtained by calculating an XOR result of each integer and a previous integer of the integer, starting from a second integer in an integer sequence, XOR calculating a first XOR result obtained in the data decompression process and a previous integer obtained, that is, the first integer, can obtain a target integer corresponding to the first XOR result, that is, a second integer in the integer sequence in the data compression process; XOR calculating a second XOR result obtained in the data decompression process and a previous integer obtained, that is, the second integer, can obtain a target integer corresponding to the second XOR result, that is, a third integer in the integer sequence in the data compression process. In this way, all integers in the integer sequence in the data compression process can be obtained.

[0279] S605: converting each integer obtained into a floating-point number, and writing each floating-point number corresponding to each integer into a floating-point number sequence according to the sequence in which the integers are obtained, to obtain decompression data corresponding to the data to be decompressed.

[0280] Converting each integer obtained into a floating-point number, and writing each floating-point number corresponding to each integer into a floating-point number sequence according to the sequence in which the integers are obtained, after all floating-point numbers corresponding to all integers are written into the floating-point number sequence, the current floating-point number sequence can be used as decompression data corresponding to the data to be decompressed.

[0281] Optionally, the to-be-decompressed data can be compressed data determined based on the data compression method corresponding to steps 71-73, and then when decompressing the to-be-decompressed data, the first integer and the target number in the to-be-decompressed data can be read first, and then each first storage data and each second storage data included in the to-be-decompressed data can be sequentially read according to the arrangement order of the storage data in the to-be-decompressed data, and when each storage data is read, the storage data is parsed according to the data content of the storage data to obtain an exclusive-OR result corresponding to the storage data. When the number of the obtained exclusive-OR results reaches the difference between the target number and 1, it means that all the first storage data and the second storage data have been read, and then the reading of the to-be-decompressed data can be stopped when the number of the obtained exclusive-OR results reaches the difference between the target number and 1. Each exclusive-OR result and the obtained previous integer can be exclusive-OR calculated according to the order in which the exclusive-OR results are obtained, to obtain a target integer corresponding to the exclusive-OR result. Finally, each integer obtained is converted into a floating-point number, and each floating-point number corresponding to each integer is written into a floating-point number sequence according to the order in which the integers are obtained, to obtain decompressed data corresponding to the to-be-decompressed data.

[0282] Optionally, the to-be-decompressed data can be compressed data determined based on the data compression method corresponding to steps 81-82, and then when decompressing the to-be-decompressed data, the first integer in the to-be-decompressed data can be read first, and then each first storage data and each second storage data included in the to-be-decompressed data can be sequentially read according to the arrangement order of the storage data in the to-be-decompressed data, and when each storage data is read, the storage data is parsed to obtain an exclusive-OR result corresponding to the storage data. After each exclusive-OR result is obtained, the exclusive-OR result and the obtained previous integer can be exclusive-OR calculated to obtain a target integer corresponding to the exclusive-OR result, and the target integer corresponding to the exclusive-OR result is converted into a floating-point number. After each floating-point number is obtained, it can be judged whether the floating-point number is a preset floating-point number. If the floating-point number is not the preset floating-point number, the floating-point number can be written into a floating-point number sequence; and if the floating-point number is the floating-point number, it indicates that the decompression is completed, and then the current floating-point number sequence can be determined as decompressed data corresponding to the to-be-decompressed data.

[0283] For better understanding of the data compression method provided by the embodiments of the present application, as shown in the following table, the data compression method provided by the embodiments of the present application can include the following steps S701-S7011. Figure 7

[0284] ​In the example, the first type of combination is a plurality of result groups including all 0s in sequence, or one result group including all 0s and adjacent result groups including non-0s; the second type of combination is one result group including non-0s; the first byte number is used to represent the number of bytes occupied by the first number; the first information includes preset second identification information, a number of common valid bits, a number of common low bits of 0, and valid bit information; and the second information includes preset third identification information, a number of common high bits of 0, and data information.

[0285] S701: According to the IEEE754 standard, a plurality of floating-point numbers in the floating-point number sequence to be compressed are converted into integers respectively to obtain an integer sequence, and a first integer in the integer sequence and a target number of integers in the integer sequence are sequentially written in a preset storage space.

[0286] The first integer is represented by a bytes, and the target number is represented by b bytes, where a and b are integers greater than 0.

[0287] In the compression processing of the floating-point number sequence to be compressed, the plurality of floating-point numbers in the floating-point number sequence to be compressed can be converted into integers respectively according to the IEEE754 standard to obtain an integer sequence, and a first integer (occupying a bytes) in the integer sequence and a target number (occupying b bytes) of integers in the integer sequence can be sequentially written in a preset storage space.

[0288] S702: Starting from a second integer in the integer sequence, an exclusive OR result of each integer and a previous integer of the integer is calculated to obtain a result sequence, and starting from a first exclusive OR result in the result sequence, the result sequence is grouped according to a preset number to obtain a result group sequence.

[0289] After obtaining the integer sequence, starting from a second integer in the integer sequence, an exclusive OR result of each integer and a previous integer of the integer is calculated to obtain a result sequence, and starting from a first exclusive OR result in the result sequence, the result sequence is grouped according to a preset number to obtain a result group sequence, and each result group in the result group sequence can include a preset number of exclusive OR results.

[0290] S703: According to the arrangement order of each result group in the result group sequence, each result group is sequentially traversed, and when each result group is traversed, it is determined whether each exclusive OR result included in the result group is 0.

[0291] If yes, step S704 is performed; if no, step S706 is performed.

[0292] After the result group sequence is obtained, each result group in the result group sequence can be traversed in sequence according to the arrangement order of each result group in the result group sequence, and when each result group is traversed, it is judged whether each XOR result included in the result group is 0.

[0293] S704: The next result group is traversed until there is an XOR result that is not 0 in the traversed result group, and the traversed result group that is not divided into any combination and includes each XOR result that is 0 is determined as a first type combination.

[0294] For each result group, if when the result group is traversed, it is judged that each XOR result included in the result group is 0, the next result group can be continuously traversed until there is an XOR result that is not 0 in the traversed result group, and then the traversed result group that is not divided into any combination and includes each XOR result that is 0 can be determined as a first type combination.

[0295] S705: When each first type combination is determined, storage data including preset first identification information, a first byte number and a first number of result groups in the first type combination is generated as first storage data about the first type combination, and the first storage data is written into a preset storage space.

[0296] The preset first identification information is a number 0 occupying one bit, the first byte number is represented by c bits, and c is an integer not equal to 0.

[0297] When each first type combination is determined, storage data including preset first identification information (0), a first byte number and a first number of result groups in the first type combination (occupying c bytes) can be generated as first storage data about the first type combination, and the first storage data is written into a preset storage space.

[0298] S706: The result group is determined as a second type combination.

[0299] For each result group, if when the result group is traversed, it is judged that each XOR result included in the result group is not 0, the result group can be determined as a second type combination.

[0300] S707: When each second type combination is determined, a first data amount of first information about the second type combination and a second data amount of second information about the second type combination are determined.

[0301] The first information includes preset second identification information (11), a number of public valid bits (occupying d bits), a number of public low bits 0 (occupying e bits), and valid bit information. The second information includes preset third identification information (10), a number of public high bits 0 (occupying f bits), and data information.

[0302] The data information includes target information of each exclusive-OR result in the second type of combination arranged according to arrangement information of the exclusive-OR result. For each exclusive-OR result in the second type of combination, if the exclusive-OR result is 0, the target information of the exclusive-OR result is a first value (0); if the exclusive-OR result is not 0, the target information of the exclusive-OR result includes a second value (1) and values of bits left after removing a number of public high bits 0 from the exclusive-OR result (occupying g bits) in order from the highest bit to the lowest bit.

[0303] S708: If the first data amount is less than the second data amount, first information about the second type of combination is generated as second storage data about the second type of combination.

[0304] If the first data amount is less than the second data amount, second information about the second type of combination is generated as second storage data about the second type of combination.

[0305] S709: If the first data amount is not less than the second data amount, second information about the second type of combination is generated as second storage data about the second type of combination.

[0306] If the first data amount is not less than the second data amount, second information about the second type of combination is generated as second storage data about the second type of combination.

[0307] S7010: After the last result group in the result group sequence is traversed, the first integer, the target number, each first storage data, and each second storage data written in the preset storage space are determined as compressed data of the floating-point number sequence.

[0308] S7011: The compressed data is compressed by Huffman coding to obtain target compressed data.

[0309] Correspondingly, for the data compression method as shown in Figure 7 , the data decompression method provided by the embodiment of the application can include the following steps S801-S8010 as shown in Figure 8 .

[0310] S801: decode the to-be-decompressed data by Huffman decoding to obtain compressed data; read the first a bytes in the compressed data to obtain the first integer in the integer sequence.

[0311] The to-be-decompressed data is obtained based on a data compression method as shown in Figure 6 The to-be-decompressed data corresponds to the target compressed data in step S7011.

[0312] S802: continue to sequentially read b bytes to obtain the target number of integers in the integer sequence, and initialize an empty first sequence.

[0313] S803: determine whether the number of XOR results in the first sequence is less than the difference between the target number and 1.

[0314] If yes, perform step S804; if no, perform step S809.

[0315] S804: continue to sequentially read 1 bit, and determine whether the data on the bit is 0.

[0316] If yes, perform step S805; if no, perform step S806.

[0317] S805: continue to sequentially read c bits to obtain the first number of first bytes; continue to sequentially read the first number of bytes to obtain the first number; write the product of the first number and the preset number of XOR results 0 into the first sequence; and return to step S803.

[0318] S806: continue to sequentially read 1 bit, and determine whether the data on the bit is 1.

[0319] If yes, perform step S807; if no, perform step S808.

[0320] S807: continue to sequentially read d bits to obtain the number of common significant bits; continue to sequentially read e bits to obtain the number of common low 0s; continue to sequentially read the product of the number of common significant bits and the preset number of bits to obtain the common significant bits of the preset number of XOR results; respectively append the number of common low 0s of 0 after each common significant bit to obtain the preset number of XOR results; write the obtained preset number of XOR results into the first sequence; and return to step S803.

[0321] S808: Continue to sequentially read f bits to obtain the number of common high bits 0; determine whether the number of the obtained XOR results in the present step is less than the preset number; if yes, continue to read one bit; if the bit is 0, write one XOR result 0 into the first sequence, and return to determine whether the number of the obtained XOR results in the present step is less than the preset number; if the bit is 1, continue to read g bits that are different from the number of common high bits 0, obtain one XOR result, write the XOR result into the first sequence, and return to determine whether the number of the obtained XOR results in the present step is less than the preset number; if no, return to step S803.

[0322] S809: Initialize an empty second sequence, write the obtained first integer into the second sequence, traverse each XOR result in the first sequence according to the writing order of the XOR results in the first sequence, and perform XOR calculation on each XOR result and the latest written integer in the second sequence to obtain an integer and write the integer into the second sequence.

[0323] S8010: After traversing the first sequence, convert each integer in the second sequence into a floating-point number according to the IEEE754 standard to obtain decompressed data corresponding to the to-be-decompressed data.

[0324] To verify the data compression performance of the data compression method provided in the embodiments of the present application, the data compression method provided in the embodiments of the present application and the Gorrila compression method are compared and tested.

[0325] As shown in FIG. 9(a), compared with the Gorrila compression method, the average compression rate of the data compression method as shown in FIG. 9(a) can be increased by 22% when the data set UCR (including real time series floating-point data of 129 different scenes) is compressed. Figure 7 As shown in FIG. 9(b), the compression speed of the data compression method as shown in FIG. 9(b) is basically the same as that of the Gorrila compression method when the data set UCR is compressed. Figure 7 As shown in FIG. 9(c), compared with the compressed data obtained based on the Gorrila compression method, the decompression speed of the compressed data obtained based on the data compression method as shown in FIG. 9(c) can be faster. Figure 7

[0326] Corresponding to the data compression method provided in the embodiments of the present application, the embodiments of the present application further provide a data compression device.

[0327] Figure 10 The structure diagram of the data compression device provided in the embodiments of the present application is shown in FIG. 9(d), which can include the following modules: Figure 10 ​​

[0328] The data conversion module 1001 is configured to convert a plurality of floating-point numbers in a floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and write a first integer in the integer sequence into a preset storage space;

[0329] The result calculation module 1002 is configured to calculate an exclusive-OR result of each integer and a previous integer of the integer from a second integer in the integer sequence to obtain a result sequence, and group the result sequence according to a preset number from a first exclusive-OR result in the result sequence to obtain a result group sequence;

[0330] The combination determination module 1003 is configured to determine a first type of combination and a second type of combination in the result group sequence; wherein the first type of combination is a plurality of result groups including only 0 and being continuous, or a result group including only 0 and adjacent result groups including an exclusive-OR result other than 0, and the second type of combination is a result group including an exclusive-OR result other than 0;

[0331] The data generation module 1004 is configured to generate first storage data about each first type of combination according to a number of result groups in the first type of combination, and generate second storage data about each second type of combination according to an exclusive-OR result in the second type of combination;

[0332] The data writing module 1005 is configured to sequentially write each first storage data and each second storage data into the preset storage space from a next storage location of a storage location where the first integer is located in the preset storage space according to an arrangement order of the result groups in each first type of combination and each second type of combination in the result group sequence;

[0333] The data determination module 1006 is configured to determine the first integer, each first storage data and each second storage data written in the preset storage space as compressed data of the floating-point number sequence.

[0334] Based on this, the data compression method provided in the embodiment of the present application can improve the compression rate of lossless compression of floating-point numbers.

[0335] That is to say, in the embodiment of the present application, different data fluctuation conditions can correspond to different data compression modes, and since lossless compression of floating-point data can be realized in the compression process of floating-point data in the embodiment of the present application, the data compression method provided in the embodiment of the present application can improve the compression rate of lossless compression of floating-point numbers.

[0336] Optionally, in a specific implementation, the combination determining module is specifically configured to:

[0337] According to the arrangement order of each result group in the result group sequence, each result group is sequentially traversed, and when each result group is traversed, it is determined whether each exclusive OR result included in the result group is 0;

[0338] If yes, the next result group is traversed until there is an exclusive OR result that is not 0 in the traversed result group, and the result group that is not divided into any combination and includes each exclusive OR result that is 0 is determined as the first combination;

[0339] If no, the result group is determined as the second type of combination;

[0340] Optionally, in an implementation, the data generation module comprises:

[0341] The first generation sub-module is configured to, when each first-type combination is determined, generate storage data comprising preset first identification information, a first byte number and a first quantity of result groups in the first-type combination, as first storage data about the first-type combination; the first byte number is used to represent a byte number occupied by the first quantity when the first quantity is stored;

[0342] The second generation sub-module is configured to, when each second-type combination is determined, generate second storage data about the second-type combination according to a distribution of 0 in each exclusive-OR result in the second-type combination;

[0343] Optionally, in an implementation, the second generation sub-module is specifically configured to:

[0344] generate, according to the distribution of 0 in each exclusive-OR result in the second-type combination, first information or second information about the second-type combination as the second storage data about the second-type combination;

[0345] The first information comprises preset second identification information, a common valid bit quantity, a common low-bit 0 quantity and valid bit information; and the second information comprises preset third identification information, a common high-bit 0 quantity and data information.

[0346] The common low-bit 0 quantity is used to represent a minimum quantity of bit positions or a minimum quantity of complete bytes occupied by low-bit 0 of each exclusive-OR result in the second-type combination; the low-bit 0 of each exclusive-OR result is 0 before a first non-0 number in an order from a lowest bit to a highest bit;

[0347] The common valid bit quantity is used to represent a maximum value of a quantity of valid bits in each exclusive-OR result in the second-type combination; the valid bit of each exclusive-OR result is a bit position occupied by a first non-0 number to a last non-0 number in an order from the highest bit to the lowest bit among bit positions occupied by the exclusive-OR result;

[0348] The common high-bit 0 quantity is used to represent a minimum quantity of bit positions or a minimum quantity of complete bytes occupied by high-bit 0 of each exclusive-OR result in the second-type combination; the high-bit 0 of each exclusive-OR result is 0 before a first non-0 number in an order from the highest bit to the lowest bit;

[0349] The valid bit information is arranged according to the arrangement information of each XOR result in the second type of combination, and the value of the common valid bit of each XOR result in the second type of combination; the common valid bit of each XOR result is: in the bit occupied by each XOR result, the common high bit 0 quantity of bits is removed in the order from the highest bit to the lowest bit, and the common low bit 0 quantity of bits is removed in the order from the lowest bit to the highest bit, and the remaining bit is left;

[0350] The data information includes: target information of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, the target information of the XOR result is the first value, if the XOR result is not 0, the target information of the XOR result includes: the second value, and the value of the bit left after removing the common high bit 0 quantity of bits in the XOR result in the order from the highest bit to the lowest bit;

[0351] Optionally, in a specific implementation manner, the second generation submodule is specifically configured to:

[0352] If the number of XOR results of 0 included in the second type of combination is less than the specified number, generate the first information about the second type of combination as the second storage data about the second type of combination;

[0353] If the number of XOR results of 0 included in the second type of combination is not less than the specified number, generate the second information about the second type of combination as the second storage data about the second type of combination;

[0354] Or,

[0355] Determine the first data amount of the first information about the second type of combination and the second data amount of the second information about the second type of combination;

[0356] If the first data amount is less than the second data amount, generate the first information about the second type of combination as the second storage data about the second type of combination;

[0357] If the first data amount is not less than the second data amount, generate the second information about the second type of combination as the second storage data about the second type of combination;

[0358] Optionally, in a specific implementation manner, the data writing module is specifically configured to:

[0359] starting from a next storage location of a storage location where the first integer is located in the preset storage space, sequentially writing the first storage data or the second storage data into the preset storage space after each first storage data or second storage data is generated;

[0360] Optionally, in a specific implementation, the data conversion module is specifically configured to:

[0361] write, in the preset storage space, a first integer in the integer sequence and a target number of integers in the integer sequence in sequence;

[0362] The data writing module is specifically configured to:

[0363] starting from a next storage location of a storage location where the target number is located in the preset storage space, sequentially write the generated first storage data and second storage data into the preset storage space according to the arrangement order of the result groups in the result group sequence in each first type combination and each second type combination;

[0364] The data determination module is specifically configured to:

[0365] determine the first integer, the target number, the first storage data and the second storage data written in the preset storage space as compressed data of the floating-point number sequence;

[0366] Optionally, in a specific implementation, the apparatus further includes:

[0367] a floating-point number adding module configured to add a preset floating-point number after a last floating-point number sequence in the floating-point number sequence to be compressed; wherein the preset floating-point number is different from each floating-point number in the floating-point number sequence to be compressed;

[0368] The data conversion module is specifically configured to:

[0369] convert the plurality of floating-point numbers in the floating-point number sequence to which the preset floating-point number is added into integers to obtain an integer sequence;

[0370] Optionally, in a specific implementation, the apparatus further includes:

[0371] a data compression module configured to compress the compressed data by using a preset compression method to obtain target compressed data.

[0372] Optionally, in a specific implementation, the floating-point number sequence is a multimedia data sequence; and the multimedia data includes at least one of video data, audio data and image data.

[0373] Corresponding to the data decompression method provided in the above embodiment of the present application, the embodiment of the present application further provides a data decompression device, as shown in Figure 11 The data decompression device can include the following modules:

[0374] The decompression data obtaining module 1101 is configured to obtain the to-be-decompressed data and read the first integer in the to-be-decompressed data, wherein the to-be-decompressed data is obtained by using any of the data compression methods described above.

[0375] The data reading module 1102 is configured to read each storage data in the to-be-decompressed data in sequence according to the arrangement order of each storage data in the to-be-decompressed data.

[0376] The data analysis module 1103 is configured to, when each storage data is read, analyze the storage data according to the data content of the storage data to obtain the XOR result corresponding to the storage data.

[0377] The XOR calculation module 1104 is configured to XOR calculate each XOR result and the obtained previous integer in sequence to obtain the target integer corresponding to the XOR result.

[0378] The floating-point number conversion module 1105 is configured to convert each integer obtained into a floating-point number, write each floating-point number corresponding to each integer into a floating-point number sequence in sequence, and obtain the decompression data corresponding to the to-be-decompressed data.

[0379] The embodiment of the present application further provides an electronic device, as shown in Figure 12 The electronic device includes:

[0380] The memory 1201 is configured to store a computer program.

[0381] The processor 1202 is configured to execute the program stored in the memory 1201 to implement the steps of any of the data compression methods provided in the embodiments of the present application and / or the steps of any of the data decompression methods provided in the embodiments of the present application.

[0382] The electronic device can further include a communication bus and / or a communication interface, and the processor 1202, the communication interface, and the memory 1201 can complete mutual communication through the communication bus.

[0383] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.

[0384] The communication interface is used for communication between the above electronic device and other devices.

[0385] The memory can include a Random Access Memory (RAM) and can also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the above processor.

[0386] The above processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0387] In another embodiment provided in the present application, a computer readable storage medium is also provided, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the steps of any data compression method provided in the embodiments of the present application and / or the steps of any data decompression method provided in the embodiments of the present application.

[0388] In another embodiment provided in the present application, a computer program product containing instructions is also provided, and when the computer program product is run on a computer, the computer is caused to execute any data compression method provided in the embodiments of the present application and / or any data decompression method provided in the embodiments of the present application.

[0389] In the embodiments described above, all or some of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or some of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded into and executed by a computer, all or some of the processes or functions according to the embodiments described in the specification are generated. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through a wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be a magnetic medium (for example, floppy disk, hard disk, magnetic tape), an optical medium (for example, DVD), or a solid state disk (SSD) and the like.

[0390] It should be noted that, in this document, the 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 the entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.

[0391] Each of the embodiments in the specification is described in a related manner, and the same or similar parts between each of the embodiments can be referred to each other. Each of the embodiments focuses on the difference from other embodiments. In particular, for the device embodiments, electronic device embodiments, computer readable storage medium embodiments and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the related parts can be referred to the part of the method embodiments.

[0392] The above merely provides the preferred embodiment of the present application, and not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A data compression method, characterized in that, The method includes: Multiple floating-point numbers in the floating-point number sequence to be compressed are converted into integers to obtain an integer sequence, and the first integer in the integer sequence is written into a preset storage space; Starting from the second integer in the integer sequence, calculate the XOR result of each integer with the integer preceding it to obtain a result sequence. Starting from the first XOR result in the result sequence, group the result sequence according to a preset number to obtain a result group sequence. Determine a first type of combination and a second type of combination in the result group sequence; wherein, the first type of combination is: a plurality of consecutive result groups whose XOR results are all 0, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0; the second type of combination is: a result group that includes XOR results that are not 0. Based on the number of result groups in each first type of combination, generate first stored data for that first type of combination, and based on the XOR result in each second type of combination, generate second stored data for that second type of combination; Starting from the next storage location after the storage location of the first integer in the preset storage space, the generated first storage data and second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in the result group sequence of each first type combination and each second type combination. The first integer, each first storage data, and each second storage data written in the preset storage space are determined as the compressed data of the floating-point number sequence; The floating-point number sequence is compressed using a preset compression method to obtain the target compressed data.

2. The method according to claim 1, characterized in that, Determining the first type of combination and the second type of combination in the result group sequence includes: According to the order of the result groups in the result group sequence, each result group is traversed sequentially, and when each result group is traversed, it is determined whether each XOR result included in the result group is 0. If so, then traverse the next result group until there is a non-zero XOR result in the traversed result group. The traversed result group that has not been assigned to any combination and whose XOR results are all 0 is determined as the first type of combination. If not, then the result group is classified as a second type of combination.

3. The method according to claim 2, characterized in that, The step of generating first stored data for each first-class combination based on the number of result groups in each first-class combination, and generating second stored data for each second-class combination based on the XOR result in each second-class combination, includes: When each first type of combination is determined, storage data including preset first identification information, first byte count, and first quantity of result groups in the first type of combination is generated as first storage data about the first type of combination; wherein, the first byte count is used to characterize the number of bytes occupied by the first quantity when storing the first quantity; When each second type of combination is determined, second stored data about that second type of combination is generated based on the distribution of 0s in each XOR result of that second type of combination.

4. The method according to claim 3, characterized in that, The step of generating second stored data about the second type of combination based on the distribution of 0s in each XOR result of the second type of combination includes: Based on the distribution of 0 in each XOR result of the second type of combination, generate first information or second information about the second type of combination as second stored data about the second type of combination; The first information includes: preset second identification information, number of common valid bits, number of common low-order zeros, and valid bit information; the second information includes: preset third identification information, number of common high-order zeros, and data information. The number of common low-order zeros is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the low-order zeros of each XOR result in the second type of combination; the low-order zeros of each XOR result are: the zeros before the first non-zero number in the order from the least significant bit to the most significant bit. The number of common valid bits is used to represent the maximum number of valid bits in each XOR result of the second type of combination. The valid bits of each XOR result are the bits occupied by each XOR result in the order from the highest bit to the lowest bit, from the first non-zero number to the last non-zero number. The number of common high-order zeros is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the high-order zeros of each XOR result in the second type of combination; the high-order zeros of each XOR result are: the zeros before the first non-zero number in the order from the highest bit to the lowest bit; The effective bit information is: the value of the common effective bit of each XOR result in the second type of combination, arranged according to the arrangement information of each XOR result in the second type of combination; the common effective bit of each XOR result is: the bits remaining after removing the number of common high-order 0 bits in the bit bits occupied by each XOR result in the order from the highest bit to the lowest bit, and removing the number of common low-order 0 bits in the order from the lowest bit to the highest bit; The data information includes: target information of each XOR result in the second type of combination, arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, the target information of the XOR result is a first value; if the XOR result is not 0, the target information of the XOR result includes: a second value, and the value of the remaining bits after removing the number of common high-order 0 bits in the XOR result in the order from the highest bit to the lowest bit.

5. The method according to claim 4, characterized in that, The generation of first or second information about the second type of combination as second stored data about the second type of combination includes: If the number of XOR results of 0 included in the second type of combination is less than the specified number, then first information about the second type of combination is generated as second stored data about the second type of combination; If the number of XOR results of 0 included in the second type of combination is not less than the specified number, then second information about the second type of combination is generated as second stored data about the second type of combination; or, Determine the first data quantity of the first information about the second type of combination and the second data quantity of the second information about the second type of combination; If the first data volume is less than the second data volume, then first information about the second type of combination is generated as second stored data about the second type of combination; If the first data volume is not less than the second data volume, then second information about the second type of combination is generated as second stored data about the second type of combination.

6. The method according to claim 3, characterized in that, Starting from the next storage location in the preset storage space where the first integer is located, the generated first storage data and second storage data are sequentially written into the preset storage space according to the order of the result groups in the result group sequence of each first type combination and each second type combination, including: Starting from the next storage location after the storage location of the first integer in the preset storage space, after generating each first storage data or second storage data, the first storage data or second storage data is sequentially written into the preset storage space.

7. The method according to any one of claims 1-6, characterized in that, The step of writing the first integer in the integer sequence into the preset storage space includes: In the preset storage space, the first integer in the integer sequence and the target number of integers in the integer sequence are written sequentially. Starting from the next storage location in the preset storage space where the first integer is located, the generated first storage data and second storage data are sequentially written into the preset storage space according to the order of the result groups in the result group sequence of each first type combination and each second type combination, including: Starting from the next storage location after the target quantity in the preset storage space, the generated first storage data and second storage data are sequentially written into the preset storage space according to the order of the result groups in the result group sequence of each first combination and each second combination. The step of determining the first integer, each first storage data, and each second storage data written in the preset storage space as the compressed data of the floating-point number sequence includes: The first integer, the target quantity, each first storage data, and each second storage data written in the preset storage space are determined as the compressed data of the floating-point number sequence.

8. The method according to any one of claims 1-6, characterized in that, Before converting the multiple floating-point numbers in the sequence of floating-point numbers to be compressed into integers to obtain an integer sequence, the method further includes: After the last floating-point number in the floating-point number sequence to be compressed, a preset floating-point number is added; wherein, the preset floating-point number is different from each of the floating-point numbers in the floating-point number sequence to be compressed. The step of converting multiple floating-point numbers in the sequence of floating-point numbers to be compressed into integers to obtain an integer sequence includes: Convert each floating-point number in the floating-point number sequence with the preset floating-point number to an integer to obtain an integer sequence.

9. The method according to any one of claims 1-6, characterized in that, The floating-point number sequence is a multimedia data sequence; the multimedia data includes at least one of video data, audio data, and image data.

10. A data decompression method, characterized in that, The method includes: Obtain the data to be decompressed, and read the first integer in the data to be decompressed; wherein the data to be decompressed is obtained by the data compression method according to any one of claims 1-9; According to the order in which the stored data is arranged in the data to be decompressed, each stored data in the data to be decompressed is read sequentially. When each piece of stored data is read, the stored data is parsed according to its content to obtain the corresponding XOR result. According to the order in which the XOR results are obtained, perform an XOR operation on each XOR result and the previous integer obtained to obtain the target integer corresponding to the XOR result. Convert each obtained integer into a floating-point number, and write the floating-point number corresponding to each integer into a floating-point number sequence according to the order in which the integers are obtained, to obtain the decompressed data corresponding to the data to be decompressed.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method of any one of claims 1-9 and / or the method of claim 10.

Citation Information

Patent Citations

  • Data compression algorithm based on XOR exponentiation and modulo operation

    CN115765751A

  • Erasure-based floating point type data lossless compression and decompression method

    CN116505951A