


技术领域technical field
本发明涉及数字信息的无损压缩、解压处理领域,具体来说是一种应用于高速印花系统上基于RLE原理的行程压缩方法及装置。The invention relates to the field of lossless compression and decompression processing of digital information, in particular to a stroke compression method and device based on the RLE principle applied to a high-speed printing system.
背景技术Background technique
信息数字化后,可以通过磁带机、硬盘等设备进行数据的永久存储,也可以通过遍布全球的网络系统进行数据传输。原始信息经过数字量化后,其样本总数是有限值,这样一段数字信息中,如果存在连续相同的样本值,可以采用行程长度压缩算法(RLE)进行压缩。经过压缩的数字信息占用更小的存储空间和更少的网络带宽,因而被普遍采用。After information is digitized, data can be stored permanently through tape drives, hard disks and other devices, and data can also be transmitted through network systems all over the world. After the original information is digitally quantized, the total number of samples is limited. If there are consecutive same sample values in such a piece of digital information, it can be compressed by the Run Length Compression Algorithm (RLE). Compressed digital information takes up less storage space and less network bandwidth, so it is widely used.
目前,采用RLE原理,派生出许多具体的行程压缩算法:PCX行程压缩算法、BI RLE8、BI RLE4、紧凑位压缩算法等,这些压缩算法,采用固定的规则,进行数字信息的编码,对于特定的数字序列,有可能出现压缩后的数据量比压缩前的数据量更大的情况。此外,还有霍夫曼编码、算术编码、LZW等非RLE原理算法,这些算法或者复杂度高,或者需要得到所有的样本才能进行压缩,不适用于实时传输系统场合。At present, using the RLE principle, many specific stroke compression algorithms are derived: PCX stroke compression algorithm, BI RLE8, BI RLE4, compact bit compression algorithm, etc. These compression algorithms use fixed rules to encode digital information. For digital sequences, it is possible that the amount of data after compression is larger than the amount of data before compression. In addition, there are non-RLE principle algorithms such as Huffman coding, arithmetic coding, and LZW. These algorithms are either high in complexity, or require all samples to be compressed, and are not suitable for real-time transmission systems.
随着数码印花机的飞速发展,需要有更大带宽的前端装置来提供高速的数据传输和处理,而采用数据压缩是一种简单可行的办法。With the rapid development of digital printing machines, front-end devices with greater bandwidth are required to provide high-speed data transmission and processing, and data compression is a simple and feasible method.
发明内容Contents of the invention
本发明提供了一种基于RLE原理的行程压缩方法,使用该方法,提供可控的压缩比,并适用于网络实时传输。The invention provides a stroke compression method based on the RLE principle. The method provides a controllable compression ratio and is suitable for network real-time transmission.
一种基于RLE原理的行程压缩方法,采用宏块分割压缩策略和压缩阀值系数,达到稳定、高效、可控的目的;其中,A stroke compression method based on the RLE principle, which adopts a macroblock segmentation compression strategy and a compression threshold coefficient to achieve the purpose of stability, high efficiency, and controllability; wherein,
所述的数据压缩过程为:The described data compression process is:
a.将原始数据读入缓存中;a. Read the original data into the cache;
b.根据预先设定的宏块大小,对缓存中的原始数据进行分割,得到一个宏块数据;b. According to the preset macroblock size, the original data in the cache is divided to obtain a macroblock data;
c.使用BI RLE8算法对宏块数据进行预压缩;c. Use the BI RLE8 algorithm to pre-compress the macroblock data;
d.将宏块数据经预压缩后的压缩率与压缩阀值系数进行比较,如果预压缩后的压缩率大于压缩阀值系数,就进行该宏块数据压缩,压缩后输出,否则使用原始宏块直接输出;d. Compare the pre-compressed compression rate of the macroblock data with the compression threshold coefficient. If the pre-compressed compression rate is greater than the compression threshold coefficient, the macroblock data will be compressed and output after compression. Otherwise, the original macro will be used. block direct output;
e.返回步骤b,进行下一个宏块数据的分割压缩。e. Return to step b, and perform segmentation and compression of the next macroblock data.
所述的数据解压过程为:The described data decompression process is:
a.将所述的数据压缩过程所输出的宏块数据接收入缓存中;a. receiving the macroblock data output by the data compression process into the cache;
b.对缓存中的接收到的宏块数据是否被压缩、压缩数据大小、解压后数据大小分别进行识别,得到宏块基本信息;b. Identify whether the received macroblock data in the cache is compressed, the size of the compressed data, and the size of the decompressed data to obtain the basic information of the macroblock;
c.根据宏块基本信息,进行解压操作,如果宏块没有被压缩,就直接输出,如果宏块有压缩,就使用BI RLE8解压算法进行解压。c. Perform the decompression operation according to the basic information of the macroblock. If the macroblock is not compressed, it will be output directly. If the macroblock is compressed, it will be decompressed using the BI RLE8 decompression algorithm.
d.返回步骤b,进行下一个宏块数据的解压,直至完成所有宏块处理。d. Return to step b, and decompress the data of the next macroblock until the processing of all macroblocks is completed.
本发明还提供了一种基于RLE原理的行程压缩方法运行装置,包括数据压缩端、数据解压端以及用于从数据压缩端向数据解压端传送数据的传输装置,The present invention also provides an operating device for a stroke compression method based on the RLE principle, including a data compression end, a data decompression end, and a transmission device for transmitting data from the data compression end to the data decompression end,
所述的数据压缩端包括:Described data compression end comprises:
原始数据读取接口,用于选择存放于PC机硬盘上的原始文件,并把所选文件的内容存放至原始数据缓存器;The original data reading interface is used to select the original file stored on the hard disk of the PC, and store the content of the selected file into the original data buffer;
原始数据缓存器,用于存放压缩前的原始数据;The original data cache is used to store the original data before compression;
宏块分割器,提供宏块大小设定接口,并使用设定的宏块大小值对原始数据缓存器中的数据进行分割控制;A macroblock splitter, providing a macroblock size setting interface, and using the set macroblock size value to split and control the data in the original data buffer;
宏块预压缩器,对原始宏块数据进行预压缩,预压缩指仅进行压缩算法处理,输出压缩后宏块大小,但不进行压缩数据输出;Macroblock pre-compressor, which pre-compresses the original macroblock data. Pre-compression refers to only performing compression algorithm processing, outputting the compressed macroblock size, but not outputting compressed data;
压缩阀值系数器,提供压缩阀值系数设定接口,并提供压缩阀值系数至宏块压缩器;The compression threshold coefficient device provides a compression threshold coefficient setting interface, and provides the compression threshold coefficient to the macroblock compressor;
宏块压缩器,根据宏块预处理器的输出结果和压缩阀值系数器的输出结果进行压缩判定,宏块压缩器根据压缩判定结果,产生两种输出,第一种输出为,宏块头+不压缩宏块,第二种输出为宏块头+压缩宏块,宏块压缩器采用的RLE算法为BI RLE8算法;The macroblock compressor performs compression judgment according to the output result of the macroblock preprocessor and the output result of the compression threshold coefficient device. The macroblock compressor generates two outputs according to the compression judgment result. The first output is macroblock header + The macroblock is not compressed, the second output is the macroblock header + compressed macroblock, and the RLE algorithm used by the macroblock compressor is the BI RLE8 algorithm;
所述的数据解压端包括:The data decompression terminal includes:
压缩数据接收器,用于从传输装置接收压缩宏块数据,并存放至压缩数据缓存器;a compressed data receiver, configured to receive compressed macroblock data from the transmission device and store it in the compressed data buffer;
压缩数据缓存器,用于存放待解压的数据;A compressed data buffer for storing data to be decompressed;
宏块信息提取器,提取宏块头中的信息,送至宏块解压器;The macroblock information extractor extracts the information in the macroblock header and sends it to the macroblock decompressor;
宏块解压器,根据宏块信息提取器提供的宏块信息进行解压处理,如果宏块信息指示该宏块没有被压缩,就直接输出宏块数据至输出原始数据缓存,如果宏块信息指示该宏块进行了压缩,就采用BI RLE8算法进行解压缩处理,解压缩需要循环进行直至解压完成整个压缩宏块。The macroblock decompressor performs decompression processing according to the macroblock information provided by the macroblock information extractor. If the macroblock information indicates that the macroblock is not compressed, it directly outputs the macroblock data to the output original data buffer. If the macroblock information indicates that the macroblock After the macroblock is compressed, the BI RLE8 algorithm is used for decompression processing. The decompression needs to be performed in a loop until the decompression completes the entire compressed macroblock.
输出原始数据缓存器,存放解压后的原始数据,该原始数据即为压缩系统上的原始数据。The original data buffer is output to store the decompressed original data, which is the original data on the compression system.
本发明在进行数据压缩前,首先将大块数据分割为一个一个宏块,宏块的大小可以通过宏块分割器提供的设定接口进行设定,使用宏块的方式,使得块与块之间没有依赖,部分错误不会导致后续数据一直出错,提高了系统的可靠性;使用宏块的方式,大块数据被分割为大小可控的单元,便于传输系统进行数据传输,提供实时传输、实时处理特性。Before performing data compression, the present invention first divides the large block data into macroblocks. The size of the macroblocks can be set through the setting interface provided by the macroblock divider. By using the macroblock mode, the relationship between blocks There is no dependence between them, and some errors will not cause subsequent data to be wrong all the time, which improves the reliability of the system; using macro blocks, large blocks of data are divided into units of controllable size, which is convenient for data transmission by the transmission system, providing real-time transmission, Real-time processing features.
本发明在对宏块数据进行压缩时,引入预压缩策略,预压缩指仅进行压缩算法处理,输出压缩后宏块大小,但不进行压缩数据输出,通过预压缩,可以得到预定的宏块压缩大小,通过与压缩阀值系数的比较,可以得到可控的数据压缩率。The present invention introduces a pre-compression strategy when compressing macroblock data. Precompression refers to only performing compression algorithm processing, outputting the size of the compressed macroblock, but not outputting compressed data. Through precompression, the predetermined macroblock compression can be obtained. Size, by comparing with the compression threshold coefficient, the controllable data compression rate can be obtained.
结合具体技术领域,本发明还提供了一种数码印花机图像数据的基于RLE原理的行程压缩方法,包括数据压缩和数据解压两个过程,Combined with the specific technical field, the present invention also provides a stroke compression method based on the RLE principle for digital printing machine image data, including two processes of data compression and data decompression,
所述的数据压缩过程为:The described data compression process is:
a.将数码印花机的待打印图像数据读入缓存中;a. Read the image data to be printed by the digital printing machine into the cache;
b.根据预先设定的宏块大小,对缓存中的待打印图像数据进行分割,得到一个宏块数据;b. Segment the image data to be printed in the cache according to the preset macroblock size to obtain a macroblock data;
c.使用BI RLE8算法对宏块数据进行预压缩;c. Use the BI RLE8 algorithm to pre-compress the macroblock data;
d.将宏块数据经预压缩后的压缩率与压缩阀值系数进行比较,如果预压缩后的压缩率大于压缩阀值系数,就进行该宏块数据进行压缩后输出,否则使用原始宏块直接输出;d. Compare the pre-compressed compression rate of the macroblock data with the compression threshold coefficient. If the pre-compressed compression rate is greater than the compression threshold coefficient, the macroblock data is compressed and output, otherwise the original macroblock is used direct output;
e.返回步骤b,进行下一个宏块数据的分割压缩。e. Return to step b, and perform segmentation and compression of the next macroblock data.
所述的数据解压过程为:The described data decompression process is:
a.将所述的数据压缩过程所输出的宏块数据接收入缓存中;a. receiving the macroblock data output by the data compression process into the cache;
b.对缓存中的接收到的宏块数据是否被压缩、压缩数据大小、解压后数据大小分别进行识别,得到宏块基本信息;b. Identify whether the received macroblock data in the cache is compressed, the size of the compressed data, and the size of the decompressed data to obtain the basic information of the macroblock;
c.根据宏块基本信息,进行解压操作,如果宏块没有被压缩,就直接输出,如果宏块有压缩,就使用BI RLE8解压算法进行解压。c. Perform the decompression operation according to the basic information of the macroblock. If the macroblock is not compressed, it will be output directly. If the macroblock is compressed, it will be decompressed using the BI RLE8 decompression algorithm.
d.返回步骤b,进行下一个宏块数据的解压,直至完成所有宏块处理。d. Return to step b, and decompress the data of the next macroblock until the processing of all macroblocks is completed.
相对于传统的RLE压缩算法,本发明使用宏块的策略,将大块分割为小块,并确保小块之间无耦合,容错性能好,系统更稳定;使用宏块策略,大块数据分割为可预测大小的宏块,便于传输系统进行传输;宏块内采用阀值系数方法,动态调整压缩阀值,处理更灵活。Compared with the traditional RLE compression algorithm, the present invention uses the macroblock strategy to divide the large block into small blocks, and ensures that there is no coupling between the small blocks, with good fault tolerance and more stable system; using the macroblock strategy, large block data can be divided It is a macro block with a predictable size, which is convenient for the transmission system to transmit; the threshold coefficient method is used in the macro block to dynamically adjust the compression threshold, and the processing is more flexible.
附图说明Description of drawings
图1为本发明行程压缩方法运行装置的结构示意框图;Fig. 1 is the schematic block diagram of the structure of the stroke compression method operating device of the present invention;
图2为本发明宏块分割器和压缩阀值系数器的结构示意框图;Fig. 2 is the schematic block diagram of the structure of the macroblock divider and the compression threshold coefficient device of the present invention;
图3为本发明数据压缩过程的示意图;Fig. 3 is the schematic diagram of data compression process of the present invention;
图4为本发明数据解压过程的示意图。Fig. 4 is a schematic diagram of the data decompression process of the present invention.
具体实施方式Detailed ways
如图1所示,一种基于RLE原理的行程压缩装置,包括:As shown in Figure 1, a stroke compression device based on the RLE principle includes:
原始数据读取接口111,用于选择存放于PC机硬盘上的原始文件,并把所选文件的内容存放至原始数据缓存器;The original
原始数据缓存器113,用于存放压缩前的原始数据;
宏块分割器112,提供宏块大小设定接口,并使用设定的宏块大小值对原始数据缓存器中的数据进行分割控制;The
宏块预压缩器114,对原始宏块数据进行预压缩,预压缩指仅进行压缩算法处理,输出压缩后宏块大小,但不进行压缩数据输出;The
压缩阀值系数器115,提供压缩阀值系数设定接口,并提供压缩阀值系数至宏块压缩器;The compression
宏块压缩器116,根据宏块预处理器的输出结果和压缩阀值系数器的输出结果进行压缩判定,宏块压缩器根据压缩判定结果,产生两种输出,第一种输出为,宏块头+不压缩宏块,第二种输出为宏块头+压缩宏块,宏块压缩器采用的RLE算法为BI RLE8算法;The
传输装置120,将压缩宏块数据从数据压缩端110传送至数据解码端130;The
压缩数据接收器131,用于从传输装置接收压缩宏块数据,并存放至压缩数据缓存器;A
压缩数据缓存器132,用于存放待解压的数据;
宏块信息提取器133,提取宏块头中的信息,送至宏块解压器;The
宏块解压器134,根据宏块信息提取器提供的宏块信息进行解压处理,如果宏块信息指示该宏块没有被压缩,就直接输出宏块数据至输出原始数据缓存,如果宏块信息指示该宏块进行了压缩,就采用BI RLE8算法进行解压缩处理,解压缩需要循环进行直至解压完成整个压缩宏块。The
输出原始数据缓存器135,存放解压后的原始数据,该原始数据即为压缩系统上的原始数据。The output
宏块分割器210在初始化时自行设定默认的宏块大小参数,如图2所示,在运行过程中,外部设备可以通过其设定接口211,设置宏块大小参数,宏块分割器在接收到设定请求后,首先判定请求值是否合法,如果合法,参数被保存在宏块大小参数保存区212,如果不合法,返回设置错误结果给外部设备,并保持当前的宏块大小参数。新设定的宏块大小参数,通过控制接口213输出,在宏块压缩器下一次取宏块数据时生效。The
压缩阀值系数器220在初始化时自行设定默认的压缩阀值系数,如图2所示,在运行过程中,外部设备可以通过其设定接口221,设置压缩阀值系数,压缩阀值系数器在接收到设定请求后,首先判定请求值是否合法,如果合法,系数被保存在压缩阀值参数保存区222,如果不合法,返回设置错误结果给外部设备,并保持当前的压缩阀值参数。新设定的压缩阀值参数,通过控制接口223输出,在宏块压缩器下一次比较时生效。The compression
如图3所示,在数码印花机的工作过程中,待打印的图像数据一般是位于计算机中,需要通过网络或数据线传输至数码印花机,本发明行程压缩方法就是在计算机中完成数据压缩,再传输到数码印花机中后进行数据解压。As shown in Figure 3, during the working process of the digital printing machine, the image data to be printed is generally located in the computer and needs to be transmitted to the digital printing machine through the network or data lines. The stroke compression method of the present invention is to complete the data compression in the computer , and then transmitted to the digital printing machine for data decompression.
解压的待打印图像数据再根据需要进行旋转等处理后,发送至数码印花机喷头打印出图像。The decompressed image data to be printed is then processed according to needs, such as rotation, and then sent to the nozzle of the digital printing machine to print out the image.
进行数据压缩时,从计算机硬盘中将原始的待打印图像数据读入缓存,根据预先设置好宏块的大小,对缓存中的待打印图像数据进行分割,分割得到若干个宏块数据。When performing data compression, read the original image data to be printed from the computer hard disk into the cache, and divide the image data to be printed in the cache according to the size of the preset macroblock to obtain several macroblock data.
对宏块数据执行BI RLE8宏块预压缩,压缩过程中,不产生实际数据的输出,只记录随着压缩算法的进行,当前压缩后将会得到的宏块大小。Perform BI RLE8 macro block pre-compression on the macro block data. During the compression process, no actual data output is generated, and only the size of the macro block that will be obtained after the current compression is recorded as the compression algorithm proceeds.
预压缩完成后,根据宏块实际大小和宏块压缩后大小算出压缩率结果,将压缩率结果和预先设定的压缩阀值系数进行比较,根据比较结果进行相应处理。After the pre-compression is completed, the compression rate result is calculated according to the actual size of the macroblock and the compressed size of the macroblock, the compression rate result is compared with the preset compression threshold coefficient, and corresponding processing is performed according to the comparison result.
如果预压缩后的压缩率结果大于压缩阀值系数,就进行宏块压缩,输出为宏块头+压缩宏块,压缩使用BI RLE8算法循环进行,直到将整个宏块数据压缩完成,压缩完成后传输到数码印花机中。If the pre-compressed compression rate result is greater than the compression threshold coefficient, the macroblock will be compressed, and the output will be the macroblock header + compressed macroblock. The compression will be performed cyclically using the BI RLE8 algorithm until the entire macroblock data is compressed and transmitted after the compression is completed. into the digital printing machine.
如果预压缩后的压缩率结果小于等于压缩阀值系数,就不进行宏块压缩,直接输出为到数码印花机中,输出形式为宏块头+不压缩宏块。If the compression rate result after pre-compression is less than or equal to the compression threshold coefficient, no macroblock compression will be performed, and the output will be directly output to the digital printing machine in the form of macroblock header + uncompressed macroblock.
如图4所示,数码印花机端接收到计算机发送的数据后进行数据解压,先提取数据压缩时写入压缩数据中的宏块头,解析宏块头信息,识别出其是否经过压缩。As shown in Figure 4, after the digital printing machine receives the data sent by the computer, it decompresses the data, first extracts the macro block header written in the compressed data when the data is compressed, analyzes the macro block header information, and identifies whether it has been compressed.
对于不压缩数据,去除宏块头信息,得到恢复后的待打印图像数据。For uncompressed data, the macroblock header information is removed to obtain the restored image data to be printed.
对于压缩数据,宏块解码器执行BI RLE8解压算法,解压数据,得到经过解压后的待打印图像数据。For the compressed data, the macroblock decoder executes the BI RLE8 decompression algorithm to decompress the data and obtain the decompressed image data to be printed.
之后再根据需要对待打印图像数据进行旋转等处理后,发送至数码印花机喷头打印出图像。After that, the image data to be printed is rotated and processed as needed, and then sent to the nozzle of the digital printing machine to print out the image.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201010039585XACN101777366B (en) | 2010-01-07 | 2010-01-07 | Stroke compression method and device based on RLE principle |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201010039585XACN101777366B (en) | 2010-01-07 | 2010-01-07 | Stroke compression method and device based on RLE principle |
| Publication Number | Publication Date |
|---|---|
| CN101777366A CN101777366A (en) | 2010-07-14 |
| CN101777366Btrue CN101777366B (en) | 2011-12-07 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201010039585XAExpired - Fee RelatedCN101777366B (en) | 2010-01-07 | 2010-01-07 | Stroke compression method and device based on RLE principle |
| Country | Link |
|---|---|
| CN (1) | CN101777366B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2014163241A1 (en)* | 2013-04-02 | 2014-10-09 | 주식회사 칩스앤미디어 | Method and apparatus for processing video |
| CN115052165A (en)* | 2022-06-15 | 2022-09-13 | 珠海趣印科技有限公司 | Label printer data lossless printing method and label printing system |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1855996A (en)* | 2005-04-19 | 2006-11-01 | 展讯通信(上海)有限公司 | Encoding method for static image compression |
| CN1920883A (en)* | 2005-08-26 | 2007-02-28 | 乐金电子(昆山)电脑有限公司 | Image compression and recovery method |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1855996A (en)* | 2005-04-19 | 2006-11-01 | 展讯通信(上海)有限公司 | Encoding method for static image compression |
| CN1920883A (en)* | 2005-08-26 | 2007-02-28 | 乐金电子(昆山)电脑有限公司 | Image compression and recovery method |
| Publication number | Publication date |
|---|---|
| CN101777366A (en) | 2010-07-14 |
| Publication | Publication Date | Title |
|---|---|---|
| US11463102B2 (en) | Data compression method, data decompression method, and related apparatus, electronic device, and system | |
| US11139827B2 (en) | Conditional transcoding for encoded data | |
| JP6049017B2 (en) | Video transmission system with reduced memory requirements | |
| US20110227764A1 (en) | Systems and methods for compression of logical data objects for storage | |
| CN103841424B (en) | The system and method for compressed data in random access memory | |
| CN107404654B (en) | A JPEG image decompression method, device and platform | |
| CN103873877A (en) | Image transmission method and device for remote desktop | |
| CN108234464B (en) | High-efficiency compression method for collected data of signal centralized monitoring system | |
| CN111510152A (en) | A Compression and Decompression Method of Sonic Logging Data | |
| JP2023064241A (en) | Storage system and data processing method in storage system | |
| CN105164923B (en) | Entropy Corrector and Method | |
| CN106817584A (en) | A kind of MJPEG compressions implementation method and FPGA based on FPGA | |
| CN112584155A (en) | Video data processing method and device | |
| WO2024061316A1 (en) | Data compression method, data decompression method, and related device | |
| CN105163122B (en) | A kind of compression of images and decompression method based on image block similarity | |
| CN106656195A (en) | Data compression decompression method and data compression decompression system | |
| CN101777366B (en) | Stroke compression method and device based on RLE principle | |
| CN112290953B (en) | Array encoding device and method, array decoding device and method for multi-channel data stream | |
| US12278957B2 (en) | Video encoding and decoding methods, encoder, decoder, and storage medium | |
| KR20200121761A (en) | Using predicates in conditional transcoder for column store | |
| CN116248668A (en) | Point cloud compression and decompression method and system based on numerical coding | |
| JP2002152742A (en) | Mpeg data processing circuit and its control method | |
| CN100401671C (en) | Method for transmitting files | |
| JP3797965B2 (en) | Image encoding apparatus, image decoding apparatus and methods thereof | |
| CN110995274B (en) | Decompression method and device |
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee | ||
| CF01 | Termination of patent right due to non-payment of annual fee | Granted publication date:20111207 |