Data compression method, electronic device and storage medium

By using two encoding algorithms in the polysomnography monitoring device to compress the initial data sequence, the problem of large data transmission volume and low transmission efficiency is solved, and the full compression and efficient transmission of data are achieved.

CN113746485BActive Publication Date: 2025-05-16SHENZHEN SHULIAN TIANXIA INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110938795.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-16
Publication Date
2025-05-16
Estimated Expiration
2041-08-16

AI Technical Summary

Technical Problem

During the data transmission process, polysomnography monitoring equipment has a large number of channels, high sampling rate and large data volume, resulting in large data transmission volume and low transmission efficiency.

Method used

The initial data sequence is encoded by a preset first encoding algorithm to obtain a first data sequence, and then the first data sequence is encoded by a preset second encoding algorithm to obtain a second data sequence. By comparing the lengths of the second data sequence and the first data sequence, if the length of the second data sequence is less than the length of the first data sequence, it is determined that the target data sequence includes the second data sequence and the second identifier to achieve sufficient compression and transmission of the data.

Benefits of technology

This method can effectively reduce the amount of transmitted data, improve the transmission efficiency, accurately control the compressed data amount relative to the amount of data before compression, and ensure the effective secondary compression.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113746485B_ABST
    Figure CN113746485B_ABST
Patent Text Reader

Abstract

The embodiments of the present application relate to the technical field of data transmission, and disclose a data compression method, an electronic device, and a storage medium. The method first uses a first coding algorithm to perform a first compression on an initial data sequence, and then uses a second coding algorithm to perform a second compression, so that the initial data sequence can be fully compressed and the amount of data can be reduced as much as possible. In addition, by comparing the length of the second data sequence after the second compression with the length of the first data sequence after the first compression, the effectiveness of the secondary compression is ensured. Therefore, the amount of compressed data can be accurately controlled to be effectively reduced relative to the amount of data before compression, the amount of transmitted data can be reduced, and the transmission efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of data transmission, and in particular, to a data compression method, an electronic device, and a storage medium. Background Art

[0002] Polysomnography (PSG) is the most commonly used sleep monitoring device, which monitors the sleep state and health status by monitoring continuous breathing, arterial oxygen saturation, electroencephalogram, electrocardiogram, heart rate and other indicators during sleep. Specifically, PSG equipment generally includes a main control device and multiple data acquisition devices. The multiple data acquisition devices are used to collect physiological signals of the human body in the sleep state. The specific physiological signals include multiple real-time signals such as heart rate, temperature, electroencephalogram and audio. After the multiple data acquisition devices collect the physiological signals, they transmit each physiological signal to the main control device respectively, so that the main control device obtains each physiological signal for subsequent analysis to determine the sleep state and health status.

[0003] The data transmission between multiple data acquisition devices and the main control device has the characteristics of multiple channels, high sampling rate and large data volume, resulting in large data transmission volume and low transmission efficiency. Summary of the invention

[0004] The main technical problem solved by the embodiments of the present application is to provide a data compression method that can accurately control the amount of data after compression to effectively reduce the amount of data before compression, thereby reducing the amount of transmitted data and improving transmission efficiency.

[0005] In order to solve the above technical problems, in a first aspect, an embodiment of the present application provides a data compression method, comprising:

[0006] Acquire an initial data sequence to be compressed, where the initial data sequence is time-varying data collected within a preset time period;

[0007] Using a preset first encoding algorithm to encode the initial data sequence to obtain a first data sequence, wherein the length of the first data sequence is less than the length of the initial data sequence;

[0008] Using a preset second encoding algorithm to encode the first data sequence to obtain a second data sequence;

[0009] If the length of the second data sequence is less than the length of the first data sequence, it is determined that the target data sequence includes the second data sequence and a second identifier, wherein the target data sequence is used to obtain the initial data sequence after decoding, and the second identifier is used to indicate the identity of the second encoding algorithm.

[0010] In some embodiments, it also includes:

[0011] If the length of the second data sequence is greater than or equal to the length of the first data sequence, encoding the first data sequence using a preset third encoding algorithm to obtain a third data sequence;

[0012] If the length of the third data sequence is less than the length of the first data sequence, it is determined that the target data sequence includes the third data sequence and a third identifier, wherein the third identifier is used to indicate the identity of the third encoding algorithm.

[0013] In some embodiments, it also includes:

[0014] If the length of the third data sequence is greater than or equal to the length of the first data sequence, it is determined that the target data sequence includes the first data sequence and a first identifier, and the first identifier is used to indicate the identity of the first encoding algorithm.

[0015] In some embodiments, the using a preset first encoding algorithm to encode the initial data sequence to obtain a first data sequence includes:

[0016] Determine predicted data corresponding to the i-th data according to first two data of the i-th data in the initial data sequence, wherein 2<i≤N, and N is the number of data in the initial data sequence;

