Lossless decompression algorithm based on cpu+gpu heterogeneous platform and storage medium

By using a lossless decompression algorithm on a CPU+GPU heterogeneous platform, parallel decoding of multiple compressed bitstreams was achieved, solving the problems of low processing efficiency of single-core CPU and loss of information in lossy compression, thus improving image decoding efficiency and image quality.

CN114945096BActive Publication Date: 2025-10-21HEFEI I TEK OPTOELECTRONICS CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210582027.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-26
Publication Date
2025-10-21
Estimated Expiration
2042-05-26

AI Technical Summary

Technical Problem

A single-core CPU cannot meet the parallel decoding requirements of multiple compressed bitstreams, leading to decoding failures. Furthermore, lossy compression algorithms result in the loss of image detail information, while existing lossless compression algorithms are inefficient and consume excessive CPU resources.

Method used

A lossless decompression algorithm based on a CPU+GPU heterogeneous platform is adopted. The GPU is used for image decoding, while the CPU is responsible for bitstream transmission and GPU thread management, so as to realize parallel processing of data reception and decoding.

Benefits of technology

It improves image decoding efficiency, reduces CPU resource consumption, and ensures the integrity of image detail information, making it suitable for high detection accuracy scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114945096B_ABST
    Figure CN114945096B_ABST
Patent Text Reader

Abstract

The application discloses a lossless decompression algorithm based on a CPU+GPU heterogeneous platform and a storage medium, and is based on an industrial camera comprising two CPU resources and a GPU resource. Whenever an industrial camera is connected to the system, two cores with the lowest resource utilization are searched from a PC end as processing cores. The main core is responsible for communication with the industrial camera, receives data code streams, and schedules and manages GPU thread resources. The slave core receives original image data decoded by the GPU, and displays and stores the original image data. The GPU resource is applied and scheduled by the main core. If M rows of data need to be decoded at the same time, M GPU threads are applied. Each thread decodes one row of data. The decoded data is transmitted to the CPU slave core for display and storage. The application transfers the decompression work with large amount of calculation to the GPU for completion, saves the CPU resource of the host end, and enables the image code stream transmission and data decoding work to be completed in parallel through the heterogeneous architecture of the CPU+GPU, thereby saving the overall data processing time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a lossless decompression algorithm and storage medium based on a CPU+GPU heterogeneous platform. Background Art

[0002] To achieve higher transmission bandwidth, industrial cameras typically use compressed data to transmit images. The compressed data is then transmitted to the host computer, where it is decompressed by the CPU. Because the same host computer can be connected to multiple cameras simultaneously, this requires processing multiple compressed streams in parallel. A single-core CPU cannot process multiple streams quickly enough to decode them, resulting in decoding failures.

[0003] Image compression, also known as image coding, is a technique for representing the original pixel matrix with fewer bits, either losslessly or losslessly. The fundamental principle of image compression is the presence of redundancy in the original data. This redundancy primarily includes spatial redundancy, which manifests as information correlation between adjacent pixels in an image; temporal redundancy, which manifests as correlation between different frames in an image sequence; and spectral redundancy, which manifests as correlation between different color planes or spectral bands.

[0004] There are many methods for image compression, which can be divided into two main categories: lossy compression and lossless compression. Lossy compression usually has a higher compression ratio, but it will lose image details; lossless compression has a lower compression ratio, but it can maintain the integrity of the image information.

[0005] To maximize bandwidth while maintaining image quality, industrial cameras typically use lossless compression for data transmission. The compressed image data is then decoded on the host computer. If too many compressed streams are transmitted simultaneously, the host CPU may be unable to decode them in a timely manner, leading to errors.

[0006] The more common solutions currently are as follows:

[0007] 1. Use a lossy compression algorithm instead of lossless compression. The typical representative algorithm is the JPEG algorithm. The compression rate of lossy compression is generally higher, so the amount of transmitted data is smaller. However, the problem it brings is the loss of image detail information, increased calculation amount, and more CPU resources.

