Decoding method and electronic equipment

By constructing a correspondence table between Huffman codes and additional bit lengths, the problem of low decoding efficiency of JPEG format images can be solved by directly querying the additional bit lengths, thus achieving a more efficient decoding process.

CN121967704APending Publication Date: 2026-05-01VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
VIVO MOBILE COMM CO LTD
Filing Date
2026-01-09
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

The current technology has low decoding efficiency for JPEG format images, mainly because the additional bit length needs to be calculated multiple times during the decoding process.

Method used

By constructing a correspondence table between Huffman codes and additional bit lengths, the additional bit length corresponding to the first Huffman code can be directly queried, thereby reducing the number of calculations and judgment logic, and improving the efficiency of determining the additional bit length.

Benefits of technology

It significantly improves the decoding efficiency of JPEG format images, simplifies the calculation process, and increases the decoding speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121967704A_ABST
    Figure CN121967704A_ABST
Patent Text Reader

Abstract

The invention discloses a decoding method and electronic equipment. Belongs to the technical field of image processing. The embodiment of the method comprises the following steps: reading a first Huffman code of a first coding unit from a coding bit stream of a JPEG (Joint Photographic Experts Group) format image; a first additional bit length corresponding to the first Huffman code is inquired from a corresponding relation table, and the corresponding relation table is used for storing the corresponding relation between the Huffman code and the additional bit length; reading additional bit data from the coded bit stream based on the first additional bit length, and determining a discrete cosine transform (DCT) coefficient based on the first additional bit length and the additional bit data; and generating image data of the JPEG format image based on the DCT coefficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, specifically to decoding methods and electronic devices. Background Technology

[0002] With the development of the Internet, the JPEG (Joint Photographic Experts Group) format has occupied an important position in the field of image storage and transmission due to its good compatibility and compression efficiency. However, as image resolution continues to increase, traditional decoding methods have gradually revealed efficiency bottlenecks when processing high-resolution images.

[0003] In existing technologies, multiple calculations are required during the decoding process to determine the additional bit length, resulting in low decoding efficiency for JPEG format images. Summary of the Invention

[0004] The purpose of this application is to provide a decoding method and electronic device that can improve the decoding efficiency of JPEG format images.

[0005] In a first aspect, embodiments of this application provide a decoding method, the method comprising: reading a first Huffman code of a first coding unit from an encoded bitstream of a JPEG format image; querying a first additional bit length corresponding to the first Huffman code from a correspondence table, the correspondence table being used to store the correspondence between Huffman codes and additional bit lengths; reading additional bit data from the encoded bitstream based on the first additional bit length, and determining discrete cosine transform (DCT) coefficients based on the first additional bit length and the additional bit data; and generating image data of the JPEG format image based on the DCT coefficients.

[0006] Secondly, embodiments of this application provide a decoding apparatus, comprising: a reading unit for reading a first Huffman code of a first encoding unit from an encoded bitstream of a JPEG format image; a query unit for querying a first additional bit length corresponding to the first Huffman code from a correspondence table, the correspondence table being used to store the correspondence between Huffman codes and additional bit lengths; a determining unit for reading additional bit data from the encoded bitstream based on the first additional bit length, and determining discrete cosine transform (DCT) coefficients based on the first additional bit length and the additional bit data; and a generating unit for generating image data of the JPEG format image based on the DCT coefficients.

[0007] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0008] Fourthly, embodiments of this application provide a readable storage medium on which a computer program is stored, and when executed by a processor, the computer program implements the steps of the method described in the first aspect above.

[0009] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method described in the first aspect.

[0010] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.

[0011] In this embodiment, the first Huffman code of the first coding unit is first read from the encoded bitstream of the JPEG format image; then, the first additional bit length corresponding to the first Huffman code is looked up from the correspondence table, which stores the correspondence between Huffman codes and additional bit lengths; subsequently, additional bit data is read from the encoded bitstream based on the first additional bit length, and the Discrete Cosine Transform (DCT) coefficients are determined based on the first additional bit length and the additional bit data; finally, the image data of the JPEG format image is generated based on the DCT coefficients. By directly looking up the first additional bit length corresponding to the first Huffman code from the correspondence table used to store the correspondence between Huffman codes and additional bit lengths, the number of calculations and judgment logic is reduced, the determination efficiency of the first additional bit length is improved, thereby improving the overall decoding efficiency of the JPEG format image. Attached Figure Description

