Adaptive compression method and device for time series signal
Patent Information
- Application Number
- CN202611113899.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-08-21
AI Technical Summary
[0005]本申请提供一种时序信号的自适应压缩方法及装置,旨在解决资源受限设备的一维时序信号实时压缩中,计算存储资源有限、信号波动特性随时间变化以及压缩效率与重构保真度难以兼顾的技术问题
[0018]This application provides an adaptive compression method and apparatus for time-series signals. The method acquires the time-series signal to be compressed and determines the starting sample point of the current segment. When reading subsequent current sample points, it determines the target compression level from multiple compression levels based on the change relationship between the current sample point and the starting sample point of the current segment. This allows the compression process to adaptively select appropriate trend constraints, residual encoding, and segment length control methods based on the degree of local fluctuations in the time-series signal. Simultaneously, by continuously updating the trend constraint content of multiple compression levels based on the current sample point, and determining whether to trigger segmented output based on the target compression level, it ensures that gently changing segments can be extended as much as possible to reduce the amount of output data, while drastically changing segments can be segmented in a timely manner to avoid excessive loss of waveform details. Furthermore, during segmented output, a linear prediction benchmark is established based on the starting and ending sample points of the current segment, and only the residual information of intermediate sample points is encoded and output. This reduces the amount of data directly stored or transmitted from the original sampled data while preserving the signal change characteristics within the segment. Therefore, this application can alleviate the problems of limited computing and storage resources, signal fluctuation characteristics changing over time, and difficulty in balancing compression efficiency and reconstruction fidelity in real-time compression scenarios of one-dimensional time-series signals in resource-constrained devices.
Smart Images