[0008] 2. Use prediction-entropy coding technology, such as SFALC in the reference Starosolski R. Simple Fast and Adaptive Lossless Image Compression Algorithm [J]. Software Practice and Experience, 2007, 37 (1): 65-91. Its basic process includes two parts: prediction and coding. In the prediction stage, the predicted value of the pixel is obtained based on the information of the surrounding pixels of the pixel to be encoded, and then the predicted value and the true value of the pixel are calculated to obtain the pixel residual. Compared with the original pixel value, the dynamic range of the pixel residual is greatly reduced, which is more suitable for encoding. In the encoding process, an entropy coding technology is generally selected, such as Huffman coding or arithmetic coding, and the residual is encoded to obtain compressed code stream data.

[0009] Specifically, existing technologies have three major shortcomings. The first is that both bitstream data reception and decoding are performed on the same CPU, resulting in a serial data processing process. Bitstream data must be received before decoding can begin, resulting in low overall efficiency and long decoding times. The second is CPU resource occupancy, as decoding often requires a significant amount of CPU resources. Consequently, the number of bitstreams that can be decoded simultaneously is limited by the number and frequency of the host CPU. The third is the use of lossy compression for data transmission, which results in loss of image detail and texture, making it unsuitable for scenarios requiring high detection accuracy. Summary of the Invention

[0010] The present invention proposes a lossless decompression algorithm based on a CPU+GPU heterogeneous platform, which can solve the above technical problems.

[0011] To achieve the above object, the present invention adopts the following technical solutions:

[0012] A lossless decompression algorithm based on a CPU+GPU heterogeneous platform, based on an industrial camera including two CPU resources and one GPU resource, wherein one of the two CPU resources is a master core and the other is a slave core; characterized in that it includes the following steps:

[0013] Whenever an industrial camera is connected to the system, the PC searches for the two cores with the lowest resource utilization as processing cores. The master core is responsible for communicating with the industrial camera, receiving data streams, and scheduling and managing GPU thread resources. The slave core receives the raw image data decoded by the GPU and displays and stores it.

[0014] GPU resources are requested and scheduled by the main core. If M lines of data need to be decoded at the same time, M GPU threads will be requested. Each thread decodes a line of data separately, and the decoded data is transmitted to the CPU slave core for display and storage.

[0015] Further, the following steps are included:

[0016] S01. The camera is connected to the host. The host selects the two CPUs with the lowest CPU usage as the master and slave cores based on the current CPU usage.

[0017] S02, the camera sends a decoding table to the main core;

[0018] S03, after compressing M lines of data, the camera sends the code stream data to the main core;

[0019] S04. Every time the main core receives M lines of code stream data, it will apply for M GPU thread resources. The number of GPU threads is the same as the number of lines of the image to be decoded. Each GPU thread will decode a line of image data separately.

[0020] S05. Each GPU thread decodes a row of data separately according to the decoding table and decoding algorithm to obtain the original image data;

[0021] S06, the GPU transmits the decoded M rows of data to the slave core, which is responsible for image display and storage;

[0022] S07. Repeat steps S02 to S06 until all image data are transmitted.

[0023] Furthermore, steps S04, S05, and S06 are executed concurrently. Assuming that the execution time of steps S04, S05, and S06 is T, and the entire system starts working at time T0, then within the time [T0, T1], the main core will complete the reception of the first M lines of code stream data, and at this time, the GPU decoding thread and the slave core have not yet started; within the time [T1, T2], the main core completes the reception of the second M lines of code stream data, and at the same time, the GPU decoding thread starts decoding the first M lines of code stream data, and the slave core has not yet started; within the time [T2, T3], the main core completes the reception of the third M lines of code stream data, and the GPU decoding thread starts decoding the second M lines of code stream data. After the slave core starts decoding the first M lines, the image data is displayed and saved. At all moments thereafter, steps S04, S05, and S06 are executed concurrently.

