CN113542225B - Data compression method and device, terminal equipment and storage medium - Google Patents

Data compression method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN113542225B
CN113542225B CN202110674907.6A CN202110674907A CN113542225B CN 113542225 B CN113542225 B CN 113542225B CN 202110674907 A CN202110674907 A CN 202110674907A CN 113542225 B CN113542225 B CN 113542225B
Authority
CN
China
Prior art keywords
data
length
duration
time length
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110674907.6A
Other languages
Chinese (zh)
Other versions
CN113542225A (en
Inventor
姚探桩
罗国发
沈海燕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SHENZHEN HEGUANG MEASUREMENT CONTROL TECHNOLOGY CO LTD
Original Assignee
SHENZHEN HEGUANG MEASUREMENT CONTROL TECHNOLOGY CO LTD
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHENZHEN HEGUANG MEASUREMENT CONTROL TECHNOLOGY CO LTD filed Critical SHENZHEN HEGUANG MEASUREMENT CONTROL TECHNOLOGY CO LTD
Priority to CN202110674907.6A priority Critical patent/CN113542225B/en
Publication of CN113542225A publication Critical patent/CN113542225A/en
Application granted granted Critical
Publication of CN113542225B publication Critical patent/CN113542225B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/04Protocols for data compression, e.g. ROHC
    • GPHYSICS
    • G08SIGNALLING
    • G08CTRANSMISSION SYSTEMS FOR MEASURED VALUES, CONTROL OR SIMILAR SIGNALS
    • G08C23/00Non-electrical signal transmission systems, e.g. optical systems
    • G08C23/04Non-electrical signal transmission systems, e.g. optical systems using light waves, e.g. infrared

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The application is applicable to the technical field of data processing, and provides a data compression method, a device, terminal equipment and a storage medium, wherein the method comprises the following steps: acquiring time length data of each code in the data to be processed; recording duration data meeting first preset requirements as first data; compressing the data to be processed according to the first data; according to the method and the device, the first data is obtained from the duration data, the data to be processed is compressed according to the first data, the data to be processed can be compressed, the compressed data is stored, the storage space can be reduced, the first data is obtained by searching from the duration data, and the data is compressed according to the first data, so that the compression is more convenient and rapid.

Description

Data compression method and device, terminal equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a data compression method, a data compression device, a terminal device, and a storage medium.
Background
The learning type infrared remote controller is provided with an infrared receiving tube, and the infrared receiving tube is used for receiving the infrared codes to be learned and then storing the learned infrared codes. The learning of the infrared codes is a process of storing the time duration of the high level and the low level on the infrared codes.
At present, the learning type infrared remote controller needs less infrared codes to learn and has less information, for example, the learning of the television set top box remote controller only needs to learn a power switch and a volume, and the learning type infrared remote controller can directly store the infrared codes after receiving the infrared codes because the infrared codes are less and the information is less in required storage space. But for complex infrared coding, for example: the on-off state, the air conditioning mode, the air conditioning air quantity, the current temperature and the like on the air conditioning remote controller have larger required storage space, and the existing learning type infrared remote controller cannot store complicated infrared codes.
Disclosure of Invention
The embodiment of the application provides a data compression method, a device, terminal equipment and a storage medium, which can solve the problem that a learning type infrared remote controller cannot store complex infrared codes.
In a first aspect, an embodiment of the present application provides a data compression method, including:
acquiring time length data of each code in the data to be processed;
recording duration data meeting first preset requirements as first data;
and compressing the data to be processed according to the first data.
In a second aspect, an embodiment of the present application provides a data compression apparatus, including:
the data acquisition module is used for acquiring time length data of each code in the data to be processed;
the data searching module is used for recording the duration data meeting the first preset requirement as first data;
and the data compression module is used for compressing the data to be processed according to the first data.
In a third aspect, an embodiment of the present application provides a terminal device, including: a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method of compressing data according to any one of the above first aspects when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer readable storage medium storing a computer program, where the computer program when executed by a processor implements the method for compressing data according to any one of the first aspects.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when run on a terminal device, causes the terminal device to perform the method of compressing data according to any one of the first aspects above.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the method, firstly, each coded time length data in the data to be processed is obtained, the time length data meeting the first preset requirement is recorded as first data, the data to be processed is compressed according to the first data, the first data is obtained from the time length data, the data to be processed is compressed according to the first data, the data to be processed can be compressed, the compressed data is saved, the storage space can be reduced, the first data is obtained from the time length data in a searching mode, and the data is compressed according to the first data, so that the compression is more convenient and quick.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is an application scenario schematic diagram of a data compression method according to an embodiment of the present application;
FIG. 2 is a flow chart of a method for compressing data according to an embodiment of the present application;
FIG. 3 is a general flow chart of a method for compressing data according to an embodiment of the present application;
FIG. 4 is a flow chart illustrating a method for determining first data during lossless compression according to an embodiment of the present application;
FIG. 5 is a general flow diagram of a lossless compression method according to an embodiment of the present application;
FIG. 6 is a flow chart of data compression for lossless compression according to an embodiment of the present application;
FIG. 7 is a flow chart illustrating a method for determining first data during lossy compression according to an embodiment of the present application;
FIG. 8 is a general flow chart of a lossy compression method according to an embodiment of the application;
FIG. 9 is a flow chart of lossy compressed data compression according to one embodiment of the present application;
FIG. 10 is a schematic diagram of a data compression apparatus according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in the present description and the appended claims, the term "if" may be interpreted in context as "when … …" or "upon" or "in response to a determination" or "in response to detection. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Furthermore, the terms "first," "second," "third," and the like in the description of the present specification and in the appended claims, are used for distinguishing between descriptions and not necessarily for indicating or implying a relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
At present, the learning type infrared remote controller has less infrared codes, and generally does not exceed 10; and each infrared code learned contains less information, and the infrared code is very short. Therefore, the learning type infrared remote controller used at present only needs little storage space, and the requirement on the size of the memory in hardware is not high. For example, 10 instructions are learned, the code (high-low level change) combination of the instructions calculates the most complex change, each instruction occupies 200 bytes of storage, 2000 bytes are needed for 10 instructions, and only one relatively cheap IIC chip AT24C02 is needed for storing 2000 bytes. If complex instructions need to be stored, more memory space is required.
Since the storage of the infrared codes is to store the time of the high and low levels in the infrared codes. In order to minimize distortion when storing infrared codes, the smaller the time period that needs to be stored, the better. And because the data for storing one level occupies at least two bytes, if the level in the infrared code changes y times, 2y bytes are needed to be stored. If each instruction can provide a maximum of 332 bytes of saved bytes, the level in the ir code changes 166 times at most, which is sufficient for ir coding of fixed information classes. However, since the level of the level change is changed more than 200 times for the infrared code containing a large amount of information, the level of the level change is stored 166 times, and the level of the level change cannot be stored for the infrared code containing a large amount of information. How to reduce the storage cost of the infrared codes and efficiently decompress the infrared codes is a problem to be solved at present.
Fig. 1 is a schematic application scenario diagram of a data compression method according to an embodiment of the present application, where the data compression method may be used to compress and store an infrared code. The storage device 10 is configured to store an infrared code to be learned, and the electronic device 20 is configured to obtain the infrared code to be learned from the storage device 10, compress the infrared code, and store the compressed infrared code.
The following describes the data compression method according to the embodiment of the present application in detail with reference to fig. 1.
Fig. 2 shows a schematic flow chart of a data compression method provided by the present application, and referring to fig. 2, the method is described in detail as follows:
s101, acquiring time length data of each code in the data to be processed.
In this embodiment, the data to be processed may be infrared encoded. For convenience of explanation, the data to be processed will be described as infrared codes. The ir codes may be obtained from a memory device in which the ir codes are stored. The storage device may be a television remote control, an air conditioner remote control, a set-top box remote control, or the like.
In this embodiment, the duration data is the duration of each high and low level in the ir code. After the electronic equipment receives the infrared codes, the time of each high level and each low level in the infrared codes is obtained by utilizing the capture function of the singlechip.
In one possible implementation, the code length of the data to be processed may also be obtained.
In this embodiment, the code length is the number of level changes in the infrared code. The code length may be obtained from a storage device. Specifically, after the data processing device obtains the infrared codes, the data processing device analyzes the infrared codes to obtain the coding length of the infrared codes and the duration data of each code. The data processing equipment sends the analyzed coding length of the infrared codes and the time length data of each code to the storage equipment for storage.
By way of example, if the first level in the ir encoding is high, the second level is low and the third level is high. The encoding length of the infrared encoding is 3, so that the time length data of the first level is 0.55ms, the time length data of the second level is 0.8ms, and the time length data of the third level is 0.4ms.0.55ms, 0.8ms and 0.4ms are duration data.
S102, recording duration data meeting first preset requirements as first data.
In this embodiment, after the ir codes are obtained, it may be determined whether the ir codes need to be compressed according to the duration data and the code length.
Specifically, when the encoding length and the duration data meet a first preset condition, the duration data meeting the first preset requirement are recorded as first data.
Specifically, if the encoding length and duration data meet a first preset condition, the infrared encoding is determined to be stored after compression. That is, the ir codes cannot be stored directly and need to be compressed. The first data may be shared data as duration data. The first data may include one or more.
Specifically, if the encoding length and duration data meet the second preset condition, it is determined that the data to be processed meet the storage requirement without compression, that is, the data to be processed can be directly stored.
In this embodiment, both the first preset condition and the second preset condition may be set as needed.
In this embodiment, the second preset condition includes that the encoding length is less than or equal to a third preset value, and no duration data greater than or equal to the second preset value exists in the duration data.
S103, compressing the data to be processed according to the first data.
In this embodiment, after the first data is obtained, the first data may be numbered. The number may be a character or a number having a recognition function. One first data corresponds to a unique number. And compressing the data to be processed according to the first data and the serial number of the first data.
In the embodiment of the application, firstly, the time length data of each code in the data to be processed is acquired, the time length data meeting the first preset requirement is recorded as the first data, and the data to be processed is compressed according to the first data.
As shown in fig. 3, in one possible implementation, the first preset condition may include a first condition and/or a second condition. Wherein the first condition comprises: the coding length is smaller than or equal to the first preset value, and the duration data larger than the second preset value exist in the duration data. The second condition includes: the encoding length is larger than a third preset value, and/or the encoding length is larger than the first preset value, the encoding length is smaller than the third preset value, and the duration data which is larger than the second preset value exist in the duration data, and/or the data to be processed fail in lossless compression processing.
Specifically, the first preset value is a lossless compressed data length. The length of the lossless compression data is the difference between the encoded storage length and the length of the first data, which can be set as required. For example, the encoded storage length is 332, the length of the first data is 64, and the lossless compressed data length is: 332-64=268.
Specifically, the second preset value may be set as required, for example, the second preset value may be set to 255, and 255 is a time value corresponding to one byte.
Specifically, the third preset value is the code storage length, for example, the third preset value may be 332.
In this embodiment, if the encoding length and the duration data satisfy a first condition, an attempt is made to lossless compress the data to be processed. And if the coding length and the duration data meet the second condition, carrying out lossy compression on the data to be processed.
When the data to be processed is processed, whether the data to be processed needs to be compressed or not is judged according to the first preset condition and the second preset condition, if the data to be processed needs to be compressed and meets the first condition, lossless compression is performed, and if lossless compression fails, lossy compression can be performed. If the data to be processed satisfies the second condition, an attempt to lossy compression may be made.
In the embodiment of the application, firstly, the compression mode of the data to be processed can be judged through screening of the first condition and the second condition, when one of the second conditions is met, the lossy compression can be directly tried, the lossless compression can be not tried, the processing steps are reduced, the processing speed is improved, and the application provides a plurality of compression methods which can be used for carrying out compression processing according to the first condition and the second condition.
As shown in fig. 3, in a possible implementation manner, the method for searching the first data when the encoding length and duration data meet the first condition and the second condition is different, and an appropriate method may be selected according to needs to obtain the first data. Specifically, the implementation procedure of step S102 may include:
s1021, performing lossless compression attempt on the data to be processed when the first preset conditions comprise a first condition and the coding length and the duration data meet the first condition, searching the duration data meeting the second preset requirement, and if the duration data meet the lossless compression requirement, recording the duration data meeting the second preset requirement as first data. The first preset requirements include a second preset requirement.
Specifically, lossless compression requirements include: the number of the duration data meeting the second preset requirement is within a second preset range. The second preset range may be set as desired, for example, the second preset range may be set to 1-32, and the second preset range includes 1 and 32. The first preset range includes a second preset range.
As shown in fig. 4 and 5, in particular, the implementation procedure of step S1021 may include:
s10211, taking the 1 st time length data in the time length data as a first time length, wherein the first time length forms a first set.
In this embodiment, the time length data may be arranged, and the 1 st time length data in the arranged time length data is used as the first time length.
S10212, determining a first difference value between the ith time length data and each first time length in the first set, wherein i is more than 1 and less than or equal to d, and d is the number of the time length data.
In this embodiment, starting from the 2 nd time length data, the difference value between each data in the arranged time length data and each first time length in the first set is calculated in sequence, and is denoted as a first difference value in the present application.
S10213, if the first difference value in the first range does not exist in the first difference value, and the number of the first duration in the first set at the current time is smaller than the maximum value of the second preset range, adding the ith duration data into the first set as the first duration.
In this embodiment, satisfying the first array requirement may be included in the first range. The first range may be set as desired, for example, the first range may be 0-3. And if the first difference value is not in the first range, adding the ith duration data into the first set as a first duration.
Optionally, if the first difference value does not exist in the first range, the ith duration data is added to the first set as a first duration. After the last first duration in the first set is obtained, if the number of the first durations in the first set is within a second preset range, the first duration in the first set is used as the first data.
In this embodiment, if the first difference value does not exist in the first range, and the number of the first durations in the first set at the current time is greater than or equal to the maximum value of the second preset range, it is determined that the data to be processed fails to undergo lossless compression processing.
S10214, after the last first duration in the first set is obtained, if the number of the first durations in the first set is within a second preset range, taking the first duration in the first set as the first data.
In this embodiment, the last first duration in the first set is the first duration added last in the first set after the first difference is calculated between the d-th duration data and the first duration and after whether the d-th duration data is the first duration is determined.
By way of example, if the infrared code is 10010, the duration data are 210, 260, 230, 280, and 233, respectively. The first range is 0-3. The second preset range is 1-32.
210 is stored as a first time period in a first set. 260-210=40, 40 > 3, then 260 is stored as the first time period in the first set. 230-210=20 > 3, 260-230=30 > 3, then 230 is stored as the first time length into the first set. 280-210=70 > 3, 280-260=20 > 3, 280-230=50 > 3, 280 is stored as a first time length in the first set. 233-230=3, 233 is not the first duration. The number of the first time periods in the first set is 4, and the number of the first time periods in the first set is within a second preset range, so that the first data are 210, 260, 230 and 280.
In this embodiment, if the number of the first durations in the first set is not within the second preset range, it is determined that the data to be processed cannot be subjected to lossless compression processing. It is necessary to continue to try whether the lossy compression process can be performed.
In the embodiment of the application, when lossless compression is attempted, whether the data to be processed meets the lossless compression requirement is judged according to the determined time length data meeting the first preset requirement, if the time length data meeting the first preset requirement is met, the time length data meeting the first preset requirement can be used as the first data, the condition is provided for the determination of the first data, and lossless compression can be performed only after the first data is determined, and if the first data can not be determined, the lossless compression can not be performed, so that the judging condition is provided for the lossless compression, the possibility of failure of the lossless compression is reduced, the success rate of data compression is improved, and the lossless compression rate is ensured.
In one possible implementation manner, when the first preset condition includes a first condition and the encoding length and duration data meets the first preset condition, the implementation process of step S103 may include:
s1031, carrying out lossless compression processing on the data to be processed according to the first data.
As shown in fig. 5 and 6, in particular, the implementation procedure of step S1031 may include:
s10311, numbering the first data.
S10312, obtaining j-th time length data in the time length data, wherein j is more than or equal to 1 and less than or equal to d.
In the application, the relation between each duration data and the first data in the duration data is judged in turn.
S10313, if the first data which is equal to the j-th time length data exists in the first data, compressing the number of the first data which is equal to the j-th time length data to obtain the compressed j-th time length data.
In this embodiment, if the first data is equal to the jth time length data, it is described that the jth time length data is used as the first data. Only the number corresponding to the j-th time length data is compressed. And when decompressing, decompressing to obtain a number corresponding to the jth time length data, and obtaining the value of the jth time length data in the first data according to the number.
In this embodiment, after the compressed jth time length data is obtained, the jth time length data may be stored in correspondence or association with the compressed jth time length data.
S10314, if the first data does not have the first data equal to the j-th time length data, compressing the number of the first data corresponding to the target difference value and the target difference value together to obtain compressed j-th time length data, wherein the target difference value is any one of the first difference values which meet the first array requirement.
In this embodiment, if the data equal to the jth time length data cannot be found in the first data, the compression cannot be performed according to the number of the jth time length data, and the difference between the jth time length data and each first data needs to be calculated, which is referred to as a first difference in the present application.
In this embodiment, the first difference value within the first range of the first difference values is searched, and if there are a plurality of first difference values within the first range of the first difference values, any one of the first difference values within the first range may be used as the target difference value. In addition, the minimum value among the first difference values within the first range may also be taken as the target difference value.
In this embodiment, the number of the first data corresponding to the target difference value and the target difference value are compressed together. And when decompressing, decompressing to obtain the serial number of the first data corresponding to the target difference value and the target difference value, obtaining the first data by using the serial number of the first data corresponding to the target difference value, and calculating the sum of the first data and the target difference value to obtain the j-th duration data.
By way of example, if the infrared-encoded duration data are 210, 260, 230, 280, and 233, respectively. The first data are 210, 260, 230, 280, and the first data are numbered 210 as 1, 260 as 2, 230 as 3, 280 as 4, respectively. Then 210 is compressed to 1. 260 is 2 after compression. 230 is 3 after compression. 280 is compressed to 4. 233 and 230 are 3, 233 is compressed to be number 3 and 3.
In the embodiment of the application, the serial number and the difference value of the first data corresponding to the duration data are compressed, the serial number and the difference value of the first data corresponding to the duration data occupy one byte, the serial number and the difference value of the compressed first data are utilized to characterize the duration data, the number of bytes occupied by the duration data in storage can be smaller, and the storage space is saved.
As shown in fig. 3, in one possible implementation, the implementation procedure of step S102 may further include:
s1022, when the first preset condition includes a second condition, and the coding length and the duration data meet the second condition, performing lossy compression attempt on the data to be processed, searching duration data meeting a third preset requirement, and if the duration data meets the lossy compression requirement, recording the duration data meeting the third preset requirement as first data. The first preset requirements include a third preset requirement.
Specifically, the lossy compression requirements include: the number of the duration data meeting the third preset requirement is within a third preset range. The third preset range may be set as needed, for example, the third preset range may be set to 1-16, and the third preset range includes 1 and 16. The first preset range includes a third preset range.
As shown in fig. 7 and 8, in particular, the implementation procedure of step S1022 may include:
s10221, taking the 1 st time length data in the time length data as a first time length, wherein the first time length forms a first set.
S10222, determining a first difference value between the ith duration data and each first duration in the first set, wherein i is more than 1 and less than or equal to d, and d is the number of the duration data;
s10223, if the first difference value which is equal to the preset threshold value does not exist in the first difference values, the ith duration data is added into the first set as a first duration.
In this embodiment, the first array requirement is satisfied to be equal to the preset threshold. For example, the preset threshold may be 2 in the array set. The array set may include 2, 3, and 4. The data in the array set can be set with priority, the data with high priority is used as a preset threshold, and when the number of the first duration does not meet the third preset range, the data with low priority is used as the preset threshold in sequence.
Optionally, if the first difference value equal to the preset threshold value does not exist in the first difference value, and the number of the first duration in the first set is smaller than the maximum value of the third preset range, adding the ith duration data into the first set as the first duration.
Optionally, if the first difference value equal to the preset threshold value does not exist in the first difference value, and the number of the first duration in the first set is greater than or equal to the maximum value of the third preset range, the preset threshold value needs to be updated.
It should be noted that, when determining the first duration in the first set, the same preset threshold value needs to be used in a round of determination.
S10224, after the last first duration in the first set is obtained, if the number of the first durations in the first set is within a third preset range, taking the first duration in the first set as the first data.
S10225, if the number of the first time durations in the first set is not in the third preset range, updating the preset threshold value, and obtaining the first time durations in the first set based on the updated preset threshold value.
In this embodiment, the updated preset threshold is a value in the array set.
S10226, if the number of the first time periods in the first set obtained after updating the preset threshold is not in the third preset range, determining that the data to be processed cannot be compressed and the data to be processed cannot be stored.
In this embodiment, if the number of the first durations in the first set obtained after updating the preset threshold is within the third preset range, the first durations in the first set obtained after updating the preset threshold are used as the first data.
By way of example, the infrared-encoded duration data are 210, 260, 230, 280, and 233, respectively. The third preset range is 1-4.
If the preset threshold is 2, 210 is the first duration. 260-210 = 40 +.2, then 260 is the first duration. 230-210=20+.2, 260-230=30+.2, 230 is the first duration, and both 280 and 233 are determined in turn as the first duration. 210. 260, 230, 280 and 233 are each a first duration, and if the number of the first durations is greater than 4, 210, 260, 230, 280 and 233 cannot be used as the first data.
Updating the preset threshold, wherein the preset threshold is 3, 233-230=3=the preset threshold, 210, 260, 230, 280 are the first time length, and the number of the first time length is equal to 4, and 210, 260, 230, 280 are the first data.
In the embodiment of the application, when lossy compression is attempted, whether the data to be processed meets the lossy compression requirement is judged according to the determined time length data meeting the first preset requirement, if so, the time length data meeting the first preset requirement can be used as the first data, conditions are provided for determining the first data, lossy compression can be performed only after the first data is determined, and if the first data cannot be determined, lossy compression can not be performed, judging conditions are provided for lossy compression, so that the possibility of failure of the lossy compression is reduced, and the success rate of data compression is improved.
In one possible implementation manner, when the first preset condition includes a second condition and the encoding length and the duration data satisfy the second condition, the implementation process of step S103 may include:
s1032, carrying out lossy compression processing on the data to be processed according to the first data.
As shown in fig. 8 and 9, in particular, the implementation procedure of step S1032 may include:
s10321, numbering the first data.
S10322, acquiring nth time length data in the time length data, wherein n is more than or equal to 1 and less than or equal to d.
S10323, if the first data which is equal to the nth time length data exists in the first data, compressing the number of the first data which is equal to the nth time length data to obtain compressed nth time length data.
S10324, if the first data which is equal to the nth time length data does not exist in the first data, compressing the number of the first data corresponding to the first difference value which is equal to the preset threshold value to obtain the compressed nth time length data.
In this embodiment, the number of the first data corresponding to the first difference value equal to the preset threshold is compressed, the number of the first data corresponding to the first difference value equal to the preset threshold is used to replace the nth time length data, the number of the first data corresponding to the first difference value equal to the preset threshold can be obtained when the decompression is performed, and then the first data corresponding to the first difference value equal to the preset threshold is obtained according to the number. Since the first data and the nth time period data are different, the nth time period data cannot be restored after compression, and therefore the compression method is lossy compression.
For example, if the preset threshold is 3, the time duration data of the infrared codes are 210, 260, 230, 280 and 233, respectively. The first data are 210, 260, 230, 280, and the first data are numbered 210 as 1, 260 as 2, 230 as 3, 280 as 4, respectively. Then 210 is compressed to 1. 260 is 2 after compression. 230 is 3 after compression. 280 is compressed to 4. 233 and 230 are 3, 233 is compressed to number 3.
In the embodiment of the application, the serial numbers of the first data corresponding to the time length data are compressed, the time length data are represented by the serial numbers of the compressed first data, one serial number occupies half a byte, and two serial numbers occupy one byte, so that the number of bytes occupied by the time length data in storage is smaller, the storage space is saved, and the lossy compression method ensures the lossy compression rate.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
Corresponding to the data compression method described in the above embodiments, fig. 10 shows a block diagram of a data compression device according to an embodiment of the present application, and for convenience of explanation, only a portion related to the embodiment of the present application is shown.
Referring to fig. 10, the apparatus 200 may include: a data acquisition module 210, a data lookup module 220, and a data compression module 230.
The data acquisition module 210 is configured to acquire duration data of each code in the data to be processed;
the data searching module 220 is configured to record duration data meeting a first preset requirement as first data;
the data compression module 230 is configured to compress the data to be processed according to the first data.
In one possible implementation, the data lookup module 220 may be specifically configured to:
acquiring the coding length of the data to be processed;
and when the coding length and the duration data meet a first preset condition, recording the duration data meeting a first preset requirement as first data.
In one possible implementation, the data lookup module 220 may be specifically configured to:
taking the 1 st time length data in the time length data as a first time length, wherein the first time length forms a first set;
determining a first difference value between the ith time length data and each first time length in the first set, wherein i is more than 1 and less than or equal to d, and d is the number of the time length data;
if the first difference value which meets the first array requirement does not exist in the first difference value, adding the ith duration data into the first set as a first duration;
After the last first duration in the first set is obtained, if the number of the first durations in the first set is within a first preset range, the first duration in the first set is used as the first data.
In one possible implementation, the data compression module 230 may specifically include:
the lossless compression unit is configured to perform lossless compression processing on the data to be processed according to the first data when the first preset condition includes a first condition, and the encoding length and the duration data satisfy the first preset condition, where the first condition includes: the coding length is smaller than or equal to the first preset value, and the duration data with the length greater than a second preset value exist in the duration data;
the lossy compression unit is configured to perform lossy compression processing on the data to be processed according to the first data when the first preset condition includes a second condition, and the encoding length and the duration data satisfy the first preset condition, where the second condition includes: the coding length is larger than a third preset value, and/or the coding length is larger than the first preset value and the coding length is smaller than the third preset value, and/or the data to be processed fails to be subjected to lossless compression processing.
In one possible implementation, the lossless compression unit may be specifically configured to:
numbering the first data;
acquiring j-th time length data in the time length data, wherein j is more than or equal to 1 and less than or equal to d;
if the first data which is equal to the j-th time length data exists in the first data, the number of the first data which is equal to the j-th time length data is compressed, and the compressed j-th time length data is obtained;
if the first data which is equal to the j-th time length data does not exist in the first data, calculating a second difference value between the j-th time length data and each first data;
and jointly compressing the number of the first data corresponding to the target difference value and the target difference value to obtain the j-th duration data after compression, wherein the target difference value is any one of the second difference values which meets the requirement of the first array.
In one possible implementation, the lossy compression unit may be specifically configured to:
numbering the first data;
acquiring nth time length data in the time length data, wherein n is more than or equal to 1 and less than or equal to d;
if the first data which is equal to the nth time length data exists in the first data, the number of the first data which is equal to the nth time length data is compressed, and the compressed nth time length data is obtained;
If the first data which are equal to the nth time length data do not exist in the first data, calculating a third difference value between the nth time length data and each first data;
and compressing the number of the first data corresponding to any third difference value meeting the first array requirement to obtain the compressed nth duration data.
In one possible implementation, the data lookup module 220 may be specifically configured to:
when the coding length and the duration data meet a second preset condition, determining that the data to be processed meet a storage requirement without compression, wherein the second preset condition comprises that the coding length is smaller than or equal to the third preset value, and the duration data do not exist in the duration data, and the duration data are larger than or equal to the second preset value.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The embodiment of the present application also provides a terminal device, referring to fig. 11, the terminal device 400 may include: at least one processor 410, a memory 420, and a computer program stored in the memory 420 and executable on the at least one processor 410, the processor 410, when executing the computer program, performing the steps of any of the various method embodiments described above, such as steps S101 to S103 in the embodiment shown in fig. 2. Alternatively, the processor 410, when executing the computer program, performs the functions of the modules/units of the apparatus embodiments described above, such as the functions of the modules 210 to 230 shown in fig. 10.
By way of example, a computer program may be partitioned into one or more modules/units that are stored in memory 420 and executed by processor 410 to perform the present application. The one or more modules/units may be a series of computer program segments capable of performing specific functions for describing the execution of the computer program in the terminal device 400.
It will be appreciated by those skilled in the art that fig. 11 is merely an example of a terminal device and is not limiting of the terminal device, and may include more or fewer components than shown, or may combine certain components, or different components, such as input-output devices, network access devices, buses, etc.
The processor 410 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 420 may be an internal storage unit of the terminal device, or may be an external storage device of the terminal device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like. The memory 420 is used for storing the computer program as well as other programs and data required by the terminal device. The memory 420 may also be used to temporarily store data that has been output or is to be output.
The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (Peripheral Component, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the buses in the drawings of the present application are not limited to only one bus or to one type of bus.
The data compression method provided by the embodiment of the application can be applied to terminal equipment such as computers, tablet computers, notebook computers, netbooks, personal digital assistants (personal digital assistant, PDA) and the like, and the embodiment of the application does not limit the specific type of the terminal equipment.
Embodiments of the present application also provide a computer readable storage medium storing a computer program which, when executed by a processor, implements steps in various embodiments of a compression method that can implement the data described above.
Embodiments of the present application provide a computer program product which, when run on a mobile terminal, causes the mobile terminal to perform steps in various embodiments of a compression method that can implement the data described above.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing device/terminal apparatus, recording medium, computer Memory, read-Only Memory (ROM), random access Memory (RAM, random Access Memory), electrical carrier signals, telecommunications signals, and software distribution media. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer readable media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other manners. For example, the apparatus/network device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (8)

1. A method of compressing data, comprising:
acquiring time length data of each code in the data to be processed;
recording duration data meeting first preset requirements as first data;
compressing the data to be processed according to the first data;
The recording the time length data meeting the first preset requirement as first data comprises the following steps:
acquiring the coding length of the data to be processed;
when the coding length and the duration data meet a first preset condition, recording the duration data meeting a first preset requirement as first data;
the compressing the data to be processed according to the first data includes:
when the first preset condition includes a first condition and the encoding length and the duration data meet the first condition, performing lossless compression processing on the data to be processed according to the first data, wherein the first condition includes: the encoding length is smaller than or equal to a first preset value, and the duration data are longer than a second preset value, wherein the first preset value is the length of lossless compression data; the lossless compression data length is the difference between the code storage length and the length of the first data;
when the first preset condition includes a second condition and the encoding length and the duration data meet the second condition, performing lossy compression processing on the data to be processed according to the first data, wherein the second condition includes: the coding length is greater than a third preset value, and/or the coding length is greater than the first preset value, the coding length is less than the third preset value, and the duration data greater than a second preset value exist in the duration data, and/or the data to be processed fails to be subjected to lossless compression processing, wherein the third preset value is the coding storage length.
2. The method for compressing data as recited in claim 1, wherein said recording the time length data satisfying the first preset requirement as the first data when the code length and the time length data satisfy the first preset condition includes:
taking the 1 st time length data in the time length data as a first time length, wherein the first time length forms a first set;
calculating a first difference value between the ith time length data and each first time length in the first set, wherein i is more than 1 and less than or equal to d, and d is the number of the time length data;
if the first difference value meeting the first array requirement does not exist in the first difference value, and the number of the first duration in the first set at the current time is smaller than the maximum value of a first preset range, adding the ith duration data into the first set as the first duration;
and taking the first time length in the first set as the first data after the last first time length in the first set is obtained.
3. The method for compressing data according to claim 2, wherein performing lossless compression processing on the data to be processed based on the first data comprises:
numbering the first data;
Acquiring j-th time length data in the time length data, wherein j is more than or equal to 1 and less than or equal to d;
if the first data which is equal to the j-th time length data exists in the first data, the number of the first data which is equal to the j-th time length data is compressed, and the compressed j-th time length data is obtained;
and if the first data which is equal to the j-th time length data does not exist in the first data, the number of the first data corresponding to a target difference value and the target difference value are compressed together to obtain compressed j-th time length data, wherein the target difference value is any one of the first difference values which meets the first array requirement.
4. The method for compressing data as recited in claim 2, wherein said performing lossy compression processing on said data to be processed based on said first data comprises:
numbering the first data;
acquiring nth time length data in the time length data, wherein n is more than or equal to 1 and less than or equal to d;
if the first data which is equal to the nth time length data exists in the first data, the number of the first data which is equal to the nth time length data is compressed, and the compressed nth time length data is obtained;
If the first data does not exist in the first data, the number of the first data corresponding to the first difference value meeting the first array requirement is compressed, and the compressed nth duration data is obtained.
5. The method of compressing data as recited in claim 1, wherein after said acquiring the encoded length of said data to be processed, comprising:
when the coding length and the duration data meet a second preset condition, determining that the data to be processed meet a storage requirement without compression, wherein the second preset condition comprises that the coding length is smaller than or equal to the third preset value, and the duration data do not exist in the duration data, and the duration data are larger than or equal to the second preset value.
6. A data compression apparatus, comprising:
the data acquisition module is used for acquiring time length data of each code in the data to be processed;
the data searching module is used for recording the duration data meeting the first preset requirement as first data;
the data compression module is used for compressing the data to be processed according to the first data;
the data searching module is specifically used for:
Acquiring the coding length of the data to be processed;
when the coding length and the duration data meet a first preset condition, recording the duration data meeting a first preset requirement as first data;
the data compression module specifically comprises:
the lossless compression unit is configured to perform lossless compression processing on the data to be processed according to the first data when the first preset condition includes a first condition, and the encoding length and the duration data satisfy the first condition, where the first condition includes: the encoding length is smaller than or equal to a first preset value, and the duration data are longer than a second preset value, wherein the first preset value is the length of lossless compression data; the lossless compression data length is the difference between the code storage length and the length of the first data;
the lossy compression unit is configured to perform lossy compression processing on the data to be processed according to the first data when the first preset condition includes a second condition, and the encoding length and the duration data satisfy the second condition, where the second condition includes: the coding length is greater than a third preset value, and/or the coding length is greater than the first preset value and the coding length is smaller than the third preset value, and/or the data to be processed fails to be subjected to lossless compression processing, and the third preset value is the coding storage length.
7. Terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the data compression method according to any of claims 1 to 5 when executing the computer program.
8. A computer readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the data compression method according to any one of claims 1 to 5.
CN202110674907.6A 2021-06-17 2021-06-17 Data compression method and device, terminal equipment and storage medium Active CN113542225B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110674907.6A CN113542225B (en) 2021-06-17 2021-06-17 Data compression method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110674907.6A CN113542225B (en) 2021-06-17 2021-06-17 Data compression method and device, terminal equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113542225A CN113542225A (en) 2021-10-22
CN113542225B true CN113542225B (en) 2023-08-22

Family

ID=78096226

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110674907.6A Active CN113542225B (en) 2021-06-17 2021-06-17 Data compression method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113542225B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114726480B (en) * 2022-03-08 2023-07-25 科大讯飞股份有限公司 Data encoding method and related device, electronic equipment and storage medium
CN117200800A (en) * 2022-06-01 2023-12-08 中科寒武纪科技股份有限公司 Data compression method, device, equipment and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105070035A (en) * 2015-08-25 2015-11-18 无锡力芯微电子股份有限公司 Real-time compression method and device for infrared remote control code stream
CN107564266A (en) * 2017-08-25 2018-01-09 广东美的制冷设备有限公司 A kind of remote controller codes learning method and remote control learning device
CN107730868A (en) * 2017-09-11 2018-02-23 深圳市劳沃智能科技有限公司 The compression and storage method and device of infrared learning coded data
CN107945477A (en) * 2017-11-10 2018-04-20 深圳睿舍智能科技有限公司 The method and device that infrared or wireless remote control signals data are compressed
CN109067405A (en) * 2018-07-27 2018-12-21 深圳还是威健康科技有限公司 A kind of method, apparatus of data compression, terminal and computer readable storage medium
CN109637111A (en) * 2018-12-25 2019-04-16 歌尔科技有限公司 Infrared signal compression method, device, user equipment and storage medium
CN109756230A (en) * 2019-01-03 2019-05-14 Oppo广东移动通信有限公司 Data compression storage method, data compression method, device, equipment and medium
CN110992672A (en) * 2019-09-25 2020-04-10 广州广日电气设备有限公司 Infrared remote controller learning and encoding method, infrared remote controller system and storage medium
CN111817722A (en) * 2020-07-09 2020-10-23 北京奥星贝斯科技有限公司 Data compression method and device and computer equipment
CN112071052A (en) * 2019-09-06 2020-12-11 超级智慧家(上海)物联网科技有限公司 Infrared repeater system, infrared repeater and data learning method thereof
CN112506879A (en) * 2020-12-18 2021-03-16 深圳智慧林网络科技有限公司 Data processing method and related equipment

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105070035A (en) * 2015-08-25 2015-11-18 无锡力芯微电子股份有限公司 Real-time compression method and device for infrared remote control code stream
CN107564266A (en) * 2017-08-25 2018-01-09 广东美的制冷设备有限公司 A kind of remote controller codes learning method and remote control learning device
CN107730868A (en) * 2017-09-11 2018-02-23 深圳市劳沃智能科技有限公司 The compression and storage method and device of infrared learning coded data
CN107945477A (en) * 2017-11-10 2018-04-20 深圳睿舍智能科技有限公司 The method and device that infrared or wireless remote control signals data are compressed
CN109067405A (en) * 2018-07-27 2018-12-21 深圳还是威健康科技有限公司 A kind of method, apparatus of data compression, terminal and computer readable storage medium
CN109637111A (en) * 2018-12-25 2019-04-16 歌尔科技有限公司 Infrared signal compression method, device, user equipment and storage medium
CN109756230A (en) * 2019-01-03 2019-05-14 Oppo广东移动通信有限公司 Data compression storage method, data compression method, device, equipment and medium
CN112071052A (en) * 2019-09-06 2020-12-11 超级智慧家(上海)物联网科技有限公司 Infrared repeater system, infrared repeater and data learning method thereof
CN110992672A (en) * 2019-09-25 2020-04-10 广州广日电气设备有限公司 Infrared remote controller learning and encoding method, infrared remote controller system and storage medium
CN111817722A (en) * 2020-07-09 2020-10-23 北京奥星贝斯科技有限公司 Data compression method and device and computer equipment
CN112506879A (en) * 2020-12-18 2021-03-16 深圳智慧林网络科技有限公司 Data processing method and related equipment

Also Published As

Publication number Publication date
CN113542225A (en) 2021-10-22

Similar Documents

Publication Publication Date Title
CN113542225B (en) Data compression method and device, terminal equipment and storage medium
EP3944505A1 (en) Data compression method and computing device
US20110040982A1 (en) File encryption method
CN110704439B (en) Data storage method and device
CN108880559B (en) Data compression method, data decompression method, compression equipment and decompression equipment
CN108053034B (en) Model parameter processing method and device, electronic equipment and storage medium
CN113360911A (en) Malicious code homologous analysis method and device, computer equipment and storage medium
CN116303297A (en) File compression processing method, device, equipment and medium
CN111930924A (en) Data duplicate checking system and method based on bloom filter
CN111384972B (en) Optimization method, device and decoder of multi-system LDPC decoding algorithm
CN110288666B (en) Data compression method and device
CN107861990B (en) Video searching method and system and terminal equipment
CN116306610A (en) Model training method and device, natural language processing method and device
CN1364341A (en) Arithmetic decoding of arithmeticlaly encoded information signal
CN112712610B (en) Vehicle diagnosis log processing method and device, terminal equipment and readable storage medium
CN112395864B (en) Text error correction model training method, text error correction method and related device
CN114610266A (en) Compensation data processing method, device, equipment and medium
CN111224674B (en) Decoding method, device and decoder for multi-system LDPC code
CN112818347A (en) File label determination method, device, equipment and storage medium
CN113239226A (en) Image retrieval method, device, equipment and storage medium
WO2011162964A2 (en) System and method and computer program product for parameter estimation for lossless video compression
CN111384976A (en) Storage method and reading method of sparse check matrix
CN105049055A (en) Data compression method and data decompression method
KR100841311B1 (en) Method of image compression for video decoding based on motion compensation
US20220060197A1 (en) Method and device for compressing data, and method and device for decompressing data

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant