Data compression method, decompression method and related equipment

文档序号:1539579 发布日期:2020-02-14 浏览:9次 中文

阅读说明:本技术 一种数据压缩方法与解压方法以及相关设备 (Data compression method, decompression method and related equipment ) 是由 李宇翔 于 2017-05-26 设计创作,主要内容包括:本发明实施例公开了一种数据压缩方法与解压方法以及相关设备,用于压缩连续重复的数据。本方法可包括:获取待压缩的原始数据文件(101);查找所述原始数据文件中存在的对预定数据进行连续重复的重复数据段,并确定连续重复的次数d(102);将所述预定数据及所述连续重复的次数d写入所述原始数据文件中以代替所述重复数据段(103),从而压缩所述重复数据段。(The embodiment of the invention discloses a data compression method, a decompression method and related equipment, which are used for compressing continuously repeated data. The method can comprise the following steps: acquiring an original data file (101) to be compressed; searching repeated data segments which exist in the original data file and are used for continuously repeating the preset data, and determining the continuous repetition times d (102); writing the predetermined data and the number of consecutive repetitions, d, into the original data file in place of the repeated data segment (103), thereby compressing the repeated data segment.)

A method of data compression, comprising:

acquiring an original data file to be compressed;

searching repeated data segments which exist in the original data file and are used for continuously repeating the preset data, and determining the continuous repetition times d;

writing the predetermined data and the number of consecutive repetitions d into the original data file in place of the repeated data segment, thereby compressing the repeated data segment.

The method according to claim 1, wherein the searching for the repeated data segment existing in the original data file and continuously repeating the predetermined data, and the determining the number d of continuous repetition comprises:

reading a first data segment with the data length n times of the preset data from the original data file, wherein n is a positive integer greater than or equal to 2;

judging whether the first data segment is the n continuous repeated preset data, if so, recording the repetition times d of the preset data as n;

reading a second data segment with the same data length as the preset data, judging whether the second data segment is the preset data segment, if so, increasing the value of d by 1, and returning to the step of reading the second data segment with the same data length as the preset data.

The method of claim 2, wherein said writing said predetermined data and said number of consecutive repetitions, d, into said original data file in place of said repeated data segment comprises:

writing the first data segment and the number of consecutive repetitions, d, into the original data file in place of the repeated data segment.

The method of claim 2, further comprising, after said increasing the value of d by 1:

and judging whether the value of d is larger than or equal to a preset maximum value, if so, executing the step of writing the preset data and the continuous repeated times d into the original data file to replace the repeated data segment.

The method according to any one of claims 1 to 4, wherein after writing the predetermined data and the number of consecutive repetitions, d, into the original data file in place of the repeated data segments, the method further comprises:

clearing the value of d;

and judging whether the original data file to be compressed is completely compressed, if not, returning to the step of searching for repeated data segments which exist in the original data file and are continuously repeated for the preset data, and determining the continuous repetition times d.

A method of data decompression, comprising:

acquiring a compressed data file to be decompressed, wherein the compressed data file comprises at least one section of compressed data section, and the compressed data section comprises preset data and the continuous repetition times d of the preset data;

reading the preset data in the compressed data segment and the continuous repetition times d of the preset data;

and writing the predetermined data which is continuously repeated for d times into the compressed data file to replace the compressed data segment, thereby decompressing the compressed data file to be decompressed.

The method of claim 6, wherein the compressed data segment comprises n consecutive repetitions of the predetermined data and a number d of consecutive repetitions of the predetermined data, wherein n is a positive integer greater than or equal to 2;

the reading of the predetermined data in the compressed data segment and the number d of consecutive repetitions of the predetermined data comprises:

reading a third data segment with the data length n times of the preset data from the compressed data file;

judging whether the third data segment is n continuous repeated preset data or not, if so, reading a fourth data segment with a preset length behind the third data segment;

and reading the number d of continuous repetitions of the predetermined data from the fourth data segment.

The method of claim 7, wherein writing predetermined data that is repeated d times in succession to the compressed data file in place of the compressed data segment comprises:

and continuously repeating the preset data for d times to form a fifth data segment, and writing the fifth data segment into the compressed data file to replace the compressed data segment.

A data compression apparatus comprising input means, output means, a processor and a memory, wherein,

the input device is used for acquiring a data file to be compressed;

the processor is configured to perform the method of:

searching repeated data segments which exist in the data file and are used for continuously repeating the preset data, and determining the continuous repetition times d;

and writing the preset data and the continuous repeated times d into an output data file to replace the repeated data segment, so as to compress the repeated data segment.

The data compression device of claim 9, wherein the processor is specifically configured to:

reading a first data segment with the data length n times of the preset data from the input data file, wherein n is a positive integer greater than or equal to 2;

judging whether the first data segment is the n continuous repeated preset data, if so, recording the repetition times d of the preset data as n;

reading a second data segment with the same data length as the preset data, judging whether the second data segment is the preset data segment, if so, increasing the value of d by 1, and returning to the step of reading the second data segment with the same data length as the preset data.

The data compression device of claim 10, wherein the processor is specifically configured to:

writing the first data segment and the number of consecutive repetitions d into an output data file in place of the repeated data segment.

The data compression device of claim 10, wherein the processor is further configured to:

and judging whether the value of d is larger than or equal to a preset maximum value, if so, executing the step of writing the preset data and the continuous repeated times d into the output data file to replace the repeated data segment.

The data compression device of claim 9, wherein the processor is further configured to:

clearing the value of d;

and judging whether the input data file to be compressed is completely compressed, if not, returning to the step of searching for repeated data segments which exist in the input data file and are continuously repeated for the preset data, and determining the continuous repetition times d.

A computer-readable storage medium having stored therein instructions which, when executed on a computer, cause the computer to perform the method of any one of claims 1 to 8.

An FPGA, comprising an input device, an output device, a processor and a memory, wherein the input device is configured to read an original FPGA load file, the processor is configured to execute the data compression method according to any one of claims 1 to 5 to compress the original FPGA load file to obtain a compressed FPGA load file, and the memory is configured to store the compressed FPGA load file.

An FPGA comprising an input device, an output device, a processor and a memory, wherein the input device is configured to read a decompressed data file to be decompressed, the processor is configured to perform the data decompression method according to any one of claims 6 to 8 to decompress an original FPGA load file to obtain a decompressed FPGA load file, and the memory is configured to store the decompressed FPGA load file.

1页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:数据库租户迁移的系统和方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!