[0017] Determine the prediction error corresponding to the i-th data as the difference between the i-th data and the predicted data corresponding to the i-th data;

[0018] Determine that the first data sequence includes the first two data in the initial data sequence and (N-2) prediction errors.

[0019] In some embodiments, determining predicted data corresponding to the i-th data according to first two data of the i-th data in the initial data sequence includes:

[0020] The predicted data corresponding to the i-th data is determined to be twice the (i-1)-th data minus the (i-2)-th data.

[0021] In some embodiments, the using a preset second encoding algorithm to encode the first data sequence to obtain a second data sequence includes:

[0022] Encoding the prediction error corresponding to the i-th data to obtain first encoded data corresponding to the i-th data;

[0023] It is determined that the second data sequence includes the first two data in the initial data sequence and (N-2) first encoded data.

[0024] In some embodiments, encoding the prediction error corresponding to the i-th data to obtain first encoded data corresponding to the i-th data includes:

[0025] Determining a parameter value corresponding to the initial data sequence according to the (N-2) prediction errors;

[0026] Performing a quotient operation on the prediction error corresponding to the i-th data and the parameter value to obtain a quotient value, and performing unary encoding on the quotient value to obtain a unary encoding result;

[0027] Performing a modulo operation on the prediction error corresponding to the i-th data and the parameter value to obtain a remainder value, and performing binary encoding on the remainder value to obtain a binary encoding result;

[0028] Determine a first sign bit according to a positive or negative attribute of a prediction error corresponding to the i-th data;

[0029] Determine that the first coded data corresponding to the i data includes the first sign bit, the binary coding result and the unary coding result.

[0030] In some embodiments, encoding the first data sequence using a preset third encoding algorithm to obtain a third data sequence includes:

[0031] Removing a sign byte from the prediction error corresponding to the i-th data to obtain an unsigned byte, wherein the sign byte is used to indicate a positive or negative attribute of the prediction error;

[0032] The second encoded data corresponding to the i-th data is formed by concatenating the byte length of the second encoded data, the second sign bit and the unsigned byte, and the second sign bit is used to indicate the positive or negative attribute of the prediction error corresponding to the i-th data;

[0033] The third data sequence includes the first two data in the initial data sequence and (N-2) second encoded data.

[0034] To solve the above technical problems, in a second aspect, an embodiment of the present application provides an electronic device, comprising a memory and one or more processors, wherein the one or more processors are used to execute one or more computer programs stored in the memory, and when the one or more processors execute the one or more computer programs, the electronic device implements the method described in the first aspect.

[0035] To solve the above technical problems, in a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method described in the first aspect.

[0036] Beneficial effects of the embodiments of the present application: Different from the prior art, the data compression method provided by the embodiments of the present application, first, adopts a preset first encoding algorithm to encode the initial data sequence to be compressed to obtain a first data sequence, so that the length of the first data sequence is reduced relative to the length of the initial data sequence, and then adopts a preset second encoding algorithm to encode the first data sequence to obtain a second data sequence, that is, further perform secondary compression, and finally, compare the length of the second data sequence with the length of the first data sequence. If the length of the second data sequence is less than the length of the first data sequence, it is determined that the target data sequence (that is, the final compressed data) includes the second data sequence and the second identifier, so that the target data sequence is transmitted, which can effectively reduce the transmission amount, wherein the second identifier is used to indicate the identity of the second encoding algorithm, so as to facilitate the decompression of the target data sequence. That is, the method first uses a first encoding algorithm to compress the initial data sequence once, and then uses a second encoding algorithm to perform a second compression, so that the initial data sequence can be fully compressed and the amount of data can be reduced as much as possible, and the length of the second data sequence after the second compression is compared with the length of the first data sequence after the first compression to ensure that the secondary compression is effective. Therefore, the amount of compressed data can be accurately controlled to be effectively reduced relative to the amount of data before compression, which can reduce the amount of transmitted data and improve transmission efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0038] Figure 1 A schematic diagram of the structure of a polysomnography monitor provided in one embodiment of the present application;

[0039] Figure 2 A structural block diagram of an electronic device provided in one embodiment of the present application;

[0040] Figure 3 A flowchart of a data compression method provided in one embodiment of the present application;

[0041] Figure 4 A flowchart of a data compression method provided by another embodiment of the present application;

[0042] Figure 5 for Figure 3 A schematic diagram of a sub-process of step S22 in the method shown;

[0043] Figure 6 A schematic diagram of a prediction error provided by an embodiment of the present application;

[0044] Figure 7 A schematic diagram of the structure of an initial data sequence and a first data sequence provided in an embodiment of the present application;

[0045] Figure 8 for Figure 3 A schematic diagram of a sub-process of step S23 in the method shown;

[0046] Fig. 9 for Figure 8 A schematic diagram of a sub-process of step S231 in the method shown;