[0012] Figure 1 This is a flowchart of the decoding method provided in the embodiments of this application; Figure 2 This is a flowchart of the decoding method provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the decoding device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application; Figure 5 This is a schematic diagram of the hardware structure of an electronic device suitable for implementing the embodiments of this application. Detailed Implementation

[0013] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0014] The terms "first," "second," etc., used in this application's specification are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, in the specification, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects have an "or" relationship.

[0015] The decoding method and apparatus provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0016] Please refer to Figure 1 This document illustrates one of the flowcharts of the decoding method provided in this application embodiment. The decoding method provided in this application embodiment can be applied to electronic devices. In practice, the aforementioned electronic devices can be smartphones, tablets, laptops, wearable devices, etc.

[0017] The decoding method provided in this application includes the following steps: Step 101: Read the first Huffman code of the first coding unit from the encoded bitstream of the JPEG format image.

[0018] In this embodiment, the encoded bitstream refers to a compressed data stream conforming to the JPEG standard. It consists of continuous binary bits and contains all the information of the image after discrete cosine transform, quantization, and entropy coding. The JPEG standard is a commonly used still image compression standard, officially designated ISO / IEC 10918-1. In practice, files in .jpg or .jpeg format are image files compressed according to this standard. The JPEG standard defines the entire encoding and decoding process, including discrete cosine transform, quantization, and entropy coding.

[0019] An encoded bitstream may include multiple encoded units. An encoded unit is a binary sequence consisting of a Huffman code and its corresponding additional bits during Huffman decoding. The first encoded unit is the unit currently being decoded.

[0020] The Huffman code in the first coding unit can be called the first Huffman code. The first Huffman code refers to the Huffman code read starting from the current read position in the encoded bitstream; it is a binary sequence. In practice, a binary sequence of length m bits can be extracted from the current read position in the encoded bitstream using a dynamic length read strategy, where m is a positive integer. Since Huffman codes are typically 8, 9, 10, 11, or 12 bits, the value of m can be 8, 9, 10, 11, or 12. For example, starting from the current position in the encoded bitstream, 8 bits of data can be read as the first Huffman code to perform subsequent lookup steps in the correspondence table. If no result is found, the value of m can be updated to 9, and 9 bits of data can be read as the first Huffman code to perform subsequent lookup steps in the correspondence table, and so on, until a result is obtained.

[0021] The additional bits in the first Huffman code are the binary sequence immediately following it. These additional bits are used to determine the specific values ​​of the DCT (Discrete Cosine Transform) coefficients. DCT is a mathematical transform widely used in digital signal processing and image compression. In JPEG compression, DCT transforms the image from the spatial domain to the frequency domain. After the transformation, the image's energy is concentrated on a few low-frequency coefficients, while high-frequency information, which is less sensitive to human vision, can be significantly compressed or even discarded, thus achieving efficient compression. The DCT coefficients are the core data directly output from the Huffman decoding process and are crucial intermediate values ​​for image reconstruction.

[0022] Step 102: Query the first additional bit length corresponding to the first Huffman code from the correspondence table. The correspondence table is used to store the correspondence between Huffman codes and additional bit lengths.

[0023] In this embodiment, the correspondence table refers to a pre-constructed Huffman decoding table, which stores a large number of correspondences between Huffman codes and their additional bit lengths. The correspondence table can be pre-established before the decoding process is executed. During decoding, by using the first Huffman code as an index to query this correspondence table, the first additional bit length of the first coding unit can be obtained.

