JPEG data decoding method and device, equipment and storage medium
By sharing the virtual memory SVM between the CPU and the GPU, the initial Huffman decoding of JPEG data is used to determine whether the number of MCUs meets the conditions when the decoding is correct, the problem of excessive CPU load is solved and more efficient JPEG data decoding is achieved.
Patent Information
- Application Number
- CN202412000022.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-31
AI Technical Summary
In the prior art, the CPU load is too heavy during the decoding process of JPEG data, resulting in the problem of long decoding time and low efficiency.
By sharing the virtual memory SVM between the CPU and the GPU, the initial Huffman decoding is performed using the GPU, and when the decoding is correct, it is determined whether the MCU number meets the conditions. If it is satisfied, it instructs the GPU to perform final Huffman decoding, reducing CPU load and improving decoding efficiency.
It reduces the operating resource burden of the CPU, improves the efficiency of JPEG data decoding, and reduces the decoding time.
Smart Images

Figure CN119788872A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a JPEG data decoding method, device, equipment and storage medium. Background Art
[0002] With the continuous development of image processing technology, JPEG (Joint Photographic Experts Group) has become the most commonly used image encoding format due to its high compression rate. The encoded JPEG data needs to be decoded to obtain and display the JPEG image.
[0003] Currently, JPEG data is generally decoded based on a heterogeneous computing system formed by a CPU (Central Processing Unit) and a GPU (Graphics Processing Unit). That is, the CPU is responsible for the Huffman decoding link, and the GPU is responsible for other links, such as inverse quantization, inverse discrete cosine transform, upsampling, and color space conversion, thereby obtaining a JPEG image.
[0004] However, this method in which only the CPU is responsible for the Huffman decoding link consumes more CPU operating resources and increases the CPU operating load, resulting in a longer decoding time and lower decoding efficiency. Summary of the invention
[0005] The present application provides a JPEG data decoding method, device, equipment and storage medium, which are used to solve the technical problems in the prior art that more CPU operating resources are consumed, the CPU operating load is increased, the decoding time is long, and the decoding efficiency is low.
[0006] In a first aspect, the present application provides a JPEG data decoding method, the method is applied to a target central processing unit (CPU) in a target decoding device, the target decoding device further comprising: a target graphics processing unit (GPU) and a target shared virtual memory (SVM), the method comprising: acquiring target JPEG data, and marking the target JPEG data based on a preset segment length in units of a target minimum coding unit (MCU) to obtain target JPEG segment data; there are overlapping parts between adjacent marked segment data in the target JPEG segment data; wherein the target MCU comprises a plurality of target discrete cosine transform units (DCU);
[0007] The target JPEG segment data is stored in the target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segment data to obtain a plurality of initial decoded segments and synchronization parameter information; when the plurality of initial decoded segments are decoded correctly, adjacent initial decoded segments have overlapping parts;
[0008] In response to determining that the plurality of initial decoded segments are all decoded correctly based on the decoding results of the plurality of initial decoded segments, determining whether the number of target MCUs corresponding to the plurality of initial decoded segments meets a preset number condition, and if so, sending a target decoding instruction to a target GPU so that the target GPU performs target Huffman decoding on the plurality of initial decoded segments according to the target decoding instruction to obtain a plurality of target decoded segments;
[0009] Decode each target DCU included in each target decoded segment to obtain target JPEG decoded data, and store the target JPEG decoded data in a target SVM, so that the target GPU sequentially performs multiple preset post-processing on the target JPEG decoded data to obtain an RGB image corresponding to the target JPEG decoded data.
[0010] In one possible design, the preset quantity condition is a condition that the target MCU number corresponding to multiple initial decoded segments is equal to the target MCU number corresponding to the target JPEG data; the determination of whether the target MCU number corresponding to the multiple initial decoded segments meets the preset quantity condition includes: obtaining the target MCU number corresponding to the multiple initial decoded segments and the target MCU number corresponding to the target JPEG data, and determining whether the target MCU number corresponding to the multiple initial decoded segments is equal to the target MCU number corresponding to the target JPEG data.
[0011] In one possible design, decoding each target DCU included in each target decoded segment includes: obtaining a DC coefficient corresponding to each target DCU; decoding each target DCU based on the DC coefficient corresponding to each target DCU to obtain target JPEG decoded data.
[0012] In one possible design, the synchronization parameter information includes multiple initial decoded segment identifiers and the target MCU starting position corresponding to each initial decoded segment; after obtaining the multiple initial decoded segments and the synchronization parameter information, it also includes: obtaining the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment according to the synchronization parameter information; judging whether the second initial decoded segment overlaps with the first initial decoded segment according to the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment; if so, determining that the second initial decoded segment is decoded correctly, and judging in turn whether the multiple initial decoded segments are all decoded correctly according to the above-mentioned acquisition and judgment steps.
[0013] In a possible design, after determining whether the multiple initial decoded segments are all decoded correctly, it also includes: in response to determining that there is a decoding error in at least one initial decoded segment, acquiring the target JPEG data again, and determining the next segment length based on a preset segment length; the next segment length is longer than the preset segment length; marking the target JPEG data based on the next segment length in units of target MCUs to obtain the next JPEG segment data, so that the target GPU performs initial Huffman decoding on the next JPEG segment data to obtain multiple next initial decoded segments and next synchronization parameter information; in response to determining that the multiple next initial decoded segments are all decoded correctly, determining whether the number of target MCUs corresponding to the multiple next initial decoded segments meets a preset number condition, and if so, instructing the target GPU to perform target Huffman decoding, and decode each target DCU included in each next target decoded segment to obtain a corresponding RGB image; in response to determining that there is a decoding error in at least one next initial decoded segment, executing the acquisition of the target JPEG data and subsequent steps again until all are decoded correctly.
[0014] In a possible design, after obtaining the multiple next initial decoded segments and the next synchronization parameter information, it also includes: judging whether the multiple next initial decoded segments are all decoded correctly based on the multiple next initial decoded segments and the next synchronization parameter information.
[0015] In one possible design, after determining whether the target MCU quantity corresponding to the multiple initial decoded segments meets the preset quantity condition, or determining whether the target MCU quantity corresponding to the multiple next initial decoded segments meets the preset quantity condition, it also includes: if not, obtaining the target JPEG data again, and determining another segment length based on the preset segment length; determining whether multiple further initial decoded segments are all decoded correctly according to the target JPEG data and the further segment length, and if correct, determining whether the target MCU quantity corresponding to the multiple further initial decoded segments meets the preset quantity condition; if not, looping the above-mentioned acquisition and determination steps until it is determined that the preset quantity condition is met.
[0016] In a second aspect, the present application provides a JPEG data decoding device, including: an acquisition module, used to acquire target JPEG data;
[0017] A marking module, used for marking the target JPEG data based on a preset segment length in units of a target MCU to obtain target JPEG segment data; there are overlapping parts between adjacent marked segment data in the target JPEG segment data; wherein the target MCU includes a plurality of target DCUs;
[0018] A storage module is used to store the target JPEG segmented data into a target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segmented data to obtain a plurality of initial decoded segments and synchronization parameter information; when the plurality of initial decoded segments are decoded correctly, adjacent initial decoded segments have overlapping parts;
[0019] A judging module, configured to judge whether the number of target MCUs corresponding to the plurality of initial decoded segments meets a preset number condition in response to determining that the plurality of initial decoded segments are all decoded correctly based on the decoding results of the plurality of initial decoded segments;
[0020] a sending module, configured to send a target decoding instruction to a target GPU, so that the target GPU performs target Huffman decoding on the multiple initial decoded segments according to the target decoding instruction to obtain multiple target decoded segments;
[0021] A decoding module, used for decoding each target DCU included in each target decoded segment to obtain target JPEG decoded data;
[0022] The storage module is further used to store the target JPEG decoded data in the target SVM, so that the target GPU sequentially performs multiple preset post-processing on the target JPEG decoded data to obtain an RGB image corresponding to the target JPEG decoded data.
[0023] In a third aspect, the present application provides a target decoding device, including: a target CPU, a memory and a target GPU communicatively connected to the target CPU;
[0024] The memory stores computer-executable instructions; the target GPU is used to perform Huffman decoding on multiple segments to be decoded, and to perform multiple preset post-processing on target JPEG decoded data in sequence;
[0025] The target CPU executes the computer-executable instructions stored in the memory to implement the method according to the first aspect.
[0026] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect.
[0027] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0028] The present application provides a JPEG data decoding method, apparatus, device and storage medium, the method is applied to a target central processing unit CPU in a target decoding device, the target decoding device also includes: a target graphics processing unit GPU and a target shared virtual memory SVM, the method includes: acquiring target JPEG data, and marking the target JPEG data based on a preset segment length in units of a target minimum coding unit MCU to obtain target JPEG segmented data; there are overlapping parts between adjacent marked segmented data in the target JPEG segmented data; wherein the target MCU includes a plurality of target discrete cosine transform units DCU; storing the target JPEG segmented data in a target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segmented data to obtain a plurality of initial decoded segments and synchronization parameter information; a plurality of When the initial decoded segments are decoded correctly, there are overlapping parts between adjacent initial decoded segments; in response to determining that the initial decoded segments are all decoded correctly based on the decoding results of the initial decoded segments, it is determined whether the number of target MCUs corresponding to the initial decoded segments meets the preset number condition, and if so, a target decoding instruction is sent to the target GPU, so that the target GPU performs target Huffman decoding on the initial decoded segments according to the target decoding instruction to obtain multiple target decoded segments; each target DCU included in each target decoded segment is decoded to obtain target JPEG decoded data, and the target JPEG decoded data is stored in the target SVM, so that the target GPU performs multiple preset post-processing on the target JPEG decoded data in sequence to obtain the RGB image corresponding to the target JPEG decoded data. Since the target CPU, target GPU and target SVM are set in advance in the target decoding device, the target CPU can mark the target JPEG data as target JPEG segment data in units of target MCUs based on the preset segment length by obtaining the target JPEG data. By storing the target JPEG segment data in the target SVM, the target GPU can obtain the target JPEG segment data based on the target SVM and perform initial Huffman decoding on the target JPEG segment data, thereby obtaining multiple initial decoded segments and synchronization parameter information that have overlapping parts when the decoding is correct.Then, by determining that multiple initial decoded segments have overlapping parts according to the synchronization parameter information, it can be determined that multiple initial decoded segments are decoded correctly, and it can be further determined whether the number of target MCUs corresponding to the multiple initial decoded segments meets the conditions, so that when it is determined to meet the conditions, the target GPU is instructed to perform the final target Huffman decoding on the multiple initial decoded segments. Finally, by obtaining multiple target decoded segments, all target DCUs included in the multiple target decoded segments can be decoded to obtain target JPEG decoded data, which can be stored in the target SVM, so that the target GPU obtains the target JPEG decoded data based on the target SVM, and performs multiple preset post-processing on it in turn, so as to obtain the RGB image corresponding to the target JPEG decoded data. The GPU can also be responsible for the related work of the Huffman decoding link, without the CPU being fully responsible, thereby reducing CPU operating resources, reducing CPU operating load, and improving decoding efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0030] Figure 1 An application scenario diagram of a JPEG data decoding method provided by an embodiment of the present application;
[0031] Figure 2 A flowchart of a JPEG data decoding method provided by an embodiment of the present application;
[0032] Figure 3 A flowchart of a JPEG data decoding method provided by another embodiment of the present application;
[0033] Figure 4 A schematic diagram of the structure of a JPEG data decoding device provided in one embodiment of the present application;
[0034] Figure 5 A schematic diagram of the structure of a target decoding device provided in one embodiment of the present application.
[0035] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0036] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0037] It should be noted that the JPEG data decoding method, device, equipment and storage medium of the present application can be used in the field of image processing, and can also be used in any field other than the field of image processing. The application field of the JPEG data decoding method, device, equipment and storage medium of the present application is not limited.
[0038] First, the English abbreviations involved in this application are explained:
[0039] CPU: Central Processing Unit, is the core component of the computer responsible for executing program instructions and processing data operations.
[0040] GPU: Graphics Processing Unit, a coprocessor specifically designed for processing images and graphics operations, usually used to accelerate graphics rendering and parallel computing tasks.
[0041] SVM: Shared Virtual Memory, which allows the GPU and CPU to share memory space in the GPU scenario for more efficient data exchange and processing.
[0042] JPEG: Joint Photographic Experts Group, a widely used image compression format designed to reduce image file size while maintaining visual quality as much as possible.
[0043] MCU: Minimum Coded Unit, which refers to the smallest group of data units for interval encoding in JPEG, usually corresponding to one or more 8x8 pixel blocks.
[0044] DCU: Discrete Cosine Transform Unit. In JPEG image compression, the image is divided into multiple 8x8 pixel blocks, and each block is subjected to discrete cosine transform to convert spatial domain data into frequency domain data. Each 8x8 pixel block can be regarded as a DCU.
[0045] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.
[0046] At present, when decoding JPEG data, JPEG data is generally decoded based on a heterogeneous computing system including a CPU and a GPU. Specifically, based on the entire process of decoding JPEG data, namely Huffman decoding, inverse quantization, inverse discrete cosine transform, upsampling, and color space conversion, the CPU is set to be responsible for Huffman decoding, and the GPU is set to be responsible for inverse quantization, inverse discrete cosine transform, upsampling, and color space conversion. Then, when decoding JPEG data, the CPU obtains the JPEG data and uses a pre-stored decoding strategy to decode the JPEG data, and then sends the decoded JPEG data to the GPU, which performs inverse quantization, inverse discrete cosine transform, upsampling, and color space conversion on the decoded JPEG data in sequence, and finally obtains a JPEG image. The CPU is responsible for all Huffman decoding links, which consumes more CPU operating resources and increases the CPU operating load, resulting in a longer decoding time and lower decoding efficiency.
[0047] Therefore, in the face of the technical problems in the prior art, in order to reduce the CPU operating load and improve the decoding efficiency, the CPU is not solely responsible for Huffman decoding, but the JPEG data is marked to obtain JPEG segmented data with multiple segmentation marks and overlapping parts between each segmentation mark, so that the GPU performs parallel decoding based on the JPEG segmented data to share the Huffman decoding work. Then when decoding the JPEG data, the JPEG data is first obtained based on the CPU and marked to obtain JPEG segmented data with multiple segmentation marks and overlapping parts between each segmentation mark, and the GPU performs the first parallel decoding on the JPEG segmented data. Then, based on the CPU, it is determined whether the JPEG segmented data is decoded successfully. If so, the CPU instructs the GPU to perform a second parallel decoding on the JPEG segmented data after the first parallel decoding. Finally, the CPU decodes the DCU according to the second parallel decoding result, and the GPU sequentially performs dequantization, inverse discrete cosine transform, upsampling, and color space conversion on the decoded JPEG data to finally obtain a JPEG image. This allows the GPU to also be responsible for the related work of the Huffman decoding link, without the CPU having to take full responsibility, thereby reducing CPU operating resources, reducing CPU operating load, and improving decoding efficiency.
[0048] Figure 1 This is an application scenario diagram of a JPEG data decoding method provided by an embodiment of the present application, such as Figure 1As shown, the system corresponding to the JPEG data decoding method in the embodiment of the present application may include: a target decoding device 1, a target CPU 2, a target GPU 3 and a target SVM 4. Among them, the target CPU 2 is the central processing unit corresponding to the target decoding device 1, the target GPU 3 is the graphics processing unit corresponding to the target decoding device 1, and the target SVM 4 is the shared virtual memory corresponding to the target decoding device 1. Among them, the target CPU 2, the target GPU 3 and the target SVM 4 are located in the target decoding device 1. The target CPU 2, the target GPU 3 and the target SVM 4 have a communication connection. First, the R&D user selects the JPEG data to be decoded based on the operation interface corresponding to the target decoding device 1 in advance and triggers the decoding operation. Then, the target CPU 2 responds to the decoding operation being triggered, obtains the target JPEG data, and marks the target JPEG data based on the preset segment length in units of the target MCU to obtain the target JPEG segmented data. Among them, there is an overlapping part between the adjacent marked segmented data in the target JPEG segmented data. The target MCU includes multiple target DCUs. Then, the target JPEG segmented data is stored in the target SVM4, so that the target GPU3 performs initial Huffman decoding on the target JPEG segmented data to obtain multiple initial decoded segments and synchronization parameter information. Among them, when the multiple initial decoded segments are decoded correctly, there are overlapping parts between the adjacent initial decoded segments. Finally, in response to determining that the multiple decoded segments are decoded correctly, it is determined whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset number condition. If so, a target decoding instruction is sent to the target GPU3, so that the target GPU3 performs target Huffman decoding on the multiple initial decoded segments according to the instruction to obtain multiple target decoded segments. Finally, each target DCU included in each target decoded segment is decoded to obtain target JPEG decoded data, thereby storing the target JPEG decoded data in the target SVM, so that the target GPU performs multiple preset post-processing on the target JPEG decoded data in sequence to obtain the RGB image corresponding to the target JPEG decoded data.
[0049] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0050] Figure 2 A flowchart of a JPEG data decoding method provided by an embodiment of the present application is shown in FIG. Figure 2As shown, the execution subject of this embodiment is a JPEG data decoding device. The JPEG data decoding device is located in a target CPU in a target decoding device. The target decoding device also includes a target GPU and a target SVM. The JPEG data decoding method provided in this embodiment specifically includes the following steps:
[0051] Step 201, obtain target JPEG data, and mark the target JPEG data based on a preset segment length in units of target MCU to obtain target JPEG segment data; there are overlapping parts between adjacent marked segment data in the target JPEG segment data; wherein the target MCU includes multiple target DCUs.
[0052] The target JPEG data is JPEG data with decoding requirements.
[0053] The preset segment length is the length required to segment the target JPEG data.
[0054] The target MCU is a basic data unit constituting the target JPEG data, and may be specifically composed of multiple target DCUs. Each target DCU is a coding unit, and may be specifically composed of an 8x8 pixel matrix.
[0055] The target JPEG segmentation data is the target JPEG data with segmentation marks.
[0056] It can be understood that since the target JPEG data is a continuous character string and there is a strong correlation between adjacent data, when marking the target JPEG data, it is necessary to segment the target JPEG data based on a preset segment length and set overlapping data between each segment mark to ensure that the data between each segment mark has a strong correlation.
[0057] In this embodiment, the R&D user can select the target JPEG data to be decoded based on the operation interface corresponding to the target decoding device in advance, and trigger the decoding component based on the selection result. Then, the target CPU in the target decoding device responds to the decoding component being triggered, obtains the selected target JPEG data, and obtains the preset segment length. The target JPEG data is marked with the preset segment length, so as to obtain the target JPEG segment data in units of the target MCU.
[0058] Step 202, storing the target JPEG segment data in the target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segment data to obtain multiple initial decoded segments and synchronization parameter information; when the multiple initial decoded segments are decoded correctly, adjacent initial decoded segments have overlapping parts.
[0059] The initial Huffman decoding is to initially decode the data obtained through Huffman coding. Huffman coding is a coding method for encoding JPEG images based on a Huffman tree.
[0060] The initial decoded segment is a segment obtained after decoding the target JPEG segment data.
[0061] It is understandable that, since there is overlapping data between the segment markers, after the target JPEG segment data is decoded, if the decoding is correct, the corresponding multiple initially decoded segments should also have overlapping data.
[0062] In this embodiment, after obtaining the target JPEG segmentation data in units of the target MCU, the target JPEG segmentation data is stored in the target SVM. Based on this, the target GPU obtains the target JPEG segmentation data through the target SVM and distributes the target JPEG segmentation data to multiple threads according to the segmentation identifier. Then, the target JPEG segmentation data is calculated in parallel based on multiple threads, and multiple initial decoded segments and synchronization parameter information are output according to the calculation results. Finally, the multiple initial decoded segments and synchronization parameter information are stored in the target SVM, so that the target CPU can obtain multiple initial decoded segments and synchronization parameter information based on the target SVM.
[0063] Step 203, in response to determining that the multiple initial decoded segments are all decoded correctly based on the decoding results of the multiple initial decoded segments, it is determined whether the number of target MCUs corresponding to the multiple initial decoded segments meets a preset number condition. If so, a target decoding instruction is sent to the target GPU, so that the target GPU performs target Huffman decoding on the multiple initial decoded segments according to the target decoding instruction to obtain multiple target decoded segments.
[0064] The target decoding instruction is an instruction for instructing the target GPU to perform target Huffman decoding.
[0065] The target Huffman decoding is a decoding process of decoding the target MCU into the target DCU.
[0066] The target decoded segment is a segment corresponding to the initial decoded segment decoded based on the target Huffman decoding.
[0067] In this embodiment, after obtaining multiple initial decoded segments, based on the feature mentioned in the previous step: if the decoding is correct, the corresponding initial decoded segments should also have overlapping data. The decoding results of the multiple initial decoded segments are obtained, and based on the decoding results of the multiple initial decoded segments, it is determined whether the multiple initial decoded segments are all decoded correctly.
[0068] Based on this, in response to determining that multiple initial decoded segments are decoded correctly, based on all target MCUs in each initial decoded segment, it is further determined whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset number condition. If so, a target decoding instruction is generated and sent to the target GPU.
[0069] Based on this, the target GPU performs target Huffman decoding on the multiple initial decoded segments according to the instruction to obtain multiple target decoded segments.
[0070] Step 204, decode each target DCU included in each target decoded segment to obtain target JPEG decoded data, and store the target JPEG decoded data to the target SVM, so that the target GPU performs multiple preset post-processing on the target JPEG decoded data in sequence to obtain an RGB image corresponding to the target JPEG decoded data.
[0071] The target JPEG decoded data is the successfully decoded target JPEG data.
[0072] The preset post-processing is the post-processing required to convert the target JPEG decoded data into the corresponding RGB image. The preset post-processing specifically includes inverse quantization, inverse discrete cosine transform, upsampling, and color space conversion.
[0073] Based on this, after obtaining multiple target decoded segments, each target DCU included in each target decoded segment is decoded to obtain target JPEG decoded data, and the target JPEG decoded data is stored in the target SVM, so that the target GPU obtains the target JPEG decoded data through the target SVM, and performs inverse quantization, inverse discrete cosine transform, upsampling, and color space conversion on the target JPEG decoded data in turn, so as to obtain an RGB image corresponding to the target JPEG decoded data.
[0074] It can be understood that if the process of encoding the target JPEG data is to first convert the RGB image format into the YUV image format, and then compress the YUV image format based on the Huffman coding algorithm, the target JPEG data is obtained. When the target JPEG decoded data is subjected to preset post-processing, in order to improve the processing efficiency, the upsampling process can be removed, and the color space conversion is directly performed after the inverse discrete cosine transform is completed, and the YUV image format is converted into the RGB image format, thereby obtaining the corresponding RGB image. Among them, the RGB image format is an additive color model, which represents various colors by combining three basic colors of red (R), green (G), and blue (B) of different intensities. The YUV image format divides the color information into brightness (Y) and chrominance (U and V) components, and uses the characteristic that the human eye is more sensitive to brightness to allow more efficient compression.
[0075] It should be noted that this embodiment can be implemented based on OpenCL (Open Computing Language), specifically based on OpenCL 2.0. OpenCL is a working standard for writing programs on a heterogeneous parallel computing platform, which can be used for CPU, GPU, or other computing devices.
[0076] The JPEG data decoding method provided by the embodiment acquires target JPEG data, and marks the target JPEG data based on a preset segment length in a target MCU unit to obtain target JPEG segment data; there is an overlapping portion between adjacent marked segment data in the target JPEG segment data; the target MCU includes a plurality of target DCUs; the target JPEG segment data is stored in a target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segment data to obtain a plurality of initial decoded segments and synchronization parameter information; when the plurality of initial decoded segments are decoded correctly, there are overlapping portions between adjacent initial decoded segments; in response to the plurality of initial decoded segments being decoded correctly based on the plurality of initial decoded segments, the target JPEG segment data is decoded correctly based on the plurality of initial decoded segments. The decoding result of the segment determines that multiple initial decoded segments are decoded correctly, and determines whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset number condition. If so, a target decoding instruction is sent to the target GPU, so that the target GPU performs target Huffman decoding on the multiple initial decoded segments according to the target decoding instruction to obtain multiple target decoded segments; decodes each target DCU included in each target decoded segment to obtain target JPEG decoded data, and stores the target JPEG decoded data to the target SVM, so that the target GPU performs multiple preset post-processing on the target JPEG decoded data in sequence to obtain the RGB image corresponding to the target JPEG decoded data. Since the target CPU, target GPU and target SVM are set in advance in the target decoding device, the target CPU can obtain the target JPEG data and mark it as the target JPEG segment data in units of target MCUs based on the preset segment length. And by storing the target JPEG segment data to the target SVM, the target GPU can obtain the target JPEG segment data based on the target SVM and perform initial Huffman decoding on the target JPEG segment data, thereby obtaining multiple initial decoded segments and synchronization parameter information with overlapping parts when the decoding is correct. Then, by determining that multiple initial decoded segments have overlapping parts according to the synchronization parameter information, it can be determined that multiple initial decoded segments are decoded correctly, and it can be further determined whether the number of target MCUs corresponding to the multiple initial decoded segments meets the conditions, so that when it is determined to meet the conditions, the target GPU is instructed to perform the final target Huffman decoding on the multiple initial decoded segments. Finally, by obtaining multiple target decoded segments, all target DCUs included in the multiple target decoded segments can be decoded to obtain target JPEG decoded data, which can be stored in the target SVM, so that the target GPU obtains the target JPEG decoded data based on the target SVM, and performs multiple preset post-processing on it in turn, so as to obtain the RGB image corresponding to the target JPEG decoded data. The GPU can also be responsible for the related work of the Huffman decoding link, without the CPU being fully responsible, thereby reducing CPU operating resources, reducing CPU operating load, and improving decoding efficiency.
[0077] As an optional embodiment, based on the above embodiment, the preset quantity condition of this embodiment is that the number of target MCUs corresponding to the multiple initial decoded segments is equal to the number of target MCUs corresponding to the target JPEG data. When judging whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset quantity condition, the following steps are specifically included:
[0078] Obtain the target MCU numbers corresponding to the multiple initial decoded segments and the target MCU number corresponding to the target JPEG data, and determine whether the target MCU number corresponding to the multiple initial decoded segments is equal to the target MCU number corresponding to the target JPEG data.
[0079] It can be understood that if all target JPEG data are decoded correctly, the number of target MCUs corresponding to the target JPEG data should be consistent with the number of target MCUs corresponding to the multiple initial decoded segments.
[0080] Based on this, the target MCU number corresponding to multiple initial decoded segments and the target MCU number corresponding to the target JPEG data are obtained, and the two numbers are compared to determine whether the target MCU number corresponding to multiple initial decoded segments is equal to the target MCU number corresponding to the target JPEG data, thereby determining whether the target MCU number corresponding to multiple initial decoded segments meets the preset quantity condition.
[0081] The JPEG data decoding method provided in this embodiment has a preset quantity condition that the target MCU quantity corresponding to the multiple initial decoded segments is equal to the target MCU quantity corresponding to the target JPEG data. When judging whether the target MCU quantity corresponding to the multiple initial decoded segments meets the preset quantity condition, the target MCU quantity corresponding to the multiple initial decoded segments and the target MCU quantity corresponding to the target JPEG data are obtained, and it is judged whether the target MCU quantity corresponding to the multiple initial decoded segments is equal to the target MCU quantity corresponding to the target JPEG data. Since the MCU quantity before and after decoding is consistent, by obtaining the target MCU quantity corresponding to the multiple initial decoded segments and the target MCU quantity corresponding to the target JPEG data, it is possible to make a judgment based on the two quantities, thereby determining whether the two quantities are consistent, and then determining whether the preset quantity condition is met, thereby improving the judgment efficiency, and further improving the accuracy of decoding.
[0082] Figure 3 A flowchart of a JPEG data decoding method provided by another embodiment of the present application is shown in FIG. Figure 3 As shown, based on the above embodiment, this embodiment further refines the decoding of each target DCU included in each target decoded segment. When decoding each target DCU included in each target decoded segment, this embodiment specifically includes the following steps:
[0083] Step 301, obtaining the DC coefficient corresponding to each target DCU.
[0084] The DC coefficient corresponding to the target DCU is the first coefficient located at the upper left corner of the 8*8 matrix included in the target DCU.
[0085] It can be understood that in the process of encoding the target JPEG data, the DC coefficients corresponding to each target DCU will be differentially encoded based on the differences between the target DCUs in the target JPEG data. Therefore, decoding each target DCU included in each target decoded segment is essentially decoding the DC coefficients corresponding to each target DCU.
[0086] Based on this, after determining that multiple initial decoded segments are decoded correctly, the DC coefficient corresponding to each target DCU is obtained.
[0087] Step 302: decode each target DCU based on the DC coefficient corresponding to each target DCU to obtain target JPEG decoded data.
[0088] In this embodiment, based on the DC coefficient corresponding to each target DCU, the DC coefficient corresponding to the first target DCU is decoded first, and based on the above decoding result and the difference between the DC coefficient corresponding to the first target DCU and the DC coefficient corresponding to the second target DCU, the DC coefficient corresponding to the second target DCU is decoded, and so on, to complete the decoding of all target DCUs and obtain the target JPEG decoded data.
[0089] The JPEG data decoding method provided in this embodiment obtains the DC coefficient corresponding to each target DCU when decoding each target DCU included in each target decoded segment; decodes each target DCU based on the DC coefficient corresponding to each target DCU to obtain target JPEG decoded data. Since decoding each target DCU is essentially decoding the DC coefficient corresponding to each target DCU. Therefore, by obtaining the DC coefficient corresponding to each target DCU, each target DCU can be decoded based on the DC coefficient corresponding to each target DCU to obtain target JPEG decoded data, thereby further improving decoding efficiency.
[0090] As an optional embodiment, in this embodiment Figure 2 On the basis of the corresponding embodiment, the synchronization parameter information includes multiple initial decoded segment identifiers and the target MCU starting position corresponding to each initial decoded segment. After obtaining multiple initial decoded segments and synchronization parameter information, the following steps are also included:
[0091] Step 401: Obtain a target MCU start position corresponding to a first initial decoded segment and a target MCU start position corresponding to a second initial decoded segment according to synchronization parameter information.
[0092] The initial decoded segment identifier is any identifier that represents the identity of the initial decoded segment.
[0093] The first initial decoded segment is the first segment among multiple initial decoded segments.
[0094] The second initial decoded segment is the second segment among the multiple initial decoded segments.
[0095] In this embodiment, based on obtaining multiple initial decoded segments, the first initial decoded segment and the second initial decoded segment among the multiple initial decoded segments are obtained, and according to each initial decoded segment identifier in the synchronization parameter information, the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment are obtained.
[0096] Step 402 , judging whether the second initial decoded segment overlaps with the first initial decoded segment according to the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment.
[0097] It can be understood that the starting position of the target MCU corresponding to the first initial decoded segment is always determined, so the first initial decoded segment is always decoded correctly.
[0098] Based on this, the target MCU starting position corresponding to the first initial decoded segment is compared with the target MCU starting position corresponding to the second initial decoded segment to determine whether there is an identical target MCU starting position, thereby determining whether the second initial decoded segment overlaps with the first initial decoded segment.
[0099] Step 403: If yes, determine that the second initial decoded segment is decoded correctly, and determine in sequence whether multiple initial decoded segments are all decoded correctly according to the above acquisition and determination steps.
[0100] It can be understood that since the first initial decoded segment and the second initial decoded segment will have overlapping calculation parts, if the starting position of the target MCU corresponding to the second initial decoded segment is the same as the starting position of the target MCU corresponding to the first initial decoded segment, then the second initial decoded segment starting from this target MCU, all subsequent target MCUs are correct.
[0101] Based on this, if it is determined that the same target MCU starting position exists, it can be determined that the second initial decoded segment overlaps with the first initial decoded segment, then it is determined that the second initial decoded segment is decoded correctly, and according to the above-mentioned acquisition and judgment steps, it is determined in turn whether multiple initial decoded segments are all decoded correctly.
[0102] Similarly, according to the above acquisition and determination steps, it is determined in sequence whether the multiple initially decoded segments are all decoded correctly.
[0103] In the JPEG data decoding method provided by the present embodiment, the synchronization parameter information includes multiple initial decoded segment identifiers and the target MCU starting position corresponding to each initial decoded segment. After obtaining multiple initial decoded segments and the synchronization parameter information, the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment are obtained according to the synchronization parameter information; according to the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment, it is judged whether the second initial decoded segment overlaps with the first initial decoded segment; if so, it is determined that the second initial decoded segment is decoded correctly, and according to the above-mentioned acquisition and judgment steps, it is judged in turn whether multiple initial decoded segments are all decoded correctly. Since the starting positions of the overlapping MCUs in the segments before and after decoding should be consistent when the decoding is correct, by obtaining the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment according to the synchronization parameter information, it is possible to determine whether the second initial decoded segment overlaps with the first initial decoded segment according to the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment, thereby determining that the second initial decoded segment is decoded correctly when the overlap is determined, and then determining whether multiple initial decoded segments are all decoded correctly in sequence according to the above acquisition and judgment steps. This realizes verification of the entire decoding process, improves verification accuracy, and improves verification efficiency.
[0104] As an optional embodiment, based on the above embodiment, after determining whether multiple initially decoded segments are all decoded correctly, this embodiment further includes the following steps:
[0105] Step 501, in response to determining that there is a decoding error in at least one initially decoded segment, acquiring target JPEG data again, and determining a next segment length based on a preset segment length; the next segment length is longer than the preset segment length.
[0106] The next segment length is the length required to divide the target JPEG data again, and the next segment length is longer than the preset segment length.
[0107] In this embodiment, based on judging whether multiple initial decoded segments are all decoded correctly, in response to determining that there is a decoding error in at least one initial decoded segment, it indicates that decoding under the current preset segment length state is not sufficient to ensure the correlation between the initial decoded segments.
[0108] Based on this, the target JPEG data is acquired again, and extended based on the preset segment length, and the extended preset segment length is determined as the next segment length.
[0109] Step 502, marking the target JPEG data based on the next segment length in units of target MCUs to obtain the next JPEG segment data, so that the target GPU performs initial Huffman decoding on the next JPEG segment data to obtain multiple next initial decoded segments and next synchronization parameter information.
[0110] In this embodiment, the target JPEG data is marked based on the next segment length in units of the target MCU to obtain the next JPEG segment data, so that the target GPU performs initial Huffman decoding on the next JPEG segment data. The specific marking method is similar to the marking method based on the preset segment length in step 201, and will not be repeated here.
[0111] Step 503, in response to determining that multiple next initial decoded segments are decoded correctly, determine whether the number of target MCUs corresponding to the multiple next initial decoded segments meets a preset number condition. If so, instruct the target GPU to perform target Huffman decoding and decode each target DCU included in each next target decoded segment to obtain a corresponding RGB image.
[0112] In this embodiment, based on obtaining multiple next initial decoded segments, it is determined whether each next initial decoded segment is decoded correctly. The specific determination method is similar to steps 401-403, and will not be repeated here. Then, in response to determining that multiple next initial decoded segments are decoded correctly, it is determined whether the number of target MCUs corresponding to the multiple next decoded segments meets the preset number condition. If so, the target GPU is instructed to perform target Huffman decoding to obtain multiple next target decoded segments, and each target DCU included in each next target decoded segment is decoded to obtain the corresponding RGB image. The specific decoding method is similar to steps 203-204, and will not be repeated here.
[0113] Step 504, in response to determining that there is a decoding error in at least one next initially decoded segment, the step of obtaining the target JPEG data and subsequent steps are performed again until all decoding is correct.
[0114] In this embodiment, if there is still at least one next initially decoded segment decoding error, the target JPEG data acquisition and subsequent steps are executed again until all decoding is correct. The specific execution method is similar to steps 501-502 and will not be repeated here.
[0115] The JPEG data decoding method provided by the present embodiment, after determining whether multiple initial decoded segments are all decoded correctly, in response to determining that there is a decoding error in at least one initial decoded segment, the target JPEG data is acquired again, and the next segment length is determined based on a preset segment length; the next segment length is longer than the preset segment length; the target JPEG data is marked based on the next segment length in units of target MCUs to obtain the next JPEG segment data, so that the target GPU performs initial Huffman decoding on the next JPEG segment data to obtain multiple next initial decoded segments and next synchronization parameter information; in response to determining that multiple next initial decoded segments are all decoded correctly, it is determined whether the number of target MCUs corresponding to the multiple next initial decoded segments meets a preset number condition, and if so, the target GPU is instructed to perform target Huffman decoding, and decode each target DCU included in each next target decoded segment to obtain a corresponding RGB image; in response to determining that there is a decoding error in at least one next initial decoded segment, acquiring the target JPEG data and subsequent steps are performed again until all are decoded correctly. Since the longer preset segment length can further ensure the correlation between the initial decoded segments, when it is determined that there is a decoding error in the initial decoded segment, the target JPEG data is obtained again, and the next segment length is determined based on the preset segment length, that is, the target JPEG data can be marked based on the next segment length in units of target MCU. Then if it is determined that multiple next initial decoded segments are all decoded correctly, it can be further determined whether the number of target MCUs corresponding to the multiple next decoded segments meets the preset number condition, so as to instruct the target GPU to perform target Huffman decoding, and obtain multiple next target decoded segments, thereby decoding each target DCU included in each next initial decoded segment, so as to obtain the corresponding RGB image. If it is determined that there are still multiple next initial decoded segment decoding errors, the above steps are performed again until all are decoded correctly. This makes it possible to quickly resolve decoding errors, improve decoding accuracy, and further improve decoding efficiency.
[0116] As an optional embodiment, based on the above embodiment, after obtaining multiple next initial decoded segments and next synchronization parameter information, this embodiment further includes the following steps:
[0117] Based on the multiple next initial decoded segments and the next synchronization parameter information, it is determined whether the multiple next initial decoded segments are all decoded correctly.
[0118] In this embodiment, according to the next synchronization parameter information, the target MCU starting position corresponding to the first next initial decoded segment and the target MCU starting position corresponding to the second next initial decoded segment are obtained, and it is determined whether the second next initial decoded segment overlaps with the first next initial decoded segment according to the above starting position. If so, it is determined that the second next initial decoded segment is decoded correctly, and according to the above acquisition and judgment steps, it is sequentially determined whether multiple next initial decoded segments are all decoded correctly. The specific execution method is similar to steps 401-403, and will not be repeated here one by one.
[0119] The JPEG data decoding method provided by the present embodiment, after obtaining multiple next initial decoded segments and next synchronization parameter information, determines whether multiple next initial decoded segments are all decoded correctly based on multiple next initial decoded segments and next synchronization parameter information. Since it is necessary to verify the decoding accuracy of multiple next initial decoded segments, after obtaining multiple next initial decoded segments, by determining whether multiple next initial decoded segments are all decoded correctly based on multiple next initial decoded segments and next synchronization parameter information, the entire next decoding process can be verified, thereby further improving the accuracy of verification and further improving the verification efficiency.
[0120] As an optional embodiment, in this embodiment Figure 2 On the basis of the corresponding embodiment or the above-mentioned previous embodiment, after determining whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset number condition, or determining whether the number of target MCUs corresponding to the multiple next initial decoded segments meets the preset number condition, the following steps are also included:
[0121] Step 601: If not, the target JPEG data is acquired again, and another segment length is determined based on the preset segment length.
[0122] The further segment length is the length required for dividing the target JPEG data again, and the further segment length is longer than the preset segment length.
[0123] In this embodiment, it is determined whether the number of target MCUs corresponding to multiple initial decoded segments meets the preset number condition. If not, it means that the number of target MCUs corresponding to multiple initial decoded segments is different from the number of target MCUs corresponding to the original target JPEG data. It is determined that an abnormality occurs in the decoding process, and the target JPEG data is obtained again, and another segment length is determined based on the preset segment length. The specific execution method is similar to step 501 and will not be repeated here.
[0124] Step 602, judging whether the multiple further initially decoded segments are all decoded correctly according to the target JPEG data and the further segment length, and judging whether the target MCU quantity corresponding to the multiple further initially decoded segments meets the preset quantity condition if they are decoded correctly.
[0125] In this embodiment, when judging whether multiple and further initially decoded segments are all decoded correctly according to the target JPEG data and another segment length, it can be specifically as follows: the target JPEG data is marked based on another segment length in units of target MCUs to obtain another JPEG segment data, so that the target GPU performs initial Huffman decoding on the another JPEG segment data to obtain multiple and further initially decoded segments and another synchronization parameter information. And based on the another synchronization parameter information, it is judged whether multiple and further initially decoded segments are all decoded correctly, and if correct, it is judged whether the number of target MCUs corresponding to the multiple and further initially decoded segments meets the preset number condition. The specific execution method is similar to steps 201-203, and will not be repeated here one by one.
[0126] Step 603: If not, the above acquisition and determination steps are executed repeatedly until it is determined that the preset quantity condition is met.
[0127] In this embodiment, if not, the target JPEG data is acquired again and extended based on another segment length, so that the above acquisition and determination steps are executed cyclically until it is determined that the preset quantity condition is met.
[0128] It can be understood that, if yes, a target decoding instruction is sent to the target GPU to instruct the target GPU to perform target Huffman decoding, and decode each target DCU included in each further target decoded segment to obtain target JPEG decoded data, thereby obtaining an RGB image corresponding to the target JPEG decoded data. The specific execution method is similar to steps 203-204, and will not be repeated here.
[0129] The JPEG data decoding method provided in the present embodiment determines whether the target MCU quantity corresponding to multiple initial decoded segments meets the preset quantity condition, or determines whether the target MCU quantity corresponding to multiple next initial decoded segments meets the preset quantity condition. If not, the target JPEG data is acquired again, and another segment length is determined based on the preset segment length; based on the target JPEG data and the another segment length, it is determined whether multiple further initial decoded segments are all decoded correctly, and if correct, it is determined whether the target MCU quantity corresponding to the multiple further initial decoded segments meets the preset quantity condition; if not, the above acquisition and judgment steps are executed repeatedly until it is determined that the preset quantity condition is met. Since there may be abnormalities in the decoding process when the preset quantity condition is not met, when it is determined that it is not met, by acquiring the target JPEG data again and determining another segment length based on the preset segment length, it is possible to determine whether multiple initial decoded segments are all decoded correctly based on the target JPEG data and the another segment length. Therefore, when it is determined to be correct, it is possible to determine whether the target MCU quantity corresponding to the multiple initial decoded segments meets the preset quantity condition. If it is still not met, by cyclically executing the acquisition and judgment steps, the result that finally meets the preset quantity condition can be obtained, thereby further improving the accuracy of decoding.
[0130] Figure 4 A schematic diagram of the structure of a JPEG data decoding device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the JPEG data decoding device provided in this embodiment is located in the target central processing unit CPU in the target decoding device. Then the JPEG data decoding device 70 provided in this embodiment includes: an acquisition module 71, a marking module 72, a storage module 73, a judgment module 74, a sending module 75, and a decoding module 76.
[0131] Among them, the acquisition module 71 is used to acquire the target JPEG data; the marking module 72 is used to mark the target JPEG data based on the preset segment length in the target MCU unit to obtain the target JPEG segment data; there is an overlapping part between the adjacent marked segment data in the target JPEG segment data; wherein the target MCU includes multiple target DCUs; the storage module 73 is used to store the target JPEG segment data in the target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segment data to obtain multiple initial decoded segments and synchronization parameter information; when the multiple initial decoded segments are decoded correctly, there are overlapping parts between the adjacent initial decoded segments; the judgment module 74 is used to respond to the decoding based on the multiple initial decoded segments. The coding result determines that multiple initial decoded segments are decoded correctly, and determines whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset number condition; the sending module 75 is used to send a target decoding instruction to the target GPU if so, so that the target GPU performs target Huffman decoding on the multiple initial decoded segments according to the target decoding instruction to obtain multiple target decoded segments; the decoding module 76 is used to decode each target DCU included in each target decoded segment to obtain target JPEG decoded data; the storage module 73 is also used to store the target JPEG decoded data to the target SVM, so that the target GPU performs multiple preset post-processing on the target JPEG decoded data in sequence to obtain the RGB image corresponding to the target JPEG decoded data.
[0132] The JPEG data decoding device provided in this embodiment can be executed Figure 2 The specific implementation principles and technical effects of the method embodiments shown are similar and will not be repeated here.
[0133] Optionally, the preset quantity condition is a condition that the number of target MCUs corresponding to the plurality of initial decoded segments is equal to the number of target MCUs corresponding to the target JPEG data;
[0134] Accordingly, when judging whether the number of target MCUs corresponding to the plurality of initial decoded segments meets the preset number condition, the judging module 74 is specifically configured to:
[0135] Obtain the target MCU numbers corresponding to the multiple initial decoded segments and the target MCU number corresponding to the target JPEG data, and determine whether the target MCU number corresponding to the multiple initial decoded segments is equal to the target MCU number corresponding to the target JPEG data.
[0136] Optionally, the decoding module 76, when decoding each target DCU included in each target decoded segment, is specifically configured to:
[0137] Obtain a DC coefficient corresponding to each target DCU; decode each target DCU based on the DC coefficient corresponding to each target DCU to obtain target JPEG decoded data.
[0138] Optionally, the synchronization parameter information includes a plurality of initial decoded segment identifiers and a target MCU starting position corresponding to each initial decoded segment;
[0139] Correspondingly, the JPEG data decoding device provided by this embodiment further includes: a determination module.
[0140] Among them, the acquisition module 71 is also used to obtain the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment according to the synchronization parameter information after obtaining multiple initial decoded segments and synchronization parameter information; the judgment module 74 is also used to judge whether the second initial decoded segment overlaps with the first initial decoded segment according to the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment; the determination module is used to determine whether the second initial decoded segment is decoded correctly if so, and judge whether multiple initial decoded segments are all decoded correctly in turn according to the above-mentioned acquisition and judgment steps.
[0141] Optionally, the JPEG data decoding device provided by this embodiment further includes: an indication module.
[0142] Among them, the acquisition module 71 is also used to obtain the target JPEG data again in response to determining that there is a decoding error in at least one of the initial decoded segments after the judgment module 74 determines whether the multiple initial decoded segments are all decoded correctly. The determination module is also used to determine the next segment length based on the preset segment length; the next segment length is longer than the preset segment length; the marking module 72 is also used to mark the target JPEG data based on the next segment length in units of the target MCU to obtain the next JPEG segment data, so that the target GPU performs initial Huffman decoding on the next JPEG segment data to obtain multiple next initial decoded segments. The code segmentation and the next synchronization parameter information; the indication module is used to judge whether the number of target MCUs corresponding to the multiple next initial decoded segments meets the preset number condition in response to determining that the multiple next initial decoded segments are decoded correctly, and if so, instruct the target GPU to perform target Huffman decoding. The decoding module 76 is also used to decode each target DCU included in each next target decoded segment to obtain the corresponding RGB image; the acquisition module 71 is also used to execute the acquisition of target JPEG data and subsequent steps again in response to determining that there is a decoding error in at least one next initial decoded segment until all are decoded correctly.
[0143] Optionally, the judgment module 74 is further configured to, after obtaining multiple next initial decoded segments and next synchronization parameter information, determine whether multiple next initial decoded segments are all decoded correctly based on the multiple next initial decoded segments and the next synchronization parameter information.
[0144] Optionally, the acquisition module 71 is also used to acquire the target JPEG data again after the judgment module 74 judges whether the target number of MCUs corresponding to multiple initial decoded segments meets the preset number condition, or judges whether the target number of MCUs corresponding to multiple next initial decoded segments meets the preset number condition; the determination module is also used to determine another segment length based on the preset segment length; the judgment module 74 is also used to judge whether multiple initial decoded segments are all decoded correctly based on the target JPEG data and another segment length, and if correct, judge whether the target number of MCUs corresponding to multiple initial decoded segments meets the preset number condition; if not, the above-mentioned acquisition and judgment steps are executed in a loop until it is determined that the preset number condition is met.
[0145] The JPEG data decoding device provided in this embodiment can execute any one of the above method embodiments. The specific implementation principles and technical effects are similar and will not be repeated here.
[0146] Figure 5 A schematic diagram of the structure of a target decoding device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the target decoding device 80 provided in this embodiment includes: a target CPU 81, a memory 82 communicatively connected to the target CPU 81, and a target GPU 83.
[0147] The memory 82 stores computer-executable instructions; the target GPU 83 is used to perform Huffman decoding on multiple segments to be decoded, and to perform multiple preset post-processing on the target JPEG decoded data in sequence; the target CPU 81 executes the computer-executable instructions stored in the memory 82 to implement the JPEG data decoding method provided by any of the above embodiments. The relevant description can be understood by referring to the relevant descriptions and effects corresponding to the steps in the accompanying drawings, and no further details will be given here.
[0148] The program may include program code, and the program code includes computer-executable instructions. The memory 82 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.
[0149] In this embodiment, the target CPU 81, the memory 82 and the target GPU 83 are connected via a bus. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0150] The embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the JPEG data decoding method provided in any of the above embodiments. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.
[0151] An embodiment of the present application also provides a computer program product, including a computer program, which implements the JPEG data decoding method provided in any one of the above embodiments when executed by a processor.
[0152] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0153] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0154] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0155] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0156] If the integrated unit / module is implemented in the form of hardware, the hardware can be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the artificial intelligence processor can be any appropriate hardware processor, such as CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any appropriate magnetic storage medium or magneto-optical storage medium, such as resistive random access memory RRAM (Resistive Random Access Memory), dynamic random access memory DRAM (Dynamic Random Access Memory), static random access memory SRAM (Static Random-Access Memory), enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), high-bandwidth memory HBM (High-Bandwidth Memory), hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0157] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present application. The aforementioned memory includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a disk or an optical disk, and other media that can store program codes. In the above embodiments, the description of each embodiment has its own emphasis. For the part that is not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, 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, they should be considered to be within the scope of this specification.
[0158] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0159] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A JPEG data decoding method, characterized in that: The method is applied to a target central processing unit (CPU) in a target decoding device, wherein the target decoding device further comprises: a target graphics processing unit (GPU) and a target shared virtual memory (SVM). The method comprises: Acquire target JPEG data, and mark the target JPEG data based on a preset segment length in units of a target minimum coding unit MCU to obtain target JPEG segmented data; there are overlapping parts between adjacent marked segmented data in the target JPEG segmented data; wherein the target MCU includes a plurality of target discrete cosine transform units DCU; The target JPEG segment data is stored in the target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segment data to obtain a plurality of initial decoded segments and synchronization parameter information; when the plurality of initial decoded segments are decoded correctly, adjacent initial decoded segments have overlapping parts; In response to determining that the plurality of initial decoded segments are all decoded correctly based on the decoding results of the plurality of initial decoded segments, determining whether the number of target MCUs corresponding to the plurality of initial decoded segments meets a preset number condition, and if so, sending a target decoding instruction to a target GPU so that the target GPU performs target Huffman decoding on the plurality of initial decoded segments according to the target decoding instruction to obtain a plurality of target decoded segments; Decode each target DCU included in each target decoded segment to obtain target JPEG decoded data, and store the target JPEG decoded data in a target SVM, so that the target GPU sequentially performs multiple preset post-processing on the target JPEG decoded data to obtain an RGB image corresponding to the target JPEG decoded data.
2. The method according to claim 1, characterized in that The preset quantity condition is a condition that the number of target MCUs corresponding to the plurality of initial decoded segments is equal to the number of target MCUs corresponding to the target JPEG data; The determining whether the number of target MCUs corresponding to the plurality of initial decoded segments meets a preset number condition includes: Obtain the target MCU number corresponding to the multiple initial decoded segments and the target MCU number corresponding to the target JPEG data, and determine whether the target MCU number corresponding to the multiple initial decoded segments is equal to the target MCU number corresponding to the target JPEG data.
3. The method according to claim 1, characterized in that The decoding of each target DCU included in each target decoded segment includes: Obtain the DC coefficient corresponding to each target DCU; Each target DCU is decoded based on the DC coefficient corresponding to each target DCU to obtain target JPEG decoded data.
4. The method according to claim 1, characterized in that: The synchronization parameter information includes a plurality of initial decoded segment identifiers and a target MCU starting position corresponding to each initial decoded segment; After obtaining the plurality of initial decoded segments and synchronization parameter information, the method further includes: Acquire the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment according to the synchronization parameter information; Determine whether the second initial decoded segment overlaps with the first initial decoded segment according to the target MCU starting position corresponding to the first initial decoded segment and the target MCU starting position corresponding to the second initial decoded segment; If so, it is determined that the second initial decoded segment is decoded correctly, and according to the above-mentioned acquisition and judgment steps, it is determined in sequence whether multiple initial decoded segments are all decoded correctly.
5. The method according to claim 4, characterized in that After determining whether the multiple initially decoded segments are all decoded correctly, the method further includes: In response to determining that there is a decoding error in at least one initially decoded segment, acquiring the target JPEG data again, and determining a next segment length based on a preset segment length; the next segment length is longer than the preset segment length; Marking the target JPEG data based on the next segment length in units of target MCUs to obtain next JPEG segment data, so that the target GPU performs initial Huffman decoding on the next JPEG segment data to obtain multiple next initial decoded segments and next synchronization parameter information; In response to determining that the multiple next initial decoded segments are all decoded correctly, determining whether the number of target MCUs corresponding to the multiple next initial decoded segments meets a preset number condition, and if so, instructing the target GPU to perform target Huffman decoding, and decoding each target DCU included in each next target decoded segment to obtain a corresponding RGB image; In response to determining that there is a decoding error in at least one next initially decoded segment, obtaining target JPEG data and subsequent steps are performed again until all decoding is correct.
6. The method according to claim 5, characterized in that After obtaining the multiple next initial decoded segments and the next synchronization parameter information, the method further includes: Based on the multiple next initial decoded segments and the next synchronization parameter information, it is determined whether the multiple next initial decoded segments are all decoded correctly.
7. The method according to claim 1 or 5, characterized in that: After determining whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset number condition, or determining whether the number of target MCUs corresponding to the multiple next initial decoded segments meets the preset number condition, the method further includes: If not, the target JPEG data is acquired again, and another segment length is determined based on the preset segment length; Determine whether the multiple further initially decoded segments are all decoded correctly according to the target JPEG data and the further segment length, and if they are decoded correctly, determine whether the target MCU quantity corresponding to the multiple further initially decoded segments meets a preset quantity condition; If not, the above-mentioned acquisition and determination steps are executed repeatedly until it is determined that the preset quantity condition is met.
8. A JPEG data decoding device, characterized in that: include: Acquisition module, used to obtain target JPEG data; A marking module, used for marking the target JPEG data based on a preset segment length in units of target MCUs to obtain target JPEG segment data; There are overlapping parts between adjacent marked segmented data in the target JPEG segmented data; wherein the target MCU includes a plurality of target DCUs; A storage module is used to store the target JPEG segmented data into a target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segmented data to obtain a plurality of initial decoded segments and synchronization parameter information; when the plurality of initial decoded segments are decoded correctly, adjacent initial decoded segments have overlapping parts; A judging module, configured to judge whether the number of target MCUs corresponding to the plurality of initial decoded segments meets a preset number condition in response to determining that the plurality of initial decoded segments are all decoded correctly based on the decoding results of the plurality of initial decoded segments; a sending module, configured to send a target decoding instruction to a target GPU, so that the target GPU performs target Huffman decoding on the multiple initial decoded segments according to the target decoding instruction to obtain multiple target decoded segments; A decoding module, used for decoding each target DCU included in each target decoded segment to obtain target JPEG decoded data; The storage module is further used to store the target JPEG decoded data in the target SVM, so that the target GPU sequentially performs multiple preset post-processing on the target JPEG decoded data to obtain an RGB image corresponding to the target JPEG decoded data.
9. A target decoding device, characterized in that: include: A target CPU, a memory connected to the target CPU for communication, and a target GPU; The memory stores computer-executable instructions; the target GPU is used to perform Huffman decoding on multiple segments to be decoded, and to perform multiple preset post-processing on target JPEG decoded data in sequence; The target CPU executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Patent Citations
Black-and-white image jpeg data encoding method and device based on nvidia gpu
CN109688415A
GPU parallel huffman decoding
CN110832781A
JPEG (Joint Photographic Experts Group) coding acceleration implementation method and system based on CPU (Central Processing Unit) and GPU
CN117714710A
JPEG image sequence parallel decoding and rendering method
CN117834903A