[0047] Fig.10 for Figure 3 A schematic diagram of a sub-process of step S25 in the method shown. DETAILED DESCRIPTION

[0048] The present application is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present application, but do not limit the present application in any form. It should be noted that, for those of ordinary skill in the art, several variations and improvements can also be made without departing from the concept of the present application. These all belong to the protection scope of the present application.

[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] It should be noted that, if there is no conflict, the various features in the embodiments of the present application can be combined with each other, all within the scope of protection of the present application. In addition, although the functional module division is performed in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a sequence different from the module division in the device or the flow chart. In addition, the words "first", "second", "third", etc. used herein do not limit the data and execution order, but only distinguish the same items or similar items with basically the same functions and effects.

[0051] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used in this specification and in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.

[0052] In addition, the technical features involved in each embodiment of the present application described below can be combined with each other as long as they do not conflict with each other.

[0053] In some embodiments, see Figure 1 , is a structural diagram of a polysomnography monitor provided in an embodiment of the present application, the polysomnography monitor 100 comprises a main control device 10 and a plurality of data acquisition devices 20, and the plurality of data acquisition devices 20 are respectively connected to the main control device 10 for communication. The plurality of data acquisition devices 20 are used to collect physiological signals (data) of the user in the sleep state, and then transmit the collected data to the main control device 10 respectively, and the main control device 10 determines the sleep state and health state of the user according to the data.

[0054] Among them, the communication connection can be a wired connection (network cable connection) or a wireless connection, and the wireless connection includes Bluetooth, wifi or 4G, 5G, etc.

[0055] Among them, a data acquisition device 20 includes a controller and a sensor (not shown). The sensor can be set according to the data to be collected, so that each data acquisition device is responsible for collecting different time-varying signals. For example, data acquisition device 1# includes a heart rate sensor for collecting heart rate signals, and data acquisition device 2# includes a temperature sensor for collecting temperature signals. Each data acquisition device sends the data collected within a preset time (for example, 0.5s or 1s) to the main control device, so that the main control device obtains the time-varying signals of each sensor for subsequent analysis or display. In some embodiments, the data acquisition device 20 also includes a memory, which is used to cache data to be transmitted or store some program instructions. In some embodiments, the program instructions include instructions for processing the collected data, or instructions for controlling the sensor, such as the acquisition frequency.

[0056] The main control device 10 includes a controller, a memory or a display screen (not shown) to improve the running speed and the smoothness of the communication process. It is understandable that the main control device 10 can be paired with multiple data acquisition devices 20 and communicate, thereby receiving data collected by multiple data acquisition devices 20 and issuing relevant instructions to multiple data acquisition devices 20. The display screen is used to display the collected time-varying data or the analysis results obtained based on the collected time-varying data.

[0057] During the data transmission process, the data acquisition device 20 acquires and stores each time-varying signal of the sensor in real time, and transmits each time-varying signal to the main control device 10 .

[0058] Based on the structure of the polysomnography monitor 100 described above, in order to reduce the amount of transmitted data and improve transmission efficiency, in some embodiments, before transmitting the data, the data acquisition device 20 compresses the collected data to reduce the amount of transmitted data.

[0059] One embodiment of the present application provides an electronic device, which may be the above-mentioned data acquisition device, or other devices that need to transmit data, such as radar or smart camera. Figure 2 , is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. Specifically, the electronic device 200 includes at least one processor 210 and a memory 220 ( Figure 2 (a bus connection and a processor are used as an example).

[0060] The processor 210 is used to provide computing and control capabilities to control the electronic device 200 to perform corresponding tasks, for example, to control the electronic device 200 to perform any one of the data compression methods provided in at least one of the following embodiments.

[0061] It is understandable that the processor 210 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0062] The memory 220, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the data compression method in the embodiment of the present application. The processor 210 can implement the data compression method in any of the following method embodiments by running the non-transitory software programs, instructions and modules stored in the memory 220. Specifically, the memory 220 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device.

[0063] The following describes in detail the data compression methods provided by some embodiments of the present application. Figure 3 The data compression method S20 includes but is not limited to the following steps:

[0064] S21: Acquire an initial data sequence to be compressed, where the initial data sequence is time-varying data collected within a preset time period.

[0065] S22: Using a preset first encoding algorithm to encode the initial data sequence to obtain a first data sequence, wherein the length of the first data sequence is smaller than the length of the initial data sequence.

[0066] S23: using a preset second encoding algorithm to encode the first data sequence to obtain a second data sequence.

[0067] S24: If the length of the second data sequence is less than the length of the first data sequence, it is determined that the target data sequence includes the second data sequence and a second identifier, wherein the target data sequence is used to obtain the initial data sequence after decoding, and the second identifier is used to indicate the identity of the second encoding algorithm.