[0024] Furthermore, the GPU decoding steps include inputting a stream image, performing Huffman decoding, then performing residual recovery processing, and finally transmitting the decoded M lines of image data to the slave core for display and storage.

[0025] Furthermore, for the input code stream image, each GPU thread will decode a single line of data. The decoding process between the GPU cores is the same, the decoded data is not correlated, and the decoding work can be started at the same time.

[0026] Furthermore, the Huffman decoding step is that the input code stream data is encoded according to the Huffman coding method, and the coding table and decoding table will be sent to the GPU by the main core during initialization. The GPU completes the Huffman decoding work according to the decoding table.

[0027] Furthermore, in the residual recovery step, the data after Huffman decoding is the image residual. Assuming that the Huffman decoded data is R, the original image data X = (R + A) mod 256, where A is the left pixel of X, R is the residual data after S2 decoding, and X is the original image data. When X is the leftmost edge data of the image, A = 0;

[0028] The overall process of residual recovery starts from the leftmost pixel of a row of image data and continues to the end of the row of image pixels.

[0029] On the other hand, the present invention further discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the above method.

[0030] As can be seen from the above technical solution, the lossless decompression algorithm based on a CPU+GPU heterogeneous platform proposed in this invention can simultaneously solve the above three problems. Using a CPU to receive the bitstream and a GPU to decode it allows data reception and image decoding to be performed concurrently, saving overall processing time. Using the GPU to complete the decoding work instead of the CPU reduces the system CPU requirements and allows for the concurrent processing of multiple bitstreams. Using a lossless compression mode to transmit the bitstream data ensures that image details are not lost.

[0031] Specifically, the present invention's lossless decompression algorithm, based on a CPU+GPU heterogeneous platform, uses the CPU to transmit image stream data and manage multi-threaded GPU scheduling, while the GPU performs image stream decoding and lossless decompression. Decompression, which requires a large computational effort but employs a simple calculation method, is offloaded to the GPU, conserving CPU resources on the host. Furthermore, the CPU+GPU heterogeneous architecture enables image stream transmission and data decoding to be completed in parallel, saving overall data processing time.

[0032] Specifically, the advantages of the present invention are as follows:

[0033] The first advantage of the present invention is that it uses a CPU+GPU heterogeneous architecture to separate image code stream transmission and image decoding, so that image transmission, image decoding and image display can be executed concurrently, reducing the overall image processing time.

[0034] The second advantage of the present invention is that the GPU is used to complete the image decoding work. The number of GPU cores is much greater than that of the CPU, so multiple lines of image data can be decoded concurrently, which reduces the CPU usage and improves the concurrent efficiency of the system.

[0035] The third advantage of the present invention is the use of a lossless decompression algorithm, which does not lose image detail information and retains image texture, and is suitable for scenes with high detection accuracy or high image quality requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 is a system block diagram of an embodiment of the present invention;

[0037] Figure 2 It is a workflow diagram of an embodiment of the present invention;

[0038] Figure 3 This is a flowchart of GPU decoding according to an embodiment of the present invention. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.

[0040] Figure 1 This is the basic block diagram of the system of an embodiment of the present invention. For each industrial camera, two CPU resources and one GPU resource will be allocated to it. One of the two CPU resources is the master core, and the other is the slave core. Whenever an industrial camera is connected to the system, the two cores with the lowest resource utilization will be searched from the PC side as processing cores. The master core is responsible for communicating with the industrial camera, receiving data streams, scheduling and managing GPU thread resources; the slave core receives the original image data after GPU decoding, and displays and stores it. The GPU resources are applied for and scheduled by the master core. If M lines of data need to be decoded at the same time, M GPU threads will be applied for. Each thread decodes a line of data separately, and the decoded data is transmitted to the CPU slave core for display and storage.

[0041] Specifically, the lossless decompression algorithm based on the CPU+GPU heterogeneous platform described in the embodiment of the present invention is as follows: Figure 2 As shown, the following steps are included:

[0042] Step S01: The camera is connected to the host, and the host selects the two CPUs with the lowest CPU usage as the master core and the slave core according to the current CPU usage;

