Method, apparatus and storage medium for decoding JPEG data
By introducing a shared virtual memory (SVM) between the CPU and GPU, the GPU is used for initial Huffman decoding of JPEG data, and the number of MCUs is determined when the decoding is correct. This solves the problem of excessive CPU load and improves decoding efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, the CPU load is too heavy during JPEG data decoding, resulting in long decoding time and low efficiency.
By introducing a shared virtual memory (SVM) between the CPU and GPU, the GPU is used for initial Huffman decoding. When the decoding is successful, the number of MCUs is checked to see if the condition is met. If the condition is met, the GPU is instructed to perform the final Huffman decoding, thus reducing the CPU load.
It reduces the CPU's workload and improves the efficiency of JPEG data decoding.
Smart Images

Figure CN119788872B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and in particular to a JPEG data decoding method, apparatus, device, and storage medium. Background Technology
[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 ratio. It is necessary to decode the encoded JPEG data to obtain JPEG images for display.
[0003] Currently, JPEG data decoding is generally based on a heterogeneous computing system consisting of a CPU (Central Processing Unit) and a GPU (Graphics Processing Unit). Specifically, the CPU is responsible for the Huffman decoding process, while the GPU is responsible for other processes, such as inverse quantization, inverse discrete cosine transform, upsampling, and color space conversion, to obtain the JPEG image.
[0004] However, this method, in which the CPU is solely responsible for the Huffman decoding process, requires a significant amount of CPU resources, increases the CPU load, and results in longer decoding times and lower decoding efficiency. Summary of the Invention
[0005] This application provides a JPEG data decoding method, apparatus, device, and storage medium to solve the technical problems in the prior art that require a lot of CPU resources, increase CPU load, and result in long decoding time and low decoding efficiency.
[0006] In a first aspect, this application provides a JPEG data decoding method, the method being 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 using a target minimum coding unit (MCU) as the unit, to obtain target JPEG segmented data; wherein there is an overlap between adjacent marked segmented data in the target JPEG segmented data; wherein the target MCU includes multiple target discrete cosine transform units (DCUs);
[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 multiple initially decoded segments and synchronization parameter information; when the multiple initially decoded segments are decoded correctly, adjacent initially decoded segments have overlapping parts;
[0008] In response to determining that all of the initial decoded segments are correctly decoded 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 quantity 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.
[0009] Each target DCU included in the decoded segment of each target 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 a variety of preset post-processing on the target JPEG decoded data in sequence to obtain the RGB image corresponding to the target JPEG decoded data.
[0010] In one possible design, the preset quantity condition is that the number of target MCUs corresponding to multiple initially decoded segments is equal to the number of target MCUs corresponding to the target JPEG data; the step of determining whether the number of target MCUs corresponding to the multiple initially decoded segments meets the preset quantity condition includes: obtaining the number of target MCUs corresponding to the multiple initially decoded segments and the number of target MCUs corresponding to the target JPEG data, and determining whether the number of target MCUs corresponding to the multiple initially decoded segments is equal to the number of target MCUs corresponding to the target JPEG data.
[0011] In one possible design, the decoding of each target DCU included in each target decoded segment comprises: obtaining the DC coefficient corresponding to each target DCU; and 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 start position corresponding to each initial decoded segment; after obtaining the multiple initial decoded segments and the synchronization parameter information, the method further includes: obtaining the target MCU start position corresponding to the first initial decoded segment and the target MCU start position corresponding to the second initial decoded segment based on the synchronization parameter information; determining whether the second initial decoded segment overlaps with the first initial decoded segment based on the target MCU start position corresponding to the first initial decoded segment and the target MCU start position corresponding to the second initial decoded segment; if so, determining that the second initial decoded segment is correctly decoded, and sequentially determining whether multiple initial decoded segments are all correctly decoded according to the above acquisition and determination steps.
[0013] In one possible design, after determining whether multiple initially decoded segments are all correctly decoded, the method further includes: in response to determining that at least one initially decoded segment has a decoding error, 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 next JPEG segment data, so that the target GPU performs initial Huffman decoding on the next JPEG segment data to obtain multiple next initially decoded segments and next synchronization parameter information; in response to determining that all multiple next initially decoded segments are correctly decoded, determining whether the number of target MCUs corresponding to the multiple next initially decoded segments meets a preset quantity condition; 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 the corresponding RGB image; in response to determining that at least one next initially decoded segment has a decoding error, re-executing the acquisition of target JPEG data and subsequent steps until all segments are correctly decoded.
[0014] In one possible design, after obtaining multiple next initial decoded segments and next synchronization parameter information, the method further includes: determining whether all multiple next initial decoded segments are correctly decoded based on the multiple next initial decoded segments and next synchronization parameter information.
[0015] In one possible design, after determining whether the number of target MCUs corresponding to the plurality of initially decoded segments meets a preset quantity condition, or whether the number of target MCUs corresponding to the plurality of next initially decoded segments meets a preset quantity condition, the method further includes: if not, acquiring the target JPEG data again and determining another segment length based on the preset segment length; determining whether the plurality of subsequent initially decoded segments are all correctly decoded based on the target JPEG data and the subsequent segment length, and if correct, determining whether the number of target MCUs corresponding to the plurality of subsequent initially decoded segments meets a preset quantity condition; if not, repeating the above acquisition and determination steps until it is determined that the preset quantity condition is met.
[0016] Secondly, this application provides a JPEG data decoding apparatus, including: an acquisition module for acquiring target JPEG data;
[0017] The marking module is used to mark the target JPEG data based on a preset segment length, with the target MCU as the unit, to obtain target JPEG segment data; there is an overlap between adjacent marked segments in the target JPEG segment data; wherein, the target MCU includes multiple target DCUs;
[0018] The storage module is used to store the target JPEG segment data into the target SVM, so that the target GPU performs initial Huffman decoding on the target JPEG segment data to obtain multiple initially decoded segments and synchronization parameter information; when the multiple initially decoded segments are decoded correctly, adjacent initially decoded segments have overlapping parts;
[0019] The judgment module is used to determine whether the number of target MCUs corresponding to the multiple initially decoded segments meets a preset quantity condition in response to determining that all the multiple initially decoded segments are correctly decoded based on the decoding results of the multiple initially decoded segments.
[0020] The sending module is configured to send a target decoding instruction to the target GPU if the condition is met, so that the target GPU performs target Huffman decoding on the plurality of initially decoded segments according to the target decoding instruction to obtain a plurality of target decoded segments;
[0021] The decoding module is used to decode each target DCU included in the decoded segment of each target to obtain the target JPEG decoded data;
[0022] The storage module is further configured to store the target JPEG decoded data in the target SVM, so that the target GPU can sequentially perform various preset post-processing on the target JPEG decoded data to obtain the RGB image corresponding to the target JPEG decoded data.
[0023] Thirdly, this application provides a target decoding device, including: a target CPU, a memory communicatively connected to the target CPU, and a target GPU;
[0024] The memory stores computer-executed instructions; the target GPU is used to perform Huffman decoding on multiple segments to be decoded, and to perform various preset post-processing on the target JPEG decoded data in sequence.
[0025] The target CPU executes computer execution instructions stored in the memory to implement the method as described in the first aspect.
[0026] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the first aspect.
[0027] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.
[0028] The JPEG data decoding method, apparatus, device, and storage medium provided in this application are applied to a target central processing unit (CPU) in a target decoding device. The target decoding device further 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, using a target minimum coding unit (MCU) as the unit, to obtain target JPEG segment data; overlapping portions exist between adjacent marked segments in the target JPEG segment data; wherein the target MCU includes multiple target discrete cosine transform units (DCUs); 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 initially decoded segments and synchronization parameter information; multiple When the initial decoded segments are decoded correctly, adjacent initial decoded segments overlap. In response to determining that all initial decoded segments are correctly decoded based on their decoding results, it is determined whether the number of target MCUs corresponding to the multiple initial decoded segments meets a preset quantity condition. If so, a target decoding instruction is sent to the target GPU, causing the target GPU to perform target Huffman decoding on the multiple initial decoded segments according to the target decoding instruction, resulting in multiple target decoded segments. Each target DCU included in each target decoded segment is decoded to obtain target JPEG decoded data, which is then stored in the target SVM. The target GPU then performs various preset post-processing steps on the target JPEG decoded data to obtain the RGB image corresponding to the target JPEG decoded data. Since the target CPU, target GPU, and target SVM are pre-set in the target decoding device, the target CPU can mark the target JPEG data as target JPEG segment data based on a preset segment length by acquiring 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 initially decoded segments and synchronization parameter information that have overlapping parts when the decoding is correct.By determining that multiple initially decoded segments overlap based on synchronization parameter information, it can be confirmed that all initially decoded segments are correctly decoded. Furthermore, it can be determined whether the number of target MCUs corresponding to these segments meets a certain condition. If the condition is met, the target GPU is instructed to perform final target Huffman decoding on these segments. Finally, by acquiring these multiple target decoded segments, all target DCUs included in these segments can be decoded to obtain target JPEG decoded data. This data can be stored in the target SVM, allowing the target GPU to obtain the target JPEG decoded data based on the target SVM and perform various preset post-processing steps to obtain the corresponding RGB image. This enables the GPU to handle the Huffman decoding process, reducing the CPU's workload and improving decoding efficiency. Attached Figure Description
[0029] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0030] Figure 1 This is an application scenario diagram of a JPEG data decoding method provided in one embodiment of this application;
[0031] Figure 2 A flowchart illustrating a JPEG data decoding method provided in an embodiment of this application;
[0032] Figure 3 A flowchart of a JPEG data decoding method provided in another embodiment of this application;
[0033] Figure 4 This is a schematic diagram of the structure of a JPEG data decoding device provided in an embodiment of this application;
[0034] Figure 5 This is a schematic diagram of the structure of a target decoding device provided in an embodiment of this application.
[0035] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0036] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0037] It should be noted that the JPEG data decoding method, apparatus, device, and storage medium of this application can be used in the field of image processing, or in any field other than image processing. The application field of the JPEG data decoding method, apparatus, device, and storage medium of this application is not limited.
[0038] First, the English abbreviations used in this application will be explained:
[0039] CPU: Central Processing Unit, is the core component of a computer responsible for executing program instructions and processing data.
[0040] GPU: Graphics Processing Unit, is a coprocessor specifically designed for processing images and graphics operations, typically used to accelerate graphics rendering and parallel computing tasks.
[0041] SVM stands for Shared Virtual Memory, which allows the GPU and CPU to share memory space in GPU scenarios for more efficient data exchange and processing.
[0042] JPEG stands for 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 stands for Minimum Coded Unit. In JPEG, it refers to the smallest group of data units that are used for interval coding, usually corresponding to one or more 8x8 pixel blocks.
[0044] DCU stands for Discrete Cosine Transform Unit. In JPEG image compression, the image is divided into multiple 8x8 pixel blocks, and each block undergoes a discrete cosine transform individually, converting spatial domain data into frequency domain data. Each 8x8 pixel block can be considered as a DCU.
[0045] To clearly understand the technical solution of this application, the solutions of the prior art will be described in detail first.
[0046] Currently, JPEG data decoding is generally performed using a heterogeneous computing system that includes both CPUs and GPUs. Specifically, based on the entire JPEG decoding process—Huffman decoding, inverse quantization, inverse discrete cosine transform (ICT), upsampling, and color space conversion—the CPU is typically responsible for Huffman decoding, while the GPU handles inverse quantization, ICT, upsampling, and color space conversion. In this process, the CPU acquires the JPEG data and decodes it using a pre-stored decoding strategy. The decoded JPEG data is then sent to the GPU, which sequentially performs inverse quantization, ICT, upsampling, and color space conversion to obtain the final JPEG image. This approach, where the CPU handles all Huffman decoding, consumes significant CPU resources, increases CPU load, and results in longer decoding times and lower decoding efficiency.
[0047] Therefore, when facing technical problems in existing technologies, in order to reduce CPU load and improve decoding efficiency, instead of having the CPU solely responsible for Huffman decoding, the JPEG data is marked to obtain JPEG segment data with multiple segment markers and overlapping parts between the segment markers. The GPU then performs parallel decoding based on the JPEG segment data to share the Huffman decoding workload. So, when decoding JPEG data, the CPU first acquires the JPEG data and marks it, obtaining JPEG segment data with multiple segment markers and overlapping parts between the segment markers. The GPU then performs the first parallel decoding of the JPEG segment data. Next, the CPU determines whether the JPEG segment data has been successfully decoded. If so, the CPU instructs the GPU to perform a second parallel decoding of the JPEG segment data after the first parallel decoding. Finally, the CPU decodes the DCU based on the result of the second parallel decoding, and the GPU sequentially performs inverse quantization, inverse discrete cosine transform, upsampling, and color space conversion on the decoded JPEG data to finally obtain the JPEG image. This allows the GPU to handle the Huffman decoding process, eliminating the need for the CPU to be fully responsible, thus reducing CPU resources, lowering CPU load, and improving decoding efficiency.
[0048] Figure 1 This is an application scenario diagram of a JPEG data decoding method provided in one embodiment of this application, such as... Figure 1As shown, the system corresponding to the JPEG data decoding method in this embodiment may include: a target decoding device 1, a target CPU 2, a target GPU 3, and a target SVM 4. 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. The target CPU 2, target GPU 3, and target SVM 4 are located within the target decoding device 1. The target CPU 2, target GPU 3, and target SVM 4 are communicatively connected. First, the user selects the JPEG data to be decoded based on the operation interface corresponding to the target decoding device 1 and triggers the decoding operation. The target CPU 2, in response to the triggered decoding operation, acquires the target JPEG data and marks the target JPEG data based on a preset segment length, using the target MCU as the unit, to obtain target JPEG segmented data. There is overlap between adjacent marked segments in the target JPEG segmented data. The target MCU includes multiple target DCUs. The target JPEG segment data is then stored in the target SVM4, enabling the target GPU3 to perform initial Huffman decoding on the target JPEG segment data, obtaining multiple initially decoded segments and synchronization parameter information. When the multiple initially decoded segments are correctly decoded, adjacent initially decoded segments overlap. Finally, in response to determining that all multiple decoded segments are correctly decoded, it is checked whether the number of target MCUs corresponding to the multiple initially decoded segments meets a preset quantity condition. If so, a target decoding command is sent to the target GPU3, enabling the target GPU3 to perform target Huffman decoding on the multiple initially decoded segments according to the command, obtaining multiple target decoded segments. Finally, each target DCU included in each target decoded segment is decoded to obtain target JPEG decoded data, which is then stored in the target SVM. The target GPU then sequentially performs various preset post-processing on the target JPEG decoded data to obtain the RGB image corresponding to the target JPEG decoded data.
[0049] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0050] Figure 2 A flowchart of a JPEG data decoding method provided in an embodiment of this application is shown below. Figure 2As shown, the execution entity in this embodiment is a JPEG data decoding device. This JPEG data decoding device is located in the target CPU of the target decoding device. The target decoding device also includes a target GPU and a target SVM. Therefore, 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, using the target MCU as the unit, to obtain target JPEG segment data; there is an overlap between adjacent marked segments in the target JPEG segment data; wherein, the target MCU includes multiple target DCUs.
[0052] The target JPEG data is JPEG data that requires decoding.
[0053] The preset segment length is the length required to segment the target JPEG data.
[0054] The target MCU is the basic data unit that constitutes the target JPEG data, and it can be composed of multiple target DCUs. Each target DCU is an encoding unit, which can be composed of an 8x8 pixel matrix.
[0055] Among them, the target JPEG segmented data is the target JPEG data with segmentation tags.
[0056] Understandably, since the target JPEG data is a continuous string and adjacent data have a strong correlation, when marking the target JPEG data, it is necessary to segment and mark 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 pre-select the target JPEG data to be decoded based on the operation interface corresponding to the target decoding device, and trigger the decoding component based on the selection result. Then, the target CPU in the target decoding device responds to the triggering of the decoding component, obtains the selected target JPEG data, and obtains the preset segment length. The target JPEG data is marked using the preset segment length, thereby obtaining target JPEG segment data in units of the target MCU.
[0058] Step 202: Store the target JPEG segment data in the target SVM so that the target GPU can perform 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 involves performing initial decoding on the data obtained through Huffman coding. Huffman coding is a coding method for encoding JPEG images based on a Huffman tree.
[0060] The initially decoded segments are those obtained after decoding the target JPEG segment data.
[0061] It is understandable that, since there is overlapping data between the segment markers, after decoding the target JPEG segment data, 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 segment data at the target MCU level, the target JPEG segment data is stored in the target SVM. Based on this, the target GPU obtains the target JPEG segment data through the target SVM and allocates the target JPEG segment data to multiple threads according to the segment identifier. Then, the target JPEG segment data is processed in parallel by multiple threads, and multiple initially decoded segments and synchronization parameter information are output based on the calculation results. Finally, the multiple initially decoded segments and synchronization parameter information are stored in the target SVM, so that the target CPU can obtain multiple initially decoded segments and synchronization parameter information based on the target SVM.
[0063] Step 203: In response to the determination that all initial decoded segments are correctly decoded based on the decoding results of multiple initial decoded segments, determine whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset quantity condition. If so, send a target decoding instruction 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 that instructs the target GPU to perform target Huffman decoding.
[0065] Among them, target Huffman decoding is the decoding process of decoding the target MCU into the target DCU.
[0066] The target decoded segment is the segment obtained by decoding the initial decoded segment based on the target Huffman decoding.
[0067] In this embodiment, after obtaining multiple initially decoded segments, based on the feature mentioned in the previous step: if the decoding is error-free, the corresponding initially decoded segments should also have overlapping data, the decoding results of multiple initially decoded segments are obtained, and based on the decoding results of multiple initially decoded segments, it is determined whether multiple initially decoded segments are all decoded correctly.
[0068] Based on this, in response to the determination that multiple initially decoded segments are all correctly decoded, based on all target MCUs in each initially decoded segment, it is further determined whether the number of target MCUs corresponding to the multiple initially decoded segments meets the preset quantity 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 multiple initially decoded segments according to the instruction, and obtains 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 in the target SVM so that the target GPU can sequentially perform various preset post-processing on the target JPEG decoded data to obtain the RGB image corresponding to the target JPEG decoded data.
[0071] Among them, the target JPEG decoded data is the target JPEG data that has been successfully decoded.
[0072] The preset post-processing refers to the post-processing required to convert the target JPEG decoded data into the corresponding RGB image. Specifically, the preset post-processing 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 can obtain the target JPEG decoded data through the target SVM, and perform inverse quantization, inverse discrete cosine transform, upsampling and color space conversion on the target JPEG decoded data in sequence to obtain the RGB image corresponding to the target JPEG decoded data.
[0074] It's understandable that if the encoding process for the target JPEG data involves first converting the RGB image format to YUV image format, and then compressing the YUV image format using the Huffman coding algorithm to obtain the target JPEG data, then during the pre-processing of the decoded target JPEG data, to improve processing efficiency, the upsampling process can be removed. After completing the inverse discrete cosine transform, a color space conversion can be performed directly, converting the YUV image format to RGB image format, thus obtaining the corresponding RGB image. The RGB image format is an additive color model that represents various colors by combining different intensities of the three basic colors: red (R), green (G), and blue (B). The YUV image format divides color information into luminance (Y) and chrominance (U and V) components, utilizing the human eye's greater sensitivity to luminance to allow for more efficient compression.
[0075] It should be noted that this embodiment can be implemented based on OpenCL (Open Computing Language), specifically OpenCL 2.0. OpenCL is a working standard for writing programs on heterogeneous parallel computing platforms and can be used with CPUs, GPUs, or other computing devices.
[0076] The JPEG data decoding method provided in this embodiment acquires target JPEG data and marks the target JPEG data based on a preset segment length, using the target MCU as a unit, to obtain target JPEG segment data; there is overlap between adjacent marked segments in the target JPEG segment data; the target MCU includes multiple target DCUs; 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 multiple initially decoded segments and synchronization parameter information; when the multiple initially decoded segments are decoded correctly, adjacent initially decoded segments have overlapping parts; in response to multiple initially decoded segments... The decoding results confirm that multiple initially decoded segments are correctly decoded. It then checks if the number of target MCUs corresponding to these segments meets a preset condition. If so, a target decoding command is sent to the target GPU, enabling it to perform target Huffman decoding on the segments, resulting in multiple target decoded segments. Each target DCU within each segment is then decoded to obtain target JPEG decoded data, which is stored in the target SVM. The target GPU then performs various preset post-processing steps on this data to obtain the corresponding RGB image. Since the target CPU, GPU, and SVM are pre-configured in the target decoding device, the target CPU can mark the target JPEG data as target JPEG segments based on a preset segment length. By storing these segments in the SVM, the target GPU can obtain the segmented data and perform initial Huffman decoding, resulting in multiple initially decoded segments with overlapping parts and synchronization parameter information when correctly decoded. By determining that multiple initially decoded segments overlap based on synchronization parameter information, it can be confirmed that all initially decoded segments are correctly decoded. Furthermore, it can be determined whether the number of target MCUs corresponding to these segments meets a certain condition. If the condition is met, the target GPU is instructed to perform final target Huffman decoding on these segments. Finally, by acquiring these multiple target decoded segments, all target DCUs included in these segments can be decoded to obtain target JPEG decoded data. This data can be stored in the target SVM, allowing the target GPU to obtain the target JPEG decoded data based on the target SVM and perform various preset post-processing steps to obtain the corresponding RGB image. This enables the GPU to handle the Huffman decoding process, reducing the CPU's workload and improving decoding efficiency.
[0077] As an optional embodiment, this embodiment, based on the above embodiment, presets the quantity condition as the condition that the number of target MCUs corresponding to multiple initially decoded segments is equal to the number of target MCUs corresponding to the target JPEG data. When determining whether the number of target MCUs corresponding to multiple initially decoded segments meets the preset quantity condition, the following steps are specifically included:
[0078] Obtain the number of target MCUs corresponding to multiple initially decoded segments and the number of target MCUs corresponding to the target JPEG data, and determine whether the number of target MCUs corresponding to multiple initially decoded segments is equal to the number of target MCUs corresponding to the target JPEG data.
[0079] It is understandable that if all target JPEG data is 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 initially decoded segments.
[0080] Based on this, the number of target MCUs corresponding to multiple initially decoded segments and the number of target MCUs corresponding to target JPEG data are obtained, and the two numbers are compared to determine whether the number of target MCUs corresponding to multiple initially decoded segments and the number of target MCUs corresponding to target JPEG data are equal, thereby determining whether the number of target MCUs corresponding to multiple initially decoded segments meets the preset number condition.
[0081] The JPEG data decoding method provided in this embodiment has a preset quantity condition: the number of target MCUs corresponding to multiple initially decoded segments is equal to the number of target MCUs corresponding to the target JPEG data. When determining whether the number of target MCUs corresponding to multiple initially decoded segments meets the preset quantity condition, the method acquires both the number of target MCUs corresponding to the multiple initially decoded segments and the number of target MCUs corresponding to the target JPEG data, and then determines whether the number of target MCUs corresponding to the multiple initially decoded segments is equal to the number of target MCUs corresponding to the target JPEG data. Since the number of MCUs is consistent before and after decoding, by acquiring both the number of target MCUs corresponding to the multiple initially decoded segments and the number of target MCUs corresponding to the target JPEG data, a judgment can be made based on these two quantities to determine whether they are consistent, thereby determining whether the preset quantity condition is met, improving judgment efficiency, and further improving decoding accuracy.
[0082] Figure 3 A flowchart of a JPEG data decoding method provided in another embodiment of this application is shown below. Figure 3 As shown, this embodiment, based on the above embodiment, further refines the decoding of each target DCU included in each target decoded segment. Therefore, this embodiment specifically includes the following steps when decoding each target DCU included in each target decoded segment:
[0083] Step 301: Obtain the DC coefficient corresponding to each target DCU.
[0084] The DC coefficient corresponding to the target DCU is the first coefficient located in the upper left corner of the 8*8 matrix included in the target DCU.
[0085] It is understandable that during the encoding of the target JPEG data, differential encoding is performed on the DC coefficients corresponding to each target DCU based on the differences between each target DCU in the target JPEG data. Therefore, decoding each target DCU included in each decoded segment of the target is essentially decoding the DC coefficients corresponding to each target DCU.
[0086] Based on this, after confirming that all initially decoded segments are correctly decoded, 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 coefficients corresponding to each target DCU, the DC coefficients corresponding to the first target DCU are first decoded. Based on the above decoding result and the difference between the DC coefficients corresponding to the first target DCU and the DC coefficients corresponding to the second target DCU, the DC coefficients corresponding to the second target DCU are decoded. This process is repeated 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 coefficients corresponding to each target DCU when decoding each target DCU included in each target decoded segment; and decodes each target DCU based on the DC coefficients to obtain the target JPEG decoded data. Since decoding each target DCU is essentially decoding the DC coefficients corresponding to each target DCU, by obtaining the DC coefficients corresponding to each target DCU, the target DCU can be decoded based on the DC coefficients to obtain the target JPEG decoded data, further improving decoding efficiency.
[0090] As an optional embodiment, this embodiment is in Figure 2 Based on the corresponding embodiment, the synchronization parameter information includes multiple initial decoded segment identifiers and the target MCU start position corresponding to each initial decoded segment. After obtaining the multiple initial decoded segments and synchronization parameter information, the following steps are also included:
[0091] Step 401: Obtain the target MCU starting position corresponding to the first initially decoded segment and the target MCU starting position corresponding to the second initially decoded segment based on the synchronization parameter information.
[0092] The initial decoded segment identifier is an arbitrary identifier that represents the identity of the initial decoded segment.
[0093] The first initially decoded segment is the first segment among multiple initially decoded segments.
[0094] The second initially decoded segment is the second segment among multiple initially 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 the identifier of each initial decoded segment in the synchronization parameter information, the target MCU start position corresponding to the first initial decoded segment and the target MCU start position corresponding to the second initial decoded segment are obtained.
[0096] Step 402: Determine whether the second initially decoded segment overlaps with the first initially decoded segment based on the target MCU start position corresponding to the first initially decoded segment and the target MCU start position corresponding to the second initially decoded segment.
[0097] It is understandable that the starting position of the target MCU corresponding to the first initially decoded segment is always determined, so the first initially decoded segment is always correctly decoded.
[0098] Based on this, the starting position of the target MCU corresponding to the first initially decoded segment is compared with the starting position of the target MCU corresponding to the second initially decoded segment to determine whether there is a common starting position of the target MCU, thereby determining whether the second initially decoded segment overlaps with the first initially decoded segment.
[0099] Step 403: If yes, then determine that the second initial decoded segment is correctly decoded, and sequentially determine whether multiple initial decoded segments are all correctly decoded according to the above acquisition and judgment steps.
[0100] It is understandable that, since the first initially decoded segment and the second initially decoded segment will have overlapping calculation parts, if the starting position of the target MCU corresponding to the second initially decoded segment is the same as the starting position of the target MCU corresponding to the first initially decoded segment, then all subsequent target MCUs starting from this target MCU will be correct.
[0101] Based on this, if it is determined that there is a common target MCU starting position, it can be determined that the second initial decoded segment overlaps with the first initial decoded segment, and the second initial decoded segment is determined to be decoded correctly. Then, the acquisition and judgment steps described above are followed to determine whether multiple initial decoded segments are all decoded correctly.
[0102] Similarly, following the above acquisition and judgment steps, we sequentially determine whether all the initially decoded segments have been correctly decoded.
[0103] The JPEG data decoding method provided in this embodiment includes synchronization parameter information including multiple initial decoded segment identifiers and the target MCU start position corresponding to each initial decoded segment. After obtaining multiple initial decoded segments and synchronization parameter information, the target MCU start position corresponding to the first initial decoded segment and the target MCU start position corresponding to the second initial decoded segment are obtained according to the synchronization parameter information. Based on the target MCU start position corresponding to the first initial decoded segment and the target MCU start position corresponding to the second initial decoded segment, it is determined 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 the above acquisition and determination steps are followed sequentially to determine whether multiple initial decoded segments are all decoded correctly. Since the starting positions of the overlapping MCUs in each segment before and after decoding should be consistent if the decoding is correct, the starting positions of the target MCUs corresponding to the first and second initially decoded segments can be obtained based on the synchronization parameter information. This allows for the determination of whether the second initially decoded segment overlaps with the first initially decoded segment. If overlap is confirmed, the second initially decoded segment is determined to be correctly decoded. This process can then be repeated to sequentially determine whether multiple initially decoded segments are all correctly decoded. This allows for verification of the entire decoding process, improving verification accuracy and efficiency.
[0104] As an optional embodiment, this embodiment, based on the above embodiment, further includes the following steps after determining whether multiple initially decoded segments have been correctly decoded:
[0105] Step 501: In response to determining that there is at least one decoding error in the initially decoded segment, the target JPEG data is acquired again, and the next segment length is determined based on the preset segment length; the next segment length is longer than the preset segment length.
[0106] The next segment length is the length required to further divide the target JPEG data. The next segment length is longer than the preset segment length.
[0107] In this embodiment, based on whether all of the multiple initially decoded segments are decoded correctly, in response to determining that at least one initially decoded segment is decoded incorrectly, it is indicated that decoding under the current preset segment length is insufficient to ensure the correlation between the initially decoded segments.
[0108] Based on this, the target JPEG data is acquired again and extended based on the preset segment length. The extended preset segment length is then determined as the next segment length.
[0109] Step 502: Mark the target JPEG data based on the next segment length, taking the target MCU as the unit, to obtain the next JPEG segment data, so that the target GPU can perform 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 according to the next segment length, with the target MCU as the unit, to obtain the next JPEG segment data, so that the target GPU can perform 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 described again here.
[0111] Step 503: In response to determining that all of the next initial decoded segments are correctly decoded, determine whether the number of target MCUs corresponding to the multiple next initial decoded segments meets the preset quantity 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 the 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 correctly decoded. 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 correctly decoded, it is determined whether the number of target MCUs corresponding to multiple next decoded segments meets a preset quantity 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 at least one next initially decoded segment decoding error, the acquisition of target JPEG data and subsequent steps are performed again until all are decoded correctly.
[0114] In this embodiment, if at least one next initially decoded segment still has a decoding error, the acquisition of target JPEG data and subsequent steps are executed again until all are decoded correctly. The specific execution method is similar to steps 501-502, and will not be described in detail here.
[0115] The JPEG data decoding method provided in this embodiment, after determining whether multiple initially decoded segments are all correctly decoded, in response to determining that at least one initially decoded segment has a decoding error, acquires the target JPEG data again and determines the next segment length 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, with the target MCU as the unit, 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 initially decoded segments and next synchronization parameter information; in response to determining that multiple next initially decoded segments are all correctly decoded, it is determined whether the number of target MCUs corresponding to the multiple next initially decoded segments meets a preset number condition. 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 the corresponding RGB image; in response to determining that at least one next initially decoded segment has a decoding error, the acquisition of target JPEG data and subsequent steps are executed again until all are decoded correctly. Since a longer preset segment length can further ensure the correlation between each initially decoded segment, when an initial decoded segment decoding error is detected, the target JPEG data is acquired again, and the next segment length is determined based on the preset segment length. This means the target JPEG data can be marked based on the next segment length, using the target MCU as the unit. If multiple next initially decoded segments are determined to be correctly decoded, it can be further determined whether the number of target MCUs corresponding to these segments meets a preset condition. This instructs the target GPU to perform target Huffman decoding, obtaining multiple next target decoded segments. Each target DCU included in each next initially decoded segment is then decoded to obtain the corresponding RGB image. If multiple next initially decoded segments are still determined to be decoded incorrectly, the above steps are repeated until all segments are correctly decoded. This allows for rapid resolution of decoding errors, improves decoding accuracy, and further enhances decoding efficiency.
[0116] As an optional embodiment, this embodiment, based on the above embodiment, further includes the following steps after obtaining multiple next initial decoded segments and next synchronization parameter information:
[0117] Based on multiple next initial decoded segments and next synchronization parameter information, determine whether all multiple next initial decoded segments have been decoded correctly.
[0118] In this embodiment, based on the next synchronization parameter information, the starting position of the target MCU corresponding to the first next initially decoded segment and the starting position of the target MCU corresponding to the second next initially decoded segment are obtained. Based on these starting positions, it is determined whether the second next initially decoded segment overlaps with the first next initially decoded segment. If so, it is determined that the second next initially decoded segment is correctly decoded. Following the above acquisition and determination steps, it is then sequentially determined whether multiple next initially decoded segments are all correctly decoded. The specific execution method is similar to steps 401-403, and will not be described in detail here.
[0119] The JPEG data decoding method provided in this embodiment, after obtaining multiple next initially decoded segments and next synchronization parameter information, determines whether all multiple next initially decoded segments have been decoded correctly based on the information. Since it is necessary to verify the decoding accuracy of multiple next initially decoded segments, after obtaining these segments, determining whether all segments have been decoded correctly based on the information allows verification of the entire next decoding process, further improving the accuracy and efficiency of the verification.
[0120] As an optional embodiment, this embodiment is in Figure 2 Based on the corresponding embodiment or the previous embodiment described above, after determining whether the number of target MCUs corresponding to multiple initially decoded segments meets a preset quantity condition, or determining whether the number of target MCUs corresponding to multiple next initially decoded segments meets a preset quantity condition, the following steps are further included:
[0121] Step 601: If not, acquire the target JPEG data again and determine another segment length based on the preset segment length.
[0122] The additional segment length is the length required to further divide the target JPEG data. This additional segment length is longer than the preset segment length.
[0123] In this embodiment, based on whether the number of target MCUs corresponding to multiple initially decoded segments meets the preset number condition, if not, it means that the number of target MCUs corresponding to multiple initially decoded segments is different from the number of target MCUs corresponding to the original target JPEG data. Therefore, it is determined that an abnormality has occurred during the decoding process. Then, the target JPEG data is acquired 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: Based on the target JPEG data and the length of another segment, determine whether all the initial decoded segments have been correctly decoded, and if so, determine whether the number of target MCUs corresponding to the multiple initial decoded segments meets the preset quantity condition.
[0125] In this embodiment, when determining whether multiple initially decoded segments are correctly decoded based on the target JPEG data and the length of another segment, the specific steps are as follows: The target JPEG data is marked based on the length of another segment, using the target MCU as a unit, to obtain another JPEG segment data. The target GPU then performs initial Huffman decoding on this new JPEG segment data to obtain multiple initially decoded segments and another set of synchronization parameters. Based on the synchronization parameters, it is determined whether all multiple initially decoded segments are correctly decoded, and if correct, whether the number of target MCUs corresponding to the multiple initially decoded segments meets a preset quantity condition. The specific execution method is similar to steps 201-203, and will not be described in detail here.
[0126] Step 603: If not, repeat the above acquisition and judgment steps until 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, thereby repeatedly executing the above acquisition and judgment steps until the preset quantity condition is met.
[0128] Understandably, if so, a target decoding instruction is sent to the target GPU to instruct it to perform target Huffman decoding and decode each target DCU included in each previously decoded target segment to obtain the target JPEG decoded data, thereby obtaining the RGB image corresponding to the target JPEG decoded data. The specific execution method is similar to steps 203-204, and will not be described in detail here.
[0129] The JPEG data decoding method provided in this embodiment determines whether the number of target MCUs corresponding to multiple initially decoded segments meets a preset quantity condition, or whether the number of target MCUs corresponding to multiple next initially decoded segments meets a preset quantity condition. If not, the method acquires the target JPEG data again and determines another segment length based on the preset segment length. It then determines whether multiple subsequent initially decoded segments are correctly decoded based on the target JPEG data and the new segment length, and if correct, determines whether the number of target MCUs corresponding to the multiple subsequent initially decoded segments meets a preset quantity condition. If not, the method repeats the above acquisition and determination steps until the preset quantity condition is met. Since the decoding process may be abnormal if the preset quantity condition is not met, when it is determined that the condition is not met, the target JPEG data is acquired again and another segment length is determined based on the preset segment length. This allows us to determine whether multiple initially decoded segments are decoded correctly based on the target JPEG data and the new segment length. If the condition is correct, we can then determine whether the number of target MCUs corresponding to the multiple initially decoded segments meets the preset quantity condition. If the condition is still not met, the acquisition and judgment steps are repeated to obtain the final result that meets the preset quantity condition, thereby further improving the accuracy of decoding.
[0130] Figure 4 This is a schematic diagram of the structure of a JPEG data decoding device provided in an embodiment of this application, as shown below. Figure 4 As shown, the JPEG data decoding device provided in this embodiment is located in the target central processing unit (CPU) of the target decoding device. 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] The system includes: an acquisition module 71 for acquiring target JPEG data; a marking module 72 for marking the target JPEG data based on a preset segment length, using the target MCU as a unit, to obtain target JPEG segment data; overlapping portions exist between adjacent marked segments in the target JPEG segment data; the target MCU includes multiple target DCUs; a storage module 73 for storing the target JPEG segment data in the target SVM, enabling the target GPU to perform initial Huffman decoding on the target JPEG segment data, obtaining multiple initially decoded segments and synchronization parameter information; overlapping portions exist between adjacent initially decoded segments when decoding is correct; and a judgment module 74 for responding to the decoding based on the multiple initially decoded segments. The coding result confirms that multiple initially decoded segments are correctly decoded. It then determines whether the number of target MCUs corresponding to the multiple initially decoded segments meets a preset quantity condition. The sending module 75 is used to send a target decoding instruction to the target GPU if the condition is met, so that the target GPU performs target Huffman decoding on the multiple initially 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 in the target SVM, so that the target GPU performs various 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 perform... Figure 2 The implementation principles and technical effects of the methods shown are similar, and will not be repeated here.
[0133] Optionally, the preset quantity condition is that the number of target MCUs corresponding to multiple initially decoded segments is equal to the number of target MCUs corresponding to the target JPEG data;
[0134] Accordingly, the judgment module 74, when determining whether the number of target MCUs corresponding to multiple initially decoded segments meets the preset quantity condition, is specifically used for:
[0135] Obtain the number of target MCUs corresponding to multiple initially decoded segments and the number of target MCUs corresponding to the target JPEG data, and determine whether the number of target MCUs corresponding to multiple initially decoded segments is equal to the number of target MCUs 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 used for:
[0137] Obtain the DC coefficient corresponding to each target DCU; decode each target DCU based on the DC coefficient corresponding to each target DCU to obtain the target JPEG decoded data.
[0138] Optionally, the synchronization parameter information includes multiple initial decoded segment identifiers and the target MCU start position corresponding to each initial decoded segment;
[0139] Accordingly, the JPEG data decoding device provided in this embodiment also includes a determination module.
[0140] The acquisition module 71 is further configured to, after obtaining multiple initially decoded segments and synchronization parameter information, obtain the target MCU start position corresponding to the first initially decoded segment and the target MCU start position corresponding to the second initially decoded segment based on the synchronization parameter information; the judgment module 74 is further configured to, based on the target MCU start position corresponding to the first initially decoded segment and the target MCU start position corresponding to the second initially decoded segment, determine whether the second initially decoded segment overlaps with the first initially decoded segment; the determination module is configured to, if so, determine that the second initially decoded segment is correctly decoded, and sequentially determine whether multiple initially decoded segments are all correctly decoded according to the above acquisition and judgment steps.
[0141] Optionally, the JPEG data decoding device provided in this embodiment further includes an indicator module.
[0142] The acquisition module 71 is further configured to, after the judgment module 74 determines whether multiple initially decoded segments are all correctly decoded, acquire the target JPEG data again in response to determining that at least one initially decoded segment has a decoding error. The determination module is further configured to determine the next segment length based on a preset segment length; the next segment length is longer than the preset segment length. The marking module 72 is further configured to mark the target JPEG data based on the next segment length, on a target MCU basis, to obtain the next JPEG segment data, so that the target GPU can perform initial Huffman decoding on the next JPEG segment data to obtain multiple next initially decoded segments. The code segmentation and next synchronization parameter information; the indication module, in response to determining that multiple next initial decoded segments are all correctly decoded, determines whether the number of target MCUs corresponding to multiple next initial decoded segments meets a preset quantity condition. If so, it instructs 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 in response to determining that at least one next initial decoded segment has a decoding error, to re-execute the acquisition of target JPEG data and subsequent steps until all are decoded correctly.
[0143] Optionally, the judgment module 74 is also used to determine whether the multiple next initially decoded segments are all correctly decoded after obtaining the multiple next initially decoded segments and the next synchronization parameter information.
[0144] Optionally, the acquisition module 71 is further configured to acquire the target JPEG data again after the judgment module 74 determines whether the number of target MCUs corresponding to multiple initially decoded segments meets the preset quantity condition, or determines whether the number of target MCUs corresponding to multiple next initially decoded segments meets the preset quantity condition. The determination module is further configured to determine the length of another segment based on the preset segment length. The judgment module 74 is further configured to determine whether multiple subsequent initially decoded segments are all correctly decoded based on the target JPEG data and the length of another segment, and if correct, determine whether the number of target MCUs corresponding to multiple subsequent initially 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.
[0145] The JPEG data decoding device provided in this embodiment can execute any of the above method embodiments. The specific implementation principles and technical effects are similar, and will not be repeated here.
[0146] Figure 5 This is a schematic diagram of the structure of a target decoding device provided in an embodiment of this application, as shown below. 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 system includes a memory 82 that stores computer-executed instructions; a target GPU 83 that performs Huffman decoding on multiple segments to be decoded and sequentially performs various preset post-processing steps on the target JPEG decoded data; and a target CPU 81 that executes the computer-executed instructions stored in the memory 82 to implement the JPEG data decoding method provided in any of the above embodiments. Related explanations can be understood by referring to the descriptions and effects corresponding to the steps in the accompanying drawings, and will not be elaborated upon here.
[0148] The program may include program code, which includes computer-executable instructions. Memory 82 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device.
[0149] In this embodiment, the target CPU 81, memory 82, and target GPU 83 are connected via a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0150] This application also provides a computer-readable storage medium storing computer-executable instructions. When executed by a processor, these instructions are used to implement the JPEG data decoding method provided in any of the above embodiments. For example, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device.
[0151] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the JPEG data decoding method provided in any of the above embodiments.
[0152] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0153] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0154] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.
[0155] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.
[0156] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, an AI processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, storage units can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.
[0157] If an integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, 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. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk. In the above embodiments, the descriptions of each embodiment have different focuses; parts not described in detail in a certain embodiment can be referred to in the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0158] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0159] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method of decoding JPEG data, characterized by, 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), and the method comprises: acquiring target JPEG data and marking the target JPEG data based on a preset segmentation length in units of target minimum coding units (MCUs) to obtain target JPEG segmented data; adjacent segmented data in the target JPEG segmented data have an overlapping part; wherein the target MCUs comprise a plurality of target discrete cosine unit (DCUs); storing the target JPEG segmented data to the target SVM to enable the target GPU to perform initial Huffman decoding on the target JPEG segmented data to obtain a plurality of initial decoded segments and synchronization parameter information; adjacent initial decoded segments of the plurality of initial decoded segments have an overlapping part when the plurality of initial decoded segments are correctly decoded; in response to determining that the plurality of initial decoded segments are all correctly decoded based on decoding results of the plurality of initial decoded segments, determining whether a quantity of target MCUs corresponding to the plurality of initial decoded segments meets a preset quantity condition, and if so, sending a target decoding instruction to the target GPU to enable the target GPU to perform target Huffman decoding on the plurality of initial decoded segments according to the target decoding instruction to obtain a plurality of target decoded segments; decoding each target DCU included in each target decoded segment to obtain target JPEG decoded data, and storing the target JPEG decoded data to the target SVM to enable the target GPU to sequentially perform a plurality of preset post-processing on the target JPEG decoded data to obtain an RGB image corresponding to the target JPEG decoded data.
2. The method of claim 1, wherein, The preset quantity condition is a condition that the quantity of target MCUs corresponding to the plurality of initial decoded segments is equal to a quantity of target MCUs corresponding to the target JPEG data; The determination of whether the quantity of target MCUs corresponding to the plurality of initial decoded segments meets the preset quantity condition comprises: acquiring the quantity of target MCUs corresponding to the plurality of initial decoded segments and the quantity of target MCUs corresponding to the target JPEG data, and determining whether the quantity of target MCUs corresponding to the plurality of initial decoded segments is equal to the quantity of target MCUs corresponding to the target JPEG data.
3. The method of claim 1, wherein, The decoding of each target DCU included in each target decoded segment comprises: acquiring a direct current coefficient corresponding to each target DCU; decoding each target DCU based on the direct current coefficient corresponding to each target DCU to obtain target JPEG decoded data.
4. The method of claim 1, wherein, The synchronization parameter information comprises a plurality of initial decoded segment identifiers and target MCU start positions corresponding to each initial decoded segment. After obtaining the plurality of initial decoded segments and the synchronization parameter information, the method further comprises: acquiring 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 the synchronization parameter information; determining whether the second initial decoded segment overlaps with the first initial decoded segment according to a target MCU start position corresponding to the first initial decoded segment and a target MCU start position corresponding to the second initial decoded segment; if yes, determining that the second initial decoded segment is decoded correctly, and sequentially determining whether multiple initial decoded segments are all decoded correctly according to the above steps of acquiring and determining.
5. The method of claim 4, wherein, after determining whether the multiple initial decoded segments are all decoded correctly, further comprising: in response to determining that there is at least one initial decoded segment decoded incorrectly, 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; based on the next segment length, marking the target JPEG data 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 a target MCU quantity corresponding to the multiple next initial decoded segments satisfies a preset quantity condition, if yes, 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 at least one next initial decoded segment decoded incorrectly, performing the steps of acquiring target JPEG data and the subsequent steps again until all are decoded correctly.
6. The method of claim 5, wherein, after obtaining the multiple next initial decoded segments and the next synchronization parameter information, further comprising: determining 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.
7. The method according to claim 1 or 5, characterized in that, after determining whether the target MCU quantity corresponding to the multiple initial decoded segments satisfies the preset quantity condition, or determining whether the target MCU quantity corresponding to the multiple next initial decoded segments satisfies the preset quantity condition, further comprising: if no, acquiring target JPEG data again, and determining another segment length based on a preset segment length; determining whether multiple another initial decoded segments are all decoded correctly according to the target JPEG data and the another segment length, and determining whether a target MCU quantity corresponding to the multiple another initial decoded segments satisfies a preset quantity condition when correct; if no, performing the above steps of acquiring and determining in a loop until it is determined that the preset quantity condition is satisfied.
8. A JPEG data decoding apparatus characterized by comprising: comprising: an acquisition module, configured to acquire target JPEG data; a marking module, configured to mark the target JPEG data in units of target MCUs based on a preset segment length to obtain target JPEG segment data; there is an overlapping part between adjacent marked segment data in the target JPEG segment data; wherein, a target MCU includes multiple target DCUs; The storage module is configured to store the target JPEG segmented data to a target SVM, so that a 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, there is an overlapping part between adjacent initial decoded segments; The judgment module is configured to determine, in response to a decoding result of the plurality of initial decoded segments, whether a target MCU quantity corresponding to the plurality of initial decoded segments satisfies a preset quantity condition; The sending module is configured to send a target decoding instruction to the 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, if the target MCU quantity satisfies the preset quantity condition; The decoding module is configured to decode each target DCU included in each target decoded segment to obtain target JPEG decoded data; The storage module is further configured to store the target JPEG decoded data to the target SVM, so that the target GPU sequentially performs a plurality of 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, comprising: Comprise: A target CPU, a memory and a target GPU in communication connection with the target CPU; The memory stores computer execution instructions; the target GPU is configured to perform Huffman decoding on a plurality of to-be-decoded segments and sequentially perform a plurality of preset post-processing on target JPEG decoded data; The target CPU executes the computer execution instructions stored in the memory to implement the method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to implement the method of any one of claims 1 to 7.
Citation Information
Patent Citations
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
Cited By
A video frame zero-copy decoding rendering method, system, medium and product
CN122395375A