CN111384968A - Data compression and decompression device and data decompression method - Google Patents
Data compression and decompression device and data decompression method Download PDFInfo
- Publication number
- CN111384968A CN111384968A CN201811628184.0A CN201811628184A CN111384968A CN 111384968 A CN111384968 A CN 111384968A CN 201811628184 A CN201811628184 A CN 201811628184A CN 111384968 A CN111384968 A CN 111384968A
- Authority
- CN
- China
- Prior art keywords
- value
- encoding
- data
- decompression
- operation execution
- 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.)
- Granted
Links
Images
Classifications
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03M—CODING; DECODING; CODE CONVERSION IN GENERAL
- H03M7/00—Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
- H03M7/30—Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction
- H03M7/40—Conversion to or from variable length codes, e.g. Shannon-Fano code, Huffman code, Morse code
- H03M7/4006—Conversion to or from arithmetic code
-
- H—ELECTRICITY
- H03—ELECTRONIC CIRCUITRY
- H03M—CODING; DECODING; CODE CONVERSION IN GENERAL
- H03M7/00—Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
- H03M7/30—Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction
- H03M7/46—Conversion to or from run-length codes, i.e. by representing the number of consecutive digits, or groups of digits, of the same kind by a code word and a digit indicative of that kind
- H03M7/48—Conversion to or from run-length codes, i.e. by representing the number of consecutive digits, or groups of digits, of the same kind by a code word and a digit indicative of that kind alternating with other codes during the code conversion process, e.g. run-length coding being performed only as long as sufficientlylong runs of digits of the same kind are present
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Compression, Expansion, Code Conversion, And Decoders (AREA)
Abstract
Description
技术领域technical field
本申请涉及计算机技术领域,特别是涉及一种数据压缩解压装置和数据解压方法。The present application relates to the field of computer technology, and in particular, to a data compression and decompression device and a data decompression method.
背景技术Background technique
数据压缩是指在不丢失有用信息的前提下,缩减数据量以减少存储空间,提高其传输、存储和处理效率,或按照一定的算法对数据进行重新组织,减少数据冗余和存储空间的一种技术方法。Data compression refers to reducing the amount of data to reduce storage space, improving its transmission, storage and processing efficiency, or reorganizing data according to certain algorithms to reduce data redundancy and storage space without losing useful information. a technical method.
然而,传统的数据解压方法,在解压数据时存在效率低的问题。However, the traditional data decompression method has the problem of low efficiency when decompressing data.
发明内容SUMMARY OF THE INVENTION
基于此,有必要针对上述技术问题,提供一种高效解压数据的数据压缩解压装置和数据压缩方法。Based on this, it is necessary to provide a data compression and decompression device and a data compression method for efficiently decompressing data in response to the above technical problems.
一种数据压缩解压装置,包括:数据分割电路,以及n个压缩解压操作执行组件,其中,每一所述压缩操作执行组件包括输入FIFO存储器、多个压缩操作执行部件以及输出FIFO存储器,所述输入FIFO存储器与所述输出FIFO存储器之间串接所述多个压缩操作执行部件,所述数据分割电路连接所述输入FIFO存储器,其中,n为正整数,A data compression and decompression device, comprising: a data division circuit, and n compression and decompression operation execution components, wherein each of the compression operation execution components includes an input FIFO memory, a plurality of compression operation execution components, and an output FIFO memory, the The multiple compression operation execution components are connected in series between the input FIFO memory and the output FIFO memory, and the data division circuit is connected to the input FIFO memory, wherein n is a positive integer,
所述数据分割电路用于将压缩数据分割为多个数据流;The data dividing circuit is used for dividing the compressed data into a plurality of data streams;
各个所述输入FIFO存储器用于对接收的数据流执行同步操作,并将同步操作之后的数据流传输至连接的压缩操作执行部件;Each of the input FIFO memories is used to perform a synchronization operation on the received data stream, and transmit the data stream after the synchronization operation to the connected compression operation execution unit;
各个所述压缩操作执行组件中串接的所述多个压缩操作执行部件,用于依次对接收的输入数据执行对应的解压子操作,得到各个数据流的解压结果;The multiple compression operation execution components connected in series in each of the compression operation execution components are used to sequentially perform corresponding decompression sub-operations on the received input data to obtain decompression results of each data stream;
各个所述输出FIFO存储器用于接收连接的压缩解压操作执行部件发送的解压结果,并将接收的所述解压结果进行同步操作后输出。Each of the output FIFO memories is used to receive the decompression result sent by the connected compression and decompression operation executing component, and perform a synchronous operation on the received decompression result and output it.
一种数据解压方法,所述方法包括:A data decompression method, the method comprises:
将压缩数据分割为多个数据流;Split compressed data into multiple data streams;
获取n个数据流,对所述n个数据流进行同步操作,并将同步操作后的所述n个数据流并行解压,得到n个解压子结果,其中,n为正整数;Acquire n data streams, perform a synchronization operation on the n data streams, and decompress the n data streams after the synchronization operation in parallel to obtain n decompression sub-results, where n is a positive integer;
对所述n个解压数字进行同步操作,并将同步操作后的所述n个解压子结果,按照各个数据流在待压缩数据中的顺序和/或位置写出解压子结果;Perform a synchronous operation on the n decompressed numbers, and write the decompressed sub-results according to the order and/or position of each data stream in the data to be compressed after the synchronous operation;
重复执行所述获取n个数据流至写出所述n个解压子结果的步骤,直至单次解压子结果的数量小于n,之后终止获取数据流。The steps of acquiring n data streams to writing out the n decompression sub-results are repeatedly performed until the number of single decompression sub-results is less than n, and then the acquisition of data streams is terminated.
上述数据压缩解压装置和数据解压方法,可以并行解压n个输入的数据流,且在输入和输出端均设置FIFO存储器,对输入的数据流以及输出的解压结果均进行同步操作,保证了并行对待压缩数据的多个数据流进行压缩,或者对压缩数据进行解压时,输出的结果准确。The above-mentioned data compression and decompression device and data decompression method can decompress n input data streams in parallel, and set FIFO memories at both the input and output ends, and perform synchronous operations on the input data streams and the output decompression results, ensuring parallel treatment. When multiple data streams of compressed data are compressed, or when compressed data is decompressed, the output result is accurate.
附图说明Description of drawings
图1为一个实施例中数据压缩解压装置的结构框图;1 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图2为一个实施例中数据压缩解压装置的结构框图;Fig. 2 is a structural block diagram of a data compression and decompression apparatus in one embodiment;
图3为一个实施例中数据压缩解压装置的结构框图;3 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图4为一个实施例中数据压缩解压装置的结构框图;4 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图5为一个实施例中数据压缩解压装置的结构框图;5 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图6为一个实施例中数据压缩解压装置的结构框图;6 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图7为一个实施例中数据压缩解压装置的结构框图;7 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图8为一个实施例中数据压缩解压装置的结构框图;8 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图9为一个实施例中数据压缩解压装置的结构框图;9 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图10为一个实施例中数据压缩解压装置的结构框图;Fig. 10 is a structural block diagram of an apparatus for data compression and decompression in one embodiment;
图11为一个实施例中一种数据压缩方法的流程示意图;11 is a schematic flowchart of a data compression method in one embodiment;
图12为一个实施例中一种数据解压方法的流程示意图;12 is a schematic flowchart of a data decompression method in one embodiment;
图13为另一个实施例中一种数据压缩方法的补充步骤的流程示意图;13 is a schematic flowchart of supplementary steps of a data compression method in another embodiment;
图14为一个实施例中一种数据解压方法补充步骤的流程示意图;14 is a schematic flowchart of supplementary steps of a data decompression method in one embodiment;
图15为一个实施例中各个数据流进行压缩的步骤的流程示意图;15 is a schematic flowchart of steps for compressing each data stream in one embodiment;
图16为一个实施例中各个数据流进行解压的步骤的流程示意图;16 is a schematic flowchart of steps for decompressing each data stream in one embodiment;
图17为另一个实施例中各个数据流进行压缩的步骤的流程示意图;17 is a schematic flowchart of the steps of compressing each data stream in another embodiment;
图18为另一个实施例中各个数据流进行解压的步骤的流程示意图;18 is a schematic flowchart of steps for decompressing each data stream in another embodiment;
图19为一个实施例中各个数据流进行压缩的步骤的流程示意图;FIG. 19 is a schematic flowchart of the steps of compressing each data stream in one embodiment;
图20为一个实施例中各个数据流进行解压的步骤的流程示意图;Figure 20 is a schematic flowchart of the steps of decompressing each data stream in one embodiment;
图21为另一个实施例中各个数据流进行压缩的步骤的流程示意图;Figure 21 is a schematic flowchart of the steps of compressing each data stream in another embodiment;
图22为另一个实施例中各个数据流进行解压的步骤的流程示意图。FIG. 22 is a schematic flowchart of the steps of decompressing each data stream in another embodiment.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application will be described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application.
如图1-图10所示,为本申请其中一个实施例中的数据压缩解压装置100的结构框图,图1中数据压缩解压装置100,包括:n个压缩解压操作执行组件110,每一所述压缩解压操作执行组件包括输入FIFO存储器111、至少一个压缩解压操作执行部件112以及输出FIFO存储器113,所述输入FIFO存储器111与所述输出FIFO存储器113之间串接所述多个压缩操作执行部件112,其中,n为正整数。As shown in FIGS. 1-10 , which are structural block diagrams of a data compression and
其中,各个所述输入FIFO存储器111用于对接收的数据流执行同步操作,并将同步操作之后的数据流传输至连接的压缩操作执行部件;各个所述压缩解压操作执行组件110中串接的至少一个压缩解压操作执行部件112,依次对接收的输入数据执行对应的压缩子操作,得到各个数据流的压缩编码结果;各个所述输出FIFO存储器用于接收连接的压缩解压操作执行部件发送的压缩编码结果,并将接收的所述压缩编码结果进行同步操作后输出。进一步地,输出FIFO存储器按照各个数据流在待压缩数据中的顺序和/或位置写出接收压缩编码结果。应当清楚的是,数据流中的数据为待压缩的数据。Wherein, each of the
可选地,该数据压缩解压装置100还可以包括数据分割电路120,用于对输入的数据进行分割,得到多个数据流。可选地,输入数据可以为待压缩数据或压缩数据。可选地,数据分割电路120分割得到的数据流的大小可以为1024kb,或者其他设定大小。Optionally, the data compression and
进一步地,该数据压缩解压装置100还可以对压缩数据进行解压。Further, the data compression and
具体地,数据分割电路120将压缩数据分割为多个数据流,之后各个所述输入FIFO存储器111对接收的数据流执行同步操作,并将同步操作之后的数据流传输至连接的压缩操作执行部件,各个所述压缩操作执行组件110中串接的所述多个压缩操作执行部件112,依次对接收的输入数据执行对应的解压子操作,得到各个数据流的解压结果,各个所述输出FIFO存储器113用于接收连接的压缩解压操作执行部件发送的解压结果,并将接收的所述解压结果进行同步操作后输出。Specifically, the
本实施例中的数据压缩解压装置,可以并行压缩或解压n个输入的数据流,且在输入和输出端均设置FIFO存储器,对输入的数据流以及输出的压缩编码结果或者解压结果均进行同步操作,保证了并行对待压缩数据的多个数据流进行压缩,或者对压缩数据进行解压时,输出的结果准确。The data compression and decompression device in this embodiment can compress or decompress n input data streams in parallel, and set FIFO memories at both the input and output ends to synchronize the input data streams and the output compression encoding results or decompression results. The operation ensures that when multiple data streams of the data to be compressed are compressed in parallel, or when the compressed data is decompressed, the output result is accurate.
可选地,可以根据输入FIFO存储器111的面积以及执行的数据处理的类型设置输入位宽,其中,所述输入位宽为输入FIFO存储器单次获取数据的字节数。执行的数据处理的类型包括压缩数据或解压数据。例如,在进行数据压缩时,输入FIFO存储器的输入位宽可以为64kb等数值。在进行数据解压时,输入FIFO存储器的输入位宽可以为16kb等数值。可选地,可以根据输出FIFO存储器113的面积以及执行的数据处理的类型设置输出位宽,其中,所述输入位宽为输出FIFO存储器单次输出数据的字节数。例如,在进行数据压缩时,输出FIFO存储器的位宽16kb等数值。在进行数据压缩时,输出FIFO存储器的输入位宽可以为64kb等数值。Optionally, the input bit width may be set according to the area of the
在其中一个实施例中,上述输入FIFO存储器111、压缩解压操作执行部件112以及输出FIFO存储器113上均设置结束信号发射器,该结束信号发射器用于发射结束信号。In one embodiment, an end signal transmitter is set on the above-mentioned
具体地,在数据压缩解压装置100进行数据压缩或解压时,若n个压缩解压操作执行组件中,存在未输入数据流的压缩解压操作执行组件,则该未输入数据流的压缩解压操作执行组件的输入FIFO存储器上的结束信号发射器发射结束信号至其连接的压缩解压操作执行部件,接收到结束信号的压缩解压操作执行部件通过其安装的结束信号发射器将结束信号向后传递,直至将该结束信号传送至输出FIFO存储器,该未输入数据流的压缩解压操作执行组件的输出FIFO存储器通过其安装的结束信号发射器输出结束信号,此时,数据压缩解压装置100会终止当前执行的压缩或解压过程。Specifically, when the data compression and
本实施例中的数据压缩解压装置根据某一压缩解压操作执行组件在压缩或解压过程中在无数据流的输入时,触发设置的结束信号发射器发射结束信号进而控制数据的压缩或解压进程,避免了数据压缩或解压过程在结束时因需补齐输入数据而造成的额外开销。The data compression and decompression apparatus in this embodiment triggers the set end signal transmitter to transmit an end signal and then controls the data compression or decompression process when there is no data stream input during the compression or decompression process according to a certain compression and decompression operation execution component, It avoids the extra overhead caused by the need to pad the input data at the end of the data compression or decompression process.
在其中一个实施例中,如图3所示,数据压缩解压装置100还可以包括数据混洗操作执行部件140。该数据混洗操作执行部件140连接压缩解压操作执行组件110的输入FIFO存储器111。该数据混洗操作执行部件140,用于接收数据混洗信号后,对通过的原始数据流进行混洗,得到数据流。可选地,该原始数据流可以来自待压缩数据,或者压缩数据。In one of the embodiments, as shown in FIG. 3 , the data compression and
可选地,该数据混洗操作执行部件140按照预设规则,对所述n个所述原始数据流中后段数据进行混洗,得到n个数据流,其中,所述预设规则包括:相邻m个数据流进行混洗,或者,跳过k个数据流进行混洗,所述m为正整数,所述k为正整数。Optionally, the data shuffling
例如,n=16,设置m=4,使用序号0-15区分各个压缩解压操作执行组件110,在输入原始数据流的过程中进行1次数据混洗操作。此时,数据混洗操作执行部件140在接收对应的数据混洗信号后,对相邻的四个压缩解压操作执行组件110的原始数据流进行数据混洗,即对序号为0-3压缩解压操作执行组件进行数据混洗;对4-7压缩解压操作执行组件进行数据混洗;对8-11压缩解压操作执行组件进行数据混洗;对12-15压缩解压操作执行组件进行数据混洗。For example, n=16, set m=4, use serial numbers 0-15 to distinguish each compression and decompression
例如,n=16,设置k=4,使用序号0-15区分各个压缩解压操作执行组件110,同样使用序号0-15区分原始数据流,在输入原始数据流的过程中进行3次数据混洗操作。此时,数据混洗操作执行部件140在接收对应的数据混洗信号后,跳过四个压缩解压操作执行组件110的原始数据流进行数据混洗,此时,序号0压缩解压操作执行组件110得到的最终的数据流包含4段子数据流,依次为序号为0、4、8、12的数据流中对应子数据流。For example, n=16, set k=4, use serial numbers 0-15 to distinguish each compression and decompression
应当清楚的是,若未原始数据流未执行数据混洗操作,则输入FIFO中的原始数据流即为后续操作中的数据流。It should be clear that, if the data shuffling operation is not performed on the original data stream, the original data stream in the input FIFO is the data stream in the subsequent operation.
本实施例中的数据压缩解压装置可以实现对输入的原始数据流进行混洗,可以克服各个压缩解压操作执行组件的原始数据流中的数据在压缩或解压效率差异较大时,造成的各个压缩解压操作执行组件执行时间差异大,降低数据压缩或解压效率的问题。The data compression and decompression apparatus in this embodiment can realize shuffling of the input original data stream, and can overcome the compression or decompression efficiency of the data in the original data streams of the various compression and decompression operation execution components. The execution time of the execution components of the decompression operation varies greatly, which reduces the efficiency of data compression or decompression.
在其中一个实施例中,如图4所示,数据压缩解压装置100的各个所述压缩解压操作执行组件110中相邻的两个压缩解压操作执行部件112之间串接一存储器115,In one embodiment, as shown in FIG. 4 , a
所述相邻的两个压缩解压操作执行部件之间串接一存储器115,用于存储对应的所述相邻的两个压缩解压操作执行部件中在前的压缩解压操作执行部件的输出结果。A
具体地,压缩解压操作执行组件110中相邻的两个压缩解压操作执行部件112中在后的压缩解压操作执行部件,获取连接的存储器115中的输出结果作为输入数据执行对应的压缩或解压子操作。应当清楚的是,该输出结果为在前的压缩解压操作执行部件的输出结果。Specifically, the subsequent compression and decompression operation execution components in the adjacent two compression and decompression
本实施例中的通过在相邻的两个压缩解压操作执行部件之间串接一存储器,使得各个压缩解压操作执行组件中各个压缩解压操作执行部件的输出结果单独存储,保证了各个压缩解压操作执行组件处理的数据流的执行结果的准确性。In this embodiment, a memory is connected in series between two adjacent compression and decompression operation execution components, so that the output results of each compression and decompression operation execution component in each compression and decompression operation execution component are stored separately, which ensures that each compression and decompression operation is performed. The accuracy of the execution result of the data flow processed by the execution component.
在其中一个实施例中,如图5所示,数据压缩解压装置100还可以包括控制电路130,该控制电路130分别连接所述数据分割电路120和所述压缩操作执行组件110。具体地,控制电路130用于控制数据分割电路120执行分割操作。其中,控制电路130用于控制数据分割电路120对输入的待压缩数据或压缩数据按照预设数据大小执行分割操作。可选地预设数据大小可以为1024kb等数值。可选地,控制电路130还可以用于控制压缩解压操作执行组件110执行压缩操作,所述压缩操作包含至少一个压缩子操作。可选地,控制电路130还可以用于控制压缩解压操作执行组件110执行解压操作,所述解压操作包含至少一个解压子操作。In one embodiment, as shown in FIG. 5 , the data compression and
在其中一个实施例中,在进行数据压缩时,如图6所述,数据压缩解压装置100的各个压缩解压操作执行组件110中串接的压缩解压操作执行部件112,包括:依次串接的查询操作执行部件1121、比较操作执行部件1122以及加法操作执行部件1123,所述加法操作执行部件1123连接所述输出FIFO存储器113。可选地,该比较操作执行部件1122还可以连接输入FIFO存储器111。可选地,该查询操作执行部件1121还可以连接,输出FIFO存储器113。In one of the embodiments, during data compression, as shown in FIG. 6 , the concatenated compression and decompression
本实施例的数据压缩解压装置100可以根据接收的控制信号,控制输入的数据流进入压缩解压操作执行组件中各个压缩解压操作执行部件的顺序。例如,在进行数据压缩时,数据流流向为:查询操作执行部件1121→较操作执行部件1122→加法操作执行部件1123。相应地,据解压时,数据流流向为:比较操作执行部件1122→加法操作执行部件1123→查询操作执行部件1121。The data compression and
可选地,若该数据压缩解压装置100仅为了实现数据压缩或解压的单一操作,在进行数据压缩时各个压缩解压操作执行组件110的串接次序为:依次串接查询操作执行部件1121、比较操作执行部件1122以及加法操作执行部件1123。在进行数据解压时各个压缩解压操作执行组件110的串接次序为:依次串接比较操作执行部件1122、加法操作执行部件1123以及查询操作执行部件1121。Optionally, if the data compression and
查询操作执行部件1121,用于依次获取所述数据流中每一数字在预设的符号序列表中的排序值,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。The query
比较操作执行部件1122,用于访问预设的码长边界表,根据所述数据流中每一数字在所述符号序列表中的排序值、预设的码长表,依次确定所述数据流中每一数字的编码码长,其中,所述码长边界表包含多种编码码长,以及每一所述编码码长的数字的最大排序值,所述码长表包含预设的多种编码码长。The comparison
加法操作执行部件1123,用于根据预设的码长基础值表以及数据流中每一数字的编码码长,依次得到所述数据流中每一数字的基础值,将所述数据流中每一数字的排序值与对应的基础值相加得到所述每一数字的初始编码值,之后将各个初始编码值按照对应的编码码长进行转换,得到所述数据流中各个数字的压缩编码值,其中,所述码长基础值表包括每一所述编码码长的基础值。The addition
可选地,比较操作执行部件1122,具体用于查找码长边界表中排序值不小于当前数字的最小的排序值,根据所述码长边界表中排序值不小于当前数字的最小的排序值和所述码长表确定当前符号的编码码长。Optionally, the comparison
本实施例中的数据压缩解压装置100可以通过依次串接的查询操作执行部件、比较操作执行部件以及加法操作执行部件,依次执行查询、比较以及加法操作,替换传统的查表操作对待压缩数据进行压缩编码,由于本实施例中,使用的符号序列表、码长边界表、码长表以及码长基础值表中的数据量小,因此,该数据压缩解压装置100可以高效的进行数据压缩。由于该数据压缩方法得到的压缩数据的压缩效率与传统的Huffman编码基本一致,为方便表达,在下文提及该数据压缩方法时使用“改进的Huffman编码”表示该数据压缩方法。The data compression and
可选地,上述实施例中的符号序列表,可以根据如下步骤进行设定:Optionally, the symbol sequence table in the above embodiment can be set according to the following steps:
根据待压缩数据中各个数字的出现概率,降序排列所述待压缩数字中的各个数字,得到各个所述数字的排序值,使用各个所述数字以及对应的排序值构建符号序列表。According to the occurrence probability of each number in the data to be compressed, arrange each number in the to-be-compressed number in descending order, obtain the sorting value of each said number, and use each said number and corresponding sorting value to construct a symbol sequence table.
可选地,上述实施例中的码长表,可以根据如下步骤进行设定:Optionally, the code length table in the above embodiment can be set according to the following steps:
首先,将待压缩数据中各个数字的Huffman编码的码长,将其作为待压缩数据中各个数字的编码码长。可选地,可以首先根据待压缩数据中各个数字的出现概率得到对应的Huffman树。之后,再根据各个数字在该Huffman树中对应的叶子结点到根结点的路径长度,得到待压缩数据中各个数字的编码码长。在一示例中:待压缩数据中包括的数字:10、20、30、40、50,对应的出现概率为:0.4、0.1、0.2、0.2、0.1。控制电路110根据待压缩数据中各个数字的出现概率得到的Huffman树如图7所示。由该图7可得,10、20、30、40、50对应的叶子结点到根据结点的路径长度分别为2、3、2、2、3,由于Huffman树中各个叶子结点到根结点的路径长度对应Huffman编码的编码码长,因此,编码电路130在该示例中得到的10、20、30、40、50对应的编码码长分别为2、3、2、2、3。可选地,还可以直接待压缩数据中各个数字的Huffman编码的编码码长,得到待压缩数据中各个数字的编码码长。承接上述示例,根据上述10、20、30、40、50的出现概率构建的Huffman树,得到的Huffman编码(约定Huffman书中指向左子树的分支表示“0”,指向右子树的分支表示“1”)分别为:00、010、10、11、011。应当清楚的是本实施例进行压缩编码时各个数字的编码码长与Huffman编码一致。First, the code length of the Huffman encoding of each number in the data to be compressed is taken as the encoded code length of each number in the data to be compressed. Optionally, the corresponding Huffman tree may be obtained first according to the occurrence probability of each number in the data to be compressed. Then, according to the path length from the corresponding leaf node to the root node of each number in the Huffman tree, the encoding code length of each number in the data to be compressed is obtained. In an example: numbers included in the data to be compressed: 10, 20, 30, 40, 50, and the corresponding occurrence probabilities are: 0.4, 0.1, 0.2, 0.2, 0.1. The Huffman tree obtained by the
之后,统计待压缩数据中各个数字的编码码长的种类,待压缩数据中所有种类的编码码长组成码长表。可选地,将码长表中的编码码长升序排列,并使用序号依次标识升序排列的各个编码码长。After that, the types of encoding code lengths of each number in the data to be compressed are counted, and the encoding code lengths of all types in the data to be compressed form a code length table. Optionally, the coding code lengths in the code length table are arranged in ascending order, and the respective coding code lengths arranged in ascending order are sequentially identified by serial numbers.
可选地,上述实施例中的码长边界表,可以根据如下步骤进行设定:Optionally, the code length boundary table in the above embodiment can be set according to the following steps:
首先,获取符号序列表以及符号序列表中各数字的编码码长。之后,查找符号序列表中每种编码码长对应的最大排序值,并使用这些最大排序值构建所述码长边界表,其中,最大排序值是各种编码码长的数字的排序值的最大值。进一步地,将码长边界表中的各个最大排序值升序排列,得到所述码长边界表。更进一步的,使用与码长表对应的序号标识升序排列的码长边界表中的各个排序值。First, obtain the symbol sequence table and the encoding code length of each number in the symbol sequence table. Then, find the maximum sorting value corresponding to each coding code length in the symbol sequence table, and use these maximum sorting values to construct the code length boundary table, where the maximum sorting value is the maximum sorting value of the numbers of various coding code lengths value. Further, the maximum sorting values in the code length boundary table are arranged in ascending order to obtain the code length boundary table. Further, the sequence numbers corresponding to the code length table are used to identify each sorting value in the code length boundary table arranged in ascending order.
可选地,上述实施例中的码长基础值表,可以根据如下步骤进行设定:Optionally, the code length basic value table in the above embodiment can be set according to the following steps:
将码长边界表中各个最大排序值对应的编码值减去排序值,得到每种编码码长的基础值。可选地,升序排列码长基础值表中的各个基础值,并使用与码长表对应的序号标识升序排列的码长基础值表中的各个基础值。Subtract the sorting value from the coding value corresponding to each maximum sorting value in the code length boundary table to obtain the basic value of each coding code length. Optionally, each basic value in the code length basic value table is arranged in ascending order, and each basic value in the code length basic value table arranged in ascending order is identified by a sequence number corresponding to the code length table.
进一步地,待压缩数据中各个数字的编码值通过下述步骤设置:Further, the encoding value of each number in the data to be compressed is set by the following steps:
依次访问码长序列表中的数字,若当前数字的编码码长与上一排序值的数字的编码码长相同,则将所述上一排序值的数字的编码值加1得到所述当前数字的编码值;若当前数字的编码码长与上一排序值的数字的编码码长不同,则将所述上一排序值的数字的编码值加1得到的数值补充尾数0得到所述当前数字的编码值。循环执行上述设置编码值的步骤,直至得到符号序列表中最后一个数字的编码值。Access the numbers in the code length sequence table in turn, if the encoding code length of the current number is the same as the encoding code length of the number of the previous sorting value, then add 1 to the encoding value of the number of the previous sorting value to obtain the current number If the encoding code length of the current number is different from the encoding code length of the number of the last sorting value, then the numerical value supplemented by 1 obtained by adding 1 to the encoding value of the number of the last sorting value is obtained to obtain the current number. coded value. Repeat the above steps of setting the code value until the code value of the last number in the symbol sequence table is obtained.
例如:上述示例中,40编码码长为2比特的数字中最大排序值的数字,其排序值为2,50编码码长为3比特的数字中最大排序值的数字,其排序值为4。将2、4升序排列,得到的码长边界表为[2,4]。上述示例中,40为编码码长为2比特的数字中最大排序值的数字,其排序值为2,其编码值为10(二进制,对应十进制的数值2),因此,该示例中可以得到的编码码长为2比特的基础值为0;50为编码码长为3比特的数字中最大排序值的数字,其排序值为4,其编码值为111(二进制,对应十进制的数值7),因此,该示例中可以得到的编码码长为4比特的基础值为3。编码电路130在该示例中得到的码长基础值表为[0,3]。For example, in the above example, the number with the largest ranking value among the numbers with a 40-coded code length of 2 bits has a ranking value of 2, and the number with the largest ranking value among the 50-coded codes with a code length of 3 bits is a number with a ranking value of 4. Arrange 2 and 4 in ascending order, and the obtained code length boundary table is [2, 4]. In the above example, 40 is the number with the largest sorting value among the numbers whose coding code length is 2 bits, its sorting value is 2, and its coding value is 10 (binary, corresponding to the decimal value of 2). The basic value of the coding code length of 2 bits is 0; 50 is the number with the largest sorting value among the numbers with the coding code length of 3 bits, its sorting value is 4, and its coding value is 111 (binary, corresponding to the decimal value 7), Therefore, in this example, the base value of the encoded code length of 4 bits that can be obtained is 3. The code length base value table obtained by the
相应地,在进行数据解压时,如图6所示的数据压缩解压装置100的查询操作执行部件1122,可以用于依次获取所述数据流中每一数字在预设的符号序列表中的排序值,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。Correspondingly, during data decompression, the query
其比较操作执行部件1122,可以用于访问预设的编码值范围表和预设的码长表,依次得到输入的数据流中各编码值的码长,其中,所述编码值范围表包含多种编码码长的最大编码值,所述码长编码包含所述多种编码码长。The comparison
加法操作执行部件1123,可以用于依次获取数据流中每一编码值的有效值作为各所述编码值的初始编码值,并根据所述数据流中每一编码值的编码码长以及预设的码长基础值表得到所述数据流中每一编码值的基础值,将所述数据流中每一编码值的初始编码值与基础值的差值作为所述数据流中各个编码值的排序值,其中,所述码长基础值表包含每一所述编码码长的基础值。The addition
其查询操作执行部件1121,可以用于根据所述数据流中每一编码值的排序值,在预设的符号序列表中查询,得到与数据流中每一编码值对应的数字,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。Its query
本实施例中的数据压缩解压装置100可以通过依次串接的比较操作执行部件、加法操作执行部件以及查询操作执行部件,依次执行比较、加法以及查询、操作,替换传统的查表操作对压缩数据进行解码,由于本实施例中,使用的符号序列表、编码值范围表、码长表以及码长基础值表中的数据量小,进行的加法运算,运算速度快,因此,该数据压缩解压装置100可以高效的进行数据压缩。The data compression and
本实施例中的使用的符号序列表、码长表以及码长基础值表的与数据压缩过程一致,其具体设置方式可以参见上述实施例,在此不再做详述。The symbol sequence table, code length table, and code length basic value table used in this embodiment are consistent with the data compression process, and the specific setting method can refer to the above embodiment, which will not be described in detail here.
可选地,编码值范围表可以通过下述方式进行设置:Optionally, the coded value range table can be set in the following ways:
获取符号序列表中各个数字的编码值;查找所述符号序列表中每种编码码长的最大编码值,之后使用这些最大编码值构建编码值范围表。进一步地,升序排列编码值范围表中的编码值。可选地,使用与码长表对应的符号表示升序排列的编码值范围表中的编码值。Obtain the coding value of each number in the symbol sequence table; find the maximum coding value of each coding code length in the symbol sequence table, and then use these maximum coding values to construct a coding value range table. Further, the coded values in the coded value range table are arranged in ascending order. Optionally, the code values in the code value range table arranged in ascending order are represented by symbols corresponding to the code length table.
本实施中的设置的各个数字的编码值的方法,由于通过简单的加1或者加1补尾数0的操作,实施简单,出错概率低,且规律性强,容易被转化为上述的查表结合加法的格式获取数字的编码值的数据编码实现形式,利于提高数据压缩的效率和准确性。The method for setting the encoding value of each number in this implementation is easy to implement, has low error probability, and has strong regularity because of the simple operation of adding 1 or adding 1 to complement the mantissa 0, and is easily converted into the above-mentioned combination of table lookup The addition format obtains the data encoding implementation form of the digital encoded value, which is beneficial to improve the efficiency and accuracy of data compression.
在一可选地实施例中,如图8所示,数据压缩解压装置100的各个压缩解压操作执行组件110中串接的压缩解压操作执行部件112,包括:与连接输入FIFO存储器的游程编码执行部件1124。进一步地,该游程编码执行部件1124还可以连接输出FIFO存储器。In an optional embodiment, as shown in FIG. 8 , the compression and decompression
在其中一个可选地实施例中,在进行数据压缩时,如图8所示的数据压缩解压装置100中的游程编码执行部件1124,用于根据预设的游程位宽,以及输入的数据流中的指定数字和其他数字,分割所述输入的数据流,得到数据组;对所述数据组中除起始数字之外的其他数字进行游程编码,得到所述数据组的游程,以及将所述数据组的起始数字按照预设数值位宽进行转换得到各数据组中起始数字的编码值;将所述数据组中起始数字的编码值与游程作为所述数据组的编码值,并按照所述数据组在所述输入的数据流中的次序写出所述数据组的编码值。In one optional embodiment, when performing data compression, the run-length
例如,输入的数据流为{0,0,0,0,2,0,3,0,0},设定游程位宽为2bit,指定数字为0,预设数值位宽为8bit。For example, the input data stream is {0,0,0,0,2,0,3,0,0}, the set run length is 2bit, the specified number is 0, and the default value is 8bit.
数据流分割结果为:0,0,0,0,2,0,3,0,0。编码结果为:00000000,11,00000010, 01,00000011,10。其中,游程11表示输入数据中连续排列的三个0;用游程01表示输入数据中的一个0;用游程10表示输入数据中连续排列的两个0。The result of data stream segmentation is: 0,0,0,0,2,0,3,0,0 . The encoded result is: 00000000,11 , 00000010, 01 , 00000011,10 . Among them, the run length 11 represents three consecutive 0s in the input data; the run length 01 represents one 0 in the input data; the
应当清楚的是,游程编码执行部件1124可以每分割出一个数据组即对该数据组起始数字按照预设数值位宽进行转换,以及对该数据组的指定数字进行游程编码,当然,可选的游程编码执行部件1124可以对数据流分割完成得到所有的数据组后,再对该数据组起始数字按照预设数值位宽进行转换,以及对数据组的指定数字进行游程编码。其可以根据需求灵活选择,本实施例不作具体限定。It should be clear that the run-length
本实施例的数据压缩解压装置通过将待压缩数据中的指定数字进行游程编码,并用使用游程表示连续排列的指定数字,该方法能够对大量连续出现的数字进行数据压缩,有效节省带宽资源。The data compression and decompression device of this embodiment performs run-length coding on the specified numbers in the data to be compressed, and uses the run-length to represent the consecutively arranged specified numbers. This method can compress a large number of consecutive numbers and effectively save bandwidth resources.
在其中一个可选地实施例中,在进行数据解压时,如图8所示的数据压缩解压装置100中的游程编码执行部件1124,还可以用于根据数据流中的游程,得到解压数组,将所述解压数组中除游程以外的数字进行转化,得到所述解压数组有效数字,将所述解压数组中的游程解码为指定数字,将所述解压数组的有效数字和指定数字作为所述解压数组的解压数字。In one optional embodiment, when performing data decompression, the run-length
例如,输入的数据流为:00000000,11,00000010,01,00000011,10。其中,游程11表示输入数据中连续排列的三个0;用游程01表示输入数据中的一个0;用游程10表示输入数据中连续排列的两个0。For example, the incoming data stream is: 00000000,11,00000010,01,00000011,10. Among them, the run length 11 represents three consecutive 0s in the input data; the run length 01 represents one 0 in the input data; the
数据流分割结果为:00000000,11,00000010,01,00000011,10。得到的解压结果为:0,0,0,0,2,0,3,0,0。The result of data stream segmentation is: 00000000,11 , 00000010,01 , 00000011,10. The decompression results obtained are: 0,0,0,0,2,0,3,0,0.
本实施例的数据压缩解压装置通过将待压缩数据中的指定数字进行游程编码,并用使用游程表示连续排列的指定数字,该方法能够对大量连续出现的数字进行数据压缩,有效节省带宽资源。The data compression and decompression device of this embodiment performs run-length coding on the specified numbers in the data to be compressed, and uses the run-length to represent the consecutively arranged specified numbers. This method can compress a large number of consecutive numbers and effectively save bandwidth resources.
在其中一个实施中,在进行数据压缩时,如图9所示,数据压缩解压装置100的各个压缩解压操作执行组件110中串接的压缩解压操作执行部件112,还可以包括:设置于所述游程编码执行部件与所述输出FIFO存储器之间的替换操作执行部件1125。可选地,该替换操作执行部件1125还可以连接输出FIFO存储器。In one implementation, when performing data compression, as shown in FIG. 9 , the compression and decompression
具体地,在数据压缩解压装置100进行数据压缩时,该替换操作执行部件1125用于使用预设数字,替换起始值为所述指定数字且游程为最大值的数据组的编码值。应当清楚的是,在指定数字为确定数字,且游程位宽确定时指定数字且游程为最大值的数据组的编码值,为确定的数字加游程的组合。即替换操作执行部件1125实际是使用预设数字替换得到的游程编码中固定的数字加游程的组合。Specifically, when the data compression and
例如:承接上述示例,得到的游程编码结果:00000000,11,00000010,01,00000011,10,预设使用01000000(二进制数字,对应十进制的64)替换起始值为所述指定数字且游程为最大值的数据组的编码值。本示例中,替换操作执行部件1125实际是使用01000000替换上述游程编码结果中的00000000,11。For example: following the above example, the run-length encoding result obtained is: 00000000,11 , 00000010,01 , 00000011,10, the default is to use 01000000 (binary number, corresponding to 64 in decimal) to replace the starting value with the specified number and the run length is the largest The encoded value of the data group of values. In this example, the replacement
具体地,在数据压缩解压装置100进行数据解压,且得到的时,该替换操作执行部件1125用于根据所述编码值范围表中不小于当前编码值的最小的编码值和预设的码长表得到所述当前编码值的编码码长。应当清楚的是,在指定数字为确定数字,且游程位宽确定时指定数字且游程为最大值的数据组的编码值,为确定的数字加游程的组合。即替换操作执行部件1125实际是使用预设数字替换得到的游程编码中固定的数字加游程的组合。Specifically, when the data compression and
例如:承接上述示例,在对游程编码结果使用预设数字进行替换操作之后得到的结果为:01000000,00000010,01,00000011,10。在对其进行解压时,需先将预设数字01000000替换00000000,11。得到游程编码的压缩编码结果00000000,11,00000010,01,00000011,10。之后在使用游程编码对该结果进行解码,得到解压数据。使用游程编码对该结果进行解码的具体过程可参见上述游程解码的实施例,在此不再做详述。For example: following the above example, the result obtained after using the preset number to replace the run-length encoding result is: 01000000 , 00000010,01 , 00000011,10 . When decompressing it, you need to replace the preset number 01000000 with 00000000,11 first. Get the compressed encoding result of run-
本实施例的数据压缩解压装置在对指定数字进行游程编码得到压缩编码结果的基础上,进一步使用预设数字替换该压缩编码结果中固定的数字加游程的组合,由于游程编码得到压缩编码结果中存在大量的这一数字加游程的组合,每被替换一次,该压缩编码结果即可减少游程位宽个字节,因此该方案可以更加有效的节省带宽资源。The data compression and decompression device of this embodiment, on the basis of performing run-length encoding on a specified number to obtain a compression and encoding result, further uses a preset number to replace the fixed number plus run-length combination in the compression and encoding result. There are a large number of combinations of this number plus run length, and each time it is replaced, the compression encoding result can reduce the run length bit width by one byte, so this solution can save bandwidth resources more effectively.
在其中一个实施例中,如图10所示,数据压缩解压装置100的各个压缩解压操作执行组件110中串接的压缩解压操作执行部件112,可以包括:依次串接的依次串接的游程编码执行部件1124、替换操作执行部件1125、查询操作执行部件1121、比较操作执行部件1122以及加法操作执行部件1123,所述加法操作执行部件连接所述输出FIFO存储器。可选地,该替换操作执行部件1125可以连接输入FIFO存储器111。可选地,该游程编码执行部件1124还可以连接比较操作执行部件1122。可选地,该查询操作执行部件1121还可以连接输出FIFO存储器130。In one of the embodiments, as shown in FIG. 10 , the concatenated compression and decompression
本实施例的数据压缩解压装置100可以根据接收的控制信号,控制输入的数据流进入压缩解压操作执行组件中各个压缩解压操作执行部件的顺序。例如,在进行数据压缩时,数据流流向为:游程编码执行部件1124→替换操作执行部件1125→查询操作执行部件1121→比较操作执行部件1122→加法操作执行部件1123。相应地,据解压时,数据流流向为:替换操作执行部件1125→游程编码执行部件1124→比较操作执行部件1122→加法操作执行部件1123→查询操作执行部件1121。The data compression and
应当清楚的是,若该装置仅为了实现数据压缩或解压的单一操作,则在进行数据压缩时,该数据压缩解压装置100的各个压缩解压操作执行组件110中游程编码执行部件1124、替换操作执行部件1125、查询操作执行部件1121、比较操作执行部件1122以及加法操作执行部件1123的串接关系为:依次串接的依次串接的游程编码执行部件1124、替换操作执行部件1125、查询操作执行部件1121、比较操作执行部件1122以及加法操作执行部件1123。在进行数据解压时,该数据压缩解压装置100的各个压缩解压操作执行组件110中游程编码执行部件1124、替换操作执行部件1125、查询操作执行部件1121、比较操作执行部件1122以及加法操作执行部件1123的串接关系为:替换操作执行部件1125、游程编码执行部件1124、比较操作执行部件1122、加法操作执行部件1123以及查询操作执行部件1121。It should be clear that, if the apparatus is only for realizing a single operation of data compression or decompression, when data compression is performed, the run-length
进一步地,图10所示数据压缩解压装置100,还可以根据实际需求选择是否设置替换操作执行部件1125。若不设置操作执行部件1125,则图10中的游程编码执行部件1124需设置与输入FIFO存储器111与查询操作执行部件1121之间,以实现相应的数据压缩操作。进一步地,该游程编码执行部件1124还可以连接比较操作执行部件1122,以实现对应的数据解压操作。Further, in the data compression and
进一步地,图10所示数据压缩解压装置100中的查询操作执行部件1121、比较操作执行部件1122均可以连接至输入FIFO存储器111。该装置中的游程编码执行部件1124、替换操作执行部件1125也均可以连接至输出FIFO存储器113。此时,数据压缩解压装置100可以根据接收的控制信号,选择接收的数据流在进行压缩或解压时执行的具体子操作。Further, both the query
例如,该装置需进行游程加替换并结合改进的Huffman编码时,数据压缩解压装置100按照游程编码执行部件1124→替换操作执行部件1125→查询操作执行部件1121→比较操作执行部件1122→加法操作执行部件1123的次序对接收的数据流进行处理。具体地,数据压缩解压装置100进行游程加替换并结合改进的Huffman编码进行数据压缩时,各个压缩解压操作执行部件具体用于:For example, when the apparatus needs to perform run-length addition and replacement combined with improved Huffman coding, the data compression and
游程编码执行部件1124,用于根据预设的游程位宽,以及输入的数据流中的指定数字和其他数字,分割所述输入的数据流,得到数据组;对所述数据组中除起始数字之外的其他数字进行游程编码,得到所述数据组的游程,以及将所述数据组的起始数字按照预设数值位宽进行转换得到各数据组中起始数字的编码值;将所述数据组中起始数字的编码值与游程作为所述数据组的编码值,按照所述数据组在所述输入的数据流中的次序写出所述数据组的编码值。The run-length
替换操作执行部件1125,用于获取所述数据组的编码值,并使用预设数字,替换起始值为所述指定数字且游程为最大值的数据组的编码值,得到所述数据流的替换编码。The replacement
查询操作执行部件1121,用于获取所述数据流的替换编码,并依次获取所述数据流的替换编码中每一数字在预设的符号序列表中的排序值,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。The query
比较操作执行部件1122,用于访问预设的码长边界表,根据所述数据流的替换编码中每一数字在所述符号序列表中的排序值、预设的码长表,依次确定各个所述数字的编码码长,其中,所述码长边界表包含多种编码码长,以及每一所述编码码长的数字的最大排序值,所述码长表包含预设的多种编码码长。The comparison
加法操作执行部件1123,用于根据预设的码长基础值表以及数据流的替换编码中每一数字的编码码长,依次得到所述数据流的替换编码中每一数字的基础值,将所述数据流的替换编码中每一数字的排序值与对应的基础值相加得到所述替换编码中每一数字初始编码值,之后将所述初始编码值按照对应的编码码长进行转换,得到替换编码中每一数字的压缩编码值,其中,所述码长基础值表包括每一所述编码码长的基础值。The addition
相应地,该装置需进行游程加替换并结合改进的Huffman解码时,数据压缩解压装置100按照替换操作执行部件1125→游程编码执行部件1124→比较操作执行部件1122→加法操作执行部件1123→查询操作执行部件1121的次序对接收的数据流进行处理。具体地,数据压缩解压装置100进行游程加替换并结合改进的Huffman编码进行数据解压时,各个压缩解压操作执行部件具体用于:Correspondingly, when the apparatus needs to perform run-length addition and replacement combined with improved Huffman decoding, the data compression and
替换操作执行部件1125,用于使用指定数字和预设游程替换所述数据流中的预设数字,所述预设游程为预设的游程位宽对应的最大数值。The replacement
游程编码执行部件1124,用于根据获取数据中的游程,得到解压数组,将所述解压数组中除游程以外的数字进行转化,得到所述解压数组有效数字,将所述解压数组中的游程解码为指定数字,将所述解压数组的有效数字和指定数字作为所述数据流的中间编码结果,所述中间编码结果包含多个中间编码值。The run-length
比较操作执行部件1122,用于获取所述中间编码结果,并访问预设的编码值范围表和预设的码长表,依次得到所述中间编码结果中每一中间编码值的码长,其中,所述编码值范围表包含多种编码码长的最大编码值,所述码长编码包含所述多种编码码长。The comparison
加法操作执行部件1123,用于依次获取中间编码结果中每一中间编码值的有效值作为各所述中间编码值的初始编码值,并根据所述中间编码结果中每一中间编码值的编码码长以及预设的码长基础值表得到所述中间编码结果中每一中间编码值的基础值,将所述中间编码结果中每一中间编码值的初始编码值与基础值的差值作为所述中间编码结果中各个中间编码值的排序值,其中,所述码长基础值表包含每一所述编码码长的基础值。The addition
查询操作执行部件1121,用于根据所述中间编码结果中每一编码值的排序值,在预设的符号序列表中查询,得到与中间编码结果中每一编码值对应的数字,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。The query
例如,该装置需仅进行游程编码实现数据压缩,数据压缩解压装置100可以控制数据流进入游程编码执行部件1124执行相关操作后,直接将得到的压缩编码数据发送至输出FIFO存储器。For example, the device only needs to perform run-length encoding to realize data compression. The data compression and
相应地,该装置需仅进行游程编码实现数据解压,数据压缩解压装置100可以控制数据流进入游程编码执行部件1124执行相关操作后,直接将得到的解压数据发送至输出FIFO存储器。Correspondingly, the device only needs to perform run-length encoding to realize data decompression. The data compression and
需要说明的是,上述进行游程加替换并结合改进的Huffman编码进行数据压缩,以及仅进行游程编码仅为本实施的数据压缩解压装置可以实现的两种数据压缩的具体方式,该装置还可以基于用户的需求,灵活的将该装置在不同的压缩解压执行部件进行结合,实现多样的数据压缩方案,具体实现形式,可以在灵活选择压缩解压执行部件的基础上,参见上述实施例中的内容,即可得出具体的数据压缩方案,在此不再做详述。It should be noted that the above-mentioned performing run-length plus replacement combined with improved Huffman coding to perform data compression, and performing only run-length coding are only two specific ways of data compression that can be implemented by the data compression and decompression device of the present implementation. The device can also be based on According to the needs of users, the device can be flexibly combined with different compression and decompression execution components to realize various data compression schemes. The specific implementation form can be based on the flexible selection of compression and decompression execution components. Refer to the content in the above embodiment, A specific data compression scheme can be obtained, which will not be described in detail here.
本实施例中的数据压缩装置,可以根据不同的需求,通过控制不同的压缩解压操作执行部件执行相应的压缩子操作,实现不同的数据压缩方案。The data compression apparatus in this embodiment can implement different data compression schemes by controlling different compression and decompression operation execution components to perform corresponding compression sub-operations according to different requirements.
基于同样的发明构思,如图11所示,本申请还提出了一种数据压缩方法,该数据压缩方法,被应用于上述数据压缩解压装置,该方法具体包括:Based on the same inventive concept, as shown in FIG. 11 , the present application also proposes a data compression method. The data compression method is applied to the above-mentioned data compression and decompression device, and the method specifically includes:
步骤S101,将待压缩数据分割为多个数据流。Step S101, dividing the data to be compressed into multiple data streams.
具体地,数据分割电路120将待压缩数据分割为多个数据流。可选地,该数据流的大小可以为1024kb。可选地,可以根据待压缩数据的大小以及数据压缩解压装置100中压缩解压执行组件110的数量确定数据流的大小。Specifically, the
步骤S102,获取n个数据流,对所述n个数据流进行同步操作,并将同步操作后的所述n个数据流并行压缩,得到n个压缩编码结果,其中,n为正整数。Step S102: Acquire n data streams, perform a synchronization operation on the n data streams, and compress the n data streams after the synchronization operation in parallel to obtain n compression coding results, where n is a positive integer.
具体地,获取n个数据流,并将该n个数据流输入数据压缩解压装置100的n个压缩解压执行组件110中,在进行同步操作后,并行执行压缩操作,得到n个压缩编码结果。更具体地,获取n个数据流,并将该n个数据流输入每一压缩解压执行组件110的输入FIFO存储器111,该输入FIFO存储器111对接收的数据流进行同步操作后,将同步操作后的所述n个数据流发送至其连接的压缩解压操作执行部件,各个压缩解压操作执行部件依次执行相应的压缩子操作后,得到的n个压缩编码结果。Specifically, n data streams are acquired and input into the n compression and
步骤S103,对所述n个压缩编码进行同步操作,并将同步操作后的所述n个压缩编码结果,按照各个数据流在待压缩数据中的顺序和/或位置写出接收压缩编码结果。Step S103, perform a synchronization operation on the n compression codes, and write the received compression code results according to the order and/or position of each data stream in the data to be compressed according to the n compression codes after the synchronization operation.
具体地,得到n个压缩编码值的压缩解压操作执行部件,将其得到的压缩编码结果传输至其连接的输出FIFO存储器,各个输出FIFO存储器对接收的压缩编码结果进行同步操作后,按照各个数据流在待压缩数据中的顺序和/或位置写出接收压缩编码结果。Specifically, the compression and decompression operation execution unit that obtains n compression coding values transmits the obtained compression coding result to the output FIFO memory connected to it, and each output FIFO memory performs a synchronous operation on the received compression coding result, according to each data The sequence and/or position of the stream in the data to be compressed is written to receive the compression encoding result.
重复执行步骤101-S103,直至单次输出压缩编码结果的数量小于n。之后执行步骤S104,终止获取数据流。Steps 101-S103 are repeatedly executed until the number of single output compression coding results is less than n. After that, step S104 is executed to terminate the acquisition of the data stream.
具体地,若某次数据压缩解压装置100的n个压缩解压执行组件110输出的压缩编码结果的数量小于n,终止获取数据流。Specifically, if the number of compression and encoding results output by the n compression and
相应地,如图12所示,本申请还提出了一种数据解压方法,该数据解压方法,也被应用于上述数据压缩解压装置,该方法具体包括:Correspondingly, as shown in FIG. 12 , the present application also proposes a data decompression method. The data decompression method is also applied to the above-mentioned data compression and decompression device. The method specifically includes:
S201,将压缩数据分割为多个数据流。S201: Divide the compressed data into multiple data streams.
具体地,数据分割电路120将压缩数据分割为多个数据流。可选地,该数据流的大小可以为1024kb。可选地,可以根据压缩数据的大小以及数据压缩解压装置100中压缩解压执行组件110的数量确定数据流的大小。Specifically, the
S202,获取n个数据流,对所述n个数据流进行同步操作,并将同步操作后的所述n个数据流并行解压,得到n个解压子结果,其中,n为正整数。S202: Acquire n data streams, perform a synchronization operation on the n data streams, and decompress the n data streams after the synchronization operation in parallel to obtain n decompression sub-results, where n is a positive integer.
具体地,获取n个数据流,并将该n个数据流输入数据压缩解压装置100的n个压缩解压执行组件110中,在进行同步操作后,并行执行压缩操作,得到n个解压子结果。更具体地,获取n个数据流,并将该n个数据流输入每一压缩解压执行组件110的输入FIFO存储器111,该输入FIFO存储器111对接收的数据流进行同步操作后,将同步操作后的所述n个数据流发送至其连接的压缩解压操作执行部件,各个压缩解压操作执行部件依次执行相应的解压子操作后,得到的n个解压子结果。Specifically, n data streams are acquired and input into the n compression and
S203,对所述n个解压数字进行同步操作,并将同步操作后的所述n个解压子结果,按照各个数据流在待压缩数据中的顺序和/或位置写出解压子结果。S203, perform a synchronization operation on the n decompressed numbers, and write the decompression sub-results according to the sequence and/or position of each data stream in the data to be compressed for the n decompression sub-results after the synchronization operation.
具体地,得到n个解压子结果的压缩解压操作执行部件,将其得到的解压子结果传输至其连接的输出FIFO存储器,各个输出FIFO存储器对接收的解压子结果进行同步操作后,按照各个数据流在压缩数据中的顺序和/或位置写出接收解压子结果。Specifically, the compression and decompression operation execution unit that obtains n decompression sub-results transmits the obtained decompression sub-results to the output FIFO memory connected to it, and each output FIFO memory performs a synchronous operation on the received decompression sub-results. The order and/or position of the stream in the compressed data is written to receive the decompression sub-result.
重复执行所述获取n个数据流至写出所述n个解压子结果的步骤,直至单次解压子结果的数量小于n,之后执行S204,终止获取数据流。Repeat the steps of acquiring n data streams to writing out the n decompression sub-results until the number of single decompression sub-results is less than n, and then execute S204 to terminate the acquisition of data streams.
具体地,若某次数据压缩解压装置100的n个压缩解压执行组件110输出的解压子结果的数量小于n,终止获取数据流。Specifically, if the number of decompression sub-results output by the n compression and
本实施例的数据压缩方法,可以并行压缩或解压n个输入的数据流,且在输入和输出端均设置FIFO存储器,对输入的数据流以及输出的压缩编码值或者解压结果均进行同步操作,保证了并行对待压缩数据的多个数据流进行压缩,或者对压缩数据进行解压时,输出的结果准确。The data compression method of this embodiment can compress or decompress n input data streams in parallel, and set FIFO memories at both the input and output ends to perform synchronous operations on the input data streams and the output compression code value or decompression result, It is ensured that when multiple data streams of the data to be compressed are compressed in parallel, or the compressed data is decompressed, the output result is accurate.
作为一种可选地实施方式,如图13所示,在进行数据压缩时,在步骤S102之前,还包括:As an optional implementation manner, as shown in FIG. 13 , when performing data compression, before step S102, the method further includes:
步骤S105,获取的n个所述原始数据流,并在接收数据混洗信号后,对所述n个所述原始数据流中后段数据进行混洗,得到n个数据流,其中,所述后段数据为接收数据混洗信号之后还未获取到的各个所述原始数据流中的数据。Step S105, after the acquired n original data streams, and after receiving the data shuffling signal, shuffling the data in the later stages of the n original data streams to obtain n data streams, wherein the The subsequent data is the data in each of the original data streams that has not been acquired after receiving the data shuffling signal.
需要说明的是,本实施例中将数据分割电路分割待压缩数据得到的数据流称之为原始数据流,从输入FIFO存储器中输出的数据流称之为数据流。具体地,数据压缩解压装置100的数据混洗操作执行部件140在接收数据混洗信号后,对所述n个所述原始数据流中后段数据进行混洗,得到n个数据流。It should be noted that, in this embodiment, the data stream obtained by dividing the data to be compressed by the data dividing circuit is called the original data stream, and the data stream output from the input FIFO memory is called the data stream. Specifically, after receiving the data shuffling signal, the data shuffling
同理,在进行数据解压时,如图14所示,在步骤S202之前,也可以包括该步骤S105。此时将数据分割电路分割压缩数据得到的数据流称之为原始数据流。Similarly, when performing data decompression, as shown in FIG. 14 , step S105 may also be included before step S202 . At this time, the data stream obtained by dividing the compressed data by the data dividing circuit is called the original data stream.
进一步地,步骤S105可以包括:按照预设规则,对所述n个所述原始数据流中后段数据进行混洗,得到n个数据流,其中,所述预设规则包括:相邻m个数据流进行混洗,或者,跳过k个数据流进行混洗,所述m为正整数,m小于等于n,所述k为正整数,m小于n。Further, step S105 may include: according to a preset rule, shuffling the subsequent data in the n original data streams to obtain n data streams, wherein the preset rule includes: adjacent m The data streams are shuffled, or k data streams are skipped to be shuffled, where m is a positive integer, m is less than or equal to n, k is a positive integer, and m is less than n.
具体地,数据混洗操作执行部件140按照预设规则,对所述n个所述原始数据流中后段数据进行混洗,得到n个数据流。Specifically, the data shuffling
本实施例可以通过对数据流混洗,克服各个压缩解压操作执行组件的原始数据流中的数据在压缩效率差异较大时,造成的各个压缩解压操作执行组件执行时间差异大,降低数据压缩效率的问题。In this embodiment, by shuffling the data stream, it is possible to overcome the large difference in the execution time of the various compression and decompression operation execution components when the data in the original data streams of the various compression and decompression operation execution components has a large difference in compression efficiency, thereby reducing the data compression efficiency. The problem.
在其中一个实施例中,上述数据压缩方法或者数据解压方法还可以包括:若获取的所述原始数据流和/或所述数据流的数量小于n,则输出结束信号。该结束信号用于终止获取数据流。In one of the embodiments, the above data compression method or data decompression method may further include: if the acquired number of the original data stream and/or the data stream is less than n, outputting an end signal. The end signal is used to terminate the acquisition data stream.
具体地,在数据压缩解压装置100进行数据压缩或解压时,若n个压缩解压操作执行组件中,存在未输入数据流的压缩解压操作执行组件,则该未输入数据流的压缩解压操作执行组件的输入FIFO存储器上的结束信号发射器发射结束信号至其连接的压缩解压操作执行部件,接收到结束信号的压缩解压操作执行部件通过其安装的结束信号发射器将结束信号向后传递,直至将该结束信号传送至输出FIFO存储器,该未输入数据流的压缩解压操作执行组件的输出FIFO存储器通过其安装的结束信号发射器输出结束信号,此时,数据压缩解压装置100会终止当前执行的压缩或解压过程。Specifically, when the data compression and
在其中一个实施例中,如图15所示,步骤S102可以包括:In one embodiment, as shown in FIG. 15 , step S102 may include:
S1021a,依次获取所述数据流中数字在预设的符号序列表中的排序值,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。S1021a, sequentially acquire the ranking values of numbers in the data stream in a preset symbol sequence table, where the symbol sequence table includes multiple numbers, and the ranking of each number is obtained based on the occurrence probability of the multiple numbers value.
具体地,查询操作执行部件1121依次获取所述数据流中每一数字在预设的符号序列表中的排序值,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。Specifically, the query
S1022a,访问预设的码长边界表,根据所述数据流中每一数字在所述符号序列表中的排序值、预设的码长表,依次确定所述数据流中每一数字的编码码长,其中,所述码长边界表包含多种编码码长,以及每一所述编码码长的数字的最大排序值,所述码长表包含预设的多种编码码长。S1022a, access a preset code length boundary table, and sequentially determine the encoding of each number in the data stream according to the sorting value of each number in the data stream in the symbol sequence table and the preset code length table The code length, wherein the code length boundary table includes multiple encoding code lengths, and the maximum sorting value of the number of each encoding code length, and the code length table includes preset multiple encoding code lengths.
具体地,比较操作执行部件1122,用于访问预设的码长边界表,根据所述数据流中每一数字在所述符号序列表中的排序值、预设的码长表,依次确定所述数据流中每一数字的编码码长,其中,所述码长边界表包含多种编码码长,以及每一所述编码码长的数字的最大排序值,所述码长表包含预设的多种编码码长。Specifically, the comparison
进一步地,比较操作执行部件1122首先查找码长边界表中排序值不小于当前数字的最小的排序值;之后根据所述码长边界表中排序值不小于当前数字的最小的排序值和所述码长表确定当前符号的编码码长。Further, the comparison
S1023a,根据预设的码长基础值表以及数据流中各个数字的编码码长,依次得到所述数据流中各个数字的基础值,其中,所述码长基础值表包括每一所述编码码长的基础值。将所述数据流中每一数字的排序值与对应的基础值相加得到所述每一数字的初始编码值,之后将各个初始编码值按照对应的编码码长进行转换,得到所述数据流中各个数字的压缩编码值。S1023a, according to a preset code length basic value table and the encoding code length of each number in the data stream, sequentially obtain the basic value of each number in the data stream, wherein the code length basic value table includes each of the codes The base value of the code length. Add the sorting value of each number in the data stream and the corresponding basic value to obtain the initial encoding value of each number, and then convert each initial encoding value according to the corresponding encoding code length to obtain the data stream. The compression-encoded value of each number in .
具体地,加法操作执行部件1123根据预设的码长基础值表以及数据流中每一数字的编码码长,依次得到所述数据流中每一数字的基础值,将所述数据流中每一数字的排序值与对应的基础值相加得到所述每一数字的初始编码值,之后将各个初始编码值按照对应的编码码长进行转换,得到所述数据流中各个数字的压缩编码值,其中,所述码长基础值表包括每一所述编码码长的基础值。Specifically, the addition
相应地,在其中一个实施例中,如图16所示,对图15所示的数据压缩方法得到的压缩数据进行解压时,步骤S202可以包括:Correspondingly, in one embodiment, as shown in FIG. 16 , when decompressing the compressed data obtained by the data compression method shown in FIG. 15 , step S202 may include:
S2021a,访问预设的编码值范围表和预设的码长表,依次得到输入的数据流中各编码值的码长,其中,所述编码值范围表包含多种编码码长的最大编码值,所述码长编码包含所述多种编码码长。S2021a, accessing a preset coding value range table and a preset code length table, and sequentially obtaining the code lengths of each coding value in the input data stream, wherein the coding value range table includes the maximum coding value of multiple coding code lengths , the code length encoding includes the multiple encoding code lengths.
具体地,比较操作执行部件1122访问预设的编码值范围表和预设的码长表,依次得到输入的数据流中各编码值的码长,其中,所述编码值范围表包含多种编码码长的最大编码值,所述码长编码包含所述多种编码码长。Specifically, the comparison
进一步地,根据所述编码值范围表中不小于当前编码值的最小的编码值和预设的码长表得到所述当前编码值的编码码长。Further, the encoding code length of the current encoding value is obtained according to the smallest encoding value not less than the current encoding value in the encoding value range table and a preset code length table.
具体地,比较操作执行部件1122根据所述编码值范围表中不小于当前编码值的最小的编码值和预设的码长表得到所述当前编码值的编码码长。Specifically, the comparison
S2022a,依次获取数据流中每一编码值的有效值作为各所述编码值的初始编码值,并根据所述数据流中每一编码值的编码码长以及预设的码长基础值表得到所述数据流中每一编码值的基础值,将所述数据流中每一编码值的初始编码值与基础值的差值作为所述数据流中各个编码值的排序值,其中,所述码长基础值表包含每一所述编码码长的基础值。S2022a, sequentially acquiring the effective value of each encoding value in the data stream as the initial encoding value of each encoding value, and obtaining the encoding code length of each encoding value in the data stream and a preset code length basic value table The basic value of each coded value in the data stream, and the difference between the initial coded value and the basic value of each coded value in the data stream is used as the sorting value of each coded value in the data stream, wherein the A code length base value table contains base values for each of the encoded code lengths.
具体地,加法操作执行部件1123依次获取数据流中每一编码值的有效值作为各所述编码值的初始编码值,并根据所述数据流中每一编码值的编码码长以及预设的码长基础值表得到所述数据流中每一编码值的基础值,将所述数据流中每一编码值的初始编码值与基础值的差值作为所述数据流中各个编码值的排序值,其中,所述码长基础值表包含每一所述编码码长的基础值。Specifically, the addition
S2023a,根据所述数据流中每一编码值的排序值,在预设的符号序列表中查询,得到与数据流中每一编码值对应的数字,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。S2023a, according to the sorting value of each encoding value in the data stream, query in a preset symbol sequence table to obtain a number corresponding to each encoding value in the data stream, wherein the symbol sequence table includes a plurality of numbers , and the ranking value of each number based on the occurrence probability of the plurality of numbers.
具体地,查询操作执行部件1121根据所述数据流中每一编码值的排序值,在预设的符号序列表中查询,得到与数据流中每一编码值对应的数字,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。Specifically, the query
本实施例中数据压缩方法或解压方法,使用的符号序列表、码长边界表/编码值范围表、码长表以及码长基础值表中的数据量小,因此,使用这些数据量小的表进行数据压缩或解压数据处理效率高。In the data compression method or decompression method in this embodiment, the amount of data in the used symbol sequence table, code length boundary table/coding value range table, code length table and code length basic value table is small. Tables are highly efficient for data compression or decompression data processing.
在另一个实施例中,如图17所示,步骤S102也可以包括:In another embodiment, as shown in FIG. 17 , step S102 may also include:
S1021b,根据预设的游程位宽,以及输入的数据流中的指定数字和其他数字,分割所述输入的数据流,得到数据组。S1021b, according to the preset run-length bit width, and the designated numbers and other numbers in the input data stream, divide the input data stream to obtain a data group.
S1022b,对所述数据组中除起始数字之外的其他数字进行游程编码,得到所述数据组的游程。S1022b: Perform run-length coding on numbers other than the initial numbers in the data set to obtain the run length of the data set.
S1023b,将所述数据组的起始数字按照预设数值位宽进行转换得到各数据组中起始数字的编码值。S1023b, converting the starting number of the data group according to the preset value bit width to obtain the encoded value of the starting number in each data group.
S1024b,将所述数据组中起始数字的编码值与游程作为所述数据组的编码值,并按照所述数据组在所述输入的数据流中的次序写出所述数据组的编码值。S1024b, take the encoded value and run length of the starting number in the data group as the encoded value of the data group, and write out the encoded value of the data group according to the order of the data group in the input data stream .
具体地,游程编码执行部件1124根据预设的游程位宽,以及输入的数据流中的指定数字和其他数字,分割所述输入的数据流,得到数据组;对所述数据组中除起始数字之外的其他数字进行游程编码,得到所述数据组的游程,以及将所述数据组的起始数字按照预设数值位宽进行转换得到各数据组中起始数字的编码值;将所述数据组中起始数字的编码值与游程作为所述数据组的编码值,并按照所述数据组在所述输入的数据流中的次序写出所述数据组的编码值。Specifically, the run-length
相应地,在其中一个实施例中,如图18所示,对图17所示的数据压缩方法得到的压缩数据进行解压时,步骤S202可以包括:Correspondingly, in one of the embodiments, as shown in FIG. 18 , when decompressing the compressed data obtained by the data compression method shown in FIG. 17 , step S202 may include:
S2021b,根据获取数据流中的游程,得到解压数组。S2021b, obtain a decompressed array according to the run length in the acquired data stream.
S2022b,将所述解压数组中除游程以外的数字进行转化,得到所述解压数组有效数字,将所述解压数组中的游程解码为指定数字;将所述解压数组的有效数字和指定数字作为所述解压数组的解压数字。S2022b, convert the numbers other than the run lengths in the decompressed array to obtain significant figures of the decompressed array, and decode the run lengths in the decompressed array into specified numbers; use the significant figures and specified numbers of the decompressed arrays as the specified numbers Describes the decompression number of the decompressed array.
S2023b,按照所述解压数组在所述数据流中的次序依次写出所述解压数组的解压数字。S2023b, sequentially write the decompression numbers of the decompression array according to the order of the decompression array in the data stream.
具体地,游程编码执行部件1124根据数据流中的游程,得到解压数组,将所述解压数组中除游程以外的数字进行转化,得到所述解压数组有效数字,将所述解压数组中的游程解码为指定数字,将所述解压数组的有效数字和指定数字作为所述解压数组的解压数字。Specifically, the run-length
本实施例的数据压缩方法,对指定数字进行游程编码,并用使用游程表示连续排列的指定数字,该方法能够对大量连续出现的数字进行数据压缩,有效节省带宽资源。The data compression method of this embodiment performs run-length encoding on the designated numbers, and uses run-length to represent the designated numbers arranged in a row. This method can compress a large number of consecutive numbers and effectively save bandwidth resources.
在另一个实施例中,如图19所示,步骤S1024b之后,所述方法还包括:In another embodiment, as shown in FIG. 19 , after step S1024b, the method further includes:
S1025b,使用预设数值,替换起始值为所述指定数字且游程为最大值的数据组的编码值。S1025b, using a preset value, replace the encoded value of the data group whose initial value is the specified number and whose run length is the maximum value.
具体地,替换操作执行部件1125使用预设数字,替换起始值为所述指定数字且游程为最大值的数据组的编码值。应当清楚的是,在指定数字为确定数字,且游程位宽确定时指定数字且游程为最大值的数据组的编码值,为确定的数字加游程的组合。即替换操作执行部件1125实际是使用预设数字替换得到的游程编码中固定的数字加游程的组合。Specifically, the replacement
例如:得到的游程编码结果:00000000,11,00000010,01,00000011,10,预设使用01000000(二进制数字,对应十进制的64)替换起始值为所述指定数字且游程为最大值的数据组的编码值。本示例中,替换操作执行部件1125实际是使用01000000替换上述游程编码结果中的00000000,11。For example: the obtained run-length encoding result: 00000000,11 , 00000010,01 , 00000011,10, the default is to use 01000000 (binary number, corresponding to 64 in decimal) to replace the data set whose starting value is the specified number and whose run length is the maximum value coded value. In this example, the replacement
相应地,在其中一个实施例中,如图20所示,对图19所示的数据压缩方法得到的压缩数据进行解压时,在步骤S2021b之前可以包括:Correspondingly, in one of the embodiments, as shown in FIG. 20 , when decompressing the compressed data obtained by the data compression method shown in FIG. 19 , before step S2021b, it may include:
S2024b,使用指定数字和预设游程替换所述数据流中的预设数字,所述预设游程为预设的游程位宽对应的最大数值。S2024b, replacing a preset number in the data stream with a specified number and a preset run length, where the preset run length is the maximum value corresponding to the preset run length bit width.
具体地,替换操作执行部件1125根据所述编码值范围表中不小于当前编码值的最小的编码值和预设的码长表得到所述当前编码值的编码码长。应当清楚的是,在指定数字为确定数字,且游程位宽确定时指定数字且游程为最大值的数据组的编码值,为确定的数字加游程的组合。即替换操作执行部件1125实际是使用预设数字替换得到的游程编码中固定的数字加游程的组合。Specifically, the replacement
例如:承接上述示例,在对游程编码结果使用预设数字进行替换操作之后得到的结果为:01000000,00000010,01,00000011,10。在对其进行解压时,需先将预设数字01000000替换00000000,11。得到游程编码的压缩编码结果00000000,11,00000010,01,00000011,10。之后在使用游程编码对该结果进行解码,得到解压数据。使用游程编码对该结果进行解码的具体过程可参见上述游程解码的实施例,在此不再做详述。For example: following the above example, the result obtained after using the preset number to replace the run-length encoding result is: 01000000 , 00000010,01 , 00000011,10 . When decompressing it, you need to replace the preset number 01000000 with 00000000,11 first. Get the compressed encoding result of run-
本实施例的数据压缩方法,对指定数字进行游程编码得到压缩编码结果的基础上,进一步使用预设数字替换该压缩编码结果中固定的数字加游程的组合,由于游程编码得到压缩编码结果中存在大量的这一数字加游程的组合,每被替换一次,该压缩编码结果即可减少游程位宽个字节,因此该方案可以更加有效的节省带宽资源。In the data compression method of the present embodiment, on the basis of performing run-length encoding on a specified number to obtain a compression encoding result, a preset number is further used to replace the fixed number plus run-length combination in the compression encoding result. When a large number of combinations of this number and run length are replaced once, the compression encoding result can reduce the run length bit width by one byte, so this scheme can save bandwidth resources more effectively.
在一个实施例中,如图21所示,步骤S102也可以包括:In one embodiment, as shown in FIG. 21 , step S102 may also include:
S1021c,根据预设的游程位宽,以及输入的数据流中的指定数字和其他数字,分割所述输入的数据流,得到数据组;对所述数据组中除起始数字之外的其他数字进行游程编码,得到所述数据组的游程,以及将所述数据组的起始数字按照预设数值位宽进行二进制转换得到各数据组中起始数字的编码值;将所述数据组中起始数字的编码值与游程作为所述数据组的编码值,按照所述数据组在所述输入的数据流中的次序写出所述数据组的编码值。S1021c, dividing the input data stream according to the preset run-length bit width and the specified numbers and other numbers in the input data stream to obtain a data group; Perform run-length encoding to obtain the run length of the data group, and perform binary conversion on the starting number of the data group according to the preset value bit width to obtain the encoded value of the starting number in each data group; The encoded value and run length of the initial number are taken as the encoded value of the data group, and the encoded value of the data group is written out according to the order of the data group in the input data stream.
具体地,游程编码执行部件1124根据预设的游程位宽,以及输入的数据流中的指定数字和其他数字,分割所述输入的数据流,得到数据组;对所述数据组中除起始数字之外的其他数字进行游程编码,得到所述数据组的游程,以及将所述数据组的起始数字按照预设数值位宽进行转换得到各数据组中起始数字的编码值;将所述数据组中起始数字的编码值与游程作为所述数据组的编码值,按照所述数据组在所述输入的数据流中的次序写出所述数据组的编码值。Specifically, the run-length
S1022c,获取所述数据组的编码值,并使用预设数值,替换起始值为所述指定数字且游程为最大值的数据组的编码值,得到所述数据流的替换编码。S1022c: Obtain the encoding value of the data group, and use a preset value to replace the encoding value of the data group whose initial value is the specified number and whose run length is the maximum value, to obtain the replacement encoding of the data stream.
具体地,替换操作执行部件1125获取所述数据组的编码值,并使用预设数字,替换起始值为所述指定数字且游程为最大值的数据组的编码值,得到所述数据流的替换编码。Specifically, the replacement
S1023c,获取所述数据流的替换编码,并依次获取所述数据流的替换编码中每一数字在预设的符号序列表中的排序值,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。S1023c, obtain the replacement code of the data stream, and sequentially obtain the sorting value of each number in the replacement code of the data stream in a preset symbol sequence table, wherein the symbol sequence table includes a plurality of numbers, and A ranking value of each number obtained based on the probability of occurrence of the plurality of numbers.
具体地,查询操作执行部件1121获取所述数据流的替换编码,并依次获取所述数据流的替换编码中每一数字在预设的符号序列表中的排序值,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。Specifically, the query
S1024c,访问预设的码长边界表,根据所述数据流的替换编码中每一数字在所述符号序列表中的排序值、预设的码长表,依次确定各个所述数字的编码码长,其中,所述码长边界表包含多种编码码长,以及每一所述编码码长的数字的最大排序值,所述码长表包含预设的多种编码码长。S1024c, accessing a preset code length boundary table, and sequentially determining the encoding code of each number according to the sorting value of each number in the symbol sequence table and the preset code length table in the replacement encoding of the data stream length, wherein the code length boundary table includes multiple encoding code lengths, and the maximum sorting value of the numbers of each encoding code length, and the code length table includes preset multiple encoding code lengths.
具体地,比较操作执行部件1122访问预设的码长边界表,根据所述数据流的替换编码中每一数字在所述符号序列表中的排序值、预设的码长表,依次确定各个所述数字的编码码长,其中,所述码长边界表包含多种编码码长,以及每一所述编码码长的数字的最大排序值,所述码长表包含预设的多种编码码长。Specifically, the comparison
S1025c,根据预设的码长基础值表以及数据流的替换编码中每一数字的编码码长,依次得到所述数据流的替换编码中每一数字的基础值,将所述数据流的替换编码中每一数字的排序值与对应的基础值相加得到所述替换编码中每一数字初始编码值,之后将所述初始编码值按照对应的编码码长进行转换,得到替换编码中每一数字的压缩编码值,其中,所述码长基础值表包括每一所述编码码长的基础值。S1025c, according to the preset code length basic value table and the encoding code length of each number in the replacement encoding of the data stream, sequentially obtain the basic value of each number in the replacement encoding of the data stream, and replace the data stream with the basic value of each number in the replacement encoding. The sorting value of each number in the encoding is added with the corresponding basic value to obtain the initial encoding value of each number in the replacement encoding, and then the initial encoding value is converted according to the corresponding encoding code length to obtain each number in the replacement encoding. A digital compressed encoded value, wherein the code length base value table includes a base value for each of the encoded code lengths.
具体地,加法操作执行部件1123根据预设的码长基础值表以及数据流的替换编码中每一数字的编码码长,依次得到所述数据流的替换编码中每一数字的基础值,将所述数据流的替换编码中每一数字的排序值与对应的基础值相加得到所述替换编码中每一数字初始编码值,之后将所述初始编码值按照对应的编码码长进行转换,得到替换编码中每一数字的压缩编码值,其中,所述码长基础值表包括每一所述编码码长的基础值。Specifically, the addition
相应地,在其中一个实施例中,如图22所示,对图22所示的数据压缩方法得到的压缩数据进行解压时,步骤S202可以包括:Correspondingly, in one of the embodiments, as shown in FIG. 22 , when decompressing the compressed data obtained by the data compression method shown in FIG. 22 , step S202 may include:
S2021c,使用指定数字和预设游程替换所述数据流中的预设数字,所述预设游程为预设的游程位宽对应的最大数值。S2021c, replacing a preset number in the data stream with a specified number and a preset run length, where the preset run length is the maximum value corresponding to the preset run length bit width.
具体地,替换操作执行部件1125使用指定数字和预设游程替换所述数据流中的预设数字,所述预设游程为预设的游程位宽对应的最大数值。Specifically, the replacement
S2022c,根据获取数据中的游程,得到解压数组,将所述解压数组中除游程以外的数字进行转化,得到所述解压数组有效数字,将所述解压数组中的游程解码为指定数字,将所述解压数组的有效数字和指定数字作为所述数据流的中间编码结果,所述中间编码结果包含多个中间编码值。S2022c, obtain a decompressed array according to the run length in the acquired data, convert the numbers other than the run length in the decompressed array to obtain significant figures of the decompressed array, decode the run length in the decompressed array into a specified number, The significant figure and the specified number of the decompressed array are used as the intermediate encoding result of the data stream, and the intermediate encoding result includes a plurality of intermediate encoding values.
具体地,游程编码执行部件1124根据获取数据中的游程,得到解压数组,将所述解压数组中除游程以外的数字进行转化,得到所述解压数组有效数字,将所述解压数组中的游程解码为指定数字,将所述解压数组的有效数字和指定数字作为所述数据流的中间编码结果,所述中间编码结果包含多个中间编码值。Specifically, the run-length
S2023c,访问预设的编码值范围表和预设的码长表,依次得到所述中间编码结果中每一中间编码值的码长,其中,所述编码值范围表包含多种编码码长的最大编码值,所述码长编码包含所述多种编码码长。S2023c: Access a preset coding value range table and a preset code length table, and sequentially obtain the code length of each intermediate coding value in the intermediate coding result, wherein the coding value range table includes a plurality of coding code lengths The maximum code value, the code length code includes the multiple code code lengths.
具体地,比较操作执行部件1122获取所述中间编码结果,并访问预设的编码值范围表和预设的码长表,依次得到所述中间编码结果中每一中间编码值的码长,其中,所述编码值范围表包含多种编码码长的最大编码值,所述码长编码包含所述多种编码码长。Specifically, the comparison
S2024c,依次获取中间编码结果中每一中间编码值的有效值作为各所述中间编码值的初始编码值,并根据所述中间编码结果中每一中间编码值的编码码长以及预设的码长基础值表得到所述中间编码结果中每一中间编码值的基础值,将所述中间编码结果中每一中间编码值的初始编码值与基础值的差值作为所述中间编码结果中各个中间编码值的排序值,其中,所述码长基础值表包含每一所述编码码长的基础值。S2024c, sequentially obtaining the effective value of each intermediate encoding value in the intermediate encoding result as the initial encoding value of each intermediate encoding value, and according to the encoding code length of each intermediate encoding value in the intermediate encoding result and the preset code The long basic value table obtains the basic value of each intermediate encoding value in the intermediate encoding result, and takes the difference between the initial encoding value and the basic value of each intermediate encoding value in the intermediate encoding result as each intermediate encoding value in the intermediate encoding result. A ranking value of intermediate encoded values, wherein the code length base value table contains a base value for each of the encoded code lengths.
具体地,加法操作执行部件1123依次获取中间编码结果中每一中间编码值的有效值作为各所述中间编码值的初始编码值,并根据所述中间编码结果中每一中间编码值的编码码长以及预设的码长基础值表得到所述中间编码结果中每一中间编码值的基础值,将所述中间编码结果中每一中间编码值的初始编码值与基础值的差值作为所述中间编码结果中各个中间编码值的排序值,其中,所述码长基础值表包含每一所述编码码长的基础值。Specifically, the addition
S2025c,根据所述中间编码结果中每一编码值的排序值,在预设的符号序列表中查询,得到与中间编码结果中每一编码值对应的数字,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。S2025c, according to the sorting value of each encoding value in the intermediate encoding result, query in a preset symbol sequence table to obtain a number corresponding to each encoding value in the intermediate encoding result, wherein the symbol sequence table includes multiple number, and a ranking value of each number obtained based on the probability of occurrence of the plurality of numbers.
具体地,查询操作执行部件1121根据所述中间编码结果中每一编码值的排序值,在预设的符号序列表中查询,得到与中间编码结果中每一编码值对应的数字,其中,所述符号序列表包含多个数字,以及基于所述多个数字的出现概率得到的各个数字的排序值。Specifically, the query
本实施例的数据压缩方法,结合使用了游程编码结合数字替换以及改进的Huffman编码,该方法可以结合上述几种编码及操作的优点,数据压缩效率高。The data compression method of this embodiment uses run-length coding combined with digital replacement and improved Huffman coding. The method can combine the advantages of the above several coding and operations, and has high data compression efficiency.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage In the medium, when the computer program is executed, it may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other medium used in the various embodiments provided in this application may include non-volatile and/or volatile memory. Nonvolatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Road (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined arbitrarily. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features It is considered to be the range described in this specification.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only represent several embodiments of the present application, and the descriptions thereof are specific and detailed, but should not be construed as a limitation on the scope of the invention patent. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the scope of protection of the patent of the present application shall be subject to the appended claims.
Claims (17)
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811628184.0A CN111384968B (en) | 2018-12-28 | 2018-12-28 | Data compression/decompression device and data decompression method |
PCT/CN2019/121056 WO2020114283A1 (en) | 2018-12-07 | 2019-11-26 | Data processing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811628184.0A CN111384968B (en) | 2018-12-28 | 2018-12-28 | Data compression/decompression device and data decompression method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111384968A true CN111384968A (en) | 2020-07-07 |
CN111384968B CN111384968B (en) | 2022-08-09 |
Family
ID=71219261
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811628184.0A Active CN111384968B (en) | 2018-12-07 | 2018-12-28 | Data compression/decompression device and data decompression method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111384968B (en) |
Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1199284A (en) * | 1997-04-04 | 1998-11-18 | 三星电子株式会社 | Symbol decoding method and device |
CN1257621A (en) * | 1997-04-18 | 2000-06-21 | 首要研究有限公司 | Method and apparatus for lossless digital data compression |
US6657561B1 (en) * | 2000-05-15 | 2003-12-02 | International Business Machines Corporation | Data decompression system and method |
US20060139188A1 (en) * | 2004-12-28 | 2006-06-29 | Casio Electronics Manufacturing Co., Ltd. | Data compression/decompression device and data compression/decompression method |
US7129860B2 (en) * | 1999-01-29 | 2006-10-31 | Quickshift, Inc. | System and method for performing scalable embedded parallel data decompression |
CN1949670A (en) * | 2005-10-10 | 2007-04-18 | 中兴通讯股份有限公司 | Data compression and decompression method |
CN101198056A (en) * | 2006-12-05 | 2008-06-11 | 华为技术有限公司 | Variable length encoding method and device |
CN103326730A (en) * | 2013-06-06 | 2013-09-25 | 清华大学 | Data Parallel Compression Method |
CN104052493A (en) * | 2013-03-12 | 2014-09-17 | 三星电子株式会社 | Data processing system and method of operating a data processing system |
CN105007083A (en) * | 2015-08-13 | 2015-10-28 | 东南大学 | Method for storing output result of LZ77 compression algorithm |
CN107836083A (en) * | 2015-05-21 | 2018-03-23 | 零点科技公司 | Method, apparatus and system for semantically valued data compression and decompression |
CN109075798A (en) * | 2016-03-31 | 2018-12-21 | 零点科技公司 | Data compression of the variable-size symbol based on entropy |
CN109088636A (en) * | 2018-07-25 | 2018-12-25 | 郑州云海信息技术有限公司 | A kind of data processing method, system and electronic equipment and storage medium |
-
2018
- 2018-12-28 CN CN201811628184.0A patent/CN111384968B/en active Active
Patent Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1199284A (en) * | 1997-04-04 | 1998-11-18 | 三星电子株式会社 | Symbol decoding method and device |
CN1257621A (en) * | 1997-04-18 | 2000-06-21 | 首要研究有限公司 | Method and apparatus for lossless digital data compression |
US7129860B2 (en) * | 1999-01-29 | 2006-10-31 | Quickshift, Inc. | System and method for performing scalable embedded parallel data decompression |
US6657561B1 (en) * | 2000-05-15 | 2003-12-02 | International Business Machines Corporation | Data decompression system and method |
US20060139188A1 (en) * | 2004-12-28 | 2006-06-29 | Casio Electronics Manufacturing Co., Ltd. | Data compression/decompression device and data compression/decompression method |
CN1949670A (en) * | 2005-10-10 | 2007-04-18 | 中兴通讯股份有限公司 | Data compression and decompression method |
CN101198056A (en) * | 2006-12-05 | 2008-06-11 | 华为技术有限公司 | Variable length encoding method and device |
CN104052493A (en) * | 2013-03-12 | 2014-09-17 | 三星电子株式会社 | Data processing system and method of operating a data processing system |
CN103326730A (en) * | 2013-06-06 | 2013-09-25 | 清华大学 | Data Parallel Compression Method |
CN107836083A (en) * | 2015-05-21 | 2018-03-23 | 零点科技公司 | Method, apparatus and system for semantically valued data compression and decompression |
CN105007083A (en) * | 2015-08-13 | 2015-10-28 | 东南大学 | Method for storing output result of LZ77 compression algorithm |
CN109075798A (en) * | 2016-03-31 | 2018-12-21 | 零点科技公司 | Data compression of the variable-size symbol based on entropy |
CN109088636A (en) * | 2018-07-25 | 2018-12-25 | 郑州云海信息技术有限公司 | A kind of data processing method, system and electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN111384968B (en) | 2022-08-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8456331B2 (en) | System and method of compression and decompression | |
CN111294053B (en) | Hardware-friendly data compression method, system and device | |
JP6009676B2 (en) | Data compression device and data decompression device | |
US11677416B2 (en) | Hardware implementable data compression/decompression algorithm | |
US11909423B2 (en) | Compression circuit, storage system, and compression method | |
CN111384962B (en) | Data compression/decompression device and data compression method | |
CN111384963B (en) | Data compression/decompression device and data decompression method | |
CN111384964B (en) | Data compression and decompression device and data compression method | |
US12108064B2 (en) | Memory system | |
US12418309B2 (en) | Code table generation device, memory system, and code table generation method | |
CN111384968B (en) | Data compression/decompression device and data decompression method | |
CN115499015B (en) | Using subliterals for DEFLATE compression with reduced-complexity Huffman coding | |
CN115865098A (en) | Data Compression Method Based on Huffman Coding | |
CN114637459B (en) | Device for processing received data | |
CN111384966B (en) | Data decoding method | |
CN120653187A (en) | Storage system and data compression method | |
JP2025139943A (en) | Data compression device, data decompression device, and memory system | |
JP2025139901A (en) | Storage Systems | |
CN120238134A (en) | Data compression method and data decompression method | |
CN119906436A (en) | A lossless compression circuit, chip and device for pulse waveform data | |
CN111384967A (en) | data encoding method | |
JP2005175926A (en) | Decoder and decoding method |
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 |