[0043] Step S02: The camera sends a decoding table to the main core;

[0044] Step S03: After compressing M lines of data, the camera sends the code stream data to the main core;

[0045] Step S04: Every time the main core receives M lines of code stream data, it will apply for M GPU thread resources. The number of GPU threads is the same as the number of lines of the image to be decoded. Each GPU thread will decode a line of image data independently.

[0046] Step S05: Each GPU thread decodes a line of data separately according to the decoding table and decoding algorithm to obtain the original image data;

[0047] Step S06: The GPU transmits the decoded M rows of data to the slave core, which is responsible for image display and storage.

[0048] Step S07: Repeat steps S02 to S06 until all image data are transmitted.

[0049] It's important to note that steps S04, S05, and S06 can be executed concurrently. Assuming that the execution time for steps S04, S05, and S06 is all T, and the entire system begins operation at time T0, then during the time [T0, T1], the master core completes receiving the first M lines of codestream data, while the GPU decoding thread and the slave core are not yet operational. During the time [T1, T2], the master core completes receiving the second M lines of codestream data, while the GPU decoding thread begins decoding the first M lines of codestream data, while the slave core is not yet operational. During the time [T2, T3], the master core completes receiving the third M lines of codestream data, while the GPU decoding thread begins decoding the second M lines of codestream data. After the slave core begins decoding the first M lines, the image data is displayed and saved. At all subsequent times, steps S04, S05, and S06 execute concurrently, improving overall system processing efficiency.

[0050] like Figure 3 The following is a flowchart of GPU decoding.

[0051] Step S11, input code stream image: each GPU thread will decode a single line of data. The decoding process between the GPU cores is the same, the decoded data is not correlated, and the decoding work can be started simultaneously;

[0052] Step S12, Huffman decoding: The input bitstream data is encoded according to the Huffman encoding method. The encoding table and decoding table will be sent to the GPU by the main core during initialization. The GPU completes the Huffman decoding work according to the decoding table;

[0053] Step S13, Residual Recovery: The data after Huffman decoding is the image residual. Assuming the decoded data in step S12 is R, the original image data X = (R + A) mod 256, where A is the pixel to the left of X, R is the residual data after S2 decoding, and X is the original image data. Note that when X is the leftmost edge of the image, A = 0. The overall residual recovery process starts from the leftmost pixel of a row of image data and continues to the end of the row of image pixels.

[0054] Step S04: The decoded M lines of image data are transmitted to the slave core for display and storage.

[0055] The GPU decoding process includes: Huffman decoding process and residual recovery process. Both processes will not cause data loss, so it is a lossless coding algorithm.

[0056] In summary, the lossless decompression algorithm based on a CPU+GPU heterogeneous platform in this embodiment of the present invention uses the CPU to complete image stream data transmission and GPU multithreaded management and scheduling, while the GPU performs image stream decoding and lossless decompression. Decompression, which requires a large computational effort but employs a simple calculation method, is offloaded to the GPU, conserving CPU resources on the host side. Furthermore, the CPU+GPU heterogeneous architecture enables image stream transmission and data decoding to be completed in parallel, saving overall data processing time.

[0057] In another aspect, the present invention further discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of any of the above methods.

[0058] On the other hand, the present invention further discloses a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any of the above methods.

[0059] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the steps of any one of the methods in the above embodiments.

[0060] It is understandable that the system provided by the embodiment of the present invention corresponds to the method provided by the embodiment of the present invention, and the explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts of the above method.