[0024] The length of the first additional bit is the length of the additional bit data in the first coding unit, which can be denoted as n. It corresponds to the SIZE value in the JPEG standard, where SIZE specifies the exact structure and meaning of subsequent data. Since the encoded bitstream consists of multiple consecutive coding units, forming a continuous series of binary bits, the length of the first additional bit must be determined first to determine the end position of the additional bit in the current decoding unit, thus obtaining the accurate additional bit data. For example, if the first Huffman code is "10110101", then "10110101" can be used as an index to look up the corresponding table and obtain the corresponding additional bit length, such as n=3.

[0025] By directly querying the length of the first additional bit corresponding to the first Huffman code from the correspondence table, the multi-step query operation required to traverse the Huffman tree to determine the length of the additional bit in the traditional method is avoided. The complex process that originally required multiple memory accesses and judgments is simplified into a single direct table lookup operation, which significantly reduces the loss of instruction-level parallelism and thus improves the execution efficiency of a single decoding operation.

[0026] Step 103: Read the additional bit data from the encoded bit stream based on the first additional bit length, and determine the Discrete Cosine Transform (DCT) coefficients based on the first additional bit length and the additional bit data.

[0027] In this embodiment, the additional bit data can first be obtained by reading n bits of data starting from the next bit of the first Huffman code in the encoded bit stream, based on the first additional bit length n obtained from the query. Then, the DCT coefficient values ​​can be calculated based on the read n additional bit data using the variable-length integer decoding rule.

[0028] For example, the sign can be determined based on the highest bit of the additional bits, and the magnitude can be calculated based on the remaining bits to finally obtain the signed DCT coefficients. For example, reading the 3 additional bits "011", where the highest bit "0" represents the negative sign, and the value of the remaining bits "11" is 3, so the calculated DCT coefficient is -3.

[0029] Step 104: Generate image data for a JPEG format image based on DCT coefficients.

[0030] In this embodiment, the decoded DCT coefficients can be filled into the corresponding frequency positions. After accumulating enough coefficients, the frequency domain coefficients are converted into spatial domain pixel values ​​through inverse discrete cosine transform, and finally the image data of the JPEG format image is reconstructed. For example, multiple DCT coefficients obtained from consecutive decodings can be filled into the frequency positions corresponding to an 8×8 block, and 64 pixel values ​​can be obtained through IDCT (Inverse Discrete Cosine Transform) to form a basic block of the image.

[0031] The method provided in the above embodiments of this application first reads the first Huffman code of the first coding unit from the encoded bitstream of the JPEG format image; then, it looks up the first additional bit length corresponding to the first Huffman code from a correspondence table, which stores the correspondence between Huffman codes and additional bit lengths; next, it reads additional bit data from the encoded bitstream based on the first additional bit length, and determines the Discrete Cosine Transform (DCT) coefficients based on the first additional bit length and the additional bit data; finally, it generates the image data of the JPEG format image based on the DCT coefficients. By directly looking up the first additional bit length corresponding to the first Huffman code from the correspondence table used to store the correspondence between Huffman codes and additional bit lengths, the number of calculations and judgment logic is reduced, the determination efficiency of the first additional bit length is improved, thereby improving the overall decoding efficiency of JPEG format images.

[0032] In some optional embodiments, the correspondence table in step 102 can be generated in advance through the following steps: Step S11: Obtain the set of Huffman codes, which includes Huffman codes of various bit lengths.

[0033] The Huffman code set contains all possible Huffman codes. Let m denote the bit length of a Huffman code. Since Huffman codes are typically 8, 9, 10, 11, 12 bits, etc., the Huffman code set can contain a set of valid Huffman codes of all possible lengths, covering Huffman codes of various bit lengths such as 8, 9, 10, 11, and 12 bits.

[0034] In practice, all valid Huffman codes can be extracted from the Huffman table data in the JPEG file header, constructing a set containing all valid Huffman codes, thus obtaining the Huffman code set. The JPEG file header is the beginning of the JPEG file; it does not contain any image pixel data itself, but rather the decoding rules and related information for subsequent image data. The encoded bitstream is the actual compressed image data that follows the file header. It is a sequence of consecutive binary bits generated by performing DCT transform, quantization, and entropy coding on image pixel blocks according to the rules defined in the file header.