[0068] Among them, the initial data sequence can be the time-varying data collected by the data acquisition device in the above embodiment within a preset time. The time-varying data is data that changes with time and is arranged on a time axis, such as heart rate or temperature collected within 2 hours of sleep time. Before transmitting the data, the initial data sequence is compressed, that is, the amount of data is reduced without losing useful information, which is equivalent to reducing the number of bytes occupied by the initial data to reduce storage space and improve its transmission, storage and processing efficiency. In some embodiments, the data to be transmitted can also be compressed in groups, such as compressing 1s or 0.5s data as a group, without affecting the real-time transmission of data.

[0069] First, a preset first encoding algorithm is used to encode the initial data sequence to obtain a first data sequence, so that the length of the first data sequence is less than the length of the initial data sequence. The length refers to the number of bytes occupied by the data sequence. In this step, it is equivalent to compressing the initial data sequence. The first encoding algorithm is a data compression algorithm. In some embodiments, the first encoding algorithm can be an existing Huffman compression algorithm or an LZ77 algorithm.

[0070] Then, the first data sequence is encoded using a preset second encoding algorithm to obtain a second data sequence, that is, further secondary compression is performed. The second encoding algorithm is another data compression algorithm. In some embodiments, the second encoding algorithm can be an existing Lempel-Ziv Markov chain Algorithm (LZMA) or a multi-layer perceptron (MLP).

[0071] Finally, the length of the second data sequence is compared with the length of the first data sequence. If the length of the second data sequence is less than the length of the first data sequence, that is, the number of bytes occupied by the second data sequence is less than the number of bytes occupied by the first data sequence, it is determined that the target data sequence (that is, the final compressed data) includes the second data sequence and the second identifier, so that the target data sequence is transmitted, which can effectively reduce the transmission amount, wherein the second identifier is used to indicate the identity of the second encoding algorithm, so as to facilitate the decompression of the target data sequence. In some embodiments, the second identifier can be a specific symbol, number or letter.

[0072] In this embodiment, the initial data sequence is first compressed once using a first encoding algorithm, and then compressed twice using a second encoding algorithm, so that the initial data sequence can be fully compressed and the amount of data can be reduced as much as possible. In addition, the length of the second data sequence after the secondary compression is compared with the length of the first data sequence after the primary compression to ensure that the secondary compression is effective. Therefore, the amount of compressed data can be accurately controlled to be effectively reduced relative to the amount of data before compression, which can reduce the amount of transmitted data and improve transmission efficiency.

[0073] In some embodiments, see Figure 4 , the method S20 further includes:

[0074] S25: If the length of the second data sequence is greater than or equal to the length of the first data sequence, use a preset third encoding algorithm to encode the first data sequence to obtain a third data sequence.

[0075] S26: If the length of the third data sequence is less than the length of the first data sequence, determine that the target data sequence includes the third data sequence and a third identifier, wherein the third identifier is used to indicate the identity of the third encoding algorithm.

[0076] If the length of the second data sequence after secondary compression is greater than or equal to the length of the first data sequence, it means that the secondary compression fails. In this embodiment, a preset third encoding algorithm is used to encode the first data sequence to obtain a third data sequence. That is, another encoding algorithm is used for secondary compression. The third encoding algorithm is another data compression algorithm. In some embodiments, the third encoding algorithm can be an existing LZR algorithm or a DEFLATE algorithm.

[0077] Then, the length of the third data sequence is compared with the length of the first data sequence. If the length of the third data sequence is less than the length of the first data sequence, that is, the number of bytes occupied by the third data sequence is less than the number of bytes occupied by the first data sequence, it is determined that the target data sequence includes the third data sequence and the third identifier. The third identifier is used to indicate the identity of the third encoding algorithm to facilitate decompression of the target data sequence. In some embodiments, the third identifier can be a specific symbol, number or letter.

[0078] In this embodiment, when the secondary compression using the second coding algorithm fails, another third coding algorithm is used to perform secondary compression on the first data sequence to ensure sufficient compression and reduce the amount of data as much as possible. In addition, the effectiveness of the secondary compression is ensured by comparing the length of the third data sequence after the secondary compression using the third coding algorithm with the length of the first data sequence after the primary compression. Therefore, the ineffectiveness of the secondary compression is effectively avoided, and the amount of compressed data can be accurately controlled to be effectively reduced relative to the amount of data before compression, which can reduce the amount of transmitted data and improve transmission efficiency.

[0079] In some embodiments, see Figure 4 , the method S20 further includes:

[0080] S27: If the length of the third data sequence is greater than or equal to the length of the first data sequence, it is determined that the target data sequence includes the first data sequence and a first identifier, where the first identifier is used to indicate the identity of the first encoding algorithm.