Figure CN122621176A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of data processing technology, and in particular relates to an adaptive compression method and apparatus for time-series signals. Background Technology
[0002] With the development of IoT terminals, wearable devices, industrial monitoring equipment, and medical monitoring equipment, various sensors need to continuously collect one-dimensional time-series signals such as electrocardiograms, acceleration, pressure, temperature, and sound. These signals are typically characterized by short sampling periods, strong continuity, and large data volumes, consuming significant storage space, communication bandwidth, and power resources during local storage or wireless transmission. Especially in resource-constrained devices such as low-power microcontrollers and wireless sensor nodes, effectively compressing continuously sampled signals within limited storage capacity and computing power is a crucial issue in time-series data processing.
[0003] Existing time-series data compression methods typically include transform coding, dictionary coding, and compression methods based on linear approximation. Transform coding and dictionary coding usually require significant data buffering and computational resources when processing long data sequences, which is not conducive to real-time processing in low-power embedded devices. While compression methods based on linear approximation are simpler in structure and lower in implementation cost, they are easily limited by fixed compression parameters or a single adjustment method when dealing with signals whose fluctuation characteristics change over time. For example, the same signal may contain both slowly changing segments and rapidly changing segments. If the compression constraints are set too strictly, it can easily lead to a large number of segments and a decrease in compression efficiency; if the compression constraints are set too loosely, it may cause the loss of local waveform details, affecting the fidelity of the reconstructed signal.
[0004] Therefore, in the real-time compression of one-dimensional time-series signals on resource-constrained devices, the limited computing and storage resources, the time-varying characteristics of signal fluctuations, and the difficulty in balancing compression efficiency and reconstruction fidelity have become urgent problems to be solved. Summary of the Invention
[0005] This application provides an adaptive compression method and apparatus for time-series signals, aiming to solve the technical problems of limited computing and storage resources, changes in signal fluctuation characteristics over time, and the difficulty in balancing compression efficiency and reconstruction fidelity in real-time compression of one-dimensional time-series signals in resource-constrained devices.
[0006] In a first aspect, this application provides an adaptive compression method for time-series signals, the method comprising: Acquire the timing signal to be compressed, and determine the starting sample point of the current segment from the timing signal; The current sample points after the starting sample point of the current segment are read according to the sampling order. Based on the change relationship of the current sample points relative to the starting sample point of the current segment, and the gear control information corresponding to multiple preset compression gears, the target compression gear corresponding to the current segment is determined from the multiple compression gears. The gear control information is used to perform trend constraints on the sample points, encode the residual information, and control the segment length. Based on the current sample point and the starting sample point of the current segment, update the trend constraint content in the gear control information corresponding to the multiple compression gears respectively; Based on the gear control information corresponding to the target compression gear, determine whether to trigger the segmented output of the current segment; When the segmented output of the current segment is triggered, the end sample point of the current segment and the start sample point of the next segment are determined, and the linear prediction benchmark is determined based on the start sample point of the current segment and the end sample point. Based on the linear prediction benchmark, determine the residual information of the intermediate sample points within the current segment; Based on the gear control information corresponding to the target compression gear, the residual information is encoded to obtain residual encoded data. Output the compressed data corresponding to the current segment, and use the starting sample point of the next segment as the starting sample point of the new current segment to continue compressing the subsequent sample points in the time sequence signal; wherein, the compressed data includes the gear identification information of the target compression level, the segment length information of the current segment, the original value of the end sample point of the segment, the original value of the starting sample point of the next segment, and the residual coding data.
[0007] In one possible design, acquiring the timing signal to be compressed and determining the starting sample point of the current segment from the timing signal includes: Acquire the original sampled signal and determine the original bit width information corresponding to the original sampled signal; When the original sampled signal is a signed integer signal, the offset is determined based on the original bit width information; Based on the offset, the sample points in the original sampled signal are unsigned mapped to obtain an unsigned time-series signal; The unsigned timing signal is determined as the timing signal, and the first sample point in the timing signal is determined as the starting sample point of the current segment.
[0008] In one possible design, before reading the current sample point after the starting sample point of the current segment in the sampling order, the method further includes: For any one of the plurality of compression levels, determine the level number of the compression level; Based on the gear number and the original bit width information, determine the residual coding precision corresponding to the compression gear; Based on the residual coding accuracy and the preset quantization step size parameter, determine the trend constraint threshold corresponding to the compression level; Based on the trend constraint threshold, determine the initial range of the trend constraint corresponding to the compression gear; Based on the gear number, the total number of the multiple compression gears, and the preset maximum segment length, determine the segment length control rule corresponding to the compression gear; Based on the residual coding accuracy, the trend constraint threshold, the initial range of the trend constraint, and the segment length control rule, the gear control information corresponding to the compression gear is obtained.
[0009] In one possible design, determining the target compression level corresponding to the current segment from the multiple compression levels, based on the relationship between the current sample point and the starting sample point of the current segment, and the level control information corresponding to the multiple preset compression levels, includes: Based on the current sample point and the starting sample point of the current segment, determine the trend change information of the current sample point relative to the starting sample point of the current segment; Based on the trend change information and the trend constraint content corresponding to each compression level, determine the trend inclusion result of each compression level for the current sample point; If at least one of the compression levels corresponding to the trend inclusion result characterization can encompass the current sample point, the target compression level is determined from the compression levels that can encompass the current sample point in the order of the compression levels.
[0010] In one possible design, updating the trend constraint content in the gear control information corresponding to the multiple compression gears based on the current sample point and the starting sample point of the current segment includes: Based on the current sample point and the starting sample point of the current segment, determine the sample change information corresponding to the current sample point; For any compression level among the plurality of compression levels, the current trend constraint interval corresponding to the compression level is determined based on the sample change information and the trend constraint threshold corresponding to the compression level. Based on the current trend constraint interval, the initial range or historical trend constraint range corresponding to the compression gear is updated to obtain the updated trend constraint range corresponding to the compression gear. The updated trend constraint range is determined to be the trend constraint content in the gear control information corresponding to the compression gear.
[0011] In one possible design, determining whether to trigger the segmented output of the current segment based on the gear control information corresponding to the target compression gear includes: Based on the segment length control rules corresponding to the target compression level, determine the segment length threshold corresponding to the current segment; The length of the current segment is determined based on the number of sample points that have been included in the current segment after the starting sample point of the current segment. Based on the trend constraint content in the gear control information corresponding to the multiple compression gears, determine the gear containment state corresponding to the current sample point. If the current segment length reaches the segment length threshold, or if the gear containment state indicates that the current sample point cannot be contained by any of the compression gears, then the segment output of the current segment is determined to be triggered. If the current segment length does not reach the segment length threshold, and the gear inclusion state indicates that the current sample point can be included by at least one compression gear, the current sample point is included in the current segment to obtain the updated current segment.
[0012] In one possible design, determining the residual information of intermediate sample points within the current segment based on the linear prediction benchmark includes: Based on the linear prediction benchmark, the intermediate sample points within the current segment are predicted to obtain the predicted sample values corresponding to the intermediate sample points. Obtain the actual sample value corresponding to the intermediate sample point; Based on the actual sample values and the predicted sample values, the residual information corresponding to the intermediate sample points is determined.
[0013] In one possible design, the gear control information corresponding to the target compression gear includes a trend constraint threshold and residual coding precision. The process of encoding the residual information based on the gear control information corresponding to the target compression gear to obtain residual coded data includes: Based on the trend constraint threshold corresponding to the target compression level, the residual information is offset to obtain non-negative residual information for unsigned encoding. Based on the preset quantization step size parameter and the residual coding precision corresponding to the target compression level, the non-negative residual information is quantized to obtain the initial quantized residual. Based on the residual coding precision corresponding to the target compression level, the value range of the initial quantization residual is limited to obtain the target quantization residual; Based on the residual coding precision corresponding to the target compression level, the target quantization residual is encoded to obtain the residual coding data.
[0014] In one possible design, determining to trigger the segment output of the current segment when the current segment length reaches the segment length threshold, or when the compression level encompasses the current sample point and it cannot be encompassed by any of the compression levels, includes: When the current segment length reaches the segment length threshold, the sample point in the current segment that meets the preset segment end condition is determined as the segment end sample point, and the sample point after the segment end sample point is determined as the starting sample point of the next segment. When the gear containment state indicates that the current sample point cannot be contained by any of the compression gears, and the number of sample points already included in the current segment is greater than zero, the last sample point located before the current sample point and already included in the current segment is determined as the end sample point of the segment, and the current sample point is determined as the starting sample point of the next segment. When the compression level indicates that the current sample point cannot be contained by any compression level and the number of sample points already included in the current segment is zero, the current sample point is output as a single point of raw data, and the sample points after the current sample point are used to establish a new current segment.
[0015] Secondly, this application provides an adaptive compression device for timing signals, the device comprising: The signal acquisition module is used to acquire the timing signal to be compressed and determine the starting sample point of the current segment from the timing signal; The compression level determination module is used to read the current sample points after the starting sample point of the current segment according to the sampling order, and determine the target compression level corresponding to the current segment from the multiple compression levels based on the change relationship of the current sample points relative to the starting sample point of the current segment and the compression level control information corresponding to the multiple preset compression levels; wherein, the compression level control information is used to perform trend constraints on the sample points, encode the residual information, and control the segment length. The trend constraint update module is used to update the trend constraint content in the gear control information corresponding to the multiple compression gears based on the current sample point and the starting sample point of the current segment. The segmented output judgment module is used to determine whether to trigger the segmented output of the current segment based on the gear control information corresponding to the target compression gear. The prediction benchmark determination module is used to determine the end sample point of the current segment and the start sample point of the next segment when the segment output of the current segment is triggered, and to determine the linear prediction benchmark based on the start sample point and the end sample point of the current segment. The residual information determination module is used to determine the residual information of intermediate sample points within the current segment based on the linear prediction benchmark. The residual encoding module is used to encode the residual information based on the gear control information corresponding to the target compression gear to obtain residual encoded data. The compressed data output module is used to output the compressed data corresponding to the current segment, and to continue compressing the subsequent sample points in the time sequence signal by using the starting sample point of the next segment as the starting sample point of the new current segment; wherein, the compressed data includes the gear identification information of the target compression level, the segment length information of the current segment, the original value of the end sample point of the segment, the original value of the starting sample point of the next segment, and the residual coding data.
[0016] Thirdly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed, implement the method described in the first aspect or various possible designs of the first aspect.
[0017] Fourthly, this application provides a computer program product, which includes computer program code that, when run on a computer, causes the computer to implement the method described in the first aspect or various possible designs of the first aspect.
[0018] This application provides an adaptive compression method and apparatus for time-series signals. The method acquires the time-series signal to be compressed and determines the starting sample point of the current segment. When reading subsequent current sample points, it determines the target compression level from multiple compression levels based on the change relationship between the current sample point and the starting sample point of the current segment. This allows the compression process to adaptively select appropriate trend constraints, residual encoding, and segment length control methods based on the degree of local fluctuations in the time-series signal. Simultaneously, by continuously updating the trend constraint content of multiple compression levels based on the current sample point, and determining whether to trigger segmented output based on the target compression level, it ensures that gently changing segments can be extended as much as possible to reduce the amount of output data, while drastically changing segments can be segmented in a timely manner to avoid excessive loss of waveform details. Furthermore, during segmented output, a linear prediction benchmark is established based on the starting and ending sample points of the current segment, and only the residual information of intermediate sample points is encoded and output. This reduces the amount of data directly stored or transmitted from the original sampled data while preserving the signal change characteristics within the segment. Therefore, this application can alleviate the problems of limited computing and storage resources, signal fluctuation characteristics changing over time, and difficulty in balancing compression efficiency and reconstruction fidelity in real-time compression scenarios of one-dimensional time-series signals in resource-constrained devices. Attached Figure Description
[0019] Figure 1 A flowchart illustrating an adaptive compression method for timing signals provided in an embodiment of this application; Figure 2 A schematic diagram of the structure of an adaptive compression device for timing signals provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims and drawings of this application are intended to cover non-exclusive inclusion.
[0022] The term "embodiment" as used herein means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of the phrase "embodiment" in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0023] In this article, the term "and / or" simply describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists, A and B can exist simultaneously, and B exists. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0024] Furthermore, the terms "first," "second," etc., in the specification and claims of this application or in the aforementioned drawings are used to distinguish different objects rather than to describe a specific order, and may explicitly or implicitly include one or more of the features.
[0025] In the description of this application, unless otherwise stated, "multiple" and "at least two" mean two or more (including two), and similarly, "multiple groups" and "at least two groups" mean two or more (including two groups).
[0026] In the description of this application, it should be noted that, unless otherwise explicitly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, "connected" or "linked" can refer not only to a physical connection, but also to an electrical connection or a signal connection. For instance, it can be a direct connection, i.e., a physical connection, or an indirect connection through at least one intermediate component, as long as the circuit is connected. It can also refer to the internal connection between two components. A signal connection can refer not only to a signal connection through a circuit, but also to a signal connection through a medium, such as radio waves. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0027] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. It should be noted that, unless otherwise specified, different technical features in this application can be combined with each other.
[0028] Figure 1 This is a flowchart illustrating an adaptive compression method for timing signals provided in an embodiment of this application. Figure 1 As shown, the method provided in this application embodiment specifically includes S101 to S108, and S101 to S108 will be described in detail below.
[0029] It should be noted that the method provided in this application embodiment can be executed by a compression device, or by a sensor terminal, embedded processor, low-power microcontroller, edge computing device, data acquisition device, server, or other electronic device with timing signal processing and data encoding capabilities. This application embodiment does not limit this.
[0030] S101. Obtain the timing signal to be compressed, and determine the starting sample point of the current segment from the timing signal.
[0031] The time-series signal to be compressed is a one-dimensional continuously sampled signal, such as an electrocardiogram signal, acceleration signal, pressure signal, temperature signal, sound signal, or other sensor sampling signals that change continuously over time.
[0032] It should be noted that the time-series signal to be compressed includes multiple sample points arranged in chronological order of sampling time. Each sample point may include a sampling number and a sample value. When the compression device begins compression, it can determine the first sample point in the time-series signal to be compressed as the starting sample point of the current segment. In subsequent segmented compression processes, the starting sample point of the next segment determined by the previous segment can be used as the starting sample point of the new current segment. The starting sample point of the current segment is used as a reference point for trend judgment, linear prediction, and residual calculation of subsequent sample points within the current segment.
[0033] S102. Read the current sample point after the starting sample point of the current segment according to the sampling order. Based on the change relationship of the current sample point relative to the starting sample point of the current segment, and the gear control information corresponding to the multiple preset compression gears, determine the target compression gear corresponding to the current segment from the multiple compression gears.
[0034] Among them, the gear control information is used to constrain the trend of sample points, encode residual information, and control the segment length.
[0035] The compression device can read the sample points after the starting sample point of the current segment in the sampling order, and take the sample point being processed as the current sample point.
[0036] The relationship between the current sample point and the starting sample point of the current segment is used to characterize the amplitude change trend of the current sample point relative to the starting sample point of the current segment.
[0037] Multiple compression levels can be preset, with different compression levels corresponding to different control information. This control information can include information related to trend constraints, residual information encoding, and segment length control. Therefore, different compression levels can correspond to different trend tolerance capabilities, residual encoding capabilities, and segment control capabilities.
[0038] When determining the target compression level, the compression device can determine whether the current sample point can be encompassed by the trend constraint content corresponding to each compression level based on the change relationship between the current sample point and the starting sample point of the current segment. Based on the determination result, the target compression level is selected from multiple compression levels. The target compression level indicates the compression control method used in the current segment during trend constraint, segment length control, and residual information encoding processes.
[0039] By setting multiple compression levels, the compression process no longer relies on a single fixed error constraint, but can select the appropriate level based on the changes in the current sample points.
[0040] S103. Based on the current sample point and the starting sample point of the current segment, update the trend constraint content in the gear control information corresponding to multiple compression gears.
[0041] Trend constraints are used to limit the range of change trends formed by sample points in the current segment relative to the starting sample point of the current segment. After reading the current sample point, the compression device can update the trend constraints corresponding to multiple compression levels based on the relationship between the current sample point and the starting sample point of the current segment.
[0042] In other words, the current sample point can not only be used to determine the target compression level, but also to synchronously update the trend constraint content corresponding to each compression level, so that each compression level maintains a trend constraint state that matches the read sample point within the current segment.
[0043] In some implementations, if the current sample point can be encompassed by the trend constraint content corresponding to a certain compression level, the trend constraint content corresponding to that compression level can be updated based on the current sample point; if the current sample point cannot be encompassed by the trend constraint content corresponding to a certain compression level, it can be determined that the trend constraint content corresponding to that compression level does not satisfy the change relationship of the current sample point.
[0044] By updating the trend constraints of multiple compression levels, a basis can be provided for subsequent judgments on whether to continue expanding the current segment and whether to trigger segment output.
[0045] S104. Based on the gear control information corresponding to the target compression gear, determine whether to trigger the segmented output of the current segment.
[0046] In some implementations, the compression device can determine whether the current segment meets the segment output conditions based on the gear control information corresponding to the target compression gear.
[0047] Segmented output conditions may include at least one of segment length conditions and trend constraint conditions.
[0048] For example, when the length of the current segment reaches the length control requirement corresponding to the target compression level, the segment output of the current segment can be triggered; or, for example, when the current sample point cannot be contained by any of the multiple compression levels, the segment output of the current segment can also be triggered.
[0049] In this way, the timing of the current segment's output can be dynamically determined based on the target compression level and sample changes. For time-series signal segments with relatively gentle changes, the current segment can be allowed to cover more sample points to reduce the number of output segments; for time-series signal segments with drastic changes, segment output can be triggered in a timely manner to reduce the loss of local waveform details due to excessively long segments.
[0050] S105. When the segmented output of the current segment is triggered, determine the end sample point of the current segment and the starting sample point of the next segment, and determine the linear prediction benchmark based on the starting sample point and the end sample point of the current segment.
[0051] In some implementations, when it is determined that the segment output of the current segment is triggered, the compression device can determine the end sample point of the current segment and the start sample point of the next segment based on the triggering reason.
[0052] The end-of-segment sample point is the sample point in the current segment used to construct the linear prediction baseline together with the starting sample point of the current segment. The starting sample point of the next segment is used as the new starting sample point for subsequent segment compression. Its original value can be output along with the compressed data corresponding to the current segment so that the sample point relationship between adjacent segments can be continuously recovered during decompression.
[0053] In some implementations, the linear prediction benchmark can be determined based on the starting and ending sample points of the current segment. The linear prediction benchmark is used to characterize the approximate trend of change of sample points within the current segment.
[0054] By constructing a linear prediction baseline using the starting and ending sample points of the current segment, we can avoid directly outputting the original value for each sample point in the current segment, thus providing a basis for subsequent residual coding.
[0055] S106. Based on the linear prediction benchmark, determine the residual information of the intermediate sample points within the current segment.
[0056] In some implementations, the intermediate sample point within the current segment is the sample point located between the starting sample point and the ending sample point of the current segment.
[0057] The compression device can perform linear prediction on intermediate sample points within the current segment based on a linear prediction benchmark, obtain the predicted sample value corresponding to the intermediate sample point, and determine the residual information corresponding to the intermediate sample point based on the difference between the actual sample value and the predicted sample value. The residual information is used to characterize the degree of deviation of the intermediate sample point from the linear prediction benchmark.
[0058] Since the starting and ending sample points of the current segment have already been used to establish a linear prediction baseline, only the residual information corresponding to the intermediate sample points needs to be encoded. Compared to directly outputting the original values of each sample point in the current segment, outputting residual information based on the linear prediction baseline can reduce the amount of data that needs to be encoded, while preserving the local changes of the sample points in the current segment relative to the linear trend.
[0059] S107. Based on the gear control information corresponding to the target compression gear, the residual information is encoded to obtain residual encoded data.
[0060] In some implementations, the compression device can encode the residual information of intermediate sample points within the current segment based on the gear control information corresponding to the target compression gear, thereby obtaining residual coded data.
[0061] Since different target compression levels correspond to different residual coding control methods, a residual coding method that matches higher compression efficiency can be used when the signal changes relatively smoothly; while a residual coding method that matches higher reconstruction fidelity can be used when the signal changes more drastically. In this way, the residual coding process can be matched with the target compression level, avoiding the use of the same fixed coding method for all signal segments.
[0062] In some implementations, the residual encoded data may include the encoded results corresponding to each intermediate sample point within the current segment. This residual encoded data, in conjunction with the target compression level identifier information, the segment length information of the current segment, the original value of the end sample point of the segment, and the original value of the starting sample point of the next segment, can be used to recover the sample points within the current segment during decompression.
[0063] S108. Output the compressed data corresponding to the current segment, and use the starting sample point of the next segment as the starting sample point of the new current segment to continue compressing the subsequent sample points in the time sequence signal.
[0064] The compressed data includes the gear identification information of the target compression level, the segment length information of the current segment, the original value of the end sample point of the segment, the original value of the starting sample point of the next segment, and the residual coding data.
[0065] In some implementations, after completing the residual encoding of the current segment, the compression device can output the compressed data corresponding to the current segment. The target compression level identifier information is used to indicate the compression level used in the current segment; the segment length information of the current segment is used to indicate the number of sample points or the segment length of the current segment; the original value of the end sample point is used together with the beginning sample point of the current segment to determine the linear prediction benchmark; the original value of the beginning sample point of the next segment is used as the benchmark for the compression and subsequent decompression of the next segment; the residual encoded data is used to characterize the deviation of the intermediate sample points in the current segment from the linear prediction benchmark.
[0066] After outputting the compressed data corresponding to the current segment, the compression device can use the starting sample point of the next segment as the starting sample point of the new current segment, and continue to read subsequent sample points according to the sampling order to repeatedly perform processes such as determining the target compression level, updating trend constraint content, segment output judgment, linear prediction, and residual coding, until the compression of the time-series signal to be compressed is completed. This enables streaming segmented compression of continuous time-series signals, suitable for applications requiring simultaneous acquisition, processing, storage, or transmission.
[0067] In some implementations, when the segmented output of the current segment is triggered, the current segment may include sample points from the start sample point of the current segment to the end sample point of the segment. The compression device may output the compressed data corresponding to the current segment according to a preset field order.
[0068] For example, the compression device can first output the gear identification information of the target compression level. If the total number of compression levels is G, the gear identification information of the target compression level can be represented using ceil(log2(G)) bits. For example, when G is 8, the gear identification information of the target compression level can be represented using 3 bits.
[0069] The compression device can also output the segment length information of the current segment.
[0070] In one implementation, the segment length information of the current segment can be represented as counter-1, where counter represents the number of sample points participating in the segment output within the current segment. The segment length information of the current segment can be represented using nL bits, nL=ceil(log2(max_seg_len)), where max_seg_len is the preset maximum segment length.
[0071] When outputting residual encoded data, the compression device can determine the linear prediction baseline based on the starting sample point (anchor) and the last sample point (last_point) of the current segment.
[0072] In this embodiment, by acquiring the time-series signal to be compressed and determining the starting sample point of the current segment, when reading subsequent current sample points, the target compression level is determined from multiple compression levels based on the change relationship between the current sample point and the starting sample point of the current segment. This allows the compression process to adaptively select the appropriate trend constraint, residual encoding, and segment length control method based on the degree of local fluctuation of the time-series signal. Simultaneously, by continuously updating the trend constraint content of multiple compression levels based on the current sample point, and determining whether to trigger segmented output based on the target compression level, the segments with gentle changes can be extended as much as possible to reduce the amount of output data, while segments with drastic changes can be segmented in a timely manner to avoid excessive loss of waveform details. Furthermore, during segmented output, a linear prediction benchmark is established based on the starting sample point and the end sample point of the current segment, and only the residual information of the intermediate sample points is encoded and output. This reduces the amount of data directly stored or transmitted from the original sampled data while preserving the signal change characteristics within the segment. Therefore, this application can alleviate the problems of limited computing and storage resources, signal fluctuation characteristics changing over time, and difficulty in balancing compression efficiency and reconstruction fidelity in real-time compression scenarios of one-dimensional time-series signals in resource-constrained devices.
[0073] S101 can be implemented through S1011 to S1014, and S1011 to S1014 are described in detail below.
[0074] S1011. Obtain the original sampled signal and determine the original bit width information corresponding to the original sampled signal.
[0075] In some implementations, the original sampled signal is a one-dimensional time-series signal acquired by a sensor, analog-to-digital converter, or data acquisition device at a preset sampling frequency. The original sampled signal includes multiple original sample points arranged in chronological order of sampling time, each original sample point having a corresponding sampling sequence number and original sample value. The original bit width information is used to characterize the original data bit width of a single sample point in the original sampled signal; the original bit width information can be determined based on the sensor output format, analog-to-digital converter resolution, data acquisition interface protocol, or storage format.
[0076] For example, when the original sampled signal is acquired by a 12-bit analog-to-digital converter, the original bit width information can be 12 bits; when the original sampled signal is output from a 16-bit sampling channel, the original bit width information can be 16 bits. The original bit width information can be used to determine the representable numerical range of the original sampled signal and serves as the basis for subsequent unsigned mapping, original sample value storage, and compressed data field bit width settings.
[0077] S1012. When the original sampled signal is a signed integer signal, determine the offset based on the original bit width information.
[0078] In some implementations, the compression device can determine the data representation type of the original sampled signal. When the original sampled signal is a signed integer signal, the original sample values may include positive, negative, and zero values. To facilitate subsequent bit-level encoding according to a fixed field length, an offset for converting the signed integer signal to an unsigned integer signal can be determined based on the original bit width information.
[0079] For example, when the original bit width information represents the bit width of the original sampled signal as Lori bits, the offset can be 2. (Lori-1) This offset shifts the signed sample values in the original sampled signal to a non-negative integer range. For example, when the original bit width is 12 bits, the offset can be 2048; when the original bit width is 16 bits, the offset can be 32768. This offset remains consistent on both the compression and decompression sides so that reverse reconstruction can be performed when the signed signal needs to be recovered after decompression.
[0080] S1013. Perform unsigned mapping on the sample points in the original sampled signal based on the offset to obtain an unsigned time-series signal.
[0081] In some implementations, the compression device can add the original sample value of each sample point in the original sampled signal to the offset to obtain the corresponding unsigned sample value.
[0082] For example, when the original bit width information is Lori bits, the unsigned mapped sample values are between 0 and 2. Lori The range of unsigned integers from -1.
[0083] It should be noted that unsigned mapping does not change the temporal order of the sample points in the original sampled signal, nor does it change the sampling correspondence between adjacent sample points. Instead, it shifts the numerical representation of the sample points as a whole. Therefore, subsequent processing, such as determining the starting sample point of the current segment, reading the current sample point, judging trend changes, linear prediction, and determining residual information, can be based on the unsigned sample values. If the original sampled signal is already an unsigned integer signal, the compression device may not perform the aforementioned offset mapping, or it may set the offset to zero and directly use the original sampled signal as the timing signal to be compressed for subsequent processing.
[0084] For example, if the original sample value in the original sampled signal is denoted as x_raw[i], the unsigned mapped sample value is denoted as x[i], and the original bit width information is denoted as Lori, then when the original sampled signal is a signed integer signal, the formula x[i] = x_raw[i] + 2 can be used. (Lori-1) Perform an unsigned mapping, 0 ≤ x[i] ≤ 2 Lori -1.
[0085] Through the above unsigned mapping, the sample value x[i] can be between 0 and 2. (Lori-1) Within the range of unsigned integers. After decompression, if it is necessary to restore the original signed signal, it can be done according to x_raw[i]=x[i]-2 (Lori-1) Perform reverse restoration.
[0086] S1014. Determine the unsigned timing signal as the timing signal to be compressed, and determine the first sample point in the timing signal to be compressed as the starting sample point of the current segment.
[0087] In some implementations, after obtaining the unsigned timing signal, the compression device can use the unsigned timing signal as the timing signal to be compressed. The sample points in the timing signal to be compressed can all be represented by unsigned values corresponding to the original bit width information, thus facilitating the subsequent encoding of the original values of the end sample points of the current segment, the beginning sample points of the next segment, and other original values of sample points that need to be directly saved according to a uniform bit width.
[0088] When the compression device begins segmented compression, it can determine the first sample point in the time-series signal to be compressed as the starting sample point of the current segment. The starting sample point of the current segment can serve as a reference point for judging trend changes, updating trend constraints, and making linear predictions for subsequent current sample points within the current segment. After each current segment is compressed and output, the starting sample point of the next segment determined by that current segment can be used as the starting sample point of the new current segment, thereby achieving continuous segmented compression of the time-series signal to be compressed.
[0089] In this embodiment, by uniformly converting the original sampled signal, which may contain positive and negative values, into an unsigned timing signal before performing dynamic gear selection and segmented compression, the complexity of sign bit processing caused by signed number representation can be reduced, making it easier to perform bit-level encoding and decoding according to a fixed original bit width. At the same time, by using the same offset to perform reverse restoration on the decompression side, the original signal representation can be restored while maintaining the sampling order and sample correspondence, thereby improving the ease of implementation of timing signal compression processing in embedded devices and low-power terminals.
[0090] In one possible embodiment, prior to the method steps shown in S102, the method further includes S201 to S206, which are described in detail below.
[0091] It should be noted that before reading the current sample point after the starting sample point of the current segment, the compression device can pre-determine the compression control information for multiple compression levels. These multiple compression levels can serve as a preset set of hierarchical compression control parameters, with each compression level corresponding to a set of compression control information. The compression control information is not merely used to represent the number of bits used in residual encoding, but rather to jointly control trend constraints, residual information encoding, and segment length. Therefore, each compression level can be understood as a multi-parameter linked compression control unit.
[0092] S201. For any compression gear among multiple compression gears, determine the gear number of the compression gear.
[0093] In some implementations, the compression device may have multiple compression levels preset, and each compression level may be assigned a corresponding level number. The level number is used to characterize the order of the compression level among the multiple compression levels. For example, the total number of compression levels is G, and the level number of any compression level is g, where g is an integer and 1 ≤ g ≤ G.
[0094] In some implementations, a lower compression level indicates that the compression level is more suitable for time-series signal segments with relatively stable changes; a higher compression level indicates that the compression level is more suitable for time-series signal segments with more drastic changes. Therefore, the compression device can subsequently adaptively select between multiple compression levels based on the degree of change at the current sample point.
[0095] S202. Determine the residual coding precision corresponding to the compression gear based on the gear number and the original bit width information.
[0096] In some implementations, the raw bit width information is used to characterize the raw data bit width of a single sample point in the raw sampled signal, and the residual coding precision is used to characterize the number of bits used when encoding the residual information. The compression device can determine the residual coding precision corresponding to a compression level based on the compression level number and the raw bit width information.
[0097] For example, the original bit width information is Lori, and the residual coding precision corresponding to the compression level g is b[g]. The residual coding precision corresponding to different compression levels can be set in ascending order of the level number, that is, the lower level corresponds to a smaller residual coding precision, and the higher level corresponds to a larger residual coding precision. In one implementation, the residual coding precision corresponding to each compression level can satisfy b[1]<b[2]<……<b[G], and the residual coding precision b[G] corresponding to the highest compression level can be equal to the original bit width information Lori.
[0098] For example, when the original bit width information is 12 bits and the total number of bits is 8, the residual coding precision corresponding to multiple compression bits can be set to 1 bit, 2 bits, 3 bits, 4 bits, 5 bits, 6 bits, 7 bits, and 12 bits respectively. The above settings are just examples. In practical applications, the residual coding precision can also be adjusted according to the signal dynamic range, allowable reconstruction error, storage resources, and transmission bandwidth.
[0099] S203. Determine the trend constraint threshold corresponding to the compression level based on the residual coding accuracy and the preset quantization step size parameter.
[0100] In some implementations, a preset quantization step size parameter is used to characterize the quantization granularity when quantizing residual information. The preset quantization step size parameter may include a residual quantization step size exponent, `lossbits`, and the quantization step size can be determined based on this exponent. For example, the quantization step size can be 2^32. lossbits When lossbits is 0, the quantization step size is 1, which is suitable for lossless or near-lossless configurations; as lossbits increases, the quantization step size increases accordingly, and the allowable quantization error also increases accordingly.
[0101] The trend constraint threshold is used to limit the allowable deviation range of the current sample point relative to the starting sample point of the current segment. The compression device can determine the trend constraint threshold corresponding to the compression level based on the residual coding accuracy corresponding to the compression level and the preset quantization step size parameter.
[0102] The trend constraint threshold corresponding to the compression gear g is , Therefore, the higher the residual coding precision, the larger the trend constraint threshold, and the stronger the ability to encompass the changing trend of the current sample point; conversely, the lower the residual coding precision, the smaller the trend constraint threshold, and the stricter the constraint on the changing trend of the current sample point.
[0103] S204. Determine the initial range of trend constraints corresponding to the compression gear based on the trend constraint threshold.
[0104] In some implementations, the initial range of trend constraints is used as the initial state for subsequent updates to the trend constraint content. The initial range of trend constraints may include a lower boundary and an upper boundary. For a compression level g, the lower boundary low[g] and the upper boundary high[g] can be maintained separately. At the beginning of the current segment, since the trend constraint range has not yet been narrowed based on subsequent sample points within the current segment, low[g] can be initialized to negative infinity and high[g] can be initialized to positive infinity.
[0105] When reading the current sample point subsequently, the compression device can update the initial range of the trend constraint based on the current sample point, the starting sample point of the current segment, and the trend constraint threshold corresponding to the compression level, thus obtaining the trend constraint content of the compression level within the current segment. Since different compression levels correspond to different trend constraint thresholds, the trend constraint range corresponding to each compression level has different containment capabilities.
[0106] S205. Determine the segment length control rules corresponding to the compression gear based on the gear number, the total number of multiple compression gears, and the preset maximum segment length.
[0107] In some implementations, a preset maximum segment length is used to limit the maximum number of sample points allowed in a segment, and can be set according to hardware cache size, storage sector size, signal stability, or real-time output latency requirements. The compression device can determine the segment length control rule corresponding to a compression level based on the compression level number, the total number of compression levels, and the preset maximum segment length. The segment length control rule can be used to determine whether the current segment has reached the segment length threshold in subsequent segment output judgments.
[0108] In some implementations, the segment length control rule can be set to be negatively correlated with the gear number. That is, the higher the gear number of the compression gear, the shorter the allowed segment length; the lower the gear number of the compression gear, the longer the allowed segment length. With this setting, when the signal changes are relatively smooth and a lower gear is used, the current segment can be allowed to contain more sample points, thereby reducing the number of segments and header field overhead; when the signal changes drastically and a higher gear is used, the current segment length can be shortened, thereby reducing the loss of local change details due to excessively long segments.
[0109] For example, the segment length control rule can be a linear decreasing rule. If the total number of gears is G, the gear number of any compression gear is g, and the preset maximum segment length is max_seg_len, then the segment length threshold corresponding to that compression gear can be determined based on max_seg_len and the gear position of g relative to G. For example, it can be determined according to the formula... Determine the segment length threshold In addition to the linear decreasing rule, a lookup table rule or a piecewise constant rule can also be used to determine the segment length threshold corresponding to each compression level.
[0110] S206. Based on the residual coding accuracy, trend constraint threshold, trend constraint initial range, and segment length control rules, the gear control information corresponding to the compression gear is obtained.
[0111] In some implementations, after obtaining the residual coding precision, trend constraint threshold, initial range of trend constraints, and segment length control rules, the compression device can combine these parameters into the level control information corresponding to the compression level. In other words, the level control information corresponding to any compression level includes at least: residual coding precision for controlling the number of bits encoded in the residual information, trend constraint threshold for controlling the trend coverage range of sample points, initial range of trend constraints for subsequent trend constraint content updates, and segment length control rules for determining whether segmented output is triggered.
[0112] For multiple compression levels, the compression device can execute the method steps shown in S201 to S206 respectively to obtain the level control information corresponding to each compression level. After determining the level control information for multiple compression levels, the compression device can proceed to the subsequent point-by-point compression process. When reading the current sample point, the compression device can determine whether the current sample point can be contained within the corresponding compression level based on the trend constraint content corresponding to each compression level, and determine whether to trigger segmented output based on the segment length control rule corresponding to the target compression level. At the same time, it encodes the residual information based on the residual coding precision corresponding to the target compression level.
[0113] In this embodiment, before reading the current sample point, level control information, including residual coding accuracy, trend constraint threshold, initial range of trend constraint, and segment length control rules, is established for multiple compression levels. This allows each compression level to simultaneously control trend coverage, residual coding capability, and segment length control capability. Consequently, the subsequent compression process can adaptively adjust the compression ratio and reconstruction fidelity based on the degree of local variation in the time-series signal, thereby improving its adaptability to both smooth and drastically changing segments.
[0114] In some implementations, the compression device may also include a parameter self-diagnostic mechanism. After processing a preset number of sample points, the compression device can statistically analyze the compression status of several recent segments and adjust the compression parameters based on the statistical results.
[0115] For example, the compression device can calculate the percentage of high-level compression (Rhigh) and the average segment length (Lavg) in the most recent M segments. The percentage of high-level compression (Rhigh) can be used to characterize the proportion of segments in the most recent M segments whose target compression level is greater than or equal to a preset high-level threshold; the average segment length (Lavg) can be used to characterize the average number of sample points in the most recent M segments.
[0116] In some implementations, if Rhigh is greater than a preset percentage threshold, it indicates that the timing signal changes steeply. The compression device can increase the preset quantization step size parameter or improve the residual coding precision corresponding to the lower compression level to enhance the adaptability of subsequent compression processes to drastically changing signals. If Lavg is less than half of the preset maximum segment length, it indicates that the current segment is too short. The compression device can appropriately increase the preset maximum segment length or adjust the decreasing method of the segment length threshold to reduce the situation of overly fragmented segments. If the highest compression level has not been used for a long time within a preset statistical window, the total number of compression levels can be appropriately reduced, or the residual coding precision corresponding to the highest compression level can be reduced to reduce unnecessary level maintenance overhead.
[0117] In some implementations, the compression device can reinitialize the trend constraint content corresponding to multiple compression levels after parameter adjustment, and then start compression from the new current segment using the adjusted parameters. Through the above-mentioned parameter self-diagnosis mechanism, the compression parameters can be adaptively adjusted according to the actual changes in the time-series signal, improving the adaptability of the compression method to different signal fluctuation characteristics.
[0118] In one possible embodiment, the method steps shown in S102 can be implemented by S1021 to S1023, which are described in detail below.
[0119] S1021. Based on the current sample point and the starting sample point of the current segment, determine the trend change information of the current sample point relative to the starting sample point of the current segment.
[0120] In some implementations, the current sample point is a sample point read in the sampling order after the starting sample point of the current segment. The compression device can determine the trend change information of the current sample point relative to the starting sample point of the current segment based on the sample value of the current sample point, the sampling sequence number of the current sample point, the sample value of the starting sample point of the current segment, and the sampling sequence number of the starting sample point of the current segment. The trend change information is used to characterize the amplitude change trend of the current sample point relative to the starting sample point of the current segment.
[0121] In some implementations, the trend change information can be the slope information of the current sample point relative to the starting sample point of the current segment, or it can be an equivalent change that characterizes the amplitude change relationship between the two. For example, the trend change information can be determined based on the amplitude difference between the current sample point and the starting sample point of the current segment, and the sampling sequence difference between the current sample point and the starting sample point of the current segment. This trend change information can then be used to determine whether the current sample point still meets the trend constraint requirements corresponding to each compression level.
[0122] S1022. Based on trend change information and the trend constraint content corresponding to each compression level, determine the trend inclusion result of each compression level for the current sample point.
[0123] In some implementations, the trend constraint content corresponding to each compression level may include the trend constraint range corresponding to that compression level, and the trend constraint range may include a lower boundary and an upper boundary. The compression device can compare the trend change information corresponding to the current sample point with the trend constraint range corresponding to each compression level to determine the trend inclusion result of each compression level for the current sample point.
[0124] Specifically, if the trend change information corresponding to the current sample point is within the trend constraint range corresponding to a certain compression level, then it can be determined that the compression level can encompass the current sample point; if the trend change information corresponding to the current sample point exceeds the trend constraint range corresponding to a certain compression level, then it can be determined that the compression level cannot encompass the current sample point. Thus, the trend encompassing results of multiple compression levels for the current sample point can be obtained respectively.
[0125] In some implementations, different compression levels correspond to different trend constraint thresholds, thus the trend constraints corresponding to different compression levels have different inclusiveness. Lower compression levels typically have stricter trend constraints, suitable for current sample points with relatively stable changes; higher compression levels typically have wider trend constraints, suitable for current sample points with more drastic changes. By determining the trend inclusiveness results for each compression level, a basis can be provided for determining the subsequent target compression level.
[0126] For example, if the starting sample point of the current segment is anchor, the sampling number corresponding to the starting sample point of the current segment is idx_anchor, and the current sample point is x[i], then the trend change information of the current sample point relative to the starting sample point of the current segment can be expressed as: slope=(x[i]-anchor) / (i-idx_anchor).
[0127] The compression device can determine whether the slope is within the trend constraint range [low[g], high[g]] corresponding to the compression level g. If low[g] ≤ slope ≤ high[g], it can be determined that the compression level g can encompass the current sample point; otherwise, it can be determined that the compression level g cannot encompass the current sample point.
[0128] S1023. If at least one trend inclusion result characterization corresponding to the compression level can include the current sample point, determine the target compression level from the compression levels that can include the current sample point according to the level order.
[0129] In some implementations, the compression device can determine a set of compression levels that can encompass the current sample point based on the trend coverage results corresponding to multiple compression levels. If at least one trend coverage result indicates that the corresponding compression level can encompass the current sample point, then the target compression level can be determined from the compression levels that can encompass the current sample point according to a preset level order.
[0130] In some implementations, the preset compression level order can be from low to high. The compression device can preferentially select the lowest compression level that can encompass the current sample point as the target compression level. Since lower compression levels typically correspond to fewer residual coding bits and longer segment length control capabilities, preferentially selecting lower levels, provided that the trend constraints of the current sample point can be met, is beneficial to improving compression efficiency. When the current sample point cannot be encompassed by a lower level, a higher compression level that can encompass the current sample point can be selected according to the compression level order to improve the adaptability to sample points with drastic changes.
[0131] In some implementations, if the trend coverage results corresponding to all compression levels indicate that the current sample point cannot be covered, it can be determined that the current sample point cannot be covered by any compression level. This situation can be used to trigger the segmented output of the current segment in the subsequent segmented output judgment step.
[0132] In this embodiment, by determining the trend inclusion result of each compression level for the current sample point based on the trend change information of the current sample point relative to the starting sample point of the current segment, and determining the target compression level from the compression levels that can include the current sample point according to the level order, sample points with gentle changes can be preferentially matched with lower compression levels, and sample points with more drastic changes can be matched with higher compression levels. This allows the compression process to adaptively determine the compression control method used for subsequent segment output and residual information encoding based on the degree of local change of the time-series signal.
[0133] In some implementations, to reduce the computational overhead of the compression device, when determining whether the trend change information is within the trend constraint range corresponding to the compression level, the compression device may not directly perform a division operation, but instead use a cross-multiplication method for comparison.
[0134] For example, the starting sample point of the current segment is anchor, the sampling sequence number corresponding to the starting sample point of the current segment is idx_anchor, the current sample point is x[i], and the trend constraint range corresponding to the compression level g can be represented as [low[g], high[g]]. When i is greater than idx_anchor, determining whether the slope corresponding to the current sample point is less than high[g] can be transformed into determining whether x[i] - anchor is less than (i - idx_anchor) × high[g]; determining whether the slope corresponding to the current sample point is greater than low[g] can be transformed into determining whether x[i] - anchor is greater than (i - idx_anchor) × low[g]. Through this cross-multiplication comparison method, division operations can be reduced, improving the execution efficiency in low-power microcontrollers.
[0135] In some implementations, during the calculation of the linear prediction baseline, if the number of sample points (counter) in the current segment is a preset, shiftable integer, or if the compression device is pre-configured with a fixed-point reciprocal or shift parameter corresponding to counter, the slope can be calculated through shift operations or table lookup. For example, when counter is a power of 2, the difference between the last sample point (last_point) of the segment and the starting sample point (anchor) of the current segment can be shifted right by the corresponding number of bits to obtain the slope of the linear prediction baseline. This method reduces the processor resource consumption of division operations.
[0136] In some implementations, the quantization of residual information can also be achieved using a shift method. For example, when the quantization step size is 2... lossbits At this point, the offset residual information resid can be right-shifted according to the number of bits corresponding to lossbits to obtain the quantized residual quant; subsequently, quant is restricted to between 0 and 2. b[gear]-1 Within the range of values, b[gear] represents the residual coding precision corresponding to the target compression gear. Through the above addition, subtraction, comparison, multiplication, and shift operations, complex floating-point operations can be reduced, making the compression method suitable for embedded devices with limited computing and storage resources.
[0137] In some implementations, the compression device may only maintain the trend constraint ranges corresponding to multiple compression levels, the starting sample point of the current segment, the current sample point number, the current compression level, the current segment length, and a small amount of cached data. Therefore, the online processing of each sample point can mainly include fixed-point comparisons of multiple compression levels and a small amount of addition, subtraction, multiplication, and shift operations, resulting in lower overall storage overhead and suitability for low-power sensor terminals and microcontroller scenarios.
[0138] In one possible embodiment, the method steps shown in S103 can be implemented by S1031 to S1034, which are described in detail below.
[0139] S1031. Based on the current sample point and the starting sample point of the current segment, determine the sample change information corresponding to the current sample point.
[0140] In some implementations, sample change information is used to characterize the change of the current sample point relative to the starting sample point of the current segment. The compression device can determine the sample change information corresponding to the current sample point based on the sample value of the current sample point, the sampling sequence number of the current sample point, the sample value of the starting sample point of the current segment, and the sampling sequence number of the starting sample point of the current segment.
[0141] In some implementations, the sample change information can be the slope information of the current sample point relative to the starting sample point of the current segment, or it can be equivalent change information characterized by the amplitude difference and the sampling sequence difference. The sample change information can be used to combine the trend constraint thresholds corresponding to different compression levels to generate the current trend constraint interval corresponding to the current sample point under different compression levels.
[0142] S1032. For any compression gear among multiple compression gears, determine the current trend constraint interval corresponding to the compression gear based on the sample change information and the trend constraint threshold corresponding to the compression gear.
[0143] In some implementations, for any compression level among multiple compression levels, the compression device can acquire the trend constraint threshold corresponding to that compression level, and determine the current trend constraint interval corresponding to that compression level based on the sample change information corresponding to the current sample point and the trend constraint threshold. The current trend constraint interval is used to characterize the constraint range formed by the current sample point on the overall change trend of the current segment within the allowable deviation range of that compression level.
[0144] In some implementations, the current trend constraint interval may include a current lower boundary and a current upper boundary. A smaller trend constraint threshold results in a narrower current trend constraint interval and a more stringent constraint on sample changes; conversely, a larger trend constraint threshold results in a wider current trend constraint interval and a stronger capacity to accommodate sample changes. Since different compression levels correspond to different trend constraint thresholds, the same current sample point can correspond to different widths of current trend constraint intervals under different compression levels.
[0145] For example, for compression level g, the trend constraint range corresponding to compression level g can be determined and updated based on the current sample point x[i], the starting sample point anchor of the current segment, the sampling number i of the current sample point, the sampling number idx_anchor corresponding to the starting sample point of the current segment, and the trend constraint threshold εg.
[0146] Specifically, if the upper boundary of the trend constraint range corresponding to the compression level g is high[g] and the lower boundary is low[g], then it can be updated as follows: high[g]=min(high[g],(x[i]+εg-anchor) / (i-idx_anchor)); low[g]=max(low[g],(x[i]-εg-anchor) / (i-idx_anchor)).
[0147] By superimposing and subtracting the trend constraint threshold εg from the sample value of the current sample point, the allowed trend constraint range of the current sample point under the compression level g can be obtained. By updating high[g] and low[g], the updated trend constraint range can simultaneously meet the trend constraint requirements of the processed sample points in the current segment.
[0148] S1033. Based on the current trend constraint range, update the initial range or historical trend constraint range corresponding to the compression gear to obtain the updated trend constraint range corresponding to the compression gear.
[0149] In some implementations, if the current sample point is the first sample point used to update the trend constraint content after the starting sample point of the current segment, the compression device can update the initial range of the trend constraint corresponding to the compression level based on the current trend constraint interval to obtain the updated trend constraint range corresponding to the compression level. If the trend constraint content corresponding to the compression level has already been updated based on other sample points before the current sample point, the compression device can update the historical trend constraint range corresponding to the compression level based on the current trend constraint interval to obtain the updated trend constraint range corresponding to the compression level.
[0150] In some implementations, the update process can be an interval intersection update. That is, the compression device can perform intersection processing with the current trend constraint interval and the initial trend constraint range or the historical trend constraint range, and use the intersection result as the updated trend constraint range. Through this processing method, the updated trend constraint range can simultaneously meet the trend constraint requirements formed by the processed sample points within the current segment.
[0151] In some implementations, if the current trend constraint range does not intersect with the historical trend constraint range, it can be determined that the trend constraint content corresponding to the compression level can no longer encompass the current sample point. In this case, the updated trend constraint range corresponding to the compression level can be determined as an empty or invalid range, so that when determining the trend inclusion result or judging the level inclusion status, it can be determined that the compression level cannot encompass the current sample point.
[0152] S1034. The updated trend constraint range is determined to be the trend constraint content in the gear control information corresponding to the compression gear.
[0153] In some implementations, the compression device can determine the updated trend constraint range as the trend constraint content in the gear control information corresponding to the compression gear. Subsequently, when reading a new current sample point, a corresponding current trend constraint interval can be generated based on the new current sample point, and the existing trend constraint content can be updated based on this current trend constraint interval.
[0154] It should be noted that the compression device can execute the method steps shown in S1032 to S1034 for multiple compression levels respectively, so as to synchronously update the trend constraint content corresponding to each of the multiple compression levels. That is, after the current sample point is read, it is not only the trend constraint content corresponding to the target compression level that is updated, but the trend constraint content corresponding to multiple compression levels can be updated based on the current sample point and the starting sample point of the current segment. As a result, each compression level can maintain a trend constraint state that matches the read sample point within the current segment.
[0155] In this embodiment, by determining the current trend constraint interval for each compression level based on the sample change information corresponding to the current sample point and the trend constraint threshold corresponding to each compression level, and updating the initial or historical trend constraint range through interval intersection, multiple compression levels can maintain trend constraint content that matches the processed sample points within the current segment. Therefore, when determining the target compression level and judging whether to trigger segmented output, the judgment can be based on the continuously updated trend constraint content, thereby improving the accuracy of segment boundary determination and level selection.
[0156] In one possible embodiment, the method steps shown in S104 can be implemented by S1041 to S1045, which are described in detail below.
[0157] S1041. Determine the segment length threshold corresponding to the current segment based on the segment length control rules corresponding to the target compression level.
[0158] In some implementations, the control information corresponding to the target compression level includes segment length control rules. The compression device can determine the segment length threshold corresponding to the current segment based on the segment length control rules for the target compression level. The segment length threshold is used to limit the upper limit of the number of sample points allowed to be included in the current segment under the target compression level.
[0159] In some implementations, different target compression levels can correspond to different segment length thresholds. When the target compression level is low, it indicates that the changes in sample points within the current segment are relatively gentle, allowing the current segment to have a longer segment length; when the target compression level is high, it indicates that the changes in sample points within the current segment are relatively drastic, allowing for a shorter segment length to reduce the loss of local waveform details due to excessively long segments.
[0160] For example, if the target compression level or the currently needed level is denoted as `gear_needed`, the total number of compression levels is denoted as `G`, and the preset maximum segment length is denoted as `max_seg_len`, then the segment length threshold corresponding to the current segment can be expressed as: `threshold = max_seg_len × (1 - (gear_needed - 1) / G)`. Therefore, the higher `gear_needed` is, the smaller the threshold is, allowing segments with more drastic changes to use shorter segment lengths; the lower `gear_needed` is, the larger the threshold is, allowing segments with more gradual changes to form longer segments.
[0161] In addition to the linear decreasing method mentioned above, exponential decreasing, table lookup, or piecewise constant methods can also be used to determine the segment length threshold.
[0162] S1042. Determine the current segment length based on the number of sample points that have been included in the current segment after the starting sample point of the current segment.
[0163] In some implementations, the compression device can count the number of sample points included in the current segment after the starting sample point, and determine the current segment length based on this number of sample points. The current segment length can be used to characterize the scale of sample points already covered by the current segment.
[0164] In some implementations, the current segment length can be determined based on the number of sample points that have been included in the current segment after the starting sample point of the current segment; after the current sample point is included in the current segment, the current segment length can be updated accordingly.
[0165] S1043. Determine the gear containment state corresponding to the current sample point based on the trend constraint content in the gear control information corresponding to multiple compression gears.
[0166] In some implementations, the compression device can determine whether the current sample point can be contained by at least one compression level based on the trend constraints corresponding to multiple compression levels. If the current sample point satisfies the trend constraints corresponding to at least one compression level, the current sample point can be determined to be contained by at least one compression level; if the current sample point does not satisfy the trend constraints corresponding to any of the compression levels, the current sample point cannot be contained by any compression level.
[0167] In some implementations, the gear inclusion state can be determined based on the aforementioned trend inclusion results, or it can be re-determined during segment output judgment based on the currently maintained trend constraints of multiple compression gears. By determining the gear inclusion state, it can be determined whether the current sample point is still suitable to continue being included in the current segment.
[0168] S1044. When the current segment length reaches the segment length threshold, or when the compression level indicates that the current sample point cannot be contained by any compression level, determine to trigger the segment output of the current segment.
[0169] In some implementations, if the current segment length reaches a segment length threshold, it indicates that the current segment has reached the maximum allowable length under the target compression level, and the compression device can determine to trigger the segmented output of the current segment. This method avoids increasing linear prediction error due to an excessively long current segment and also facilitates control over the segment size and buffer usage of the compressed data.
[0170] In some implementations, if the compression level encompasses a sample point that cannot be encompassed by any compression level, it indicates that the change of the current sample point relative to the starting sample point of the current segment has exceeded the trend constraint range that multiple compression levels can provide. In this case, the compression device can determine to trigger the segment output of the current segment in order to end the current segment and establish a new current segment.
[0171] S1045. If the current segment length does not reach the segment length threshold, and the gear containment status indicates that the current sample point can be contained by at least one compression gear, the current sample point is included in the current segment to obtain the updated current segment.
[0172] In some implementations, if the current segment length does not reach the segment length threshold and the current sample point can be contained by at least one compression level, it indicates that the current segment can still be expanded. In this case, the compression device can incorporate the current sample point into the current segment to obtain the updated current segment, and continue to read subsequent sample points according to the sampling order.
[0173] In some implementations, after the current sample point is included in the current segment, the updated current segment can continue to be used for subsequent target compression level determination, trend constraint content update, and segment output judgment. Therefore, while satisfying trend constraints and segment length control, the segment length of gently changing segments can be extended as much as possible, reducing the number of segments and field overhead in the compressed data.
[0174] In this embodiment, by determining the segment length threshold according to the segment length control rules corresponding to the target compression level, and combining the current segment length and the level coverage state corresponding to the current sample point to determine whether to trigger segment output, both segment size limitations and signal change constraints can be considered simultaneously. Therefore, when the current segment still meets the length control and trend coverage requirements, the current segment can continue to expand; when the current segment reaches its length limit or the current sample point exceeds the trend coverage capacity of all compression levels, segment output can be triggered in a timely manner, thereby improving the rationality of segment boundary determination and balancing compression efficiency and reconstruction fidelity.
[0175] In one possible embodiment, the method steps shown in S106 can be implemented by S1061 to S1063, which are described in detail below.
[0176] S1061. Based on the linear prediction benchmark, perform prediction processing on the intermediate sample points within the current segment to obtain the predicted sample values corresponding to the intermediate sample points.
[0177] In some implementations, the linear prediction benchmark can be determined based on the starting and ending sample points of the current segment. Intermediate sample points within the current segment are those located between the starting and ending sample points. The compression device can perform prediction processing on each intermediate sample point within the current segment based on the linear prediction benchmark to obtain the predicted sample value corresponding to that intermediate sample point.
[0178] In some implementations, the predicted sample value can be determined based on the sampling sequence position of the intermediate sample point within the current segment. For example, the compression device can determine the predicted sample value corresponding to the intermediate sample point based on the sample value of the starting sample point of the current segment, the sample value of the ending sample point, the difference in sampling sequence between the starting and ending sample points of the current segment, and the difference in sampling sequence relative to the starting sample point of the current segment. Through this process, the sample change within the current segment can be approximated by the linear trend determined by the starting and ending sample points.
[0179] For example, if the starting sample point of the current segment is anchor, the last sample point is last_point, and the number of sample points in the current segment is counter, then the slope_mid of the linear prediction baseline can be expressed as: .
[0180] For the kth intermediate sample point within the current segment, we can use the formula... Determine the predicted sample value Where k is an integer, and 1≤k≤counter-1.
[0181] S1062. Obtain the actual sample value corresponding to the intermediate sample point.
[0182] In some implementations, the compression device can obtain the actual sample value corresponding to the intermediate sample point from the timing signal to be compressed. The actual sample value is the true sampled value of the intermediate sample point in the timing signal to be compressed, which can be the sample value after unsigned mapping, or the sample value corresponding to the original sampled signal itself being an unsigned integer signal.
[0183] In some implementations, the actual sample values corresponding to intermediate sample points can be cached during the current segment formation process, or they can be reread based on the sample point index of the current segment after the end sample point of the current segment is determined. The specific method used can be determined based on the cache capacity, processing speed, and application scenario of the compression device.
[0184] S1063. Based on the actual sample values and the predicted sample values, determine the residual information corresponding to the intermediate sample points.
[0185] In some implementations, the compression device can determine the residual information corresponding to an intermediate sample point based on the difference between the actual sample value and the predicted sample value corresponding to that intermediate sample point. The residual information is used to characterize the degree of deviation of the intermediate sample point from the linear prediction benchmark.
[0186] For example, the compression device can determine the residual information as the difference between the actual sample value and the predicted sample value, or it can determine the residual information as the difference between the predicted sample value and the actual sample value, as long as the compression side and the decompression side use the same residual definition method. For multiple intermediate sample points within the current segment, the compression device can determine the residual information corresponding to each intermediate sample point separately, and use the multiple residual information for subsequent residual coding processing.
[0187] In this embodiment, by using a linear prediction benchmark determined based on the starting and ending sample points of the current segment, the intermediate sample points within the current segment are predicted. Residual information is then determined based on the predicted and actual sample values, avoiding the direct output of the original values of all sample points within the current segment. Since the residual information primarily characterizes the degree of deviation of intermediate sample points from the linear trend, subsequent encoding only the residual information reduces the amount of compressed data while preserving local waveform variations within the current segment.
[0188] In one possible embodiment, the method steps shown in S107 can be implemented by S1071 to S1074, which are described in detail below.
[0189] S1071. Based on the trend constraint threshold corresponding to the target compression level, the residual information is offset to obtain non-negative residual information for unsigned encoding.
[0190] In some implementations, since the residual information corresponding to intermediate sample points can be positive, negative, or zero, directly encoding the residual information at a fixed-length bit level would require additional processing of the sign bit. To facilitate the use of unsigned encoding, the compression device can offset the residual information based on the trend constraint threshold corresponding to the target compression level, thereby converting the residual information into non-negative residual information as a whole.
[0191] In some implementations, offset processing may include adding the residual information to the trend constraint threshold corresponding to the target compression level or an offset value associated with that trend constraint threshold to obtain non-negative residual information. This offset value remains consistent on both the compression and decompression sides so that reverse processing can be performed based on the same offset value during decompression to recover the corresponding residual information.
[0192] S1072. Based on the preset quantization step size parameter and the residual coding precision corresponding to the target compression level, the non-negative residual information is quantized to obtain the initial quantization residual.
[0193] In some implementations, a preset quantization step size parameter is used to determine the quantization step size used when quantizing residual information, and the residual coding precision corresponding to the target compression level is used to determine the number of bits used in the quantized residual coding. The compression device can quantize the non-negative residual information based on the preset quantization step size parameter to obtain the initial quantized residual.
[0194] For example, the preset quantization step size parameter can include the residual quantization step size exponent lossbits, and the quantization step size can be 2. lossbits The compression device can determine the initial quantization residual based on the relationship between the non-negative residual information and the quantization step size. The above quantization processing can employ rounding, floor function, or other preset quantization methods, as long as the compression and decompression sides use consistent quantization rules.
[0195] S1073. Based on the residual coding precision corresponding to the target compression level, the value range of the initial quantization residual is limited to obtain the target quantization residual.
[0196] In some implementations, the residual coding precision corresponding to the target compression level determines the range of values that the residual coded data can represent. If the residual coding precision corresponding to the target compression level is b, then the corresponding unsigned coded value range can be 0 to 2.b-1 The compression device can limit the initial quantization residual based on this value range to obtain the target quantization residual.
[0197] In some implementations, when the initial quantization residual is less than the lower limit of the coded value range, the target quantization residual can be set as the lower limit; when the initial quantization residual is greater than the upper limit of the coded value range, the target quantization residual can be set as the upper limit; when the initial quantization residual is within the coded value range, the initial quantization residual can be directly set as the target quantization residual. This value range limitation ensures that the subsequently obtained residual coded data can be encoded at a fixed length according to the residual coded precision corresponding to the target compression level.
[0198] For example, the current encoding level is gear, and the trend constraint threshold corresponding to the current encoding level is εgear. For the k-th intermediate sample point within the current segment, it can be determined according to the formula... Determine the offset residual information. .
[0199] in, This represents the actual sample value corresponding to the kth intermediate sample point. Since the residual information is converted to a non-negative value after adding εgear, it facilitates subsequent unsigned encoding.
[0200] Furthermore, it can be based on the formula The residual information is quantized; and its value range is limited according to the residual coding precision b[gear] corresponding to the current coding level. Here, round indicates rounding, and clamp indicates limiting the quantization result to a preset range of values.
[0201] Using the above method, we can obtain the target quantization residual suitable for unsigned fixed-length encoding according to b[gear] bits.
[0202] S1074. Based on the residual coding precision corresponding to the target compression level, the target quantization residual is encoded to obtain residual coding data.
[0203] In some implementations, the compression device can perform fixed-length encoding on the target quantization residual according to the residual encoding precision corresponding to the target compression level, thereby obtaining residual encoded data. For example, when the residual encoding precision corresponding to the target compression level is b bits, a b-bit unsigned field can be used to represent the target quantization residual. For multiple intermediate sample points within the current segment, the corresponding target quantization residuals can be obtained separately, and the residual encoded data can be written sequentially according to the order of the sample points in the current segment.
[0204] In this embodiment, by offsetting the residual information based on the trend constraint threshold corresponding to the target compression level, and performing quantization, range limiting, and fixed-length encoding based on preset quantization step size parameters and residual encoding precision, residual information that may contain positive and negative values can be converted into residual coded data suitable for unsigned bit-level encoding. This allows the residual coded data to match the encoding capability of the target compression level, reducing encoding complexity while improving the standardization of the compressed data structure and decoding consistency.
[0205] In one possible embodiment, the method steps shown in S1044 can be implemented by S10441 to S10443, which are described in detail below.
[0206] S10441. When the current segment length reaches the segment length threshold, the sample point in the current segment that meets the preset segment end condition is determined as the segment end sample point, and the sample point after the segment end sample point is determined as the starting sample point of the next segment.
[0207] In some implementations, when the current segment length reaches the segment length threshold, it indicates that the current segment has reached the allowable length under the segment length control rules corresponding to the target compression level. At this time, the compression device can determine the sample point in the current segment that meets the preset segment tail condition as the segment tail sample point.
[0208] In some implementations, the preset segment tail condition may include: the sample point has been included in the current segment, and the sample point is the ending sample point in the current segment used to establish a linear prediction benchmark together with the starting sample point of the current segment. For example, the last sample point included in the current segment can be determined as the segment tail sample point. The compression device can further determine the sample points after the segment tail sample point as the starting sample points of the next segment, so that after outputting the compressed data corresponding to the current segment, it can continue to perform segmented compression on subsequent time-series signals.
[0209] S10442. When the gear containment state indicates that the current sample point cannot be contained by any compression gear, and the number of sample points already included in the current segment is greater than zero, the last sample point located before the current sample point and already included in the current segment is determined as the end sample point of the segment, and the current sample point is determined as the starting sample point of the next segment.
[0210] In some implementations, when the current sample point cannot be encompassed by any compression level, and there are already sample points included in the current segment, it indicates that the change of the current sample point relative to the starting sample point of the current segment has exceeded the range that the current segment can encompass, but the current segment itself has already formed an output segment. In this case, the compression device can determine the last sample point located before the current sample point and already included in the current segment as the segment tail sample point.
[0211] In this scenario, the current sample point is not included in the current segment but is instead designated as the starting sample point for the next segment. This process avoids forcibly including current sample points that cannot be encompassed by any compression level into the current segment, thereby reducing the possibility of excessive linear prediction errors within the current segment. Simultaneously, the original value of the current sample point can be retained as the starting reference for the next segment, ensuring that subsequent segment compression can proceed continuously.
[0212] S10443. When the gear containment state indicates that the current sample point cannot be contained by any compression gear, and the number of sample points already included in the current segment is zero, the current sample point is output as a single point of raw data, and the sample points after the current sample point are used to establish a new current segment.
[0213] In some implementations, when the current sample point cannot be encompassed by any compression level, and the number of sample points already included in the current segment is zero, it indicates that the current sample point has changed too much relative to the starting sample point of the current segment, causing the current segment to be unable to form a regular segment containing intermediate sample points. In this case, if the processing continues according to the regular segmentation method, it may be impossible to effectively establish a linear prediction benchmark or obtain coded residual information.
[0214] Therefore, the compression device can output the current sample point as single-point raw data. This single-point raw data may include the original value of the current sample point, or it may include identification information that identifies the data as single-point raw data. Subsequently, the compression device can use the sample points after the current sample point to establish a new current segment, so as to continue to execute the subsequent segmented compression process.
[0215] In this embodiment, by distinguishing between three scenarios—the current segment length reaching a segment length threshold, the current sample point not being encompassed by any compression level and the number of sample points already included in the current segment being greater than zero, and the current sample point not being encompassed by any compression level and the number of sample points already included in the current segment being zero—the tail sample point of the segment, the starting sample point of the next segment, or the single-point raw data output method can be determined according to different triggering reasons. This avoids abnormally changing sample points from disrupting the linear prediction relationship of the current segment, while ensuring that continuous time-series signals can still be stably compressed and output even in boundary scenarios.
[0216] In some implementations, the decoding end can reconstruct the sample points in the current segment based on the target compression level identifier information, the segment length information of the current segment, the original value of the end sample point of the segment, the original value of the starting sample point of the next segment, and the residual coding data.
[0217] For example, the decoder can read the gear corresponding to the current segment and determine the linear prediction baseline based on the last_point of the segment end and the anchor of the current segment start: slope_mid=(last_point-anchor) / counter.
[0218] Furthermore, the decoding end can read the quantization residual corresponding to the kth intermediate sample point. And according to the formula To obtain the reconstructed sample values .
[0219] After reconstructing the current segment, the decoder can output the last_point of the segment's last sample point and use the starting sample point of the next segment as the new anchor to continue decoding. If it is necessary to recover the signed signal, the offset 2 can be subtracted after obtaining the unsigned reconstructed sample values. (Lori-1) This yields the corresponding original signed sample values.
[0220] In one possible embodiment, this application also provides an adaptive compression apparatus for timing signals. This apparatus can be used to execute the adaptive compression method for timing signals described in any of the above embodiments. The apparatus can be a standalone compression device or integrated into a sensor terminal, embedded processor, low-power microcontroller, edge computing device, data acquisition device, server, or other electronic device with timing signal processing and data encoding capabilities.
[0221] Figure 2 This is a schematic diagram of the structure of an adaptive compression device for timing signals provided in an embodiment of this application. Figure 2 As shown, the adaptive compression device 200 for the time-series signal includes a signal acquisition module 201, a gear determination module 202, a trend constraint update module 203, a segmented output judgment module 204, a prediction benchmark determination module 205, a residual information determination module 206, a residual encoding module 207, and a compressed data output module 208.
[0222] The signal acquisition module 201 is used to acquire the timing signal to be compressed and determine the starting sample point of the current segment from the timing signal. Specifically, the signal acquisition module can acquire multiple sample points arranged in the order of sampling time, and determine the first sample point in the timing signal to be compressed as the starting sample point of the current segment when compression begins; in subsequent segmented compression processes, the starting sample point of the next segment determined by the previous segment can be used as the starting sample point of the new current segment.
[0223] The compression level determination module 202 is used to read the current sample points after the starting sample point of the current segment according to the sampling order. Based on the change relationship of the current sample points relative to the starting sample point of the current segment, and the compression level control information corresponding to multiple preset compression levels, it determines the target compression level corresponding to the current segment from multiple compression levels. Among them, the compression level control information is used to perform trend constraints on the sample points, encode the residual information, and control the segment length.
[0224] The trend constraint update module 203 is used to update the trend constraint content in the gear control information corresponding to multiple compression gears based on the current sample point and the starting sample point of the current segment. Specifically, the trend constraint update module can synchronously update the trend constraint content corresponding to each compression gear according to the change of the current sample point relative to the starting sample point of the current segment, so that each compression gear maintains a trend constraint state that matches the read sample point within the current segment.
[0225] The segmented output judgment module 204 is used to determine whether to trigger segmented output of the current segment based on the gear control information corresponding to the target compression gear. Specifically, the segmented output judgment module can determine whether the current segment meets the segmented output conditions based on the segment length control rules corresponding to the target compression gear, the current segment length, and the gear containment state corresponding to the current sample point.
[0226] The prediction benchmark determination module 205 is used to determine the end sample point of the current segment and the starting sample point of the next segment when the segment output of the current segment is triggered, and to determine a linear prediction benchmark based on the starting sample point and the end sample point of the current segment. This linear prediction benchmark is used to characterize the approximate change trend of the sample points within the current segment.
[0227] The residual information determination module 206 is used to determine the residual information of intermediate sample points within the current segment based on the linear prediction benchmark. Specifically, the residual information determination module can determine the predicted sample value corresponding to the intermediate sample point based on the linear prediction benchmark, and determine the residual information corresponding to the intermediate sample point based on the difference between the predicted sample value and the actual sample value.
[0228] The residual encoding module 207 is used to encode residual information based on the gear control information corresponding to the target compression gear to obtain residual encoded data. Specifically, the residual encoding module can perform offsetting, quantization, value range limitation, and encoding processing on the residual information according to the trend constraint threshold corresponding to the target compression gear, the preset quantization step size parameter, and the residual encoding precision, thereby obtaining the residual encoded data corresponding to the current segment.
[0229] The compressed data output module 208 is used to output the compressed data corresponding to the current segment, and to continue compressing the subsequent sample points in the time sequence signal by using the starting sample point of the next segment as the starting sample point of the new current segment. The compressed data includes the target compression level identifier information, the segment length information of the current segment, the original value of the end sample point of the segment, the original value of the starting sample point of the next segment, and residual encoded data.
[0230] In some implementations, the above modules can be implemented by software programs, hardware circuits, or a combination of both. For example, the above modules can be implemented by a processor executing a computer program stored in memory; or, some of the above modules can be implemented by fixed-point arithmetic units, cache units, encoding units, or logic control circuits. This application does not limit this approach.
[0231] In this embodiment, the starting sample point of the current segment is determined by the signal acquisition module, the target compression level is adaptively determined by the level determination module based on the changing relationship of the current sample point, the trend constraint update module synchronously maintains the trend constraint content corresponding to multiple compression levels, and the segment output judgment module, prediction benchmark determination module, residual information determination module, residual encoding module, and compressed data output module complete the segment output, linear prediction, residual encoding, and compressed data output. This enables the device to adaptively adjust the compression control mode according to the local fluctuation degree of the time-series signal. Therefore, in resource-constrained one-dimensional time-series signal compression scenarios, both compression efficiency and reconstruction fidelity can be balanced.
[0232] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 3 As shown, the electronic device 300 provided in this embodiment includes a memory 301 and a processor 302.
[0233] The memory 301 can be a separate physical unit, connected to the processor 302 via a bus 303. Alternatively, the memory 301 and processor 302 can be integrated and implemented in hardware. The memory 301 stores program instructions, which the processor 302 calls to execute the operations performed by the adaptive compression device for timing signals in any of the above method embodiments.
[0234] Optionally, when some or all of the methods in the above embodiments are implemented by software, the electronic device 300 may also include only the processor 302. A memory 301 for storing programs is located outside the electronic device 300, and the processor 302 is connected to the memory via circuits / wires to read and execute the programs stored in the memory. The processor 302 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and an NP. The processor 302 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0235] The memory 301 may include volatile memory, such as random-access memory (RAM); the memory may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory may also include a combination of the above types of memory.
[0236] For example, this application provides a chip including: an interface circuit and a logic circuit. The interface circuit is used to receive signals from other chips outside the chip and transmit them to the logic circuit, or to send signals from the logic circuit to other chips outside the chip. The logic circuit is used to perform the operations performed by the timing signal adaptive compression device in the above method embodiments.
[0237] For example, this application provides a computer-readable storage medium storing computer program instructions thereon, which are executed by the processor of an electronic device to cause the electronic device to perform the operations performed by the adaptive compression device for timing signals in the above method embodiments.
[0238] For example, this application provides a computer program product that, when run on an electronic device, causes the electronic device to perform the operations performed by the adaptive compression device for timing signals in the above method embodiments.
[0239] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An adaptive compression method for time-series signals, characterized in that, The method includes: Acquire the timing signal to be compressed, and determine the starting sample point of the current segment from the timing signal; The current sample points after the starting sample point of the current segment are read according to the sampling order. Based on the change relationship of the current sample points relative to the starting sample point of the current segment, and the gear control information corresponding to multiple preset compression gears, the target compression gear corresponding to the current segment is determined from the multiple compression gears. The gear control information is used to perform trend constraints on the sample points, encode the residual information, and control the segment length. Based on the current sample point and the starting sample point of the current segment, update the trend constraint content in the gear control information corresponding to the multiple compression gears respectively; Based on the gear control information corresponding to the target compression gear, determine whether to trigger the segmented output of the current segment; When the segmented output of the current segment is triggered, the end sample point of the current segment and the start sample point of the next segment are determined, and the linear prediction benchmark is determined based on the start sample point of the current segment and the end sample point. Based on the linear prediction benchmark, determine the residual information of the intermediate sample points within the current segment; Based on the gear control information corresponding to the target compression gear, the residual information is encoded to obtain residual encoded data. Output the compressed data corresponding to the current segment, and use the starting sample point of the next segment as the starting sample point of the new current segment to continue compressing the subsequent sample points in the time sequence signal; wherein, the compressed data includes the gear identification information of the target compression level, the segment length information of the current segment, the original value of the end sample point of the segment, the original value of the starting sample point of the next segment, and the residual coding data.
2. The method according to claim 1, characterized in that, The step of acquiring the time-series signal to be compressed and determining the starting sample point of the current segment from the time-series signal includes: Acquire the original sampled signal and determine the original bit width information corresponding to the original sampled signal; When the original sampled signal is a signed integer signal, the offset is determined based on the original bit width information; Based on the offset, the sample points in the original sampled signal are unsigned mapped to obtain an unsigned time-series signal; The unsigned timing signal is determined as the timing signal, and the first sample point in the timing signal is determined as the starting sample point of the current segment.
3. The method according to claim 2, characterized in that, Before reading the current sample points after the starting sample point of the current segment according to the sampling order, the method further includes: For any one of the plurality of compression levels, determine the level number of the compression level; Based on the gear number and the original bit width information, determine the residual coding precision corresponding to the compression gear; Based on the residual coding accuracy and the preset quantization step size parameter, determine the trend constraint threshold corresponding to the compression level; Based on the trend constraint threshold, determine the initial range of the trend constraint corresponding to the compression gear; Based on the gear number, the total number of the multiple compression gears, and the preset maximum segment length, determine the segment length control rule corresponding to the compression gear; Based on the residual coding accuracy, the trend constraint threshold, the initial range of the trend constraint, and the segment length control rule, the gear control information corresponding to the compression gear is obtained.
4. The method according to claim 1, characterized in that, The step of determining the target compression level corresponding to the current segment from the multiple compression levels based on the change relationship between the current sample point and the starting sample point of the current segment, and the level control information corresponding to the multiple preset compression levels, includes: Based on the current sample point and the starting sample point of the current segment, determine the trend change information of the current sample point relative to the starting sample point of the current segment; Based on the trend change information and the trend constraint content corresponding to each compression level, determine the trend inclusion result of each compression level for the current sample point; If at least one of the compression levels corresponding to the trend inclusion result characterization can encompass the current sample point, the target compression level is determined from the compression levels that can encompass the current sample point in the order of the compression levels.
5. The method according to claim 3, characterized in that, The step of updating the trend constraint content in the gear control information corresponding to the multiple compression gears based on the current sample point and the starting sample point of the current segment includes: Based on the current sample point and the starting sample point of the current segment, determine the sample change information corresponding to the current sample point; For any compression level among the plurality of compression levels, the current trend constraint interval corresponding to the compression level is determined based on the sample change information and the trend constraint threshold corresponding to the compression level. Based on the current trend constraint interval, the initial range or historical trend constraint range corresponding to the compression gear is updated to obtain the updated trend constraint range corresponding to the compression gear. The updated trend constraint range is determined to be the trend constraint content in the gear control information corresponding to the compression gear.
6. The method according to claim 1, characterized in that, The step of determining whether to trigger the segmented output of the current segment based on the gear control information corresponding to the target compression gear includes: Based on the segment length control rules corresponding to the target compression level, determine the segment length threshold corresponding to the current segment; The length of the current segment is determined based on the number of sample points that have been included in the current segment after the starting sample point of the current segment. Based on the trend constraint content in the gear control information corresponding to the multiple compression gears, determine the gear containment state corresponding to the current sample point. If the current segment length reaches the segment length threshold, or if the gear containment state indicates that the current sample point cannot be contained by any of the compression gears, then the segment output of the current segment is determined to be triggered. If the current segment length does not reach the segment length threshold, and the gear inclusion state indicates that the current sample point can be included by at least one compression gear, the current sample point is included in the current segment to obtain the updated current segment.
7. The method according to claim 1, characterized in that, The step of determining the residual information of intermediate sample points within the current segment based on the linear prediction benchmark includes: Based on the linear prediction benchmark, the intermediate sample points within the current segment are predicted to obtain the predicted sample values corresponding to the intermediate sample points. Obtain the actual sample value corresponding to the intermediate sample point; Based on the actual sample values and the predicted sample values, the residual information corresponding to the intermediate sample points is determined.
8. The method according to claim 7, characterized in that, The gear control information corresponding to the target compression gear includes a trend constraint threshold and residual coding precision. The residual information is encoded based on the gear control information corresponding to the target compression gear to obtain residual coded data, including: Based on the trend constraint threshold corresponding to the target compression level, the residual information is offset to obtain non-negative residual information for unsigned encoding. Based on the preset quantization step size parameter and the residual coding precision corresponding to the target compression level, the non-negative residual information is quantized to obtain the initial quantized residual. Based on the residual coding precision corresponding to the target compression level, the value range of the initial quantization residual is limited to obtain the target quantization residual; Based on the residual coding precision corresponding to the target compression level, the target quantization residual is encoded to obtain the residual coding data.
9. The method according to claim 6, characterized in that, The step of determining to trigger segment output for the current segment when the current segment length reaches the segment length threshold, or when the compression level encompasses the current sample point and indicates that it cannot be encompassed by any compression level, includes: When the current segment length reaches the segment length threshold, the sample point in the current segment that meets the preset segment end condition is determined as the segment end sample point, and the sample point after the segment end sample point is determined as the starting sample point of the next segment. When the gear containment state indicates that the current sample point cannot be contained by any of the compression gears, and the number of sample points already included in the current segment is greater than zero, the last sample point located before the current sample point and already included in the current segment is determined as the end sample point of the segment, and the current sample point is determined as the starting sample point of the next segment. When the compression level indicates that the current sample point cannot be contained by any compression level and the number of sample points already included in the current segment is zero, the current sample point is output as a single point of raw data, and the sample points after the current sample point are used to establish a new current segment.
10. An adaptive compression device for time-series signals, characterized in that, The device includes: The signal acquisition module is used to acquire the timing signal to be compressed and determine the starting sample point of the current segment from the timing signal; The compression level determination module is used to read the current sample points after the starting sample point of the current segment according to the sampling order, and determine the target compression level corresponding to the current segment from the multiple compression levels based on the change relationship of the current sample points relative to the starting sample point of the current segment and the compression level control information corresponding to the multiple preset compression levels; wherein, the compression level control information is used to perform trend constraints on the sample points, encode the residual information, and control the segment length. The trend constraint update module is used to update the trend constraint content in the gear control information corresponding to the multiple compression gears based on the current sample point and the starting sample point of the current segment. The segmented output judgment module is used to determine whether to trigger the segmented output of the current segment based on the gear control information corresponding to the target compression gear. The prediction benchmark determination module is used to determine the end sample point of the current segment and the start sample point of the next segment when the segment output of the current segment is triggered, and to determine the linear prediction benchmark based on the start sample point and the end sample point of the current segment. The residual information determination module is used to determine the residual information of intermediate sample points within the current segment based on the linear prediction benchmark. The residual encoding module is used to encode the residual information based on the gear control information corresponding to the target compression gear to obtain residual encoded data. The compressed data output module is used to output the compressed data corresponding to the current segment, and to continue compressing the subsequent sample points in the time sequence signal by using the starting sample point of the next segment as the starting sample point of the new current segment; wherein, the compressed data includes the gear identification information of the target compression level, the segment length information of the current segment, the original value of the end sample point of the segment, the original value of the starting sample point of the next segment, and the residual coding data.