[0035] Step S12: Traverse the Huffman tree to obtain the additional bit length corresponding to each Huffman code in the Huffman code set.

[0036] A Huffman tree is a binary tree data structure built according to the JPEG standard, used to determine the symbol pairs corresponding to Huffman codes of different lengths. For each Huffman code in the set of Huffman codes, its corresponding symbol pair (RUNLENGTH, SIZE) can be determined by traversing the Huffman tree. Here, RUNLENGTH is the zero-run length, and SIZE is the extra bit length. The SIZE value can be extracted from the symbol pair (RUNLENGTH, SIZE) as the extra bit length, and a correspondence between the Huffman code and the extra bit length can be established.

[0037] As an example, for the 8-bit Huffman code 10110101, the symbol pair (0,3) is obtained by traversing the Huffman tree, and the correspondence can be established as: 10110101→3; for the 9-bit Huffman code 111001010, the symbol pair (2,1) is obtained by traversing the Huffman tree, and the correspondence can be established as: 111001010→1; for the 10-bit Huffman code 1111001101, the symbol pair (5,2) is obtained by traversing the Huffman tree, and the correspondence can be established as: 1111001101→2.

[0038] Step S13: Generate a correspondence table based on the additional bit length corresponding to each Huffman code.

[0039] Here, a data structure supporting multi-length key-value queries can be created as a mapping table. All mappings established in step S12 are stored in this table. This table needs to support queries for Huffman codes of various bit lengths.

[0040] By acquiring a set of Huffman codes containing multiple lengths and systematically establishing the correspondence between each Huffman code and the additional bit length, it is ensured that the correspondence table can cover all possible valid Huffman codes in the JPEG standard, providing a complete query basis for the decoding stage, thereby ensuring the universal applicability and standard compatibility of the decoding process for various complex images.

[0041] In some alternative embodiments, see Figure 2 The operation of determining the DCT coefficients based on the first additional bit length and the additional bit data in step 102 above can further include the following steps: Step S21: Based on the first additional bit length and additional bit data, calculate the magnitude of the DCT coefficients through bit operations.

[0042] Amplitude refers to the absolute value of the Discrete Cosine Transform (DCT) coefficients, and is a key parameter for determining the magnitude of the DCT coefficients. Bitwise operations refer to operations performed directly on binary bits in a computer, including basic operations such as shifting, AND, OR, and NOT.

[0043] Specifically, the amplitude can be calculated using bitwise operation formulas, as shown below: Amplitude = (1 << (n-1)) + Additional bits Here, 1<<(n-1) is a bit left shift operation, which is equivalent to calculating 2 to the power of (n-1).

[0044] Step S22: Determine the DCT coefficients based on the amplitude.

[0045] Here, the sign of the DCT coefficients can be determined first, and then the sign can be combined with the amplitude calculated in step S22. The final DCT coefficient value can be obtained through a simple multiplication operation. If the sign is positive, the DCT coefficient is equal to the amplitude; if the sign is negative, the DCT coefficient is equal to the opposite of the amplitude.

[0046] The amplitude is calculated by performing bitwise operations based on the current number of additional bits and the remaining bits in the additional bit data excluding the highest bit. The floating-point power function pow(2, n-1) used in the traditional method is replaced with efficient integer bitwise operations: 1<<(n-1)). The floating-point function call that originally required dozens of CPU clock cycles is shortened to a bitwise operation that only requires 1 clock cycle, thereby significantly reducing the computational complexity and greatly improving the decoding speed.

[0047] In some optional embodiments, after step 103 is performed above, the following steps may also be performed: Step S31: Summing the bit length of the first Huffman code with the bit length of the first additional bit, we obtain the total bit length of the first coding unit.

[0048] The number of bits in the first Huffman code refers to the actual bit length of the first Huffman codeword read from the encoded bitstream in step 101, which can be denoted as m. The bit length m of the first Huffman code can be summed with the bit length n of the first additional bit to obtain the total bit length of the first coding unit, i.e., m+n. The total bit length of the first coding unit represents the total number of bits occupied by the first coding unit in the encoded bitstream.