[0081] If the length of the third data sequence compressed by the third coding algorithm is greater than or equal to the length of the first data sequence, it means that the secondary compression performed by the third coding algorithm is invalid. In this embodiment, the first data sequence and the first identifier obtained by the compression of the first coding algorithm are directly used as the target data sequence, that is, no secondary compression is performed. Among them, the first identifier is used to indicate the identity of the first coding algorithm, which is convenient for the subsequent decompression of the target data sequence. In some embodiments, the first identifier can be a specific symbol, number or letter.

[0082] In this embodiment, when the secondary compression performed by the third encoding algorithm fails, the result after the primary compression is used as the final compression result, which can avoid the increase of the data volume of the final compression result due to the secondary compression.

[0083] In some embodiments, see Figure 5 , step S22 specifically includes:

[0084] S221: Determine predicted data corresponding to the ith data according to first two data of the ith data in the initial data sequence, wherein 2<i≤N, and N is the number of data in the initial data sequence.

[0085] S222: Determine that the prediction error corresponding to the i-th data is the difference between the i-th data and the predicted data corresponding to the i-th data.

[0086] S223: Determine that the first data sequence includes the first two data in the initial data sequence and (N-2) prediction errors.

[0087] Based on 2<i≤N, N is the number of data in the initial data sequence, and in the initial data sequence, the N data are arranged in time domain order, and the i-th data in the initial data sequence is any data except the first two data (i.e., the first data and the second data) in the initial data sequence.

[0088] That is, for any data except the first two data in the initial data sequence, the corresponding prediction error is determined by the method in step S221 to step S223. Here, the specific process of step S221 to step S223 is exemplarily described by taking the i-th data as an example.

[0089] First, the predicted data corresponding to the ith data is determined according to the first two data of the ith data, that is, the predicted data corresponding to the ith data is determined according to the (i-1)th data and the (i-2)th data.

[0090] It can be understood that the initial data sequence is continuous in the time domain, so that adjacent data fluctuate less, that is, the difference between the (i-2)th data, the (i-1)th data and the i-th data is small. Therefore, the next data can be predicted based on the previous two data, that is, the i-th data can be predicted based on the (i-2)th data and the (i-1)th data, so that the i-th data is connected with the (i-2)th data and the (i-1)th data.

[0091] In some embodiments, step S221 specifically includes: determining that the predicted data corresponding to the i-th data is twice the (i-1)-th data minus the (i-2)-th data.

[0092] Specifically, the following formula is used to calculate the predicted data yi' corresponding to the i-th data yi;

[0093] y i '-y (i-1) =y (i-1) -y (i-2) ;

[0094] yi'=2*y (i-1) -y (i-2) ;

[0095] In this implementation, if Figure 6 As shown, a first-order function related to time is established through the (i-2)th data and the (i-1)th data, and then, the predicted data yi' corresponding to the i-th data can be accurately predicted according to the first-order function.

[0096] Then, the difference between the i-th data yi and the predicted data yi' corresponding to the i-th data is taken as the corresponding prediction error, that is, the prediction error xi = yi'-yi.

[0097] It can be understood that, in the initial data sequence, when 2<i≤N, each data corresponds to a prediction error, and (N-2) prediction errors are obtained.

[0098] Finally, if Figure 7 As shown, the first two data (i.e., the first data and the second data) in the initial data sequence and (N-2) prediction errors are arranged in the time sequence in the initial data sequence to obtain the first data sequence. When decoding, the actual yi can be inferred from the prediction error xi, so that the original data information will not be lost.

[0099] It can be understood that since any prediction error xi in the first data sequence is smaller than the original i-th data yi, the number of bytes occupied by xi will also be correspondingly smaller, thereby making the length of the first data sequence smaller than the length of the initial data sequence, that is, the initial data sequence can be effectively compressed.

[0100] It can be understood that the closer the predicted data yi' is to the initial data yi, the more accurate it is, and the smaller the corresponding prediction error xi is, and the smaller the number of bytes it occupies. In order to make the predicted data yi' more accurate and the prediction error xi smaller, in some embodiments, a more accurate higher-order function can be established based on the (i-2)th data and the (i-1)th data, and using the higher-order function to predict yi' can obtain a more accurate yi' and a smaller prediction error xi.

[0101] In this embodiment, through the above method, the length of the first data sequence is made smaller than the length of the initial data sequence, that is, it is effectively compressed without losing the original data information, and the algorithm is simple, runs fast and efficiently, which further helps to improve the data transmission efficiency.

[0102] For further secondary compression, in some embodiments, see Figure 8 , step S23 specifically includes:

[0103] S231: Encode the prediction error corresponding to the i-th data to obtain first encoded data corresponding to the i-th data.

[0104] S232: Determine that the second data sequence includes the first two data in the initial data sequence and (N-2) first coded data.

[0105] In this embodiment, the (N-2) prediction errors in the first data sequence are encoded to further reduce the number of bytes occupied by each prediction error to obtain corresponding first encoded data. That is, the number of bytes occupied by the first encoded data corresponding to the i-th data is less than the number of bytes occupied by the corresponding prediction data.