[0061] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can 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 link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0062] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0063] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A lossless decompression algorithm based on a CPU+GPU heterogeneous platform, based on an industrial camera comprising two CPU resources and one GPU resource, wherein one of the two CPU resources is a master core and the other is a slave core; characterized in that: The following steps are involved: Whenever an industrial camera is connected to the system, the host searches for the two cores with the lowest resource utilization as processing cores. The master core is responsible for communicating with the industrial camera, receiving stream data, and scheduling and managing GPU thread resources. The slave core receives the raw image data decoded by the GPU and displays and stores it. GPU resources are requested and scheduled by the main core. If M lines of data need to be decoded at the same time, M GPU threads will be requested. Each thread decodes a line of data separately. The decoded image data is transmitted to the CPU slave core for display and storage. The lossless decompression algorithm further comprises the following steps: S04. Every time the main core receives M lines of code stream data, it will apply for M GPU thread resources. The number of GPU threads is the same as the number of lines of the image to be decoded. Each GPU thread will decode a line of image data separately. S05. Each GPU thread decodes a row of data separately according to the decoding table and decoding algorithm to obtain the original image data; S06, the GPU transmits the decoded M rows of data to the slave core, which is responsible for image display and storage; After the core starts displaying and storing the first M lines of decoded image data, steps S04, S05 and S06 are executed concurrently.

2. The lossless decompression algorithm based on CPU+GPU heterogeneous platform according to claim 1, characterized in that: Before step S04, the lossless decompression algorithm further includes the following steps: S01. The industrial camera is connected to the host. The host selects the two CPUs with the lowest CPU usage as the master and slave cores based on the current CPU usage. S02, the industrial camera sends a decoding table to the main core; S03, after compressing M lines of data, the industrial camera sends the code stream data to the main core; After step S06, the lossless decompression algorithm further includes the following steps: S07. Repeat steps S02 to S06 until all image data are transmitted.

3. The lossless decompression algorithm based on a CPU+GPU heterogeneous platform according to claim 2, characterized in that: Steps S04, S05, and S06 are executed concurrently. Assuming that the execution time of steps S04, S05, and S06 is T, and the entire system starts working at time T0, then within the time [T0, T1], the main core will complete the reception of the first M lines of code stream data, and the GPU decoding thread and the slave core are not yet working; within the time [T1, T2], the main core completes the reception of the second M lines of code stream data, and the GPU decoding thread starts decoding the first M lines of code stream data, and the slave core is not yet working; within the time [T2, T3], the main core completes the reception of the third M lines of code stream data, and the GPU decoding thread starts decoding the second M lines of code stream data. After the slave core starts decoding the first M lines, the image data is displayed and saved. At all moments thereafter, steps S04, S05, and S06 are executed concurrently.

4. The lossless decompression algorithm based on a CPU+GPU heterogeneous platform according to claim 1, characterized in that: The steps of GPU decoding include inputting the bitstream image, performing Huffman decoding, then performing residual recovery processing, and finally transmitting the decoded M lines of image data to the core for display and storage.

5. The lossless decompression algorithm based on a CPU+GPU heterogeneous platform according to claim 4, characterized in that: For the input bitstream image, each GPU thread decodes a single row of data. The decoding process is the same between the GPU cores, and the decoded data is not correlated, so decoding can start at the same time.

6. The lossless decompression algorithm based on a CPU+GPU heterogeneous platform according to claim 4, characterized in that: The Huffman decoding steps are as follows: the input bitstream data is encoded according to the Huffman coding method. The encoding table and decoding table will be sent to the GPU by the main core during initialization, and the GPU will complete the Huffman decoding work according to the decoding table.

7. The lossless decompression algorithm based on a CPU+GPU heterogeneous platform according to claim 4, characterized in that: The residual recovery step is that the data after Huffman decoding is the image residual. Assuming that the Huffman decoded data is R, then the original image data X=(R+A) mod 256, where A is the left pixel of X, R is the residual data after Huffman decoding, and X is the original image data. When X is the leftmost edge data of the image, A=0; The overall process of residual recovery starts from the leftmost pixel of a row of image data and continues to the end of the row of image pixels.

8. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to perform the steps of the lossless decompression algorithm according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • JPEG 2000 image uncompressing implementation method based on GPU

    CN104185030A

  • Image processing method and electronic apparatus

    CN104519353A

  • Decoding method, device and equipment and storage medium

    CN111768460A