[0049] Step S32: Based on the total bit length, locate the second coding unit of the encoded bit stream. The second coding unit is the next coding unit after the first coding unit.

[0050] The second coding unit refers to the decoding unit consisting of the next Huffman codeword and its additional bit data immediately following the first coding unit. In practice, a bitstream read pointer can be maintained, pointing to the position of the currently processed bit. Based on the calculated total number of bits, the read pointer is moved forward by the corresponding number of bits, so that the pointer accurately points to the starting position of the next coding unit. This operation can be implemented using bit pointer arithmetic. Similar to the first coding unit, the second coding unit may also include Huffman code and additional bit data. This Huffman code can be called the second Huffman code, and the bit length of the additional bit data can be called the second additional bit length.

[0051] By directly locating the second encoding unit of the encoded bitstream based on the total number of bits, the multiple and scattered pointer update operations in the traditional method are integrated into a one-time precise location, eliminating the precision error and boundary condition judgment caused by the accumulation of multiple bit operations, thereby ensuring the continuity and stability of the decoding process in complex bitstream environments.

[0052] It should be noted that the decoding method provided in this application can be executed by a decoding device. This application uses the example of a decoding device executing the decoding method to illustrate the decoding device provided in this application.

[0053] like Figure 3 As shown, the decoding device 300 of this embodiment includes: a reading unit 301, used to read the first Huffman code of the first encoding unit from the encoded bitstream of the JPEG format image; a query unit 302, used to query the first additional bit length corresponding to the first Huffman code from a correspondence table, the correspondence table being used to store the correspondence between the Huffman code and the additional bit length; a determining unit 303, used to read additional bit data from the encoded bitstream based on the first additional bit length, and determine the discrete cosine transform (DCT) coefficients based on the first additional bit length and the additional bit data; and a generating unit 304, used to generate image data of the JPEG format image based on the DCT coefficients.

[0054] In some optional implementations of this embodiment, the correspondence table is generated through the following steps: obtaining a set of Huffman codes, which includes Huffman codes of various bit lengths; traversing the Huffman tree to obtain the additional bit length corresponding to each Huffman code in the set; and generating the correspondence table based on the additional bit length corresponding to each Huffman code. By obtaining a set of Huffman codes containing multiple lengths and systematically establishing the correspondence between each Huffman code and its additional bit length, it is ensured that the correspondence table can cover all possible valid Huffman codes in the JPEG standard, providing a complete query basis for the decoding stage, thereby ensuring the universal applicability and standard compatibility of the decoding process for various complex images.

[0055] In some optional implementations of this embodiment, the device further includes a positioning unit, configured to: sum the bit length of the first Huffman code with the first additional bit length to obtain the total bit length of the first coding unit; and, based on the total bit length, locate the second coding unit of the coded bit stream, wherein the second coding unit is the next coding unit after the first coding unit. By directly locating the second coding unit of the coded bit stream based on the total bit length, the multiple, scattered pointer update operations in traditional methods are integrated into a one-time precise positioning, eliminating the precision errors and boundary condition judgments caused by the accumulation of multiple bit operations, thereby ensuring the continuity and stability of the decoding process in complex bit stream environments.

[0056] In some optional implementations of this embodiment, the determining unit 103 is further configured to: calculate the magnitude of the DCT coefficients through bitwise operations based on the first additional bit length and the additional bit data; and determine the DCT coefficients based on the magnitude. By calculating the magnitude through bitwise operations based on the current number of additional bits and the remaining bits in the additional bit data excluding the highest bit, the floating-point power function pow(2, n-1) used in the traditional method is replaced with efficient integer bitwise operations: 1<<(n-1)). This shortens the floating-point function call that originally required tens of CPU clock cycles to a bitwise operation that only requires one clock cycle, thereby significantly reducing computational complexity and greatly improving decoding speed.