[0106] Then, the first two data in the initial data sequence and (N-2) first coded data are arranged in the time sequence in the initial data sequence to obtain a second data sequence. It can be understood that the encoding in this embodiment is used to further reduce the prediction error. In some implementations, the prediction error can be subtracted from a set value, or divided by a set value to obtain the corresponding first coded data.

[0107] In this embodiment, the (N-2) prediction errors in the first data sequence are encoded to further reduce the number of bytes occupied by each prediction error and obtain corresponding first encoded data, so that the length of the second data sequence including the first two data in the initial data sequence and the (N-2) first encoded data is further reduced, thereby achieving secondary compression.

[0108] In some embodiments, see Fig. 9 , step S231 specifically includes:

[0109] S2311: Determine the parameter value corresponding to the initial data sequence based on the (N-2) prediction errors.

[0110] S2312: performing a quotient operation on the prediction error corresponding to the i-th data and the parameter value to obtain a quotient value, and performing unary encoding on the quotient value to obtain a unary encoding result.

[0111] S2313: performing a modulo operation on the prediction error corresponding to the i-th data and the parameter value to obtain a remainder value, and performing binary encoding on the remainder value to obtain a binary encoding result.

[0112] S2314: Determine a first sign bit according to the positive or negative attribute of the prediction error corresponding to the i-th data.

[0113] S2315: Determine that the first encoded data corresponding to the i data includes the first sign bit, the binary encoding result and the unary encoding result.

[0114] In this embodiment, first, according to (N-2) prediction errors xi, 3≤i≤N, the parameter value M corresponding to the initial data sequence is determined, and the parameter value M is used to encode each prediction error xi to further reduce each prediction error xi.

[0115] In some embodiments, the parameter value M is determined by the following formula:

[0116] M=2 k

[0117]

[0118] Wherein, α is a weight coefficient, and in some embodiments, α is 0.7.

[0119] Then, the prediction error xi corresponding to the i-th data is divided by the parameter value to obtain the quotient value qi (qi=xi / M), and the quotient value qi is unary encoded to obtain the unary encoding result ui.

[0120] It is understandable that the unary code can be represented by 0 or 1, and then distinguished by a separator. Taking 0 as an example, the unary code result ui corresponding to qi is qi 0s and a 1 for distinction. The unary code result is shown in Table 1 below:

[0121] Table 1

[0122] qi Unary encoding result (output bit) 0 1 1 01 2 001 3 0001 ... ... N 00......001(N zeros)

[0123] Then, the prediction error xi corresponding to the i-th data is modulo the parameter value to obtain the residual value ri, which is ri=abs(xi)%M. The residual value ri is binary-coded to obtain the binary coding result bi. The binary coding result is shown in Table 2 below:

[0124] Table 2

[0125] ri Binary encoding result (output bit) 0 000 1 001 2 010 3 011 ... ... 7 111

[0126] The first sign bit is determined according to the positive and negative attribute of the prediction error xi corresponding to the i-th data. It can be understood that the first sign bit represents the positive and negative attribute of the i-th data. For example, when xi is a negative number, the first sign bit fi is 1, and when xi is a positive number, the first sign bit fi is 0.

[0127] Finally, the first symbol bit fi, the binary encoding result bi and the unary encoding result ui are combined into the first encoded data ci. It can be understood that the order of the first symbol bit fi, the binary encoding result bi and the unary encoding result ui can be set arbitrarily, as long as the order is kept consistent during compression and decompression. For example, the first encoded data ci = (fi, bi, ui).

[0128] The following is an illustrative description using the prediction error xi=10, k=3 as an example.

[0129] From k=3, we can get:

[0130] Parameter value M = 2 3 =8;

[0131] The quotient qi=xi / M=10 / 8=1; qi is encoded in unary and the unary encoding result ui=01 is obtained.

[0132] Remainder ri=abs(xi)%M=abs(10)%8=2; binary code ri to obtain the binary coding result bi=010.

[0133] The first sign bit fi=0, where 0 represents a positive number.

[0134] The first coded data ci=(fi,bi,ui)=001001 obtained after merging.

[0135] It can be seen that the prediction error xi=10 originally occupies 1 byte, and after compression, it becomes a 6-bit data ci.

[0136] It can be understood that the parameter value k also needs to be stored together with the second data sequence, which is equivalent to, in this embodiment, the target data sequence includes the parameter value k, the second data sequence and the second identifier, wherein the parameter value k is used for decoding.

[0137] In this embodiment, the above method can effectively encode the (N-2) prediction errors in the first data sequence to further reduce the number of bytes occupied by each prediction error and obtain the corresponding first encoded data, so that the length of the second data sequence including the first two data in the initial data sequence and the (N-2) first encoded data is further reduced, thereby achieving secondary compression.

[0138] In some embodiments, the second identifier used to represent the identity of the second encoding algorithm may be the parameter value k. Based on the fact that the first identifier used to represent the identity of the first encoding algorithm may be a specific symbol, number or letter, the third identifier used to represent the identity of the third encoding algorithm may be a specific symbol, number or letter, for example, the first identifier is 0, the third identifier is 1, and the parameter value k calculated by the above formula is greater than 1. Therefore, setting the second identifier to the parameter value k, on the one hand, can be distinguished from the first identifier and the third identifier, that is, it can characterize the identity of the second encoding algorithm, and on the other hand, the parameter value k also needs to be stored together with the second data sequence, that is, it is equivalent to the target data sequence including the parameter value k for use in decoding. Using the same data for the parameter value and the second identifier can reduce the length of the target data sequence.

[0139] In some embodiments, see Fig.10 , step S25 specifically includes:

[0140] S251: removing the sign byte in the prediction error corresponding to the i-th data to obtain an unsigned byte, wherein the sign byte is used to indicate the positive or negative attribute of the prediction error.

[0141] S252: The second encoded data corresponding to the i-th data is concatenated by the byte length of the second encoded data, the second sign bit and the unsigned byte, and the second sign bit is used to indicate the positive or negative attribute of the prediction error corresponding to the i-th data.

[0142] S253: The third data sequence includes the first two data in the initial data sequence and (N-2) second coded data.

[0143] It can be understood that the prediction error xi is a small value, so the head of the prediction error xi has some sign bytes used to indicate its positive and negative attributes. For example, if the prediction error xi is a 32-bit integer, such as 100, the prediction error xi before compression by the third encoding algorithm is: 00000000 00000000 00000000 01100100, that is, a 4-byte data, in which the first 3 bytes represent positive and negative attributes, occupying too many bytes, resulting in byte waste, and the last one is an unsigned byte "01100100". It can be understood that the unsigned byte "01100100" represents the value "100" of the prediction error xi.

[0144] In order to reduce the length of the prediction error xi, the sign byte in the prediction error xi is removed to obtain an unsigned byte, and then the positive and negative attributes of the prediction error are represented by the second sign bit. The second sign bit can effectively shorten the data length relative to the original multiple sign bytes. Therefore, the byte length, the second sign bit and the unsigned byte of the second coded data are concatenated to form the second coded data corresponding to the prediction error xi, which can effectively shorten the data length.

[0145] Specifically, for the prediction error xi before compression by the third encoding algorithm, 00000000 0000000000000000 01100100, the second encoded data after compression is 01000000 01100100, where the first two bits "01" of the first byte represent that the second encoded data occupies 2 bytes in total, the remaining bits of the first byte represent the sign (positive and negative attributes), and the second byte is still the original unsigned byte. Compared with the prediction error xi before compression, 2 bytes can be saved.

[0146] It can be understood that when the number of bits occupied by the value of the prediction error xi is less than or equal to 5, for example, the unsigned byte corresponding to the prediction error xi (decimal value 3) is "00000011", and the second coded data obtained by splicing the unsigned byte with the length of the second coded data (1, corresponding to 1 byte) and the second sign bit (0, positive number) is "10000011". Here, for the convenience of description, the bits in the unsigned byte other than the bits occupied by the value are called padding bits, for example, the first 6 bits in "00000011" are padding bits.

[0147] It can be understood that in this embodiment, the sign byte is removed as much as possible. When concatenating the unsigned byte and the length of the second encoded data and the second sign bit, if the padding bits in the unsigned byte can accommodate the length of the second encoded data and at least one bit for representing the sign, the compressed second encoded data is one byte. If the padding bits in the unsigned byte cannot accommodate the length of the second encoded data and at least one bit for representing the sign, a byte is added before the unsigned byte, and the added byte includes the length of the second encoded data and the second sign bit.

[0148] The (N-2) prediction errors are encoded in the above manner to obtain (N-2) second encoded data. The first two data in the initial data sequence and the (N-2) second encoded data are arranged according to the time sequence in the initial data sequence to obtain a third data sequence.

[0149] In summary, the data compression method provided by the embodiment of the present application firstly uses a preset first coding algorithm to encode the initial data sequence to be compressed to obtain a first data sequence, so that the length of the first data sequence is reduced relative to the length of the initial data sequence, and then uses a preset second coding algorithm to encode the first data sequence to obtain a second data sequence, that is, further perform secondary compression, and finally, compare the length of the second data sequence with the length of the first data sequence. If the length of the second data sequence is less than the length of the first data sequence, it is determined that the target data sequence (that is, the data after final compression) includes the second data sequence and the second identifier, so that the target data sequence is transmitted, which can effectively reduce the transmission amount, wherein the second identifier is used to indicate the identity of the second coding algorithm, which is convenient for decompressing the target data sequence. That is, the method first uses the first coding algorithm to perform a primary compression on the initial data sequence, and then uses the second coding algorithm to perform a secondary compression, so that the initial data sequence can be fully compressed and the data amount can be reduced as much as possible, and the length of the second data sequence after the secondary compression is compared with the length of the first data sequence after the primary compression to ensure that the secondary compression is effective, so that the amount of compressed data can be effectively reduced relative to the amount of data before compression, and the amount of transmitted data can be reduced, and the transmission efficiency can be improved. For example, for a whole night of PSG data, the amount of data after compression is only about 30% of the original.