[0057] The apparatus provided in the above embodiments of this application first reads the first Huffman code of the first coding unit from the encoded bitstream of the JPEG format image; then, it looks up the first additional bit length corresponding to the first Huffman code from a correspondence table, which stores the correspondence between Huffman codes and additional bit lengths; next, it reads additional bit data from the encoded bitstream based on the first additional bit length, and determines the Discrete Cosine Transform (DCT) coefficients based on the first additional bit length and the additional bit data; finally, it generates the image data of the JPEG format image based on the DCT coefficients. By directly looking up the first additional bit length corresponding to the first Huffman code from the correspondence table used to store the correspondence between Huffman codes and additional bit lengths, the number of calculations and judgment logic is reduced, the determination efficiency of the first additional bit length is improved, thereby improving the overall decoding efficiency of JPEG format images.

[0058] The decoding device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.

[0059] The decoding device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.

[0060] The decoding device provided in this application embodiment can achieve... Figure 1 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.

[0061] Optionally, such as Figure 4 As shown, this application embodiment also provides an electronic device 400, including a processor 401 and a memory 402. The memory 402 stores a program or instructions that can run on the processor 401. When the program or instructions are executed by the processor 401, they implement the various steps of the above-described decoding method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.

[0062] It should be noted that the electronic devices in the embodiments of this application include the aforementioned mobile electronic devices and non-mobile electronic devices.

[0063] Figure 5 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application. The electronic device 500 includes, but is not limited to, components such as: radio frequency unit 501, network module 502, audio output unit 503, input unit 504, sensor 505, display unit 506, user input unit 507, interface unit 508, memory 509, and processor 510.

[0064] Those skilled in the art will understand that the electronic device 500 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 510 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 5 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here. The processor 510 is configured to read the first Huffman code of the first coding unit from the encoded bitstream of the JPEG format image; query the first additional bit length corresponding to the first Huffman code from the correspondence table, the correspondence table being used to store the correspondence between the Huffman code and the additional bit length; read additional bit data from the encoded bitstream based on the first additional bit length, and determine the discrete cosine transform (DCT) coefficients based on the first additional bit length and the additional bit data; and the generation unit 304 is configured to generate image data of the JPEG format image based on the DCT coefficients.

[0065] By directly querying the first additional bit length corresponding to the first Huffman code from the correspondence table used to store the correspondence between Huffman codes and additional bit lengths, the number of calculations and judgment logic is reduced, the efficiency of determining the first additional bit length is improved, and thus the overall decoding efficiency of JPEG format images is improved.

[0066] In some optional implementations of this embodiment, the correspondence table is generated through the following steps: obtaining a set of Huffman codes, which includes Huffman codes of various bit lengths; traversing the Huffman tree to obtain the additional bit length corresponding to each Huffman code in the set; and generating the correspondence table based on the additional bit length corresponding to each Huffman code. By obtaining a set of Huffman codes containing multiple lengths and systematically establishing the correspondence between each Huffman code and its additional bit length, it is ensured that the correspondence table can cover all possible valid Huffman codes in the JPEG standard, providing a complete query basis for the decoding stage, thereby ensuring the universal applicability and standard compatibility of the decoding process for various complex images.

[0067] In some optional implementations of this embodiment, the processor 510 is further configured to sum the bit length of the first Huffman code with the bit length of the first additional bit to obtain the total bit length of the first coding unit; based on the total bit length, locate the second coding unit of the coded bit stream, wherein the second coding unit is the next coding unit after the first coding unit. By directly locating the second coding unit of the coded bit stream based on the total bit length, the multiple and scattered pointer update operations in the traditional method are integrated into a one-time precise location, eliminating the precision error and boundary condition judgment caused by the accumulation of multiple bit operations, thereby ensuring the continuity and stability of the decoding process in complex bit stream environments.

[0068] In some optional implementations of this embodiment, the processor 510 is further configured to calculate the magnitude of the DCT coefficients through bitwise operations based on the first additional bit length and the additional bit data; and determine the DCT coefficients based on the magnitude. By calculating the magnitude based on bitwise operations performed on the current number of additional bits and the remaining bits in the additional bit data excluding the highest bit, the floating-point power function pow(2, n-1) used in the traditional method is replaced with efficient integer bitwise operations: 1<<(n-1)), which shortens the floating-point function call that originally required tens of CPU clock cycles to a bitwise operation that only requires 1 clock cycle, thereby significantly reducing the computational complexity and greatly improving the decoding speed.