[0150] Another embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions, which, when executed by a processor, enable the processor to execute the data compression method in any of the above embodiments.

[0151] It should be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0152] Through the description of the above implementation methods, ordinary technicians in this field can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Ordinary technicians in this field can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes in different aspects of the present application as described above, which are not provided in detail for the sake of simplicity. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A data compression method, characterized in that: include: Acquire an initial data sequence to be compressed, where the initial data sequence is time-varying data collected within a preset time period; Using a preset first encoding algorithm to encode the initial data sequence to obtain a first data sequence, wherein the length of the first data sequence is less than the length of the initial data sequence; Using a preset second encoding algorithm to encode the first data sequence to obtain a second data sequence; If the length of the second data sequence is less than the length of the first data sequence, determining that the target data sequence includes the second data sequence and a second identifier, wherein the target data sequence is used to obtain the initial data sequence after decoding, and the second identifier is used to indicate the identity of the second encoding algorithm; The adopting a preset first encoding algorithm to encode the initial data sequence to obtain a first data sequence includes: Determine predicted data corresponding to the i-th data according to first two data of the i-th data in the initial data sequence, wherein 2<i≤N, and N is the number of data in the initial data sequence; Determine the prediction error corresponding to the i-th data as the difference between the i-th data and the predicted data corresponding to the i-th data; Determine that the first data sequence includes the first two data in the initial data sequence and (N-2) prediction errors; The adopting a preset second encoding algorithm to encode the first data sequence to obtain a second data sequence includes: Encoding the prediction error corresponding to the i-th data to obtain first encoded data corresponding to the i-th data; Determine that the second data sequence includes the first two data in the initial data sequence and (N-2) first coded data; The step of encoding the prediction error corresponding to the i-th data to obtain first encoded data corresponding to the i-th data includes: Determining a parameter value corresponding to the initial data sequence according to the (N-2) prediction errors; Performing a quotient operation on the prediction error corresponding to the i-th data and the parameter value to obtain a quotient value, and performing unary encoding on the quotient value to obtain a unary encoding result; Performing a modulo operation on the prediction error corresponding to the i-th data and the parameter value to obtain a remainder value, and performing binary encoding on the remainder value to obtain a binary encoding result; Determine a first sign bit according to a positive or negative attribute of a prediction error corresponding to the i-th data; Determine that the first coded data corresponding to the i data includes the first sign bit, the binary coding result and the unary coding result.

2. The method according to claim 1, characterized in that Also includes: If the length of the second data sequence is greater than or equal to the length of the first data sequence, encoding the first data sequence using a preset third encoding algorithm to obtain a third data sequence; If the length of the third data sequence is less than the length of the first data sequence, it is determined that the target data sequence includes the third data sequence and a third identifier, wherein the third identifier is used to indicate the identity of the third encoding algorithm.

3. The method according to claim 2, characterized in that Also includes: If the length of the third data sequence is greater than or equal to the length of the first data sequence, it is determined that the target data sequence includes the first data sequence and a first identifier, and the first identifier is used to indicate the identity of the first encoding algorithm.

4. The method according to claim 1, characterized in that The determining, based on first two data of the i-th data in the initial data sequence, predicted data corresponding to the i-th data includes: The predicted data corresponding to the i-th data is determined to be twice the (i-1)-th data minus the (i-2)-th data.

5. The method according to claim 2 or 3, characterized in that: The adopting a preset third encoding algorithm to encode the first data sequence to obtain a third data sequence includes: Removing a sign byte from the prediction error corresponding to the i-th data to obtain an unsigned byte, wherein the sign byte is used to indicate a positive or negative attribute of the prediction error; The second encoded data corresponding to the i-th data is formed by concatenating the byte length of the second encoded data, the second sign bit and the unsigned byte, and the second sign bit is used to indicate the positive or negative attribute of the prediction error corresponding to the i-th data; The third data sequence includes the first two data in the initial data sequence and (N-2) second encoded data.

6. An electronic device, characterized in that: The electronic device comprises a memory and one or more processors, wherein the one or more processors are used to execute one or more computer programs stored in the memory, and when the one or more processors execute the one or more computer programs, the electronic device implements the method as described in any one of claims 1 to 5.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data compressing method and device of server

    CN105630999A