[0069] It should be understood that, in this embodiment, the input unit 504 may include a graphics processing unit (GPU) 5041 and a microphone 5042. The GPU 5041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 507 includes at least one of a touch panel 5071 and other input devices 5072. The touch panel 5071 is also called a touch screen. The touch panel 5071 may include a touch detection device and a touch controller. Other input devices 5072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.

[0070] The memory 509 can be used to store software programs and various data. The memory 509 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 509 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 509 in this embodiment includes, but is not limited to, these and any other suitable types of memory.

[0071] Processor 510 may include one or more processing units; optionally, processor 510 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 510.

[0072] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described decoding method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0073] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0074] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described decoding method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0075] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0076] This application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the various processes of the decoding method embodiments described above, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0077] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0078] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0079] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A decoding method, characterized in that, The method includes: Read the first Huffman code of the first coding unit from the encoded bitstream of the Joint Picture Experts Group JPEG format image; From the correspondence table, query the first additional bit length corresponding to the first Huffman code. The correspondence table is used to store the correspondence between Huffman codes and additional bit lengths. Additional bit data is read from the encoded bit stream based on the first additional bit length, and the Discrete Cosine Transform (DCT) coefficients are determined based on the first additional bit length and the additional bit data. Image data for the JPEG format image is generated based on the DCT coefficients.

2. The method according to claim 1, characterized in that, The correspondence table is generated through the following steps: Obtain a set of Huffman codes, which includes Huffman codes of various bit lengths; Traverse the Huffman tree to obtain the additional bit length for each Huffman code in the set of Huffman codes; The correspondence table is generated based on the additional bit length corresponding to each Huffman code.

3. The method according to claim 1, characterized in that, After determining the Discrete Cosine Transform (DCT) coefficients based on the first additional bit length and the additional bit data, the method further includes: The total bit length of the first coding unit is obtained by summing the bit length of the first Huffman code with the bit length of the first additional bit. Based on the total bit length, the second coding unit of the encoded bit stream is located, and the second coding unit is the next coding unit after the first coding unit.

4. The method according to claim 1, characterized in that, The step of determining the Discrete Cosine Transform (DCT) coefficients based on the first additional bit length and the additional bit data includes: Based on the first additional bit length and the additional bit data, the magnitude of the DCT coefficient is calculated through bit operations; The DCT coefficients are determined based on the amplitude.

5. A decoding device, characterized in that, The device includes: The read unit is used to read the first Huffman code of the first encoding unit from the encoded bitstream of the JPEG format image; The query unit is used to query the first additional bit length corresponding to the first Huffman code from the correspondence table, wherein the correspondence table is used to store the correspondence between Huffman codes and additional bit lengths. The determining unit is configured to read additional bit data from the encoded bit stream based on the first additional bit length, and determine the discrete cosine transform (DCT) coefficients based on the first additional bit length and the additional bit data. The generation unit is used to generate image data of the JPEG format image based on the DCT coefficients.

6. The apparatus according to claim 5, characterized in that, The correspondence table is generated through the following steps: Obtain a set of Huffman codes, which includes Huffman codes of various bit lengths; Traverse the Huffman tree to obtain the additional bit length for each Huffman code in the set of Huffman codes; The correspondence table is generated based on the additional bit length corresponding to each Huffman code.

7. The apparatus according to claim 5, characterized in that, The device further includes a positioning unit for: The total bit length of the first coding unit is obtained by summing the bit length of the first Huffman code with the bit length of the first additional bit. Based on the total bit length, the second coding unit of the encoded bit stream is located, and the second coding unit is the next coding unit after the first coding unit.

8. The apparatus according to claim 5, characterized in that, The determining unit is further configured to: Based on the first additional bit length and the additional bit data, the magnitude of the DCT coefficient is calculated through bit operations; The DCT coefficients are determined based on the amplitude.

9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the decoding method as described in any one of claims 1-4.

10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the decoding method as described in any one of claims 1-4.